# Is it possible to get the angle of the Sun to a block in Minecraft?

Minecraft has shadows in some of the shaders, and the shadows are obviously created via the positon of the sun or by timing. So is there a way to actually get this angle of elevation from the ground of specific coordinates to the sun? Or, is it possible to get the shadow length of a block?

• I think your assumption might be wrong. I could see that it doesn't take into consideration the position of the sun, but actually the current game time and if the block is within sunlight. (For the default shader). Been a while since I played Minecraft, but I would guess that if it was really calculating a shadow from the placement of the sun, it could calculate a shadow with a torch, which, if I remember right it doesnt. But I'm very much out of my depth and might be totally wrong.
– Fredy31
Commented Apr 7, 2022 at 14:17
• @Fredy31 in computer graphics, calculating shadows from a number of different lights is substantially harder than just calculating shadows from just one light, and calculating shadow from a sun-style light (directional, no location) is also easier. Commented Apr 8, 2022 at 12:20

If you are talking about shaders as in shadermod/Iris/OptiFine shaders, those talk to the OpenGL graphics library directly and get the angle from their respective mod like this from the Iris mod. There is currently no direct way to fetch the sun's angle with a command in the vanilla game.

• As far as I'm aware the sun's position is based entirely on the time of day, so you could possibly use `time query daytime` (with `execute store`) and some `scoreboard players operation`s to calculate it in vanilla. Commented Apr 8, 2022 at 3:46
• @RadvylfPrograms your a programmer! Have you tried your idea yet? Thanks Commented Jun 17, 2022 at 8:16
• @DialFrost I haven't tried it, but the angle should just be proportional to the `daytime` as long as its between two values. You'd have to do some experimenting to figure out what those are, but once you know `start` and `end` of when the sun's up, you just need to find something like `(now - start) / (end - start) * 180` for the angle of the sun. Commented Jun 17, 2022 at 15:25