Commit eb3b9cc8 authored by unknown's avatar unknown
Browse files

Fixed LS bounces thresh. and added uniform distribution randomness to raygen

parent 2f79ee8b
......@@ -19,7 +19,7 @@
<item name="pathtrace_clamp_indirect">8</item>
<!-- Bounce limits -->
<item name="pathtrace_bounces_diffuse">2</item>
<item name="pathtrace_bounces_diffuse">4</item>
<item name="pathtrace_bounces_translucent">4</item>
<item name="pathtrace_bounces_reflect">4</item>
<item name="pathtrace_bounces_refract">8</item>
......@@ -27,7 +27,7 @@
<item name="pathtrace_bounces_emissive">0</item>
<!-- Line space bounce count thresholds -->
<item name="pathtrace_ls_thresh_bounces_diffuse">0</item>
<item name="pathtrace_ls_thresh_bounces_diffuse">3</item>
<item name="pathtrace_ls_thresh_bounces_translucent">2</item>
<item name="pathtrace_ls_thresh_bounces_reflect">3</item>
<item name="pathtrace_ls_thresh_bounces_refract">5</item>
......
......@@ -6,6 +6,15 @@ namespace glare
{
namespace advanced
{
uint32_t RayGeneratorBase::randomSeed()
{
static std::random_device rd;
static std::mt19937 gen(rd());
static std::uniform_int_distribution<uint32_t> dist(0, std::numeric_limits<uint32_t>::max());
return dist(gen);
}
void RayGeneratorBase::generate(Raytracer &raytracer)
{
m_updated_size = false;
......@@ -32,7 +41,7 @@ namespace glare
m_generator_shader_default->updateUniformImageRGBA32F("u_render_target", raytracer.renderTarget(), gl::Access::eReadWrite);
m_generator_shader_default->updateStorageBuffer("trace_buffer", raytracer.traceBuffer());
m_generator_shader_default->updateUniformInt("random_seed", rand());
m_generator_shader_default->updateUniformInt("random_seed", randomSeed());
m_generator_shader_default->updateUniformStruct("u_camera", raytracer.collector()->getActiveCamera());
m_generator_shader_default->updateStorageBuffer("mesh_buffer", raytracer.collector()->meshBuffer());
......@@ -91,7 +100,7 @@ namespace glare
m_buffer_depthtest->updateUniformImageRGBA32F("u_render_target", raytracer.renderTarget(), gl::Access::eReadWrite);
m_buffer_depthtest->updateStorageBuffer("trace_buffer", raytracer.traceBuffer());
m_buffer_depthtest->updateUniformStruct("u_camera", raytracer.collector()->getActiveCamera());
m_buffer_depthtest->updateUniformInt("random_seed", rand());
m_buffer_depthtest->updateUniformInt("random_seed", randomSeed());
m_buffer_depthtest->dispatchCompute(m_last_width*m_last_height, 1024);
}
......
......@@ -37,6 +37,8 @@ namespace glare
RayGeneratorBase(RayGeneratorBase &other) = delete;
virtual ~RayGeneratorBase() = default;
virtual void generate(Raytracer &raytracer);
static uint32_t randomSeed();
protected:
bool m_updated_size = false;
unsigned m_last_width = 0;
......
......@@ -145,6 +145,7 @@ namespace glare
}
m_render_shader->updateUniformUInt("u_render_config.bounce_thresholds", bounce_thresholds);
m_linespace_config.bounce_thresholds = 0;
for (int i = 0; i < 8; ++i)
{
m_linespace_config.bounce_thresholds |= (m_ls_bounce_count_thresholds[i] & 0xf) << (4 * i);
......
Supports Markdown
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