Related Scripting Object: Shader
The Shader object represents a node in the render tree of an object. More...
#include <xsi_shader.h>
Inheritance diagram for Shader:

Public Member Functions |
|
| Shader () | |
| ~Shader () | |
| Shader (const CRef &in_ref) | |
| Shader (const Shader &in_obj) | |
| bool | IsA (siClassID in_ClassID) const |
| siClassID | GetClassID () const |
| Shader & | operator= (const Shader &in_obj) |
| Shader & | operator= (const CRef &in_ref) |
| CRefArray | GetShaders () const |
| CRefArray | GetImageClips () const |
| CString | GetProgID () const |
| siShaderParameterType | GetOutputType2 () const |
| siShaderOutputType | GetOutputType () const |
| CStatus | GetColorParameterValue (const CString &in_name, float &out_red, float &out_green, float &out_blue, float &out_alpha, double in_time=DBL_MAX) |
| CStatus | PutColorParameterValue (const CString &in_name, float in_red, float in_green, float in_blue, float in_alpha=1.0f, double in_time=DBL_MAX) |
| TextureLayer | CreateTextureLayer (const CString &in_strName=CString(), bool in_bAfter=true, const TextureLayer &in_refLayer=TextureLayer()) |
| CStatus | AddSharedTextureLayer (const TextureLayer &in_layer, bool in_bAfter=true, const TextureLayer &in_refLayer=TextureLayer()) |
| CRefArray | GetTextureLayers () const |
| CStatus | RemoveTextureLayer (const TextureLayer &in_layer) |
| bool | HasRenderer (const CString &in_strRenderer) const |
| CValue | GetRendererOption (const CString &in_strRenderer, const CString &in_strOption) const |
| CString | GetSymbolName (const CString &in_strRenderer) const |
| CString | GetCodePath (const CString &in_strRenderer) const |
| CString | GetCodeText (const CString &in_strRenderer) const |
| Property | AddProperty (const CString &in_preset, bool in_bBranch=false, const CString &in_name=CString()) |
| CRefArray | GetProperties () const |
| siShaderParameterType | GetShaderInputType (const CString &in_scriptname) const |
| CString | GetPortDisplayName (const CString &in_portScriptName) const |
| CStatus | PutPortDisplayName (const CString &in_portScriptName, const CString &in_displayName) |
| CRef | GetRoot (void) const |
The initial Shader of a render tree can be created with SceneItem::AddMaterial and additional shaders can be created and connected together with Parameter::ConnectFromPreset and Parameter::Connect.
A Shader is a type of DataSource.
using namespace XSI; Application app; Model root = app.GetActiveSceneRoot(); X3DObject myCube; root.AddGeometry( L"Cube",L"MeshSurface",L"" ,myCube ); Material myMaterial; myCube.AddMaterial(L"Phong",false,L"",myMaterial); CRefArray refShaders = myMaterial.GetShaders(); for(LONG i = 0;i < refShaders.GetCount(); ++i) { app.LogMessage( L"The shader: " + Shader(refShaders[i]).GetFullName() ); }
It is easy to find the entire list of parameters by calling ProjectItem::GetParameters. They are also documented in the SPDL parameter section of the reference.
class CPhong { public: CPhong( const Shader & in_phong ) : shader( in_phong ) { // This object only works if we are constructed with a valid // reference to a phong shader assert( shader.IsValid() ) ; assert( shader.GetProgID() == L"Softimage.material-phong.1" ) ; } // // GetMethods // // Access to simple parameters float GetShiny() { return shader.GetParameterValue(L"Shiny") ; } LONG GetReflectSamples() { return shader.GetParameterValue(L"reflect_samples") ; } bool IsDiffuseInUse() { return shader.GetParameterValue(L"diffuse_inuse") ; } // Access to color parameters CStatus GetAmbient(float& r, float& g, float& b, float& a) { return shader.GetColorParameterValue(L"ambient",r,g,b,a ) ; } CStatus GetDiffuse(float& r, float& g, float& b, float& a) { return shader.GetColorParameterValue(L"diffuse",r,g,b,a ) ; } // // Put Methods // void PutShiny( float in_v ) { shader.PutParameterValue( L"Shiny", in_v ) ; } void PutRelectSamples( LONG in_v ) { shader.PutParameterValue( L"reflect_samples", in_v ) ; } void SetDiffuseInUse( bool in_enable ) { shader.PutParameterValue( L"diffuse_inuse", in_enable ) ; } void PutAmbient(float r, float g, float b, float a) { shader.PutColorParameterValue( L"ambient", r, g, b, a ) ; } void PutDiffuse(float r, float g, float b, float a) { shader.PutColorParameterValue( L"diffuse", r, g, b, a ) ; } private: CPhong() ; Shader shader ; // We use this C++ API object to read the information } ;
Destructor.
Constructs a Shader object from a CRef object.
| in_ref | A reference to a shader. |
Constructs a new Shader object from an existing Shader object.
| bool IsA | ( | siClassID | in_ClassID | ) | const [virtual] |
Returns true if this object supports the functionality of a specified class. For example, a Shader is a type of ProjectItem, so a Shader object supports ProjectItem functionality.
| in_ClassID | Test if this object supports this class. |
Reimplemented from ProjectItem.
Reimplemented in Texture.
Returns the class ID for this object.
Reimplemented from ProjectItem.
Reimplemented in Texture.
Assigns a Shader object to an existing Shader object.
| in_obj | A Shader object to be copied into this object. |
Assigns a CRef to this Shader object. The Shader object is cleared if the CRef is not a reference to an object that supports the Shader class.
| in_ref | A reference to an object that supports the Shader class. |
Reimplemented from ProjectItem.
Reimplemented in Texture.
Returns an array of references to the shaders connected to this Shader.
Returns an array of references to the ImageClip objects in the shader tree whose root is this shader.
Returns the programmatic identifier (ProgID) of this shader. You can use the ProgID with Parameter::ConnectFromProgID to recreate the shader.
Returns the output type of this shader. This is a convenient alternative to using Parameter::GetValueType for getting the parameter type of a color parameter.
This function is obsolete and replaced by Shader::GetOutputType2
| CStatus GetColorParameterValue | ( | const CString & | in_name, | |
| float & | out_red, | |||
| float & | out_green, | |||
| float & | out_blue, | |||
| float & | out_alpha, | |||
| double | in_time = DBL_MAX |
|||
| ) |
Returns the RGBA values of a color parameter. This is a convenient alternative to using ProjectItem::GetParameterValue for getting the RGBA values of a color parameter.
| in_name | The scripting name of the Parameter, for example diffuse, specular, or ambient. |
| out_red | The Red component value, typically a number in the range 0.0 to 1.0. | |
| out_green | The Green component value, typically a number in the range 0.0 to 1.0. | |
| out_blue | The Blue component value, typically a number in the range 0.0 to 1.0. | |
| out_alpha | The Alpha component value. |
| in_time | Time (in frames) at which to get the value. By default, GetColorParameterValue gets the value at the current frame (represented by the value DBL_MAX). |
| CStatus PutColorParameterValue | ( | const CString & | in_name, | |
| float | in_red, | |||
| float | in_green, | |||
| float | in_blue, | |||
| float | in_alpha = 1.0f, |
|||
| double | in_time = DBL_MAX |
|||
| ) |
Sets the RGBA values for a color parameter. This is a convenient alternative to ProjectItem::PutParameterValue for setting the RGBA values of a color parameter.
| in_name | The scripting name of the color parameter, for example "ambient". | |
| in_red | The Red component value, typically a number in the range 0 to 1.0. | |
| in_green | The Green component value, typically a number in the range 0 to 1.0. | |
| in_blue | The Blue component value, typically a number in the range 0 to 1.0. | |
| in_alpha | The Alpha component value. If the Alpha channel is hidden in the user interface and is not used by the shader, setting the Alpha value has no effect. | |
| in_time | Time (in frames) at which to set the color values. By default, PutColorParameterValue sets the value at the current frame (which is represented by the value DBL_MAX). |
| TextureLayer CreateTextureLayer | ( | const CString & | in_strName = CString(), |
|
| bool | in_bAfter = true, |
|||
| const TextureLayer & | in_refLayer = TextureLayer() |
|||
| ) |
Creates a new texture layer belonging to the container (the shader).
| in_strName | The name of new texture layer. | |
| in_bAfter | True to insert the layer after the reference layer (in_refLayer), and False to insert the layer before the reference layer. If there is no reference layer, then True adds the layer to the end of the list, and False adds the layer to the start of the list. | |
| in_refLayer | The reference texture layer. Used to indicate where the new layer is inserted in the list. |
| CStatus AddSharedTextureLayer | ( | const TextureLayer & | in_layer, | |
| bool | in_bAfter = true, |
|||
| const TextureLayer & | in_refLayer = TextureLayer() |
|||
| ) |
Adds an existing texture layer to the container. The layer already belongs to at least one other texture layer container (either a Shader or a Material).
| in_layer | The texture layer to add to this container. | |
| in_bAfter | True to insert the layer after the reference layer (in_refLayer), and False to insert the layer before the reference layer. If there is no reference layer, then True adds the layer to the end of the list, and False adds the layer to the start of the list. | |
| in_refLayer | The reference texture layer. Used to indicate where the new layer is inserted in the list. |
CStatus::Fail if the texture layer could not be created.
Returns a collection of TextureLayer objects owned by the shader.
Removes a texture layer from the container. If this container is the only owner of the layer, then the layer is deleted from the scene, otherwise the layer is removed from this container (but is still owned by other containers).
| in_layer | Texture layer to remove from this container. |
CStatus::Fail if the layer could not be removed.
Returns true if the shader supports the specified renderer.
| in_strRenderer | Name of a renderer. |
Returns the value of a renderer option. If the renderer or the option do not exist for this shader, an empty CValue is returned.
| in_strRenderer | Name of a renderer. | |
| in_strOption | Name of a render option. |
Returns the symbol name of the shader code executed by the renderer for this shader. If the symbol name is not set, an empty string is returned.
| in_strRenderer | Name of a renderer. |
Returns the file path of the shader code executed during rendering. If the file path is not set, an empty string is returned.
| in_strRenderer | Name of a renderer. |
Returns the text of the shader code executed during rendering. If the text is not set, an empty string is returned.
| in_strRenderer | Name of a renderer. |
| Property AddProperty | ( | const CString & | in_preset, | |
| bool | in_bBranch = false, |
|||
| const CString & | in_name = CString() |
|||
| ) |
Adds a property to the shader. For example, you can add a UserDataBlob or CustomProperty to store custom user data inside a render tree.
| in_preset | A preset name or the name of a self-installed CustomProperty. | |
| in_bBranch | Should always be false. | |
| in_name | Optional name for the new property. If no name is specified, the name is based on in_preset. |
Returns an array of all Property objects applied to the shader. A Shader may have nested CustomProperty or UserDataBlob properties.
Returns the input type of a shader parameter. Before you connect a shader to the parameter, use Parameter::GetCapabilities to make sure that the parameter supports the siTexturable capability (see the siCapabilities enum).
| in_paramscriptname | The script name of a parameter. |
Returns the port's display name, as it appears in the rendertree.
| in_portScriptName | The script name of the port parameter. |
Sets the port's display name, as it appears in the rendertree.
| in_portScriptName | The script name of the port parameter. | |
| in_displayName | The shader port's new display name. If the string is empty, it will be reset to its original value. |
Returns the root of the shader tree. The root may be a Camera, Light, Material, or a geometry shader.