Sign in to follow this  

point lights not working

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi, I'm trying to getting lighting in a scene but can't seem to do it, I have loaded a .x skinned mesh from file using my own parser and state sorted the vertices by material, when I set the material for each batch of vertices I set the diffuse equal to the ambient for each material.

D3DLIGHT9 light;
D3DMATERIAL9 material;

material.Diffuse = material.Ambient = ...;

light.Type = D3DLIGHT_POINT;
light.Diffuse.r = 0.5f;
light.Diffuse.g = 0.5f
.....

light.Attenation0 = 0.1f;
light.Range = 1000.0f

pDevice->SetLight(0, &light);
pDevice->LightEnable(0, TRUE);

pDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
pDevice->SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(110, 0, 0)); 

The problem is that nothing is happening, the ambient light works fine and the material colours are spot on but there is no point lights in the scene? I also set the vertex format to look like:

pDevice->SetFVF(D3DFVF_XYZ | D3DFVF_NORMAL | D3DFVF_DIFFUSE | D3DFVF_TEX1);

typedef struct
{
   vect3 pos;
   vect3 normal;
   DWORD color;
   float u, v;
} Vertex3D;

Share this post


Link to post
Share on other sites
lights at 0, 0, 0 same area as most of the model I am using to test with. I don't know if its something to do with the way I am converting the normals - just the exact same way i am transforming the vertices by multiplying them by the bone/frame hierarchy of matrices. is this the correct way?

Share this post


Link to post
Share on other sites
Quote:
Original post by staticVoid2
is this the correct way?


Sure, but you'll want them to be normalized. When you transform them into some other space they probably get scaled down, which darkens the NdotL lighting.

Share this post


Link to post
Share on other sites
Quote:
just the exact same way i am transforming the vertices by multiplying them by the bone/frame hierarchy of matrices. is this the correct way?

Definitely not!

The bone matrices have a translation component which will move the normal in addition to rotating it.

You want to just use the rotation portion of the matrices to transform the normals.

Share this post


Link to post
Share on other sites
Quote:
Original post by XVincentX
Do you have a personal parser for X file loading?


yes.


Are you supposed to add the same light for every frame? in the irrlicht engine after each frame all dynamic lights are deleted then added to the scene again on the next render call.

[Edited by - staticVoid2 on June 25, 2008 3:52:10 AM]

Share this post


Link to post
Share on other sites
Wow!! Could you ask you how have you implemented it?
I use D3D10 and there is not .x file support. So i've to load it with a REF d3d9 device, and make an exchange of data, but i do not want to work in this way.

So, for now, i've implemented a .dae file loader (collada) but i want to switch to .x also.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this