Sign in to follow this  

Rendering lightmap fails with vertex buffer

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

I first posted this problem on the graphics programming and theory forum but I think it is more of a DirectX related problem. Here we go: I first render a lightmap with the lighting information of my scene to a texture. After that i render the scene again and combine the texture color and the color of the lighting texture to produce the final color of the pixel. To find the coordinates in the lightmap I transform the object with world-view-projection onto my screen and then devide them by the w component. After that I convert these coordinates to texture coordinates. The math behind this has been verified by several people. The scene is made up by a number of spheres which are rendered throught the Mesh.Drawsubset method and a couple of walls that I create with a vertexbuffer. As you can see in the pictures below the spheres are rendered correctly but the walls fail to calculate the texture coordinates correctly. I was wondering if anyone knows what the problem might be, or how a Mesh renders itself. Lightmap Colormap

Share this post


Link to post
Share on other sites
Those screenshots look great, sorry I can't figure out what's happening though. Are the spheres really being lit correctly because there's some sort of floating lighting below the top two. You could try simpler meshes to try and figure out the pattern, if there is one.

Share this post


Link to post
Share on other sites
AFAIK DrawSubset() of a ID3DXMesh (if that is what you´re using) should do just the same as you would, too:
Set the vertex and index buffers and use a DrawIndexedPrimitive call to render the subset.
Are there any differences in the vertex declaration you´re using for meshes and those for your "hand-made" level around? Also it might help to post your shader code.

Good luck!

Share this post


Link to post
Share on other sites
Actually, I have a hard time understanding why you're lightmapping this way?
Lightmapping is usually done per triangle, so you render a map for each triangle and simply blend that with the base texture of the triangle.
Anyway, you shouldn't be dividing with the W coordinate, you should be multiplying by it.
Or as a matter of fact, you shouldn't use the W at all, since it's already been used by doing the projective multiply.

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this