1 | ///////////////////////////////////////////////////////////////////////////////
|
---|
2 | //
|
---|
3 | // ## ######
|
---|
4 | // ###### ###
|
---|
5 | // ## ############### Shark 3D Engine (www.shark3d.com)
|
---|
6 | // ########## # # #
|
---|
7 | // ######## Copyright (c) 1996-2006 Spinor GmbH.
|
---|
8 | // ######### # # # All rights reserved.
|
---|
9 | // ## ##########
|
---|
10 | // ##
|
---|
11 | //
|
---|
12 | ///////////////////////////////////////////////////////////////////////////////
|
---|
13 |
|
---|
14 | struct VS_INPUT
|
---|
15 | {
|
---|
16 | float4 posObj: POSITION;
|
---|
17 | float2 mainTexCoord: TEXCOORD0;
|
---|
18 | };
|
---|
19 |
|
---|
20 | struct VS_OUTPUT
|
---|
21 | {
|
---|
22 | float4 posScr: POSITION;
|
---|
23 | float fog: FOG;
|
---|
24 | float4 diffuse: COLOR0;
|
---|
25 | float2 mainTexCoord: TEXCOORD0;
|
---|
26 | float4 baseVec: TEXCOORD2;
|
---|
27 | };
|
---|
28 |
|
---|
29 | ///////////////////////////////////////////////////////////////////////////////
|
---|
30 |
|
---|
31 | const float4x4 matProjView;
|
---|
32 | const float4x4 matView;
|
---|
33 | const float4 mtrlEmissive;
|
---|
34 |
|
---|
35 | const float4 passInfo;
|
---|
36 | const float4 tex0RcpSize;
|
---|
37 |
|
---|
38 | ///////////////////////////////////////////////////////////////////////////////
|
---|
39 | // Vertexshader
|
---|
40 | // Profile: 1x1
|
---|
41 |
|
---|
42 | VS_OUTPUT main( VS_INPUT input )
|
---|
43 | {
|
---|
44 | VS_OUTPUT output = (VS_OUTPUT)0;
|
---|
45 |
|
---|
46 | //Transform position to clip space
|
---|
47 | output.posScr = mul(input.posObj, matProjView);
|
---|
48 |
|
---|
49 | //Transform position to eye space -> pos
|
---|
50 | float4 posView = mul(input.posObj, matView);
|
---|
51 |
|
---|
52 | //fog
|
---|
53 | output.fog = posView.z / posView.w;
|
---|
54 |
|
---|
55 | //Color
|
---|
56 | output.diffuse = mtrlEmissive;
|
---|
57 |
|
---|
58 | // Texture coordinates
|
---|
59 | output.mainTexCoord = input.mainTexCoord;
|
---|
60 |
|
---|
61 | // Scaling offset
|
---|
62 | int iter = passInfo.x;
|
---|
63 |
|
---|
64 | // Use fractional basis value to reduce banding:
|
---|
65 | float2 offsScale = tex0RcpSize * pow(2.1, iter) * 0.5;
|
---|
66 |
|
---|
67 | float4 dirVec;
|
---|
68 | int fiter = fmod(iter, 4.0);
|
---|
69 | if(fiter < 2.0)
|
---|
70 | {
|
---|
71 | if(fiter < 1.0)
|
---|
72 | dirVec = float4(1, 0, 0, 1); // Vectors (1, 0) and (0, 1)
|
---|
73 | else
|
---|
74 | dirVec = float4(1, 1,-1, 1); // Vectors (1, 1) and (-1, 1)
|
---|
75 | }
|
---|
76 | else
|
---|
77 | {
|
---|
78 | if(fiter < 3.0)
|
---|
79 | dirVec = float4(2, 1,-1, 2); // Vectors (2, 1) and (-1, 2)
|
---|
80 | else
|
---|
81 | dirVec = float4(1, 2,-2, 1); // Vectors (1, 2) and (-2, 1)
|
---|
82 | }
|
---|
83 |
|
---|
84 | output.baseVec = dirVec * offsScale.xyxy;
|
---|
85 |
|
---|
86 | return output;
|
---|
87 | }
|
---|
88 |
|
---|
89 | ///////////////////////////////////////////////////////////////////////////////
|
---|