Exposed shadow map bias to light gui
parent
33a2e1d8cb
commit
894377d440
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -29,6 +29,7 @@ struct Light {
|
|||
float mNear;
|
||||
float mFar;
|
||||
float mBBoxSize;
|
||||
float mShadowBias = 0.003;
|
||||
|
||||
Matrix44f mLightSpaceMatrix;
|
||||
|
||||
|
|
Loading…
Reference in New Issue