Some preparations for cascaded shadow maps
parent
75677a5b70
commit
0950a04022
|
@ -29,7 +29,7 @@ float ShadowCalculationPCF(vec4 frag_pos_light_space, vec3 frag_normal_light_spa
|
||||||
projected_coordinates = projected_coordinates * 0.5 + 0.5;
|
projected_coordinates = projected_coordinates * 0.5 + 0.5;
|
||||||
|
|
||||||
if (abs(projected_coordinates.z) > 1.0 ) {
|
if (abs(projected_coordinates.z) > 1.0 ) {
|
||||||
return 1.0;
|
return 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float current_depth = projected_coordinates.z;
|
float current_depth = projected_coordinates.z;
|
||||||
|
@ -74,6 +74,16 @@ float ShadowCalculation(vec4 frag_pos_light_space, vec3 frag_normal_light_space)
|
||||||
return current_depth - bias > closest_depth ? 1.0 : 0.0;
|
return current_depth - bias > closest_depth ? 1.0 : 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec3 get_cascade_color (float depth) {
|
||||||
|
if (depth < 0.97) {
|
||||||
|
return vec3 (1.0, 0.0, 0.0);
|
||||||
|
} else if (depth < 0.99) {
|
||||||
|
return vec3 (0.0, 1.0, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return vec3 (0.0, 0.0, 1.0);
|
||||||
|
}
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec3 color = texture(uColor, ioFragTexCoords).rgb;
|
vec3 color = texture(uColor, ioFragTexCoords).rgb;
|
||||||
vec3 normal = texture (uNormal, ioFragTexCoords).xyz;
|
vec3 normal = texture (uNormal, ioFragTexCoords).xyz;
|
||||||
|
@ -103,6 +113,8 @@ void main() {
|
||||||
vec3 normal_light_space = (transpose(inverse(uViewToLightSpaceMatrix)) * vec4(normal, 1.0)).xyz;
|
vec3 normal_light_space = (transpose(inverse(uViewToLightSpaceMatrix)) * vec4(normal, 1.0)).xyz;
|
||||||
float shadow = ShadowCalculationPCF(position_light_space, normal);
|
float shadow = ShadowCalculationPCF(position_light_space, normal);
|
||||||
|
|
||||||
outColor = (ambient * ambient_occlusion + (1.0 - shadow) * (diffuse + specular)) * ambient_occlusion;
|
// vec3 cascade = get_cascade_color(depth);
|
||||||
|
// ambient = cascade;
|
||||||
|
outColor = (ambient + (1.0 - shadow) * (diffuse + specular)) * ambient_occlusion;
|
||||||
// outColor = (ambient + (diffuse + specular)) * ambient_occlusion;
|
// outColor = (ambient + (diffuse + specular)) * ambient_occlusion;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue