Advertisement
Guest User

MultiTexturing XNA 16 Textures

a guest
Apr 5th, 2013
211
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float4x4 View;
  2. float4x4 Projection;
  3. float4x4 World;
  4.  
  5. texture Texture1; sampler MultiTexture1 = sampler_state { Texture = (Texture1); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  6. texture Texture2; sampler MultiTexture2 = sampler_state { Texture = (Texture2); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  7. texture Texture3; sampler MultiTexture3 = sampler_state { Texture = (Texture3); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  8. texture Texture4; sampler MultiTexture4 = sampler_state { Texture = (Texture4); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  9. texture Texture5; sampler MultiTexture5 = sampler_state { Texture = (Texture5); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  10. texture Texture6; sampler MultiTexture6 = sampler_state { Texture = (Texture6); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  11. texture Texture7; sampler MultiTexture7 = sampler_state { Texture = (Texture7); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  12. texture Texture8; sampler MultiTexture8 = sampler_state { Texture = (Texture8); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  13. texture Texture9; sampler MultiTexture9 = sampler_state { Texture = (Texture9); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  14. texture Texture10; sampler MultiTexture10 = sampler_state { Texture = (Texture10); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  15. texture Texture11; sampler MultiTexture11 = sampler_state { Texture = (Texture11); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  16. texture Texture12; sampler MultiTexture12 = sampler_state { Texture = (Texture12); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  17. texture Texture13; sampler MultiTexture13 = sampler_state { Texture = (Texture13); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  18. texture Texture14; sampler MultiTexture14 = sampler_state { Texture = (Texture14); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  19. texture Texture15; sampler MultiTexture15 = sampler_state { Texture = (Texture15); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  20. texture Texture16; sampler MultiTexture16 = sampler_state { Texture = (Texture16); MinFilter = Linear; MagFilter = Linear; MipFilter = Linear; AddressU = wrap; AddressV = wrap; };
  21.  
  22. struct VS_INPUT
  23. {
  24.     float4 Position : POSITION0;
  25.     float3 Normal : NORMAL0;
  26.     float2 TexCoord : TEXCOORD0;
  27.     float4 ColorA : COLOR0;
  28.     float4 ColorB : COLOR1;
  29.     float4 ColorC : COLOR2;
  30.     float4 ColorD : COLOR3;
  31. };
  32.  
  33. struct VS_OUTPUT
  34. {
  35.     float4 Position : POSITION0;
  36.     float2 TexCoord : TEXCOORD0;
  37.     float4 ColorA : COLOR0;
  38.     float4 ColorB : COLOR1;
  39.     float4 ColorC : COLOR2;
  40.     float4 ColorD : COLOR3;
  41. };
  42.  
  43. VS_OUTPUT MultiTexturing_Vertex(VS_INPUT input)
  44. {
  45.     VS_OUTPUT output;
  46.  
  47.     float4x4 vp = mul(mul(World, View), Projection);
  48.     output.Position = mul(input.Position, vp);
  49.     output.TexCoord = input.TexCoord;
  50.     output.ColorA = input.ColorA;
  51.     output.ColorB = input.ColorB;
  52.     output.ColorC = input.ColorC;
  53.     output.ColorD = input.ColorD;
  54.  
  55.     return output;
  56. }
  57.  
  58. float4 MultiTexturing_Pixel(VS_OUTPUT input) : COLOR
  59. {
  60.     float4 color = float4(0,0,0,0);
  61.  
  62.     color += tex2D(MultiTexture1, input.TexCoord) * input.ColorA.r;
  63.     color += tex2D(MultiTexture2, input.TexCoord) * input.ColorA.g;
  64.     color += tex2D(MultiTexture3, input.TexCoord) * input.ColorA.b;
  65.     color += tex2D(MultiTexture4, input.TexCoord) * input.ColorA.a;
  66.  
  67.     color += tex2D(MultiTexture5, input.TexCoord) * input.ColorB.r;
  68.     color += tex2D(MultiTexture6, input.TexCoord) * input.ColorB.g;
  69.     color += tex2D(MultiTexture7, input.TexCoord) * input.ColorB.b;
  70.     color += tex2D(MultiTexture8, input.TexCoord) * input.ColorB.a;
  71.  
  72.     color += tex2D(MultiTexture9, input.TexCoord) * input.ColorC.r;
  73.     color += tex2D(MultiTexture10, input.TexCoord) * input.ColorC.g;
  74.     color += tex2D(MultiTexture11, input.TexCoord) * input.ColorC.b;
  75.     color += tex2D(MultiTexture12, input.TexCoord) * input.ColorC.a;
  76.  
  77.     color += tex2D(MultiTexture13, input.TexCoord) * input.ColorD.r;
  78.     color += tex2D(MultiTexture14, input.TexCoord) * input.ColorD.g;
  79.     color += tex2D(MultiTexture15, input.TexCoord) * input.ColorD.b;
  80.     color += tex2D(MultiTexture16, input.TexCoord) * input.ColorD.a;
  81.  
  82.  
  83.     return color;
  84. }
  85.  
  86. technique MultiTexture
  87. {
  88.     pass Pass0
  89.     {
  90.         VertexShader = compile vs_3_0 MultiTexturing_Vertex();
  91.         PixelShader = compile ps_3_0 MultiTexturing_Pixel();
  92.     }
  93. }
Advertisement
RAW Paste Data Copied
Advertisement