EEVEE: Fix bump mapping

Fix issue in latest patch and assure derivatives calculation is correct on
all GPU.
This commit is contained in:
Clément Foucault 2019-09-06 19:02:15 +02:00
parent 073624d4cc
commit d83734aa4b
3 changed files with 21 additions and 6 deletions

View File

@ -369,6 +369,9 @@ void gpu_extensions_init(void)
}
/* df/dy calculation factors, those are dependent on driver */
GG.dfdyfactors[0] = 1.0;
GG.dfdyfactors[1] = 1.0;
if ((strstr(vendor, "ATI") && strstr(version, "3.3.10750"))) {
GG.dfdyfactors[0] = 1.0;
GG.dfdyfactors[1] = -1.0;
@ -383,10 +386,6 @@ void gpu_extensions_init(void)
GG.dfdyfactors[0] = -1.0;
GG.dfdyfactors[1] = 1.0;
}
else {
GG.dfdyfactors[0] = 1.0;
GG.dfdyfactors[1] = 1.0;
}
if (strstr(version, "Build 10.18.10.3") || strstr(version, "Build 10.18.10.4") ||
strstr(version, "Build 10.18.14.4") || strstr(version, "Build 10.18.14.5")) {

View File

@ -275,6 +275,22 @@ static void gpu_shader_standard_defines(char defines[MAX_DEFINE_LENGTH])
strcat(defines, "#define OS_UNIX\n");
}
float derivatives_factors[2];
GPU_get_dfdy_factors(derivatives_factors);
if (derivatives_factors[0] == 1.0f) {
strcat(defines, "#define DFDX_SIGN 1.0\n");
}
else {
strcat(defines, "#define DFDX_SIGN -1.0\n");
}
if (derivatives_factors[1] == 1.0f) {
strcat(defines, "#define DFDY_SIGN 1.0\n");
}
else {
strcat(defines, "#define DFDY_SIGN -1.0\n");
}
return;
}

View File

@ -1,11 +1,11 @@
void dfdx_v3(vec3 v, out vec3 dy)
{
dy = v + abs(dFdx(v));
dy = v + DFDX_SIGN * dFdx(v);
}
void dfdy_v3(vec3 v, out vec3 dy)
{
dy = v + abs(dFdy(v));
dy = v + DFDY_SIGN * dFdy(v);
}
void node_bump(float strength,