Commit cd98d22e authored by Johannes Braun's avatar Johannes Braun
Browse files

Added LS as primary ray generator option.

parent 739edf69
...@@ -14,6 +14,7 @@ layout(local_size_variable) in; ...@@ -14,6 +14,7 @@ layout(local_size_variable) in;
layout(rgba32f) uniform image2D u_render_target; layout(rgba32f) uniform image2D u_render_target;
uniform Camera u_camera; uniform Camera u_camera;
uniform int random_seed; uniform int random_seed;
uniform bool use_linespace = false;
uniform struct uniform struct
{ {
...@@ -31,5 +32,5 @@ void main() ...@@ -31,5 +32,5 @@ void main()
vec2 random = settings.u_random_subpixel ? vec2(0, 0) : rand2D(random_seed + id, target_size.x*target_size.y); vec2 random = settings.u_random_subpixel ? vec2(0, 0) : rand2D(random_seed + id, target_size.x*target_size.y);
traces_data[id].ray = u_camera.getRayFromPixel(vec2(gl_GlobalInvocationID.xy), random, vec2(target_size)); traces_data[id].ray = u_camera.getRayFromPixel(vec2(gl_GlobalInvocationID.xy), random, vec2(target_size));
traces_data[id].hit.invalidate(); traces_data[id].hit.invalidate();
traces_data[id].ray.nearestIntersection(traces_data[id].hit, true); traces_data[id].ray.nearestIntersection(traces_data[id].hit, !use_linespace);
} }
...@@ -488,7 +488,7 @@ void drawSettingsWindow() ...@@ -488,7 +488,7 @@ void drawSettingsWindow()
ImGui::BeginNamedGroup("Ray Generator"); ImGui::BeginNamedGroup("Ray Generator");
{ {
ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth()); ImGui::PushItemWidth(ImGui::GetContentRegionAvailWidth());
if (int raygenstate = static_cast<int>(pathtracer->getRayGenerator()); ImGui::Combo("", &raygenstate, { "Trace [default]", "OpenGL GBuffer" })) if (int raygenstate = static_cast<int>(pathtracer->getRayGenerator()); ImGui::Combo("", &raygenstate, { "Trace [default]", "Line Space", "OpenGL GBuffer" }))
pathtracer->setRayGenerator(static_cast<raytrace::RayGenType>(raygenstate)); pathtracer->setRayGenerator(static_cast<raytrace::RayGenType>(raygenstate));
ImGui::PopItemWidth(); ImGui::PopItemWidth();
} }
......
...@@ -147,13 +147,9 @@ namespace glare::raytrace ...@@ -147,13 +147,9 @@ namespace glare::raytrace
void Pathtracer::saveRender(const fs::path& target) const void Pathtracer::saveRender(const fs::path& target) const
{ {
if (target.extension() == ".hdr") if (target.extension() == ".hdr")
{
m_render_target->get<float>().save(target); m_render_target->get<float>().save(target);
}
else else
{
m_render_target->get<uint8_t>().save(target); m_render_target->get<uint8_t>().save(target);
}
} }
int& Pathtracer::EffectArray::operator[](Effect effect) int& Pathtracer::EffectArray::operator[](Effect effect)
......
...@@ -31,6 +31,7 @@ namespace glare::raytrace ...@@ -31,6 +31,7 @@ namespace glare::raytrace
switch (pathtracer.getRayGenerator()) switch (pathtracer.getRayGenerator())
{ {
default: default:
case RayGenType::eLinespace:
case RayGenType::eTrace: generateTrace(pathtracer, updated_size); break; case RayGenType::eTrace: generateTrace(pathtracer, updated_size); break;
case RayGenType::eOpenGL: generateOpenGL(pathtracer, updated_size); break; case RayGenType::eOpenGL: generateOpenGL(pathtracer, updated_size); break;
} }
...@@ -43,6 +44,7 @@ namespace glare::raytrace ...@@ -43,6 +44,7 @@ namespace glare::raytrace
generator_program->uniform("u_render_target", pathtracer.renderTarget().imageAddress(gl::Access::eReadWrite)); generator_program->uniform("u_render_target", pathtracer.renderTarget().imageAddress(gl::Access::eReadWrite));
generator_program->storageBuffer("trace_buffer", pathtracer.traceBuffer()); generator_program->storageBuffer("trace_buffer", pathtracer.traceBuffer());
generator_program->uniform("random_seed", randomSeed()); generator_program->uniform("random_seed", randomSeed());
generator_program->uniform("use_linespace", pathtracer.getRayGenerator() == RayGenType::eLinespace);
pathtracer.collector()->apply(*generator_program); pathtracer.collector()->apply(*generator_program);
generator_program->dispatch2D(m_last_width, 12, m_last_height, 12); generator_program->dispatch2D(m_last_width, 12, m_last_height, 12);
......
...@@ -16,7 +16,8 @@ namespace glare::raytrace ...@@ -16,7 +16,8 @@ namespace glare::raytrace
enum class RayGenType enum class RayGenType
{ {
eTrace = 0, eTrace = 0,
eOpenGL = 1 eLinespace = 1,
eOpenGL = 2
}; };
class RayGenerator class RayGenerator
......
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