» EX9.Effect.Template
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

EX9.Effect.Template

French | Italian | Spanish

The Template has the whole effect structure already laid out as code and implements the most basic and working vertex- and pixel-shader. In fact a constant shading with simple texturing.

The template is structured in 4 sections:

  • Parameters
  • VertexShader
  • PixelShader
  • Techniques

Parameter

In the parameter section it first declares the most commonly used transformation matrices via semantics. Note that the variable tW which is declared with the WORLD semantic appears as a pin on the effect, while the other transformations do not. The VIEW and PROJECTION semantics assign the respective matrices that are connected to the Renderer (EX9)s View Transform and Projection Transform to the tV and tP matrices.

Next it declares a texture and a sampler, which has this texture assigned. The last parameter is the texture transformation matrix.

For every effect you also have to specify which data you want to output from the vertexshader and receive as parameter in the pixelshader. This is most conveniently done via a struct:

struct vs2ps
{
    float4 Pos  : POSITION;
    float2 TexCd : TEXCOORD0;
};

Note that this very struct is used as a return parameter for the vertexshader function:

vs2ps VS(float4 PosO  : POSITION, float4 TexCd : TEXCOORD0)
 {..}

and also as the parameter input to the pixelshader function:

float4 PS(vs2ps In): COLOR
 {..}

Using a struct like here is not mandatory. Besides the struct you can pump additional parameters into the pixelshader function as you like.

In this simple case the struct only carries two values: The position and texture coordinate vectors. In a realworld effect you'll very likely pass more information from the vertex- to the pixelshader.

VertexShader

The templates vertexshader function does not very much. It only fills the output struct with the current vertex position in projection space:

 Out.Pos = mul(PosO, tWVP);

and the current vertex texture coordinate transformed via the input texture transformation matrix:

 Out.TexCd = mul(TexCd, tTex);

PixelShader

The pixelshader function is even simpler. It takes the incoming texture coordinate for this pixel to get the color of the sampler Samp at this position and returns it.

Techniques

The template effect specifies two techniques. TSimplShader is the cool one, using the shader functions. The other is boring using only fixed function instructions, which you most likely will not need.

anonymous user login

Shoutbox

~5d ago

joreg: Workshop on 16 05: Introduction to Shaders. Signup here: https://thenodeinstitute.org/courses/ss24-vvvv-introduction-to-shaders-in-vvvv/

~6d ago

bjoern: hello, I am looking for a job / project starting june. get in touch via vvvv specialists available for hire

~12d ago

joreg: Workshop on 09 05: Deepdive into the Stride 3D Engine. Signup here: https://thenodeinstitute.org/courses/ss24-vvvv-advanced-3d-rendering-in-vvvv-with-stride/

~12d ago

tekcor: Dear vvvv community, I am leaving my personal fundraiser here because I know many of you personally, sending love https://t.ly/iV9l_

~13d ago

joreg: Rewatch the 24th vvvvorldwide meetup here: https://www.youtube.com/live/gNszIiRAjDo?si=0RXF0pW73EUaRqGk

~13d ago

joreg: LINK - the vvvv summer camp 2024 is announced: https://visualprogramming.net/blog/2024/link-the-vvvv-summer-camp-24/

~15d ago

joreg: Tonight, May 3, vvvv meetup in Berlin or via stream: https://visualprogramming.net/blog/2024/24.-vvvv-worldwide-meetup/

~19d ago

joreg: Workshop on 02 05: Intro to the Stride 3D Engine. Signup here: https://thenodeinstitute.org/courses/ss24-vvvv-intro-to-the-stride-3d-engine-in-vvvv/