EEVEE Next: Tag shadowmap usage for transparent object volumes #104580
|
@ -1153,8 +1153,6 @@ void ShadowModule::set_view(View &view)
|
|||
|
||||
void ShadowModule::debug_draw(View &view, GPUFrameBuffer *view_fb)
|
||||
{
|
||||
// GPU_texture_copy(inst_.render_buffers.combined_tx, usage_tag_debug_tx_);
|
||||
|
||||
if (!ELEM(inst_.debug_mode,
|
||||
eDebugMode::DEBUG_SHADOW_TILEMAPS,
|
||||
eDebugMode::DEBUG_SHADOW_VALUES,
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
* Virtual shadowmapping: Usage tagging
|
||||
*
|
||||
* Shadow pages are only allocated if they are visible.
|
||||
* This pass scan the depth buffer and tag all tiles that are needed for light shadowing as
|
||||
* needed.
|
||||
* This ray-marches the object bounds and tags all tiles that are needed for light shadowing.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(eevee_shadow_tag_usage_lib.glsl)
|
||||
|
@ -43,16 +42,11 @@ float pixel_size_at(float linear_depth)
|
|||
float pixel_size = pixel_world_radius;
|
||||
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
|
||||
if (is_persp) {
|
||||
pixel_size *= linear_depth;
|
||||
pixel_size *= max(0.01, linear_depth);
|
||||
}
|
||||
return pixel_size * exp2(fb_lod);
|
||||
}
|
||||
|
||||
float step_size_at(float linear_depth)
|
||||
{
|
||||
return max(0.01, pixel_size_at(linear_depth));
|
||||
}
|
||||
|
||||
void step_bounding_sphere(vec3 vs_near_plane,
|
||||
vec3 vs_view_direction,
|
||||
float near_t,
|
||||
|
@ -97,6 +91,9 @@ void main()
|
|||
vec3 ls_near_plane = point_world_to_object(ws_near_plane);
|
||||
vec3 ls_view_direction = normalize(point_world_to_object(interp.P) - ls_near_plane);
|
||||
|
||||
/* TODO (Miguel Pozo): We could try to ray-cast against the non-inflated bounds first,
|
||||
* and fallback to the inflated ones if theres no hit.
|
||||
* The inflated bounds can cause unnecesary extra steps. */
|
||||
float ls_near_box_t = ray_aabb(
|
||||
ls_near_plane, ls_view_direction, interp.ls_aabb_min, interp.ls_aabb_max);
|
||||
vec3 ls_near_box = ls_near_plane + ls_view_direction * ls_near_box_t;
|
||||
|
@ -107,15 +104,14 @@ void main()
|
|||
/* Depth test. */
|
||||
far_box_t = min(far_box_t, distance(ws_near_plane, ws_opaque));
|
||||
|
||||
/* Ray march from the front to the back of the bbox, and tag shadow usage along the way. */
|
||||
float step_size;
|
||||
for (float t = near_box_t; t <= far_box_t; t += step_size) {
|
||||
/* Ensure we don't get past far_box_t. */
|
||||
t = min(t, far_box_t);
|
||||
step_size = pixel_size_at(t);
|
||||
|
||||
vec3 P = ws_near_plane + (ws_view_direction * t);
|
||||
vec3 vP = vs_near_plane + (vs_view_direction * t);
|
||||
step_size = step_size_at(t);
|
||||
|
||||
float step_radius;
|
||||
step_bounding_sphere(vs_near_plane, vs_view_direction, t, t + step_size, P, step_radius);
|
||||
vP = point_world_to_view(vP);
|
||||
|
|
|
@ -3,8 +3,7 @@
|
|||
* Virtual shadowmapping: Usage tagging
|
||||
*
|
||||
* Shadow pages are only allocated if they are visible.
|
||||
* This pass scan the depth buffer and tag all tiles that are needed for light shadowing as
|
||||
* needed.
|
||||
* This contains the common logic used for tagging shadows for opaque and transparent receivers.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_intersect_lib.glsl)
|
||||
|
@ -152,22 +151,6 @@ void shadow_tag_usage_tilemap_punctual(uint l_idx, vec3 P, vec3 V, float dist_to
|
|||
}
|
||||
}
|
||||
|
||||
void shadow_tag_usage(vec3 vP, vec3 P, vec2 pixel)
|
||||
{
|
||||
/* TODO (Miguel Pozo): Is this correct for orto view? */
|
||||
float dist_to_cam = length(vP);
|
||||
|
||||
LIGHT_FOREACH_BEGIN_DIRECTIONAL (light_cull_buf, l_idx) {
|
||||
shadow_tag_usage_tilemap_directional(l_idx, P, vec3(0), dist_to_cam, 0);
|
||||
}
|
||||
LIGHT_FOREACH_END
|
||||
|
||||
LIGHT_FOREACH_BEGIN_LOCAL (light_cull_buf, light_zbin_buf, light_tile_buf, pixel, vP.z, l_idx) {
|
||||
shadow_tag_usage_tilemap_punctual(l_idx, P, vec3(0), dist_to_cam, 0);
|
||||
}
|
||||
LIGHT_FOREACH_END
|
||||
}
|
||||
|
||||
void shadow_tag_usage(vec3 vP, vec3 P, vec3 V, float radius, float dist_to_cam, vec2 pixel)
|
||||
{
|
||||
LIGHT_FOREACH_BEGIN_DIRECTIONAL (light_cull_buf, l_idx) {
|
||||
|
@ -180,3 +163,11 @@ void shadow_tag_usage(vec3 vP, vec3 P, vec3 V, float radius, float dist_to_cam,
|
|||
}
|
||||
LIGHT_FOREACH_END
|
||||
}
|
||||
|
||||
void shadow_tag_usage(vec3 vP, vec3 P, vec2 pixel)
|
||||
{
|
||||
/* TODO (Miguel Pozo): Is this correct for orto view? */
|
||||
float dist_to_cam = length(vP);
|
||||
|
||||
shadow_tag_usage(vP, P, vec3(0), 0, dist_to_cam, pixel);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* Virtual shadowmapping: Usage tagging
|
||||
*
|
||||
* Shadow pages are only allocated if they are visible.
|
||||
* This renders bounding boxes for transparent objects in order to tag the correct shadows.
|
||||
* This renders the bounding boxes for transparent objects in order to tag the correct shadows.
|
||||
*/
|
||||
|
||||
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
|
||||
|
|
Loading…
Reference in New Issue