Weird OpenGl culling problem

Started by
2 comments, last by Ermacc 14 years, 3 months ago
Hello everyone, and first of all, happy holidays!:) I was puzzled by a certain problem in my game engine recently and decided to ask for help. I'm trying to do some basic water(plane with transparent water texture on), and parts of some objects are not rendered "underwater".(or above the water if viewed from below) To illustrate i have a couple of screenshots: http://img163.imageshack.us/i/water1p.jpg/ http://img85.imageshack.us/i/water2a.jpg/ As you can see the rocks and the trees are rendered ok, but the units are cut off at the water plane. Now the reason for this is probably that the map(rocks, trees, water, etc) is a single 3ds model, and the units are separate models. I'm using a 3ds loader i found on the web, but i checked it and i don't think it has some weird culling implemented in itself.. So maybe this is some default OpenGl culling at work, which can somehow be disabled? Any ideas, on what could be the problem? Edit: Sorry, i think i've posted this in the wrong forum. I guess this belongs in the opengl one... If someone can move this, thanks in advance!
Advertisement
Moving to OpenGL.

As for the problem, looks just like the depth buffer is doing its job. If you draw the water surface and write it's depth information to the depth buffer, then the units will correctly be clipped at the water surface, since they are then behind it.

Draw the water surface last instead. You need to to that to handle transparency correct.
Try drawing your units first, and the map after. Your problem is depth-culling, which will make sure nothing is drawn on top of geometry that is in front of it. Even if the water is partly transparent, it will completely cull objects behind it that are drawn after it, since depth-testing doesn't know about transparency. If you draw your other models first, then this won't be a problem, as the water will just be drawn on top, and no culling be performed.
Thanks a bunch, guys! Drawing water at the end fixed the problem. Can't believe it was so simple. :)

This topic is closed to new replies.

Advertisement