» 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

~14h ago

fleg: This Tuesday, Cologne: exhibition opening of "interwoven", textile disinformation patterns created with vvvv. https://fleg.de/news/exhibition-interwoven

~14d ago

manuelgonzalvez: Assimp nodes all broken afted Win Update w/exception "COM object that has been separated from its underlying RCW(...)"

~14d ago

manuelgonzalvez: @levi thanks would love to! anyway managed to get something similar working based on forum search and anthokio's patches.

~15d ago

levi: @ravasquez thanks. 31.2 x86 verrion worked. @manuelgonzalvez i have a dx11 projectTexture if u a want.

~16d ago

manuelgonzalvez: Anyone has a dx11 port of "projectedTexture" dx9 fx for projection mapping?

~16d ago

manuelgonzalvez: Anyone has a dx11 port of "projectedTexture" dx9 fx for projection mapping?

~16d ago

ravazquez: @levi not sure bout the ImagePack, but I believe VL.OpenCV should give you the same tools and should work with beta just fine

~17d ago

levi: anyone knows of a VVVVpacks.image that works for elliot's projector calibration patches?x64,dx11. always crashes v4 on solve.

~23d ago

Lorenz: VJing with GIFS: https://lorenzpotthast.de/gifjockey/ A fun little side project, that I first prototyped in v4 and now turned web-based ;)

~1mth ago

schlonzo: finally fixed in 4.8 nice1