Archived

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

Settings for a spot light?

This topic is 5270 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hey im trying to make a spot light, like in the sdk example. Ive tried using the same settings as their code but can''t get it working. Does anyone know how to set it so i got a small circle spot light to point onto a surface. My settings so far are.
quote:
light.Type=D3DLIGHT_SPOT; light.Range=100; light.Falloff=1; light.Attenuation0=0.1; light.Attenuation1=0; light.Attenuation2=0; light.Theta=3; light.Phi=1;
the actual code is this
	void SetLight(int index, D3DLIGHTTYPE type, float range,float falloff, float theta, float phi, float x, float y, float z,float x2, float y2, float z2, 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;

light.Direction.x = x2;
light.Direction.y = y2;
light.Direction.z = z2;
light.Falloff = falloff;
light.Theta=theta;
light.Phi = phi;

if (type=D3DLIGHT_POINT )
{
light.Attenuation1 = 0.01f;
light.Attenuation0 = 0;
}
else
{
light.Attenuation1 = 0;
light.Attenuation0 = 0.01f;
}
myDevice->SetLight( index, &light );
}


Share on other sites
What does "can''t get it working" mean?

I''m going to make a guess and say that you probably don''t have enough vertices in the mesh you are attempting to light with the spotlight. Lighting occurs on a per-vertex basis so if you want to see a small circle of light from a spotlight, you''re going to need enough vertices to represent that circle.

Maybe your light is more than 100 units away from the vertices (beyond the light''s effective range).

Share on other sites
This may sound a bit off topic, but try avoiding use of the spotlight. The effect it gives is not worth it given the resources it uses up. Your best bet if possible is to use mutipass texturing and have an overlay texture that represents the spotlight.

Dave.

Share on other sites
Well by working i mean seeing the defining circle of light and actually having light. Everythings black.

Also don, so using multiple spot lights wouldnt be a good idea for a game?

If thats so i might just skip them and use point lights

Share on other sites
If the spotlights are in hardware and they give you the effect you want, then use them (especially if you''re limited by fill rate).

It sounds to me like you want to see a circle of light hitting a floor or wall. As I mentioned before, you won''t get that effect unless you tessellate the receiving surface into a lot of vertices. As suggested, you might do better using a light map.