godot
godot copied to clipboard
Fix issue in shadow to opacity in GLES3
This fixes this bug in the GLES3 implementation of shadow to opacity:
You can test this with this shader:
shader_type spatial;
render_mode blend_mix, depth_draw_opaque, cull_back, shadow_to_opacity;
void fragment() {
ALBEDO = vec3(0.0, 0.0, 0.0);
}
Shadow to opacity is used in AR applications to render transparent geometry where there is geometry in real life. Think of a table or wall or anything like that. We render this geometry in the Opaque pass but with transparency based on how much in shadow we are.
We don't have access to ambient_light during depth passes or shadow passes hence the error. The fix now excludes our lighting check and alpha scissor check during depth/shadow pass which is correct behaviour. This allows for real live geometry to be visible through passthrough, accurately occlude other virtual geometry and casing shadows on virtual geometry.
One sec, there is more to this, there is a mismatch on the ifdefs, it shouldn't do anything with alpha during depth pass if USE_SHADOW_TO_OPACITY is set.
Ok, fixed it and tested it in passthrough in XR. So important to note that ALPHA in this case does not determine whether there is geometry or not. The geometry is fully opaque as far as depth is concerned. We are writing ALPHA because we want to see what's in the real world.
This is great! I'm using this fix on a mixed reality project I'm working on for a hackathon, you can see the result of the fix here:
Without it there's no way of hiding virtual elements that are behind real life objects. Great job!
I think this same code is in the mobile renderer too. It might need to be fixed as well
I think this same code is in the mobile renderer too. It might need to be fixed as well
oops! fixed! :)
Thanks!