Working pcf, not optimized

This commit is contained in:
FakeShemp
2016-02-10 16:16:41 +01:00
parent 69db32337d
commit cb77c1ff97
3 changed files with 9 additions and 10 deletions
+2 -2
View File
@@ -58,8 +58,8 @@ private:
glm::mat4 m_LightView;
glm::mat4 m_LightSpaceMatrix;
GLuint resolutionSizeWidth = 2048 * 4;
GLuint resolutionSizeHeigth = 2048 * 4;
GLuint resolutionSizeWidth = 2048 * 2;
GLuint resolutionSizeHeigth = 2048 * 2;
bool m_ShadowOn = true;
};
+4 -5
View File
@@ -121,16 +121,15 @@ float CalcShadowValue(vec4 positionLightSpace, vec3 normal, vec3 lightDir, sampl
//float bias = max(0.05 * (1.0 - dot(normal, lightDir)), 0.005);
//float bias = 0.005 * tan(acos(clamp(dot(normal, lightDir), 0,1))); bias = clamp(bias, 0,0.01);
vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w;
vec3 projCoords = vec3(positionLightSpace.xy, positionLightSpace.z + bias) / positionLightSpace.w;
projCoords = projCoords * 0.5 + 0.5;
//float shadowMapDepth = texture(depthTexture, projCoords.xy).r;
float shadowMapDepth = 1.0 - texture(depthTexture, projCoords);
float shadowMapDepth = texture(depthTexture, projCoords);
float geometryDepth = projCoords.z;
//float shadow = geometryDepth - bias > shadowMapDepth ? 1.0 : 0.0;
//float shadow = geometryDepth - bias > shadowMapDepth ? 0.0 : 1.0;
float shadow = shadowMapDepth;
//float shadow = 1.0 - bias > shadowMapDepth ? 0.0 : 1.0;
//float shadow = 0.0;
float shadow = 1.0 - shadowMapDepth;
//vec2 texelSize = 1.0 / textureSize(depthTexture, 0);
//for(int x = -1; x <= 1; x++)
+3 -3
View File
@@ -33,7 +33,7 @@ void ShadowPass::InitializeFrameBuffers()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
//glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
m_DepthBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthMap, GL_DEPTH_ATTACHMENT)));
@@ -71,7 +71,7 @@ void ShadowPass::Draw(RenderScene & scene)
glViewport(0, 0, resolutionSizeWidth, resolutionSizeHeigth);
//glCullFace(GL_FRONT);
glCullFace(GL_FRONT);
//state->Disable(GL_CULL_FACE);
ImGui::DragFloat4("ShadowMapCam", m_LRBT, 1.f, -1000.f, 1000.f);
@@ -121,7 +121,7 @@ void ShadowPass::Draw(RenderScene & scene)
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
//glCullFace(GL_BACK);
glCullFace(GL_BACK);
m_ShadowProgram->Unbind();