Fix viewport
This commit is contained in:
@@ -114,27 +114,10 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
|
||||
return vec4(TBN * normalize(NormalMap), 0.0);
|
||||
}
|
||||
|
||||
//float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture)
|
||||
//{
|
||||
// // perform perspective divide
|
||||
// //vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w;
|
||||
// // Transform to [0,1] range
|
||||
// //projCoords = projCoords * 0.5 + 0.5;
|
||||
// // Get closest depth value from light's perspective (using [0,1] range fragPosLight as coords)
|
||||
// float closestDepth = texture(depthTexture, positionLightSpace.xy).r;
|
||||
// // Get depth of current fragment from light's perspective
|
||||
// float currentDepth = positionLightSpace.z;
|
||||
// // Check whether current frag pos is in shadow
|
||||
// float shadow = currentDepth > closestDepth ? 1.0 : 0.0;
|
||||
//
|
||||
// return shadow;
|
||||
//
|
||||
//}
|
||||
|
||||
float CalcShadowValue(vec4 positionLightSpace, vec4 normal, vec4 lightDir, sampler2D depthTexture)
|
||||
{
|
||||
|
||||
//float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005);
|
||||
float bias = max(0.05 * (1.0 - dot(normal, -lightDir)), 0.005);
|
||||
// perform perspective divide
|
||||
vec3 projCoords = positionLightSpace.xyz / positionLightSpace.w;
|
||||
// Transform to [0,1] range
|
||||
@@ -188,7 +171,7 @@ void main()
|
||||
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
||||
} else if (light.Type == 2) { //Directional
|
||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||
shadowFactor = CalcShadowValue(Input.PositionLightSpace, normal, light.Direction, DepthMap);
|
||||
shadowFactor = CalcShadowValue(Input.PositionLightSpace, vec4(Input.Normal, 0.0), light.Direction, DepthMap);
|
||||
}
|
||||
|
||||
totalLighting.Diffuse += light_result.Diffuse;
|
||||
|
||||
@@ -47,7 +47,7 @@ void main()
|
||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||
}
|
||||
|
||||
//vec4 lightPos = biasMatrix * LightP * LightV * M * vec4(Position, 1.0); // N
|
||||
//vec4 lightPos = LightP * LightV * M * vec4(Position, 1.0); // N
|
||||
|
||||
gl_Position = P*V*M*boneTransform * vec4(Position, 1.0);
|
||||
//gl_Position = lightPos; // N
|
||||
@@ -61,5 +61,5 @@ void main()
|
||||
Output.ExplosionPercentageElapsed = 0.0;
|
||||
|
||||
//Output.PositionLightSpace = lightPos; // N
|
||||
Output.PositionLightSpace = lightSpaceMatrix * (M * vec4(Position, 1.0));
|
||||
Output.PositionLightSpace = lightSpaceMatrix * M * vec4(Position, 1.0);
|
||||
}
|
||||
@@ -25,9 +25,8 @@ void ShadowPass::InitializeFrameBuffers()
|
||||
// Depth texture
|
||||
glGenTextures(1, &m_DepthMap);
|
||||
glBindTexture(GL_TEXTURE_2D, m_DepthMap);
|
||||
//glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||
//glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB16F, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height, 0, GL_RGB, GL_FLOAT, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
|
||||
Reference in New Issue
Block a user