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

cn.Tutorial Effects - Vertexshader Preparations

English | Spanish | Italian | Japanese

TOC: Of Effects and Shaders
Next: Mr. Wiggle


顶点着色器操纵网格上的每个顶点。对于很多种的数据场来说一个顶点是一个容器。这些数据场作为输入的参数在顶点着色器中使用。最重要的是位置,材质坐标和法线。作为一个着色器的制作者,你需要知道每个顶点中能储存什么样的数据。你可以使用VertexDeclaration (EX9.Geometry Mesh) 获得网格中的数据描述。


Mesh Data




  • 引脚中着色器的值
  • 空间变换信息
  • 网格信息

顶到着色器把顶点的位置信息转换到一个直接坐标系空间中,然后投射到屏幕上(3D空间 -> 2D屏幕空间,参见ex9.spaces。取决于着色器它同时也准备一些其它的数据,这些数据之后被用到像素着色中。顶点着色器计算的所有的数据被封装到一个数据结构中,这个结构我们称之为“vs2ps”。它可以包含很多种的数据场,这完全取决与你在像素着色器中的需求。但它必须要输出位置数据场,这样显卡才能计算屏幕中的那些网格包含在网格内。所有的其它的数据场都是可操控的,最常用的是材质坐标和法线。

Mesh data flow

详细信息参见 ex9.dataflow


Clone the Template (EX9.Effect) on a patch and connect a mesh to it and render it into a Renderer (EX9):在程序片中克隆Template (EX9.Effect)在上面连接一个网格,用Renderer (EX9)渲染:

Basic patch


float4x4 tW: WORLD;        //the models world matrix as via the shader
float4x4 tV: VIEW;         //view matrix as set via Renderer (EX9)
float4x4 tP: PROJECTION;   //projection matrix as set via Renderer (EX9)
float4x4 tWVP: WORLDVIEWPROJECTION; //all 3 premultiplied 
//texture transformation marked with semantic TEXTUREMATRIX
//to achieve symmetric transformations
float4x4 tTex: TEXTUREMATRIX <string uiname="Texture Transform";>;
//the data structure: "vertexshader to pixelshader"
//used as output data of the VS function
//and as input data of the PS function
struct vs2ps
    float4 Pos  : POSITION;
    float2 TexCd : TEXCOORD0;
//vertex shader
vs2ps VS(
    float4 PosO  : POSITION,
    float4 TexCd : TEXCOORD0)
    //declare output struct
    vs2ps Out;
    //transform position
    Out.Pos = mul(PosO, tWVP);
    //transform texturecoordinates
    Out.TexCd = mul(TexCd, tTex);
    return Out;
technique TSimpleShader
    pass P0
        VertexShader = compile vs_1_1 VS();
        PixelShader  = null;

Next: Mr. Wiggle
TOC: Of Effects and Shaders

anonymous user login


~2h ago

joreg: and thanks for the pointer re offline installer: links are now fixed.

~2h ago

joreg: @herbst re install path please see this discussion: https://discourse.vvvv.org/t/installer-doesnt-ask-for-path/18234

~2h ago

herbst: Also, offline installer links greet me with a TeamCity login request. ("guest login" works, but that was just a lucky guess)

~2h ago

herbst: Why does the current installer neither let me choose nor tell me where vvvv gets installed to?

~22h ago

Yoctopory: The EDSDK (DX11) doesn't seem to work with the newe r Canon EOS 2000D. The same patch works with the older EOS 1200D Any Ideas?

~1d ago

levi: Any one knows of solutions for large touch surfaces (fingers)? 5 meters or so ?

~2d ago

CeeYaa: https://www.youtube.com/watch?v=OkzfYQCLrCE thanks for the insights, impressive stuff @mediadog yes, it is a very nice CAVE

~3d ago

mediadog: @CeeYaa Why I'm learning Unreal, now if I could just afford wrap-around LED walls! Can do in vvvv too, it's just a CAVE