Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Tags in this Discussion

SceniX, OptiX and Entry Points, help!
  • Hi,

    In SceniX Viewer, I would like to have a background environment map for the OptiX renderer.

    I followed the RTFx.pdf and amended ao_ray_generation_cuda.rtfx file (a file from another SceniX sample) to test, the Miss program:


    RT_PROGRAM void path_miss_radiance()
    {
    thePrd.color = make_float4(1.0f, 0.0f, 0.0f, 1.0f);
    }


    I ran rtfxc.exe to compile the ao_ray_generation_cuda.rtfx to o_ray_generation_ptx.rtfx. Then ran bin2c to convert ao_ray_generation_ptx.rtfx to ao_ray_generation_ptx.inc

    Then guess work set in after that. I looked at the QtAmbientOcclusion sample for inspiration, that uses a variable type RTFxSceneAttributeSharedPtr to set to the RTFx program. Unfortunately SceniX Viewer has no such variable.


    How do I get SceniX to use my own compiled RTFx OptiX entry point programs in SceniX?

    Thanks for any help,
    Jules
  • 6 Comments sorted by
  • That is actually not Viewer related. You add your custom RTFx programs to the scene graph.
    Please read through the Using RTFx.pdf in the docs folder in case you haven't done that yet.

    The ray generation, miss, and exception programs are of global nature and go into the RTFxSceneAttribute of your scene.
    In QtIconTracer\src\IconScene.cpp you see how that RTFxSceneAttribute is created and then added to the scene graph with theScene->addAttribute(rtfxSceneAttribute).
    If you added your miss program to the technique block like in the QtIconTracer\src\path_ray_generation_cuda.rtfx for example, adding the RTFxSceneAttribute to the scene graph will not generate a built-in one for that ray type but use yours.
  • Hi Detlef,

    Thanks for the reply, I'm afraid I'm still not getting it working. I couldn't find in RTfx.pdf any examples on adding the RTFxSceneAttribute attribute. I looked in the QtIconTracer sample that helped. Then searched for Scene::Create in the SceniX Viewer sample; found in the PreviewScene::PreviewScene() constructor. Added this after the next line 'SceneWriteLock scene( theScene )':

    std::string rtfxPTXCode = (const char *) &ao_ray_generation[0];
    RTFxProgramSharedPtr prgRayGeneration = createRTFxProgram(rtfxPTXCode);

    RTFxSceneAttributeSharedPtr rtfxSceneAttribute = RTFxSceneAttribute::create();
    {
    RTFxSceneAttributeWriteLock rtfx(rtfxSceneAttribute);
    rtfx->setProgram(prgRayGeneration);
    }

    scene->addAttribute( rtfxSceneAttribute );

    My miss program that I compiled in an amended path_ray_generation_cuda.rtfx is as earlier in this thread, and was hoping that the SceniX Viewer would show the background as red when switching over to the OptiX renderer. Nothing happens!

    Where am I going wrong?

    Thanks for any help,
    Jules
  • Vote Up0Vote Down Detlef Roettger
    Posts: 330 Accepted Answer
    Your problem is that you're trying to change the most complex SceniX example without understanding how it works. (Changing the miss program on the preview scene isn't doing anything to the four main viewports, but to the Material Editor preview scene, which BTW you can also switch to ray tracing with the right click context menu. What you really would have to do is to change the RTFxSceneAttribute of the loaded scene.)

    Please take a step back and do the following:
    1.) Start with a smaller example.
    2.) Please use the QtMinimal example which is also able to render ray traced when starting it with the command line QtMinimal.exe --raytracing. Try that to see the difference.
    3.) Now in that example there is either a SimpleScene or a loaded scene used (--filename command to load a scene).
    4.) After the scene has been defined in that example (e.g. before the line RenderContextGLFormat format;), add your RTFxSceneAttribute with your miss program.
    Since you're using the built-in ray tracing programs for everything else in that case, you must make sure that your radiance per ray data is matching the one described inside the appendix of the Using RTFx.pdf exactly or you will get a validation failure from OptiX.
    (You might actually need to specify one for raytype 1 in that case as well which would be the shadow ray in SceniX. An empty one will do. There is some gotcha with replacing only parts of the built-in pipeline's programs and not matching the number of ray types. The QtAmbientOcclusion and QtIconTracer examples exchange everything except the intersection and bounding box programs and don't run into that.)
    5.) Run the QtMinimal --raytracing until you have your miss program running which does something different than returning the float4 clearColor.
    6.) Now go back to the SceniX Viewer and debug into the code which is executed in Menu -> File -> Load. The scene is loaded in the SceneSerializer::load() function, look for nvutil::loadScene(). That is where you might want to change your scene.
  • Thanks Detlef for all your help. Pleased to say I have it all working now!

    As you advised, I started with the QtMinimal sample. Got my understanding up to par and made the sample work with my custom Miss program. Then applied it to the SceniX Viewer and got the test result I was expecting, i.e. when switching to the OptiX renderer, the background instantly went red.

    All the best,
    Jules
  • Fine.
    Also mind, that when saving your changed scene it will contain your miss program already, so loading that NBF into the original QtMinimal should also render with your miss program.
    That also means that when saving and loading an NBF file in your modified Viewer you would exchange the already existing RTFxSceneAttribute against one with your miss programs needlessly.
    Sometimes that would not be desirable, esp. when a file comes with own custom RTFxSceneAttribute and own RTFx programs.
  • Detlef, thanks for letting me know.

    Jules