EEVEE Next: GI surfels debug display #105802

Merged
Miguel Pozo merged 6 commits from pragma37/blender:pull-eevee-next-surfels into main 2023-03-16 14:14:44 +01:00
13 changed files with 57 additions and 59 deletions
Showing only changes of commit 4775441b59 - Show all commits

View File

@ -142,9 +142,9 @@ set(SRC
engines/eevee_next/eevee_depth_of_field.cc
engines/eevee_next/eevee_engine.cc
engines/eevee_next/eevee_film.cc
engines/eevee_next/eevee_gi.cc
engines/eevee_next/eevee_hizbuffer.cc
pragma37 marked this conversation as resolved Outdated

Rename to eevee_irradiance_cache.cc.

Rename to `eevee_irradiance_cache.cc`.
engines/eevee_next/eevee_instance.cc
engines/eevee_next/eevee_irradiance_cache.cc
engines/eevee_next/eevee_light.cc
engines/eevee_next/eevee_material.cc
engines/eevee_next/eevee_motion_blur.cc
@ -274,9 +274,9 @@ set(SRC
engines/eevee_next/eevee_depth_of_field.hh
engines/eevee_next/eevee_engine.h
engines/eevee_next/eevee_film.hh
engines/eevee_next/eevee_gi.hh
engines/eevee_next/eevee_hizbuffer.hh
engines/eevee_next/eevee_instance.hh
engines/eevee_next/eevee_irradiance_cache.hh
engines/eevee_next/eevee_light.hh
engines/eevee_next/eevee_material.hh
engines/eevee_next/eevee_motion_blur.hh
@ -427,6 +427,8 @@ set(GLSL_SRC
engines/eevee_next/shaders/eevee_colorspace_lib.glsl
engines/eevee_next/shaders/eevee_cryptomatte_lib.glsl
engines/eevee_next/shaders/eevee_transparency_lib.glsl
engines/eevee_next/shaders/eevee_debug_surfels_vert.glsl
engines/eevee_next/shaders/eevee_debug_surfels_frag.glsl
engines/eevee_next/shaders/eevee_depth_of_field_accumulator_lib.glsl
engines/eevee_next/shaders/eevee_depth_of_field_bokeh_lut_comp.glsl
engines/eevee_next/shaders/eevee_depth_of_field_downsample_comp.glsl
@ -450,8 +452,6 @@ set(GLSL_SRC
engines/eevee_next/shaders/eevee_geom_gpencil_vert.glsl
engines/eevee_next/shaders/eevee_geom_mesh_vert.glsl
pragma37 marked this conversation as resolved Outdated

Drop the gi_ bit as this could be used for other cases.

Drop the `gi_` bit as this could be used for other cases.
engines/eevee_next/shaders/eevee_geom_world_vert.glsl
engines/eevee_next/shaders/eevee_gi_debug_surfels_vert.glsl
engines/eevee_next/shaders/eevee_gi_debug_surfels_frag.glsl
engines/eevee_next/shaders/eevee_hiz_debug_frag.glsl
engines/eevee_next/shaders/eevee_hiz_update_comp.glsl
engines/eevee_next/shaders/eevee_light_culling_debug_frag.glsl

View File

@ -119,7 +119,6 @@
#define LIGHT_BUF_SLOT 1
#define LIGHT_ZBIN_BUF_SLOT 2
#define LIGHT_TILE_BUF_SLOT 3
#define GI_SURFEL_BUF_SLOT 4
/* Only during surface shading. */
pragma37 marked this conversation as resolved Outdated

This isn't a buffer that needs to be bound to multiple shader (yet). So I would remove the static index.

This isn't a buffer that needs to be bound to multiple shader (yet). So I would remove the static index.

I was more worried about replacing an already binded buffer.
Isn't that an issue?

I was more worried about replacing an already binded buffer. Isn't that an issue?

No because this only for the display pass. Every resource needed should be bound inside a pass.
If it needs to be bound to an existing pass, the slot need to be chosen manually on a per shader basis to avoid conflict.
Not sure if my explanation is clear. But anyway, just remove that define.

No because this only for the display pass. Every resource needed should be bound inside a pass. If it needs to be bound to an existing pass, the slot need to be chosen manually on a per shader basis to avoid conflict. Not sure if my explanation is clear. But anyway, just remove that define.
#define RBUFS_AOV_BUF_SLOT 5
/* Only during shadow rendering. */

View File

@ -70,7 +70,7 @@ void Instance::init(const int2 &output_res,
shadows.init();
motion_blur.init();
main_view.init();
gi.init();
irradiance_cache.init();
}
void Instance::set_time(float time)
@ -118,7 +118,7 @@ void Instance::begin_sync()
main_view.sync();
world.sync();
film.sync();
gi.sync();
irradiance_cache.sync();
}
void Instance::scene_sync()

View File

@ -19,8 +19,8 @@
#include "eevee_cryptomatte.hh"
#include "eevee_depth_of_field.hh"
#include "eevee_film.hh"
#include "eevee_gi.hh"
#include "eevee_hizbuffer.hh"
#include "eevee_irradiance_cache.hh"
#include "eevee_light.hh"
#include "eevee_material.hh"
#include "eevee_motion_blur.hh"
@ -61,7 +61,7 @@ class Instance {
RenderBuffers render_buffers;
MainView main_view;
World world;
GI gi;
IrradianceCache irradiance_cache;
/** Input data. */
Depsgraph *depsgraph;
@ -106,7 +106,7 @@ class Instance {
render_buffers(*this),
main_view(*this),
world(*this),
gi(*this){};
irradiance_cache(*this){};
~Instance(){};
void init(const int2 &output_res,

View File

@ -3,60 +3,60 @@
#include "BLI_rand.hh"
#include "eevee_instance.hh"
#include "eevee_gi.hh"
#include "eevee_irradiance_cache.hh"
namespace blender::eevee {
void GI::generate_random_surfels()
void IrradianceCache::generate_random_surfels()
{
const int surfels_len = 256;
surfels.resize(surfels_len);
debug_surfels.resize(surfels_len);
RandomNumberGenerator rng;
rng.seed(0);
for (Surfel &surfel : surfels) {
for (DebugSurfel &surfel : debug_surfels) {
float3 random = rng.get_unit_float3();
surfel.position = random * 3.0f;
surfel.normal = random;
surfel.color = float4(rng.get_float(), rng.get_float(), rng.get_float(), 1.0f);
}
surfels.push_update();
debug_surfels.push_update();
}
void GI::init()
void IrradianceCache::init()
{
if (debug_surfels_sh_ == nullptr) {
debug_surfels_sh_ = GPU_shader_create_from_info_name("eevee_gi_debug_surfels");
debug_surfels_sh_ = GPU_shader_create_from_info_name("eevee_debug_surfels");
}
/* TODO: Remove this. */
generate_random_surfels();
}
void GI::sync()
void IrradianceCache::sync()
{
debug_pass_sync();
}
void GI::debug_pass_sync()
void IrradianceCache::debug_pass_sync()
{
if (inst_.debug_mode == eDebugMode::DEBUG_GI_SURFELS) {
if (inst_.debug_mode == eDebugMode::DEBUG_IRRADIANCE_CACHE_SURFELS) {
debug_surfels_ps_.init();
debug_surfels_ps_.state_set(DRW_STATE_WRITE_COLOR | DRW_STATE_WRITE_DEPTH |
DRW_STATE_DEPTH_LESS_EQUAL);
debug_surfels_ps_.shader_set(debug_surfels_sh_);
debug_surfels_ps_.bind_ssbo(GI_SURFEL_BUF_SLOT, surfels);
debug_surfels_ps_.bind_ssbo("surfels_buf", debug_surfels);
debug_surfels_ps_.push_constant("surfel_radius", 0.25f);
debug_surfels_ps_.draw_procedural(GPU_PRIM_TRI_STRIP, surfels.size(), 4);
debug_surfels_ps_.draw_procedural(GPU_PRIM_TRI_STRIP, debug_surfels.size(), 4);
}
}
void GI::debug_draw(View &view, GPUFrameBuffer *view_fb)
void IrradianceCache::debug_draw(View &view, GPUFrameBuffer *view_fb)
{
if (inst_.debug_mode == eDebugMode::DEBUG_GI_SURFELS) {
inst_.info = "Debug Mode: GI Surfels";
if (inst_.debug_mode == eDebugMode::DEBUG_IRRADIANCE_CACHE_SURFELS) {
inst_.info = "Debug Mode: Irradiance Cache Surfels";
GPU_framebuffer_bind(view_fb);
inst_.manager->submit(debug_surfels_ps_, view);
}

View File

@ -8,20 +8,20 @@ namespace blender::eevee {
class Instance;
class GI {
class IrradianceCache {
private:
Instance &inst_;
SurfelBuf surfels;
PassSimple debug_surfels_ps_ = {"GI.Debug"};
DebugSurfelBuf debug_surfels;
PassSimple debug_surfels_ps_ = {"IrradianceCache.Debug"};
GPUShader *debug_surfels_sh_ = nullptr;
/* TODO: Remove this. */
void generate_random_surfels();
public:
GI(Instance &inst) : inst_(inst){};
~GI(){};
IrradianceCache(Instance &inst) : inst_(inst){};
~IrradianceCache(){};
void init();
void sync();

View File

@ -49,13 +49,12 @@ enum eDebugMode : uint32_t {
*/
DEBUG_HIZ_VALIDATION = 2u,
/**
* Display GI surfels.
* Display IrradianceCache surfels.
*/
DEBUG_GI_SURFELS = 3u,
DEBUG_IRRADIANCE_CACHE_SURFELS = 3u,
/**
* Show tiles depending on their status.
*/
DEBUG_SHADOW_TILEMAPS = 10u,
pragma37 marked this conversation as resolved Outdated

Blank line.

Blank line.
/**
* Show content of shadow map. Used to verify projection code.
@ -827,17 +826,17 @@ static inline ShadowTileDataPacked shadow_tile_pack(ShadowTileData tile)
/** \} */
/* -------------------------------------------------------------------- */
/** \name GI
/** \name Debug
* \{ */
pragma37 marked this conversation as resolved

\name Debug

`\name Debug`
struct Surfel {
float3 position;
struct DebugSurfel {
packed_float3 position;
pragma37 marked this conversation as resolved Outdated

Rename to DebugSurfel

Rename to `DebugSurfel`

So the idea would be to eventually have a Surfel and a DebugSurfel and make the copy/conversion before rendering the debug visualization?

So the idea would be to eventually have a Surfel and a DebugSurfel and make the copy/conversion before rendering the debug visualization?

Yes. I'm thinking we could reuse it for raytracing debugging.

Yes. I'm thinking we could reuse it for raytracing debugging.
int _pad0;
pragma37 marked this conversation as resolved

Use packed_float3 if you do that.

Use `packed_float3` if you do that.
float3 normal;
packed_float3 normal;
int _pad1;
float4 color;
};
BLI_STATIC_ASSERT_ALIGN(Surfel, 16)
BLI_STATIC_ASSERT_ALIGN(DebugSurfel, 16)
/** \} */
@ -948,7 +947,7 @@ using DepthOfFieldDataBuf = draw::UniformBuffer<DepthOfFieldData>;
using DepthOfFieldScatterListBuf = draw::StorageArrayBuffer<ScatterRect, 16, true>;
using DrawIndirectBuf = draw::StorageBuffer<DrawCommand, true>;
using FilmDataBuf = draw::UniformBuffer<FilmData>;
using SurfelBuf = draw::StorageArrayBuffer<Surfel, 64>;
using DebugSurfelBuf = draw::StorageArrayBuffer<DebugSurfel, 64>;
using HiZDataBuf = draw::UniformBuffer<HiZData>;
using LightCullingDataBuf = draw::StorageBuffer<LightCullingData>;
using LightCullingKeyBuf = draw::StorageArrayBuffer<uint, LIGHT_CHUNK, true>;

View File

@ -136,7 +136,7 @@ void ShadingView::render()
inst_.hiz_buffer.debug_draw(render_view_new_, combined_fb_);
inst_.shadows.debug_draw(render_view_new_, combined_fb_);
inst_.gi.debug_draw(render_view_new_, combined_fb_);
inst_.irradiance_cache.debug_draw(render_view_new_, combined_fb_);
GPUTexture *combined_final_tx = render_postfx(rbufs.combined_tx);

View File

@ -1,7 +1,7 @@
void main()
{
Surfel surfel = surfels_buf[surfel_index];
DebugSurfel surfel = surfels_buf[surfel_index];
out_color = surfel.color;
/* Display surfels as circles. */

View File

@ -4,7 +4,7 @@
void main()
{
surfel_index = gl_InstanceID;
Surfel surfel = surfels_buf[surfel_index];
DebugSurfel surfel = surfels_buf[surfel_index];
const vec3 verts[4] = vec3[4](vec3(-1, 1, 0), vec3(-1, -1, 0), vec3(1, 1, 0), vec3(1, -1, 0));
vec3 lP = verts[gl_VertexID];

View File

@ -1,16 +0,0 @@
#include "eevee_defines.hh"
#include "gpu_shader_create_info.hh"
GPU_SHADER_INTERFACE_INFO(eeve_gi_surfel_iface, "")
.smooth(Type::VEC3, "P")
.flat(Type::INT, "surfel_index");
GPU_SHADER_CREATE_INFO(eevee_gi_debug_surfels)
.additional_info("eevee_shared", "draw_view")
.vertex_source("eevee_gi_debug_surfels_vert.glsl")
.vertex_out(eeve_gi_surfel_iface)
.fragment_source("eevee_gi_debug_surfels_frag.glsl")
.fragment_out(0, Type::VEC4, "out_color")
.storage_buf(GI_SURFEL_BUF_SLOT, Qualifier::READ, "Surfel", "surfels_buf[]")
.push_constant(Type::FLOAT, "surfel_radius")
.do_static_compilation(true);

View File

@ -0,0 +1,16 @@
#include "eevee_defines.hh"
#include "gpu_shader_create_info.hh"
GPU_SHADER_INTERFACE_INFO(eeve_debug_surfel_iface, "")
.smooth(Type::VEC3, "P")
.flat(Type::INT, "surfel_index");
GPU_SHADER_CREATE_INFO(eevee_debug_surfels)
.additional_info("eevee_shared", "draw_view")
.vertex_source("eevee_debug_surfels_vert.glsl")
.vertex_out(eeve_debug_surfel_iface)
.fragment_source("eevee_debug_surfels_frag.glsl")
.fragment_out(0, Type::VEC4, "out_color")
.storage_buf(0, Qualifier::READ, "DebugSurfel", "surfels_buf[]")
.push_constant(Type::FLOAT, "surfel_radius")
.do_static_compilation(true);

View File

@ -605,8 +605,8 @@ set(SRC_SHADER_CREATE_INFOS
../draw/engines/basic/shaders/infos/basic_depth_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_depth_of_field_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_film_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_gi_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_hiz_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_irradiance_cache_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_light_culling_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_material_info.hh
../draw/engines/eevee_next/shaders/infos/eevee_motion_blur_info.hh