Tibi
May 27, 2023, 5:26pm
1
Hi.
I am trying to draw in a fragment shader a circle that is fuzzy like a point of light, I managed to do it but is not perfect as you can see in this image.
This is the project Plasmic Audio Player
If you increase the Unreal bloom pass strength in the live settings the sphere is not good, there is a fuzzy white square around it.
This is the code I used for the fragment shader.
float dist = length(vUv - vec2(0.5, 0.5));
float alpha = 1. - smoothstep(0., 0.03, dist);
gl_FragColor = vec4(uColor, alpha * uOpacity);
It has probably something to do with uOpacity
, try this:
float dist = length(vUv - vec2(0.5, 0.5));
float alpha = 1. - smoothstep(0., 0.5, dist);
gl_FragColor = vec4(uColor, alpha);
Tibi
June 3, 2023, 3:39pm
3
Yes, this works but I need the uOpacity to tween the opacity when the particles first appear.
Is there any other way to change the opacity of the shader?
Thank you!
This should work if uOpacity
is constant for all fragments and changes from 1.0 for full glow to 0.0 for full transparency (in a tween transition):
tfoller:
float dist = length(vUv - vec2(0.5, 0.5));
float alpha = 1. - smoothstep(0., 0.5, dist);
gl_FragColor = vec4(uColor, alpha * uOpacity);
if it doesn’t, then check uOpacity
- maybe it has an unusual value or is not set properly.
Tibi
June 3, 2023, 6:32pm
5
Yes the value is from 0.0 to 1.0.
I think is fine now.
Thank you for your help!