1 / 36

Advanced Computer Graphics Global Illumination - OptiX

Advanced Computer Graphics Global Illumination - OptiX. Ming-Te Chi Department of Computer Science,  National Chengchi University. Outline. CUDA OptiX. CPU vs GPU. OpenMP. #include < omp.h > # include < stdio.h > # include < stdlib.h > void Test( int n ) {

judd
Download Presentation

Advanced Computer Graphics Global Illumination - OptiX

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Advanced Computer Graphics Global Illumination - OptiX • Ming-Te Chi • Department of Computer Science,  • National Chengchi University

  2. Outline • CUDA • OptiX

  3. CPU vs GPU

  4. OpenMP #include <omp.h> #include <stdio.h> #include <stdlib.h> void Test( int n ) { for( inti = 0; i < 10000; ++i) { //do nothing, just waste time} printf( "%d, ", n ); } intmain(intargc, char* argv[]) { #pragma omp parallel for for( inti = 0; i < 10; ++ i ) Test( i ); system( "pause" ); }

  5. CUDA - Kernels and Thread

  6. NVCC • cu: c language with extension • PTX: binary in CUDA instruction set architecture. (virtual assemble language) • nvcc: nVidiaCuda Compiler: • Compile cu into PTX

  7. CPU to GPU

  8. Memory Hierarchy Execution flow

  9. OptiX

  10. Document OptiX: A scalable framework for ray-tracing based application. • OptiX Programming Guide • Host-based API • CUDA c-based system that produce ray, intersection, … • OptiXQuickstart Guide • How to implement several basic ray tracing effects, from trivially simple to moderately complex.

  11. Object model • Context • Program • Variable • Buffer • Texture sampler • Geometry Instance • Geometry • Material • Group • Geometry Group • Transform • Selector • Transform • Acceleration

  12. Node graph

  13. Host - Context

  14. Host – entry points

  15. Programs - Ray Type

  16. Radiance

  17. Shadow ray

  18. Geometry Instance • Geometry Instance • Geometry • IntersectionProgram • BoundingBoxProgram • Material • ClosestHitProgram • AnyHitProgram

  19. Programs • Ray Generation • camera • Closest Hit • shading • Any Hit • Shadow ray • Miss • background/environment • Exception • Bad pixel / Print error • Intersection • ray-primitive • Bounding Box • Ray-bounding box • Visit

  20. Programs – Ray Generation(1)

  21. Programs – Ray Generation(2)

  22. Programs – bounding box

  23. Programs – Intersection

  24. Programs – Closest Hit

  25. Programs – Miss

  26. Supported OptiX call

  27. sample • Sample 1~8 • Whitted, Cook,glass, Tutorial

  28. Host - SampleScene.h class SampleScene { // Create the optix scene and return initial viewing parameters virtual void initScene( InitialCameraData& camera_data )=0; // Update camera shader with new viewing params and then trace virtual void trace( constRayGenCameraData& camera_data )=0; // Return the output buffer to be displayed virtual optix::Buffer getOutputBuffer()=0; // Optional virtual interface virtual void cleanUp(); virtual void resize(unsigned int width, unsigned int height); virtual boolkeyPressed(unsigned char key, int x, int y) }

  29. void Tutorial::trace( constRayGenCameraData& camera_data ) { m_context["eye"]->setFloat( camera_data.eye ); m_context["U"]->setFloat( camera_data.U ); m_context["V"]->setFloat( camera_data.V ); m_context["W"]->setFloat( camera_data.W ); Buffer buffer = m_context["output_buffer"]->getBuffer(); RTsizebuffer_width, buffer_height; buffer->getSize( buffer_width, buffer_height ); m_context->launch( 0, static_cast<unsigned int>(buffer_width), static_cast<unsigned int>(buffer_height) ); }

  30. Tutorial 0 – Normal shader Intersection() rtTrace()

  31. Tutorial 1 – Diffuse shader

  32. Light ffnormal Ray.origin L hit_point

  33. Tutorial 2 – Phong Highlight • Half vector Light ffnormal Ray.origin L hit_point

  34. Tutorial 3 - Shadows

  35. Light ffnormal Ray.origin L hit_point

More Related