Basic camera questions (Sorry in advance)

I’m a little lost with camera frustums. I’m trying to adjust the clipping when close to an object. It seems to clip when the object is still a good distance from the player model.



I adjusted the far frustum and got the results of not rendering object past a certain distance (expected!)

I adjusted the near frustum to accomplish the same for objects close to the camera and it has a dramatic effect on the the perspective.



I guess my simple question is, how do I accomplish the above stated purpose and not mess up the perspective? What is the relation between the near frustum and perspective? I’m so lost with this one >.<



Also, is there a good read on how near/far/etc frustums work in relation to each other? lol



Sorry for the stupid questions.

This the code I use to adjust the near/far and field of view:

[java]

float aspect = (float)cam.getWidth() / (float)cam.getHeight();

cam.setFrustumPerspective( 70f, aspect, 0.1f, cam.getFrustumFar() );

[/java]



This sets a pretty wide field of view (70 degrees vertically) and a pretty close near clip. I don’t remember what Camera’s default value is… maybe 45? You could play with it and find something you like.

2 Likes

Thanks!

Interesting…



setFrustumPerspective has a fairly heavy effect on the fog renderer. Odd side effect.

The fog post-filter has a near plane hard-coded… and I could not understand the calculations in it when I looked before. May be related.

…and note, for any post-filter that uses the depth buffer (like the post-filter fog), a small difference in near value is as significant as a huge difference in far clip because of the way the depth buffer resolution is organized.



You could try cut-pasting the fog frag material stuff (.j3md and .frag) and customize the fog.frag with a different near clip to see if that fixes it. Not a pretty solution but a solution.

pspeed said:
...and note, for any post-filter that uses the depth buffer (like the post-filter fog), a small difference in near value is as significant as a huge difference in far clip because of the way the depth buffer resolution is organized.

Exactly!!
look at this page for more explanations on the depth buffer http://www.sjbaker.org/steve/omniv/love_your_z_buffer.html

Heheh… that’s precisely the page I used to reverse the z-buffer for the DoF filter. :slight_smile: