Geometry mixing problems

Started by
4 comments, last by ajoling 19 years, 4 months ago
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
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
Advertisement
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...
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.
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
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 :)
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>
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.
Sirob Yes.» - status: Work-O-Rama.
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 :)
www.persistentrealities.com for Inline ASM for VB, VB Fibre, and other nice code samples in C++, PHP, ASP, etc.<br/>Play Yet Another Laser Game!<br/>

This topic is closed to new replies.

Advertisement