• 10
• 10
• 12
• 12
• 14

The Near View Is Not Shown Properly

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

Recommended Posts

Hello!

I have encountered some problems and I don't know what might be causing it. The problem is that I can't properly see what is being draw near to the camera.

This is how I am setting up my frustum but I have played around with it alot and it looks like that it is not the issue. http://pastebin.com/Zq9iZm9Y

This is how it looks right now: http://imgur.com/a/uxhgs

You can see that if I rotate the world around that there is a wall/path behind me as well but as you can see it is being rendered strangely. If anybody knows what might be causing this please feel free to share the information.

Regards!

Edited by Skyzyx

Share on other sites

Hard to really tell without knowing more about how big everything is. Have you tried reducing your near plane value?

Matrix.frustumM(projectionMatrix, 0, -aspectRatio, aspectRatio, -1, 1, 1, 150);

One of those is probably it. I don't know what you are using there so I'm not entirely sure but you could try something like:
Matrix.frustumM(projectionMatrix, 0, -aspectRatio, aspectRatio, -1, 1, 0.1, 150);

Is this the function you are using?

https://developer.android.com/reference/android/opengl/Matrix.html#frustumM(float[], int, float, float, float, float, float, float)

You might be better of using perspectiveM to setup your projection.

Edited by Nanoha

Share on other sites

I tried to set the near plane to 0.1f or even 0.01f but everything gets stretched out. I tried using perspectiveM and setting the near plane to 0.1f seemed to do the trick with a 90 degree angle. Thanks for the help!

Share on other sites

Normally for anything related to the physical world, 1.0 is one meter.  So if your near plane needs to be at  0.01 it means the thing is one centimeter away from your eyeball.  Unless that thing is a pair of glasses, you don't want it anywhere near that close.

Consider what you are doing with that line:Matrix.frustumM(projectionMatrix, 0, -aspectRatio, aspectRatio, -1, 1, 1, 150);

You are making an orthgraphic view, basically a flat view used for HUD or map views.  The view has six walls:  the left wall is -aspectRatio meters from your eyeball, the right wall is aspectRatio meters from your eyeball, the ceiling and floor are one meter above and below your eyes.  The nearest thing you can see is one meter away (which is probably good) and you are looking at a deep box of 150 meters in depth.

When you change to perspectiveM you are looking out more like a fanned out view, more like what your eyeball actually sees. You can set an angle for your field of view, your aspect ratio, and near/far planes.  You will probably want to see starting at about a meter or half-meter out, and quite far into the distance.

To get a real life view of what your field of view should be, hold up a protractor to your eyeball and look at your monitor.  Center it on your screen and look at the angle it spans. If you want it to look similar to your monitor being a view of the world it should be near 60 degrees or so. If you're looking for a wider view maybe up to 90, an extended camera view you might want even higher than that. The fov can be changed for artistic reasons, like looking in a sniper's scope which can have a fov under 6 degrees, maybe as low as 2 degrees or so depending on the lens you are simulating.

Share on other sites

I might add that a 55mm lens is your normal human view lens with cameras. The more you go below that the more you will get  a "fish eye" perspective that will warp things. The more above that you go the more you will get a telescopic view of things where things appear to be slower together than the really are.

I've been watching a great lecture on perspective in drawing that probably applies here. This is basically mathematics and the physical world we live in.

You're basically creating vanishing points like in drawing. The closer they get, the more the whole view is squished together like with a telephoto camera lens. The further they are moved apart, the more it stretches everything in view and the more you get that "fish eye" effect.

The field of view should be between about 45 and 60 to get a natural view the way humans normally see things. Beyond that in either direction it will be "unnatural" for better or worse.

And looking at the pictures,  I can't tell that anything is rendered wrong. I don't know what you intend it to look like. If it's drawing "inside out" that's a totally different problem.

Edited by BBeck