EEVEE Next: Double sided for GI #113362

Merged
Miguel Pozo merged 5 commits from pragma37/blender:pull-eevee-double-sided-gi into main 2023-10-09 17:02:22 +02:00
9 changed files with 32 additions and 9 deletions

View File

@ -256,7 +256,12 @@ class EEVEE_NEXT_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
mat = context.material
layout.prop(mat, "use_backface_culling")
col = layout.column(heading="Cull Backfaces")
col.prop(mat, "use_backface_culling", text="Camera")
col.prop(mat, "use_backface_culling_probe", text="Probe Capture")
layout.separator()
pragma37 marked this conversation as resolved

Rename double_sided_gi to use_backface_culling_probe.

Do not move show_transparent_back here (it is not the same as a backface culling).

Rename `double_sided_gi` to `use_backface_culling_probe`. Do not move `show_transparent_back` here (it is not the same as a backface culling).
layout.prop(mat, "blend_method")
layout.prop(mat, "shadow_method")
@ -265,7 +270,7 @@ class EEVEE_NEXT_MATERIAL_PT_settings(MaterialButtonsPanel, Panel):
row.prop(mat, "alpha_threshold")
pragma37 marked this conversation as resolved Outdated

make format

`make format`

Python file!

Python file!
if mat.blend_method not in {'OPAQUE', 'CLIP', 'HASHED'}:
layout.prop(mat, "show_transparent_back")
col.prop(mat, "show_transparent_back", text="Transparency")
layout.prop(mat, "use_screen_refraction")
layout.prop(mat, "pass_index")

View File

@ -1081,9 +1081,13 @@ void CapturePipeline::sync()
inst_.bind_uniform_data(&surface_ps_);
}
PassMain::Sub *CapturePipeline::surface_material_add(GPUMaterial *gpumat)
PassMain::Sub *CapturePipeline::surface_material_add(::Material *blender_mat, GPUMaterial *gpumat)
{
return &surface_ps_.sub(GPU_material_get_name(gpumat));
PassMain::Sub &sub_pass = surface_ps_.sub(GPU_material_get_name(gpumat));
GPUPass *gpupass = GPU_material_get_pass(gpumat);
sub_pass.shader_set(GPU_pass_shader_get(gpupass));
sub_pass.push_constant("double_sided", !(blender_mat->blend_flag & MA_BL_CULL_BACKFACE_PROBE));
return &sub_pass;
}
void CapturePipeline::render(View &view)

View File

@ -371,7 +371,7 @@ class CapturePipeline {
public:
CapturePipeline(Instance &inst) : inst_(inst){};
PassMain::Sub *surface_material_add(GPUMaterial *gpumat);
PassMain::Sub *surface_material_add(::Material *blender_mat, GPUMaterial *gpumat);
void sync();
void render(View &view);
@ -567,7 +567,7 @@ class PipelineModule {
case MAT_PIPE_SHADOW:
return shadow.surface_material_add(gpumat);
case MAT_PIPE_CAPTURE:
return capture.surface_material_add(gpumat);
return capture.surface_material_add(blender_mat, gpumat);
fclem marked this conversation as resolved

Don't pass blender_mat here. You can get the material from the gpumat using GPU_material_get_material.

Don't pass `blender_mat` here. You can get the material from the gpumat using `GPU_material_get_material`.
Review

Why? Most pipelines receive the blender_mat directly as parameter.

Why? Most pipelines receive the `blender_mat` directly as parameter.

Nevermind, I misread something.

Nevermind, I misread something.
case MAT_PIPE_PLANAR_PREPASS:
BLI_assert_unreachable();
return nullptr;

View File

@ -1036,6 +1036,11 @@ struct Surfel {
packed_float3 albedo_back;
/** Cluster this surfel is assigned to. */
int cluster_id;
/** True if the light can bounce or be emitted by the surfel back face. */
bool1 double_sided;
int _pad0;
int _pad1;
int _pad2;
/** Surface radiance: Emission + Direct Lighting. */
SurfelRadiance radiance_direct;
/** Surface radiance: Indirect Lighting. Double buffered to avoid race conditions. */

View File

@ -53,7 +53,7 @@ void irradiance_capture_surfel(Surfel surfel, vec3 P, inout SphericalHarmonicL1
void validity_capture_surfel(Surfel surfel, vec3 P, inout float validity)
{
vec3 L = safe_normalize(surfel.position - P);
bool facing = dot(-L, surfel.normal) > 0.0;
bool facing = surfel.double_sided || dot(-L, surfel.normal) > 0.0;
validity += float(facing);
}

View File

@ -53,9 +53,10 @@ void main()
surfel_buf[surfel_id].radiance_direct.front.rgb = g_emission;
surfel_buf[surfel_id].radiance_direct.front.a = 0.0;
/* TODO(fclem): 2nd surface evaluation. */
surfel_buf[surfel_id].albedo_back = albedo;
surfel_buf[surfel_id].radiance_direct.back.rgb = g_emission;
surfel_buf[surfel_id].albedo_back = double_sided ? albedo : vec3(0);
surfel_buf[surfel_id].radiance_direct.back.rgb = double_sided ? g_emission : vec3(0);
surfel_buf[surfel_id].radiance_direct.back.a = 0.0;
surfel_buf[surfel_id].double_sided = double_sided;
if (!capture_info_buf.capture_emission) {
surfel_buf[surfel_id].radiance_direct.front.rgb = vec3(0.0);

View File

@ -182,6 +182,7 @@ GPU_SHADER_CREATE_INFO(eevee_surf_capture)
.define("MAT_CAPTURE")
.storage_buf(SURFEL_BUF_SLOT, Qualifier::WRITE, "Surfel", "surfel_buf[]")
.storage_buf(CAPTURE_BUF_SLOT, Qualifier::READ_WRITE, "CaptureInfoData", "capture_info_buf")
.push_constant(Type::BOOL, "double_sided")
.fragment_source("eevee_surf_capture_frag.glsl")
.additional_info("eevee_global_ubo", "eevee_utility_texture");

View File

@ -342,6 +342,7 @@ enum {
MA_BL_SS_REFRACTION = (1 << 1),
MA_BL_CULL_BACKFACE = (1 << 2),
MA_BL_TRANSLUCENCY = (1 << 3),
MA_BL_CULL_BACKFACE_PROBE = (1 << 4),
pragma37 marked this conversation as resolved Outdated

MA_BL_CULL_BACKFACE_PORBE

`MA_BL_CULL_BACKFACE_PORBE`
};
/** #Material::blend_shadow */

View File

@ -858,6 +858,12 @@ void RNA_def_material(BlenderRNA *brna)
prop, "Backface Culling", "Use back face culling to hide the back side of faces");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
prop = RNA_def_property(srna, "use_backface_culling_probe", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_CULL_BACKFACE_PROBE);
RNA_def_property_ui_text(
pragma37 marked this conversation as resolved Outdated

GI is not a widespread accronym in the blender codebase. Use "probe capture" instead.

GI is not a widespread accronym in the blender codebase. Use "probe capture" instead.
prop, "Probe Capture Backface Culling", "Use back faces for probe captures");
RNA_def_property_update(prop, 0, "rna_Material_draw_update");
prop = RNA_def_property(srna, "use_screen_refraction", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "blend_flag", MA_BL_SS_REFRACTION);
RNA_def_property_ui_text(