Giter Site home page Giter Site logo

shocker-0x15 / optix_utility Goto Github PK

View Code? Open in Web Editor NEW
98.0 3.0 8.0 22.82 MB

OptiX 8 Lightweight Wrapper Library

License: Other

C++ 95.63% Python 1.11% CMake 2.83% Cuda 0.42%
rtx optix raytracing cuda gpu graphics rendering visualization frameworks utilities

optix_utility's Introduction

OptiX Utility

example

OptiXはOptiX 7以降Direct X Raytracing (DXR)にそっくりなローレベル指向なAPIになりました。細かいところに制御が効く一方で、何をするにも煩雑なセットアップコードを書く必要が出てきました。このOptiX Utilityは細かい制御性はできる限り保持したまま定形処理になりがちな部分を隠蔽したクラス・関数を提供することを目的としています。

OptiX changes its form since OptiX 7 into a low-level oriented API similar to Direct X Raytracing (DXR). It provides fine-level controllability but requires the user to write troublesome setup code to do anything. The purpose of this OptiX Utility is to provide classes and functions which encapsulate parts that tend to be boilerplate code while keeping fine controllability.

組込方法 / Integration

OptiX Utilityを使うプログラムに以下を追加します。
Add the followings to your program which uses OptiX Utility:

  • optix_util.h
  • optix_util_private.h
  • optix_util.cpp

オプションとして、プログラムがCUDAのメモリ確保などを実装していない場合は cuda_util.h, cuda_util.cpp と optixu_on_cudau.h も追加します。CUDA UtilityにOpenGL連携機能が必要ない場合はコンパイルオプションとしてCUDA_UTIL_DONT_USE_GL_INTEROPを定義してください。
Optionally add cuda_util.h, cuda_util.cpp and optixu_on_cudau.h as well if the program doesn't have functionalities like memory allocation for CUDA. Define CUDA_UTIL_DONT_USE_GL_INTEROP as a compile option when you don't need OpenGL interoperability in CUDA Utility.

機能 / Features

Currently based on OptiX 8.0.0

  • Traversable types
    • Single GAS
    • Single-level instancing
    • Multi-level instancing
  • Primitive types
    • Triangles
    • Curves
      • 1st order: Round linear segments
      • 2nd order: Round quadratic B-splines, Ribbons (Flat quadratic B-splines)
      • 3rd order: Round cubic B-splines, Round Catmull-Rom splines, Round cubic Bézier curves
    • Spheres
    • User-defined custom primitives
  • Opacity micro-map (OMM)
  • Displacement micro-map (DMM)
  • Motion blur types
    • Instance motion blur
    • Deformation blur
  • Acceleration structure management
    • Full build
    • Fast update
    • Compaction
  • Shader binding table management
    • Automatic build
    • Memory management is still under user control
  • Geometry instancing with different material sets
  • Callable programs
  • OptiX-IR support for better debugging
    * but fow now (8.0.0 and the 546.17 diver), OptiX-IR itself causes some weird behavior, so using traditional ptx input is recommended until we get the update...
  • OptiX AI denoiser
    • LDR (Not Tested)
    • HDR
    • HDR with Kernel Prediction Model (AOV Output Not Tested)
    • HDR Upscaling 2x (AOV Output Not Tested)
    • HDR Temporal
    • HDR Temporal with Kernel Prediction Model (AOV Output Not Tested)
    • HDR Temporal + Upscaling 2x (AOV Output Not Tested)
  • Automatic payload/attribute packing/unpacking in kernel code
    • supports hit objects as well for shader execution reordering (SER)
  • Payload usage annotation to reduce register consumption in complex pipelines

TODO

  • Support SBT offset summation accross all instances in the traversal graph
  • Test NVRTC compilation.
  • Test flow vector trustworthiness guiding
  • Test AOV denoisers
  • Test Linux environment
  • Parallel module compilation
  • AS relocation
  • OMM relocation
  • Multi-GPU

構成要素 / Components

  • optix_util.h, optix_util_private.h, optix_util.cpp
    OptiXのオブジェクトをホスト側で管理するためのAPIと、デバイス側の関数ラッパーを提供しています。
    This provides API to manage OptiX objects on host-side and device-side function wrappers.
  • cuda_util.h, cuda_util.cpp
    このCUDAユーティリティはCUDAのbufferやarrayの生成、そしてカーネルの実行のためのクラス・関数を提供しています。
    現在のOptiXはCUDAに基づいたAPIになっているため、ユーザーはOptiXのコードと併せて頻繁に純粋なCUDAのコードも扱う必要があります。
    これにはOptiX関連のコードは含まれず、OptiX Utilityとも直接関係しません。
    This CUDA Utility provides classes and functions for CUDA buffer, array creation, and kernel execution. OptiX is now CUDA-centric API, so the user often needs to manage pure CUDA code along with OptiX code.
    This doesn't contain any OptiX-related code and is not directly related to the OptiX Utility.
  • optixu_on_cudau.h
    OptiX UtilityをCUDA Utilityと組み合わせて使うための関数といくつかの補助クラスを定義した取るに足らないファイルです。
    This trivial file defines a function to use OptiX Utility combined with the CUDA Utility and defines several auxiliary classes.
  • samples
    OptiX Utilityの基本的な使い方を網羅した複数のサンプルがあります。
    Multiple samples cover basic usage of the OptiX Utility.

コード例 / Code example

ホスト側 / Host-side

OptiX UtilityはシェーダーバインディングテーブルのセットアップといったOptiXカーネルを実行するまでに必要な面倒な手続きを可能な限り隠蔽します。

OptiX utility hides troublesome procedures like setting up shader binding table required to execute OptiX kernels as much as possible.

// Create an OptiX context from a CUDA context (Driver API).
optixu::Context optixContext = optixu::Context::create(cuContext);

// Create a pipeline and associated programs (groups) then link the pipeline.
optixu::Pipeline pipeline = optixContext.createPipeline();
pipeline.setPipelineOptions(
    optixu::calcSumDwords<PayloadSignature>(),
    optixu::calcSumDwords<AttributeSignature>(),
    "plp", sizeof(PipelineLaunchParameters),
    OPTIX_TRAVERSABLE_GRAPH_FLAG_ALLOW_ANY,
    OPTIX_EXCEPTION_FLAG_STACK_OVERFLOW | OPTIX_EXCEPTION_FLAG_TRACE_DEPTH,
    OPTIX_PRIMITIVE_TYPE_FLAGS_TRIANGLE);
optixu::Module mainModule =
    pipeline.createModuleFromPTXString(
        ptx, OPTIX_COMPILE_DEFAULT_MAX_REGISTER_COUNT,
        OPTIX_COMPILE_OPTIMIZATION_DEFAULT, OPTIX_COMPILE_DEBUG_LEVEL_LINEINFO);
optixu::Program rayGenProgram = pipeline.createRayGenProgram(module, RT_RG_NAME_STR("pathtracing"));
// ...
optixu::HitProgramGroup searchRayHitProgramGroup =
    pipeline.createHitProgramGroupForTriangleIS(
        mainModule, RT_CH_NAME_STR("shading"), emptyModule, nullptr);
optixu::HitProgramGroup visibilityRayHitProgramGroup =
    pipeline.createHitProgramGroupForTriangleIS(
        emptyModule, nullptr, mainModule, RT_AH_NAME_STR("visibility"));
// ...
pipeline.link(2);

// Allocate a shader binding table (scene independent part).
cudau::Buffer sbt;
size_t sbtSize;
scene.generateShaderBindingTableLayout(&sbtSize);
//...
pipeline.setShaderBindingTable(sbt, sbt.getMappedPointer());

// Create materials.
optixu::Material defaultMat = optixContext.createMaterial();
defaultMat.setHitGroup(RayType::Search, searchRayHitProgramGroup);
defaultMat.setHitGroup(RayType::Visibility, visibilityRayHitProgramGroup);
// ...
defaultMat.setUserData(...);

// Create a scene.
optixu::Scene scene = optixContext.createScene();

// Create geometry instances (triangles or curves or user-defined custom primitives).
optixu::GeometryInstance geomInst0 = scene.createGeometryInstance();
cudau::TypedBuffer<Vertex> vertexBuffer;
cudau::TypedBuffer<Triangle> triangleBuffer;
// ...
geomInst0.setVertexBuffer(vertexBuffer);
geomInst0.setTriangleBuffer(triangleBuffer);
geomInst0.setUserData(...);
geomInst0.setNumMaterials(1, BufferView());
geomInst0.setGeometryFlags(0, OPTIX_GEOMETRY_FLAG_NONE);
geomInst0.setMaterial(0, 0, defaultMat);

OptixAccelBufferSizes asMemReqs;

// Create geometry acceleration structures.
optixu::GeometryAccelerationStructure gas0 = scene.createGeometryAccelerationStructure();
gas0.setConfiguration(
    optixu::ASTradeoff::PreferFastTrace,
    optixu::AllowUpdate::Yes, optixu::AllowCompaction::Yes); // Builder preference.
gas0.addChild(geomInst0);
gas0.addChild(geomInst1);
gas0.addChild(...);
gas0.setUserData(...);
optixu::GeometryAccelerationStructure gas1 = scene.createGeometryAccelerationStructure();
// ...
cudau::Buffer gas0Mem;
gas0.prepareForBuild(&asMemReqs);

// Create instances.
optixu::Instance inst0 = scene.createInstance();
inst0.setChild(gas0);
inst0.setTransform(...);
optixu::Instance inst1 = scene.createInstance();
// ...

// Create instance acceleration structures.
optixu::InstanceAccelerationStructure ias0 = scene.createInstanceAccelerationStructure();
ias0.setConfiguration(
    optixu::ASTradeoff::PreferFastBuild,
    optixu::AllowUpdate::Yes, optixu::AllowCompaction::Yes); // Builder preference.
ias0.addChild(inst0);
ias0.addChild(inst1);
ias0.addChild(...);
optixu::InstanceAccelerationStructure ias1 = scene.createInstanceAccelerationStructure();
// ...
cudau::TypedBuffer<OptixInstance> instBuffer;
cudau::Buffer ias0Mem;
ias0.prepareForBuild(&asMemReqs);

// Build acceleration structures.
cudau::Buffer asBuildScratchMem;
// ...
OptixTraversableHandle gas0Handle = gas0.rebuild(cuStream, gas0Mem, asBuildScratchMem);
// ...
OptixTraversableHandle ias0Handle = ias0.rebuild(cuStream, instBuffer, ias0Mem, asBuildScratchMem);

// Allocate a shader binding table (scene dependent part).
cudau::Buffer hitGroupSbt;
size_t hitGroupSbtSize;
scene.generateShaderBindingTableLayout(&hitGroupSbtSize);
// ...

// Associate the pipeline and the scene/shader binding table.
pipeline.setScene(scene);
pipeline.setHitGroupShaderBindingTable(hitGroupSbt, hitGroupSbt.getMappedPointer());

// Setup pipeline launch parameters and allocate memory for it on the device.
PipelineLaunchParameter plp;
// ...
CUdeviceptr plpOnDevice;
cuMemAlloc(&plpOnDevice, sizeof(plp));

// Launch the pipeline!
cuMemcpyHtoDAsync(plpOnDevice, &plp, sizeof(plp), cuStream);
pipeline.launch(cuStream, plpOnDevice, width, height, 1);
//...

デバイス側 / Device-side

OptiX Utilityはペイロードのパッキングを簡単にしたりカーネル間通信における型の不一致を回避するため、デバイス側の組み込み関数のラッパーを提供しています。

OptiX utility provides template wrappers for device-side built-in functions to ease packing of payloads and to avoid type inconsistency for inter-kernel communications.

// Define payload signatures.
using SearchRayPayloadSignature = optixu::PayloadSignature<PCG32RNG, ExtraPayload*>;
using VisibilityRayPayloadSignature = optixu::PayloadSignature<float>;
// ...
CUDA_DEVICE_KERNEL void RT_RG_NAME(pathtracing)() {
    // ...
    ExtraPayload* exPayloadPtr = &exPayload;
    while (true) {
        // ...
        SearchRayPayloadSignature::trace(
            traversable, origin, direction,
            0.0f, FLT_MAX, 0.0f, 0xFF, OPTIX_RAY_FLAG_NONE,
            RayType_Search, NumRayTypes, RayType_Search,
            rng, exPayloadPtr);
        // ...
    }
    // ...
}
// ...
CUDA_DEVICE_KERNEL void RT_CH_NAME(shading)() {
    auto sbtr = reinterpret_cast<HitGroupSBTRecordData*>(optixGetSbtDataPointer());
    // ...
    PCG32RNG rng;
    ExtraPayload* exPayloadPtr;
    SearchRayPayloadSignature::get(&rng, &exPayloadPtr);
    // ...
    {
        // ...
        float visibility = 1.0f;
        VisibilityRayPayloadSignature::trace(
            traversable, p, shadowRayDir, 0.0f, dist * 0.999f, 0.0f, 0xFF, OPTIX_RAY_FLAG_NONE,
            RayType_Visibility, NumRayTypes, RayType_Visibility,
            visibility);
        // ...
    }
    // ...
    SearchRayPayloadSignature::set(&rng, nullptr);
}
// ...
CUDA_DEVICE_KERNEL void RT_AH_NAME(visibility)() {
    float visibility = 0.0f;
    VisibilityRayPayloadSignature::set(&visibility);

    optixTerminateRay();
}
// ...

動作環境 / Confirmed Environment

現状以下の環境で動作を確認しています。
I've confirmed that the programs run correctly in the following environment.

  • Windows 11 (23H2) & Visual Studio Community 2022 (17.11.0)
  • Ryzen 9 7950X, 64GB, RTX 4080 16GB
  • NVIDIA Driver 560.81

動作させるにあたっては以下のライブラリが必要です。
It requires the following libraries.

  • CUDA 12.5 Update 1 (probably works with lower CUDA versions)
    Note that CUDA (<= 12.5.0) has compilation issues for C++20 with Visual Studio 2022 17.10.
    Use CUDA 12.5 Update 1 or newer for C++20.
  • OptiX 8.0.0 (requires Maxwell or later generation NVIDIA GPU)

ライセンス / License

Released under the Apache License, Version 2.0 (See LICENSE.md)


2024 @Shocker_0x15, @bsky.rayspace.xyz

optix_utility's People

Contributors

hurleyworks avatar shin-watanabe avatar shocker-0x15 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

optix_utility's Issues

Picking problem

I suspect that this might be my error or a bug in Optix7 so feel free to just close this if you don't have time or interest in looking at it. :)

When I create a scene with multiple geometry instances, picking will occasionally fail by picking the incorrect instance. Here's a screen grab of what I'm doing and the debug output. All I'm doing is clicking on the same pixel multiple times until the wrong instance is picked. The error is very intermittent but will always occur if I keep picking long enough.

I made an simplified version of my project here if you have the time to look at it. No worries if you don't have time
https://github.com/Hurleyworks/Ketone

The output between the #### lines is from the kernel to make sure the picking ray is the same every time

59.689542       DEBUG [27224 PathTracer.cpp->PathTracer::pick:131]      20,  72025::HellBoy_instance_19
59.822032       DEBUG [27224 SceneHandler.cpp->SceneHandler::updateState:79]    SceneHandler::updateState
60.620206       DEBUG [27224 PathTracer.h->PathTracer::generatePickRay:24]      Picking at: 863, 244
############################################
Pick origin
 2.000000 3.000000 -4.000000
Pick direction
 -0.728819 -0.368924 0.576817
############################################
60.623296       DEBUG [27224 PathTracer.cpp->PathTracer::pick:131]      20,  72025::HellBoy_instance_19
60.757620       DEBUG [27224 SceneHandler.cpp->SceneHandler::updateState:79]    SceneHandler::updateState
61.422434       DEBUG [27224 PathTracer.h->PathTracer::generatePickRay:24]      Picking at: 863, 244
############################################
Pick origin
 2.000000 3.000000 -4.000000
Pick direction
 -0.728819 -0.368924 0.576817
############################################
61.425515       DEBUG [27224 PathTracer.cpp->PathTracer::pick:131]      39,  92857::HellBoy_instance_38  WRONG!!!!!

picking_bug

Compiling on Linux

You probably don't support Linux (gcc/clang). Here are some errors (related to std library) while compiling with gcc 12.1:

optix_util.h(423): error: namespace "std" has no member "tuple_element_t"
optix_util.h(471): error: namespace "std" has no member "tuple_element_t"
optix_util.h(491): error: namespace "std" has no member "tuple_element_t"
optix_util.h(601): error: namespace "std" has no member "index_sequence"
optix_util.h(614): error: namespace "std" has no member "index_sequence"
optix_util.h(621): error: namespace "std" has no member "index_sequence"

These can be fixed by including 'utility' header.

Other errors:
cuda_util.cpp:374:18: error: ‘memcpy’ is not a member of ‘std’
cuda_util.cpp:254:22: error: ‘memset’ is not a member of ‘std’
cuda_util.cpp:46:9: error: ‘va_end’ was not declared in this scope
cuda_util.cpp:45:9: error: ‘vprintf_s’ was not declared in this scope

optix_util_private.h:43:10: fatal error: intrin.h: No such file or directory

common.h:67:32: error: ambiguating new declaration of ‘void printf(const char*, ...)’

latest version does not compile

Hi again :)

The latest GitHub version does not compile because of an error on line 785 of optix_util.cpp. Looks like getName() returns a const char* instead of a std::string;

I see you have a new RTX 3080 now. I am jealous. :)

I also had a question about object replacement. I'm trying to do a fluid simulation where a new fluid mesh is constantly generated. Right now I am just creating new vertex buffers and triangle buffers and rebuilding the GAS, the hitgroupSBT and the top level IAS. Can you tell me if that's the best way to do object replacement? I am getting okay results but I'm wondering if performance can be improved.
https://www.youtube.com/watch?v=dXsj5O6w0no&ab_channel=HurleyworksInc

  OptixVertices newVertices;
    uint32_t vertexCount = addVertices (newMesh, newVertices);
   
    OptixTriangles newTriangles;
    uint32_t triangleCount = addAllTriangles (newMesh, newTriangles);

    uint32_t geoGroupID = node->getClientID();
    GeometryGroupRef& geomGroup = state->geomGroups.at (geoGroupID);

    VertexBufferRef vertexBuffer = make_shared_with_deleter<cudau::TypedBuffer<Shared::Vertex>> (
        [] (cudau::TypedBuffer<Shared::Vertex>* p) {
            p->finalize();
        });
    vertexBuffer->initialize (state->cuContext, g_bufferType, newVertices);

    GeometryInstanceRef& geoInst = geomGroup->geomInsts[0];
    geoInst->vertexBuffer->finalize();
    geoInst->vertexBuffer = vertexBuffer;

    geoInst->triangleBuffer.finalize();
    geoInst->triangleBuffer.initialize (state->cuContext, g_bufferType, newTriangles, state->cuStream);

    geoInst->optixGeomInst.setVertexBuffer (*vertexBuffer);
    geoInst->optixGeomInst.setTriangleBuffer (geoInst->triangleBuffer);

    Shared::GeometryData geomData = {};
    geomData.vertexBuffer = vertexBuffer->getDevicePointer();
    geomData.triangleBuffer = geoInst->triangleBuffer.getDevicePointer();
    geoInst->optixGeomInst.setUserData (geomData);

    geomGroup->optixGAS.markDirty();

Start from empty scene

Hello,

Thanks for making this project. It seems really well designed!

I would like to use it in my projects. Can you tell me what License you will use?

My projects are interactive content creation like in this video https://youtu.be/o2Y-f_frc5c

So I would like to start just rendering the background without any geometry and then let the user add geometry interactively. Is this possible in OpitX7_Utility? If so, could you please tell me how to do it?

Thanks!

crash when /sdl compile option is disabled in Visual Studio 2019 (16.6.4)

The /sdl option is disabled by default in Visual Studio 2019 (16.6.4)
https://docs.microsoft.com/en-us/cpp/build/reference/sdl-enable-additional-security-checks?view=vs-2019

OptiX7_Utility programs will crash unless the /sdl compiler option is enabled. This is easily tested by disabling it in any of the sample projects. If there is no fix for the cause of crashing it would be a good idea to mention that the /sdl option needs to be enabled in the project README file so that users can understand why the own projects using Optix7_Utility are crashing.

Windows 10 Home
i7-9700k CPU @ 3.60GHz
GeForce RTX 2070 SUPER
CUDA 11.0
Optix 7.1.0

Can't compile CallableProgramGroup

Howdy, hope all is well!

I have been stuck on a strange problem for a while. When I compile a kernel with a direct callable program, the ptx output does not contain the program so the call to pipeline.createCallableProgramGroup() fails.

[ 2][COMPILE FEEDBACK]: COMPILE ERROR: "__direct_callable__testCall" not found in programDescriptions[0].callables.moduleDC

Here's the kernel code, the output ptx code and the pipeline creation function. This barebones example compile and runs fine if I remove the callable program

https://gist.github.com/Hurleyworks/6573dd5ebb9ccf306e1184a9d5e30154

Do you have an idea what I'm doing wrong. Everything works as expected in the uber sample so it has to be something I'm doing wrong somewhere.

Thanks again for making the project. I'm really enjoying using it ... it makes life so much easier :)
https://www.youtube.com/watch?v=MPXU3avzv_s&ab_channel=HurleyworksInc

unchecked pointers in Instance::Priv::fillInstance(OptixInstance* instance)

I managed a rare crash in OptiX_Utility by forgetting to properly set the GAS for an instance. Starting at line 1459 of optix_util.cpp it looks all the child pointers are not checked before they are used. In my case std::get<_GeometryAccelerationStructure*>(child) returns nullptr so gas->isReady() crashed the app.

 auto gas = std::get<_GeometryAccelerationStructure*>(child);
 throwRuntimeError(gas->isReady(), "GAS %s is not ready.", gas->getName().c_str()

Cmake errors in latest version

Greetings!

I have OptiX SDK 8.0.0 installed in the default location but when I try to create the OptiXUtility solution using the Cmake Gui, I get these errors. I am a Premake user so I am not sure how to change Cmake to work out of the box.

=======================================================
CMake Warning at CMakeLists.txt:18 (find_package):
By not providing "FindOptiX80.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "OptiX80", but
CMake did not find one.

Could not find a package configuration file provided by "OptiX80" with any
of the following names:

OptiX80Config.cmake
optix80-config.cmake

Add the installation prefix of "OptiX80" to CMAKE_PREFIX_PATH or set
"OptiX80_DIR" to a directory containing one of the above files. If
"OptiX80" provides a separate development package or SDK, be sure it has
been installed.

CMake Error at CMakeLists.txt:25 (message):
OptiX SDK 8.0.0 not found.

Rendering error with GAS made with multiple GeometryInstances in 02.scene_edit sample

This rendering error only occurs if the 6surf_box.OBJ is loaded after another object has been loaded into the scene. If you start with an empty scene and create an IAS for the 6surf_box.OBJ then it will render as expected.

Steps to reproduce:

  1. load 6surf_box.OBJ and create an IAS for it . Note that it renders correctly.
  2. close the application and start again
  3. load the subd_cube.OBJ and create an IAS for it and note that renders correctly.
  4. load 6surf_box.OBJ and create an IAS for it . Note the render errors ( all black )

test_obj.zip

Assimp not working in scene_edit sample

Hi,

I've compiled OptiX_Utility using cmake. There seems to be a problem when trying to load any .OBJ file using Assimp in the scene_edit sample . Assimp fails with this message:

ai_assert failure in D:\ActiveWorks\OpenSource\rendering\OptiX_Utility\ext\assimp\code\Common\Importer.cpp(812): _ValidateFlags(pFlags)

updating generateShaderBindingTableLayout() after interactively removing an instance

Hello again!

My project is mostly based on the scene_edit sample. When the user interactively removes an instance from the scene. I believe that I need to call optixu::Scene::generateShaderBindingTableLayout() again because a GAS has been removed. Is that correct? If so, there doesn't appear to be a way to reset the boolean variable sbtLayoutIsUpToDate from the client side. There is a markSBTLayoutDirty() function in optixu::Scene::Priv but it is not exposed. I can see the markSBTLayoutDirty() is called when a GAS is marked dirty but in my case I am removing it, not updating it. My workaround at the moment is:

optixu::Scene::generateShaderBindingTableLayout(size_t* memorySize, bool forceUpdate = false);

which lets me set the m->sbtLayoutIsUpToDate to false so the layout is recomputed.

Using multiple material sets

"Each GeometryInstance can set a material with two indices, matSetIdx and matIdx, so you can set multiple materials with the same matIdx. Then you create a GAS from the GeomInst and set the number of material sets with setNumMaterialSets(). After that you can create multiple instances with the same GAS but with different material set by specifying the second argument of Instance::setGAS()."

Sorry, I can't seem to get this to work in my project. The error I'm getting is
551, 49, 0) error: invalid hit sbt of 2 at primitive with gas sbt index 0

I want to create 2 material sets per GeometryInstance, , each with a different material and I want to render the geometry instances using the material in the second material set ( index 1 )
inst->optixInst.setChild (geomGroup->optixGAS, isInstance ? 1 : 0);

One thing I'm not clear on is what to set geomInst->optixGeomInst.setNumMaterials(). Is that the number of materials per set or the total number of materials in all sets?

Thanks for adding denoising support. I was able to add it to my project without much trouble :)
https://youtu.be/LjxuUyKH7UU

Some samples crash in Debug mode only

Greeting!

These samples crash in the latest OptiX_Utility in debug mode only. I couldn't learn anything running the NSight cuda debugger
pick
texture
material_sets
multi_level_instancing

Here's the error message
[ 2][ ERROR]: Error recording event to prevent concurrent launches on the same OptixPipeline (CUDA error string: unspecified launch failure, CUDA error code: 719)
Error recording resource event on user stream (CUDA error string: unspecified launch failure, CUDA error code: 719)

OptiX 8.0
Cuda 12.2
Geforce RTX 3090 driver 537.34 ( crashed in previous driver too )
Windows 11 Pro

minor issue in pick sample

Pipeline::hitGroupShaderBindingTable (line 323 in pick_main.cpp) is unused. Instead new cudau::Buffers for the hitGroupSBTs are created around line 897 of pick_main.cpp. No big deal of course but I thought you might want to know. :)

Compilation files

Hi,

Could you please update the Visual Studio solution file or CMake files for compiling this project ?

Thanks for sharing !

Pick sample not working

Hello!

The new Pick sample does not work on my system. The sample compiles and runs but after 2 render iterations it hits (in Debug mode) an "out of range" assert in std::vector. In Release mode the sample crashes. If I try to debug, it looks like the assert is triggered on line 1185 of pick_main.cpp because pickInfo.instanceID is an invalid number.

Optix 7.2
Cuda 11.2
RTX 2070 SUPER vs 460.89

Pick_sample_crash

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.