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?
-
2I 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 ♦Apr 7 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.– user253751Apr 8 at 12:20
1 Answer
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.
-
10As 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
(withexecute store
) and somescoreboard players operation
s to calculate it in vanilla. Apr 8 at 3:46 -
-
1@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 knowstart
andend
of when the sun's up, you just need to find something like(now - start) / (end - start) * 180
for the angle of the sun. Jun 17 at 15:25