Fix #119800: EEVEE-Next: Planar probe debug display #120011

Merged
Jeroen Bakker merged 4 commits from Jeroen-Bakker/blender:eevee-next/fixes/119800 into main 2024-03-28 15:15:19 +01:00
4 changed files with 32 additions and 5 deletions

View File

@ -150,7 +150,11 @@ void PlanarProbeModule::viewport_draw(View &view, GPUFrameBuffer *view_fb)
DRW_STATE_DEPTH_LESS_EQUAL | DRW_STATE_CULL_BACK);
viewport_display_ps_.framebuffer_set(&view_fb);
viewport_display_ps_.shader_set(inst_.shaders.static_shader_get(DISPLAY_PROBE_PLANAR));
bind_resources(viewport_display_ps_);
SphereProbeData &world_data = *static_cast<SphereProbeData *>(&inst_.light_probes.world_sphere_);
viewport_display_ps_.push_constant("world_coord_packed",
reinterpret_cast<int4 *>(&world_data.atlas_coord));
viewport_display_ps_.bind_resources(*this);
viewport_display_ps_.bind_resources(inst_.sphere_probes);
viewport_display_ps_.bind_ssbo("display_data_buf", display_data_buf_);
viewport_display_ps_.draw_procedural(GPU_PRIM_TRIS, 1, display_data_buf_.size() * 6);

View File

@ -2,9 +2,24 @@
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#pragma BLENDER_REQUIRE(draw_view_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_reflection_probe_lib.glsl)
void main()
{
vec2 uv = gl_FragCoord.xy / vec2(textureSize(planar_radiance_tx, 0).xy);
out_color = texture(planar_radiance_tx, vec3(uv, probe_index));
float depth = texture(planar_depth_tx, vec3(uv, probe_index)).r;
if (depth == 1.0) {
vec3 ndc = drw_screen_to_ndc(vec3(uv, 0.0));
vec3 wP = drw_point_ndc_to_world(ndc);
vec3 V = drw_world_incident_vector(wP);
vec3 R = -reflect(V, probe_normal);
SphereProbeUvArea world_atlas_coord = reinterpret_as_atlas_coord(world_coord_packed);
out_color = reflection_probes_sample(R, 0.0, world_atlas_coord);
}
else {
out_color = texture(planar_radiance_tx, vec3(uv, probe_index));
}
out_color.a = 0.0;
}

View File

@ -22,8 +22,10 @@ void main()
probe_index = display_data_buf[display_index].probe_index;
vec3 P = transform_point(display_data_buf[display_index].plane_to_world, vec3(lP, 0.0));
mat4 plane_to_world = display_data_buf[display_index].plane_to_world;
probe_normal = safe_normalize(plane_to_world[2].xyz);
vec3 P = transform_point(plane_to_world, vec3(lP, 0.0));
gl_Position = drw_point_world_to_homogenous(P);
/* Small bias to let the probe draw without Z-fighting. */
gl_Position.z -= 0.0001;

View File

@ -78,10 +78,16 @@ GPU_SHADER_CREATE_INFO(eevee_display_probe_reflection)
.fragment_out(0, Type::VEC4, "out_color")
.do_static_compilation(true);
GPU_SHADER_INTERFACE_INFO(eevee_display_probe_planar_iface, "").flat(Type::INT, "probe_index");
GPU_SHADER_INTERFACE_INFO(eevee_display_probe_planar_iface, "")
.flat(Type::VEC3, "probe_normal")
.flat(Type::INT, "probe_index");
GPU_SHADER_CREATE_INFO(eevee_display_probe_planar)
.additional_info("eevee_shared", "draw_view", "eevee_lightprobe_planar_data")
.push_constant(Type::IVEC4, "world_coord_packed")
.additional_info("eevee_shared",
"draw_view",
"eevee_lightprobe_planar_data",
"eevee_reflection_probe_data")
.storage_buf(0, Qualifier::READ, "PlanarProbeDisplayData", "display_data_buf[]")
.vertex_source("eevee_display_probe_planar_vert.glsl")
.vertex_out(eevee_display_probe_planar_iface)