[1493] | 1 | struct VS_OUTPUT {
|
---|
| 2 | float4 Pos: POSITION;
|
---|
| 3 | float3 normal: TEXCOORD0;
|
---|
| 4 | float3 lightVec : TEXCOORD1;
|
---|
| 5 | float3 viewVec: TEXCOORD2;
|
---|
| 6 | float4 shadowCrd: TEXCOORD3;
|
---|
| 7 | float2 texCoord: TEXCOORD4;
|
---|
| 8 | float2 texCoordNormalized: TEXCOORD5;
|
---|
| 9 | };
|
---|
| 10 |
|
---|
| 11 | float distanceScale;
|
---|
| 12 | float4 lattenuation;
|
---|
| 13 | float4 lightPosition;
|
---|
| 14 | float4 lightDirection;
|
---|
| 15 | float4 cameraPosition;
|
---|
| 16 | float4 cameraDirection;
|
---|
| 17 | float4x4 worldviewproj;
|
---|
| 18 | float4x4 worldmatrix;
|
---|
| 19 | float4x4 proj_matrix;
|
---|
| 20 | float4x4 texAdjMatrix;
|
---|
| 21 | float4x4 texMat;
|
---|
| 22 | float time_0_X;
|
---|
| 23 |
|
---|
| 24 | VS_OUTPUT main_vp(
|
---|
| 25 | float4 position : POSITION,
|
---|
| 26 | float3 normal : NORMAL,
|
---|
| 27 | float2 texCoord : TEXCOORD0,
|
---|
| 28 | float2 texCoordNormalized : TEXCOORD1,
|
---|
| 29 | float3 inTangent : TEXCOORD2,
|
---|
| 30 | float3 inBinormal : BINORMAL
|
---|
| 31 | )
|
---|
| 32 | {
|
---|
| 33 |
|
---|
| 34 | VS_OUTPUT Out;
|
---|
| 35 |
|
---|
| 36 | Out.Pos = mul(worldviewproj, position);
|
---|
| 37 | float4 worldpos = mul(worldmatrix,position);
|
---|
| 38 | Out.normal = normal;
|
---|
| 39 | Out.lightVec = lightPosition.xyz - worldpos.xyz;
|
---|
| 40 | Out.viewVec = cameraPosition.xyz - position.xyz;
|
---|
| 41 | Out.texCoord = texCoord;
|
---|
| 42 | Out.texCoordNormalized = texCoordNormalized;
|
---|
| 43 | //float4x4 texMat = mul(texMat,worldmatrix);
|
---|
| 44 | //float4x4 texMat = mul(worldmatrix,texMat);
|
---|
| 45 | //float4 sPos = mul(texMat,position);
|
---|
| 46 |
|
---|
| 47 | //float4 sPos = mul(mul(proj_matrix,worldmatrix),position);
|
---|
| 48 | float4 sPos = Out.Pos;
|
---|
| 49 | // Use projective texturing to map the position of each fragment
|
---|
| 50 | // to its corresponding texel in the shadow map.
|
---|
| 51 | sPos.z += 1.0;
|
---|
| 52 | //Out.shadowCrd.x = sPos.z + sPos.x;
|
---|
| 53 | //Out.shadowCrd.y = sPos.z - sPos.y;
|
---|
| 54 | //Out.shadowCrd.z = 0;
|
---|
| 55 | //Out.shadowCrd.w = sPos.z + sPos.z;
|
---|
| 56 | //Out.shadowCrd = sPos;
|
---|
| 57 | // Projective texture coordinates, adjust for mapping
|
---|
| 58 | float4x4 scalemat = float4x4(0.5, 0, 0, 0.5,
|
---|
| 59 | 0, -0.5, 0, 0.5,
|
---|
| 60 | 0, 0, 0.5, 0.5,
|
---|
| 61 | 0, 0, 0, 1);
|
---|
| 62 | Out.shadowCrd = mul(scalemat,sPos);
|
---|
| 63 |
|
---|
| 64 |
|
---|
| 65 |
|
---|
| 66 | return Out;
|
---|
| 67 | } |
---|