Sha256: 55eec396730f41e708bced289833528b66c61d3f746e522a1c7c3f371272dc64
Contents?: true
Size: 1.01 KB
Versions: 21
Compression:
Stored size: 1.01 KB
Contents
#ifdef USE_BUMPMAP uniform sampler2D bumpMap; uniform float bumpScale; // Derivative maps - bump mapping unparametrized surfaces by Morten Mikkelsen // http://mmikkelsen3d.blogspot.sk/2011/07/derivative-maps.html // Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2) vec2 dHdxy_fwd() { vec2 dSTdx = dFdx( vUv ); vec2 dSTdy = dFdy( vUv ); float Hll = bumpScale * texture( bumpMap, vUv ).x; float dBx = bumpScale * texture( bumpMap, vUv + dSTdx ).x - Hll; float dBy = bumpScale * texture( bumpMap, vUv + dSTdy ).x - Hll; return vec2( dBx, dBy ); } vec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) { vec3 vSigmaX = dFdx( surf_pos ); vec3 vSigmaY = dFdy( surf_pos ); vec3 vN = surf_norm; // normalized vec3 R1 = cross( vSigmaY, vN ); vec3 R2 = cross( vN, vSigmaX ); float fDet = dot( vSigmaX, R1 ); vec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 ); return normalize( abs( fDet ) * surf_norm - vGrad ); } #endif
Version data entries
21 entries across 21 versions & 2 rubygems