Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: data/branches/Shader_HS18/programs/Cg/instancing.cg @ 12115

Last change on this file since 12115 was 12115, checked in by wiesep, 5 years ago

Changed folder structure, deletet some unused files and cleaned up code

File size: 1.4 KB
Line 
1
2
3void 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*/
35void 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}
Note: See TracBrowser for help on using the repository browser.