Bump mapping produces some problem...

Started by
0 comments, last by Subotron 15 years, 4 months ago
I am using Cg for the bump mapping. it works fine without shadow enabled. That is, when I render twice at one frame(normal scene and shadow scene), it produce some strange result. in the display callback, renderScene(); renderScene(); In the render scene function renderScene(){ // Load Identity // Camera look setting // Set Cg Program parameter with model view projection matrix // Draw Objects } When I press foward moving key, I could see the second rendered object. When I stay at the same position or rotates, the second object is unnoticeable. I suspetced that sending modelview_projection matrix might be wrong. (cgGLSetStateMatrixParameter(myCgVertexParam_modelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY); ) So I get opengl matrix parameter manually and send it to Cg program, but the problem still exists. Do you have any idea about the source of this problem? [Edited by - namwkim on November 29, 2008 7:57:08 PM]
Advertisement
I don't really understand your problem, and we're probably going to need to see your code to fix this.

From what I understand, you want the object to only be drawn once to the screen, but when you use both shadows and bump mapping it gets drawn twice, but you only see this when you do certain camera movement.

First of all, the problem is not your camera movement in this case (although it is indeed very weird that one of the 2 objects gets translated like in the screenshot, but this is a different bug).

The whole bug seems to be that you actually draw your scene to the backbuffer twice! This will not only be really slow, but it's totally wrong.

From what I see in the screenshots, bump mapping works, but there are no shadows.

So what I expect that you do: You render the shadow pass to the backbuffer, where you probably want to render it to some other buffer like the depth buffer or a texture (assuming you use shadow mapping and not stencil shadows). Either way, you don't want to render this pass to the screen. The second pass (bump mapping) should take into account the shadow map generated in the first pass, and apply that (next to the bump mapping itself) to produce the shadows. That way, each object will be drawn to the screen only once (in the 2nd pass), and you should never see that double object anymore.

About the modelViewProjection matrix, why do you set it to identity? That seems weird to me.

If this is not your problem, please elaborate a bit more. Your post isn't exactly clear and you provide very little information (no offense, just trying to be helpful).

This topic is closed to new replies.

Advertisement