diff --git a/README.md b/README.md index 1faaac4..35ed6b1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This tutorial was created to accompany the 2019 Siggraph course on https://drive.google.com/open?id=1_IYHwAZ4EoMcDmS0TknP-TZd7Cwmab_I ). The aim of this repo is to serve as a "tutorial" in how to set -up a full Scene - i.e.,, OptiX Context, Module, Programs, Pipeline, +up a full Scene - i.e., OptiX Context, Module, Programs, Pipeline, Shader Binding Table (SBT), Accel Struct (AS), Build Inputs, Texture Samplers, etc., in the newly introduced OptiX 7. @@ -14,7 +14,7 @@ To do this, this repo intentionally does not provide *one* example that has the final code, but instead is split into 10 smaller examples, each of which modifies and extends the previous one, hopefully in a way that it is relatively easy to spot the differences -(i.e.,, to spot what exactly had to be added to go from "A" to "B"). +(i.e., to spot what exactly had to be added to go from "A" to "B"). Note this tutorial does (intentionally) not end in a overwhelming wow-factor full-featured renderer - it's aim is to *only* help you get @@ -27,16 +27,15 @@ out of the box in both Linux and Windows. However, I assume it's safe to expect that some one or other bug has crept in somewhere that I haven't found yet. If you do find one, please feel free to let me know via email or bug report, or send a push request, so others will be -spared from finding it again. Of course, any other feedback is -welcome, too! +spared from finding it again. Any other feedback is welcome, too! # Building the Code This code was intentionally written with minimal dependencies, -requiring pretty much only CMake (as a build system), your favorite -compiler (tested with Visual Studio under Windows, and GCC under -Linux), and of course the OptiX 7 SDK (including CUDA 10.1 and the +requiring only CMake (as a build system), your favorite +compiler (tested with Visual Studio 2017 under Windows, and GCC under +Linux), and the OptiX 7 SDK (including CUDA 10.1 and the most recent NVIDIA developer driver). ## Dependencies @@ -55,8 +54,8 @@ most recent NVIDIA developer driver). `export OptiX_INSTALL_DIR=` - on windows, the installer should automatically put it into the right directory -The literally only *external* library we use is GLFW for windowing, and -even this one we actually build on the fly under Windows, so installing +The only *external* library we use is GLFW for windowing, and +even this one we build on the fly under Windows, so installing it is required only under Linux. Detailed steps below: @@ -97,7 +96,7 @@ Detailed steps below: - Open `CMake GUI` from your start menu - point "source directory" to the downloaded source directory - point "build directory" to /build (agree to create this directory when prompted) - - click 'configure', then specify the generator as Visual Studio 15 2017, and the Optional platform as x64. If CUDA, SDK, and compiler are all properly installed this should enable the 'generate' button. If not, make sure all dependencies are properly installed, "clear cache", and re-configure. + - click 'configure', then specify the generator as Visual Studio 2017 (Version 15), and the Optional platform as x64. If CUDA, SDK, and compiler are all properly installed this should enable the 'generate' button. If not, make sure all dependencies are properly installed, "clear cache", and re-configure. - click 'generate' (this creates a visual studio project and solutions) - click 'open project' (this should open the project in visual studio) @@ -128,11 +127,11 @@ in a console window, e.g., run `build\Debug\ex01_helloOptix.exe` ## Example 2: First Pipeline Setup and Raygen Program This is the first "real" OptiX example, and maybe somewhat -surprisingly, the biggest "step" in all of the examples. +surprisingly, the biggest "step" in all the examples. The actual raygen program that this example launches is actually -very(!) small, and pretty much trivial; and there are no other programs, -not even geometry, nor a single ray being traced... but to launch +very (!) small, and pretty much trivial; and there are no other programs, +not even geometry, nor a single ray being traced ... but to launch this simple raygen program we nevertheless have to go through the entire process of creating Modules, Programs, and, in particular, a valid "Shader Binding Table" (SBT), before we can launch our little @@ -148,9 +147,8 @@ On the upside: Once this initial setup is done, everything will get Rendering to files is nice and well, but *probably* you want to eventually do some online rendering; so this example moves the previous raygen example into a 3D viewer window (created and run using -GLFW). For now this viewer just displays the rendered images (i.e.,, -nothing changes from frame to frame); I'm going to add some user -interaction after Siggraph is over. +GLFW). For now this viewer just displays the rendered images, with no +user interaction. ![Same Raygen example, in GLFL Window (Linux)](./example03_inGLFWindow/ex03-linux.png) ![Same Raygen example, in GLFL Window (Windows)](./example03_inGLFWindow/ex03-windows.png) @@ -163,17 +161,18 @@ real geometry. This example introduces how to create some Triangle Mesh Geometry (in this example, two simple, hardcoded, cubes), how to build an -Acceleration structure over this "BuildInput", and how to trace rays -against. To do this it also needs to introduce a simple camera model. +Acceleration Structure over this "BuildInput", and how to trace rays +against it. To do this we also need to introduce a simple camera model. ![First Triangle Mesh and Accel Struct](./example04_firstTriangleMesh/ex04.png) ## Example 5: First Shader Binding Table (SBT) Data The earlier examples *created* an SBT (they had to, else they couldn't -have executed any OptiX launch); but didn't actually put any data into +have executed any OptiX launch), but didn't actually put any data into the SBT. This example introduces how to do that, by putting just some -simple constant per-object color into the mesh's SBT entry. +simple constant per-object color into the mesh's SBT entry, then shading +it based on the surface normal's angle to the view ray. ![First SBT Data](./example05_firstSBTData/ex05.png) @@ -204,21 +203,21 @@ suddenly starts to take shape: ## Example 8: Adding Textures via CUDA Texture Objects This example shows how to create and set up CUDA texture objects on -the host, host to pass those to the device via the SBT, and how to use +the host, with the host passing those to the device via the SBT, and how to use those texture objects on the device. This one will take a bit of time -to load in Debug - it's worth the wait! +to load in Debug - it's worth the wait! Or simply build and run in Release. ![Adding Textures](./example08_addingTextures/ex08.png) ## Example 9: Adding a second ray type: Shadows -This is the last example that focusses on host-side setup, in this +This is the last example that focuses on host-side setup, in this case adding a second ray type (for shadow rays), which also requires -to change the way the SBT is being built. +changing the way the SBT is being built. This sample also shows how to shoot secondary rays (the shadow rays) in device programs, how to use an any-hit program for the shadow rays, -how to call *optixTerminateRay* from within an anyhit program, and how +how to call *optixTerminateRay* from within an any-hit program, and how to use the optixTrace call's SBT index/offset values to specify the ray type. @@ -232,9 +231,12 @@ example can now start to focus more on the "ray tracing 101" style additions that focus what rays to trace to add certain rendering effects. -This simple example intentionally only adds soft shadows from area lights, but extending this to add reflections, refraction, diffuse bounces, better material models/BRDFs, etc., show from now on be rather straightforward. +This simple example intentionally only adds soft shadows from area +lights, but extending this to add reflections, refraction, diffuse +bounces, better material models/BRDFs, etc., should from now on be +straightforward. -Please feel free to play with adding these examples... and share what +Please feel free to play with adding these examples ... and share what you did! ![Soft Shadows](./example10_softShadows/ex10.png) @@ -242,9 +244,9 @@ you did! ## Example 11: It's up to you ... From here on, there are multiple different avenues of how to add to -this very simple viewer, both in terms of visual features, -performance, kind and complexity of geometry, etc. In no particular -order, and just to serve as an inspiration: +this simple viewer, in terms of visual features, performance, kind +and complexity of geometry, etc. In no particular order, and just +to serve as inspiration: - Performance - Multi-GPU diff --git a/example01_helloOptix/main.cpp b/example01_helloOptix/main.cpp index dbcf304..30db887 100644 --- a/example01_helloOptix/main.cpp +++ b/example01_helloOptix/main.cpp @@ -21,7 +21,7 @@ /*! \namespace osc - Optix Siggraph Course */ namespace osc { - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void initOptix() { // ------------------------------------------------------- diff --git a/example02_pipelineAndRayGen/SampleRenderer.cpp b/example02_pipelineAndRayGen/SampleRenderer.cpp index a36e1f9..ad27c94 100644 --- a/example02_pipelineAndRayGen/SampleRenderer.cpp +++ b/example02_pipelineAndRayGen/SampleRenderer.cpp @@ -50,7 +50,7 @@ namespace osc { int objectID; }; - /*! constructor - performs asll setup, inlucuding initializing + /*! constructor - performs all setup, including initializing optix, creates module, pipeline, programs, SBT, etc. */ SampleRenderer::SampleRenderer() { @@ -83,7 +83,7 @@ namespace osc { std::cout << GDT_TERMINAL_DEFAULT; } - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void SampleRenderer::initOptix() { std::cout << "#osc: initializing optix..." << std::endl; @@ -125,7 +125,7 @@ namespace osc { CUDA_CHECK(StreamCreate(&stream)); cudaGetDeviceProperties(&deviceProps, deviceID); - std::cout << "#osc: running on device device: " << deviceProps.name << std::endl; + std::cout << "#osc: running on device: " << deviceProps.name << std::endl; CUresult cuRes = cuCtxGetCurrent(&cudaContext); if( cuRes != CUDA_SUCCESS ) @@ -175,7 +175,7 @@ namespace osc { - /*! does all setup for the raygen program(s) we are going to use */ + /*! does all setup for the raygen program(s) we are going to use */ void SampleRenderer::createRaygenPrograms() { // we do a single ray gen program in this example: @@ -200,7 +200,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the miss program(s) we are going to use */ + /*! does all setup for the miss program(s) we are going to use */ void SampleRenderer::createMissPrograms() { // we do a single ray gen program in this example: @@ -225,7 +225,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the hitgroup program(s) we are going to use */ + /*! does all setup for the hitgroup program(s) we are going to use */ void SampleRenderer::createHitgroupPrograms() { // for this simple example, we set up a single hit group @@ -330,7 +330,7 @@ namespace osc { // we don't actually have any objects in this example, but let's // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) + // (which the sanity checks in compilation would complain about) int numObjects = 1; std::vector hitgroupRecords; for (int i=0;i 1) PRINT(log); } - /*! does all setup for the miss program(s) we are going to use */ + /*! does all setup for the miss program(s) we are going to use */ void SampleRenderer::createMissPrograms() { // we do a single ray gen program in this example: @@ -225,7 +225,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the hitgroup program(s) we are going to use */ + /*! does all setup for the hitgroup program(s) we are going to use */ void SampleRenderer::createHitgroupPrograms() { // for this simple example, we set up a single hit group @@ -330,7 +330,7 @@ namespace osc { // we don't actually have any objects in this example, but let's // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) + // (which the sanity checks in compilation would complain about) int numObjects = 1; std::vector hitgroupRecords; for (int i=0;i 1) PRINT(log); } - /*! does all setup for the miss program(s) we are going to use */ + /*! does all setup for the miss program(s) we are going to use */ void SampleRenderer::createMissPrograms() { // we do a single ray gen program in this example: @@ -389,7 +391,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the hitgroup program(s) we are going to use */ + /*! does all setup for the hitgroup program(s) we are going to use */ void SampleRenderer::createHitgroupPrograms() { // for this simple example, we set up a single hit group @@ -494,7 +496,7 @@ namespace osc { // we don't actually have any objects in this example, but let's // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) + // (which the sanity checks in compilation would complain about) int numObjects = 1; std::vector hitgroupRecords; for (int i=0;i(); prd = gdt::randomColor(primID); } @@ -141,7 +141,7 @@ namespace osc { // to make stb_image_write happy ... const uint32_t rgba = 0xff000000 | (r<<0) | (g<<8) | (b<<16); - + // and write to frame buffer ... const uint32_t fbIndex = ix+iy*optixLaunchParams.frame.size.x; optixLaunchParams.frame.colorBuffer[fbIndex] = rgba; diff --git a/example05_firstSBTData/SampleRenderer.cpp b/example05_firstSBTData/SampleRenderer.cpp index a7f9738..83d8f9d 100644 --- a/example05_firstSBTData/SampleRenderer.cpp +++ b/example05_firstSBTData/SampleRenderer.cpp @@ -45,13 +45,11 @@ namespace osc { struct __align__( OPTIX_SBT_RECORD_ALIGNMENT ) HitgroupRecord { __align__( OPTIX_SBT_RECORD_ALIGNMENT ) char header[OPTIX_SBT_RECORD_HEADER_SIZE]; - // just a dummy value - later examples will use more interesting - // data here TriangleMeshSBTData data; }; - //! add aligned cube aith front-lower-left corner and size + //! add aligned cube with front-lower-left corner and size void TriangleMesh::addCube(const vec3f ¢er, const vec3f &size) { affine3f xfm; @@ -81,7 +79,7 @@ namespace osc { 5,7,6, 5,6,4, 0,4,5, 0,5,1, 2,3,7, 2,7,6, - 1,5,6, 1,7,3, + 1,5,7, 1,7,3, 4,0,2, 4,2,6 }; for (int i=0;i<12;i++) @@ -91,7 +89,7 @@ namespace osc { } - /*! constructor - performs asll setup, inlucuding initializing + /*! constructor - performs all setup, including initializing optix, creates module, pipeline, programs, SBT, etc. */ SampleRenderer::SampleRenderer(const TriangleMesh &model) : model(model) @@ -246,11 +244,11 @@ namespace osc { outputBuffer.free(); // << the UNcompacted, temporary output buffer tempBuffer.free(); compactedSizeBuffer.free(); - + return asHandle; } - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void SampleRenderer::initOptix() { std::cout << "#osc: initializing optix..." << std::endl; @@ -292,7 +290,7 @@ namespace osc { CUDA_CHECK(StreamCreate(&stream)); cudaGetDeviceProperties(&deviceProps, deviceID); - std::cout << "#osc: running on device device: " << deviceProps.name << std::endl; + std::cout << "#osc: running on device: " << deviceProps.name << std::endl; CUresult cuRes = cuCtxGetCurrent(&cudaContext); if( cuRes != CUDA_SUCCESS ) @@ -342,7 +340,7 @@ namespace osc { - /*! does all setup for the raygen program(s) we are going to use */ + /*! does all setup for the raygen program(s) we are going to use */ void SampleRenderer::createRaygenPrograms() { // we do a single ray gen program in this example: @@ -367,7 +365,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the miss program(s) we are going to use */ + /*! does all setup for the miss program(s) we are going to use */ void SampleRenderer::createMissPrograms() { // we do a single ray gen program in this example: @@ -392,7 +390,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the hitgroup program(s) we are going to use */ + /*! does all setup for the hitgroup program(s) we are going to use */ void SampleRenderer::createHitgroupPrograms() { // for this simple example, we set up a single hit group @@ -494,10 +492,6 @@ namespace osc { // ------------------------------------------------------------------ // build hitgroup records // ------------------------------------------------------------------ - - // we don't actually have any objects in this example, but let's - // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) int numObjects = 1; std::vector hitgroupRecords; for (int i=0;i pixels; }; diff --git a/example06_multipleObjects/SampleRenderer.cpp b/example06_multipleObjects/SampleRenderer.cpp index aaaf2c0..b825c32 100644 --- a/example06_multipleObjects/SampleRenderer.cpp +++ b/example06_multipleObjects/SampleRenderer.cpp @@ -49,7 +49,7 @@ namespace osc { }; - //! add aligned cube aith front-lower-left corner and size + //! add aligned cube with front-lower-left corner and size void TriangleMesh::addCube(const vec3f ¢er, const vec3f &size) { PING; @@ -80,7 +80,7 @@ namespace osc { 5,7,6, 5,6,4, 0,4,5, 0,5,1, 2,3,7, 2,7,6, - 1,5,6, 1,7,3, + 1,5,7, 1,7,3, 4,0,2, 4,2,6 }; for (int i=0;i<12;i++) @@ -90,8 +90,8 @@ namespace osc { } - /*! constructor - performs asll setup, inlucuding initializing - optix, creates module, pipeline, programs, SBT, etc. */ + /*! constructor - performs all setup, including initializing + optix, creates module, pipeline, programs, SBT, etc. */ SampleRenderer::SampleRenderer(const std::vector &meshes) : meshes(meshes) { @@ -223,7 +223,7 @@ namespace osc { /* stream */0, &accelOptions, triangleInput.data(), - (int)meshes.size(), + (int)meshes.size(), tempBuffer.d_pointer(), tempBuffer.sizeInBytes, @@ -261,7 +261,7 @@ namespace osc { return asHandle; } - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void SampleRenderer::initOptix() { std::cout << "#osc: initializing optix..." << std::endl; @@ -294,7 +294,7 @@ namespace osc { } /*! creates and configures a optix device context (in this simple - example, only for the primary GPU device) */ + example, only for the primary GPU device) */ void SampleRenderer::createContext() { // for this sample, do everything on one device @@ -303,7 +303,7 @@ namespace osc { CUDA_CHECK(StreamCreate(&stream)); cudaGetDeviceProperties(&deviceProps, deviceID); - std::cout << "#osc: running on device device: " << deviceProps.name << std::endl; + std::cout << "#osc: running on device: " << deviceProps.name << std::endl; CUresult cuRes = cuCtxGetCurrent(&cudaContext); if( cuRes != CUDA_SUCCESS ) @@ -317,8 +317,8 @@ namespace osc { /*! creates the module that contains all the programs we are going - to use. in this simple example, we use a single module from a - single .cu file, using a single embedded ptx string */ + to use. in this simple example, we use a single module from a + single .cu file, using a single embedded ptx string */ void SampleRenderer::createModule() { moduleCompileOptions.maxRegisterCount = 100; @@ -353,7 +353,7 @@ namespace osc { - /*! does all setup for the raygen program(s) we are going to use */ + /*! does all setup for the raygen program(s) we are going to use */ void SampleRenderer::createRaygenPrograms() { // we do a single ray gen program in this example: @@ -378,7 +378,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the miss program(s) we are going to use */ + /*! does all setup for the miss program(s) we are going to use */ void SampleRenderer::createMissPrograms() { // we do a single ray gen program in this example: @@ -403,7 +403,7 @@ namespace osc { if (sizeof_log > 1) PRINT(log); } - /*! does all setup for the hitgroup program(s) we are going to use */ + /*! does all setup for the hitgroup program(s) we are going to use */ void SampleRenderer::createHitgroupPrograms() { // for this simple example, we set up a single hit group @@ -449,7 +449,7 @@ namespace osc { &pipelineCompileOptions, &pipelineLinkOptions, programGroups.data(), - (int)programGroups.size(), + (int)programGroups.size(), log,&sizeof_log, &pipeline )); @@ -507,10 +507,6 @@ namespace osc { // ------------------------------------------------------------------ // build hitgroup records // ------------------------------------------------------------------ - - // we don't actually have any objects in this example, but let's - // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) int numObjects = (int)meshes.size(); std::vector hitgroupRecords; for (int meshID=0;meshID &meshes); @@ -78,7 +78,7 @@ namespace osc { // internal helper functions // ------------------------------------------------------------------ - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void initOptix(); /*! creates and configures a optix device context (in this simple diff --git a/example06_multipleObjects/devicePrograms.cu b/example06_multipleObjects/devicePrograms.cu index fd23aa2..ff48c6f 100644 --- a/example06_multipleObjects/devicePrograms.cu +++ b/example06_multipleObjects/devicePrograms.cu @@ -79,7 +79,6 @@ namespace osc { const vec3f rayDir = optixGetWorldRayDirection(); const float cosDN = 0.2f + .8f*fabsf(dot(rayDir,Ng)); - vec3f &prd = *(vec3f*)getPRD(); prd = cosDN * sbtData.color; } @@ -154,7 +153,7 @@ namespace osc { // to make stb_image_write happy ... const uint32_t rgba = 0xff000000 | (r<<0) | (g<<8) | (b<<16); - + // and write to frame buffer ... const uint32_t fbIndex = ix+iy*optixLaunchParams.frame.size.x; optixLaunchParams.frame.colorBuffer[fbIndex] = rgba; diff --git a/example06_multipleObjects/main.cpp b/example06_multipleObjects/main.cpp index c762e4a..870bff1 100644 --- a/example06_multipleObjects/main.cpp +++ b/example06_multipleObjects/main.cpp @@ -101,8 +101,8 @@ namespace osc { pixels.resize(newSize.x*newSize.y); } - GLuint fbTexture {0}; vec2i fbSize; + GLuint fbTexture {0}; SampleRenderer sample; std::vector pixels; }; diff --git a/example07_firstRealModel/SampleRenderer.cpp b/example07_firstRealModel/SampleRenderer.cpp index 2656945..8188ae9 100644 --- a/example07_firstRealModel/SampleRenderer.cpp +++ b/example07_firstRealModel/SampleRenderer.cpp @@ -49,7 +49,7 @@ namespace osc { }; - /*! constructor - performs asll setup, inlucuding initializing + /*! constructor - performs all setup, including initializing optix, creates module, pipeline, programs, SBT, etc. */ SampleRenderer::SampleRenderer(const Model *model) : model(model) @@ -221,7 +221,7 @@ namespace osc { return asHandle; } - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void SampleRenderer::initOptix() { std::cout << "#osc: initializing optix..." << std::endl; @@ -263,7 +263,7 @@ namespace osc { CUDA_CHECK(StreamCreate(&stream)); cudaGetDeviceProperties(&deviceProps, deviceID); - std::cout << "#osc: running on device device: " << deviceProps.name << std::endl; + std::cout << "#osc: running on device: " << deviceProps.name << std::endl; CUresult cuRes = cuCtxGetCurrent(&cudaContext); if( cuRes != CUDA_SUCCESS ) @@ -467,10 +467,6 @@ namespace osc { // ------------------------------------------------------------------ // build hitgroup records // ------------------------------------------------------------------ - - // we don't actually have any objects in this example, but let's - // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) int numObjects = (int)model->meshes.size(); std::vector hitgroupRecords; for (int meshID=0;meshID(); prd = cosDN * sbtData.color; } @@ -154,7 +153,7 @@ namespace osc { // to make stb_image_write happy ... const uint32_t rgba = 0xff000000 | (r<<0) | (g<<8) | (b<<16); - + // and write to frame buffer ... const uint32_t fbIndex = ix+iy*optixLaunchParams.frame.size.x; optixLaunchParams.frame.colorBuffer[fbIndex] = rgba; diff --git a/example07_firstRealModel/main.cpp b/example07_firstRealModel/main.cpp index a906f0e..96d0f25 100644 --- a/example07_firstRealModel/main.cpp +++ b/example07_firstRealModel/main.cpp @@ -101,8 +101,8 @@ namespace osc { pixels.resize(newSize.x*newSize.y); } - GLuint fbTexture {0}; vec2i fbSize; + GLuint fbTexture {0}; SampleRenderer sample; std::vector pixels; }; diff --git a/example08_addingTextures/SampleRenderer.cpp b/example08_addingTextures/SampleRenderer.cpp index a3ea93e..657ff75 100644 --- a/example08_addingTextures/SampleRenderer.cpp +++ b/example08_addingTextures/SampleRenderer.cpp @@ -49,7 +49,7 @@ namespace osc { }; - /*! constructor - performs asll setup, inlucuding initializing + /*! constructor - performs all setup, including initializing optix, creates module, pipeline, programs, SBT, etc. */ SampleRenderer::SampleRenderer(const Model *model) : model(model) @@ -281,7 +281,7 @@ namespace osc { return asHandle; } - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void SampleRenderer::initOptix() { std::cout << "#osc: initializing optix..." << std::endl; @@ -323,7 +323,7 @@ namespace osc { CUDA_CHECK(StreamCreate(&stream)); cudaGetDeviceProperties(&deviceProps, deviceID); - std::cout << "#osc: running on device device: " << deviceProps.name << std::endl; + std::cout << "#osc: running on device: " << deviceProps.name << std::endl; CUresult cuRes = cuCtxGetCurrent(&cudaContext); if( cuRes != CUDA_SUCCESS ) @@ -527,10 +527,6 @@ namespace osc { // ------------------------------------------------------------------ // build hitgroup records // ------------------------------------------------------------------ - - // we don't actually have any objects in this example, but let's - // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) int numObjects = (int)model->meshes.size(); std::vector hitgroupRecords; for (int meshID=0;meshID(); prd = cosDN * diffuseColor; - } extern "C" __global__ void __anyhit__radiance() @@ -191,7 +189,7 @@ namespace osc { // to make stb_image_write happy ... const uint32_t rgba = 0xff000000 | (r<<0) | (g<<8) | (b<<16); - + // and write to frame buffer ... const uint32_t fbIndex = ix+iy*optixLaunchParams.frame.size.x; optixLaunchParams.frame.colorBuffer[fbIndex] = rgba; diff --git a/example08_addingTextures/main.cpp b/example08_addingTextures/main.cpp index 9ae6c7a..96d0f25 100644 --- a/example08_addingTextures/main.cpp +++ b/example08_addingTextures/main.cpp @@ -101,8 +101,8 @@ namespace osc { pixels.resize(newSize.x*newSize.y); } - GLuint fbTexture {0}; vec2i fbSize; + GLuint fbTexture {0}; SampleRenderer sample; std::vector pixels; }; @@ -138,8 +138,8 @@ namespace osc { } catch (std::runtime_error e) { std::cout << GDT_TERMINAL_RED << "FATAL ERROR: " << e.what() << GDT_TERMINAL_DEFAULT << std::endl; - std::cout << "Did you forget to copy sponza.obj and sponza.mtl into your optix7course/models directory?" << std::endl; - exit(1); + std::cout << "Did you forget to copy sponza.obj and sponza.mtl into your optix7course/models directory?" << std::endl; + exit(1); } return 0; } diff --git a/example09_shadowRays/SampleRenderer.cpp b/example09_shadowRays/SampleRenderer.cpp index 42d1bc7..6c85d7f 100644 --- a/example09_shadowRays/SampleRenderer.cpp +++ b/example09_shadowRays/SampleRenderer.cpp @@ -50,7 +50,7 @@ namespace osc { }; - /*! constructor - performs asll setup, inlucuding initializing + /*! constructor - performs all setup, including initializing optix, creates module, pipeline, programs, SBT, etc. */ SampleRenderer::SampleRenderer(const Model *model) : model(model) @@ -282,7 +282,7 @@ namespace osc { return asHandle; } - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void SampleRenderer::initOptix() { std::cout << "#osc: initializing optix..." << std::endl; @@ -324,7 +324,7 @@ namespace osc { CUDA_CHECK(StreamCreate(&stream)); cudaGetDeviceProperties(&deviceProps, deviceID); - std::cout << "#osc: running on device device: " << deviceProps.name << std::endl; + std::cout << "#osc: running on device: " << deviceProps.name << std::endl; CUresult cuRes = cuCtxGetCurrent(&cudaContext); if( cuRes != CUDA_SUCCESS ) @@ -566,10 +566,6 @@ namespace osc { // ------------------------------------------------------------------ // build hitgroup records // ------------------------------------------------------------------ - - // we don't actually have any objects in this example, but let's - // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) int numObjects = (int)model->meshes.size(); std::vector hitgroupRecords; for (int meshID=0;meshID pixels; }; @@ -124,7 +124,6 @@ namespace osc { "../models/sponza.obj" #endif ); - Camera camera = { /*from*/vec3f(-1293.07f, 154.681f, -0.7304f), /* at */model->bounds.center()-vec3f(0,400,0), /* up */vec3f(0.f,1.f,0.f) }; diff --git a/example10_softShadows/SampleRenderer.cpp b/example10_softShadows/SampleRenderer.cpp index a69d69b..18ca914 100644 --- a/example10_softShadows/SampleRenderer.cpp +++ b/example10_softShadows/SampleRenderer.cpp @@ -50,7 +50,7 @@ namespace osc { }; - /*! constructor - performs asll setup, inlucuding initializing + /*! constructor - performs all setup, including initializing optix, creates module, pipeline, programs, SBT, etc. */ SampleRenderer::SampleRenderer(const Model *model, const QuadLight &light) : model(model) @@ -287,7 +287,7 @@ namespace osc { return asHandle; } - /*! helper function that initializes optix, and checks for errors */ + /*! helper function that initializes optix and checks for errors */ void SampleRenderer::initOptix() { std::cout << "#osc: initializing optix..." << std::endl; @@ -329,7 +329,7 @@ namespace osc { CUDA_CHECK(StreamCreate(&stream)); cudaGetDeviceProperties(&deviceProps, deviceID); - std::cout << "#osc: running on device device: " << deviceProps.name << std::endl; + std::cout << "#osc: running on device: " << deviceProps.name << std::endl; CUresult cuRes = cuCtxGetCurrent(&cudaContext); if( cuRes != CUDA_SUCCESS ) @@ -571,10 +571,6 @@ namespace osc { // ------------------------------------------------------------------ // build hitgroup records // ------------------------------------------------------------------ - - // we don't actually have any objects in this example, but let's - // create a dummy one so the SBT doesn't have any null pointers - // (which the sanity checks in compilation would compain about) int numObjects = (int)model->meshes.size(); std::vector hitgroupRecords; for (int meshID=0;meshID pixels; }; @@ -125,7 +125,6 @@ namespace osc { "../models/sponza.obj" #endif ); - Camera camera = { /*from*/vec3f(-1293.07f, 154.681f, -0.7304f), /* at */model->bounds.center()-vec3f(0,400,0), /* up */vec3f(0.f,1.f,0.f) };