sp614x / optifine

1.81k stars 416 forks source link

[Shaders] Shadow terrain lag #6560

Open sonicether opened 2 years ago

sonicether commented 2 years ago

The terrain as rendered through the shadow program seems to be 1 frame late. So, when placing a block or other terrain changes happen, it takes a frame to see these changes in the shaders. Entities do not have this issue. Additionally, the existence of any "shadowcomp" programs seems to increase this lag to 2 frames.

To reproduce, just load any shader that renders shadows, set your max frame rate to 5, and place a block down, and notice how first, the block appears in your view casting no shadow, and then on the next frame, the shadow appears.

All versions of OptiFine seem to have this issue.

Also, any uniforms that come into the shadow programs don't seem to be 1 frame behind (variables like cameraPosition), but the terrain that is rendered is.

My best guess is that the terrain is being rendered through the shadow program after all other gbuffer, deferred, and composite programs? Not sure why another frame of lag is introduced with the existence of a shadowcomp program.

sp614x commented 2 years ago

The shadow pass runs before the normal rendering pass. The chunk GPU uploads run in the normal rendering pass after the camera setup and before the terrain rendering. It is normal that the terrain appears in the shadowmap in the next frame. Shadowcomp programs shouldn't add more lag as all composites are finished at the end of the frame.