Skip to main content
GameDev.net gamedev.net
🔒 Locked

OpenGL problem...

Started by RaPhiuS Oct 13, 2004 at 2:14 PM 7 replies 2k views
Original Post
RaPhiuS
RaPhiuS
Hello, I'm encountering a really special problem which i have no clue about where it comes from. I have implemented a quad tree terrain renderer with frustum culling and everything seems to work well except one thing... i got weird results on my pc and perfect results on my laptop. My pc have a Geforce 4 Ti 4200 and my laptop a Geforce FX GO5200.. To be more clear and to illustrate my problem look at those two pictures: http://users.skynet.be/henrraph/shade.jpg http://users.skynet.be/henrraph/wire.jpg I have put on the two pictures white arrows showing what is wrong and the corresponding part on the wireframe representation (second picture). This is really a strange problem because i only got this problem with my geforce 4 ti 4200 on my pc and on my laptop everything looks like it should. Have someone an idea where it could come from ? (opengl dll, libs ... ) I have put online an executable of what is happening that you can download here : http://users.skynet.be/henrraph/terrain.zip If someone know what is going on, i would be glad to hear from it ;-) Best Regards, RaPhiuS
Best Regards, RaPhiuS / PaRaSiTe
extralongpants
extralongpants
It looks like you either don't have depth testing enabled, or you have disabled the depth mask. One of the video cards might be defaulting some value that the other card doesn't. Make sure that depth testing is enabled, and is set to the proper function, and that the depth mask is enabled. I'm assuming you know the openGL commands for these, but just in case you dont:

//sets up depth testing, such that objects with a//smaller z value get drawn over objects with a greater z//value.glDepthFunc(GL_LESS);//enables depth testingglEnable(GL_DEPTH_TEST);//enables the depth maskglDepthMask(GL_TRUE);


Well, I hope that helps you out. Just try putting those three commands in, right before you render your terrain and see if your problem goes away. Good luck!
RaPhiuS
RaPhiuS
Thank you for your suggestion odiousangel.

Well i discovered my problem which was a z-buffer issue. By changing my near plane in gluPerspective() the effect totally disappeared and now everything is working fine on both my pc and laptop.

I just can't explain why :/

What near/far ratios are you guys using in gluPerspective() ?
Best Regards, RaPhiuS / PaRaSiTe
extralongpants
extralongpants
What was your near plane value before and what is it now? If your near plane value was greater than your far plane, it would make sense if everything was being drawn in reverse.
RaPhiuS
RaPhiuS
My near plane was 0.1 and my far plane was at 4000. With a near plane of 3 and far plane of 4000 it looks now much much better.
Best Regards, RaPhiuS / PaRaSiTe
extralongpants
extralongpants
Ah, I see now. How big is your terrain? I'm assuming it isn't 4000.0 units wide.
You should avoid making the far clipping plane distance any number bigger than you need. It makes the z-buffer less accurate. For example, if the width of your terrain is 100.0, then set your far clipping plane to 100.0 *sqrt(2). The camera would then have to be outside the terrain for anything to start disappearing.
If your terrain really is that large, I suggest scaling it down. Remember that the values within that 4000 range will eventually map down to 0.0-1.0, which inherits a loss of accuracy.
You may also want to try a 24 bit z-buffer, if you aren't using one already.
Anyway, those are just a few things to consider. If your current values are working alright, then you might as well keep them. I was just making some suggestions for future projects. I'm glad to see that you were able to fix the problem.
RaPhiuS
RaPhiuS
Thank you for your suggestions odiousangel, i'll take them into account for a future project :-) My current values are fine for me and give the right results ;-)

I added some more stuff and a picture is available here :

http://users.skynet.be/henrraph/sdtfqt_shade.jpg

Tell me what you think about it ! You'll notice the problem is not there anymore :-)

Again, thank you for your infos odiousangel !
Best Regards, RaPhiuS / PaRaSiTe
Lyve
Lyve
The last shot is looking very nice!

You are using very big values at all, I would think about reducing the overall scale so that one unit is one meter or something like that. Now it looks like you are using decimeters or centimeters (?). So such a small value for the near clipping plane doesn't make sense, I guess you can even increase the value to 10 or 50 or so.
Remember that the near clipping plane is the important thing for getting a high z-buffer accuracy, because you have a perspective projection.
_____________________________________http://www.winmaze.de, a 3D shoot em up in OpenGL, nice graphics, multiplayer, chat rooms, a nice community, worth visiting! ;)http://www.spheretris.tk, an upcoming Tetrisphere clone for windows, a 3D tetris game on a sphere with powerful graphics for Geforce FX and similar graphics cards.
extralongpants
extralongpants
Quote:
Original post by RaPhiuS
http://users.skynet.be/henrraph/sdtfqt_shade.jpg


Nice! That looks a lot better than any terrain I've been able to create. Keep up the good work!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.