1
$\begingroup$

The 2D pipeline involves with the construction of world coordinate scene followed by converting world coordinate to viewing coordinate, then transforming viewing coordinate to normalized coordinate and lastly converting normalized coordinate to device coordinate.

I am confused. Isn't viewing coordinate and device coordinate the same things? Can someone give me the detail differentiation among these?

$\endgroup$
1
$\begingroup$

The 2D pipeline involves ... [coordinate transformation terms]

Can someone give me the detail differentiation among these?

This is something I very recently learned while trying to understand how software handles 3D graphics behind the scenes. I've never encountered these terms in reference to 2D graphics before, but the ideas still apply. 2D graphics are just 3D graphics without a few fancy tricks.

Very Generally

Most of these different coordinate spaces don't technically exist. They come about by considering the objects you wish to draw from some reference point. When you change that reference point, you change the coordinate space. Math gets involved, but I won't do any here.

The Drawing Device and Device Coordinates

... converting normalized coordinate to device coordinate.

Isn't viewing coordinate and device coordinate the same things?

Short answer, no, but they can be in certain 2D cases. In 3D, pretty much never.

There seems to be a confusion not just between view and device coordinates, but also with the distinction between normalized and device coordinates. Lets start with normalized and device, and we'll get to view later.

In 3D systems (and 2D systems setup to work like them) you are presented with a "drawing device" consisting of two parts: drawing tools (usually functions accessed from application code) and a drawing area. Ignoring the tools, the important thing is that the drawing area has a coordinate system independent of pixels which adds a lot of flexibility and generality to the device.

Any time something is setup to work numerically in a range from 0 to 1 it is "normal", and often the range 0 to -1 is included too. With a drawing device the coordinates for both the X and Y directions of your drawing area range from -1 to 1, with -1 meaning "all the way left" for X and "all the way down" for Y, and 1 meaning "all the way right" or "all the way up" for X and Y respectively.

You can easily add a Z direction too (also ranging from -1 to 1) for "3D" drawing, but all this does is give you a layered 2D image. There is no perspective (or "depth") in your final drawing which is great for 2D games and graphics. The reason for this is that the drawing device will simply divide the space up into pixel size steps along X and Y then draw each pixel back to front (-Z to +Z). If you want real 3D though, you'll need some extra mathematical steps.

It is possible (and common) for the device to understand and work with coordinates outside the -1 to 1 range. However, if we want an object to appear on screen than it must be "normalized" so that any coordinates it refers to are within -1 to 1. After this is done to an object the terms "normalized coordinates" and "device coordinates" are practically synonymous, just one refers to the object you altered so that it would fit within the drawing area and the other refers to the drawing area itself.

Object and World Spaces

The 2D [or 3D] pipeline involves with the construction of world coordinate scene ...

Yes, but you start in "object space".

When someone creates a model of an object (or draws a sprite) all that matters to them, coordinate-wise, is where zero is within the space they're working. This consideration is called "object space" because the artist isn't concerned with the -1 to 1 drawing area, only accurately representing the object they'd like to draw. A model of a pen might be 6 units long and a model of a person might be 5.5 units tall. The important thing is that all of the points that make up some object are positioned with regard to the coordinate (0, 0, 0) and nothing else.

When later loaded into memory they will be too big for the drawing area (which is only 2 units tall and wide) and the pen will appear larger than the person. It's up to us humans to know what the units mean and adjust them properly. Resizing and positioning all objects in relation to each other instead of each individually being sized with relation to zero transforms the objects into "world space".

From the shortness of your question I wasn't sure if you knew that yet or not, but I thought I'd include that for completeness, as a good foundation for answering the next part of your question.

View Space

... followed by converting world coordinate to viewing coordinate ...

Isn't viewing coordinate and device coordinate the same things?

Note that in my explanation above nothing ever happened to the drawing device, or the coordinates of the drawing area. The only thing that ever changed was the objects we wanted to draw. The drawing area is fixed and unchanging, only ever drawing any object that fits within the coordinates -1 to 1.

Each object loaded appears at the center of the drawing area at whatever size it was designed to have (object space) which is practically always too big for the drawing device. After rearranging and resizing every object around each other (object space → world space) we still have a final scene that is too big for the drawing area, and we have no way to move around within the scene. This is where we transform everything into "view space" and work with "eye coordinates". Again, there is no such space, but what we do to work within it is to consider an imaginary camera and, treating the entire world as one giant object, we resize and reposition everything with respect to the position of the camera. That is "view space", the movement of everything around a camera, and the terms "view coordinates" (or "eye coordinates") refer to the positions of everything in relation to the camera.

View to Viewport

At this point everything that you want to see should be within the device space, but there are still a few last tasks to perform to get everything to draw.

If you were working on a 3D scene instead of a 2D one, you would perform a "perspective transformation" to create the illusion of depth. This is where you squish and warp things to make them look like they're shrinking into the distance.

Anything outside the drawing area needs to be thrown out. This saves on work for the computer, and it also is considered another transformation from view space to "clip space" because you are "clipping away" the extra data.

And finally, after clipping, you'll do a "viewport" transformation that turns the -1 to 1 coordinates into pixel coordinates.

Summary

Well... I didn't intend for this answer to get so long. My apologies if I covered anything you already knew. It's hard to guess what someone does or does not already understand. Please leave a comment if you have any further questions.

Object Coordinates: The positions of points relative to a zero point. The points referred to are the building blocks of some single object.

World Coordinates: The positions of collections of points (objects) relative to a single shared standard zero point.

View Coordinates: The position of all points (the whole scene) relative to a camera.

Device Coordinates: Any position within -1 to 1 on both the X and Y axis (and Z too for 3D). Any point within the drawing area of the device.

Normalized Coordinates: The positions of points of any object (or the whole scene) that have been transformed to fit within the -1 to 1 space of the drawing device.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.