diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 7 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 16 | ||||
-rw-r--r-- | source/blender/gpu/shaders/material/gpu_shader_material_bump.glsl | 4 |
3 files changed, 21 insertions, 6 deletions
diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index 5839b34cd19..0d8e246a2b4 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -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")) { diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 3e930d19696..5c2a41d19b3 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -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; } diff --git a/source/blender/gpu/shaders/material/gpu_shader_material_bump.glsl b/source/blender/gpu/shaders/material/gpu_shader_material_bump.glsl index fabc070b0bc..9f73f654217 100644 --- a/source/blender/gpu/shaders/material/gpu_shader_material_bump.glsl +++ b/source/blender/gpu/shaders/material/gpu_shader_material_bump.glsl @@ -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, |