Spotlight theory

Started by
1 comment, last by MENTAL 20 years, 12 months ago
Right then. i think i've got it sorted. The big red thing is the light, the big red arrow is the light direction, and the dark red lines are the cut-off angle. The blue thing is the vertex position and normal. Random Scribble right then. make a vector from the light position to the vertex and normalize. dot it with the light direction. if it's outside cos(cutoff) then don't light it. if not, dot the light angle with the normal. the result is the luminance of the vertex. clamp to 0,1. i don't need anything past that (oh the joys of cel-shading). of course, it's probably miles off - i've just been combining directional and positional lighting theories plus a little (and i do mean little) trig. thanks in advance EDIT: wrong url [edited by - MENTAL on April 20, 2003 6:30:26 PM]
Advertisement
Hey, great art you have there...

But your algo sounds OK, if I got it right. You might want to add some fadeout towards the spot cutoff ? Here''s the typical pseudo code for spotlights:

s = light_to_vertex_normalized DOT spot_light_direction_normalized

if( s < cos(cutoff) ) return

spot_factor = pow(s, spot_light_exponent)

final_intensity = (N dot vertex_to_light_normalized) * spot_factor

yeah, beats the crap out of your puny screenshots don''t it

anyway, i was thinking about adding some fadeout (both for the cutoff and radius) but it looks a bit rubbishy when cel-shading (i tried it for positional lights, and imo it would look even worse for spotlights).

i just wanted to make sure the light angle dot normal bit was correct (the rest of it kinda made sense)

cheers

This topic is closed to new replies.

Advertisement