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

it.Tutorial Effects - Mr. Wiggle

English | Spanish | Mandarin | Japanese

INDICE: it.Of Effects and Shaders
Precedente: Vertexshader, i Preparativi
Prossimo: Disegnare con le Funzioni


Cominciamo con il celebre MrWiggle, un effetto che distorce una mesh secondo una sinusoide:

Il vertexshader viene richiamato per ogni vertice della mesh. Come hai imparato qui, l'input di un vertexshader sono i dati contenuti nel vertice della mesh che ora viene processata:

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

Per il momento ci interessa il vettore PosO, che è la posizione del vertice in questione. Aggiungeremo un offset alla coordinata x del vertice a seconda della posizione verticale (coordinata y):

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

Per controllare la sinusoide aggiungiamo qualche parametro:

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

Quindi il vertexshader con gli input sarà così:

float Frequency = 10;
float Phase = 0;
float Amplitude = 0.01;
 
vs2ps VS(
    float4 PosO  : POSITION,
    float4 TexCd : TEXCOORD0)
{
    //dichiara la struttura dell'output
    vs2ps Out;
 
    //offset della coordinata x
    PosO.x += sin(PosO.y * Frequency + Phase) * Amplitude;
 
    //trasforma la posizione
    Out.Pos = mul(PosO, tWVP);
 
    //trasforma le coordinate della texture
    Out.TexCd = mul(TexCd, tTex);
 
    return Out;
}

E di conseguenza la patch sarà simile a questa:

mr wiggle patch

Prossimo: Disegnare con le Funzioni
Precedente: Vertexshader, i Preparativi
INDICE: it.Of Effects and Shaders

anonymous user login

Shoutbox

~1mth ago

mediadog: @ggml Yup, lots. Only used in 4.x, haven't tried in 5.x yet: https://www.unrealengine.com/marketplace/en-US/product/simple-udp-tcp-socket-client

~1mth ago

ggml: someone has sent udp bytes to unreal ?

~2mth ago

micha_nismus: worked out, thank you very much ! :-)

~2mth ago

joreg: @micha_nismus does this help? https://youtu.be/xkrbT45BgOQ

~2mth ago

micha_nismus: thx joerg. Can anybody help me why i can't see any renderer in gamma? thx :-)

~2mth ago

joreg: @micha_nismus instead of discord, we're using matrix, see: chat

~2mth ago

micha_nismus: searching for a public discord server for vvvv

~2mth ago

joreg: Join us for the 20th #vvvv meetup on January 19th: https://thenodeinstitute.org/event/20-worldwide-vvvv-meetup/

~2mth ago

joreg: @schlonzo re "SDSL support" did you see the Shader wizard? or do you mean something different?