Share

Other Improvements and Changes

OSL improvements

Several things were added for OSL in 3ds Max 2021, mostly around UI refinement. For more detail about the following improvements, see the Open Shading Language (OSL) Support topic.

The default layout engine was improved to right-justify parameter headings and have some more user control of the layout, but it now also has the ability to load a .ui file that completely defines the user interface of an OSL shader.

There are also several new options for shader metadata: not only can the shader itself can be versioned with the new version attribute, but parameters' appearance and behavior can be tweaked with the new attributes autopop, connectable, step, packName, widgetWidth and worldunits.

3ds Max now correctly supports the widget type "null", as well as a few custom UI widgets "max:actionButton" and "max:ramp0".

Parameter support was extended. The new "semi-types" vector2, vector4, color2, color4 and matrix33 can now be used. These types are not built-in OSL types, but defined in header files. Including these header files and using these types is now supported (see the section about include files). Also, parameters of type array are supported in certain cases (see the ramp widget).

Support for OSL in the viewport has been vastly improved. The majority of OSL language functions are automatically converted to HLSL code and will display correctly in the viewport in 'Realistic' material display mode. You can now effectively develop OSL shaders without ever launching an actual rendering. Not everything is supported (for example, shaders passing string values to each other, or doing operations on string values) but the confidence level is displayed at the bottom of the OSL map as a percentage value. If this reads 100%, the shader will most likely display identically in the viewport and the final render.

Tab supports random access iterators

Tab now returns standard compatible random access iterators (raw pointers) through newly added begin() and end() methods. Here are a few examples of supported algorithms:

Tab<size_t> t; 
for (size_t i = 0; i < 100; ++i) { 
     t.Append(1, &i); 
} 

// range for loop 
for (size_t val : t) { 
    // ... 
} 

// copy 
Tab<size_t> copy_t; 
copy_t.SetCount(100); 
std::copy(t.begin(), t.end(), copy_t.begin()); 

// find an element 
auto it = std::find(t.begin(), t.end(), 42); 
if (it != t.end()) { 
    // ... 
} 

// sort 
std::sort(t.begin(), t.end(), [](const size_t& lhs, const size_t& rhs) { return lhs < rhs; }); 

Fixed conversion of integer parameters with large values

In order to ensure that integers larger than 2 ^ 24 - 1 are converted properly, use the two new APIs below instead of ParamDimensionBase::Convert(float value) and ParamDimensionBase::Unconvert(float value) :

int ParamDimensionBase::Convert()
int ParamDimensionBase::UnConvert(int value); 

Disabling asserts in hybrid and debug builds

Asserts can now be disabled in Hybrid and Debug build configurations of a plug-in by defining the MAX_ASSERTS_NOT_ACTIVE_IN_HYBRID_BUILD and MAX_ASSERTS_NOT_ACTIVE_IN_DEBUG_BUILD pre-processor symbols respectively. One way to do this is by setting them as an environment variable for the compiler:

set CL=/DMAX_ASSERTS_NOT_ACTIVE_IN_HYBRID_BUILD 

Was this information helpful?