Snippets

Joseph Chow Getting current fragment position glsl

Created by Joseph Chow
1
2
3
4
5
6
7
// Fragment coordinate in NDC (Normalized Device Coordinates) for ShaderToy
// Coordinates of the fragment in the range of [-1,1]
// this of course can vary depending on your enviroment details, for instance, gl_FragCoord(which is what I'm assuming 
// "fragCoord" is aliasing, doesn't exist in OpenGL 3.2+ and is instead "gl_PointCoord" but the idea is the same.

vec2 q = ( 2.0 * fragCoord.xy - iResolution.xy ) / iResolution.y;
        

Comments (0)

HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.