source: GTP/branches/IllumWPdeliver2008dec/IlluminationWP/demos/OgreDemos/media/MORIA/SkinningVS.cg @ 3255

Revision 3255, 4.6 KB checked in by szirmay, 15 years ago (diff)
Line 
1
2void trollSkinning_One_Weight_vp(
3        float4 position : POSITION,
4        float3 normal   : NORMAL,
5        float2 uv       : TEXCOORD0,
6        float3 tangent  : TANGENT,
7        float4  blendIdx : BLENDINDICES,
8        float4 blendWgt : BLENDWEIGHT,
9        out float4 oPosition : POSITION,
10        out float2 oUv       : TEXCOORD0,
11        //out float3 oTangent: TEXCOORD1,
12        //out float3 oBinormal: TEXCOORD2,
13        out float3 oNormal   : TEXCOORD3,
14        out float3 V: TEXCOORD4,
15        out float3 L1: TEXCOORD5,
16        out float3 L2: TEXCOORD6,
17        uniform float3x4   worldMatrix3x4Array[69],
18        uniform float4x4 viewProjectionMatrix,
19        uniform float4   lightPos1,
20        uniform float4   lightPos2,
21        uniform float4   cameraPos)
22{
23        // transform by indexed matrix
24        float4 blendPos = float4(0,0,0,1);
25        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[0]], position).xyz * blendWgt[0];
26        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[1]], position).xyz * blendWgt[1];
27       
28        // view / projection
29        oPosition = mul(viewProjectionMatrix, blendPos);
30        // transform normal
31        oNormal = mul((float3x3)worldMatrix3x4Array[blendIdx[0]], normal) * blendWgt[0];
32        oNormal += mul((float3x3)worldMatrix3x4Array[blendIdx[1]], normal) * blendWgt[1];
33        //oTangent = mul((float3x3)worldMatrix3x4Array[blendIdx], tangent);
34        oNormal = normalize(oNormal);
35//      oTangent = normalize(oTangent);
36//      oBinormal = cross(oTangent, oNormal);
37        // Lighting - support point and directional
38        L1 =  lightPos1.xyz - blendPos.xyz * lightPos1.w;
39        L2 =  lightPos2.xyz - blendPos.xyz * lightPos2.w;
40        V =  cameraPos.xyz - blendPos.xyz;
41       
42        oUv = uv;       
43}       
44
45
46void trollSkinning_SMGen_One_Weight_vp(
47        float4 position : POSITION,
48        float4  blendIdx : BLENDINDICES,
49        float4 blendWgt : BLENDWEIGHT, 
50        out float4 oPosition : POSITION,
51        out float3 cPos:TEXCOORD0,     
52        uniform float3x4   worldMatrix3x4Array[69],
53        uniform float4x4 viewMatrix,
54        uniform float4x4 viewProjectionMatrix)
55{
56        // transform by indexed matrix
57        float4 blendPos = float4(0,0,0,1);
58        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[0]], position).xyz * blendWgt[0];
59        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[1]], position).xyz * blendWgt[1];
60       
61        // view / projection
62        cPos = mul(viewMatrix, blendPos).xyz;
63        oPosition = mul(viewProjectionMatrix, blendPos);       
64}
65
66struct PS_IN
67{
68        float4 hPos:POSITION;
69        float2 texCoord:TEXCOORD0;
70        float3 tangent:TEXCOORD1;
71        float3 binormal:TEXCOORD2;
72        float3 normal:TEXCOORD3;
73        float3 V: TEXCOORD4;
74        float3 L1: TEXCOORD5;
75        float3 L2: TEXCOORD6;
76};
77
78PS_IN FPSArmSkinning_VP(float4 position : POSITION,
79                        float3 normal   : NORMAL,
80                        float3 tangent  : TANGENT,
81                        float2 uv       : TEXCOORD0,
82                        float4  blendIdx : BLENDINDICES,
83                        float4 blendWgt : BLENDWEIGHT,
84                        uniform float3x4   worldMatrix3x4Array[49],
85                        uniform float4x4 viewMatrix,
86                        uniform float4x4 viewProjectionMatrix,
87                        uniform float4   lightPos1,
88                        uniform float4   lightPos2,
89                        uniform float4   cameraPos)
90{
91        PS_IN OUT = (PS_IN) 0;
92        // transform by indexed matrix
93        float4 blendPos = float4(0,0,0,1);
94        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[0]], position).xyz * blendWgt[0];
95        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[1]], position).xyz * blendWgt[1];
96       
97        // view / projection
98        OUT.hPos = mul(viewProjectionMatrix, blendPos);
99        // transform normal
100        OUT.normal = mul((float3x3)worldMatrix3x4Array[blendIdx[0]], normal) * blendWgt[0];
101        OUT.normal += mul((float3x3)worldMatrix3x4Array[blendIdx[1]], normal) * blendWgt[1];
102        OUT.tangent = mul((float3x3)worldMatrix3x4Array[blendIdx[0]], tangent) * blendWgt[0];
103        OUT.tangent += mul((float3x3)worldMatrix3x4Array[blendIdx[1]], tangent) * blendWgt[1];
104        OUT.normal = normalize(OUT.normal);
105        OUT.tangent = normalize(OUT.tangent);
106        OUT.binormal = cross(OUT.tangent, OUT.normal);
107        // Lighting - support point and directional
108        OUT.L1 =  lightPos1.xyz - blendPos.xyz * lightPos1.w;
109        OUT.L2 =  lightPos2.xyz - blendPos.xyz * lightPos2.w;
110        OUT.V =  cameraPos.xyz - blendPos.xyz;
111       
112        OUT.texCoord = uv;
113
114        return OUT;     
115}
116
117void FPSArmSkinning_SMGen_VP(
118        float4 position : POSITION,
119        float4  blendIdx : BLENDINDICES,
120        float4 blendWgt : BLENDWEIGHT, 
121        out float4 oPosition : POSITION,
122        out float3 cPos:TEXCOORD0,     
123        uniform float3x4   worldMatrix3x4Array[49],
124        uniform float4x4 viewMatrix,
125        uniform float4x4 viewProjectionMatrix)
126{
127        // transform by indexed matrix
128        float4 blendPos = float4(0,0,0,1);
129        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[0]], position).xyz * blendWgt[0];
130        blendPos.xyz += mul(worldMatrix3x4Array[blendIdx[1]], position).xyz * blendWgt[1];
131       
132        // view / projection
133        cPos = mul(viewMatrix, blendPos).xyz;
134        oPosition = mul(viewProjectionMatrix, blendPos);       
135}
136       
Note: See TracBrowser for help on using the repository browser.