IShader (Shader object)

1. Definition

The Shader object is of type IShader and derives from ISlideShowObject.

IShader inherits from ISlideShowObject
  function Filename: IFilename;
  procedure SetTechnique(TechniqueName: string);
  procedure SetParamInt(ParamName: string; Value: Integer);
  procedure SetParamFloat(ParamName: string; Value: Float);
  procedure SetParamFloat2(ParamName: string; V1, V2: Single);
  procedure SetParamFloat3(ParamName: string; V1, V2, V3: Single);
  procedure SetParamFloat4(ParamName: string; V1, V2, V3, V4: Single);
  procedure SetParamRangeValue(ParamName: string; Value: IRangeValue);
  procedure SetParamRangeValue2(ParamName: string; V1, V2: IRangeValue);
  procedure SetParamRangeValue3(ParamName: string; V1, V2, V3: IRangeValue);
  procedure SetParamRangeValue4(ParamName: string; V1, V2, V3, V4: IRangeValue);
  function GetPostProcessing: Boolean;
  procedure SetPostProcessing(const Value: Boolean);
  function GetMeshColumns: Integer;
  procedure SetMeshColumns(const P: Integer);
  function GetMeshRows: Integer;
  procedure SetMeshRows(const P: Integer);
  procedure SetMesh(const Mesh: TVertexArray; const Indices: TIndexArray);
  procedure AddTexture(const Texture: ICanvas);
  procedure SetTexture(const TextureIndex: Integer; const Texture: ICanvas);
  function GetTexture(const TextureIndex: Integer): ICanvas;
  procedure DeleteTexture(const TextureIndex: Integer);
  procedure ClearTextures;
  function TextureCount: Integer;

2. Methods

  • Object creation

    function CreateShaderObject: IShader;
    
  • The file name of the Shader. Here, a specific source file of a HLSL Shader for DirectX 9 is meant (mostly *.fx).

    function Filename: IFilename;
    
  • If the Shader source code contains more than one shader technology it can be set using SetTechnique

    procedure SetTechnique(TechniqueName: string);
    
  • A shader requires different parameters. Which they are depends on the shader actually used. Using the SetParamXXX functions corresponding values can be passed to the shader.

    procedure SetParamInt(ParamName: string; Value: Integer);
    procedure SetParamFloat(ParamName: string; Value: Float);
    

3. Examples

Pixelshader effect

Pixelate: Presets\Scripts\Pixelate.sss

Assign own geometry

Complete code, see Toolbox object "Triangle": Presets\Scripts\GeometryTriangle.sss

var Mesh: TVertexArray;

// Triangle:
//
// (-0.5, 0.5)----(0, 0.5)----(0.5, 0.5)
// |                /\                 |
// |             /      \              |
// |           /          \            |
// |        /                \         |
// |      /       (0, 0)       \       |
// |   /                         \     |
// | /                             \   |
// (-0.5, -0.5)--------------(0.5, -0.5)

// Mesh := [Vertex(0, 0.5), Vertex(0.5, 0.5), Vertex(-0.5, 0.5)];
Mesh.SetLength(3);
Mesh[0] := Vertex(0, 0.5);
Mesh[1] := Vertex(0.5, -0.5);
Mesh[2] := Vertex(-0.5, -0.5);
Shader.SetMesh(Mesh, []);