Created
September 12, 2012 09:31
-
-
Save gero3/3705525 to your computer and use it in GitHub Desktop.
description of shadermaterial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*global THREE:true requestAnimationFrame:true shaders:true*/ | |
var shaders = { | |
splat:{ | |
defines : {"USE_DIFFUSE2" : true}, | |
uniforms:{ | |
"alpha1" : { type: "t", value: null }, | |
"diffuse1" : { type: "t", value: null }, | |
"multiplier1" : {type: "f", value: 16.0 }, | |
"offset1" : {type: "f", value: 0.5 }, | |
"diffuse2" : { type: "t", value: null, defined: "USE_DIFFUSE2"}, | |
"multiplier2" : {type: "f", value: 1.0, defined: "USE_DIFFUSE2" }, | |
"offset2" : {type: "f", value: 0, defined: "USE_DIFFUSE2"} | |
}, | |
vertexShader:[ | |
"varying vec2 vUv;", | |
"", | |
"void main() {", | |
" ", | |
" vUv = uv;", | |
" vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", | |
" gl_Position = projectionMatrix * mvPosition;", | |
" ", | |
"}" | |
].join("\n"), | |
fragmentShader:[ | |
"uniform sampler2D alpha1;", | |
"uniform sampler2D diffuse1;", | |
"uniform float multiplier1;", | |
"uniform float offset1;", | |
"#ifdef USE_DIFFUSE2", | |
" uniform sampler2D diffuse2;", | |
" uniform float multiplier2;", | |
" uniform float offset2;", | |
"#endif", | |
"varying vec2 vUv;", | |
"", | |
"void main() {", | |
" vec4 alphaBlend = texture2D( alpha1, vUv);", | |
" vec4 texel1 = texture2D( diffuse1, offset1 + vUv * multiplier1 );", | |
" #ifdef USE_DIFFUSE2", | |
" vec4 texel2 = texture2D( diffuse2, offset2 + vUv * multiplier2 );", | |
" #endif", | |
" gl_FragColor = texel1;", | |
"}" | |
].join("\n") | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment