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

# Tutorial Effects - Mr. Wiggle

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:

Next: Function Printing

# Shoutbox

~21h ago

matka: Massive thanks to developers for the latest release.

~1d ago

joreg: in case you missed the news so far: vvvv 50beta36 is out now: vvvv50beta36 #vvvv

~2d ago

stulloyd: 19/announcing-microsoft-directx-raytracing/

~3d ago

~3d ago

colorsound: @nsynk team. I sent you email about the optitrack at the store. Did you receive it? Thanks.

~4d ago

dominikKoller: vvvv Academy is going on Tour - and looking for partners to host a course! vvvv-academy-on-tour

~6d ago

joreg: another release candidate is out for the weekend: beta36-release-candidate #vvvv please test and report!