Sign in to follow this  
ajoling

Geometry mixing problems

Recommended Posts

Hi, Today I started on porting the nice water from the DirectX8 SDK to my terrain. It works fine now, except for one issue, I cannot seem to fix. AFAIK, it should be something related to the depth buffer. Right now I just make a plane, and put it at a certain height, so it mixes with the terrain hills: I think that is pretty clear. Could it be of my 16bit Zbuffer (voodoo3)? I tried turning it on and off, and render the water at different moments, but it just doesn't resolve this strange choppy geometry. Or should I really match the plane to it's shape "between" the hills? ajoling

Share this post


Link to post
Share on other sites
Question: When you refer to a plane, are you referring to a quad or a user-defined clipping plane?... I'm assuming you're using a quad.

You might be right that it has to do with your chipset. You can post a link to the executable here, (add something like "test my program" or something to the subject) and we can see if we can replicate the problem.

I just thought of this, but are you making sure you're using a 16-bit depth buffer when you initialise your device? I don't think it would create if you tried to make a 32-bit device on 16-bit hardware, but who knows?

IMO, matching the plane between the hills might be a nightmare. Additionally, you'll have to do some funky stuff to get ripples to work without creating a gap between the water and land. And then you'd have to interpolate between vertex coordinates to find the right "fit" and so on... I don't think its worth it.

The strange thing is, everything else renders fine. Post your render code for the water, (states) - maybe something yucky happened there? SDK code isn't always exactly.. nice.

In any case, that certainly is an odd bug...

Share this post


Link to post
Share on other sites
Yeah. I thought it might be a culling issue, but after trying all the combinations, I gave up on that one. I'm totally clueless :).

I just zoomed out, and then even more weird stuff happens:



Maybe I should try it on a PC with a 32bit z-buffer... But it's still very strange.

Share this post


Link to post
Share on other sites
I found it, and will post the solution right here. (For future reference)

The problem is known as "z-fighting", as many know, the depth isn't linearly distributed, at the closer (near plane) distance there is more precision than at the Far plane. Hence why at the close proximity the water did work pretty well.

since it's going to be a RTS game, I can put my Near plane different. Right now I've tried 100.0f, and it seems to work quite well. Not sure if this is stil lthe case with 32-bit, but with 16-bit it definetly is. I also read that a "W-Buffer" might stop this problem, but AFAIK a Voodoo3 doesn't have one.

Well, I hope to help someone with the above :)

Share this post


Link to post
Share on other sites
Since AFAIK z-fighting is caused due to the z-buffer being too inaccurate, switching to 32 bit z-buffer would fix the problem. In your case, making the z-buffer's range shorter also helpped, since it made it more accurate.

Also, if you ever encounter this problem again, using a REF device to emmulate a 32bit buffer would allow you to test what effect this would have on your engine. I'd try it next time you run into problems with these sort of things.

Share this post


Link to post
Share on other sites
http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

Nice link which explains it in detail.

Now, my water is awesome (for my voodoo3), check the screenshot here:

http://www.persistentrealities.com/problem/water3.jpg

Except I can't get it any bigger than the 64x64, which the original water sample uses. The caustics simply completely disappear. Maybe someone managed to get it to work with bigger dimension? :) The DX sample code isn't very explained :).

Otherwise I'll settle without the nice caustics I guess, and maybe in the end of the game work on something new... Maybe when I got some new hardware with a pixelshader or so :)

Share this post


Link to post
Share on other sites

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