EEVEE Next: Tag shadowmap usage for transparent object volumes #104580

Merged
Miguel Pozo merged 31 commits from pragma37/blender:pull-eevee-shadows-tag-usage-transparent into main 2023-03-08 13:51:35 +01:00
3 changed files with 11 additions and 10 deletions
Showing only changes of commit b387a90985 - Show all commits

View File

@ -57,14 +57,8 @@ void main()
vec3 near_plane_os = point_world_to_object(near_plane_ws);
vec3 view_direction_os = normalize(point_world_to_object(interp.P) - near_plane_os);
const ObjectBounds bounds = bounds_buf[resource_id];
vec3 aabb_min_os = point_world_to_object(bounds.bounding_corners[0].xyz);
vec3 aabb_max_os = point_world_to_object(
bounds.bounding_corners[0].xyz + bounds.bounding_corners[1].xyz +
bounds.bounding_corners[2].xyz + bounds.bounding_corners[3].xyz);
float near_box_t_os = ray_aabb(near_plane_os, view_direction_os, aabb_min_os, aabb_max_os);
float near_box_t_os = ray_aabb(
near_plane_os, view_direction_os, interp.aabb_min_os, interp.aabb_max_os);
pragma37 marked this conversation as resolved

Be conservative in Z too. Bias far_box_t by step_size to have one more iteration before and after.

This is for the same issue as the full 1px inflate.

Be conservative in Z too. Bias `far_box_t` by step_size to have one more iteration before and after. This is for the same issue as the full 1px inflate.
vec3 near_box_os = near_plane_os + view_direction_os * near_box_t_os;
vec3 near_box_ws = point_object_to_world(near_box_os);

View File

@ -12,7 +12,7 @@ void main()
{
PASS_RESOURCE_ID
ObjectBounds bounds = bounds_buf[resource_id];
const ObjectBounds bounds = bounds_buf[resource_id];
interp.P = bounds.bounding_corners[0].xyz;
interp.P += bounds.bounding_corners[1].xyz * max(0, pos.x);
@ -20,5 +20,10 @@ void main()
interp.P += bounds.bounding_corners[3].xyz * max(0, pos.z);
interp.vP = point_world_to_view(interp.P);
pragma37 marked this conversation as resolved

I think we need a fullpixel here.

Imagine a really tiny box.

      tagged    |   not tagged    < Tiles tagging. Tilemap boundary at the middle
 --------------T|---------------  < the shadow tilemap at the correct LOD
            |----x----|           < the half inflated bounds (covers 1 pixel)
                 x                < the object (infinitesimal)
|----x----|----x----|----x----|   < Screen LOD where we raster the bboxes

A tile map boundary cannot be mitigated by tagging a lower LOD selection.

Inflating a whole pixel:

      tagged    |    tagged       < Tiles tagging. Tilemap boundary at the middle
 --------------T|--------T------  < the shadow tilemap at the correct LOD
       |---------x--------|       < the FULL inflated bounds (covers 2 pixel)
                 x                < the object (infinitesimal)
|----x----|----x----|----x----|   < Screen LOD where we raster the bboxes
I think we need a fullpixel here. Imagine a really tiny box. ``` tagged | not tagged < Tiles tagging. Tilemap boundary at the middle --------------T|--------------- < the shadow tilemap at the correct LOD |----x----| < the half inflated bounds (covers 1 pixel) x < the object (infinitesimal) |----x----|----x----|----x----| < Screen LOD where we raster the bboxes ``` A tile map boundary cannot be mitigated by tagging a lower LOD selection. Inflating a whole pixel: ``` tagged | tagged < Tiles tagging. Tilemap boundary at the middle --------------T|--------T------ < the shadow tilemap at the correct LOD |---------x--------| < the FULL inflated bounds (covers 2 pixel) x < the object (infinitesimal) |----x----|----x----|----x----| < Screen LOD where we raster the bboxes ```
interp.aabb_min_os = point_world_to_object(bounds.bounding_corners[0].xyz);
interp.aabb_max_os = point_world_to_object(
bounds.bounding_corners[0].xyz + bounds.bounding_corners[1].xyz +
bounds.bounding_corners[2].xyz + bounds.bounding_corners[3].xyz);
pragma37 marked this conversation as resolved

This only works because max_v2 is a define. Use vs_inflate_vector.xy to avoid the confusion.
Also not entierly sure what's this about. Can you add a comment on this?

This only works because `max_v2` is a define. Use `vs_inflate_vector.xy` to avoid the confusion. Also not entierly sure what's this about. Can you add a comment on this?
gl_Position = point_world_to_ndc(interp.P);
}

View File

@ -54,7 +54,9 @@ GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_opaque)
GPU_SHADER_INTERFACE_INFO(eevee_shadow_tag_transparent_iface, "interp")
.smooth(Type::VEC3, "P")
.smooth(Type::VEC3, "vP");
.smooth(Type::VEC3, "vP")
.flat(Type::VEC3, "aabb_min_os")
.flat(Type::VEC3, "aabb_max_os");
GPU_SHADER_CREATE_INFO(eevee_shadow_tag_usage_transparent)
.do_static_compilation(true)