» 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

~2d ago

nanotekt: vvvv+blender=lovvvve :D https://youtu.be/dUyeoi9mBIc

~3d ago

Patxi7: Pepper's Ghost & vvvv https://vimeo.com/632159133

~8d ago

mediadog: @manuelgonzalvez Needed to explicitly install VLC for VLC2; I use 3.0.6-win64 for stability.

~8d ago

mediadog: @manuelgonzalvez 42 getting crashes from DX11 VLC lib after last Win10 update. Switched to VLC2 plugin OK so far.

~9d ago

sunep: Looks interesting. Can't find a price though https://en.ids-imaging.com/ensenso-3d-camera-s-series.html

~19d ago

joreg: @guest re svg export: i'm afraid not.

~19d ago

joreg: @manuelgonzalvez what's stopping you? now is the time!

~19d ago

joreg: @schlonzo glad you like it!

~20d ago

schlonzo: the new burger menu is great!

~20d ago

schlonzo: the new burger menu is great!