Commit a0d8ac76 authored by Florian Oetke's avatar Florian Oetke
Browse files

GI shadows

parent 55c08c1f
......@@ -25,6 +25,7 @@ layout(set=2, binding = 9) uniform sampler2D ao_sampler;
layout (constant_id = 0) const int LAST_SAMPLE = 0; // 1 if this is the last MIP level to sample
layout (constant_id = 1) const float R = 40; // the radius to fetch samples from
layout (constant_id = 2) const int SAMPLES = 128; // the number of samples to fetch
layout (constant_id = 3) const int VISIBILITY = 0; // 1 if shadows should be traced
// arguments are packet into the matrices to keep the pipeline layouts compatible between GI passes
......@@ -186,7 +187,9 @@ vec3 calc_illumination_from(int lod, vec2 tex_size, ivec2 src_uv, vec2 shaded_uv
float r2 = dot(diff, diff);
float visibility = 1;//lod<=1 ? 1.0 : v(lod, shaded_point, P, shaded_uv, src_uv);
float visibility = 1.0;
if(VISIBILITY==1)
visibility = v(lod, shaded_point, P, shaded_uv, src_uv);
float NdotL_src = clamp(dot(N, dir), 0.0, 1.0); // cos(θ')
float NdotL_dst = clamp(dot(shaded_normal, -dir), 0.0, 1.0); // cos(θ)
......
......@@ -147,13 +147,6 @@ namespace mirrage {
});
break;
case "d_disect"_strid: {
auto s = _meta_system.renderer().settings();
s.debug_disect = !s.debug_disect;
_meta_system.renderer().settings(s, false);
_set_preset(0);
break;
}
case "print"_strid: {
auto cam = _camera.get<Transform_comp>().get_or_throw().position;
......@@ -163,9 +156,7 @@ namespace mirrage {
<< " Camera orientation: " << _cam_yaw << "/" << _cam_pitch << "\n"
<< " Sun orientation: " << _sun_elevation << "/" << _sun_azimuth
<< "\n"
<< " Sun color: " << _sun_color_temperature << "\n"
<< " Disected: "
<< _meta_system.renderer().settings().debug_disect;
<< " Sun color: " << _sun_color_temperature;
break;
}
......@@ -270,10 +261,6 @@ namespace mirrage {
_sun.get<renderer::Directional_light_comp>().process(
[&](renderer::Directional_light_comp& light) { light.temperature(_sun_color_temperature); });
auto s = _meta_system.renderer().settings();
s.debug_disect = p.disect_model;
_meta_system.renderer().settings(s, false);
_update_sun_position();
}
......@@ -489,6 +476,10 @@ namespace mirrage {
nk_checkbox_label(ctx, "Indirect Illumination", &bool_nk_wrapper);
renderer_settings.gi = bool_nk_wrapper == 1;
bool_nk_wrapper = renderer_settings.gi_shadows ? 1 : 0;
nk_checkbox_label(ctx, "Indirect Shadows", &bool_nk_wrapper);
renderer_settings.gi_shadows = bool_nk_wrapper == 1;
bool_nk_wrapper = renderer_settings.gi_highres ? 1 : 0;
nk_checkbox_label(ctx, "High-Resolution GI", &bool_nk_wrapper);
renderer_settings.gi_highres = bool_nk_wrapper == 1;
......@@ -501,9 +492,6 @@ namespace mirrage {
nk_property_int(ctx, "Sample Count", 8, &renderer_settings.gi_samples, 1024, 1, 1);
nk_property_int(
ctx, "Low-Quality MIP-Levels", 0, &renderer_settings.gi_low_quality_mip_levels, 8, 1, 1);
nk_property_float(
ctx, "Exposure", 0.f, &renderer_settings.exposure_override, 50.f, 0.001f, 0.01f);
......
......@@ -35,11 +35,11 @@ namespace mirrage::renderer {
bool gi = true;
bool gi_highres = true;
bool gi_shadows = false;
int gi_diffuse_mip_level = 1;
int gi_min_mip_level = 0;
int gi_samples = 32;
int gi_lowres_samples = 128;
bool gi_jitter_samples = false;
int gi_low_quality_mip_levels = 0;
bool tonemapping = true;
......@@ -53,13 +53,11 @@ namespace mirrage::renderer {
float background_intensity = 0.f;
bool dynamic_shadows = false;
bool debug_disect = false;
int debug_gi_layer = -1;
};
#ifdef sf2_structDef
sf2_structDef(
Renderer_settings, shadowmap_resolution, shadow_quality, gi, dynamic_shadows, debug_gi_layer);
sf2_structDef(Renderer_settings, shadowmap_resolution, shadow_quality, gi, dynamic_shadows);
#endif
struct Global_uniforms {
......
......@@ -242,7 +242,6 @@ namespace mirrage::renderer {
auto _ = _renderer.profiler().push("Geometry");
Deferred_push_constants dpc{};
dpc.light_data.x = _renderer.settings().debug_disect;
auto last_substance_id = ""_strid;
auto last_material = static_cast<const Material*>(nullptr);
......
......@@ -437,7 +437,7 @@ namespace mirrage::renderer {
color, graphic::all_color_components, graphic::blend_premultiplied_alpha);
// diffuse sample
pass.stage("sample_first"_strid)
pass.stage("sample_fi"_strid)
.shader("frag_shader:gi_sample"_aid,
graphic::Shader_stage::fragment,
"main",
......@@ -445,6 +445,16 @@ namespace mirrage::renderer {
first_level_sample_count)
.shader("vert_shader:gi_sample"_aid, graphic::Shader_stage::vertex);
pass.stage("sample_fi_v"_strid)
.shader("frag_shader:gi_sample"_aid,
graphic::Shader_stage::fragment,
"main",
2,
first_level_sample_count,
3,
1)
.shader("vert_shader:gi_sample"_aid, graphic::Shader_stage::vertex);
pass.stage("sample"_strid)
.shader("frag_shader:gi_sample"_aid,
graphic::Shader_stage::fragment,
......@@ -453,8 +463,18 @@ namespace mirrage::renderer {
sample_count)
.shader("vert_shader:gi_sample"_aid, graphic::Shader_stage::vertex);
pass.stage("sample_v"_strid)
.shader("frag_shader:gi_sample"_aid,
graphic::Shader_stage::fragment,
"main",
2,
sample_count,
3,
1)
.shader("vert_shader:gi_sample"_aid, graphic::Shader_stage::vertex);
// circle instead of ring sample-pattern
pass.stage("sample_last"_strid)
pass.stage("sample_la"_strid)
.shader("frag_shader:gi_sample"_aid,
graphic::Shader_stage::fragment,
"main",
......@@ -463,6 +483,17 @@ namespace mirrage::renderer {
2,
sample_count)
.shader("vert_shader:gi_sample"_aid, graphic::Shader_stage::vertex);
pass.stage("sample_la_v"_strid)
.shader("frag_shader:gi_sample"_aid,
graphic::Shader_stage::fragment,
"main",
0,
1,
2,
sample_count,
3,
1)
.shader("vert_shader:gi_sample"_aid, graphic::Shader_stage::vertex);
// upsample the previous level
pass.stage("upsample"_strid)
......@@ -1315,13 +1346,19 @@ namespace mirrage::renderer {
_sample_renderpass.execute(command_buffer, fb, [&] {
auto sample_count = to_2prod(_renderer.settings().gi_samples);
auto stage = "sample"_strid;
if(i == end - 1) {
_sample_renderpass.set_stage("sample_first"_strid);
stage = "sample_fi"_strid;
sample_count = to_2prod(_renderer.settings().gi_lowres_samples);
} else if(i == begin)
_sample_renderpass.set_stage("sample_last"_strid);
else
_sample_renderpass.set_stage("sample"_strid);
} else if(i == begin) {
stage = "sample_la"_strid;
}
if(_renderer.settings().gi_shadows && i - _min_mip_level > 1)
stage = stage + "_v"_strid;
_sample_renderpass.set_stage(stage);
if(first_iteration) {
_sample_renderpass.bind_descriptor_sets(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment