Eevee: Fix crash on core profile.

This commit is contained in:
Clément Foucault 2017-04-18 19:13:18 +02:00
parent 85b4398d90
commit 5bbc803ff0
3 changed files with 7 additions and 6 deletions

View File

@ -153,9 +153,9 @@ void make_orthonormal_basis(vec3 N, out vec3 T, out vec3 B)
}
/* ---- Opengl Depth conversion ---- */
float linear_depth(float z, float zf, float zn)
float linear_depth(bool is_persp, float z, float zf, float zn)
{
if (gl_ProjectionMatrix[3][3] == 0.0) {
if (is_persp) {
return (zn * zf) / (z * (zn - zf) + zf);
}
else {
@ -163,9 +163,9 @@ float linear_depth(float z, float zf, float zn)
}
}
float buffer_depth(float z, float zf, float zn)
float buffer_depth(bool is_persp, float z, float zf, float zn)
{
if (gl_ProjectionMatrix[3][3] == 0.0) {
if (is_persp) {
return (zf * (zn - z)) / (z * (zn - zf));
}
else {

View File

@ -8,7 +8,7 @@ vec2 jitternoise = vec2(0.0);
void setup_noise(void)
{
jitternoise = texture(texJitter, gl_FragCoord.xy / NOISE_SIZE, 0).rg; /* Global variable */
jitternoise = texture(texJitter, gl_FragCoord.xy / NOISE_SIZE).rg; /* Global variable */
}
vec3 hammersley_3d(float i, float invsamplenbr)

View File

@ -153,7 +153,8 @@ float light_visibility(LightData ld, ShadingData sd)
/* Depth in lightspace to compare against shadow map */
float w = dot(maj_axis, sd.l_vector);
w -= scd.sh_map_bias * w;
float shdepth = buffer_depth(w, scd.sh_cube_far, scd.sh_cube_near);
bool is_persp = (ProjectionMatrix[3][3] == 0.0);
float shdepth = buffer_depth(is_persp, w, scd.sh_cube_far, scd.sh_cube_near);
vis *= texture(shadowCubes, vec4(uvs, shid * 6.0 + face, shdepth));
}