Focal Point Question, Computer Graphic

Started by
7 comments, last by max zeng 6 years, 7 months ago

the self-taught thread profess you guys to be genius programmers at age 12 or something. so u figure you guys must know the answer the question i am stuck on. 

i'm programming a perspective game engine from scratch without open GL functions, and read up on how to 3d perspective work. 

I get the basic gist of it. one issue so far. 

how is focal point determined.  wat value is used here.  let's say if i were to create a camera for a game. Pinhole+Camera+Terminology.jpg

Advertisement

What focal point? There is nothing of the sort in the posted diagram.

Seriously, all you need to render a 3D scene is either finding Xim (and whether it's clipped) given Xcam or more likely Xcam given Xim. Xim coordinates also need to be transformed between 3D and 2D. The only parameters are the locations of C and P (where is your camera and where is it facing) and the U and V directions (tilt and rotation of the image plane, often but not necessarily constrained to be perpendicular to Z).

 

Omae Wa Mou Shindeiru

focal length, wat value is used for this

You don't need focal length for a regular 3D projection.

https://en.wikipedia.org/wiki/3D_projection#Perspective_projection

https://www.scratchapixel.com/lessons/3d-basic-rendering/perspective-and-orthographic-projection-matrix/building-basic-perspective-projection-matrix

1 hour ago, max zeng said:

focal length, wat value is used for this

It's not clear what you're asking.  As far as I can tell from your drawing, the "focal length" is just the distance along the line of sight to the point P, which is the "image center".  But, what is the image?  What is the image plane you're talking about?  In a game camera you have a zNear (near clipping plane) and zFar (far clipping plane) and everything in between are just points.  There is no focal distance unless you're talking about some depth-of-field rendering.  In a normal game camera, everything is in focus.

495px-Perspective_transform_diagram.svg.

 

 

wat is the value is for BZ, camera to image plane. 

The focal distance BZ is the distance between a point (the camera location) and a plane (the image plane). Both are under your control, so the computation is straightforward. There are very simple formulas.

Of course, as Hodgman noted, BZ doesn't have any useful role to play. Can you explain why you care about this distance?

Omae Wa Mou Shindeiru

https://www.scratchapixel.com/lessons/3d-basic-rendering/rasterization-practical-implementation

look at FIgure 2:

see where all the rays converge onto a single point, that's what the eye represent on the last picture i posted. 

the focal length is the distance this point of convergence to the image plane. 

the focal length matters because you need it to calculate the point of intersection between the object you are looking at to the image plane to get a 2d rasterization.

 

This topic is closed to new replies.

Advertisement