mirror of
https://github.com/TheRedShip/RT_GPU.git
synced 2025-09-27 10:48:34 +02:00
~ | Fixing fog lighting acne and denoising not clearing
This commit is contained in:
@ -39,7 +39,7 @@ class Window
|
|||||||
static void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods);
|
static void mouseButtonCallback(GLFWwindow *window, int button, int action, int mods);
|
||||||
|
|
||||||
void imGuiNewFrame();
|
void imGuiNewFrame();
|
||||||
void imGuiRender(ShaderProgram &raytracing_program);
|
void imGuiRender(ShaderProgram &raytracing_program, std::vector<GLuint> &textures);
|
||||||
|
|
||||||
GLFWwindow *getWindow(void) const;
|
GLFWwindow *getWindow(void) const;
|
||||||
float getFps(void) const;
|
float getFps(void) const;
|
||||||
|
@ -84,7 +84,7 @@ vec3 sampleSphereLight(vec3 position, GPUObject obj, int light_index, GPUMateria
|
|||||||
}
|
}
|
||||||
|
|
||||||
float cos_theta = max(0.0, -dot(light_dir, normalize(sample_point - obj.position)));
|
float cos_theta = max(0.0, -dot(light_dir, normalize(sample_point - obj.position)));
|
||||||
return mat.emission * mat.color / (light_dist * light_dist) * cos_theta / (4.0 * M_PI * (obj.radius / 2.0) * (obj.radius / 2.0));
|
return mat.emission * mat.color / max(light_dist * light_dist, 1.0) * cos_theta / (4.0 * M_PI * (obj.radius / 2.0) * (obj.radius / 2.0));
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 sampleQuadLight(vec3 position, GPUObject obj, int light_index, GPUMaterial mat, inout uint rng_state)
|
vec3 sampleQuadLight(vec3 position, GPUObject obj, int light_index, GPUMaterial mat, inout uint rng_state)
|
||||||
@ -123,8 +123,8 @@ vec3 sampleQuadLight(vec3 position, GPUObject obj, int light_index, GPUMaterial
|
|||||||
float area = length(crossQuad);
|
float area = length(crossQuad);
|
||||||
float pdf = 1.0 / area;
|
float pdf = 1.0 / area;
|
||||||
|
|
||||||
float cos_theta = max(0.0, dot(obj.normal, -light_dir));
|
// float cos_theta = max(0.0, dot(obj.normal, -light_dir));
|
||||||
return mat.emission * mat.color / (light_dist * light_dist) * pdf;
|
return mat.emission * mat.color / max(light_dist * light_dist, 1.);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec3 sampleLights(in vec3 position, inout uint rng_state)
|
vec3 sampleLights(in vec3 position, inout uint rng_state)
|
||||||
|
@ -100,7 +100,7 @@ int main(int argc, char **argv)
|
|||||||
render_program.use();
|
render_program.use();
|
||||||
drawScreenTriangle(VAO, textures[window.getOutputTexture()], render_program.getProgram());
|
drawScreenTriangle(VAO, textures[window.getOutputTexture()], render_program.getProgram());
|
||||||
|
|
||||||
window.imGuiRender(raytracing_program);
|
window.imGuiRender(raytracing_program, textures);
|
||||||
|
|
||||||
window.display();
|
window.display();
|
||||||
window.pollEvents();
|
window.pollEvents();
|
||||||
|
@ -200,7 +200,7 @@ void Window::imGuiNewFrame()
|
|||||||
ImGui::NewFrame();
|
ImGui::NewFrame();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Window::imGuiRender(ShaderProgram &raytracing_program)
|
void Window::imGuiRender(ShaderProgram &raytracing_program, std::vector<GLuint> &textures)
|
||||||
{
|
{
|
||||||
bool has_changed = false;
|
bool has_changed = false;
|
||||||
|
|
||||||
@ -298,7 +298,12 @@ void Window::imGuiRender(ShaderProgram &raytracing_program)
|
|||||||
|
|
||||||
if (ImGui::CollapsingHeader("Denoiser"))
|
if (ImGui::CollapsingHeader("Denoiser"))
|
||||||
{
|
{
|
||||||
ImGui::Checkbox("Enable##1", (bool *)(&_scene->getDenoise().enabled));
|
if (ImGui::Checkbox("Enable##1", (bool *)(&_scene->getDenoise().enabled)))
|
||||||
|
{
|
||||||
|
//clear denoising texture
|
||||||
|
glClearTexImage(textures[3], 0, GL_RGBA, GL_FLOAT, nullptr);
|
||||||
|
glClearTexImage(textures[4], 0, GL_RGBA, GL_FLOAT, nullptr);
|
||||||
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
if (ImGui::SliderInt("Pass", &_scene->getDenoise().pass, 0, 8))
|
if (ImGui::SliderInt("Pass", &_scene->getDenoise().pass, 0, 8))
|
||||||
_scene->getDenoise().pass = (_scene->getDenoise().pass / 2) * 2; // make sure it's even
|
_scene->getDenoise().pass = (_scene->getDenoise().pass / 2) * 2; // make sure it's even
|
||||||
|
Reference in New Issue
Block a user