rendering a scene with magnification

Started by
17 comments, last by JoeJ 7 years, 4 months ago

you don't need separate versions for perspective and orthographic cameras

no ortho cameras required here. not sure when one might want both. perspective is generally considered superior to ortho for most things, so if you use perspective, there's little point in dropping back to ortho for some things, it just makes you ortho graphics look worse compared to your perspective graphics. that's why a uniform level of graphics throughout a title is desirable. you don't want the good stuff making the bad stuff look even worse.


I'm not sure what you mean by number 2. sounds as if you want to scale individual objects? That would lead to all sorts of issues (for example objects starting to interpenetrate after scaling).

yes - i suspect that would be likely at extreme magnification levels.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement

i suspect that the answer - as usual - is way simpler than one might think:

you're looking at a planet, it fills half the screen. cut the FOV in half, it seems twice as big (in diameter), and thus twice as close.

so say you have a base_FOV of 90 degrees (45 left and right).

#define base_FOV pi / 2.0f;

new_FOV = base_FOV / magnification;

set_FOV ( new_FOV );

and that's all there is to it.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

E.g. You hace 3D scene on a screen sized 1000 * 500, and you want to take a rectangle form pixels (4,5) to (90, 55) and this rectangle should be upscaled to fill the screen. So it's about a area on the upper left of the view port.

not quite. you can't just scale in screen space, because all that does is magnify what is visible without magnification. it doesn't include things beyond the far clip plane which would be visible with magnification, or things inside the viewing frustum that scale to zero or less without magnification. also, whether the camera is looking straight ahead or at at target, its should always scale with respect to the center of the screen, not the upper left edge of the viewing frustum. .

I don't follow your logic, maybe i have an other definition of magnification, but it seems a lot like "scaling" to me, especially with the idea described as taking a sub rectangle of the full image to showed it fullscreen. Offcentered projection matrix are definitely the way to go in that case. The nearZ/farZ is subsidiary, who does not use infinite far Z projection matrix nowaday these days ? And if your frustum culling is properly plug to your view + projection, then the question of smaller than a pixel object cull is not relevant either.

The offcentered projection effect can be seen as zooming/navigating in a picture that looks a lot like what the OP describe.

E.g. You hace 3D scene on a screen sized 1000 * 500, and you want to take a rectangle form pixels (4,5) to (90, 55) and this rectangle should be upscaled to fill the screen. So it's about a area on the upper left of the view port.

not quite. you can't just scale in screen space, because all that does is magnify what is visible without magnification. it doesn't include things beyond the far clip plane which would be visible with magnification, or things inside the viewing frustum that scale to zero or less without magnification. also, whether the camera is looking straight ahead or at at target, its should always scale with respect to the center of the screen, not the upper left edge of the viewing frustum. .

I don't follow your logic, maybe i have an other definition of magnification, but it seems a lot like "scaling" to me, especially with the idea described as taking a sub rectangle of the full image to showed it fullscreen. Offcentered projection matrix are definitely the way to go in that case. The nearZ/farZ is subsidiary, who does not use infinite far Z projection matrix nowaday these days ? And if your frustum culling is properly plug to your view + projection, then the question of smaller than a pixel object cull is not relevant either.

The offcentered projection effect can be seen as zooming/navigating in a picture that looks a lot like what the OP describe.

I agree, that statement makes no sense at all. The far clip plane (if present at all) is completely unrelated and "things inside the viewing frustum that scale to zero or less without magnification" just do not exist.

@Norman: Maybe you are confused, because you believe we mean scaling the current view as a texture? That would obviously lead to loss of detail. We are actually talking about scaling in post-projection space to actually render a larger view of part of the screen in full resolution

Yep, there seems some confusion left...

is there a mathematical relation between FOV and apparent magnification?

#define base_FOV pi / 2.0f; new_FOV = base_FOV / magnification; set_FOV ( new_FOV );

Yes, but it depends on what you want to maginfy and where it is.

See this picture:

16jh8g3.jpg

You can see that doubling fov from 30 to 60 degrees does not make the black line half it's size, so your simple formula is not correct in general. It is only correct for points that all have the same distance from the camera.

E.g. if i want the fov to scale my view to fit the double sized grey line exactly, i belive it's this:

newFov = atan (x*2 / distance along view vector)

You would need to verify, but this formula works only for lines perpendicular to view direction, so it's no general solution either.

Just to mention - i'd stick to your formula, it's the best thing Mr. Sulu could do :)

However, imagine Mr spock points out something interesting on the surface of a planet, marks it with a small red rectangle which happens to be NOT at the center of the screen, and Kirk says 'scale it up, Scotty!'...

Then you need the 'picking' or 'Offcenter' methods we talked about.

However, imagine Mr spock points out something interesting on the surface of a planet, marks it with a small red rectangle which happens to be NOT at the center of the screen, and Kirk says 'scale it up, Scotty!'... Then you need the 'picking' or 'Offcenter' methods we talked about.

not if the visual scanners (the camera) are aimed at the target first!

this will always be the case, so the target will always be in the center of the screen. so no offset projection required. so simply playing with FOV should work just fine. but from your diagram, its also apparent that the relation between FOV and apparent size is not linear. IE 1/2 FOV != 2x mag.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

its also apparent that the relation between FOV and apparent size is not linear.

Yes, but it must be still easy to calculate.

If we think of the black line above as the image projected to the near clip plane, that example might be better than i initially thought (brobably i was wrong with some statements).

It should help to find a general solotion independent of position or distance.

I think this works:

//float sizeAtDistOne = 1.0f;
        //float fov = atan (sizeAtDistOne / 1.0f); // but we don't wanna calc current fov - we already know, calc size instead:

        float fov = PI / 4.0f; // assuming you actually have 90 degrees fov, so a half angle of 45 degrees = pi/4 rad
        float sizeAtDistOne = tan(fov);

        float mag = 2.0f; // Kirks order
        float targetSize = sizeAtDistOne / mag;

        float targetFov = atan (targetSize / 1.0f);

        SystemTools::Log ("sizeAtDistOne: %f current fov: %f target fov for magnification of (%f): %f", sizeAtDistOne, fov / PI * 180 * 2, mag, targetFov / PI * 180 * 2);

I get this output:

sizeAtDistOne: 1.000000 current fov: 90.000003 target fov for magnification of (2.000000): 53.130102

I have tested this on my viewport. Changing fov from 90 to 53.13 ideed doubles the pixel diameter of my scene - exactly :)

Hopefully this is not just a special case for initial 90 degrees - i may have a bug somewhere.

Let me know if it works...

its also apparent that the relation between FOV and apparent size is not linear.

Yes, but it must be still easy to calculate.

If we think of the black line above as the image projected to the near clip plane, that example might be better than i initially thought (brobably i was wrong with some statements).

It should help to find a general solotion independent of position or distance.

I think this works:


//float sizeAtDistOne = 1.0f;
        //float fov = atan (sizeAtDistOne / 1.0f); // but we don't wanna calc current fov - we already know, calc size instead:

        float fov = PI / 4.0f; // assuming you actually have 90 degrees fov, so a half angle of 45 degrees = pi/4 rad
        float sizeAtDistOne = tan(fov);

        float mag = 2.0f; // Kirks order
        float targetSize = sizeAtDistOne / mag;

        float targetFov = atan (targetSize / 1.0f);

        SystemTools::Log ("sizeAtDistOne: %f current fov: %f target fov for magnification of (%f): %f", sizeAtDistOne, fov / PI * 180 * 2, mag, targetFov / PI * 180 * 2);

I get this output:

sizeAtDistOne: 1.000000 current fov: 90.000003 target fov for magnification of (2.000000): 53.130102

I have tested this on my viewport. Changing fov from 90 to 53.13 ideed doubles the pixel diameter of my scene - exactly :)

Hopefully this is not just a special case for initial 90 degrees - i may have a bug somewhere.

Let me know if it works...

There's an even easier way to do it. Just scale the projection matrix in the XY plane. No need to calculate atan just to calculate the tan of that angle again while creating the perspective matrix.

There's an even easier way to do it. Just scale the projection matrix in the XY plane. No need to calculate atan just to calculate the tan of that angle again while creating the perspective matrix.

haha, feeling really stupid now :D

awesome!

This topic is closed to new replies.

Advertisement