Point Light in view space !

Started by
15 comments, last by MegaPixel 13 years, 9 months ago
Quote:Original post by AverageJoeSSU
if you move the camera and the lights move with your camera... something is wrong with your viewmatrix for the lighting. again... simple test case....


Yeah I'll go for that and I'll be back with news as soon as I isolate the problem !

Thanks
Advertisement
Quote:Original post by AverageJoeSSU
if you move the camera and the lights move with your camera... something is wrong with your viewmatrix for the lighting. again... simple test case....


I simplified my scene: A plane and 5 lights. It seems with this setup that

actually they are in a space with the camera ( they seems to behave like a

headlamp .... ). They move together with the camera space and the plane goes

away as the camera goes far and far from it.

http://img808.imageshack.us/img808/9531/simpleplanefivelight.mp4

I'll try to remove the translation part of the camera and see what actually

happens !

thanks
Hi,

The lights seems to move with the camera w.r.t. the geometry. Maybe the problem is the way the geometry itself is transformed.
What is the worldmatrix used with the geometry (the scene)? is it an identity matrix or do you perform some scaling?
In your vertex shader try to replace worldviewmatrix by viewmatrix or worldmatrix and let us see what happens :)

It seems to me that your scene is transformed by the view matrix then scaled.Maybe you are interverting the view and the world matrices.
Quote:Original post by knighty
Hi,

The lights seems to move with the camera w.r.t. the geometry. Maybe the problem is the way the geometry itself is transformed.
What is the worldmatrix used with the geometry (the scene)? is it an identity matrix or do you perform some scaling?
In your vertex shader try to replace worldviewmatrix by viewmatrix or worldmatrix and let us see what happens :)

It seems to me that your scene is transformed by the view matrix then scaled.Maybe you are interverting the view and the world matrices.


I partially fixed the problem ! The problem was in the far plane :D ! In the very beginning I was doing some different test with different depth range and I forgot to update the zFar value...

I was passing zFar = 1000 to the shader while I was building the projection matrix with 3000.f.

Ok that fix the problem if I use white colored lights, yellow lights ...

Now it's happening something weird and without any reason. If I change de color of one light from white to red everything is fine. If I change that color to green ... the light is moving again from its location ... GOOOD what.. :((((

I tot it was fixed ...

However I think this problem is different from the one that I had before (which is actually fixed)...


partially fixed version (white lights). Every light is in place ... Cool !!! :

http://img827.imageshack.us/img827/8161/movinglightpartiallyfix.mp4

BUT !!!!

I change one color of one light to... say green ... that light is moving instead of staying in its location and the others white lights are fine:

http://img38.imageshack.us/img38/4733/greenlightmoving.mp4

If I change the color of that same light to red and it's fine (the other unchanged lights are fine too)!!!!! WHAT THE ... :D

http://img517.imageshack.us/img517/2507/redlightstill.mp4

...

someone tell me where is the logic reason to that !!! I tot that passing the right far plane fixed the problem but it fixes it just partially ... ie only if I put specific colors.... it doesn't sound logic ...

Duh ! :(











Fixed !!! ... for some reason the constructor D3DXVECTOR4 wasn't not putting w = 1 if I was passing a D3DXVECTOR3 as its argument (therefore w was = 0 ... no translation :P ) ... and this was happening only if I was changing the color of the light ... WEIRD ...
Therefore I just replaced the D3DXVec4Transform with the more safe D3DXVec3Transform which takes D3DXVECTOR3 as input argument and convert it internally to a (x,y,z,1) ... multiplying it with the input matrix outputting a D3DXVECTOR4 :P

Everything is working now and thanks to you all and for your suggestions. They put me on the right path
thanks again
nice! looks pretty good.

------------------------------

redwoodpixel.com


Thanks AverageJoeSSU,

the final rendering (no stencil culling optimization to this stage nor frustum culling of lights is present ...). Just a bugfree working release with 3 types of lights: point, spot, and directional ( actually I didn't put in a directional light in this video).
The total number of lights is 14, one of which is a spot light:

http://img62.imageshack.us/img62/5290/deferredrenderernobu.mp4

Thanks again to you all.

This topic is closed to new replies.

Advertisement