Add support for displacement mapping to the SceneJS.Texture
node.
This would involve extending the texture layer "applyTo" mode to
target texturing output at vertices within GLSL, along with
extensions to the GLSL program generator.
Notes
- Internal pixel format of GL_RGBA_FLOAT32_ATI
- Map must not be filtered - must be nearest mode
Bilear filtering can be done in GLSL like this though:
#define textureSize 256.0
#define texelSize 1.0 / 256.0
vec4 texture2D_bilinear( uniform sampler2D tex, vec2 uv )
{
vec2 f = fract( uv.xy * textureSize );
vec4 t00 = texture2D( tex, uv );
vec4 t10 = texture2D( tex, uv + vec2( texelSize, 0.0 ));
vec4 tA = mix( t00, t10, f.x );
vec4 t01 = texture2D( tex, uv + vec2( 0.0, texelSize ) );
vec4 t11 = texture2D( tex, uv + vec2( texelSize, texelSize ) );
vec4 tB = mix( t01, t11, f.x );
return mix( tA, tB, f.y );
}
Links