Correct specular highlights, light colors

This commit is contained in:
saschawillems 2016-07-17 15:14:52 +02:00
parent f3a86c292c
commit 94d8f7b94a
5 changed files with 21 additions and 26 deletions

View file

@ -73,7 +73,6 @@ float filterPCF(vec4 sc, float layer)
return shadowFactor / count;
}
void main()
{
// Get G-Buffer values
@ -112,18 +111,19 @@ void main()
float spotEffect = smoothstep(lightCosOuterAngle, lightCosInnerAngle, cosDir);
float heightAttenuation = smoothstep(lightRange, 0.0f, dist);
// Diffuse lighting.
// Diffuse lighting
float NdotL = max(0.0, dot(N, L));
vec3 diff = vec3(NdotL);
// Specular lighting.
// Specular lighting
vec3 R = reflect(-L, N);
float NdotR = max(0.0, dot(R, V));
vec3 spec = vec3(pow(NdotR, 16.0));
vec3 spec = vec3(pow(NdotR, 16.0) * albedo.a * 2.5);
fragcolor += vec3((diff + spec) * spotEffect * heightAttenuation) * ubo.lights[i].color.rgb * albedo.rgb ;
fragcolor += vec3((diff + spec) * spotEffect * heightAttenuation) * ubo.lights[i].color.rgb * albedo.rgb;
}
// Shadow calculations in a separate pass
for(int i = 0; i < LIGHT_COUNT; ++i)
{
vec4 shadowClip = ubo.lights[i].viewMatrix * vec4(fragPos, 1.0);

View file

@ -14,23 +14,14 @@ layout (binding = 0) uniform UBO
} ubo;
layout (location = 0) out vec2 outUV;
//layout (location = 1) out vec4 outShadowCoord;
out gl_PerVertex
{
vec4 gl_Position;
};
/*
const mat4 biasMat = mat4(
0.5, 0.0, 0.0, 0.0,
0.0, 0.5, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.5, 0.5, 0.0, 1.0 );
*/
void main()
{
outUV = inUV;
gl_Position = ubo.projection * ubo.modelview * vec4(inPos.xyz, 1.0);
//outShadowCoord = (biasMat * ubo.lightMVP * ubo.modelview) * vec4(inPos, 1.0);
}