3ds Max C++ API Reference
IOSLMapInterface Class Referenceabstract

The Interface for the 3ds Max OSL Map interface. More...

#include <MaxOSLInterface.h>

Public Member Functions

virtual const char * GetOutputName (int outindex) const =0
 Get the name of output x. More...
 
virtual MSTR GetShaderName () const =0
 Get the name of shader (not guaranteed to be unique in any way, just informational) More...
 
virtual MSTR GetOSL () const =0
 Get the OSL source code for this OSL Map. More...
 
virtual MSTR GetOSO () const =0
 Get the OSO compiled byte-code for this OSL Map. More...
 
virtual MSTR GetHLSL ()=0
 Experimental, and of limited practical use: Get the converted HLSL of this OSL Map in the form of an HLSL function body. More...
 
virtual int GetHLSLQuality () const =0
 Gets the HLSL conversion quality in percent. More...
 
virtual IParamBlock2GetParameters () const =0
 Gets the IParamBlock2 pointer to the actual parameters of the OSL shader. More...
 
virtual MSTR GetResolvedFilename (ParamID ID) const =0
 If a given parameter in the list returned by GetParameters() has TYPE_FILENAME, one uses this function to ask for the fully qualified path name. More...
 

Detailed Description

The Interface for the 3ds Max OSL Map interface.

This interface exposes methods that relate to properties of a particular OSL Map.

To retrieve the interface, use GetInterface on the map:

auto ip = (MaxSDK::OSL::IOSLMapInterface *)oslmap->GetInterface(MAXOSL_OSLMAP_INTERFACE);
#define MAXOSL_OSLMAP_INTERFACE
Interface ID for the 3ds Max OSL Map interface This interface exposes methods that relate to properti...
Definition: MaxOSLInterface.h:36
The Interface for the 3ds Max OSL Map interface.
Definition: MaxOSLInterface.h:247

Member Function Documentation

◆ GetOutputName()

virtual const char* GetOutputName ( int  outindex) const
pure virtual

Get the name of output x.

◆ GetShaderName()

virtual MSTR GetShaderName ( ) const
pure virtual

Get the name of shader (not guaranteed to be unique in any way, just informational)

◆ GetOSL()

virtual MSTR GetOSL ( ) const
pure virtual

Get the OSL source code for this OSL Map.

◆ GetOSO()

virtual MSTR GetOSO ( ) const
pure virtual

Get the OSO compiled byte-code for this OSL Map.

◆ GetHLSL()

virtual MSTR GetHLSL ( )
pure virtual

Experimental, and of limited practical use: Get the converted HLSL of this OSL Map in the form of an HLSL function body.

◆ GetHLSLQuality()

virtual int GetHLSLQuality ( ) const
pure virtual

Gets the HLSL conversion quality in percent.

100 doesn't mean the conversion is "perfect", it simply means that every operator in the OSO bytecode had some implementation that in itself didn't emit a warning in the conversion step.

◆ GetParameters()

virtual IParamBlock2* GetParameters ( ) const
pure virtual

Gets the IParamBlock2 pointer to the actual parameters of the OSL shader.

This will contain all the parameters as exposed by the OSL shaders. Note the following:

  • An input exists both as a regular parameter, and a Texmap parameter, with the addition of "_map" appended to the end of the parameter name. So for example a color parameter in the OSL file called "Bob", will create a TYPE_FRGBA parameter named "Bob" and a TYPE_TEXMAP parameter named "Bob_map"
  • Inputs that use a computed default will not have a regular input parameter, only the "_map" variant. A computed default is when an input in the OSL source code reads something like
    point UVW = point(u, v, 0)

For renderers using their own OSL implementation, the work flow is as follows:

  • Walk the parameters in this IParamBlock2 and assign them to values on the OSL shader.
  • If a parameter is of TYPE_FILENAME, use GetResolvedFilename(ID) to get the properly resolved path.
  • Walk the TYPE_TEXMAP parameters, resolve them using IOSLGlobalInterface::GetOSLMap to know which "OSL Map" and which output on that "OSL Map" to connect that input to.
See also
Class IOSLGlobalInterface

◆ GetResolvedFilename()

virtual MSTR GetResolvedFilename ( ParamID  ID) const
pure virtual

If a given parameter in the list returned by GetParameters() has TYPE_FILENAME, one uses this function to ask for the fully qualified path name.

The function resolves the path also for UDIM filenames ("c:\foo\bar<UDIM>.exr"), something the regular 3ds Max resolver cannot do. The function is meaningless if the parameter is not of TYPE_FILENAME; in such case it will simply return an empty string.