glLightfv_(#GL_LIGHT1+Light, #GL_AMBIENT, @LColor())
glLightfv_(#GL_LIGHT1+Light, #GL_POSITION, @LPosition())
LColor() and LPosition() are arrays allocated 4 floats big. I always thought the 4th entry of LPosition() is the light range, but the light is very big(it goes constant over the whole world and is in the middle as light as at the border of the map). Light is the number of the light(current: 0).
Lightrange of PointLight with Color?
Hello, Well I am always reposition the light when I change the perspective matrix, but I always get this result: http://www.bradan.net/images/light.jpg This is the code for the light(It's PureBasic code, but understandable for you):
Thanks
The fourth element of position is not the range of the light. Position is a four element homogeneous coordinate for the light. Homogeneous coordinates are very useful and allow us to place items at infinite distance, which allows us to have directional or positional lights. A light with a non-zero w-coordinate is a positional light and is centered at a location in the world. A light with a w-coordinate of zero is infinitely far away and therefore all light from the light arrives from the same direction - we have a directional light.
Regardless of whether your light is positional or directional the "range" is always infinite. You can however attenuate the light contribution over distance. Each light has parameters for constant, linear and quadratic attenuation. The light contribution at distance d from the light is 1 / (c + ld + qd²), where c is the linear attenuation, l is the linear attenuation and q is the quadratic attenuation. A real light in a vacuum attenuates quadratically, but you'll want to play around with the parameters to get the best effect. Attenuation only works for positional lights because directional lights are by their very nature infinitely far away.
More information can be found in the Red Book. Copies of an early edition can be found online.
Enigma
Regardless of whether your light is positional or directional the "range" is always infinite. You can however attenuate the light contribution over distance. Each light has parameters for constant, linear and quadratic attenuation. The light contribution at distance d from the light is 1 / (c + ld + qd²), where c is the linear attenuation, l is the linear attenuation and q is the quadratic attenuation. A real light in a vacuum attenuates quadratically, but you'll want to play around with the parameters to get the best effect. Attenuation only works for positional lights because directional lights are by their very nature infinitely far away.
More information can be found in the Red Book. Copies of an early edition can be found online.
Enigma
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement