help ! my point light is following the camera

Started by
3 comments, last by MegaPixel 13 years, 9 months ago
Hi guys,

I managed to implement a deferred renderer it works pretty well, but I've

noticed that as I move around with the camera the point light shading is

following the camera, or it's just my impression ... :|.

As I perform any lighting calculation in view space I need obviously for the

light position to be expressed in view space. Therefore I multiply it for the

viewMatrix.

This is a VIDEO showing the problem:

http://img594.imageshack.us/img594/6477/pointlightissue.mp4

Currently I transform the light like this:

//view space light positionD3DXVec3Transform(&VSLightPos,&(*itr)->getLightPos(),&pRenderer->getViewMatrix());


Thanks in advance for any hint :)


Advertisement
Are you sure you're actually translating the light position, multiplying the view matrix by a vector with w=1?
Quote:Original post by My_Mind_Is_Going
Are you sure you're actually translating the light position, multiplying the view matrix by a vector with w=1?


Actually you got a point ! I'm quite sure that I'm multiplying the light pos as lightPos = (x,y,z,1). But maybe due the big number of changes I could have been missing that ...

I'll have a look and I'll let you know

Thanks a lot
Quote:Original post by MegaPixel
Quote:Original post by My_Mind_Is_Going
Are you sure you're actually translating the light position, multiplying the view matrix by a vector with w=1?


Actually you got a point ! I'm quite sure that I'm multiplying the light pos as lightPos = (x,y,z,1). But maybe due the big number of changes I could have been missing that ...

I'll have a look and I'll let you know

Thanks a lot


Ok actually I wasn't doing multiplication with w = 1 but using just x,y,z. Therefore I changed with:

D3DXVec4Transform(&VSLightPos,&D3DXVECTOR4((*itr)->getLightPos().x(*itr)->getLightPos().y,(*itr)->getLightPos().z,1.f),&pRenderer->getViewMatrix());


but the problem is still there !!!

:((((

Quote:Original post by MegaPixel
Quote:Original post by MegaPixel
Quote:Original post by My_Mind_Is_Going
Are you sure you're actually translating the light position, multiplying the view matrix by a vector with w=1?


Actually you got a point ! I'm quite sure that I'm multiplying the light pos as lightPos = (x,y,z,1). But maybe due the big number of changes I could have been missing that ...

I'll have a look and I'll let you know

Thanks a lot


Ok actually I wasn't doing multiplication with w = 1 but using just x,y,z. Therefore I changed with:

*** Source Snippet Removed ***

but the problem is still there !!!

:((((


Pleaseeeeee I'm getting crazy :((( ... Everything seems to be fine to me: I recostruct the position in view space the light is transformed in view space, the normal is in view space !!! Infact I perform lighting in view space :D. However, the lighting seems to follow the camera as the camera moves.

this video is showing the problem:

http://img706.imageshack.us/img706/4306/lightingissue.mp4

Please, everything seems correct to me !!!








This topic is closed to new replies.

Advertisement