Presentation is loading. Please wait.

Presentation is loading. Please wait.

The OpenRT Application Programming Interface - Towards a Common API for Interactive Ray Tracing – OpenSG 2003 Darmstadt, Germany Andreas Dietrich Ingo.

Similar presentations


Presentation on theme: "The OpenRT Application Programming Interface - Towards a Common API for Interactive Ray Tracing – OpenSG 2003 Darmstadt, Germany Andreas Dietrich Ingo."— Presentation transcript:

1 The OpenRT Application Programming Interface - Towards a Common API for Interactive Ray Tracing – OpenSG 2003 Darmstadt, Germany Andreas Dietrich Ingo Wald Carsten Benthin Philipp Slusallek Computer Graphics Lab Saarland University

2 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface2 Introduction Interactive rendering performance available even on standard PCsInteractive rendering performance available even on standard PCs –Interactive systems typically limited to simple illumination models –High-quality image generation still dominated by offline rendering systems High-quality interactive rendering now possibleHigh-quality interactive rendering now possible –Ray Tracing will play a larger role in future applications –Current application programming interfaces not well suited Need for an API, which combines best of both worlds Need for an API, which combines best of both worlds

3 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface3 Rasterization Most of todays interactive rendering systems build on rasterization techniquesMost of todays interactive rendering systems build on rasterization techniques –Projection of polygons onto the image plane –Each polygon is processed locally without relation to any other Rasterization pipeline Rasterization pipeline Efficient hardware implementations Efficient hardware implementations Absence of global information has certain drawbacksAbsence of global information has certain drawbacks –Linear in the number of triangles –Limited to local illumination High-quality images require multiple rendering passes (e.g. to produce shadows) High-quality images require multiple rendering passes (e.g. to produce shadows) Extensive manual tuning Extensive manual tuning –Physically-accurate lighting effects are beyond the capabilities of rendering tricks even with programmable GPUs

4 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface4 Ray Tracing Most architectures incorporating sophisticated illumination perform ray tracingMost architectures incorporating sophisticated illumination perform ray tracing –Close modeling of physical light propagation –Shooting of imaginary rays into the scene Advantages over rasterizationAdvantages over rasterization –Physical correctness -Shooting of arbitrary rays -Accurate computation of global and advanced lighting effects (e.g. shadows, reflections, refractions on arbitrary surfaces) –Plug and play shading -Combination of different shading effects in correct order -Independent building of individual shaders –Complex scenes -Logarithmic in the number of triangles -Handling of scenes with billions of triangles -Inherent occlusion-culling, demand driven and output-sensitive

5 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface5 An Interactive Ray Tracing API Available rendering APIsAvailable rendering APIs –Pixars RenderMan -Oriented towards high-quality rendering, especially ray tracing -Missing support for interactive applications –OpenGL Performer, OpenInventor, OpenSG -No single candidate -Mostly used for a specific application domain –OpenGL -Flexible and popular -Too tightly coupled to the rasterization pipeline APIs for interactive ray tracing simply not yet available APIs for interactive ray tracing simply not yet available Introduction of a new API called OpenRT

6 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface6 OpenRT Low-level graphics interface in the spirit of OpenGLLow-level graphics interface in the spirit of OpenGL –Syntactically similar to OpenGL -Easy-to-use -Aids the porting of applications –Allows to layer scene graph APIs on top –But: Neither simple extension nor subset of OpenGL -Fundamental differences between rasterization and ray tracing Supports high-quality image generationSupports high-quality image generation –Physically-correct lighting simulations –Arbitrary programmable shading –Highly complex scenes possible Development not finalized but already used in practiceDevelopment not finalized but already used in practice –Saarland Universitys Real-Time Ray Tracing system [Wald 01] –SaarCOR hardware ray tracing architecture [Schmittler 02]

7 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface7 OpenRT API Structure OpenRT API actually comprises three sub-interfacesOpenRT API actually comprises three sub-interfaces –OpenRT application interface -Specify geometry objects, transformations, textures, … -Similar to OpenGL –OpenSRT programmable shader interface -Specify and load shader programs -Communication with shaders via shader parameters –OpenRTS shading language -Shader plug-in programming interface -Not used by front-end applications -Could be replaced by other shading languages (e.g. RenderMan) For many calls simply replace OpenGL´s gl with rt

8 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface8 OpenRT and OpenGL OpenRT and OpenGL differ in four main areas 1. Rendering semantics –Unlike OpenGLs drawing approach OpenRT uses objects –Shader objects are bound to geometry objects 2. Objects and instantiation –Geometric objects serve as simple containers –Efficient reuse of objects 3. Multi-pass rendering vs. programmable shading –Possible but not necessary due to programmable shader objects 4. Fragment and 2D operations –OpenRT serves as a pure 3D graphics library –Mix of OpenRT and OpenGL under evaluation

9 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface9 Application Example Framework #include #include RTint objId; void Display() { rtutSwapBuffers(); } void Idle() { static int rot = 0; rot++; static int rot = 0; rot++; rtDeleteAllInstances(); rtDeleteAllInstances(); for (int i=0; i<8; i++) { for (int i=0; i<8; i++) { int dx = (i&1)?-1:1; int dx = (i&1)?-1:1; int dy = (i&2)?-1:1; int dy = (i&2)?-1:1; int dz = (i&4)?-1:1; int dz = (i&4)?-1:1; // position individual objects // position individual objects rtTranslatef(dx,dy,dz); rtTranslatef(dx,dy,dz); rtRotatef(4*rot*dx,dz,dy,dx); rtRotatef(4*rot*dx,dz,dy,dx); rtScalef(.5,.5,.5); rtScalef(.5,.5,.5); rtInstantiateObject(objId); rtInstantiateObject(objId); } rtutPostRedisplay(); rtutPostRedisplay();} int main(int argc, char *argv[]) { rtutInit(&argc, argv); rtutInit(&argc, argv); rtutInitWindowSize(640, 480); rtutInitWindowSize(640, 480); rtutCreateWindow("Eight Cubes"); rtutCreateWindow("Eight Cubes"); rtutIdleFunc(Idle); rtutIdleFunc(Idle); rtutDisplayFunc(Display); rtutDisplayFunc(Display); objId = createColorCubeObject(); objId = createColorCubeObject(); rtPerspective(65, 1, 1, ); rtPerspective(65, 1, 1, ); rtLookAt(2,4,3, 0,0,0, 0,0,1); rtLookAt(2,4,3, 0,0,0, 0,0,1); rtutMainLoop(); rtutMainLoop(); return 0; return 0;} rtutInit(&argc, argv); rtutInitWindowSize(640, 480); rtutCreateWindow("Eight Cubes"); rtutIdleFunc(Idle);rtutDisplayFunc(Display); …rtutMainLoop(); Applications can make use of the OpenRT Utility Toolkit, RTUT Handling of windows, events, devices, … Virtually operated like OpenGLs GLUT Virtually operated like OpenGLs GLUT

10 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface10 Application Example Instantiation #include #include RTint objId; void Display() { rtutSwapBuffers(); } void Idle() { static int rot = 0; rot++; static int rot = 0; rot++; rtDeleteAllInstances(); rtDeleteAllInstances(); for (int i=0; i<8; i++) { for (int i=0; i<8; i++) { int dx = (i&1)?-1:1; int dx = (i&1)?-1:1; int dy = (i&2)?-1:1; int dy = (i&2)?-1:1; int dz = (i&4)?-1:1; int dz = (i&4)?-1:1; // position individual objects // position individual objects rtTranslatef(dx,dy,dz); rtTranslatef(dx,dy,dz); rtRotatef(4*rot*dx,dz,dy,dx); rtRotatef(4*rot*dx,dz,dy,dx); rtScalef(.5,.5,.5); rtScalef(.5,.5,.5); rtInstantiateObject(objId); rtInstantiateObject(objId); } rtutPostRedisplay(); rtutPostRedisplay();} int main(int argc, char *argv[]) { rtutInit(&argc, argv); rtutInit(&argc, argv); rtutInitWindowSize(640, 480); rtutInitWindowSize(640, 480); rtutCreateWindow("Eight Cubes"); rtutCreateWindow("Eight Cubes"); rtutIdleFunc(Idle); rtutIdleFunc(Idle); rtutDisplayFunc(Display); rtutDisplayFunc(Display); objId = createColorCubeObject(); objId = createColorCubeObject(); rtPerspective(65, 1, 1, ); rtPerspective(65, 1, 1, ); rtLookAt(2,4,3, 0,0,0, 0,0,1); rtLookAt(2,4,3, 0,0,0, 0,0,1); rtutMainLoop(); rtutMainLoop(); return 0; return 0;}rtDeleteAllInstances(); for (int i=0; i<8; i++) { int dx = (i&1)?-1:1; int dx = (i&1)?-1:1; int dy = (i&2)?-1:1; int dy = (i&2)?-1:1; int dz = (i&4)?-1:1; int dz = (i&4)?-1:1; // position individual objects // position individual objects rtTranslatef(dx,dy,dz); rtTranslatef(dx,dy,dz); rtRotatef(4*rot*dx,dz,dy,dx); rtRotatef(4*rot*dx,dz,dy,dx); rtScalef(.5,.5,.5); rtScalef(.5,.5,.5); rtInstantiateObject(objId); rtInstantiateObject(objId);} Objects have to be instantiated rtInstantiatedObject() rtInstantiatedObject() Instance = geometry + transformation rtTranslatef(), rtRotatef(), … rtTranslatef(), rtRotatef(), … Remove current instances using rtDeleteAllInstances() rtDeleteAllInstances()

11 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface11 Application Example Geometry Objects #include #include #define VERTEX_COLOR_SHADER_ID 0 #define VERTEX_COLOR_SHADERFILE_ID 1 RTint createColorCubeObject() { srtShaderFile(VERTEX_COLOR_SHADERFILE_ID, srtShaderFile(VERTEX_COLOR_SHADERFILE_ID, "VertexColor", "VertexColor", "libVertexColor.so"); "libVertexColor.so"); srtCreateShader(VERTEX_COLOR_SHADER_ID); srtCreateShader(VERTEX_COLOR_SHADER_ID); RTint objId = rtGenObjects(1); RTint objId = rtGenObjects(1); rtNewObject(objId, RT_COMPILE); rtNewObject(objId, RT_COMPILE); rtMatrixMode(RT_MODELVIEW); rtMatrixMode(RT_MODELVIEW); rtPushMatrix(); rtPushMatrix(); rtTranslatef(-1, -1, -1); rtTranslatef(-1, -1, -1); rtScalef(2, 2, 2); rtScalef(2, 2, 2); // first cube side // first cube side rtBegin(RT_POLYGON); rtBegin(RT_POLYGON); rtColor3f(0, 0, 0); rtColor3f(0, 0, 0); rtVertex3f(0, 0, 0); rtVertex3f(0, 0, 0); rtColor3f(0, 1, 0); rtColor3f(0, 1, 0); rtVertex3f(0, 1, 0); rtVertex3f(0, 1, 0); rtColor3f(1, 1, 0); rtColor3f(1, 1, 0); rtVertex3f(1, 1, 0); rtVertex3f(1, 1, 0); rtColor3f(1, 0, 0); rtColor3f(1, 0, 0); rtVertex3f(1, 0, 0); rtVertex3f(1, 0, 0); rtEnd(); rtEnd(); // other cube sides // other cube sides rtPopMatrix(); rtPopMatrix(); rtEndObject(); rtEndObject(); return objId; return objId;} RTint objId = rtGenObjects(1); rtNewObject(objId, RT_COMPILE); … rtEndObject(); Geometry objects are allocated using rtGenObjects() rtGenObjects() New object encapsulated between rtNewObject()/rtEndObject() rtNewObject()/rtEndObject() Just like OpenGLs Just like OpenGLsglGenLists()glNewList()/glEndList()

12 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface12 Application Example Primitives #include #include #define VERTEX_COLOR_SHADER_ID 0 #define VERTEX_COLOR_SHADERFILE_ID 1 RTint createColorCubeObject() { srtShaderFile(VERTEX_COLOR_SHADERFILE_ID, srtShaderFile(VERTEX_COLOR_SHADERFILE_ID, "VertexColor", "VertexColor", "libVertexColor.so"); "libVertexColor.so"); srtCreateShader(VERTEX_COLOR_SHADER_ID); srtCreateShader(VERTEX_COLOR_SHADER_ID); RTint objId = rtGenObjects(1); RTint objId = rtGenObjects(1); rtNewObject(objId, RT_COMPILE); rtNewObject(objId, RT_COMPILE); rtMatrixMode(RT_MODELVIEW); rtMatrixMode(RT_MODELVIEW); rtPushMatrix(); rtPushMatrix(); rtTranslatef(-1, -1, -1); rtTranslatef(-1, -1, -1); rtScalef(2, 2, 2); rtScalef(2, 2, 2); // first cube side // first cube side rtBegin(RT_POLYGON); rtBegin(RT_POLYGON); rtColor3f(0, 0, 0); rtColor3f(0, 0, 0); rtVertex3f(0, 0, 0); rtVertex3f(0, 0, 0); rtColor3f(0, 1, 0); rtColor3f(0, 1, 0); rtVertex3f(0, 1, 0); rtVertex3f(0, 1, 0); rtColor3f(1, 1, 0); rtColor3f(1, 1, 0); rtVertex3f(1, 1, 0); rtVertex3f(1, 1, 0); rtColor3f(1, 0, 0); rtColor3f(1, 0, 0); rtVertex3f(1, 0, 0); rtVertex3f(1, 0, 0); rtEnd(); rtEnd(); // other cube sides // other cube sides rtPopMatrix(); rtPopMatrix(); rtEndObject(); rtEndObject(); return objId; return objId;}rtBegin(RT_POLYGON); rtColor3f(0, 0, 0); rtColor3f(0, 0, 0); rtVertex3f(0, 0, 0); rtVertex3f(0, 0, 0); rtColor3f(0, 1, 0); rtColor3f(0, 1, 0); rtVertex3f(0, 1, 0); rtVertex3f(0, 1, 0); rtColor3f(1, 1, 0); rtColor3f(1, 1, 0); rtVertex3f(1, 1, 0); rtVertex3f(1, 1, 0); rtColor3f(1, 0, 0); rtColor3f(1, 0, 0); rtVertex3f(1, 0, 0); rtVertex3f(1, 0, 0);rtEnd(); Primitives are defined using rtBegin( primType )/rtEnd() rtBegin( primType )/rtEnd() With standard types RT_TRIANGLE, RT_POLYGON, … RT_TRIANGLE, RT_POLYGON, … Vertex data supplied by rtVertex3f(), rtColor3f(), … rtVertex3f(), rtColor3f(), …

13 OpenRT Video

14 COMPUTER GRAPHIK – UNIVERSITÄT DES SAARLANDES OpenSG 2003 The OpenRT Application Programming Interface14 Summary Ray tracing is much more powerful then rasterizationRay tracing is much more powerful then rasterization –More accurate, fully automatic, more efficient Interactive ray tracing now possibleInteractive ray tracing now possible –Need for an API that combines interactivity and high-quality image generation OpenRT can serve as such an APIOpenRT can serve as such an API –Low-level graphics interface –As easy to use as OpenGL –Supports all the advantages of interactive ray tracing –Successfully applied in practice

15 Questions ? For more information see


Download ppt "The OpenRT Application Programming Interface - Towards a Common API for Interactive Ray Tracing – OpenSG 2003 Darmstadt, Germany Andreas Dietrich Ingo."

Similar presentations


Ads by Google