HLSL Shader

The shader used in the SlideShow for the Shader object is written in high-level shading language (HLSL). HLSL was developed by Microsoft for DirectX 9.

Shaders suitable for Shader object are populated with some default values.

Default values

If a Shader defines the following parameters (as uniform external <Typ> <Name> ) they are assigned according to the SlideShow.

  • gTime: float - elapsed time in seconds
  • gProgress: float - A numerical value from 0 to 1 that runs over the total duration of the ShaderObject. In the beginning it is 0.0, 1.0 at the end.
  • gOpacity: float - Opacity (0.0 = fully transparent (invisible), 1.0 = fully visible, inbetween = "semi"-transparent)

Additional parameters

Any additional parameters can be defined in the shader (according to the HLSL standard). These parameters can be loaded via the script functions (SetParamXXX) of the shader object.

Textures in Shader

The Shader object provides its own texture for each track or for the background. These are provided in Shader under gTexture0 to gTexture<N>. It depends on the graphics card or the ShaderModels used, how many textures can be used simultaneously in a shader.

  • gTexture0: texture - first texture
  • gTexture1: texture - second texture
  • etc.

RenderTargets in Shader

Multipass Shader

Minimal Shader: minimal.fx

This minimum shader does nothing more than to present the image as it is.

uniform extern float4x4 gWVP : WorldViewProjection; // Transformation matrix, which needs to be applied
uniform extern texture gTexture0; // first texture

sampler Texture0Sampler = sampler_state
  Texture = <gTexture0>;
  MinFilter = LINEAR;
  MagFilter = LINEAR;
  MipFilter = LINEAR;
  AddressU = MIRROR;
  AddressV = MIRROR;

struct OutputVS
  float4 posH: POSITION0;
  float2 tex0: TEXCOORD0;

// Vertex shader transforms the points in the 3D geometry
OutputVS mainVS(float3 pos : POSITION, float2 tex0: TEXCOORD0) {
  OutputVS outVS;

  outVS.tex0 = tex0.xy; // pass texture coordinates
  outVS.posH = mul(float4(pos.xyz, 1.0), gWVP); // transform vertex coordinates. This is important!

  return outVS;

// Pixel shader calculates the actual color values for a pixel
float4 mainPS(float2 tex0: TEXCOORD0) : COLOR {
  return tex2D(Texture0Sampler, tex0); 

technique technique0 {
  pass p0 {
    VertexShader = compile vs_2_0 mainVS();
    PixelShader = compile ps_2_0 mainPS();
    CullMode = None;
    FillMode = Solid;