So I'm working on a WebGL code in JS that draws approximation of a given function using gl_POINTS
, and I'm trying to make those points' colors blend with background color the further from camera they get. So whenever user moves or rotates camera, colors change. I thought of using Blending function, but supposedly I'm supposed to implement that feature mostly in fragment shader.
All I figured out so far is that fragment shader has vec2 gl_FragCoord
built-in variable , but that doesn't seem to help much since it's only position on screen, doesn't really keep any z coordinate I could use. Am I missing something?