Should gl_FragCoord work in something like the Image Filter example project?
Could it be made to work?
Should gl_FragCoord work in something like the Image Filter example project?
Could it be made to work?
Should gl_FragCoord work in something like the Image Filter example project?
Yes; if I understand correctly, it should and does work.
In test.adjustColorBrightness.c
, I replaced the contents of main()
with this:
gl_FragColor = vec4(gl_FragCoord.x/640., gl_FragCoord.y/480., 0., 1.);
…and fed it a 640x480 image. It rendered the attached 2D gradient, which I believe is correct. I also tested it in a 3D object shader, and it correctly provides normalized depth coordinates, too.
(For 2D shaders with VuoImageRenderer
, it may be easier to use varying vec4 fragmentTextureCoordinate;
since that’s already normalized to the size of the image.)
Are you seeing or expecting something different?