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

Tutorial Effects - Sr. Wiggle

English | Italian | Mandarin | Japanese

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


Comencemos con el famoso efecto MrWiggle que distosiona una malla mediante ondas sinusoidales:

El vertex shader es llamado por cada vértice de la malla. Como has aprendido aquí here, el input del vertex shader es la data almacenada en los vértices de la malla que son ahora procesados:

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

Aquí estamos interesados en el PosO vector, que es la posición del vértice actual. Añadiremos un offset a la coordenada x del vértice que va a depender de su posición vertical (coordenada y):

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

Añadimos algunos parámetros para controlar las ondas:

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

Así el vertex shader con sus inputs queda como esto:

float Frequency = 10;
float Phase = 0;
float Amplitude = 0.01;
 
vs2ps VS(
    float4 PosO  : POSITION,
    float4 TexCd : TEXCOORD0)
{
    //declara la estructura de salida
    vs2ps Out;
 
    //offset de la coordenada x
    PosO.x += sin(PosO.y * Frequency + Phase) * Amplitude;
 
    //transforma la posición
    Out.Pos = mul(PosO, tWVP);
 
    //transforma las coordenadas de textura
    Out.TexCd = mul(TexCd, tTex);
 
    return Out;
}

y el patch:

mr wiggle patch

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

anonymous user login

Shoutbox

~2d 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/

~3d ago

joreg: The new vvvv Show-Off-Reel is out: https://vimeo.com/930568091

~9d ago

joreg: The summer season of vvvv workshops at The NODE Institute is out: https://thenodeinstitute.org/ss24-vvvv-intermediates/

~9d ago

domj: If you happen to be in Prague, come join us at the Schema workshop on Thursday 25.4. :) https://www.facebook.com/events/395516526614988/?ti=ls

~21d ago

joreg: Postponed: Next vvvv beginner course starting April 29: https://thenodeinstitute.org/courses/vvvv-beginner-class-summer-2024/