1 | //--------------------------------------------------------------------------------------
|
---|
2 | // Input and Output structs
|
---|
3 | //--------------------------------------------------------------------------------------
|
---|
4 |
|
---|
5 |
|
---|
6 | struct vtxin
|
---|
7 | {
|
---|
8 | float4 position: POSITION;
|
---|
9 | float3 normal: NORMAL;
|
---|
10 | float4 color: COLOR;
|
---|
11 | float4 texCoord: TEXCOORD0;
|
---|
12 | };
|
---|
13 |
|
---|
14 | // vtx output
|
---|
15 | struct vtxout
|
---|
16 | {
|
---|
17 | float4 position: POSITION;
|
---|
18 | float4 texCoord: TEXCOORD0;
|
---|
19 |
|
---|
20 | float4 color: COLOR0;
|
---|
21 | float4 eyePos: TEXCOORD1; // eye position
|
---|
22 | float3 normal: TEXCOORD2;
|
---|
23 | };
|
---|
24 |
|
---|
25 |
|
---|
26 | //--------------------------------------------------------------------------------------
|
---|
27 | // Vertex Shaders
|
---|
28 | //--------------------------------------------------------------------------------------
|
---|
29 |
|
---|
30 |
|
---|
31 | vtxout animateVtx(vtxin IN,
|
---|
32 | uniform float3 windDir,
|
---|
33 | uniform float windStrength,
|
---|
34 | uniform float frequency,
|
---|
35 | uniform float2 minMaxPos,
|
---|
36 | uniform float timer)
|
---|
37 | {
|
---|
38 | vtxout OUT;
|
---|
39 |
|
---|
40 | OUT.color = float4(0);//IN.color;
|
---|
41 | OUT.texCoord = IN.texCoord;
|
---|
42 |
|
---|
43 | const float pos = (minMaxPos.x - IN.position.z) / (minMaxPos.x - minMaxPos.y);
|
---|
44 |
|
---|
45 | float factor = pos * windStrength * sin(timer * frequency);
|
---|
46 |
|
---|
47 | // transform the vertex position into post projection space
|
---|
48 | OUT.position = mul(glstate.matrix.mvp, IN.position);
|
---|
49 | // displace the input position
|
---|
50 | OUT.position += float4(factor * windDir, 0);
|
---|
51 |
|
---|
52 | // transform the vertex position into eye space
|
---|
53 | OUT.eyePos = mul(glstate.matrix.modelview[0], IN.position);
|
---|
54 | OUT.eyePos += float4(factor * windDir, 0);
|
---|
55 |
|
---|
56 | OUT.normal = IN.normal;
|
---|
57 |
|
---|
58 | return OUT;
|
---|
59 | } |
---|