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

Version Path
mittsu-opengl-0.5.1 lib/mittsu/opengl/shader/chunks/bumpmap_pars_fragment.glsl
mittsu-0.4.1 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-opengl-0.5.0 lib/mittsu/opengl/shader/chunks/bumpmap_pars_fragment.glsl
mittsu-0.4.0 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.3.3 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.3.2 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.3.1 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.3.0 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.2.4 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.2.3 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.2.2 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.2.1 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.2.0 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.1.7 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.1.6 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.1.5 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.1.4 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.1.3 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.1.2 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl
mittsu-0.1.1 lib/mittsu/renderers/shaders/shader_chunk/bumpmap_pars_fragment.glsl