» Tutorial Effects - Mr. Wiggle
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

Tutorial Effects - Mr. Wiggle

Italian | Spanish | Mandarin | Japanese

TOC: Of Effects and Shaders
Back: Vertexshader Preparations
Next: Function Printing


Lets start with the famous MrWiggle effect, it distorts a mesh by sine waves:

The vertex shader is called for each vertex of the mesh. As you have learned here, the input of the vertex shader is the data stored in the vertex of the mesh which is now processed:

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

Here we are interested in the PosO vector, which is the position of the current vertex. We will add an offset to the x coordinate of the vertex depending on its vertical position (y coordinate):

PosO.x += sin(PosO.y);

To control the waves we add some parameters:

PosO.x += sin(PosO.y * Frequency + Phase) * Amplitude;

Then the vertex shader with its inputs looks like:

float Frequency = 10;
float Phase = 0;
float Amplitude = 0.01;
 
vs2ps VS(
    float4 PosO  : POSITION,
    float4 TexCd : TEXCOORD0)
{
    //declare output struct
    vs2ps Out;
 
    //offset x coordinate
    PosO.x += sin(PosO.y * Frequency + Phase) * Amplitude;
 
    //transform position
    Out.Pos = mul(PosO, tWVP);
 
    //transform texturecoordinates
    Out.TexCd = mul(TexCd, tTex);
 
    return Out;
}

And the patch accordingly:

mr wiggle patch

Next: Function Printing
Back: Vertexshader Preparations
TOC: Of Effects and Shaders

anonymous user login

Shoutbox

~3d ago

micha_nismus: worked out, thank you very much ! :-)

~4d ago

joreg: @micha_nismus does this help? https://youtu.be/xkrbT45BgOQ

~6d ago

micha_nismus: thx joerg. Can anybody help me why i can't see any renderer in gamma? thx :-)

~10d ago

joreg: @micha_nismus instead of discord, we're using matrix, see: chat

~10d ago

micha_nismus: searching for a public discord server for vvvv

~18d ago

joreg: Join us for the 20th #vvvv meetup on January 19th: https://thenodeinstitute.org/event/20-worldwide-vvvv-meetup/

~18d ago

joreg: @schlonzo re "SDSL support" did you see the Shader wizard? or do you mean something different?

~18d ago

joreg: @LCA not aware, but the HIKVision sdk comes with a c# demo. need help for a commercial project? get in touch via devvvvs@vvvv.org

~20d ago

LCA: Has anyone ever made a HIKVision GigE work with vvvv?

~24d ago

schlonzo: What's the shortcut Anton used? =)