Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/gpu/intern/gpu_shader_material.glsl')
-rw-r--r--source/blender/gpu/intern/gpu_shader_material.glsl16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_shader_material.glsl b/source/blender/gpu/intern/gpu_shader_material.glsl
index feb0a84fa87..0aae6d84a01 100644
--- a/source/blender/gpu/intern/gpu_shader_material.glsl
+++ b/source/blender/gpu/intern/gpu_shader_material.glsl
@@ -1226,6 +1226,22 @@ void mtex_bump_tap5( vec3 texco, sampler2D ima, float hScale,
dBt = hScale * (Hu - Hd);
}
+void mtex_bump_deriv( vec3 texco, sampler2D ima, float ima_x, float ima_y, float hScale,
+ out float dBs, out float dBt )
+{
+ float s = 1; // negate this if flipped texture coordinate
+ vec2 TexDx = dFdx(texco.xy);
+ vec2 TexDy = dFdy(texco.xy);
+
+ // this variant using a derivative map is described here
+ // http://mmikkelsen3d.blogspot.com/2011/07/derivative-maps.html
+ vec2 dim = vec2(ima_x, ima_y);
+ vec2 dBduv = hScale*dim*(2*texture2D(ima, texco.xy).xy-1);
+
+ dBs = dBduv.x*TexDx.x + s*dBduv.y*TexDx.y;
+ dBt = dBduv.x*TexDy.x + s*dBduv.y*TexDy.y;
+}
+
void mtex_bump_apply( float fDet, float dBs, float dBt, vec3 vR1, vec3 vR2, vec3 vNacc_in,
out vec3 vNacc_out, out vec3 perturbed_norm )
{