Transformations & Transformations & Coordinate Systems Coordinate Systems CSCD 472? Slide 1 4/5/10
Transformations: Basic Definitions Transformations: Basic Definitions Basic definitions Coordinate systems in RenderMan are always LEFT handed with the positive z-axis pointing into the screen (in world coordinates) The fixed or default camera is located at the origin and points down the positive z-axis All transformations are represented as 4 X 4 transformation matrices. Points are transformed by post-multiplication and matrices are concatenated using pre- multiplication (before concatenation) The matrix on top of the transformation stack is called the “current transformation matrix”. It is also said to represent “local coordinates” CSCD 472? Slide 2 4/5/10
Transformation Commands Transformation Commands Transformation Commands each pre-multiplies (before concatenates current transform matrix with no preceeding push. Translate dx dy dz Rotate angle vx vy vz rotations are always counter-clockwise around the axis given Skew angle vx vy vz ax ay az angles are given in degrees Shearing transform – moves everything along a vector parallel to A = (ax, ay, az) – amount of shift depends on distance of vertex V=(vx,vy,vz) from plane defined by A and A X V CSCD 472? Slide 3 4/5/10
Transformation Commands Transformation Commands Transformation Commands ConcatTransform matrix pre-concatenates the current matrix with matrix – often used to setup a gluLookAt style of camera transorm. Identity replaces current matrix with an identity matrix – In a world block returns the local coordinate system to be equal to the world coordinate system. Transform matrix replaces current matrix with the provided matrix – equivalent to Identity followed by ConcatTransform matrix. CSCD 472? Slide 4 4/5/10
Saving and Restoring the Saving and Restoring the Current Transformation Matrix Current Transformation Matrix Effects of blocks on Current Transformation Matrix (CTM) AttributeBegin – starts an attribute block automatically pushes current attributes and CTM – the CTM does NOT change. AttributeEnd – pops most previous attributes and replaces CTM with one on the top of the stack. TransformBegin – pushes only the CTM but not the attributes – allows change of movement w/o affecting the attributes. TransformEnd – pops most previous CTM only. CSCD 472? Slide 5 4/5/10
Special Coordinate Systems Special Coordinate Systems “camera” Space exists around the virtual camera – camera is at the origin of a left-handed coordinate system looking down positive z-axis forms the center of the visual universe – other coordinate systems emanate from this one. Cameras are not objects. Created when Projection is called sets the current transformation matrix to identity – all transformations that occur from here to the WorldBegin call build up the “world- to-camera” matrix. At WorldBegin the current transformation matrix is stored as the final “world-to-camera” matrix and the current transformation matrix is reset to CSCD 472? identity. Slide 6 4/5/10
Special Coordinate Systems Special Coordinate Systems “camera” Space As in OpenGL this is the coordinate system in which all transforms have been applied including the “camera” transform. We (OpenGL orientation) visualize the camera transform as moving objects in world space so their position relative to the fixed camera is what it would have been with respect to the virtual camera. RenderMan prefers us to visualize the camera transform as a transformation of the camera coordinate system to produce world coordinates. Both views produce the same result – in OpenGL we start with one universal coordinate system and move objects to where we want them (backwards) – in RenderMan we transform one coordinate system into another (forwards). CSCD 472? Slide 7 4/5/10
Special Coordinate Systems Special Coordinate Systems “world” Space initialized at WorldBegin relative to camera space from WorldBegin to WorldEnd changes to the current transformation matrix create new “local coordinate systems” that are relative to “world” space. This matrix transforms points from the “local” coordinate system into world space. In OpenGL – we build most objects relative to the universal coordinate system – often around the origin - and then move them to where we want them – we call this a “modeling” transform. In RenderMan we go the other direction and transform world coordinates to “object” or “local” coordinates and produce the same final result. CSCD 472? Slide 8 4/5/10
Special Coordinate Systems Special Coordinate Systems “object” (“local”) Space These concepts need to be described carefully – Advanced RenderMan uses this explanation of local coordinate: When primitives are created, they take their positions from the current transformation matrix at the time and that becomes the “object” space for that particular object. Depending on the interpretation of the pronoun “that” this passage seems to imply that “object” and “local” space are the same as “world” space. The transform that takes “world” coordinates to “object” coordinates is actually the modeling transform considered from the “forward” rather than “backward” point of view. CSCD 472? Slide 9 4/5/10
Special Coordinate Systems Special Coordinate Systems “shader” Space When shaders are created (with Surface or other calls) the “local” or “object” coordinate system is stored as the “shader space” for that particular shader. Since in “object” coordinates the center of the object is the origin of the coordinate system, shaders work with respect to the object itself without any regard to the transforms that are applied to the object. CSCD 472? Slide 10 4/5/10
RIB File Illustrating Coordinate Spaces RIB File Illustrating Coordinate Spaces Display "Transforms" "framebuffer" "rgba" . . . . Projection "perspective" "fov" 45 Translate 0 0 5 Rotate -50 1 0 0 Rotate 20 0 1 0 WorldBegin ## begining of the workd blockWorldBegin AttributeBegin Color [0.9 0.4 0.1] Rotate -90 1 0 0 Translate 1 0 0 Cone [1.0 0.5 360] AttributeEnd WorldEnd CSCD 472? Slide 11 4/5/10
Rendering with defaultsurface Rendering with defaultsurface Rendered with defaultlight and defaultsurface shaders CSCD 472? Slide 12 4/5/10
Special Coordinate Systems Special Coordinate Systems “screen” Space projected 2D coordinates – x is right and y is up z coords mapped to 0 – 1 “NDC” coordinates Normalized Device Coordinates – upper left is (0, 0) lower-right is (1.0, 1.0) CropWindow defined in this space “raster” coordinates resolution dependent 2D pixel coordinates upper- left is (0, 0) lower-right is (xres, yres) pixel addresses CSCD 472? Slide 13 4/5/10
Coordinate System Commands Coordinate System Commands CoordinateSystem name names the current local coordinate system with name for later reference CoordSysTransform name replaces the current matrix with the one that forms the name coordinate – used to add objects directly into that local coordinate space. CSCD 472? Slide 14 4/5/10
Recommend
More recommend