Custom scriptable class for RenderMan Shader Language (RSL) Shader types.
Inherits :
DAZ Script | |
---|---|
ShaderType | { None, Surface, Light, LightArea, VolumeAtmosphere, VolumeInterior, VolumeExterior, Displacement, Imager } |
DAZ Script |
---|
DzRSLShader () |
void | propertyAdded ( DzProperty prop ) |
void | propertyListChanged () |
void | propertyRemoved ( DzProperty prop ) |
This class provides the ability to define RSL shaders for the elements that can use them (DzShaderMaterial, DzShaderLight, DzShaderCamera).
Optimizations:
Two methods in this class that should not be overlooked are setActiveInShadowPass() and setOnlyInShadowPass(), as they can have a significant impact on render times.
In the context of Surface shaders, the data members set by these methods are used to identify whether the shader participates during the shadow [map] pass - the pass for each contributing light in the scene that indicates the use of Deep Shadow Maps for shadows. This affords developers a couple of key benifits:
In the context of Light shaders, the data members set by these methods are used to identify whether this shader participates when the DzLight::ShadowType indicates shadowing is used. This affords developers the benifit of being able to use Light shaders that are optimized for either condition.
Property Naming:
Standard Shader and Materials Presets make an effort to copy as much as possible from one element to the next via DzElement::copyFrom(). In order for this to occur, the properties must match in both name and type. Provided below are the names and types used by DzDefaultMaterial, DzLight, DzDistantLight, DzSpotLight and DzPointLight in the event that you would like use properties that will work with the copyFrom() method.
Default Material:
Default Lights:
Default Camera:
Name
Type
Name
Type
Diffuse Color
Negative Bump
Diffuse Strength
Positive Bump
Glossiness
Displacement Strength
Specular Color
Minimum Displacement
Specular Strength
Maximum Displacement
Multiply Specular
Through Opacity
Reflection Color
Ambient Color
Reflection Strength
Ambient Strength
Refraction Color
Opacity Strength
Refraction Strength
Bump Strength
Index of Refraction
Name
Type
Color
Intensity
Shadow Type
Shadow Bias
Shadow Softness
Illumination
Spread Angle
Name
Type
Focal Length
DOF
Depth of Field
Aperature
Samples:
See Also:
Recommended Reading:
Enumerated values for RSL shader types.
Attention:
See Also:
Default Constructor.
Attention:
Boolean : addMappableProperty( DzNumericProperty prop, String token, String mapToken )
Adds a mappable numeric property to this shader object. DzColorProperty instances are passed as color type variables to the shader - all other DzNumericProperty derived instances are passed as float type variables. If the property is mapped, the absolute path of the image file is passed as a string type variable to the shader.
Parameter(s):
param
argument.prop
is passed to.prop
's map is passed to, if prop
is mapped.Return Value:
true
if prop
was successfully added to the list of properties used by this shader (e.g. did not already exist), otherwise false
.Boolean : addMapProperty( DzNumericProperty prop, String mapToken )
Adds a mappable numeric property to this shader object (intended for situations where the property itself is passed as an attribute via the render-time script, or simply for display purposes, but the associated map should be passed as an arg to the shader). If the property is mapped, the absolute path of the image file is passed as a string type variable to the shader.
Parameter(s):
mapParam
argument.prop
's map is passed to, if prop
is mapped.Return Value:
true
if prop was successfully added to the list of properties used by this shader (e.g. did not already exist), otherwise false
.Boolean : addShaderProperty( DzProperty prop, String token )
Adds a standard property to the list of properties used by this shader object, and adds the property to this shader object's owner if it does not already exist. DzColorProperty instances are passed as color type variables to the shader - all other DzNumericProperty derived instances are passed as float type variables. DzImageProperty instances are passed as string type variables (the value of which is the absolute path of the image file).
Parameter(s):
Return Value:
true
if prop
was successfully added to the list of properties used by this shader (e.g. did not already exist), otherwise false
.String : findMapTokenByProperty( DzNumericProperty prop )
Return Value:
prop
is passed to, if prop
is mappable. Returns an empty string if prop
is not found, or not mappable.DzProperty : findProperty( String name )
Return Value:
name
if name
is found, otherwise NULL.DzProperty : findPropertyByToken( String token )
Return Value:
token
, if token
is found. Undefined by default.String : findTokenByProperty( DzProperty prop )
Return Value:
prop
is passed to. Returns an empty string if prop
is not found.Return Value:
Return Value:
Return Value:
DzProperty : getProperty( Number which )
Get a property from this shader's property list.
Parameter(s):
Return Value:
which
is within range, the property at the given index, otherwise NULL.Since:
Array : getPropertyList()
Return Value:
Since:
Return Value:
String : getShaderFile()
Return Value:
Return Value:
Boolean : isActiveInBakePass()
Return Value:
true
if this shader participates in the bake pass, otherwise false
.Boolean : isActiveInBeautyPass()
Return Value:
true
if this shader participates in the beauty pass, otherwise false
.Boolean : isActiveInShadowPass()
Return Value:
true
if this shader participates in the shadow pass, otherwise false
.Boolean : isOnlyInShadowPass()
Return Value:
true
if this shader ONLY participates in the shadow pass, otherwise false
. Same as isActiveInShadowPass() && !isActiveInBeautyPass().Boolean : removeProperty( DzProperty prop )
Removes the given property, if it can be found.
Parameter(s):
Return Value:
true
on success, otherwise false
.Boolean : removeProperty( String name )
Removes the property named name, if it can be found.
Parameter(s):
Return Value:
true
on success, otherwise false
.void : setActiveInBakePass( Boolean yesNo )
Sets whether this shader object participates in the baking pass; false
by default. If this is set to true
, the shader must have a string input variable named “BakeFileName” and another string input variable named “BakeType”.
“BakeFileName” will not be set unless it is a baking pass. When set, it will contain the name of the file to bake into.
“BakeType” will be set to one of three values: “Illumination”, “Shader”, or “IllumShader”. They indicate as follows:
Illumination
Bake only the illumination seen by the surface.
Shader
Bake the shader without any illuminations. (Assume all points are lit uniformly at 100%).
IllumShader
Bake the shader and illumination contributions.
Note:
true
.void : setActiveInBeautyPass( Boolean yesNo )
Sets whether this shader object participates in the beauty/final pass; true
by default.
See Also:
void : setActiveInShadowPass( Boolean yesNo )
Sets whether this shader object participates in the shadow pass; false
by default.
See Also:
Boolean : setDefinitionFile( String definitionFile, Boolean doOverride=false, Boolean runScript=true )
Sets the relative path of the (DAZ Script) file that builds this shader object's property list.
Parameter(s):
Return Value:
true
if definitionFile
is valid, otherwise false
.Attention:
definitionFile
is executed the moment the call to this method is made. A global variable named Shader
- referring to the current DzRSLShader being rendered, exists for the duration of definitionFile
. Referencing this variable from outside definitionFile
will result in an error.See Also:
void : setOnlyInShadowPass( Boolean yesNo )
Sets whether this shader object ONLY participates in the shadow pass; false
by default. This is the same as calling setActiveInBeautyPass( false ) and setActiveInShadowPass( true ).
See Also:
Boolean : setRenderTimeFile( String renderTimeFile )
Sets the relative path of the (DAZ Script) file that will be executed at render-time. This script can set attributes as well as shader parameters for the element, and implement custom logic for special effects.
Parameter(s):
Return Value:
true
if renderTimeFile
is valid, otherwise false
.Attention:
renderTimeFile
is executed, a global variable named Shader
- referring to the current DzRSLShader being rendered - exists for the duration of renderTimeFile
. Referencing this variable from outside renderTimeFile
will result in an error. See the Render Time Functions for a list of special functions only available to this script.See Also:
Boolean : setShaderFile( String shaderFile )
Sets the shader file that this shader object calls when rendered.
Parameter(s):
Return Value:
true
if shaderFile
plus the shader extension for the active renderer exists, otherwise false
.Attention:
See Also:
Boolean : setShaderType( ShaderType shaderType )
Sets the type for this shader object.
Parameter(s):
Example:
var oShadObj = new DzRSLShader; oShadObj.setShaderType( DzRSLShader.Surface );
DzVec3 : gammaCorrectColor( Color color )
Parameter(s):
Return Value:
void : setFloatAttrib( String attrib, String token, Number val )
Adds a RiAttribute call with a float value.
Parameter(s):
Example:
Shader.setFloatAttrib( "user", "float myFloat", 1.0 );
void : setIntegerAttrib( String attrib, String token, Number val )
Adds a RiAttribute call with an integer value.
Parameter(s):
Example:
Shader.setIntegerAttrib( "user", "integer myInteger", 1 );
void : setColorAttrib( String attrib, String token, Number r, Number g, Number b, Boolean isFloat=false )
Adds a RiAttribute call with a color value.
Parameter(s):
Example:
var color = new Color( 210, 210, 210 ); Shader.setColorAttrib( "user", "color myColor", color.red, color.green, color.blue ); //Shader.setColorAttrib( "user", "color myColor", color.red, color.green, color.blue, false );
Attention:
isFloat
is false
(the default), the values of r, g and b are assumed to be in the [0,255] range and will be converted to the [0,1] range prior to being passed on to the renderer. This allows for the values of the individual components to be driven beyond their normal range in cases where such an ability is needed, as with some subsurface scattering techniques.void : setStringAttrib( String attrib, String token, String val )
Adds a RiAttribute call with a string value.
Parameter(s):
Example:
Shader.setStringAttrib( "user", "string myString", "foo.bar" );
void : setPointAttrib( String attrib, String token, DzVec3 vec )
Adds a RiAttribute call with a point value.
Parameter(s):
Example:
Shader.setPointAttrib( "user", "point myPoint", new DzVec3( 1, 1, 1 ) );
void : setVectorAttrib( String attrib, String token, DzVec3 vec )
Adds a RiAttribute call with a vector value.
Parameter(s):
Example:
Shader.setVectorAttrib( "user", "vector myVector", new DzVec3( 1, 1, 1 ) );
void : setNormalAttrib( String attrib, String token, DzVec3 vec )
Adds a RiAttribute call with a normal value.
Parameter(s):
Example:
Shader.setNormalAttrib( "user", "normal myNormal", new DzVec3( 1, 1, 1 ) );
void : setMatrixAttrib( String attrib, String token, DzMatrix4 mtx )
Adds a RiAttribute call with a matrix value.
Parameter(s):
Example:
Shader.setMatrixAttrib( "user", "matrix myMatrix", new DzMatrix4() );
void : setFloatToken( String token, Number val )
Sets the value of a float token in the list of tokens passed to the shader.
Parameter(s):
void : setIntegerToken( String token, Number val )
Sets the value of an integer token in the list of tokens passed to the shader.
Parameter(s):
void : setColorToken( String token, Color val )
Sets the value of a color token in the list of tokens passed to the shader.
Parameter(s):
void : setStringToken( String token, String val )
Sets the value of a string token in the list of tokens passed to the shader.
Parameter(s):
void : setPointToken( String token, DzVec3 vec )
Sets the value of a point token in the list of tokens passed to the shader.
Parameter(s):
void : setVectorToken( String token, DzVec3 vec )
Sets the value of a vector token in the list of tokens passed to the shader.
Parameter(s):
void : setNormalToken( String token, DzVec3 vec )
Sets the value of a normal token in the list of tokens passed to the shader.
Parameter(s):
void : setMatrixToken( String token, DzMatrix4 mtx )
Sets the value of a matrix token in the list of tokens passed to the shader.
Parameter(s):
void : makeCubeFaceEnvironment( String px, String nx, String py, String ny, String pz, String nz, String tex, Number fov, DzRenderOptions::PixelFilter filter, Number swidth, Number twidth, Array tokens, Array params )
Convert six images representing six viewing directions into an environment map in the format required by the renderer.
Parameter(s):
Attention:
filter
argument are accessed like properties on an instance of the global object.var oRenderMgr = App.getRenderMgr(); var oOptions = oRenderMgr.getRenderOptions(); ... oOptions.Gaussian; ...
void : makeLatLongEnvironment( String pic, String tex, DzRenderOptions::PixelFilter filter, Number swidth, Number twidth, Array tokens, Array params )
Convert an image representing a latitude-longitude map into an environment map in the format required by the renderer.
Parameter(s):
Attention:
filter
argument are accessed like properties on an instance of the global object.var oRenderMgr = App.getRenderMgr(); var oOptions = oRenderMgr.getRenderOptions(); ... oOptions.Gaussian; ...
void : makeShadow( String pic, String tex, Array tokens, Array params )
Convert a depth image into a shadow map in the format required by the renderer.
Parameter(s):
void : makeTexture( String pic, String tex, String swrap, String twrap, DzRenderOptions::PixelFilter filter, Number swidth, Number twidth, Array tokens, Array params )
Convert an image map into a map in the format required by the renderer.
Parameter(s):
Attention:
filter
argument are accessed like properties on an instance of the global object.var oRenderMgr = App.getRenderMgr(); var oOptions = oRenderMgr.getRenderOptions(); ... oOptions.Gaussian; ...
void : makeBump( String pic, String tex, String swrap, String twrap, DzRenderOptions::PixelFilter filter, Number swidth, Number twidth, Array tokens, Array params )
Convert a bump map into a map in the format required by the renderer.
Parameter(s):
Attention:
filter
argument are accessed like properties on an instance of the global object.var oRenderMgr = App.getRenderMgr(); var oOptions = oRenderMgr.getRenderOptions(); ... oOptions.Gaussian; ...
void : addTransformBegin()
Adds a RiSpec RiTransformBegin() call.
Attention:
Since:
void : addTransformEnd()
Adds a RiSpec RiTransformEnd() call.
Attention:
Since:
void : addScheduledTransformEnd()
Adds a RiSpec RiTransformEnd() call after the owner.
Attention:
var oOwner = Shader.getOwner(); if( oOwner.inherits("DzShaderLight") && !oOwner.usesLocalShaderSpace() ){ Shader.addTransformBegin(); Shader.addIdentity(); var mtxTransform = new DzMatrix4( 1, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1 ); Shader.addTransform( mtxTransform ); var vecPos = !oOwner.isDirectional() ? oOwner.getWSPos() : new DzVec3( 0, 0, -200 ); var quatRot = oOwner.getWSRot(); var vecAxis = quatRot.getAxisOfRotation(); var nRadiansToDegrees = 180 / Math.PI; var nAngle = quatRot.getAngleOfRotation() * nRadiansToDegrees; Shader.addTranslate( vecPos.x, vecPos.y, vecPos.z ); Shader.addRotate( -nAngle, vecAxis.x, vecAxis.y, vecAxis.z ); Shader.addCoordinateSystem( "3DLEnvSpace" ); Shader.addScheduledTransformEnd(); }
Since:
void : addConcatTransform( DzMatrix4 transform )
Adds a RiSpec RiConcatTransform() call.
Parameter(s):
Since:
void : addCoordinateSystem( String space )
Adds a RiSpec RiCoordinateSystem() call.
Parameter(s):
Since:
void : addCoordSysTransform( String space )
Adds a RiSpec RiCoordSysTransform() call.
Parameter(s):
Since:
void : addIdentity()
Adds a RiSpec RiIdentity() call.
Since:
void : addRotate( Number angle, Number dx, Number dy, Number dz )
Adds a RiSpec RiRotate() call.
Parameter(s):
Since:
void : addScale( Number dx, Number dy, Number dz )
Adds a RiSpec RiScale() call.
Parameter(s):
Since:
void : addScopedCoordinateSystem( String space )
Adds a RiSpec DDiScopedCoordinateSystem() call.
Parameter(s):
Since:
void : addSkew( Number angle, Number dx1, Number dy1, Number dz1, Number dx2, Number dy2, Number dz2 )
Adds a RiSpec RiSkew() call.
Parameter(s):
Since:
void : addTransform( DzMatrix4 transform )
Adds a RiSpec RiTransform() call.
Parameter(s):
Since:
void : addTranslate( Number dx, Number dy, Number dz )
Adds a RiSpec RiTranslate() call.
Parameter(s):
Since:
void : propertyAdded( DzProperty prop )
Signature:“propertyAdded(DzProperty*)”
Transmitted when a property is added to this element.
Parameter(s):
void : propertyListChanged()
Signature:“propertyListChanged()”
Transmitted when a property is added to or removed from this element.
void : propertyRemoved( DzProperty prop )
Signature:“propertyRemoved(DzProperty*)”
Transmitted when a property is removed from this element.
Parameter(s):