IrisShaders / Iris

A modern shaders mod for Minecraft compatible with existing OptiFine shader packs
https://irisshaders.dev
GNU Lesser General Public License v3.0
3.36k stars 642 forks source link

Iris should support occlusion culling in the shadow pass somehow #893

Open coderbot16 opened 3 years ago

coderbot16 commented 3 years ago

Advanced Shadow Frustum Culling in Iris 1.1.2 is pretty much the best we can do with normal frustum culling techniques. Occlusion culling is needed to improve culling. Obviously, it doesn't work with voxelization. Though, it does work with the sun-bounce GI in SEUS.

IMS212 commented 3 years ago

Some info about how Canvas does this was explained by grondag in the caffeine server: “Canvas uses two additional occlusion rasters for shadow pass - the first (lets call it A) is visible world geometry in ortho projection. Occluders that are drawn to the perspective-projection rasterizer are also drawn to A. The second raster (B) contains shadowing occluders, also drawn in ortho projection. Occluders in B are sorted starting from the light source. (Ortho sorting can be less expensive than perspective - it is essentially step-wise iteration in three dimensions.)

Each potential shadow occluder is first compared against A. (You could still use your nice extruded frustum test as a pre-filter, though I haven't tried that yet.) If the occluder doesn't intersect with any part of A, then it cannot occlude anything in view and is discarded. If it does intersect with A, then we try to draw it on B. If all covered pixels were already filled in B, then the occluder was already fully in shadow and can be discarded. If any pixel was filled, then the occluder should be part of the shadow pass.

This is efficient but not perfect. If you are standing in a fully-enclosed cave looking towards the sun (which you cannot see), the process will still iterate from the sun all the way down to the exterior surface of the cave. It does give the correct result - that your view is entirely in shadow - but it seems relatively expensive in the nominal case. “