Particle lighting : cos + sin is a good solution ?

Started by
0 comments, last by C0lumbo 8 years, 4 months ago

Hi,

Using cos and sin you can compute the normal for the particle lighting :


n.x = -cos( pi * uv.x );
n.y = -cos( pi * uv.y );
n.z = sin( pi * length( uv ) );
n = normalize( n );

Is it a good way or a better way exists ?

Thanks

Advertisement

You could replace a sin and a normalize with a sqrt:

n.z = sqrtf(max(0.0f, 1.0f - n.x*n.x - n.y*n.y))

I'm sure there's many other solutions. A texture lookup would probably be faster on mobile (but probably slower on desktop GPUs).

This topic is closed to new replies.

Advertisement