Dissolve sprites on distance from camera

Hi,

I try to write a shader to dissolve point sprites when they get closer to the camera so that the particles don’t clip or get too big. My guess is to multiply the alpha based on a normalized distance from the camera like length(camSpaceVert).

Thank you for helping or pointing me to the right ressources.

Vincent

You might be able to access the depth component from gl_FragDepth or gl_FragCoord in the fragment shader, and then remap it using the near/far clip values into a normalized value.

You could go further by using that normalized value to sample from a black to white texture with a custom lookup curve for controlling alpha falloff.