Skip to content

Instantly share code, notes, and snippets.

@otanodesignco
Last active August 1, 2023 06:42
Show Gist options
  • Save otanodesignco/215689f96c2efd9436d8e8b96326d9a2 to your computer and use it in GitHub Desktop.
Save otanodesignco/215689f96c2efd9436d8e8b96326d9a2 to your computer and use it in GitHub Desktop.
Calculate the screen space uv to map a texture over the mesh regardless of the mesh position or orientation
/* Fragment shader
//
// Screen space
//
*/
uniform vec2 uResolution; // screen width and height
void main()
{
vec2 uv = gl_FragCoord.xy / uResolution; // screen space uv to map textures to the full shape of the model regardless of position
gl_FragColor = vec4( uv, 0.8, 1.0 ); // display uv
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment