Last active
November 8, 2022 12:45
-
-
Save ramboldio/828bac8855f20b8ed939aa45027eeb72 to your computer and use it in GitHub Desktop.
Three.js / WebGL Custom texture shader
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
<script type="x-shader/x-vertex" id="vertexshader"> | |
// switch on high precision floats | |
#ifdef GL_ES | |
precision highp float; | |
#endif | |
varying vec2 texcoord; | |
void main() | |
{ | |
gl_Position = projectionMatrix * modelViewMatrix * vec4(position,1.0); | |
texcoord = uv; | |
} | |
</script> | |
<script type="x-shader/x-fragment" id="fragmentshader"> | |
#ifdef GL_ES | |
precision highp float; | |
#endif | |
varying vec2 texcoord; | |
uniform sampler2D u_texture; | |
void main() | |
{ | |
/* Set color of the fragment */ | |
gl_FragColor = texture2D(u_texture, texcoord); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, this really helped me on a project I am working on.