Lighting 2D surface from 3D geometry with D3D

Started by
-1 comments, last by Starfall 23 years, 3 months ago
I''m drawing a 2D image onto the screen with Direct3D, using a triangle strip, and I want to be able to light this based on a mesh I have that approximates the thing represented by the 2D image. I am planning on using vertex lighting. I figure one way I could do this is to render the mesh out with the vertices I want to be light being RGB 255-255-255, and dark 0-0-0 to create a lightmap, and then rendering my 2D image using this lightmap. However, this does not seem to be a very efficient way to do things, given that I would like my lighting to be dynamic, and therefore I would need to re-render my lightmaps every frame in many cases, not to mention the extra memory usage. It''s also a combination of the worst of both worlds from vertex and lightmap lighting from what I understand. Another possible way would be to try to distort my texture so that the mesh could be rendered itself, and not render as a simple 2D triangle strip. However, I see this option being a lot of work and likely degrading the quality of the image as well. The image wouldn''t easily map onto the mesh unfortunately. I think my most likely solution, unless I get any better ideas or suggestions, would be to try to render out the mesh but set the texture coordinates on the vertices so that the texture is effectively rendered in 2d. I guess I just need some calculations to be able to work out those coordinates, which would depend on the perspective. I''m a newbie when it comes to 3D, so there may be an easy way to do this that I''ve missed... if anyone has any ideas I''d be glad to hear them. Thanks Starfall

This topic is closed to new replies.

Advertisement