GLBasic forum

Main forum => GLBasic - en => Topic started by: MrTAToad on 2011-Aug-29

Title: 3D Lighting
Post by: MrTAToad on 2011-Aug-29
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.
Title: Re: 3D Lighting
Post by: mentalthink on 2011-Aug-29
I like to have this parameter too, I think it´s essential in 3d.
Title: Re: 3D Lighting
Post by: Slydog on 2011-Aug-29
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.
Title: Re: 3D Lighting
Post by: mentalthink on 2011-Aug-29
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.

Title: Re: 3D Lighting
Post by: Kitty Hello on 2011-Aug-30
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

Title: Re: 3D Lighting
Post by: MrTAToad on 2011-Aug-30
I'll have to see if that can be used...

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