SlideShare une entreprise Scribd logo
1  sur  56
CS 354 Transformation, Clipping, and Culling Mark Kilgard University of Texas January 31, 2012
Today’s material ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Course Information Reminders ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
My Office Hours ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Last time, this time ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Daily Quiz ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Programmer’s View: OpenGL API Example ,[object Object],glShadeModel ( GL_SMOOTH );  // smooth color interpolation glEnable ( GL_DEPTH_TEST );  // enable hidden surface removal glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glBegin (GL_TRIANGLES); {  // every 3 vertexes makes a triangle glColor4ub (255, 0, 0, 255);  // RGBA=(1,0,0,100%) glVertex3f (-0.8,  0.8,  0.3);  // XYZ=(-8/10,8/10,3/10) glColor4ub (0, 255, 0, 255);  // RGBA=(0,1,0,100%) glVertex3f ( 0.8,  0.8, -0.2);  // XYZ=(8/10,8/10,-2/10) glColor4ub (0, 0, 255, 255);  // RGBA=(0,0,1,100%) glVertex3f ( 0.0, -0.8, -0.2);  // XYZ=(0,-8/10,-2/10) }  glEnd (); Pro Tip:  use curly braces to “bracket” nested OpenGL usage; no semantic meaning, just highlights grouping
Programmer’s View: GLUT API Example ,[object Object],#include <GL/glut.h>  // includes necessary OpenGL headers void display() { // <<  insert code on prior slide here  >> glutSwapBuffers (); } void main(int argc, char **argv) {   // request double-buffered color window with depth buffer glutInitDisplayMode ( GLUT_RGBA  |  GLUT_DOUBLE  |  GLUT_DEPTH ); glutInit (&argc, argv); glutCreateWindow (“simple triangle”); glutDisplayFunc (display);  // function to render window glutMainLoop (); } FYI:  GLUT = OpenGL Utility Toolkit
A Simplified Graphics Pipeline Application Vertex batching & assembly Triangle assembly Triangle clipping Triangle rasterization Fragment shading Depth testing Color update Application- OpenGL API boundary  Framebuffer NDC to window space Depth buffer several operations left out for simplicity in explaining the simple_triangle example
A few more steps expanded Application Vertex batching & assembly Lighting View frustum clipping Triangle rasterization Fragment shading Depth testing Color update Application- OpenGL API boundary  Framebuffer NDC to window space Depth buffer Vertex transformation User defined clipping Back face culling Perspective divide Triangle assembly Texture coordinate generation was just “triangle clipping”  before
Conceptual Vertex Transformation glVertex* API commands Modelview matrix User-defined clip planes View-frustum clip planes to primitive rasterization object-space coordinates  (x o ,y o ,z o ,w o )  eye-space coordinates  (x e ,y e ,z e ,w e ) clipped eye-space coordinates  clipped clip-space  coordinates  Perspective division Projection matrix Viewport + Depth Range transformation (x c ,y c ,z c ,w c ) window-space coordinates  (x w ,y w ,z w ,1/w c ) normalized device coordinates (NDC) (x n ,y n ,z n ,1/w c ) clip-space coordinates  (x c ,y c ,z c ,w c ) (x e ,y e ,z e ,w e ) (x e ,y e ,z e ,w e )
User Clip Planes in Practice [ParaView] [IVoR] Primarily used scientific visualization and Computer Aided Design (CAD) applications
Remember Back to clipspace Example Six user-defined clip planes enabled to clip teapot to left scene’s clip space view Without user clip planes
Four-component positions! ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Example, All Identical Positions ,[object Object],[object Object],[object Object],[object Object],(2,-5,10) (2,-5,10,1) (4,-10,20,2) (1,-2.5,5,0.5) (-2,5,-10,-1)
Affine  View Frustum Clip Equations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Projective  View Frustum Clip Equations ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
glVertex3f Generalized ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Vertex Transformation ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Vertex Transformation ,[object Object],[object Object]
Matrix Multiplication ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Two Transforms in Sequence ,[object Object],FIRST object-space to eye-space SECOND eye-space to clip-space 16 Multiply-Add operations Another 16 Multiply-Add operations
Modelview-Projection Transform ,[object Object],[object Object],[object Object],concatenation is 64 Multiply-Add operations, done by OpenGL driver Matrix multiplication is  associative  (but not commutative) A(BC) = (AB)C, but ABC≠CBA
Setting the Modelview and Projection Matrices ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Careful:  Beware of Selectors ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Many Matrix Manipulation Commands ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],OpenGL API convention f-suffixed means takes single-precision float parameters d-suffixed means takes double-precision parameters Examples:  glTranslate d ,  glScale d ,  glRotate d
EXT_direct_state_access Versions of Matrix Commands Convetions All  f -suffixed entry points have  d -suffixed versions for double precision too All selector-free routines take a GLenum  matrix mode parameter, same as  glMatrixMode glMatrixMultTransposefEXT glMultTransposeMatrixf glMatrixLoadTransposefEXT glLoadTransposeMatrixf glMatrixPopEXT glPopMatrix glMatrixPushEXT glPushMatrix glMatrixFrustumEXT glFrustumf glMatrixOrthoEXT glOrthof glMatrixTranslatefEXT glTranslatef glMatrixScalefEXT glScalef glMatrixRotatefEXT glRotatef glMatrixLoadIdentityEXT glLoadIdentity glMatrixMultfEXT glMultMatrixf glMatrixLoadfEXT glLoadMatrixf Selector-free DSA Command Conventional Command
Scale, Rotate, and Translate Example ,[object Object],glShadeModel ( GL_SMOOTH );  // smooth color interpolation glEnable ( GL_DEPTH_TEST );  // enable hidden surface removal glMatrixMode ( GL_MODELVIEW ); glLoadIdentity ();   // reset to null transform glScalef (0.7, 0.4, 1.0);   // scale by 70% in X and 40% in Y (and 100% in Z) glRotatef (30, 0, 0, 1);   // rotate in XY plane (around Z axis) 30 degrees glTranslatef (-0.1, 0.3, 0.1); // shift -0.1 to the left and 0.3 up (and 0.1 back in Z) glClear (GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); glBegin (GL_TRIANGLES); {  // every 3 vertexes makes a triangle glColor4ub (255, 0, 0, 255);  // RGBA=(1,0,0,100%) glVertex3f (-0.8,  0.8,  0.3);  // XYZ=(-8/10,8/10,3/10) glColor4ub (0, 255, 0, 255);  // RGBA=(0,1,0,100%) glVertex3f ( 0.8,  0.8, -0.2);  // XYZ=(8/10,8/10,-2/10) glColor4ub (0, 0, 255, 255);  // RGBA=(0,0,1,100%) glVertex3f ( 0.0, -0.8, -0.2);  // XYZ=(0,-8/10,-2/10) }  glEnd ();
Load Identity Transform ,[object Object],[object Object],[object Object]
Non-uniform Scale Transform ,[object Object],[object Object],[object Object]
Translate Transform ,[object Object],[object Object],[object Object]
Rotation Transform ,[object Object],[object Object],[object Object],glRotatef (a,1,0,0)  glRotatef (a,0,1,0)  glRotatef (a,0,0,1)  Axis could be arbitrary un-normalized direction vector
Orthographic Transform ,[object Object],[object Object],[object Object]
Frustum Transform ,[object Object],[object Object],[object Object]
Two Transforms Concatenated ,[object Object],[object Object],[object Object],[object Object],Just 16 Multiply-Add operations… even though 2 (combined) transformation matrices!
Perspective Divide ,[object Object],[object Object],[object Object],[object Object],[object Object]
Viewport and Depth Range ,[object Object],[object Object],[object Object],[object Object],[object Object]
Conceptual Vertex Transformation glVertex* API commands Modelview matrix User-defined clip planes View-frustum clip planes to primitive rasterization object-space coordinates  (x o ,y o ,z o ,w o )  eye-space coordinates  (x e ,y e ,z e ,w e ) clipped eye-space coordinates  clipped clip-space  coordinates  Perspective division Projection matrix Viewport + Depth Range transformation (x c ,y c ,z c ,w c ) window-space coordinates  (x w ,y w ,z w ,1/w c ) normalized device coordinates (NDC) (x n ,y n ,z n ,1/w c ) clip-space coordinates  (x c ,y c ,z c ,w c ) (x e ,y e ,z e ,w e ) (x e ,y e ,z e ,w e )
View Frustum Clipping Generalizes Cleanly ,[object Object],[object Object],(-1.8,  0.8, 0.3, 1) (-0.8,  0.8, -0.2,1) (0, -0.8, -0.2, 1) origin at (0,0,0,1)   
Clipped Triangle Visualized Clipped and Rasterized Normally Visualization of NDC space Notice triangle is “poking out” of the cube; this is the reason that should be clipped
Break Clipped Triangle into Two Triangles But how do we find these “new” vertices? The edge clipping the triangle is the line at X = -1 so we know X = -1 at these points—but what about Y?
Use Ratios to Interpolate Clipped Positions (-1.8,  0.8, 0.3, 1) (-0.8,  0.8, -0.2,1) (0, -0.8, -0.2) origin at (0,0,0,1) X = -1 Y = (1.8/2.6)×0.8 + (0.8/2.6)×0.8 = 0.8 Z = (1.8/2.6)×0.3 + (0.8/2.6)×-0.2 = 0.1461538 W = (1.8/2.6)×1 + (0.8/2.6)×1 = 1 -1-(-1.8)=0.8 0.8-(-1)=1.8 0.8-(-1.8)=2.6 (-1,0.8,0.146153,1) Straightforward because all the edges are orthogonal Weights: 1.8/2.6 0.8/2.6, sum to 1
Use Ratios to Interpolate Clipped Positions (-1.8,  0.8, 0.3) (-0.8,  0.8, -0.2) (0, -0.8, -0.2) origin at (0,0,0) 0-(-1.8) = 1.8 0-(-1) = 1 X = -1 Y = (1/1.8)×0.8 + (0.8/1.8)×-0.8 = 0.08888…  Z = (1/1.8)×0.3 + (0.8/1.8)×-0.2 = 0.07777… (-1,0.0888,0.0777) -1-(-1.8) = 0.8 Weights: 1/1.8  0.8/1.8, sum to 1
Generalize to Non-1 W ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
View Frustum Plane Equations ,[object Object],-1 z c  + 1w c  ≥ 0  1 -1 0 0 Top 1 z c  + 1w c  ≥ 0 1 1 0 0 Near -1 y c  + 1w c  ≥ 0  1 0 -1 0 Top 1 y c  + 1w c  ≥ 0 1 0 1 0 Bottom -1 x c  + 1w c  ≥ 0  1 0 0 -1 Right 1 x c  + 1w c  ≥ 0 1 0 0 1 Left Plane equation D C B A Name
Projective Clipping ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Readily Extends to User-defined Clip Planes ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
(Clip) Plane Transformation ,[object Object],[object Object],glClipPlane  parameters glVertex4f parameters
Conceptual Vertex Transformation glVertex* API commands Modelview matrix User-defined clip planes View-frustum clip planes to primitive rasterization object-space coordinates  (x o ,y o ,z o ,w o )  eye-space coordinates  (x e ,y e ,z e ,w e ) clipped eye-space coordinates  clipped clip-space  coordinates  Perspective division Projection matrix Viewport + Depth Range transformation (x c ,y c ,z c ,w c ) window-space coordinates  (x w ,y w ,z w ,w w ) normalized device coordinates (NDC) (x n ,y n ,z n ,w n ) clip-space coordinates  (x c ,y c ,z c ,w c ) (x e ,y e ,z e ,w e ) (x e ,y e ,z e ,w e )
Vertex Shaders in the Pipeline Geometry Program 3D Application or Game OpenGL API GPU Front End Vertex Assembly Vertex Shader Clipping, Setup, and Rasterization Fragment Shader Texture Fetch Raster Operations Framebuffer Access Memory Interface CPU – GPU Boundary OpenGL 3.3 Attribute Fetch Primitive Assembly Parameter Buffer Read programmable fixed-function Legend So far, we’ve discussed “fixed-function” vertex transformation Modern GPUs make vertex processing  programmable Via vertex shaders!
Vertex Programmability Paletted matrix skinning Twister vertex program Per-vertex cartoon shading
Other Vertex Processing Tasks ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Vertex Shader Example: Key Frame Blending Frame A Frame B Blended Frame 47% = + 53%
Key Frame Blending Vertex Shader Frame A Frame B Other possible key frames
Non-linear Vertex Transform + Fragment Shader Setup Fragment program Vertex program 2D grid over (s,t)  [0,1] Tessellated torus
Next Lecture ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],2nd homework is on class web site, 5 pages, 10 problems

Contenu connexe

Tendances

Tendances (20)

Deferred Rendering in Killzone 2
Deferred Rendering in Killzone 2Deferred Rendering in Killzone 2
Deferred Rendering in Killzone 2
 
Sr 01-40 good
Sr 01-40 goodSr 01-40 good
Sr 01-40 good
 
Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1Rendering AAA-Quality Characters of Project A1
Rendering AAA-Quality Characters of Project A1
 
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The RunFive Rendering Ideas from Battlefield 3 & Need For Speed: The Run
Five Rendering Ideas from Battlefield 3 & Need For Speed: The Run
 
Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
 	 Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09) 	 Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
Shadows & Decals: D3D10 Techniques in Frostbite (GDC'09)
 
Ray Tracing in Computer Graphics
Ray Tracing in Computer GraphicsRay Tracing in Computer Graphics
Ray Tracing in Computer Graphics
 
DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3DirectX 11 Rendering in Battlefield 3
DirectX 11 Rendering in Battlefield 3
 
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
More Performance! Five Rendering Ideas From Battlefield 3 and Need For Speed:...
 
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time RaytracingCEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
CEDEC 2018 - Towards Effortless Photorealism Through Real-Time Raytracing
 
Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3Calibrating Lighting and Materials in Far Cry 3
Calibrating Lighting and Materials in Far Cry 3
 
Grapics debugging with RenderDoc
Grapics debugging with RenderDocGrapics debugging with RenderDoc
Grapics debugging with RenderDoc
 
Advanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering PipelineAdvanced Scenegraph Rendering Pipeline
Advanced Scenegraph Rendering Pipeline
 
Frostbite on Mobile
Frostbite on MobileFrostbite on Mobile
Frostbite on Mobile
 
Progressive Lightmapper: An Introduction to Lightmapping in Unity
Progressive Lightmapper: An Introduction to Lightmapping in UnityProgressive Lightmapper: An Introduction to Lightmapping in Unity
Progressive Lightmapper: An Introduction to Lightmapping in Unity
 
Star Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processingStar Ocean 4 - Flexible Shader Managment and Post-processing
Star Ocean 4 - Flexible Shader Managment and Post-processing
 
OpenGL 4.4 - Scene Rendering Techniques
OpenGL 4.4 - Scene Rendering TechniquesOpenGL 4.4 - Scene Rendering Techniques
OpenGL 4.4 - Scene Rendering Techniques
 
The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2The Rendering Technology of Killzone 2
The Rendering Technology of Killzone 2
 
Colin Barre-Brisebois - GDC 2011 - Approximating Translucency for a Fast, Che...
Colin Barre-Brisebois - GDC 2011 - Approximating Translucency for a Fast, Che...Colin Barre-Brisebois - GDC 2011 - Approximating Translucency for a Fast, Che...
Colin Barre-Brisebois - GDC 2011 - Approximating Translucency for a Fast, Che...
 
Voxel based global-illumination
Voxel based global-illuminationVoxel based global-illumination
Voxel based global-illumination
 
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil PerssonLow-level Shader Optimization for Next-Gen and DX11 by Emil Persson
Low-level Shader Optimization for Next-Gen and DX11 by Emil Persson
 

En vedette

2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates
Tarun Gehlot
 

En vedette (8)

Projection Matrices
Projection MatricesProjection Matrices
Projection Matrices
 
3D transformation
3D transformation3D transformation
3D transformation
 
OpenGL Transformation
OpenGL TransformationOpenGL Transformation
OpenGL Transformation
 
Homogeneous coordinate
Homogeneous coordinateHomogeneous coordinate
Homogeneous coordinate
 
Secrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics TechnologySecrets of CryENGINE 3 Graphics Technology
Secrets of CryENGINE 3 Graphics Technology
 
2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates2 d transformations and homogeneous coordinates
2 d transformations and homogeneous coordinates
 
2d/3D transformations in computer graphics(Computer graphics Tutorials)
2d/3D transformations in computer graphics(Computer graphics Tutorials)2d/3D transformations in computer graphics(Computer graphics Tutorials)
2d/3D transformations in computer graphics(Computer graphics Tutorials)
 
3d transformation computer graphics
3d transformation computer graphics 3d transformation computer graphics
3d transformation computer graphics
 

Similaire à CS 354 Transformation, Clipping, and Culling

CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
RajJain516913
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
anhlodge
 

Similaire à CS 354 Transformation, Clipping, and Culling (20)

CS 354 Object Viewing and Representation
CS 354 Object Viewing and RepresentationCS 354 Object Viewing and Representation
CS 354 Object Viewing and Representation
 
CS 354 Pixel Updating
CS 354 Pixel UpdatingCS 354 Pixel Updating
CS 354 Pixel Updating
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphics
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
OpenGL Transformations
OpenGL TransformationsOpenGL Transformations
OpenGL Transformations
 
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeksBeginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
Beginning direct3d gameprogramming06_firststepstoanimation_20161115_jintaeks
 
Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5Trident International Graphics Workshop 2014 1/5
Trident International Graphics Workshop 2014 1/5
 
Bai 1
Bai 1Bai 1
Bai 1
 
Shadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics HardwareShadow Volumes on Programmable Graphics Hardware
Shadow Volumes on Programmable Graphics Hardware
 
Advanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics APIAdvanced Game Development with the Mobile 3D Graphics API
Advanced Game Development with the Mobile 3D Graphics API
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
Trident International Graphics Workshop 2014 4/5
Trident International Graphics Workshop 2014 4/5Trident International Graphics Workshop 2014 4/5
Trident International Graphics Workshop 2014 4/5
 
slides.07.pptx
slides.07.pptxslides.07.pptx
slides.07.pptx
 
Parallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel applicationParallel Computing 2007: Bring your own parallel application
Parallel Computing 2007: Bring your own parallel application
 
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docxSAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx
 
CS 354 Viewing Stuff
CS 354 Viewing StuffCS 354 Viewing Stuff
CS 354 Viewing Stuff
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
Praseed Pai
Praseed PaiPraseed Pai
Praseed Pai
 
Drawing Tools
Drawing ToolsDrawing Tools
Drawing Tools
 
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeksBeginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
Beginning direct3d gameprogramming10_shaderdetail_20160506_jintaeks
 

Plus de Mark Kilgard

Plus de Mark Kilgard (20)

D11: a high-performance, protocol-optional, transport-optional, window system...
D11: a high-performance, protocol-optional, transport-optional, window system...D11: a high-performance, protocol-optional, transport-optional, window system...
D11: a high-performance, protocol-optional, transport-optional, window system...
 
Computers, Graphics, Engineering, Math, and Video Games for High School Students
Computers, Graphics, Engineering, Math, and Video Games for High School StudentsComputers, Graphics, Engineering, Math, and Video Games for High School Students
Computers, Graphics, Engineering, Math, and Video Games for High School Students
 
NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017NVIDIA OpenGL and Vulkan Support for 2017
NVIDIA OpenGL and Vulkan Support for 2017
 
NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017NVIDIA OpenGL 4.6 in 2017
NVIDIA OpenGL 4.6 in 2017
 
NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016NVIDIA OpenGL in 2016
NVIDIA OpenGL in 2016
 
Virtual Reality Features of NVIDIA GPUs
Virtual Reality Features of NVIDIA GPUsVirtual Reality Features of NVIDIA GPUs
Virtual Reality Features of NVIDIA GPUs
 
Migrating from OpenGL to Vulkan
Migrating from OpenGL to VulkanMigrating from OpenGL to Vulkan
Migrating from OpenGL to Vulkan
 
EXT_window_rectangles
EXT_window_rectanglesEXT_window_rectangles
EXT_window_rectangles
 
OpenGL for 2015
OpenGL for 2015OpenGL for 2015
OpenGL for 2015
 
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
Slides: Accelerating Vector Graphics Rendering using the Graphics Hardware Pi...
 
Accelerating Vector Graphics Rendering using the Graphics Hardware Pipeline
Accelerating Vector Graphics Rendering using the Graphics Hardware PipelineAccelerating Vector Graphics Rendering using the Graphics Hardware Pipeline
Accelerating Vector Graphics Rendering using the Graphics Hardware Pipeline
 
NV_path rendering Functional Improvements
NV_path rendering Functional ImprovementsNV_path rendering Functional Improvements
NV_path rendering Functional Improvements
 
OpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUsOpenGL 4.5 Update for NVIDIA GPUs
OpenGL 4.5 Update for NVIDIA GPUs
 
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
SIGGRAPH Asia 2012: GPU-accelerated Path RenderingSIGGRAPH Asia 2012: GPU-accelerated Path Rendering
SIGGRAPH Asia 2012: GPU-accelerated Path Rendering
 
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and BeyondSIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
SIGGRAPH Asia 2012 Exhibitor Talk: OpenGL 4.3 and Beyond
 
Programming with NV_path_rendering: An Annex to the SIGGRAPH Asia 2012 paper...
Programming with NV_path_rendering:  An Annex to the SIGGRAPH Asia 2012 paper...Programming with NV_path_rendering:  An Annex to the SIGGRAPH Asia 2012 paper...
Programming with NV_path_rendering: An Annex to the SIGGRAPH Asia 2012 paper...
 
GPU accelerated path rendering fastforward
GPU accelerated path rendering fastforwardGPU accelerated path rendering fastforward
GPU accelerated path rendering fastforward
 
GPU-accelerated Path Rendering
GPU-accelerated Path RenderingGPU-accelerated Path Rendering
GPU-accelerated Path Rendering
 
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
SIGGRAPH 2012: GPU-Accelerated 2D and Web RenderingSIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
SIGGRAPH 2012: GPU-Accelerated 2D and Web Rendering
 
GTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path RenderingGTC 2012: GPU-Accelerated Path Rendering
GTC 2012: GPU-Accelerated Path Rendering
 

Dernier

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 

CS 354 Transformation, Clipping, and Culling

  • 1. CS 354 Transformation, Clipping, and Culling Mark Kilgard University of Texas January 31, 2012
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9. A Simplified Graphics Pipeline Application Vertex batching & assembly Triangle assembly Triangle clipping Triangle rasterization Fragment shading Depth testing Color update Application- OpenGL API boundary Framebuffer NDC to window space Depth buffer several operations left out for simplicity in explaining the simple_triangle example
  • 10. A few more steps expanded Application Vertex batching & assembly Lighting View frustum clipping Triangle rasterization Fragment shading Depth testing Color update Application- OpenGL API boundary Framebuffer NDC to window space Depth buffer Vertex transformation User defined clipping Back face culling Perspective divide Triangle assembly Texture coordinate generation was just “triangle clipping” before
  • 11. Conceptual Vertex Transformation glVertex* API commands Modelview matrix User-defined clip planes View-frustum clip planes to primitive rasterization object-space coordinates (x o ,y o ,z o ,w o ) eye-space coordinates (x e ,y e ,z e ,w e ) clipped eye-space coordinates clipped clip-space coordinates Perspective division Projection matrix Viewport + Depth Range transformation (x c ,y c ,z c ,w c ) window-space coordinates (x w ,y w ,z w ,1/w c ) normalized device coordinates (NDC) (x n ,y n ,z n ,1/w c ) clip-space coordinates (x c ,y c ,z c ,w c ) (x e ,y e ,z e ,w e ) (x e ,y e ,z e ,w e )
  • 12. User Clip Planes in Practice [ParaView] [IVoR] Primarily used scientific visualization and Computer Aided Design (CAD) applications
  • 13. Remember Back to clipspace Example Six user-defined clip planes enabled to clip teapot to left scene’s clip space view Without user clip planes
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27. EXT_direct_state_access Versions of Matrix Commands Convetions All f -suffixed entry points have d -suffixed versions for double precision too All selector-free routines take a GLenum matrix mode parameter, same as glMatrixMode glMatrixMultTransposefEXT glMultTransposeMatrixf glMatrixLoadTransposefEXT glLoadTransposeMatrixf glMatrixPopEXT glPopMatrix glMatrixPushEXT glPushMatrix glMatrixFrustumEXT glFrustumf glMatrixOrthoEXT glOrthof glMatrixTranslatefEXT glTranslatef glMatrixScalefEXT glScalef glMatrixRotatefEXT glRotatef glMatrixLoadIdentityEXT glLoadIdentity glMatrixMultfEXT glMultMatrixf glMatrixLoadfEXT glLoadMatrixf Selector-free DSA Command Conventional Command
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38. Conceptual Vertex Transformation glVertex* API commands Modelview matrix User-defined clip planes View-frustum clip planes to primitive rasterization object-space coordinates (x o ,y o ,z o ,w o ) eye-space coordinates (x e ,y e ,z e ,w e ) clipped eye-space coordinates clipped clip-space coordinates Perspective division Projection matrix Viewport + Depth Range transformation (x c ,y c ,z c ,w c ) window-space coordinates (x w ,y w ,z w ,1/w c ) normalized device coordinates (NDC) (x n ,y n ,z n ,1/w c ) clip-space coordinates (x c ,y c ,z c ,w c ) (x e ,y e ,z e ,w e ) (x e ,y e ,z e ,w e )
  • 39.
  • 40. Clipped Triangle Visualized Clipped and Rasterized Normally Visualization of NDC space Notice triangle is “poking out” of the cube; this is the reason that should be clipped
  • 41. Break Clipped Triangle into Two Triangles But how do we find these “new” vertices? The edge clipping the triangle is the line at X = -1 so we know X = -1 at these points—but what about Y?
  • 42. Use Ratios to Interpolate Clipped Positions (-1.8, 0.8, 0.3, 1) (-0.8, 0.8, -0.2,1) (0, -0.8, -0.2) origin at (0,0,0,1) X = -1 Y = (1.8/2.6)×0.8 + (0.8/2.6)×0.8 = 0.8 Z = (1.8/2.6)×0.3 + (0.8/2.6)×-0.2 = 0.1461538 W = (1.8/2.6)×1 + (0.8/2.6)×1 = 1 -1-(-1.8)=0.8 0.8-(-1)=1.8 0.8-(-1.8)=2.6 (-1,0.8,0.146153,1) Straightforward because all the edges are orthogonal Weights: 1.8/2.6 0.8/2.6, sum to 1
  • 43. Use Ratios to Interpolate Clipped Positions (-1.8, 0.8, 0.3) (-0.8, 0.8, -0.2) (0, -0.8, -0.2) origin at (0,0,0) 0-(-1.8) = 1.8 0-(-1) = 1 X = -1 Y = (1/1.8)×0.8 + (0.8/1.8)×-0.8 = 0.08888… Z = (1/1.8)×0.3 + (0.8/1.8)×-0.2 = 0.07777… (-1,0.0888,0.0777) -1-(-1.8) = 0.8 Weights: 1/1.8 0.8/1.8, sum to 1
  • 44.
  • 45.
  • 46.
  • 47.
  • 48.
  • 49. Conceptual Vertex Transformation glVertex* API commands Modelview matrix User-defined clip planes View-frustum clip planes to primitive rasterization object-space coordinates (x o ,y o ,z o ,w o ) eye-space coordinates (x e ,y e ,z e ,w e ) clipped eye-space coordinates clipped clip-space coordinates Perspective division Projection matrix Viewport + Depth Range transformation (x c ,y c ,z c ,w c ) window-space coordinates (x w ,y w ,z w ,w w ) normalized device coordinates (NDC) (x n ,y n ,z n ,w n ) clip-space coordinates (x c ,y c ,z c ,w c ) (x e ,y e ,z e ,w e ) (x e ,y e ,z e ,w e )
  • 50. Vertex Shaders in the Pipeline Geometry Program 3D Application or Game OpenGL API GPU Front End Vertex Assembly Vertex Shader Clipping, Setup, and Rasterization Fragment Shader Texture Fetch Raster Operations Framebuffer Access Memory Interface CPU – GPU Boundary OpenGL 3.3 Attribute Fetch Primitive Assembly Parameter Buffer Read programmable fixed-function Legend So far, we’ve discussed “fixed-function” vertex transformation Modern GPUs make vertex processing programmable Via vertex shaders!
  • 51. Vertex Programmability Paletted matrix skinning Twister vertex program Per-vertex cartoon shading
  • 52.
  • 53. Vertex Shader Example: Key Frame Blending Frame A Frame B Blended Frame 47% = + 53%
  • 54. Key Frame Blending Vertex Shader Frame A Frame B Other possible key frames
  • 55. Non-linear Vertex Transform + Fragment Shader Setup Fragment program Vertex program 2D grid over (s,t)  [0,1] Tessellated torus
  • 56.