Understanding the Camera in Computer graphics
We’ve already discussed 3D modeling concepts in computer graphics. We've explained that the key difference between a 2D and 3D scene is that a 2D scene and 2D objects are limited to a single plane, while a 3D scene and 3D Objects can have multiple planes.
In the image below, you'll see a scene of three different planes, which contains a simple 3D model. But because each of its faces is rotated, they all had to be drawn on a separate 2D scene.
The 2D scene, on the other hand, has only one plane, so the entire 2D object can reside on top of that single plane.
We have also discussed the idea of a scene being a virtual world in which 3D objects are displayed. So let us expand on this. In the following part of the article, we will analyze how we view 3D objects in the real world and compare how we emulate the same concepts to visualize digital 3d models.
How do we see the depth of objects?
Our eyes are sensors. They are responsible for perceiving the world in front of us and sending their observations to the brain, where the information is processed. It's this process that allows us to see the depth and view the world in three dimensions. Here are the three factors that make it possible:
Perspective. The further away the object gets from you, the smaller will it look. The same is when looking at parts from a single object, the deeper it gets, the smaller these parts of the object look.
This is something that 3D computer graphics software emulates to trick our eyes to think they see real 3D objects. The technical term for this is called Projection, which will be explained further into the article. In the meantime, let’s take a look at the two images below.
As you can see, I took two snapshots of the same 3D scene, each from a different angle. I managed to get different angles by rotating the scene, which will be explained further in the article. In the meantime, let’s take a look at the measurements printed on the side of the images.
Let me explain what I did. I took two snapshots of my SelfCAD scene, and loaded them into a 2D image measurement software, and started drawing. I've drawn a total of 7 measurement lines. You can see the order in which I've drawn them (from 1-7), and next to it, is the length of the line. So let’s analyze what we see.
The first line I measured faced the front, and it had a measurement of 1.00. In the second drawing, on the other hand, I measured the line in the back on the same bottom plane, and as you can see, the measurement was only 0.76. It means that it became smaller from front to back. Each line is just slightly shorter, so it’s barely noticeable, but over the entire scene, it makes a big difference.
You can also see my third measurement gave the utmost right side the size of 0.49, while the 4th got the height of 0.82.
Now, let’s compare the measurements on both snapshots. The 5th one on the second image is measuring the same edge as the third one in the first image. You can see it got much bigger, from 0.49 to 0.77. The 6th one measures the same line as the first one, and it became much smaller, from 1.00 to 0.55. The 7th measurement was 1.00 in the first image, which turned to 0.82 in the 4th measurement in the second picture.
This shows you how much calculations go into any 3D Graphics software, to simulate the depth based on resizing a small part of the scene. The same is true for rendering 3D objects, where each part is calculated and resized in a way that should trick our eyes view objects as in a natural 3d world.
Lighting. We naturally see objects that are further away from us as darker. 3D Computer graphics are emulating the same. If you select RGB color for your plan or objects, that is only the base color, you can expect the software to add a slight shade on top of it, and it will get darker the deeper each pixel gets. We’ll discuss this at length in the lighting topics in the rendering posts.
What’s interesting about the lighting phenomenon is that most standard digital cameras capture the same dark shading effects to make images look neutral to our eyes. Modern computer algorithms use those lighting effects to reconstruct the depth of a 3D object from a simple 2D Image. SelfCAD ImageTo3D can create 3D Objects from 2D Images, using this same technique.
Rotation. When we inspect objects, we naturally move our heads and eyeballs, to get a perspective of how the object looks from different angles. But when the object is rendered on a 2D screen, eye and head movement will not change what you see. This is the biggest challenge augmented, and virtual reality is trying to solve by using special glasses or other techniques that can naturally understand your eye and head movements and rotate the scene to match them. But when it comes to 3D Modeling software and most computer graphic applications, we rely on manual rotations to see the different sides.
The computer’s point of view is called the Camera. In SelfCAD, it is set by default to a position that allows you to look at the entire scene from the front, but you can rotate, move, and zoom it in to see any object or a part you’re working on from up close.
Any 3D scene needs a Camera. However, augmented and virtual reality is trying to automatically adjust the Camera as you move, while 3D modeling applications expect you to adjust the scenes manually as needed.
From a technical point of view, moving the Camera is called Pan. The same term is used in 2D graphics as well, so you may be familiar with the term of panning a 2D Google map. Having looked at that, let us look at how we look at objects.
How to add planes
In SelfCAD you can customize almost everything about the Planes. That includes adding and coloring planes, as well as adding up to 4 viewports, each with its own projection. Adding more than one viewport allows working with the same object from many sides at the same time, without the need to rotate the scene to see the other side of the model.
What is interesting about the planes is that because SelfCAD is using a cartesian coordinates system, your default scene works with six cubic planes but it will always hide three of them as you rotate the scene. It allows you to see the objects inside the scene.
For example, on the right side viewport, you can see keep open the Front, Right, and the Top planes, while on the left side, you see we keep open the Right, Front, and the Top. As you rotate each viewport, SelfCAD will hide planes accordingly to what is best to visualize the scene. If you'll disable any plane, it won't show it at all, but if you check, for example, the Back/Front plane, it will show either of these two, based on the position of the Camera in the selected viewport.
You can manually add more planes and even create custom ones. It allows you to accommodate architectural and other technical drawings. However, for the basic scene, you are limited to the basic Cartesian planes, as described above.
Looking into objects
One interesting advantage of computer graphics over real-world objects is that you can zoom in to an object to see what’s inside. The Camera sees what’s in front of it based on a selected projection, and if you position the camera inside of an object, it can see what’s inside.
For example, you can model a building completed with the interior design. From the outside, you'll naturally see just the building itself as shown below.
How the building looks like when viewed naturally.
And by zooming the camera in, you'll be able to view the insides with the interior design as shown below.
The interior design of the building when the camera is zoomed in.
Camera helper tools
To make it easier to position the camera, SelfCAD will, by default, zoom the scene towards the mouse, but you can change this behavior in the camera settings.
All the basic camera settings are intuitively located and managed from the left side, as you can see in the video below.
From a mathematical point of view, there are many different types of 3D projections, however, from the design perspective, you will mostly work with just two of them. The first one is the perspective mode. It's a default mode that makes the objects look as natural as possible. The second one is the orthographic mode. It's doesn't offer the natural look to the models, but it's better suited to measuring positions.
In the above image, you can see the snapshot of the same scene using an orthographic projection, and as you can see, all sides are now measured equally. The small 1.01 offset is from the fact that I did not position my mouse at the first and last pixels of that plane, but you can see how I got all 7 lines as the same measurement. This is very helpful in modeling when you need to trace parts from an object or when tracing a reference image. See the two images below.
Tracing of a reference image.
In general, you always want to visualize your scene in a perspective projection, as it adds depth and realism to the design, but you should often switch to the orthographic projection while 3D Modeling, as it helps with measurements.
There are other types of projections that are used in internal algorithms, but there is no need to learn when and how they are used. SelfCAD uses them seamlessly, according to what is best to way visualize the scene. The only exception to that rule is the Reshape Tool.
The reshape tool is using a 2D camera projection where the functions depend on how you position the camera. For example, let’s say I want to add a rectangle part on top of a basic cylinder. I can select the top polygon and use the Inset to add the center ring.
Then I can use the Reshape Tool to convert the ring into a rectangle, but this will only work as intended after positioning the camera to look at the top of the model. As you can see, the image on the left shows a less than perfect rectangle, while the image on the right shows a circle that has been reshaped into a perfect rectangle. All that was changed between those two scenarios is the position of the camera.
The position of the camera is only relevant, while the Reshape Tool is active. After finalizing the changes, you can click on the Home icon to revert the camera to the default position to use other tools. I, for example, used extrusion to extrude a cube from the top.
SelfCAD has recently released an option to position the Camera at a point selected by the left click of the mouse. This feature might be helpful when using a tool like Reshape, which depends on the position of the camera.
Do you have any questions about the article? Have any thoughts that you'd like to share with others? Do you think something should be added or changed? Take part in the discussion in the thread dedicated to this article by clicking on the button down below!
Haven't tried SelfCAD yet? Register now, and try it out for free!