Advertisement
Guest User

Untitled

a guest
Jul 8th, 2014
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 23.87 KB | None | 0 0
  1. /*
  2.   FOUR WEIGHT ENVMAP SKINNING
  3. */
  4. void hardwareSkinningSecondary_vp(
  5.     uniform float4x4 texViewProj,
  6.     uniform float4   ambient,
  7.     uniform float4   diffuse,
  8.     uniform float4   emissive,
  9.     float4 position : POSITION,
  10.     float3 normal   : NORMAL,
  11.     float2 uv       : TEXCOORD0,
  12.     float3 uv1       : TEXCOORD1,
  13.     float4 blendIdx : BLENDINDICES,
  14.     float4 blendWgt : BLENDWEIGHT,
  15.    
  16.  
  17.     out float4 oPosition : POSITION,
  18.     out float2 oUv       : TEXCOORD0,
  19.     out float2 oUv1       : TEXCOORD1,
  20.     out float3 oUv2       : TEXCOORD2,
  21.     out float4 colour           : COLOR,
  22.     // Support up to 24 bones of float3x4
  23.     // vs_1_1 only supports 96 params so more than this is not feasible
  24.     uniform float3x4   worldMatrix3x4Array[64],
  25.     uniform float4x4 viewProjectionMatrix,
  26.     uniform float4x4 viewMatrix,
  27.     uniform float4   lightPos[1],
  28.     uniform float4   lightDiffuseColour[1])
  29. {
  30.     // transform by indexed matrix
  31.     float4 blendPos = float4(0,0,0,0);
  32.     int i;
  33.     for (i = 0; i < 4; ++i)
  34.     {
  35.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  36.     }
  37.     // view / projection
  38.     oPosition = mul(viewProjectionMatrix, blendPos);
  39.     // transform normal
  40.     float3 norm = float3(0,0,0);
  41.     for (i = 0; i < 4; ++i)
  42.     {
  43.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  44.         blendWgt[i];
  45.     }
  46.     norm = normalize(norm);
  47.     // Lighting - support point and directional
  48.     float3 lightDir0 =  normalize(
  49.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  50.  
  51.    
  52.     oUv = uv;
  53.     oUv1 = uv;
  54.  
  55.    
  56.  
  57.     colour = ambient * diffuse +
  58.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  59.            emissive;
  60.     colour = saturate( colour );
  61.     colour.a=1;
  62.  
  63.     norm = mul( (float3x3)viewMatrix, norm );
  64.     norm = mul( (float3x3)texViewProj, norm );
  65.  
  66.  
  67.     oUv2 = norm;
  68. }
  69.  
  70. /*
  71.   THREE WEIGHT ENVMAP SKINNING
  72. */
  73. void hardwareSkinningThreeSecondary_vp(
  74.     uniform float4x4 texViewProj,
  75.     uniform float4   ambient,
  76.     uniform float4   diffuse,
  77.     uniform float4   emissive,
  78.     float4 position : POSITION,
  79.     float3 normal   : NORMAL,
  80.     float2 uv       : TEXCOORD0,
  81.     float3 uv1       : TEXCOORD1,
  82.     float4 blendIdx : BLENDINDICES,
  83.     float4 blendWgt : BLENDWEIGHT,
  84.    
  85.  
  86.     out float4 oPosition : POSITION,
  87.     out float2 oUv       : TEXCOORD0,
  88.     out float2 oUv1       : TEXCOORD1,
  89.     out float3 oUv2       : TEXCOORD2,
  90.     out float4 colour           : COLOR,
  91.     // Support up to 24 bones of float3x4
  92.     // vs_1_1 only supports 96 params so more than this is not feasible
  93.     uniform float3x4   worldMatrix3x4Array[64],
  94.     uniform float4x4 viewProjectionMatrix,
  95.     uniform float4x4 viewMatrix,
  96.     uniform float4   lightPos[1],
  97.     uniform float4   lightDiffuseColour[1])
  98. {
  99.     // transform by indexed matrix
  100.     float4 blendPos = float4(0,0,0,0);
  101.     int i;
  102.     for (i = 0; i < 3; ++i)
  103.     {
  104.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  105.     }
  106.     // view / projection
  107.     oPosition = mul(viewProjectionMatrix, blendPos);
  108.     // transform normal
  109.     float3 norm = float3(0,0,0);
  110.     for (i = 0; i < 3; ++i)
  111.     {
  112.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  113.         blendWgt[i];
  114.     }
  115.     norm = normalize(norm);
  116.     // Lighting - support point and directional
  117.     float3 lightDir0 =  normalize(
  118.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  119.  
  120.    
  121.     oUv = uv;
  122.     oUv1 = uv;
  123.  
  124.    
  125.  
  126.     colour = ambient * diffuse +
  127.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  128.            emissive;
  129.     colour = saturate( colour );
  130.     colour.a=1;
  131.  
  132.     norm = mul( (float3x3)viewMatrix, norm );
  133.     norm = mul( (float3x3)texViewProj, norm );
  134.  
  135.     oUv2 = norm;
  136. }
  137.  
  138. /*
  139.   TWO WEIGHT ENVMAP SKINNING
  140. */
  141. void hardwareSkinningTwoSecondary_vp(
  142.     uniform float4x4 texViewProj,
  143.     uniform float4   ambient,
  144.     uniform float4   diffuse,
  145.     uniform float4   emissive,
  146.     float4 position : POSITION,
  147.     float3 normal   : NORMAL,
  148.     float2 uv       : TEXCOORD0,
  149.     float3 uv1       : TEXCOORD1,
  150.     float4 blendIdx : BLENDINDICES,
  151.     float4 blendWgt : BLENDWEIGHT,
  152.    
  153.  
  154.     out float4 oPosition : POSITION,
  155.     out float2 oUv       : TEXCOORD0,
  156.     out float2 oUv1       : TEXCOORD1,
  157.     out float3 oUv2       : TEXCOORD2,
  158.     out float4 colour           : COLOR,
  159.     // Support up to 24 bones of float3x4
  160.     // vs_1_1 only supports 96 params so more than this is not feasible
  161.     uniform float3x4   worldMatrix3x4Array[64],
  162.     uniform float4x4 viewProjectionMatrix,
  163.     uniform float4x4 viewMatrix,
  164.     uniform float4   lightPos[1],
  165.     uniform float4   lightDiffuseColour[1])
  166. {
  167.     // transform by indexed matrix
  168.     float4 blendPos = float4(0,0,0,0);
  169.     int i;
  170.     for (i = 0; i < 2; ++i)
  171.     {
  172.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  173.     }
  174.     // view / projection
  175.     oPosition = mul(viewProjectionMatrix, blendPos);
  176.     // transform normal
  177.     float3 norm = float3(0,0,0);
  178.     for (i = 0; i < 2; ++i)
  179.     {
  180.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  181.         blendWgt[i];
  182.     }
  183.     norm = normalize(norm);
  184.     // Lighting - support point and directional
  185.     float3 lightDir0 =  normalize(
  186.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  187.  
  188.    
  189.     oUv = uv;
  190.     oUv1 = uv;
  191.  
  192.    
  193.  
  194.     colour = ambient * diffuse +
  195.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  196.            emissive;
  197.     colour = saturate( colour );
  198.     colour.a=1;
  199.  
  200.     norm = mul( (float3x3)viewMatrix, norm );
  201.     norm = mul( (float3x3)texViewProj, norm );
  202.  
  203.     oUv2 = norm;
  204. }
  205.  
  206. /*
  207.   ONE WEIGHT ENVMAP SKINNING
  208. */
  209. void hardwareSkinningOneSecondary_vp(
  210.     uniform float4x4 texViewProj,
  211.     uniform float4   ambient,
  212.     uniform float4   diffuse,
  213.     uniform float4   emissive,
  214.     float4 position : POSITION,
  215.     float3 normal   : NORMAL,
  216.     float2 uv       : TEXCOORD0,
  217.     float3 uv1       : TEXCOORD1,
  218.     float4 blendIdx : BLENDINDICES,
  219.     float4 blendWgt : BLENDWEIGHT,
  220.    
  221.  
  222.     out float4 oPosition : POSITION,
  223.     out float2 oUv       : TEXCOORD0,
  224.     out float2 oUv1       : TEXCOORD1,
  225.     out float3 oUv2       : TEXCOORD2,
  226.     out float4 colour           : COLOR,
  227.     // Support up to 24 bones of float3x4
  228.     // vs_1_1 only supports 96 params so more than this is not feasible
  229.     uniform float3x4   worldMatrix3x4Array[64],
  230.     uniform float4x4 viewProjectionMatrix,
  231.     uniform float4x4 viewMatrix,
  232.     uniform float4   lightPos[1],
  233.     uniform float4   lightDiffuseColour[1])
  234. {
  235.     // transform by indexed matrix
  236.     float4 blendPos = float4(0,0,0,0);
  237.     int i;
  238.     for (i = 0; i < 1; ++i)
  239.     {
  240.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  241.     }
  242.     // view / projection
  243.     oPosition = mul(viewProjectionMatrix, blendPos);
  244.     // transform normal
  245.     float3 norm = float3(0,0,0);
  246.     for (i = 0; i < 1; ++i)
  247.     {
  248.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  249.         blendWgt[i];
  250.     }
  251.     norm = normalize(norm);
  252.     // Lighting - support point and directional
  253.     float3 lightDir0 =  normalize(
  254.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  255.  
  256.    
  257.     oUv = uv;
  258.     oUv1 = uv;
  259.  
  260.    
  261.  
  262.     colour = ambient * diffuse +
  263.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  264.            emissive;
  265.     colour = saturate( colour );
  266.     colour.a=1;
  267.  
  268.     norm = mul( (float3x3)viewMatrix, norm );
  269.     norm = mul( (float3x3)texViewProj, norm );
  270.  
  271.     oUv2 = norm;
  272. }
  273.  
  274.  
  275. /*
  276.   FOUR WEIGHT SKINNING
  277. */
  278. void hardwareSkinning_vp(
  279.     uniform float4x4 texViewProj,
  280.     uniform float4   ambient,
  281.     uniform float4   diffuse,
  282.     uniform float4   emissive,
  283.     float4 position : POSITION,
  284.     float3 normal   : NORMAL,
  285.     float2 uv       : TEXCOORD0,
  286.     float3 uv1       : TEXCOORD1,
  287.     float4 blendIdx : BLENDINDICES,
  288.     float4 blendWgt : BLENDWEIGHT,
  289.    
  290.  
  291.     out float4 oPosition : POSITION,
  292.     out float2 oUv       : TEXCOORD0,
  293.     out float3 oUv1       : TEXCOORD1,
  294.     out float4 colour           : COLOR,
  295.     // Support up to 24 bones of float3x4
  296.     // vs_1_1 only supports 96 params so more than this is not feasible
  297.     uniform float3x4   worldMatrix3x4Array[64],
  298.     uniform float4x4 viewProjectionMatrix,
  299.     uniform float4x4 viewMatrix,
  300.     uniform float4   lightPos[1],
  301.     uniform float4   lightDiffuseColour[1])
  302. {
  303.     // transform by indexed matrix
  304.     float4 blendPos = float4(0,0,0,0);
  305.     int i;
  306.     for (i = 0; i < 4; ++i)
  307.     {
  308.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  309.     }
  310.     // view / projection
  311.     oPosition = mul(viewProjectionMatrix, blendPos);
  312.     // transform normal
  313.     float3 norm = float3(0,0,0);
  314.     for (i = 0; i < 4; ++i)
  315.     {
  316.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  317.         blendWgt[i];
  318.     }
  319.     norm = normalize(norm);
  320.     // Lighting - support point and directional
  321.     float3 lightDir0 =  normalize(
  322.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  323.  
  324.    
  325.     oUv = uv;
  326.  
  327.    
  328.  
  329.     colour = ambient * diffuse +
  330.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  331.            emissive;
  332.     colour = saturate( colour );
  333.     colour.a=1;
  334.  
  335.     norm = mul( (float3x3)viewMatrix, norm );
  336.     norm = mul( (float3x3)texViewProj, norm );
  337.  
  338.  
  339.     oUv1 = norm;
  340. }
  341.  
  342.  
  343. /*
  344.     THREE WEIGHT SKINNING
  345. */
  346. void hardwareSkinningThree_vp(
  347.     uniform float4x4 texViewProj,
  348.     uniform float4   ambient,
  349.     uniform float4   diffuse,
  350.     uniform float4   emissive,
  351.     float4 position : POSITION,
  352.     float3 normal   : NORMAL,
  353.     float2 uv       : TEXCOORD0,
  354.     float3 uv1       : TEXCOORD1,
  355.     float4 blendIdx : BLENDINDICES,
  356.     float4 blendWgt : BLENDWEIGHT,
  357.    
  358.  
  359.     out float4 oPosition : POSITION,
  360.     out float2 oUv       : TEXCOORD0,
  361.     out float3 oUv1       : TEXCOORD1,
  362.     out float4 colour           : COLOR,
  363.     // Support up to 24 bones of float3x4
  364.     // vs_1_1 only supports 96 params so more than this is not feasible
  365.     uniform float3x4   worldMatrix3x4Array[64],
  366.     uniform float4x4 viewProjectionMatrix,
  367.     uniform float4x4 viewMatrix,
  368.     uniform float4   lightPos[1],
  369.     uniform float4   lightDiffuseColour[1])
  370. {
  371.     // transform by indexed matrix
  372.     float4 blendPos = float4(0,0,0,0);
  373.     int i;
  374.     for (i = 0; i < 3; ++i)
  375.     {
  376.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  377.     }
  378.     // view / projection
  379.     oPosition = mul(viewProjectionMatrix, blendPos);
  380.     // transform normal
  381.     float3 norm = float3(0,0,0);
  382.     for (i = 0; i < 3; ++i)
  383.     {
  384.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  385.         blendWgt[i];
  386.     }
  387.     norm = normalize(norm);
  388.     // Lighting - support point and directional
  389.     float3 lightDir0 =  normalize(
  390.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  391.  
  392.    
  393.     oUv = uv;
  394.  
  395.    
  396.  
  397.     colour = ambient * diffuse +
  398.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  399.            emissive;
  400.     colour = saturate( colour );
  401.     colour.a=1;
  402.  
  403.     norm = mul( (float3x3)viewMatrix, norm );
  404.     norm = mul( (float3x3)texViewProj, norm );
  405.  
  406.     oUv1 = norm;
  407. }
  408.  
  409.  
  410. /*
  411.     TWO WEIGHT SKINNING
  412. */
  413. void hardwareSkinningTwo_vp(
  414.     uniform float4x4 texViewProj,
  415.     uniform float4   ambient,
  416.     uniform float4   diffuse,
  417.     uniform float4   emissive,
  418.     float4 position : POSITION,
  419.     float3 normal   : NORMAL,
  420.     float2 uv       : TEXCOORD0,
  421.     float3 uv1       : TEXCOORD1,
  422.     float4 blendIdx : BLENDINDICES,
  423.     float4 blendWgt : BLENDWEIGHT,
  424.    
  425.  
  426.     out float4 oPosition : POSITION,
  427.     out float2 oUv       : TEXCOORD0,
  428.     out float3 oUv1       : TEXCOORD1,
  429.     out float4 colour           : COLOR,
  430.     // Support up to 24 bones of float3x4
  431.     // vs_1_1 only supports 96 params so more than this is not feasible
  432.     uniform float3x4   worldMatrix3x4Array[64],
  433.     uniform float4x4 viewProjectionMatrix,
  434.     uniform float4x4 viewMatrix,
  435.     uniform float4   lightPos[1],
  436.     uniform float4   lightDiffuseColour[1])
  437. {
  438.     // transform by indexed matrix
  439.     float4 blendPos = float4(0,0,0,0);
  440.     int i;
  441.     for (i = 0; i < 2; ++i)
  442.     {
  443.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  444.     }
  445.     // view / projection
  446.     oPosition = mul(viewProjectionMatrix, blendPos);
  447.     // transform normal
  448.     float3 norm = float3(0,0,0);
  449.     for (i = 0; i < 2; ++i)
  450.     {
  451.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  452.         blendWgt[i];
  453.     }
  454.     norm = normalize(norm);
  455.     // Lighting - support point and directional
  456.     float3 lightDir0 =  normalize(
  457.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  458.  
  459.    
  460.     oUv = uv;
  461.  
  462.    
  463.  
  464.     colour = ambient * diffuse +
  465.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  466.            emissive;
  467.     colour = saturate( colour );
  468.     colour.a=1;
  469.  
  470.     norm = mul( (float3x3)viewMatrix, norm );
  471.     norm = mul( (float3x3)texViewProj, norm );
  472.  
  473.     oUv1 = norm;
  474. }
  475.  
  476.  
  477.  
  478. /*
  479.     ONE WEIGHT SKINNING
  480. */
  481. void hardwareSkinningOne_vp(
  482.     uniform float4x4 texViewProj,
  483.     uniform float4   ambient,
  484.     uniform float4   diffuse,
  485.     uniform float4   emissive,
  486.     float4 position : POSITION,
  487.     float3 normal   : NORMAL,
  488.     float2 uv       : TEXCOORD0,
  489.     float3 uv1       : TEXCOORD1,
  490.     float4 blendIdx : BLENDINDICES,
  491.     float4 blendWgt : BLENDWEIGHT,
  492.    
  493.  
  494.     out float4 oPosition : POSITION,
  495.     out float2 oUv       : TEXCOORD0,
  496.     out float3 oUv1       : TEXCOORD1,
  497.     out float4 colour           : COLOR,
  498.     // Support up to 24 bones of float3x4
  499.     // vs_1_1 only supports 96 params so more than this is not feasible
  500.     uniform float3x4   worldMatrix3x4Array[64],
  501.     uniform float4x4 viewProjectionMatrix,
  502.     uniform float4x4 viewMatrix,
  503.     uniform float4   lightPos[1],
  504.     uniform float4   lightDiffuseColour[1])
  505. {
  506.     // transform by indexed matrix
  507.     float4 blendPos = float4(0,0,0,0);
  508.     int i;
  509.     for (i = 0; i < 1; ++i)
  510.     {
  511.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  512.     }
  513.     // view / projection
  514.     oPosition = mul(viewProjectionMatrix, blendPos);
  515.     // transform normal
  516.     float3 norm = float3(0,0,0);
  517.     for (i = 0; i < 1; ++i)
  518.     {
  519.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  520.         blendWgt[i];
  521.     }
  522.     norm = normalize(norm);
  523.     // Lighting - support point and directional
  524.     float3 lightDir0 =  normalize(
  525.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  526.  
  527.    
  528.     oUv = uv;
  529.  
  530.    
  531.  
  532.     colour = ambient * diffuse +
  533.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  534.            emissive;
  535.     colour = saturate( colour );
  536.     colour.a=1;
  537.  
  538.     norm = mul( (float3x3)viewMatrix, norm );
  539.     norm = mul( (float3x3)texViewProj, norm );
  540.  
  541.     oUv1 = norm;
  542. }
  543.  
  544. /*
  545.   FOUR WEIGHT SKINNING BEHIND
  546. */
  547. void hardwareSkinningBehind_vp(
  548.     uniform float4x4 texViewProj,
  549.     uniform float4   ambient,
  550.     uniform float4   diffuse,
  551.     uniform float4   emissive,
  552.     float4 position : POSITION,
  553.     float3 normal   : NORMAL,
  554.     float2 uv       : TEXCOORD0,
  555.     float4 blendIdx : BLENDINDICES,
  556.     float4 blendWgt : BLENDWEIGHT,
  557.    
  558.  
  559.     out float4 oPosition : POSITION,
  560.     out float2 oUv       : TEXCOORD0,
  561.     out float4 colour           : COLOR,
  562.     // Support up to 24 bones of float3x4
  563.     // vs_1_1 only supports 96 params so more than this is not feasible
  564.     uniform float3x4   worldMatrix3x4Array[64],
  565.     uniform float4x4 viewProjectionMatrix,
  566.     uniform float4x4 viewMatrix,
  567.     uniform float4   lightPos[1],
  568.     uniform float4   lightDiffuseColour[1])
  569. {
  570.     // transform by indexed matrix
  571.     float4 blendPos = float4(0,0,0,0);
  572.     int i;
  573.     for (i = 0; i < 4; ++i)
  574.     {
  575.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  576.     }
  577.     // view / projection
  578.     oPosition = mul(viewProjectionMatrix, blendPos);
  579.     // transform normal
  580.     float3 norm = float3(0,0,0);
  581.     for (i = 0; i < 4; ++i)
  582.     {
  583.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  584.         blendWgt[i];
  585.     }
  586.     norm = normalize(norm);
  587.     // Lighting - support point and directional
  588.     float3 lightDir0 =  normalize(
  589.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  590.  
  591.  
  592.    
  593.  
  594.     colour = ambient * diffuse +
  595.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  596.            emissive;
  597.     colour = saturate( colour );
  598.     colour.a=1;
  599.  
  600.  
  601.  
  602.     norm = mul( (float3x3)viewMatrix, norm );
  603.     norm.xy *= .5;
  604.     norm.xy += .5;
  605.     norm.y *= -1.0;
  606.     oUv = norm;
  607. }
  608.  
  609. /*
  610.   THREE WEIGHT SKINNING BEHIND
  611. */
  612. void hardwareSkinningBehindThree_vp(
  613.     uniform float4x4 texViewProj,
  614.     uniform float4   ambient,
  615.     uniform float4   diffuse,
  616.     uniform float4   emissive,
  617.     float4 position : POSITION,
  618.     float3 normal   : NORMAL,
  619.     float2 uv       : TEXCOORD0,
  620.     float4 blendIdx : BLENDINDICES,
  621.     float4 blendWgt : BLENDWEIGHT,
  622.    
  623.  
  624.     out float4 oPosition : POSITION,
  625.     out float2 oUv       : TEXCOORD0,
  626.     out float4 colour           : COLOR,
  627.     // Support up to 24 bones of float3x4
  628.     // vs_1_1 only supports 96 params so more than this is not feasible
  629.     uniform float3x4   worldMatrix3x4Array[64],
  630.     uniform float4x4 viewProjectionMatrix,
  631.     uniform float4x4 viewMatrix,
  632.     uniform float4   lightPos[1],
  633.     uniform float4   lightDiffuseColour[1])
  634. {
  635.     // transform by indexed matrix
  636.     float4 blendPos = float4(0,0,0,0);
  637.     int i;
  638.     for (i = 0; i < 3; ++i)
  639.     {
  640.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  641.     }
  642.     // view / projection
  643.     oPosition = mul(viewProjectionMatrix, blendPos);
  644.     // transform normal
  645.     float3 norm = float3(0,0,0);
  646.     for (i = 0; i < 3; ++i)
  647.     {
  648.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  649.         blendWgt[i];
  650.     }
  651.     norm = normalize(norm);
  652.     // Lighting - support point and directional
  653.     float3 lightDir0 =  normalize(
  654.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  655.  
  656.  
  657.    
  658.  
  659.     colour = ambient * diffuse +
  660.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  661.            emissive;
  662.     colour = saturate( colour );
  663.     colour.a=1;
  664.  
  665.  
  666.  
  667.     norm = mul( (float3x3)viewMatrix, norm );
  668.     norm.xy *= .5;
  669.     norm.xy += .5;
  670.     norm.y *= -1.0;
  671.     oUv = norm;
  672. }
  673.  
  674.  
  675.  
  676. /*
  677.   TWO WEIGHT SKINNING BEHIND
  678. */
  679. void hardwareSkinningBehindTwo_vp(
  680.     uniform float4x4 texViewProj,
  681.     uniform float4   ambient,
  682.     uniform float4   diffuse,
  683.     uniform float4   emissive,
  684.     float4 position : POSITION,
  685.     float3 normal   : NORMAL,
  686.     float2 uv       : TEXCOORD0,
  687.     float4 blendIdx : BLENDINDICES,
  688.     float4 blendWgt : BLENDWEIGHT,
  689.    
  690.  
  691.     out float4 oPosition : POSITION,
  692.     out float2 oUv       : TEXCOORD0,
  693.     out float4 colour           : COLOR,
  694.     // Support up to 24 bones of float3x4
  695.     // vs_1_1 only supports 96 params so more than this is not feasible
  696.     uniform float3x4   worldMatrix3x4Array[64],
  697.     uniform float4x4 viewProjectionMatrix,
  698.     uniform float4x4 viewMatrix,
  699.     uniform float4   lightPos[1],
  700.     uniform float4   lightDiffuseColour[1])
  701. {
  702.     // transform by indexed matrix
  703.     float4 blendPos = float4(0,0,0,0);
  704.     int i;
  705.     for (i = 0; i < 2; ++i)
  706.     {
  707.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  708.     }
  709.     // view / projection
  710.     oPosition = mul(viewProjectionMatrix, blendPos);
  711.     // transform normal
  712.     float3 norm = float3(0,0,0);
  713.     for (i = 0; i < 2; ++i)
  714.     {
  715.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  716.         blendWgt[i];
  717.     }
  718.     norm = normalize(norm);
  719.     // Lighting - support point and directional
  720.     float3 lightDir0 =  normalize(
  721.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  722.  
  723.  
  724.    
  725.  
  726.     colour = ambient * diffuse +
  727.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  728.            emissive;
  729.     colour = saturate( colour );
  730.     colour.a=1;
  731.  
  732.  
  733.  
  734.     norm = mul( (float3x3)viewMatrix, norm );
  735.     norm.xy *= .5;
  736.     norm.xy += .5;
  737.     norm.y *= -1.0;
  738.     oUv = norm;
  739. }
  740.  
  741.  
  742. /*
  743.   ONE WEIGHT SKINNING BEHIND
  744. */
  745. void hardwareSkinningBehindOne_vp(
  746.     uniform float4x4 texViewProj,
  747.     uniform float4   ambient,
  748.     uniform float4   diffuse,
  749.     uniform float4   emissive,
  750.     float4 position : POSITION,
  751.     float3 normal   : NORMAL,
  752.     float2 uv       : TEXCOORD0,
  753.     float4 blendIdx : BLENDINDICES,
  754.     float4 blendWgt : BLENDWEIGHT,
  755.    
  756.  
  757.     out float4 oPosition : POSITION,
  758.     out float2 oUv       : TEXCOORD0,
  759.     out float4 colour           : COLOR,
  760.     // Support up to 24 bones of float3x4
  761.     // vs_1_1 only supports 96 params so more than this is not feasible
  762.     uniform float3x4   worldMatrix3x4Array[64],
  763.     uniform float4x4 viewProjectionMatrix,
  764.     uniform float4x4 viewMatrix,
  765.     uniform float4   lightPos[1],
  766.     uniform float4   lightDiffuseColour[1])
  767. {
  768.     // transform by indexed matrix
  769.     float4 blendPos = float4(0,0,0,0);
  770.     int i;
  771.     for (i = 0; i < 1; ++i)
  772.     {
  773.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  774.     }
  775.     // view / projection
  776.     oPosition = mul(viewProjectionMatrix, blendPos);
  777.     // transform normal
  778.     float3 norm = float3(0,0,0);
  779.     for (i = 0; i < 1; ++i)
  780.     {
  781.         norm += mul((float3x3)worldMatrix3x4Array[blendIdx[i]], normal) *
  782.         blendWgt[i];
  783.     }
  784.     norm = normalize(norm);
  785.     // Lighting - support point and directional
  786.     float3 lightDir0 =  normalize(
  787.         lightPos[0].xyz -  (blendPos.xyz * lightPos[0].w));
  788.  
  789.  
  790.    
  791.  
  792.     colour = ambient * diffuse +
  793.            diffuse * (saturate(dot(lightDir0, norm)) * lightDiffuseColour[0]) +
  794.            emissive;
  795.     colour = saturate( colour );
  796.     colour.a=1;
  797.  
  798.  
  799.  
  800.     norm = mul( (float3x3)viewMatrix, norm );
  801.     norm.xy *= .5;
  802.     norm.xy += .5;
  803.     norm.y *= -1.0;
  804.     oUv = norm;
  805. }
  806.  
  807.  
  808.  
  809. /*
  810.   FOUR WEIGHT CASTER
  811. */
  812. void hardwareSkinningCaster_vp(
  813.     uniform float4   emissive,
  814.     float4 position : POSITION,
  815.     float3 normal   : NORMAL,
  816.     float4 blendIdx : BLENDINDICES,
  817.     float4 blendWgt : BLENDWEIGHT,
  818.    
  819.  
  820.     out float4 oPosition : POSITION,
  821.     out float4 colour           : COLOR,
  822.     // Support up to 24 bones of float3x4
  823.     // vs_1_1 only supports 96 params so more than this is not feasible
  824.     uniform float3x4   worldMatrix3x4Array[64],
  825.     uniform float4x4 viewProjectionMatrix)
  826. {
  827.     // transform by indexed matrix
  828.     float4 blendPos = float4(0,0,0,0);
  829.     int i;
  830.     for (i = 0; i < 4; ++i)
  831.     {
  832.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  833.     }
  834.     // view / projection
  835.     oPosition = mul(viewProjectionMatrix, blendPos);
  836.     // transform normal
  837.  
  838.    
  839.  
  840.     colour = float4( 0, 0, 0, 1 ) + emissive;
  841.     colour.a=1;
  842. }
  843.  
  844.  
  845. /*
  846.   THREE WEIGHT CASTER
  847. */
  848. void hardwareSkinningCasterThree_vp(
  849.     uniform float4   emissive,
  850.     float4 position : POSITION,
  851.     float3 normal   : NORMAL,
  852.     float4 blendIdx : BLENDINDICES,
  853.     float4 blendWgt : BLENDWEIGHT,
  854.    
  855.  
  856.     out float4 oPosition : POSITION,
  857.     out float4 colour           : COLOR,
  858.     // Support up to 24 bones of float3x4
  859.     // vs_1_1 only supports 96 params so more than this is not feasible
  860.     uniform float3x4   worldMatrix3x4Array[64],
  861.     uniform float4x4 viewProjectionMatrix)
  862. {
  863.     // transform by indexed matrix
  864.     float4 blendPos = float4(0,0,0,0);
  865.     int i;
  866.     for (i = 0; i < 3; ++i)
  867.     {
  868.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  869.     }
  870.     // view / projection
  871.     oPosition = mul(viewProjectionMatrix, blendPos);
  872.     // transform normal
  873.  
  874.    
  875.  
  876.     colour = float4( 0, 0, 0, 1 ) + emissive;
  877.     colour.a=1;
  878. }
  879.  
  880.  
  881. /*
  882.   TWO WEIGHT CASTER
  883. */
  884. void hardwareSkinningCasterTwo_vp(
  885.     uniform float4   emissive,
  886.     float4 position : POSITION,
  887.     float3 normal   : NORMAL,
  888.     float4 blendIdx : BLENDINDICES,
  889.     float4 blendWgt : BLENDWEIGHT,
  890.    
  891.  
  892.     out float4 oPosition : POSITION,
  893.     out float4 colour           : COLOR,
  894.     // Support up to 24 bones of float3x4
  895.     // vs_1_1 only supports 96 params so more than this is not feasible
  896.     uniform float3x4   worldMatrix3x4Array[64],
  897.     uniform float4x4 viewProjectionMatrix)
  898. {
  899.     // transform by indexed matrix
  900.     float4 blendPos = float4(0,0,0,0);
  901.     int i;
  902.     for (i = 0; i < 2; ++i)
  903.     {
  904.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  905.     }
  906.     // view / projection
  907.     oPosition = mul(viewProjectionMatrix, blendPos);
  908.     // transform normal
  909.  
  910.    
  911.  
  912.     colour = float4( 0, 0, 0, 1 ) + emissive;
  913.     colour.a=1;
  914. }
  915.  
  916.  
  917. /*
  918.   ONE WEIGHT CASTER
  919. */
  920. void hardwareSkinningCasterOne_vp(
  921.     uniform float4   emissive,
  922.     float4 position : POSITION,
  923.     float3 normal   : NORMAL,
  924.     float4 blendIdx : BLENDINDICES,
  925.     float4 blendWgt : BLENDWEIGHT,
  926.    
  927.  
  928.     out float4 oPosition : POSITION,
  929.     out float4 colour           : COLOR,
  930.     // Support up to 24 bones of float3x4
  931.     // vs_1_1 only supports 96 params so more than this is not feasible
  932.     uniform float3x4   worldMatrix3x4Array[64],
  933.     uniform float4x4 viewProjectionMatrix)
  934. {
  935.     // transform by indexed matrix
  936.     float4 blendPos = float4(0,0,0,0);
  937.     int i;
  938.     for (i = 0; i < 1; ++i)
  939.     {
  940.         blendPos += float4(mul(worldMatrix3x4Array[blendIdx[i]], position).xyz, 1.0) * blendWgt[i];
  941.     }
  942.     // view / projection
  943.     oPosition = mul(viewProjectionMatrix, blendPos);
  944.     // transform normal
  945.  
  946.    
  947.  
  948.     colour = float4( 0, 0, 0, 1 ) + emissive;
  949.     colour.a=1;
  950. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement