42#define default_depth -1.0f
63 SearchDebugLightCtx &,
92 [[maybe_unused]]
int4 tile_coord)
const
104 if (
tile.do_update &&
tile.is_used) {
106 return float3(0.5f, 1, 0);
113 if (
tile.is_cached) {
114 col +=
float3(0.2f, 0, 0.5f);
115 if (
tile.do_update) {
116 col +=
float3(0.8f, 0, 0);
124 if (!
tile.is_valid) {
129 SHADOW_TILEMAP_MAX_CLIPMAP_LOD :
130 SHADOW_TILEMAP_LOD));
135 if (is_sun_light(
light.type)) {
155 .debug_tilemap_index = this->debug_tilemap_index,
181 constexpr int debug_tile_size_px = 4;
183 int2 px = texel / debug_tile_size_px;
184 int tilemap = px.
x / SHADOW_TILEMAP_RES;
185 int tilemap_index =
light.tilemap_index + tilemap;
186 if ((px.
y < SHADOW_TILEMAP_RES) && (tilemap_index <=
light.tilemap_max_get())) {
187 if (do_debug_sample_tile) {
190 ShadowSamplingTile
tile = shadow_sampling_tile_unpack(
193 if (!
any(
equal(texel % (SHADOW_TILEMAP_RES * debug_tile_size_px),
int2(0)))) {
194 return {.valid =
true,
196 .color_mul =
float4(0.0f),
202 ShadowTileMapData tilemap = srt.
tilemaps_buf[tilemap_index];
204 uint2(px + SHADOW_TILEMAP_RES) % SHADOW_TILEMAP_RES, tilemap.tiles_index, 0);
207 if (!
any(
equal(texel % (SHADOW_TILEMAP_RES * debug_tile_size_px),
int2(0)))) {
208 return {.valid =
true,
210 .color_mul =
float4(0.0f),
224 uint2(coord.
tilemap_tile >> tile_samp.lod), tilemap.tiles_index,
int(tile_samp.lod));
226 return {.valid =
true,
228 .color_mul =
float4(0.5f),
238 return {.valid =
true,
239 .color_add =
float4((depth == -1.0f) ?
float3(1.0f, 0.0f, 0.0f) :
float3(1.0f / depth),
242 .color_mul =
float4(0.5f),
281 return {.valid =
true,
283 .color_mul =
float4(0.0f),
290 return {.valid =
true,
292 .color_mul =
float4(0.5f),
299 return {.valid =
true,
301 .color_mul =
float4(0.5f),
315 frag_out.color_add =
float4(0.0f);
316 frag_out.color_mul =
float4(1.0f);
323 const LightData
light = srt.debug_light_get();
325 const eDebugMode mode = eDebugMode(srt.debug_mode);
326 bool do_debug_sample_tile = mode != DEBUG_SHADOW_TILEMAPS;
329 result.valid =
false;
330 if (mode != DEBUG_SHADOW_ATOMIC_COST) {
334 if (!result.valid && depth != 1.0f) {
336 case DEBUG_SHADOW_TILEMAPS:
339 case DEBUG_SHADOW_VALUES:
342 case DEBUG_SHADOW_TILE_RANDOM_COLOR:
345 case DEBUG_SHADOW_TILEMAP_RANDOM_COLOR:
348 case DEBUG_SHADOW_ATOMIC_COST:
356 frag_out.color_add = result.color_add;
357 frag_out.color_mul = result.color_mul;
396 if (srt.debug_mode == DEBUG_IRRADIANCE_CACHE_VALIDITY) {
400 else if (srt.debug_mode == DEBUG_IRRADIANCE_CACHE_VIRTUAL_OFFSET) {
402 sample_id = vert_id / 2;
405 grid_sample.
x = (sample_id % grid_resolution.
x);
406 grid_sample.
y = (sample_id / grid_resolution.
x) % grid_resolution.
y;
407 grid_sample.
z = (sample_id / (grid_resolution.
x * grid_resolution.
y));
410 srt.grid_mat, grid_resolution, grid_sample);
413 if (srt.debug_mode == DEBUG_IRRADIANCE_CACHE_VALIDITY) {
414 v_out.interp_color =
float4(1.0f - debug_data.r, debug_data.r, 0.0f, 0.0f);
415 out_point_size = 3.0f;
416 if (debug_data.r > srt.debug_value) {
418 out_position =
float4(0.0f);
419 out_point_size = 0.0f;
423 else if (srt.debug_mode == DEBUG_IRRADIANCE_CACHE_VIRTUAL_OFFSET) {
426 out_position =
float4(0.0f);
427 out_point_size = 0.0f;
431 if ((vert_id & 1) == 1) {
433 v_out.interp_color =
float4(1.0f, 0.0f, 0.0f, 0.0f);
436 v_out.interp_color =
float4(0.0f, 0.0f, 1.0f, 0.0f);
443 out_position.
z -= 2.5e-5f;
444 out_point_size = 3.0f;
450 frag_out.out_color = v_out.interp_color;
484 v_out.surfel_index = inst_id;
485 Surfel
surfel = srt.surfels_buf[v_out.surfel_index];
488 if (vert_id == 0 &&
surfel.next > -1) {
489 Surfel surfel_next = surfels_buf[
surfel.next];
491 (surfel_next.next == -1) ?
float4(0.0f, 1.0f, 1.0f, 1.0f) :
492 float4(0.0f, 1.0f, 0.0f, 1.0f);
494 drw_ debug_line(surfel_next.position,
surfel.position, line_color);
518 float4(TBN[1] * srt.debug_surfel_radius, 0),
519 float4(TBN[2] * srt.debug_surfel_radius, 0),
522 v_out.P = (model_matrix *
float4(lP, 1)).xyz;
527 out_position.z += 2.5e-5f;
542 Surfel
surfel = srt.surfels_buf[v_out.surfel_index];
545 radiance_vis += front_face ?
surfel.radiance_direct.front :
surfel.radiance_direct.back;
546 radiance_vis += front_face ?
surfel.radiance_indirect[1].front :
547 surfel.radiance_indirect[1].back;
549 switch (eDebugMode(srt.debug_mode)) {
551 case DEBUG_IRRADIANCE_CACHE_SURFELS_NORMAL:
554 case DEBUG_IRRADIANCE_CACHE_SURFELS_CLUSTER:
557 case DEBUG_IRRADIANCE_CACHE_SURFELS_IRRADIANCE:
558 frag_out.out_color =
float4(radiance_vis.rgb, 0.0f);
560 case DEBUG_IRRADIANCE_CACHE_SURFELS_VISIBILITY:
561 frag_out.out_color =
float4(radiance_vis.aaa, 0.0f);
566 if (
distance(v_out.P,
surfel.position) > srt.debug_surfel_radius) {
592 const ::gbuffer::Layers gbuf = reader.read_layers(texel);
594 if (gbuf.has_no_closure()) {
601 float shade =
saturate(view.normal_world_to_view(gbuf.surface_N()).z);
607 float eval_cost = 0.0f;
608 for (
uchar i = 0; i < GBUFFER_LAYER_MAX; i++) {
609 switch (gbuf.layer[i].type) {
612 case CLOSURE_BSDF_MICROFACET_GGX_REFLECTION_ID:
625 switch (eDebugMode(srt.debug_mode)) {
627 case DEBUG_GBUFFER_STORAGE:
630 case DEBUG_GBUFFER_EVALUATION:
635 frag_out.color_mul =
float4(0.0f);
659 for (
int i = 1; i < HIZ_MIP_COUNT; i++) {
663 color =
float4(1.0f, 0.1f, 0.1f, 1.0f);
667 frag_out.color_add =
float4(color.rgb, 0.0f) * 0.2f;
668 frag_out.color_mul = color;
PipelineGraphic eevee_debug_gbuffer(eevee::debug_fullscreen_vert, eevee::debug::gbuffer::frag_main)
PipelineGraphic eevee_shadow_debug(eevee::debug_fullscreen_vert, eevee::debug_shadow_frag, eevee::ShadowRenderConstants{.shadow_random=false})
PipelineGraphic eevee_debug_surfels(eevee::debug::surfels::vert_main, eevee::debug::surfels::frag_main)
PipelineGraphic eevee_debug_irradiance_grid(eevee::debug::irradiance_grid::vert_main, eevee::debug::irradiance_grid::frag_main)
PipelineGraphic eevee_hiz_debug(eevee::debug_fullscreen_vert, eevee::debug::hiz::frag_main)
float3 light_world_to_local_point(LightData light, float3 point)
float3 light_world_to_local_direction(LightData light, float3 L)
int shadow_tile_offset(uint2 tile, int tiles_index, int lod)
ShadowCoordinates shadow_punctual_coordinates(LightData light, float3 lP, int face_id)
int shadow_punctual_face_index_get(float3 lL)
ShadowCoordinates shadow_directional_coordinates(LightData light, float3 lP)
uint2 shadow_tile_coord_in_atlas(uint2 tile, int tilemap_index)
ShadowSamplingTile shadow_tile_load(usampler2D tilemaps_tx, uint2 tile_co, int tilemap_index)
float3 shadow_punctual_local_position_to_face_local(int face_id, float3 lL)
#define storage(slot, qualifiers)
void gpu_discard_fragment()
bool any(VecOp< bool, D >) RET
float distance(float, float) RET
VecBase< uint, D > floatBitsToUint(VecOp< float, D >) RET
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) RET
SamplerBase< float, 3 > sampler3D
TEX_TEMPLATE SizeVec textureSize(T, int) RET
SamplerBase< uint, 2 > usampler2D
float3 hue_gradient(float t)
float3 heatmap_gradient(float t)
float3 green_to_red_gradient(float t)
float3 neon_gradient(float t)
void fullscreen_vertex(int vertex_id, float4 &out_position)
float3x3 from_up_axis(float3 up)
float reduce_add(float2 a)
const ccl_global KernelWorkTile * tile
@ CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID
@ CLOSURE_BSDF_DIFFUSE_ID
@ CLOSURE_BSSRDF_BURLEY_ID
@ CLOSURE_BSDF_THIN_GLASS_TRANSMISSION_ID
@ CLOSURE_BSDF_TRANSLUCENT_ID
MatBase< float, 4, 4 > float4x4
void frag_main(Resources &srt, const draw::View &views, const ::gbuffer::Reader &reader, const float4 frag_co, DualBlendFragOut &frag_out)
void frag_main(const HiZ &hiz, const float4 frag_co, DualBlendFragOut &frag_out)
void frag_main(const VertOut &v_out, FragOut &frag_out)
void vert_main(const Resources &srt, const draw::View &views, const int vert_id, float4 &out_position, float &out_point_size, VertOut &v_out)
float3 debug_random_color(int v)
void vert_main(const Resources &srt, const draw::View &views, const int vert_id, const int inst_id, float4 &out_position, VertOut &v_out)
void frag_main(const Resources &srt, const bool front_face, const VertOut &v_out, FragOut &frag_out)
void foreach(const LightRenderData &srt, CallbackT &cb, ResourceT &res)
float3 grid_sample_position(float4x4 grid_local_to_world_mat, int3 grid_res, int3 cell_coord)
void debug_shadow_frag(ShadowDebug &srt, const draw::View &views, const float4 frag_co, float &frag_depth, const HiZ &hiz, const DebugVertOut v_out, DualBlendFragOut &frag_out)
ShadowDebugOutput debug_random_tilemap_color(const ShadowDebug &srt, float3 P, LightData light)
ShadowDebugOutput debug_tilemaps(const ShadowDebug &srt, float3, LightData light, int2 texel, bool do_debug_sample_tile)
ShadowDebugOutput debug_atlas_values(const ShadowDebug &srt, float3 P, LightData light)
ShadowDebugOutput debug_tile_state(const ShadowDebug &srt, float3 P, LightData light)
void debug_fullscreen_vert(const int vert_id, float4 &out_position, DebugVertOut &v_out)
ShadowDebugOutput debug_atomic_cost(ShadowDebug &srt, float3 P, LightData)
ShadowDebugOutput debug_random_tile_color(const ShadowDebug &srt, float3 P, LightData light)
float interleaved_gradient(float2 pixel, float seed, float offset)
float4 transform(float4 hs_position)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
float4 point_world_to_homogenous(float3 P) const
float3 point_screen_to_world(float3 ssP) const
float atomic_cost(const ShadowDebug &srt, LightData light)
void eval_local(ShadowDebug &srt, uint, LightData light)
void eval_directional(ShadowDebug &srt, uint, LightData light)
const LightData(& light_buf)[]
void eval_local(LightRenderData &, uint l_idx, LightData light)
void eval_directional(LightRenderData &, uint l_idx, LightData light)
ShadowTileMapData(& tilemaps_buf)[]
ShadowSamplingTile shadow_tile_data_get(usampler2D tilemaps_tx, ShadowCoordinates coord) const
LightRenderData light_data
ShadowCoordinates debug_coord_get(float3 P, LightData light) const
float3 debug_random_color(int v) const
LightData debug_light_get()
float3 debug_tile_lod(eLightType type, ShadowSamplingTile tile) const
ShadowSamplingTile debug_tile_get(float3 P, LightData light) const
ShadowRenderData shadow_data
void debug_tile_print(ShadowTileData tile, int4 tile_coord) const
float3 debug_random_color(int2 v) const
float3 debug_tile_state_color(ShadowTileData tile) const
usampler2D shadow_tilemaps_tx
float read_depth(ShadowCoordinates coord) const
const Surfel(& surfels_buf)[]
const float debug_surfel_radius