Godrays shader issue

I have this script Glitch :・゚✧

The issue that I have is at the edges where the rays are ending it looks bad, is not interpolated smoothly alpha alpha-based, on a glitch, is looks acceptable but on my project in Vite is even worse, not sure what is going on and how to fix it, I tried AI, no luck…

You can see live here just hold the mouse and drag Future Web Fesign - home

Maybe is color banding. Try dithering postprocess with code:

vec3 dither_shift_RGB_1=2.0*vec3(0.25/255.0,-0.25/255.0,0.25/255.0);
vec3 dither_shift_RGB_2=-2.0*vec3(0.25/255.0,-0.25/255.0,0.25/255.0);
float grid_position=fract(sin(gl_FragCoord.x*12.9898+gl_FragCoord.y*78.233)*43758.5453);
vec3 dither_shift_RGB=mix(dither_shift_RGB_1,dither_shift_RGB_2,grid_position);
gl_FragColor.rgb=clamp(gl_FragColor.rgb+dither_shift_RGB,0.0,1.0);
2 Likes

I think you probably need to control the source of the godrays to never create the situation where it clips with camera.. or make it fade out when you detect that its going to intersect the camera.

something like.. opacity = abs(normalize(emitter.position - camera.position) dot ( camera look direction ))

edit: NVM, this isn’t actual “godrays” in the 3d sense. its a 2d shader effect on a plane.

1 Like

The issue is the fading out, at the end of the rays, it is not getting all the way to zero smoothly interpolated, and it creates those artifacts. the issue is created here float alpha = min(c, c1);

On the glitch version, it looks much better than on my version, which is also something I don’t understand…

I tried, no luck, is crazy that I can’t fade the opacity correctly… it shuld be a simple job…