| [390] | 1 |  | 
|---|
 | 2 |  | 
|---|
 | 3 | void instancing_vp(uniform float3x4   worldMatrix3x4Array[80], float4 position : POSITION, | 
|---|
 | 4 |                                                 float3 normal : NORMAL, | 
|---|
 | 5 |                                                 float2 uv : TEXCOORD0, | 
|---|
 | 6 |                                                 float index : TEXCOORD1, | 
|---|
 | 7 |                                                 uniform float4x4 viewProjectionMatrix, | 
|---|
 | 8 |                                                 uniform float4 lightPos, | 
|---|
 | 9 |                                                 uniform float4 ambient, | 
|---|
 | 10 |                                                 uniform float4 lightDiffuseColour, | 
|---|
 | 11 |                                                 out float4 oPosition : POSITION, | 
|---|
 | 12 |                                                 out float2 oUv : TEXCOORD0, | 
|---|
 | 13 |                                                 out float4 Color : COLOR ) | 
|---|
 | 14 | { | 
|---|
 | 15 |         // transform by indexed matrix | 
|---|
 | 16 |         float4 transformedPos = float4(mul(worldMatrix3x4Array[index], position).xyz, 1.0); | 
|---|
 | 17 |          | 
|---|
 | 18 |         // view / projection | 
|---|
 | 19 |         oPosition = mul(viewProjectionMatrix, transformedPos); | 
|---|
 | 20 |         oUv = uv; | 
|---|
 | 21 |  | 
|---|
 | 22 |         float3 norm = mul((float3x3)worldMatrix3x4Array[index], normal); | 
|---|
 | 23 |          | 
|---|
 | 24 |         float3 lightDir =       normalize( | 
|---|
 | 25 |                 lightPos.xyz -  (transformedPos.xyz * lightPos.w)); | 
|---|
 | 26 |  | 
|---|
 | 27 |         Color = ambient + saturate(dot(lightDir, norm)) * lightDiffuseColour; | 
|---|
 | 28 |          | 
|---|
 | 29 |          | 
|---|
 | 30 | } | 
|---|
 | 31 |  | 
|---|
 | 32 | /* | 
|---|
 | 33 |   Instancing shadow-caster pass | 
|---|
 | 34 | */ | 
|---|
 | 35 | void instancingCaster_vp( | 
|---|
 | 36 |         float4 position : POSITION, | 
|---|
 | 37 |         float3 normal   : NORMAL, | 
|---|
 | 38 |         float index     : TEXCOORD1, | 
|---|
 | 39 |  | 
|---|
 | 40 |         out float4 oPosition : POSITION, | 
|---|
 | 41 |         out float4 colour    : COLOR, | 
|---|
 | 42 |         // Support up to 80 bones of float3x4 | 
|---|
 | 43 |         uniform float3x4   worldMatrix3x4Array[80], | 
|---|
 | 44 |         uniform float4x4 viewProjectionMatrix, | 
|---|
 | 45 |         uniform float4   ambient) | 
|---|
 | 46 | { | 
|---|
 | 47 |         // transform by indexed matrix | 
|---|
 | 48 |         float4 transformedPos = float4(mul(worldMatrix3x4Array[index], position).xyz, 1.0); | 
|---|
 | 49 |  | 
|---|
 | 50 |         // view / projection | 
|---|
 | 51 |         oPosition = mul(viewProjectionMatrix, transformedPos); | 
|---|
 | 52 |          | 
|---|
 | 53 |         colour = ambient; | 
|---|
 | 54 |          | 
|---|
 | 55 | } | 
|---|
 | 56 | void crowd_vp( | 
|---|
 | 57 |         float4 position : POSITION, | 
|---|
 | 58 |         float3 normal   : NORMAL, | 
|---|
 | 59 |         float2 uv       : TEXCOORD0, | 
|---|
 | 60 |         float4  blendIdx : BLENDINDICES, | 
|---|
 | 61 |         float4  blendWgt : BLENDWEIGHT, | 
|---|
 | 62 |         float   index : TEXCOORD1, | 
|---|
 | 63 |  | 
|---|
 | 64 |         out float4 oPosition : POSITION, | 
|---|
 | 65 |         out float2 oUv       : TEXCOORD0, | 
|---|
 | 66 |         out float4 colour           : COLOR, | 
|---|
 | 67 |         // Support up to 20 bones of float3x4 | 
|---|
 | 68 |         // vs_2_0 only supports 256 params so more than this is not feasible | 
|---|
 | 69 |         uniform float4x4 viewProjectionMatrix, | 
|---|
 | 70 |         uniform float numBones, | 
|---|
 | 71 |         uniform float3x4   worldMatrix3x4Array[80], | 
|---|
 | 72 |         uniform float4 lightDiffuseColour, | 
|---|
 | 73 |         uniform float4 ambient, | 
|---|
 | 74 |         uniform float4 lightPos) | 
|---|
 | 75 | { | 
|---|
 | 76 |         // transform by indexed matrix | 
|---|
 | 77 |         float4 blendPos = float4(0,0,0,0); | 
|---|
 | 78 |         int i; | 
|---|
 | 79 |         for (i = 0; i < 4; ++i) | 
|---|
 | 80 |         { | 
|---|
 | 81 |                 blendPos += float4(mul(worldMatrix3x4Array[index*numBones+blendIdx[i]], position).xyz, 1.0) * blendWgt[i]; | 
|---|
 | 82 |         } | 
|---|
 | 83 |         // view / projection | 
|---|
 | 84 |         oPosition = mul(viewProjectionMatrix, blendPos); | 
|---|
 | 85 |         oUv = uv; | 
|---|
 | 86 |         float3 norm = float3(0,0,0); | 
|---|
 | 87 |         for (i = 0; i < 4; ++i) | 
|---|
 | 88 |         { | 
|---|
 | 89 |                 norm += mul((float3x3)worldMatrix3x4Array[index*numBones+blendIdx[i]], normal)* blendWgt[i]; | 
|---|
 | 90 |         } | 
|---|
 | 91 |         float3 lightDir =       normalize( | 
|---|
 | 92 |                 lightPos.xyz -  (blendPos.xyz * lightPos.w)); | 
|---|
 | 93 |  | 
|---|
 | 94 |         colour = ambient + saturate(dot(lightDir, norm)) * lightDiffuseColour; | 
|---|
 | 95 |  | 
|---|
 | 96 |          | 
|---|
 | 97 | } | 
|---|
 | 98 |  | 
|---|
 | 99 | /* | 
|---|
 | 100 |   Single-weight-per-vertex hardware skinning, shadow-caster pass | 
|---|
 | 101 | */ | 
|---|
 | 102 | void crowdCaster_vp( | 
|---|
 | 103 |         float4 position : POSITION, | 
|---|
 | 104 |         float3 normal   : NORMAL, | 
|---|
 | 105 |         float  blendIdx : BLENDINDICES, | 
|---|
 | 106 |         float index     : TEXCOORD1, | 
|---|
 | 107 |  | 
|---|
 | 108 |         out float4 oPosition : POSITION, | 
|---|
 | 109 |         out float4 colour    : COLOR, | 
|---|
 | 110 |         // Support up to 24 bones of float3x4 | 
|---|
 | 111 |         // vs_1_1 only supports 96 params so more than this is not feasible | 
|---|
 | 112 |         uniform float3x4   worldMatrix3x4Array[80], | 
|---|
 | 113 |         uniform float4x4 viewProjectionMatrix, | 
|---|
 | 114 |         uniform float numBones, | 
|---|
 | 115 |         uniform float4   ambient) | 
|---|
 | 116 | { | 
|---|
 | 117 |         // transform by indexed matrix | 
|---|
 | 118 |         float4 blendPos = float4(mul(worldMatrix3x4Array[index*numBones+blendIdx], position).xyz, 1.0); | 
|---|
 | 119 |  | 
|---|
 | 120 |         // view / projection | 
|---|
 | 121 |         oPosition = mul(viewProjectionMatrix, blendPos); | 
|---|
 | 122 |          | 
|---|
 | 123 |         colour = ambient; | 
|---|
 | 124 |          | 
|---|
 | 125 | }        | 
|---|