3D Lighting

Previous topic - Next topic

MrTAToad

Is it possible for a spot light (or perhaps some other light) so that the intensity/brightness decreases over a set distance.  The spot light is infinite, although the angle defines which area gets lit, and thus everything no matter how far is generally well lit.

mentalthink

I like to have this parameter too, I think it´s essential in 3d.

Slydog

I've somewhat achieved this (to my satisfaction) using fog (X_FOG).  I use the 'LINEAR' mode.
I still have a spot light (or other light, can't remember) and I use the fog to gradually dim the light further away.

I'm not sure how computationally expensive this is, and maybe another light mode like you mentioned may be faster.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

mentalthink

Hi I use sometime the fog effect, but not works in all devices, If I don´t rebember Bad in Palm pre don´t works, and I think it´s a powerfull cosume CPU.

I don´t think if can be too much complicated add, this parameter, but I think this can open dors, in 3D in Glbasic, I don´t use too much ligth or no one, but in some cases it´s very useful have this control over the lights.


Kitty Hello

This is what the EntitySystem does:

Code (glbasic) Select

IF o.cnst > 0 OR o.linear > 0 OR o.quadratic > 0
INLINE
#ifdef HAVE_OPENGL
    #define GL_LIGHT0 0x4000
    #define GL_CONSTANT_ATTENUATION 0x1207
    #define GL_LINEAR_ATTENUATION             0x1208
    #define GL_QUADRATIC_ATTENUATION          0x1209
    glLightf(GL_LIGHT0+iLight, GL_CONSTANT_ATTENUATION,  o.cnst);
    glLightf(GL_LIGHT0+iLight, GL_LINEAR_ATTENUATION, o.linear);
    glLightf(GL_LIGHT0+iLight, GL_QUADRATIC_ATTENUATION, o.quadratic);
    #else
    // #error no light attentiation
    #endif
ENDINLINE
ENDIF


MrTAToad

#5
I'll have to see if that can be used...

Is it possible to calculate the attenuation values from a given (distance) value ?