3ds Max C++ API Reference
|
Interface for the 3ds Max OSL Raytracing features, allowing OSL to use a 3rd party renderer's raytracing engine. More...
#include <MaxOSLInterface.h>
Public Types | |
enum | ReturnFlags { HitSomething = 1 } |
Bit values for the return value of TraceRay. More... | |
enum | TraceFlags { Shade = 1 } |
Bit values for the flags parameter of TraceRay. More... | |
Public Member Functions | |
virtual int | TraceRay (Ray &ray, float min_dist=-1, float max_dist=-1, int flags=0, const char *trace_set=nullptr, float *hit_dist=nullptr, Point3 *hit=nullptr, Color *hitCol=nullptr, Point3 *hitNormal=nullptr, Point3 *hitUVW=nullptr)=0 |
The TraceRay call - to be implemented by the Renderer. More... | |
Interface for the 3ds Max OSL Raytracing features, allowing OSL to use a 3rd party renderer's raytracing engine.
This interface should be exposed by the renderer on the ShadeContext it passes to the OSL Map's EvalColor/Mono/NormalPerturb() methods. The OSL Map rendering service callback for the OSL trace() call will get the interface with
and call its IOSLRaytracingInterface::TraceRay method to perform raytracing.
enum ReturnFlags |
enum TraceFlags |
|
pure virtual |
The TraceRay call - to be implemented by the Renderer.
The OSL language contains a trace() call, and the renderer being used to render the OSL Map can choose to implement the trace() call in its own interal raytracing functionality. If this is not done, a fall back functionality is used, which is not very optimized (effectively, RenderGlobalContext::IntersectWorld is used!!). The Renderer needs to accept a GetInterface(MAXOSL_RAYTRACE_INTERFACE) on the ShadeContext it provides, and implement the IOSLRaytracingInterface and this function.
The function returns ReturnFlags and the HitSomething bit defines if the ray hits something or not.
If the OSL trace call has the "shade" value set, the TraceFlags::Shade bit is set. The other bits in the TraceFlags are currently unused and are reserved for future expansion.
In the Scanline renderer implementation, if TraceFlags::Shade=0, only hit_dist is filled in. However, if TraceFlags::Shade=1, the hit, hitCol and hitNormal are also filled in. These can be retrieved in the OSL code by doing
respectively.
ray | The ray to be traced |
min_dist | The minimum distance (basically, ray start offset) |
max_dist | The maximum distance (do not find hits beyond this distance) |
flags | Flags for the rendering. Currently only the Shade flag is supported. If that is set, the surface shader will be invoked at the hit point, and, additional values can be retrieved after the trace call |
trace_set | This is the char * version of the ustring that contains the trace set. Since it originates in an ustring, one can rely on the same pointer also containing the same string, so after checking a string's actual value once, one can resort to a pure pointer compare moving forward. IOSLGlobalInterface::GetUString() can also be used to compute ustring pointers up-front. |
hit_dist | If non-NULL, filled in with the distance to the hit point. |
hit | If non-NULL, and Shade bit was 1, filled in with the world space hit point. |
hitCol | If non-NULL, and Shade bit was 1, filled in with the color resulting by tracing the ray. |
hitNormal | If non-NULL, and Shade bit was 1, filled in with the normal of the traced object. |
hitUVW | If non-NULL, and Shade bit was 1, filled in with the UVW coordinates of the traced object. |