Lighting textures

Hi,

I am dealing with a 3d texture, colored using a fragment shader. I need to add a diffuse light effect. Should this be done using a light source or in the fragment shader?

P.S.
I tried to create a light source as follows but it did not give any effect

 
LightAmbient : array[0..3] of GLfloat=( 0.5, 0.5, 0.5, 1);
LightDiffuse : array[0..3] of GLfloat=( 1.0, 1.0, 1.0, 1);
LightPosition : array[0..3] of GLfloat= ( 0.0, 0.0, 2.0, 0.0);

glLightfv(GL_LIGHT1, GL_AMBIENT, @LightAmbient);
glLightfv(GL_LIGHT1, GL_DIFFUSE, @LightDiffuse);
glLightfv(GL_LIGHT1, GL_POSITION,@LightPosition);
glEnable(GL_LIGHT1);

// draw texture

glEnable(GL_LIGHTING); 

Thanks :slight_smile:

Hmmm. I thought that when you use a fragment shader, the fixed function part is pretty much disabled altogether (which, I believe is kind of the point behind shader functionality)?

So I think you would have to put that functionality into your shader.