User Tools

Site Tools


DzShaderMaterial

Custom scriptable class for materials using RenderMan Shader Language (RSL) Shaders.

More...

Inherits :

Constructors

DAZ Script
DzShaderMaterial ()
DzShaderMaterial ( DzShaderMaterial mat, Boolean duplicateMissingProps=true )
DzShaderMaterial ( String definitionFile )

Methods

Detailed Description

This class provides a DzMaterial derived object with creator-defined properties that will be passed to the RSL Shader at render-time. By default, the material only has two properties - Diffuse Color (Cs) and Opacity Strength (Os) - which are not passed as tokens to the shader, rather they are attributes sent directly to the renderer, via RiColor() and RiOpacity() respectively. These properties are not mappable by default, but can be made so by using DzRSLShader::addMapProperty(). All other properties for the material must be added using DzRSLShader::addShaderProperty() and DzRSLShader::addMappableProperty() in order to be used to pass values as arguments to the shader. Properties for the material that will be used by the render-time scripts to set attributes must be added via DzElement::addProperty().

Samples:

  • rispec_constant_shader_preset - A [heavily commented] Shader Preset that applies a material definition script (below) for the standard RenderMan Constant Surface Shader.

See Also:

Constructors


DzShaderMaterial()

Default Constructor.


DzShaderMaterial( DzShaderMaterial mat, Boolean duplicateMissingProps=true )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameter(s):

  • mat - The DzShaderMaterial to copy
  • duplicateMissingProps - Whether or not to duplicate missing properties

See Also:


DzShaderMaterial( String definitionFile )

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameter(s):

  • definitionFile - The relative path [from DzApp::getScriptsPath()] to the DAZ Script that creates this material's property list.

See Also:

Methods


Boolean : addShader( DzRSLShader shader )

Adds shader to this material's internal list of shaders and sets shader 's owner to this material.

Return Value:

  • true if shader is successfully added to the list (e.g. does not already exist), otherwise false.

String : getDefinitionFile()

Return Value:

  • The relative path [from DzApp::getScriptsPath()] to the DAZ Script that creates this material's property list.

DzColorProperty : getDiffuseProperty()

Return Value:

  • The Diffuse Color property of this material

Number : getNumShaders()

Return Value:

  • The number of DzRSLShaders on this material

DzFloatProperty : getOpacityProperty()

Return Value:

  • The Opacity property of this material

DzRSLShader : getShader( Number index )

Return Value:

  • The DzRSLShader at index or NULL if no shader exists at that index.

Boolean : removeShader( DzRSLShader shader )

Removes shader from this material's internal list of shaders.

Return Value:

  • true if shader is successfully removed from the list, otherwise false.

void : setDefinitionFile( String definitionFile, Boolean doOverride=false, Boolean runScript=true )

Sets the relative path of the [DAZ Script] file that defines this material.

Parameter(s):

  • definitionFile - The relative path [from DzApp::getScriptsPath()] to the DAZ Script that defines this material
  • doOverride - Whether or not to override the setting of the definition file if it has already been set
  • runScript - Whether or not to run the definition script upon setting it

Example:

In a nested folder [./scripts/support/DAZ/shaderDefinitions/surface]

// Set the definition file for the DzShaderMaterial (relative to the scripts folder)
oMaterial.setDefinitionFile( "support/DAZ/shaderDefinitions/surface/dzglossy.dsb" );

Attention:

  • definitionFile is executed the moment the call to this method is made. A global transient variable named Material - refering to the current DzShaderMaterial being rendered, exists for the duration of definitionFile. Referencing this variable from outside definitionFile will result in an error.

void : setMaterialName( String name )

Sets the name of the material type that will be returned by getMaterialName(). By default, this is “Custom”

Parameter(s):

  • name - The name to assign to this material

Example:

// Set the name of the material
// (the label displayed to the user in the Surfaces pane when the surface is selected)
Material.setMaterialName( "DAZ Studio Glossy Plastic" );

void : setNeedsTangentSpaceParams( Boolean onoff )

Sets whether this material needs the Tangent Space Params: varying vector dPds and varying float dPdsM. dPds is the tangent vector along the surface. dPdsM is the handedness of the bitangent vector on the surface. The bitangent can be reconstructed using:

vector B = normalize (((normalize(N) ^ normalize(dPds))*dPdsM);

This should be turned off/on in the script handed to DzRSLShader::setRenderTimeFile(). It is not persistent between sessions. It is false by default.

Parameter(s):

  • onoff - Whether or not this material needs the Tangent Space Params

Example:

// Turn on the TangentSpaeParams, from within in a surface DzRSLShader's rendertime file:
var Material = Shader.getOwner();
Material.setNeedsTangentSpaceParams( true );