# help ! my point light is following the camera

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

## Recommended Posts

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 :)

##### Share on other sites
Are you sure you're actually translating the light position, multiplying the view matrix by a vector with w=1?

##### Share on other sites
Quote:
 Original post by My_Mind_Is_GoingAre 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

##### Share on other sites
Quote:
Original post by MegaPixel
Quote:
 Original post by My_Mind_Is_GoingAre 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 !!!

:((((

##### Share on other sites
Quote:
Original post by MegaPixel
Quote:
Original post by MegaPixel
Quote:
 Original post by My_Mind_Is_GoingAre 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 !!!

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633701
• Total Posts
3013442
×