MFC Object Viewer + Bug = I don't like it !

richardve, can you explain why 0.1f is bad? I thought that the important number is the ratio between the near and far plane. Isn’t setting near and far to 0.1 and 100 the same in terms of z buffer resolution as using 1 and 1000? With a 32bit z buffer I have found I can set the near and far to 0.01 and 1000.

0.1f is bad because you loose precision, so you’re killing the depth buffer.

0.1 and 100 looks like it’s the same as 1 and 1000, but it’s not, because of the way floats work.

You can probably find more about it when doing a search here at these boards.

[sorry, short answer… have to catch the train in a few minutes]

yeah, i agree with richardve. i have personal experience such a problem. the .1f will detort the texture on your model and causes the viewport to display objects which lie behind another( hence seeing two objects instead of one).

richardve Flipcode is not good idea for whole code post ! hahaha I should try that next time !
hehehe (I’ll be pulverized by the critics on COTD lol)

talking abouit near and far clipping plane
I agree that with 0.1f I got ugly distortion for far polygons…but If I set it to 1 I’ll lose near polygons…I mean…suppose my scale is 1 unit = 1 meter… everything nearer that 1 meter will be clipped no ?

Should I use a scale of 1 unit = 1 centimeter to solve this problem ?

Originally posted by Evil-Dog:
Should I use a scale of 1 unit = 1 centimeter to solve this problem ?

Evil-Dog, this is not an unit issue. I suggest you do a search on the beginner forum. I just did a search on “near clip”, and a lot of people answered similar questions already.
I also find people are a lot more patient in the beginner forum, so next time you may want to post your project on that forum first.

[This message has been edited by Coconut (edited 02-12-2002).]

I understand that it’s a ratio near plane/far plane
but how can I achieve to have a very far view without clipping what is near ?
like having near object clipped at 1 and far object clipped at 100 000 (100 km)
if I set those value I’ll get ugly polygons merging…glitches…ugly stuff you know hehehe
What can we do to counter this clipping-interval/polygon-quality ratio problem ?


Evil-Dog
Sleep is a waste of time

Why do you want to draw two things, one is 1 mm in front of your eyes, and one is 100000km from you precisely?
What application do you have?


Originally posted by richardve:

I really can’t stand seeing this so much… why are people still using 0.1f for the near clipping plane??

It’s bad, it’s evil, it’s no good, and it’ll give you some very nice looking artifacts.

Pleeeaaase, use 1.f or higher


0.1f for the near clipping plane is used in NeHe Lesson 3 (possibly other lessons) which is what was used by the OP. You might point this out to NeHe.

I haven’t noticed any artifacts.

If you can produce some evil in a demo/tutorial, I’ll post it as a warning to all.

I don’t think 0.1f for near clipping plane is bad.
it seems the ratio is bad…not the value itself…

and coconut don’t exagerate what I said please hehehe

suppose I have a scale of 1 unit = 1 meter
I want something visible at 1 cm
and also visible at 1 km
so with my scale, that makes the near clipping at 0.01f (1 meter / 100 = 1 cm) and my far clipping at 1000 (1000 meters = 1 km hehehe)
take a terrain engine for example
isn’t it possible to do this without having distortion for far object ?


Evil-Dog
Sleeping is a waste of time

Originally posted by J P:
0.1f for the near clipping plane is used in NeHe Lesson 3 (possibly other lessons) which is what was used by the OP. You might point this out to NeHe.

I haven’t noticed any artifacts.

If you can produce some evil in a demo/tutorial, I’ll post it as a warning to all.

Good idea, I’ll do that when I’ve got the time for it.

/me bookmarks this topic…

Hey guys…can someone answer to my question.
Now that you say that the ratio near/far clipping can cause distortion I wonder…
What if I want an object visible at 1 cm and another object visible (without distortion) at 1 km ?
What is the proper way to deal with that ratio problem ?


Evil-Dog
Sleep is a waste of time

Well, you could use two frustrums. generate one with a near of .1 and a far of 10.0, draw everything in that range, then a second from 10.0 to 1000.0, that should solve the problem

That seems to be a good solution !
thank you for your good idea !


Evil-Dog
Sleep is a waste of time

Originally posted by chowe6685:
Well, you could use two frustrums. generate one with a near of .1 and a far of 10.0, draw everything in that range, then a second from 10.0 to 1000.0, that should solve the problem

Shouldn’t he do that with decreasing depth values ???

I think that if you use such an algorithm, you have to clear the Z-Buffer between two ranges (otherwise the Z values will conflict, as they depend on the range !).

If you draw from close to far and clear the Z-Buffer, the objects that are close to the viewer will be erased by the ones that are far.

On the other hand, if you draw the farthest objects first, clear the Z-Buffer and draw the closest ones, everything will work (that’s the Painter algorithm with multiple passes…).

Regards.

Eric

is this the advanced section?

Very constructive comment fritzlang.
continue like this you’ll help a lot of people !
sigh

Eric thank you for the advise I’ll work on that.


Evil-Dog
Sleep is waste of time

Ok you have a point there,
I apologize.

It’s ok dude
Sometimes I don’t post in the right forum…or the subject change during the discussion…things happen…

Do you have a solution for the clipping ratio problem ?


Evil-Dog
Sleep is a waste of time

Read this article: http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html