Reflection does not work properly

hi folks,
I try to reflect rays from closest hit point.It reflects but there is an error. Some points on objects has the color of the exception program bad color(red dots). How can i fix this?

Enable exceptions, provide an exception program which prints the exception code, and check if you have a stack overflow error.
If yes, raise the stack size with rtContextSetStackSize(size), resp. m_context->setStackSize(size) if you use the C++ wrappers, until the error goes away.

Example code which shows how to do that can be found in this post:
https://devtalk.nvidia.com/default/topic/936762/?comment=4882450

Thanks Detlef. What does rtThrow do when exceptions are not enabled?

Good question. I actually needed to look that up. ;-)
I expected it does nothing in this case because none of the exception handling is compiled into the megakernel, and the OptiX API reference confirms that and it’s actually more fine grained, limited to the user exceptions flag only:
“Calls to rtThrow will be silently ignored unless user exceptions are enabled using rtContextSetExceptionEnabled.”

I’m using rtThrow in my “rtAssert” implementation but switch exceptions and that code on and off together with a define for performance reasons. I do not benchmark with exceptions enabled.

// RT_FUNCTION is #define RT_FUNCTION __forceinline__ __device__

#if USE_DEBUG_EXCEPTIONS

RT_FUNCTION void rtAssert(const bool condition, const unsigned int code)
{
  if (!condition)
  {
    rtThrow(RT_EXCEPTION_USER + code);
  }
}

#else 

#define rtAssert(condition, code)

#endif