Skip to main content
gamedev.net
🔒 Locked

Projective texturing

Started by rxa Mar 31, 2009 at 6:34 PM 0 replies 750+ views
Original Post
rxa
rxa
My first post on this forum so greetings to ya all I'm trying to project a texture on my scene from a spot light. For some reason it seems alright on the floor but on the walls you can see it's wrong. I have formed an matrix, which I use to move from world space to light space, I compute the matrix as follows: light_space_xform = inverse(light_xform) * projection_xform * scale_offset. where: light_world_xform - 4x4 local to world space transformation proj_xform - matrix4x4 perspective(fov, aspectratio, nearclip, farclip); scale_offset_xform - scales from [-1,1] to [0,1] range so I can sample my texture. 0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.0 0.0 0.0 0.5 0.0 0.5 0.5 0.5 1.0 <- the scale_offset_xform matrix In my fragment shader I transorm each world space position in light's space, and then use it to map a position on my texture. pos_in_light = pos_in_world * light_space_xform pos_in_light.x /= pos_in_light.w pos_in_light.y /= pos_in_light.w /*clamp, wrap here*/ light_col_out = texture.get( pos_in_light.x, pos_in_light.y) Most likely there's something nasty going on with my transformations? Matrices are row-major.

Topic Locked

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

Sign in to reply to this topic.