OptiX 7.2 Long shadows

Good morning,

Sorry if this is a dumb question, but I am looking into shadows using OptiX 7.2 and thanks to some great help from everyone here on the forum I have been very successful generating a simple shadowing technique using a kind of visibility test. However, I would like to know how to implement something like “long shadows” from a single light source (out of view). I think this will be executed with shadow rays, but am unsure.

Is there some example code using this concept, just a simple cube/sphere/etc. whereby a long shadow is generated?

I apologize in advance if this is a redundant question.


Hey @picard1969,

What does “long shadow” mean? What problem are you anticipating that is different from the shadows you have now?

In general, your shadow rays should work regardless of the orientation of your geometry and light. If you’re worried about very narrow grazing angles and/or shadow-ray self-intersection, this article might be of interest to you: A Fast and Robust Method for Avoiding Self-Intersection, by Carsten Wächter and Nikolaus Binder, from Ray Tracing Gems Ray Tracing Gems


Thank you @dhart for the reply. I apologize for not getting back sooner, I have been on a mini-vacation, i.e., long weekend.

Maybe a sample image of what I am looking for could explain better (please see “long_shadows.png”). I am guess this is constructed using something along the lines of a shadow ray, but am not 100% certain.

Any hints/help would be greatly appreciated.


Hey @picard1969,

I see, yes you want to add shadow rays to your app to generate these kinds of shadows.

There’s a complete working example of shadow ray setups in multiple OptiX SDK samples. The optixPathTracer sample is setup almost like the image you posted; it has a quad shaped area light source that casts shadows on the floor. The sample also includes indirect bounce lighting, which you can disable if you change the maximum depth to 0 in the raygen program in optixPathTracer.cu:

if( prd.done  || prd.depth >= 0 ) // TODO RR, variable for depth

Wherever you see the word “occlusion” in optixPathTracer, that’s referring to shadow rays. Note there are special hit & miss programs for the shadow rays, because they do something different from the primary camera (“radiance”) rays.

Take a tour through that code, learn how it works, play with it a little (turn off the shadows, change the shadow color, etc.) and let us know if you have any questions about it.


Hi @dhart,

Thank you for the response and the helpful information. I will give the code a look and see how it goes.

Also, I found this: optix7course/example09_shadowRays at master · ingowald/optix7course · GitHub which looks like it has shadow rays as well.

Please also have a look at the new examples I just added to the OptiX 7 Advanced Samples showing how to implement different light types.

These allow placing different singular and area lights into a scene and it would be simple to mimic the above screenshot with some runtime generated or loaded objects and a single rectangle area light.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.