Jump to content
  • Advertisement
Sign in to follow this  
RaPhiuS

OpenGL problem...

This topic is 5391 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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 testing
glEnable(GL_DEPTH_TEST);

//enables the depth mask
glDepthMask(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!

Share this post


Link to post
Share on other sites
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() ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 !

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!