Spotlight - inner cone angle

BlitzMax Forums/OpenGL Module/Spotlight - inner cone angle

simonh(Posted 2006) [#1]
Does anyone know how to convert the GL_SPOT_EXPONENT value in OpenGL to B3D's inner cone angle?

I have managed to convert B3D's light range (I think!), by setting the GL_LINEAR_ATTENUATION value to 1.0/light_range, and the other attenuation values to 0. This has got point lights working correctly, now I just need to get spotlights working too.


marksibly(Posted 2006) [#2]
Hi,

I don't think you can. GL_SPOT_EXPONENT looks like it controls the 'falloff rate' of the spotlight, whereas inner cone angle is more a binary thing - ie: everything inside the inner cone angle is 'fullbright'.


simonh(Posted 2006) [#3]
Oh, OK. I assumed that OpenGL would have something to match DirectX's inner cone value, seems not though.


simonh(Posted 2006) [#4]
For those that might be interested, A GL_SPOT_EXPONENT value of 10.0 seems to produce something that vaguely resembles B3D's spotlights when inner cone angle = 0.


JoshK(Posted 2006) [#5]
Thanks for the info. I will use this.

Because hardware lights are more or less infinite, and do not have a linear range, I recommend setting the attenuation to 0 (no attenutation) and multiplying the light color by a falloff value based on entity distance. For example, if the light's range is 100, the light color is 255,255,255, and a mesh is 75 units of distance away from the light, set the light color to 64,64,64 and render with no attentuation.

Before rendering each mesh, you have to enable and set up lights that are to effect that mesh. This also lets you check the line of sight, to test whether the light should effect the mesh or not. In my own engine, I only test the line of sight with brushes (which is fast), and don't worry about whether a mesh occludes another mesh.


puki(Posted 2006) [#6]
Um, reading "halo's" post - is lighting not much better than in B3D?


AntonyWells(Posted 2006) [#7]
What do you care? Your the least prolific coder in the whole world.


puki(Posted 2006) [#8]
I like to proceed at a leisurely pace. Like a tortoise circumnavigating the world.


Tom(Posted 2006) [#9]
Puki has a spotlight shining down onto his head, and it has a volumetric 'D' in the middle :P


JoshK(Posted 2006) [#10]
I think you need to tweak these parameters:
gllightfv GL_LIGHT0+n,GL_SPOT_DIRECTION,[0.0,-1.0,0.0,0.0]
gllightf GL_LIGHT0+n,GL_SPOT_CUTOFF,45.0

Um, reading "halo's" post - is lighting not much better than in B3D?

If you mean the lighting system I set up, try out the demos on my forums. The lighting is definitely more advanced than b3d.


simonh(Posted 2006) [#11]
Yeah cutoff is the outer cone angle (/2), direction is always kept the same.


JoshK(Posted 2006) [#12]
Then there is a SPOT_LIGHT_EXPONENT parameter, which I am guessing creates a gradient from the center out.


simonh(Posted 2006) [#13]
Yep as Mark said it controls the falloff rate.