[2270] | 1 |
|
---|
| 2 | // gametools
|
---|
| 3 | #include \
|
---|
| 4 | <levelutil/shader/prog/d3d9_hlsl/include_stddef_d3d9_hlsl.s3d_shadercode_run>
|
---|
| 5 |
|
---|
| 6 |
|
---|
| 7 | struct VS_INPUT
|
---|
| 8 | {
|
---|
| 9 | float2 texCoord : TEXCOORD0;
|
---|
| 10 | float4 posObj: POSITION;
|
---|
| 11 | };
|
---|
| 12 |
|
---|
| 13 | struct VS_OUTPUT
|
---|
| 14 | {
|
---|
| 15 | float4 posScr: POSITION;
|
---|
| 16 | float2 center: TEXCOORD0;
|
---|
| 17 | float pointSize: PSIZE;
|
---|
| 18 | float radius :TEXCOORD1;
|
---|
| 19 | float4 color :TEXCOORD2;
|
---|
| 20 |
|
---|
| 21 | };
|
---|
| 22 |
|
---|
| 23 |
|
---|
| 24 | ///////////////////////////////////////////////////////////////////////////////
|
---|
| 25 | // Vertexshader
|
---|
| 26 | // Profile: 3x0
|
---|
| 27 | const float4x4 projMat;
|
---|
| 28 | const float4x4 matView;
|
---|
| 29 | const float4x4 matViewInv;
|
---|
| 30 | sampler tex0: register(s0);
|
---|
| 31 |
|
---|
| 32 | VS_OUTPUT main(VS_INPUT input)
|
---|
| 33 | {
|
---|
| 34 | float pointSize = 20;
|
---|
| 35 | float resolution = 128;
|
---|
| 36 |
|
---|
| 37 | VS_OUTPUT output = (VS_OUTPUT)0;
|
---|
| 38 |
|
---|
| 39 | output.pointSize = pointSize;
|
---|
| 40 | output.radius = pointSize / resolution;
|
---|
| 41 |
|
---|
| 42 | float4 pos = tex2Dlod(tex0, float4(input.posObj.x, input.posObj.y,0,0));
|
---|
| 43 |
|
---|
| 44 | //debug
|
---|
| 45 | //output.posScr = float4(input.posObj.xy *2.0 - 1.0, 0, 1);
|
---|
| 46 |
|
---|
| 47 | //output.posScr = pos;
|
---|
| 48 | output.center = output.posScr;
|
---|
| 49 |
|
---|
| 50 | //output.color = float4(1,0,1,1);
|
---|
| 51 | if(pos.w == 0)
|
---|
| 52 | {
|
---|
| 53 | output.center = 0.0f;
|
---|
| 54 | output.posScr = 1000.0f; //transform out of view
|
---|
| 55 | }
|
---|
| 56 | else
|
---|
| 57 | {
|
---|
| 58 | float4 mPosition = float4(normalize(pos.xyz),1);
|
---|
| 59 | float4 cPosition = mul(mPosition, matView);
|
---|
| 60 | float4 hPosition = mul(cPosition, projMat);
|
---|
| 61 |
|
---|
| 62 | output.posScr = hPosition;
|
---|
| 63 | output.center = float2(hPosition.x, hPosition.y) / hPosition.w;
|
---|
| 64 | }
|
---|
| 65 |
|
---|
| 66 |
|
---|
| 67 |
|
---|
| 68 |
|
---|
| 69 | return output;
|
---|
| 70 | }
|
---|
| 71 |
|
---|
| 72 | ///////////////////////////////////////////////////////////////////////////////
|
---|