opengl - Fragment shader smooth opacity -


what want achieve quite simple, given

a center point radius color 

draw circle @ center point given color filled in.

the center of circle 100% color , color fade out way along radius.

here have achieved

(bgcolor: 10, 20, 30, 255, lightcolor: 100, 100, 30, 255):

enter image description here

the shader code fragment:

#ifdef gl_es precision highp float; #endif  uniform vec2 center; uniform vec4 lightcolor; uniform float lightradius;  void main() {     float distance = abs(distance(center, gl_fragcoord.xy));     gl_fragcolor = vec4(lightcolor * (1.0 - 1.0 / lightradius * distance)); } 

the problem color fading center edge not smooth (it might seem obvious in screenshot above though).

i wonder if there way make smooth fade out circle?

any advice appreciated, :)

simple answer:if wanna smth i'll use tweaked phong lighting . vector math better gradients think. can try change 1.o 1.0lf. it's #version 400 core stuff


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -