» 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

~8h ago

joreg: We are complete: #NODE20 will feature 30 #vvvv workshops, from intro to masterclass, from user to developer: node20-workshops

~1d ago

joreg: Please help yourself to the latest #vvvv gamma 2020.2: vvvv-gamma-2020.2-release

~4d ago

nodeforum: E-mail invitations for NODE20’s Festival Hub have been sent out yesterday. In case of trouble let us know via help@nodeforum.org

~6d ago

david: @neuston: email is going out very soon!!!

~6d ago

neuston: @sunep Thx, but I have checked the spam folder but could not fine any

~6d ago

sunep: @neustron have you checked your spam folder? Mine went to spam.

~6d ago

neuston: I've not received any activation email for Talque, after purchased tickets of NODE20 last week. Is it normal? just want to confirm.

~6d ago

boplbopl: @tonfilm nice!

~6d ago

tonfilm: The first #vl #stride screenshots are here! vl.stride-earlyaccess-screenshots #visualprogramming #dotnet @stride3d #creativecoding #vvvv #gamedev