Embed presentation
Downloaded 1,024 times





![For review, OpenGL 3.1 Texturing Guarantees 16 texture units Texture buffer objects Texture rectangle target: 2D image with [0..width, 0..height] coordinate space Signed normalized texture formats Miscellaneous Fast data copying between buffer objects Primitive restart index for vertex arrays Shader improvements OpenGL Shading Language 1.40 Shader can access uniform values from buffer objects Instanced rendering provides instance counter to vertex shader](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-6-2048.jpg&f=jpg&w=240)










![OpenGL & Direct3D Conventions OpenGL 3.2 First vertex of primitive Last vertex of primitive (mostly) Provoking vertex for flat-shading OpenGL 3.2 Upper-left Lower-left Fragment coordinate origin Cg HLSL 9, 10, and 11 GLSL Shading Language syntax Convention OpenGL Direct3D Addressed by Window origin Lower-left, pixels at half-integers Upper-left, pixels on integers (DX9) pixels on half-integers (DX 10) projection matrix & front-facing re-configuration Clip space [-1…+1] 3 [-1…+1] 2 [0…1] projection matrix re-configuration 4-byte vertex color RGBA BGRA OpenGL 3.2 Shader bind granularity Linked (for GLSL) Per-domain (for Cg & assembly) Per-domain EXT_separate shader_objects Object manipulation Bind-to-edit, Bind-to-query Edit-by-name, Query-by-name EXT_direct_ state_access](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-17-2048.jpg&f=jpg&w=240)








![Direct3D vs. OpenGL Coordinate System Conventions Window origin conventions Direct3D = upper-left origin OpenGL = lower-left origin Pixel center conventions Direct3D9 = pixel centers at integer locations OpenGL and Direct3D 10 = pixel centers at half-pixel locations Makes pixel centers for rasterization “match” texel centers for texturing Clip space conventions Direct3D = [-1,+1] for XY, [0,1] for Z OpenGL = [-1,+1] range for XYZ Affects How projection matrix is loaded Fragment shaders that access the window position Point sprites have upper-left texture coordinate origin OpenGL already lets application choose lower-left or upper-left](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-26-2048.jpg&f=jpg&w=240)

![Direct3D 9 to OpenGL How to go from Direct3D ’s [-1,+1]x[-1,+1]x[0,1] clip space to OpenGL’s [-1,+1] 3 integer-centered pixel centers to OpenGL’s half-pixel centers Simple state adjustment Projection matrix fudge glMatrixLoadIdentityEXT(GL_PROJECTION); glMatrixScalefEXT(GL_PROJECTION, 1, -1, 2); glMatrixTranslatefEXT(GL_PROJECTION, 0.5/windowWidth, 0.5/windowHeight, -0.5); Reverse convention for what is front-facing glFrontFace(GL_CW); // OpenGL default is GL_CCW Compensates for y-flip that reverses coordinate system’s handedness No need for API additions to support Direct3D 9’s system](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-28-2048.jpg&f=jpg&w=240)
![Direct3D 10 to OpenGL How to go from Direct3D 10’s [-1,+1]x[-1,+1]x[0,1] clip space to OpenGL’s [-1,+1] 3 where both APIs have half-pixel centers Simple state adjustment Projection matrix fudge glMatrixLoadIdentityEXT(GL_PROJECTION); glMatrixScalefEXT(GL_PROJECTION, 1, -1, 2); glMatrixTranslatefEXT(GL_PROJECTION, 0, 0, // no half-pixel shift for Direct3 10 -0.5); Reverse convention for what is front-facing glFrontFace(GL_CW); // OpenGL default is GL_CCW Compensates for y-flip that reverses coordinate system’s handedness Again, no need for API additions to support Direct3D 10’s system](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-29-2048.jpg&f=jpg&w=240)

















![Cg Code Shader performs texture-basis setup Can compile to GLSL or HLSL 10 code Cg 2.2 feature See working example code in Cg 2.2 TRIANGLE void md2bump_geometry( AttribArray < float4 > position : POSITION , AttribArray < float2 > texCoord : TEXCOORD0 , AttribArray < float3 > objPosition : TEXCOORD1 , AttribArray < float3 > objNormal : TEXCOORD2 , AttribArray < float3 > objView : TEXCOORD3 , AttribArray < float3 > objLight : TEXCOORD4 ) { float3 dXYZdU = objPosition[1] - objPosition[0]; float dSdU = texCoord[1].s - texCoord[0].s; float3 dXYZdV = objPosition[2] - objPosition[0]; float dSdV = texCoord[2].s - texCoord[0].s; float3 tangent = normalize (dSdV * dXYZdU - dSdU * dXYZdV); float area = determinant ( float2x2 (dSTdV, dSTdU)); float3 orientedTangent = area >= 0 ? tangent : -tangent; for ( int i=0; i<3; i++) { float3 normal = objNormal[i], binormal = cross (tangent,normal); float3x3 basis = float3x3 (orientedTangent, binormal, normal); float3 surfaceLightVector : TEXCOORD1 = mul (basis, objLight[i]); float3 surfaceViewVector : TEXCOORD2 = mul (basis, objView[i]); emitVertex (position[i], texCoord[i], surfaceLightVector, surfaceViewVector); } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-47-2048.jpg&f=jpg&w=240)



![Depth Clamping to the Rescue Depth clamping API Easy to enable/disable glEnable(GL_DEPTH_CLAMP); glDisable(GL_DEPTH_CLAMP); What it does Disables near & far clip planes But this allows depth values to interpolate beyond [0,1] representable range of the depth buffer So additionally clamps interpolated values to [0,1] range](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-51-2048.jpg&f=jpg&w=240)
![Depth Clamping Applications Avoid near plane “cut opens” via depth clamping Fragment shader replaces color of z=0 fragments with black In GLSL: if (gl_FragCoord.z == 0) gl_FragColor = vec4(0,0,0,1); Alternatively, use Painter’s algorithm for objects at the near plane Last (or first) fragment at z=0 “wins” Infinite Z-fail Shadow volumes See [Everett & Kilgard 2002] Conserves depth buffer precision when eye-space infinity must be within depth range](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-52-2048.jpg&f=jpg&w=240)





![Texture arrays 1D texture array 2D texture array Cube map texture array Multisample 2D texture multisample 2D texture array multisample All of OpenGL’s Texture Targets Conventional targets 1D texture 2D texture 3D texture Special addressing Cube map texture cube face selection Rectangle texture [0..w]x[0..h] range Texture buffer 1D unfiltered buffer objects](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-58-2048.jpg&f=jpg&w=240)



















![Passing Varyings Between Separate Shader Objects Programs in separate domains should pass varyings through builtin varyings (NOT user-specified varyings) So instead of varying float4 my_varying; Use a built-in such as gl_Texcoord[0] Guarantees up-stream and down-stream domains rendezvous with the same value Use of user-declared varyings are undefined Compiling Cg code to GLSL profiles guarantees this is the case Cg has semantics to indicate how varyings correspond to API resources Example Cg declaration: float4 my_varying : TEXCOORD0;](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-78-2048.jpg&f=jpg&w=240)







The document provides a comprehensive overview of OpenGL 3.2 and its features, highlighting enhancements from previous versions, such as increased shader capabilities and modern GPU functionality. It also discusses the compatibility of OpenGL with Direct3D conventions, addressing the differences in pixel processing, vertex ordering, and shading models. Additionally, the document emphasizes Nvidia's commitment to backward compatibility and support for both OpenGL and Direct3D APIs in visual computing applications.





![For review, OpenGL 3.1 Texturing Guarantees 16 texture units Texture buffer objects Texture rectangle target: 2D image with [0..width, 0..height] coordinate space Signed normalized texture formats Miscellaneous Fast data copying between buffer objects Primitive restart index for vertex arrays Shader improvements OpenGL Shading Language 1.40 Shader can access uniform values from buffer objects Instanced rendering provides instance counter to vertex shader](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-6-2048.jpg&f=jpg&w=240)










![OpenGL & Direct3D Conventions OpenGL 3.2 First vertex of primitive Last vertex of primitive (mostly) Provoking vertex for flat-shading OpenGL 3.2 Upper-left Lower-left Fragment coordinate origin Cg HLSL 9, 10, and 11 GLSL Shading Language syntax Convention OpenGL Direct3D Addressed by Window origin Lower-left, pixels at half-integers Upper-left, pixels on integers (DX9) pixels on half-integers (DX 10) projection matrix & front-facing re-configuration Clip space [-1…+1] 3 [-1…+1] 2 [0…1] projection matrix re-configuration 4-byte vertex color RGBA BGRA OpenGL 3.2 Shader bind granularity Linked (for GLSL) Per-domain (for Cg & assembly) Per-domain EXT_separate shader_objects Object manipulation Bind-to-edit, Bind-to-query Edit-by-name, Query-by-name EXT_direct_ state_access](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-17-2048.jpg&f=jpg&w=240)








![Direct3D vs. OpenGL Coordinate System Conventions Window origin conventions Direct3D = upper-left origin OpenGL = lower-left origin Pixel center conventions Direct3D9 = pixel centers at integer locations OpenGL and Direct3D 10 = pixel centers at half-pixel locations Makes pixel centers for rasterization “match” texel centers for texturing Clip space conventions Direct3D = [-1,+1] for XY, [0,1] for Z OpenGL = [-1,+1] range for XYZ Affects How projection matrix is loaded Fragment shaders that access the window position Point sprites have upper-left texture coordinate origin OpenGL already lets application choose lower-left or upper-left](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-26-2048.jpg&f=jpg&w=240)

![Direct3D 9 to OpenGL How to go from Direct3D ’s [-1,+1]x[-1,+1]x[0,1] clip space to OpenGL’s [-1,+1] 3 integer-centered pixel centers to OpenGL’s half-pixel centers Simple state adjustment Projection matrix fudge glMatrixLoadIdentityEXT(GL_PROJECTION); glMatrixScalefEXT(GL_PROJECTION, 1, -1, 2); glMatrixTranslatefEXT(GL_PROJECTION, 0.5/windowWidth, 0.5/windowHeight, -0.5); Reverse convention for what is front-facing glFrontFace(GL_CW); // OpenGL default is GL_CCW Compensates for y-flip that reverses coordinate system’s handedness No need for API additions to support Direct3D 9’s system](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-28-2048.jpg&f=jpg&w=240)
![Direct3D 10 to OpenGL How to go from Direct3D 10’s [-1,+1]x[-1,+1]x[0,1] clip space to OpenGL’s [-1,+1] 3 where both APIs have half-pixel centers Simple state adjustment Projection matrix fudge glMatrixLoadIdentityEXT(GL_PROJECTION); glMatrixScalefEXT(GL_PROJECTION, 1, -1, 2); glMatrixTranslatefEXT(GL_PROJECTION, 0, 0, // no half-pixel shift for Direct3 10 -0.5); Reverse convention for what is front-facing glFrontFace(GL_CW); // OpenGL default is GL_CCW Compensates for y-flip that reverses coordinate system’s handedness Again, no need for API additions to support Direct3D 10’s system](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-29-2048.jpg&f=jpg&w=240)

















![Cg Code Shader performs texture-basis setup Can compile to GLSL or HLSL 10 code Cg 2.2 feature See working example code in Cg 2.2 TRIANGLE void md2bump_geometry( AttribArray < float4 > position : POSITION , AttribArray < float2 > texCoord : TEXCOORD0 , AttribArray < float3 > objPosition : TEXCOORD1 , AttribArray < float3 > objNormal : TEXCOORD2 , AttribArray < float3 > objView : TEXCOORD3 , AttribArray < float3 > objLight : TEXCOORD4 ) { float3 dXYZdU = objPosition[1] - objPosition[0]; float dSdU = texCoord[1].s - texCoord[0].s; float3 dXYZdV = objPosition[2] - objPosition[0]; float dSdV = texCoord[2].s - texCoord[0].s; float3 tangent = normalize (dSdV * dXYZdU - dSdU * dXYZdV); float area = determinant ( float2x2 (dSTdV, dSTdU)); float3 orientedTangent = area >= 0 ? tangent : -tangent; for ( int i=0; i<3; i++) { float3 normal = objNormal[i], binormal = cross (tangent,normal); float3x3 basis = float3x3 (orientedTangent, binormal, normal); float3 surfaceLightVector : TEXCOORD1 = mul (basis, objLight[i]); float3 surfaceViewVector : TEXCOORD2 = mul (basis, objView[i]); emitVertex (position[i], texCoord[i], surfaceLightVector, surfaceViewVector); } }](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-47-2048.jpg&f=jpg&w=240)



![Depth Clamping to the Rescue Depth clamping API Easy to enable/disable glEnable(GL_DEPTH_CLAMP); glDisable(GL_DEPTH_CLAMP); What it does Disables near & far clip planes But this allows depth values to interpolate beyond [0,1] representable range of the depth buffer So additionally clamps interpolated values to [0,1] range](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-51-2048.jpg&f=jpg&w=240)
![Depth Clamping Applications Avoid near plane “cut opens” via depth clamping Fragment shader replaces color of z=0 fragments with black In GLSL: if (gl_FragCoord.z == 0) gl_FragColor = vec4(0,0,0,1); Alternatively, use Painter’s algorithm for objects at the near plane Last (or first) fragment at z=0 “wins” Infinite Z-fail Shadow volumes See [Everett & Kilgard 2002] Conserves depth buffer precision when eye-space infinity must be within depth range](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-52-2048.jpg&f=jpg&w=240)





![Texture arrays 1D texture array 2D texture array Cube map texture array Multisample 2D texture multisample 2D texture array multisample All of OpenGL’s Texture Targets Conventional targets 1D texture 2D texture 3D texture Special addressing Cube map texture cube face selection Rectangle texture [0..w]x[0..h] range Texture buffer 1D unfiltered buffer objects](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-58-2048.jpg&f=jpg&w=240)



















![Passing Varyings Between Separate Shader Objects Programs in separate domains should pass varyings through builtin varyings (NOT user-specified varyings) So instead of varying float4 my_varying; Use a built-in such as gl_Texcoord[0] Guarantees up-stream and down-stream domains rendezvous with the same value Use of user-declared varyings are undefined Compiling Cg code to GLSL profiles guarantees this is the case Cg has semantics to indicate how varyings correspond to API resources Example Cg declaration: float4 my_varying : TEXCOORD0;](/image.pl?url=https%3a%2f%2fimage.slidesharecdn.com%2fgtc2009openglkilgard-091008215235-phpapp01%2f75%2fOpenGL-3-2-and-More-78-2048.jpg&f=jpg&w=240)





