Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DLIGHT8 range equivalent in OpenGL

Started by thedigga007 Feb 14, 2008 at 1:50 PM 3 replies 1.6k views
Original Post
thedigga007
thedigga007
In D3D there is a "Range" value for point lights, is there a way to emulate this in OpenGL? definition: Range Distance beyond which the light has no effect. The maximum allowable value for this member is the square root of FLT_MAX. This member does not affect directional lights. Thanks edit: I tried this but it just doesnt look the same as it does on d3d...

lights[index].constant_atten = light->Attenuation0;
lights[index].linear_atten = light->Attenuation1/light->Range;
lights[index].quadratic_atten = light->Attenuation2+(1/(light->Range*light->Range));
V-man
V-man
Nope.
You can scan the spec yourself which is at www.opengl.org
thedigga007
thedigga007
Yeah that was the first thing I did. Unfortunately no such parameter exists in OpenGL for lighting.

quote d3d docs:

D = |VL|

In the preceding formula, D is the distance being calculated, V is the position of the vertex being lit, and L is the light source's position. If D is greater than the light's range, that is, the Range member of a D3DLIGHT8 structure, Direct3D makes no further attenuation calculations and applies no effects from the light to the vertex. If the distance is within the light's range, Direct3D then applies the following formula to calculate light attenuation over distance for point lights and spotlights.

A = 1/atten0 + D*atten1 + d^2*atten2

Now obviously without the ability to tell opengl that I want D = R if D > R I cannot reuse the same lighting data...soo it looks like its just not possible. Bummer.
desudesu
desudesu
Actually, you could probably easily pull it off using shaders.
thedigga007
thedigga007
This is true but I would prefer to use the fixed function pipeline =/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.