#### Archived

This topic is now archived and is closed to further replies.

# Spotlight theory

This topic is 5714 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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. 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]

##### Share on other sites
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

##### Share on other sites
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

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
13
5. 5
frob
12

• 9
• 9
• 11
• 11
• 23
• ### Forum Statistics

• Total Topics
633667
• Total Posts
3013254
×