» 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

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:


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

anonymous user login

Shoutbox

~9h ago

Urbankind: circuitb:Wrongcop is epic! :)

~10h ago

joreg: @tobi: use GetSlice() as the patch i referred you to is demonstrating. or start a forum thread with your patch.

~10h ago

TobiTobsen123: hmm yes i can see the values...but how to handle them as seperate values? I need to forward them via TCP/IP...

~11h ago

joreg: @tobi: OSCDecoder helppatch has a section: OSC_Advanced (bottomright) that demoes decoding of multiple messages

~12h ago

TobiTobsen123: I'm using an OSCDecoder, it receives two arguments...works but how can I seperate the arguments into two seperate values

~14h ago

u7angel: @mediadog, make it a forum question.

~14h ago

u7angel: @mediadog, tty renderer ?

~17h ago

microdee: however non-conductive objects are invisible for this so the pencil and the sticks in the video are still a mysteries