Skip to content

Instantly share code, notes, and snippets.

@gero3
Created September 12, 2012 09:31
Show Gist options
  • Save gero3/3705525 to your computer and use it in GitHub Desktop.
Save gero3/3705525 to your computer and use it in GitHub Desktop.
description of shadermaterial
/*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