Skip to main content
gamedev.net
🔒 Locked

Using lights

Started by y0rsh 1 reply 500+ views
Original Post
y0rsh
y0rsh
First of all, I want to say hi to all as this is my first post although I've been reading the forum for some time. I have a problem, I need to render illuminated objects using lights located in world coordinates. This is what I'm doing: 0. Load identity matrix 1. Push camera matrix 2. Render light (supplying position in world coordinates) 3. Push object transformation (to position the object in the world) 4. Render object 5. Pop object transformation To explain more clearly, I have a ball with a transformation of 40 units to the right and a light in world position (10,0,0). The camera is pointing towards the -Z axis. What I see is the ball being illuminated on it's right side, like if it was on the origin when the illumination took place and then was moved. What I need is the ball to be illuminated on the left side, so what should be the ordered of transformation to get the ball or any other object illuminated after it has been positioned in world coordinates and not like if it was on the origin. Any help will be greatly appreciated. Cheers
V-man
V-man
That's correct. If light position is in world coordinates, it needs to be transformed by the camera matrix so that it goes to eye coordinates. Your code is fine.
y0rsh
y0rsh
Thanks V-Man, I found my mistake, when giving the coordinates of the light I was setting w to 0 instead of 1. DOUGH! There goes half a day wasted

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.