Created
March 17, 2021 14:57
-
-
Save hamid814/4cdc7bc51fba781cf02e65d208fe1b39 to your computer and use it in GitHub Desktop.
Threejs mirror shader. Splits screen into four. Use in shaderpass
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
uniform sampler2D tDiffuse; | |
varying vec2 vUv; | |
float map(float value, float min1, float max1, float min2, float max2) { | |
return min2 + (value - min1) * (max2 - min2) / (max1 - min1); | |
} | |
void main() { | |
vec2 doubleUv = vUv * 2.0; | |
if(vUv.x > 0.5) doubleUv.x = map(doubleUv.x - 1.0, 0.0, 1.0, 1.0, 0.0); | |
if (vUv.y > 0.5) doubleUv.y = map(doubleUv.y - 1.0, 0.0, 1.0, 1.0, 0.0); | |
gl_FragColor = texture2D(tDiffuse, doubleUv); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment