wireframe landscape hiding edges that can't see

Started by
5 comments, last by fugedizsolt 16 years, 5 months ago
Hi Dear Community! Pleas help me, I want to see a nice landscape! I have a height map, 256x256. Every little square 2 triangles. I have a working program to draw this landscape in wireframe mode. But I see all the edges. I have tried to use backface culling, it is a partial success. Is it possible that draw edges only I can see, from the camera viewpoint? These are not the solution: - I fill the little triangles with black, draw the wireframe triangles little above the black solid triangles, but the result is not that I like: close to surface I can see the little error lines... - I have tried to use stencil buffer: colormask false,false,false,false first draw the wireframe mode edges to the stencil buffer second I draw the filled triangles, with depth test colormask true,,, then draw the scene again this is not the solution (I think) Any idea? Thanks
Advertisement
Quote:Original post by fugedizsolt
I have tried to use backface culling, it is a partial success.

This should work. Are you sure both triangles are set up in the same orientation?
Hi DevFred!

Imagine that you are standing on a highland and you see ahead of you a big canyon. Backface culling is hiding triangles that facing away, but there are triangles that are facing towards you and you can't see them either, because the highland surface hides them.

|
---------\ /------------
\ /
\ /
\/

Thanks
Fuge
Hi,
In the Directx SDK there is a MeshViewer. If I open an .X file, I can view the mesh with solid fill AND edges. This is what I want, but I don't know how to do it in OpenGL. Please help
From your description I take it that you draw GL_LINES for the wireframe?
If so this may be the problem. I'm not 100% sure but you could draw the wireframe using glPolygonMode(GL_LINES), but I'm not sure if the interiors are filled then or if you are already using this.

Another way is to first draw the whole geometry filling the depth buffer and then using glPolygonOffset with appropriate parameters and then draw in wireframe again.
I'm pretty sure you need to render the scene twice to get the effect you're after. Render the whole scene once into just the depth buffer. Then render the scene again into the colour buffer with depth test enabled and a small polygon offset toward the camera.

I think I heard someone saying there was another way to do it using DX10 class shaders ... but I didn't really pay attention to the details unfortunately.

Good luck!
Thank You, polygonoffset was the magic word for me.

This topic is closed to new replies.

Advertisement