Exposed shadow map bias to light gui

simple_math_single_header
Martin Felis 2018-06-25 16:55:01 +02:00
parent 33a2e1d8cb
commit 894377d440
3 changed files with 5 additions and 1 deletions

View File

@ -18,6 +18,7 @@ uniform sampler2D uPosition;
uniform vec3 uLightDirection;
uniform mat4 uLightSpaceMatrix;
uniform mat4 uViewToLightSpaceMatrix;
uniform float uShadowBias;
in vec2 ioFragTexCoords;
@ -30,7 +31,7 @@ float ShadowCalculationPCF(vec4 frag_pos_light_space, vec3 frag_normal_light_spa
float current_depth = projected_coordinates.z;
float bias = 0.00;
bias = max(0.02 * (1.0 - dot(frag_normal_light_space, uLightDirection)), 0.003);
bias = max(0.01 * (1.0 - dot(frag_normal_light_space, uLightDirection)), uShadowBias);
float shadow = 0.0;
vec2 texel_size = 1.0 / textureSize(uShadowMap, 0);

View File

@ -208,6 +208,7 @@ void Light::DrawGui() {
ImGui::SliderFloat("Volume Size", &mBBoxSize, 1.0f, 50.0f);
ImGui::SliderFloat("Near", &mNear, -10.0f, 50.0f);
ImGui::SliderFloat("Far", &mFar, -10.0f, 50.0f);
ImGui::SliderFloat("Shadow Bias", &mShadowBias, 0.0f, 0.01f, "%.5f", 1.0f);
ImVec2 content_avail = ImGui::GetContentRegionAvail();
@ -699,6 +700,7 @@ void Renderer::RenderGl() {
Vector3f light_direction = view_mat_rot * mLight.mDirection.normalized();
mDeferredLighting.SetVec3("uLightDirection", light_direction.normalized());
mDeferredLighting.SetFloat("uShadowBias", mLight.mShadowBias);
gVertexArray.Bind();
gScreenQuad.Draw(GL_TRIANGLES);

View File

@ -29,6 +29,7 @@ struct Light {
float mNear;
float mFar;
float mBBoxSize;
float mShadowBias = 0.003;
Matrix44f mLightSpaceMatrix;