» チュートリアル エフェクト - 表示するための数式
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

チュートリアル エフェクト - 表示するための数式

English | Italian | Spanish | Mandarin

TOC: エフェクトとシェーダー
Back: Mr. Wiggle
Next: 頂点データ


数学的機能による頂点データ操作の様々な可能性について説明します。

次の例ではGrid (EX9.Geometry) を入力に使います。解像度は約50x50にしてください。

f(x, y) = z

xとyによって新しいzを作成します。the MrWiggle exampleを使うとこのように書くことができます:

float2 Frequency = 10;
float2 Phase = 0;
float2 Amplitude = 0.01;
 
vs2ps VS(
    float4 PosO  : POSITION,
    float4 TexCd : TEXCOORD0)
{
    //declare output struct
    vs2ps Out;
 
    //calculate two waves
    float2 wave = sin(PosO.xy * Frequency + Phase) * Amplitude;
 
    //set z coordinate
    PosO.z = wave.x + wave.y;
 
    //transform position
    Out.Pos = mul(PosO, tWVP);
 
    //transform texturecoordinates
    Out.TexCd = mul(TexCd, tTex);
 
    return Out;
}

パッチはこの様になります:

function patch

f(u, v) = xyz

その他の一般的なものはグリッドのxy座標から全く新しい位置を計算するためのものです。これはしばしばパラメトリックサーフェスと呼ばれます。入力のxyパラメーターはuvと呼ばれます。

例えば円錐形です:

x = v*cos(u)
y = v*sin(u)
z = v

関数としてこの様に書くことができます:

float3 Cone(float2 uv)
{
    float u = uv.x;
    float v = uv.y;
 
    float3 newPos;
    newPos.x = v * cos(u);
    newPos.y = v * sin(u);
    newPos.z = v;
 
    return newPos;
}

0..1の範囲での循環を得るために2Πでuをスケールすることが便利になるかもしれません。それだけでなく入力パラメーターのための汎用的なオフセットとスケールを持つことも便利になるかもしれません。頂点シェーダーはこの様になります:

#define twopi 6.28318531
 
float2 Scale = 1;
float2 Offset = 0;
 
float3 Cone(float2 uv)
{
 
     uv *= Scale;
     uv += Offset;
 
    float u = uv.x * twopi;
    float v = uv.y;
 
    float3 newPos;
    newPos.x = v * cos(u);
    newPos.y = v * sin(u);
    newPos.z = v;
 
    return newPos;
}
 
vs2ps VS(
    float4 PosO  : POSITION,
    float4 TexCd : TEXCOORD0)
{
    //declare output struct
    vs2ps Out;
 
    //set new position
    PosO.xyz = Cone(PosO.xy);
 
    //transform position
    Out.Pos = mul(PosO, tWVP);
 
    //transform texturecoordinates
    Out.TexCd = mul(TexCd, tTex);
 
    return Out;
}

そしてパッチはこの様になります:

cone patch

Next: 頂点データ
Back: Mr. Wiggle
TOC: エフェクトとシェーダー

anonymous user login

Shoutbox

~14d ago

~17d ago

joreg: The Winter Season of vvvv workshops is now over but all recordings are still available for purchase: https://thenodeinstitute.org/ws23-vvvv-intermediates/

~24d ago

schlonzo: Love the new drag and drop functionality for links in latest previews!

~1mth ago

joreg: Workshop on 29 02: Create Sequencers and Precise Clock Based Tools. Signup here: https://thenodeinstitute.org/courses/ws23-vvvv-08-create-sequencers-and-precise-clock-based-tools-in-vvvv-gamma/

~1mth ago

joreg: Workshop on 22 02: Unlocking Shader Artistry: A Journey through ‘The Book of Shaders’ with FUSE. Signup here: https://thenodeinstitute.org/courses/ws23-vvvv-12-book-of-shaders/

~2mth ago

joreg: Talk and Workshop on February 15 & 16 in Frankfurt: https://visualprogramming.net/blog/vvvv-at-node-code-frankfurt/

~2mth ago

woei: @Joanie_AntiVJ: think so, looks doable