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 | } |
---|