Archived

This topic is now archived and is closed to further replies.

johnnyBravo

My lighting isn't lighting my objects material colours properly..

Recommended Posts

My situation is that I have a bunch of meshes and vertices. All in my scene coloured by materials. I have the ambient lighting set to 0. I''ve got my point light casting white light onto my objects. The problem is the light reflected is 1. Even if i set red to 0.5, my green to 0.0001, etc it will still return the light as 1. That is as long as the rgb has any value higher than 0, it will reflect the colour as 1. I can''t see what the problem is. For I want to reflect different tones of green , red , blue etc. heres sections of my code that show what i am doing. my setlight function which creates the light, positioning etc
	void SetLight(int index, D3DLIGHTTYPE type, float range, float x, float y, float z, float r, float g, float b, float a)
	{
		
		D3DLIGHT9 light;
		ZeroMemory( &light, sizeof(D3DLIGHT9) );
    	light.Type       = type;
		light.Diffuse.r  = r;
		light.Diffuse.g  = g;
		light.Diffuse.b  = b;
		light.Diffuse.a  = a;	
 		light.Range      = range;
		light.Position.x = x;
		light.Position.y = y;
		light.Position.z = z;
    
		myDevice->SetLight( index, &light );
	}
This function sets my materials
	void SetColour3D(float r, float g, float b, float a)
	{
		D3DMATERIAL9 mtrl;
		ZeroMemory( &mtrl, sizeof(D3DMATERIAL9) );
		mtrl.Diffuse.r = mtrl.Ambient.r  = r;
		mtrl.Diffuse.g = mtrl.Ambient.g  = g;
		mtrl.Diffuse.b = mtrl.Ambient.b  = b;
		mtrl.Diffuse.a = mtrl.Ambient.a = a;
		myDevice->SetMaterial( &mtrl );
	}

Share this post


Link to post
Share on other sites
The usual suspect:
- do your vertices contain normals?
- have you enabled lighting?
- have you set the diffuse material source to material?

Share this post


Link to post
Share on other sites
Maybe the light is saturating at all distances... try setting the attenuation parameters on your light to something easy ( eg. constant=0, linear=1, quadratic=0 ) and see if this makes a difference.

Share this post


Link to post
Share on other sites