Advertisement
Guest User

Effect File /w Blending

a guest
Nov 17th, 2012
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.69 KB | None | 0 0
  1. float4x4 World;
  2. float4x4 View;
  3. float4x4 Projection;
  4.  
  5. float4 AmbientColor;
  6. float AmbientIntensity;
  7.  
  8. float3 DiffuseDirection;
  9. float4 DiffuseColor;
  10. float DiffuseIntensity;
  11.  
  12. Texture xTexture;
  13. Texture bTexture;
  14.  
  15. sampler TextureSampler = sampler_state { texture = <xTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};
  16. sampler TextureSampler2 = sampler_state { texture = <bTexture> ; magfilter = LINEAR; minfilter = LINEAR; mipfilter=LINEAR; AddressU = mirror; AddressV = mirror;};
  17. // TODO: add effect parameters here.
  18.  
  19. struct VertexShaderInput
  20. {
  21. float4 Position : POSITION0;
  22. float2 TexCoords1 : TEXCOORD0;
  23. float2 TexCoords2 : TEXCOORD1;
  24. float BlendWeight : BLENDWEIGHT0;
  25. float4 Color : COLOR0;
  26. // TODO: add input channels such as texture
  27. // coordinates and vertex colors here.
  28. };
  29.  
  30. struct VertexShaderOutput
  31. {
  32. float4 Position : POSITION0;
  33. float3 Normal : NORMAL0;
  34. float2 TexCoords1 : TEXCOORD0;
  35. float2 TexCoords2 : TEXCOORD1;
  36. float BlendWeight : BLENDWEIGHT0;
  37. float4 Color : COLOR0;
  38.  
  39. // TODO: add vertex shader outputs such as colors and texture
  40. // coordinates here. These values will automatically be interpolated
  41. // over the triangle, and provided as input to your pixel shader.
  42. };
  43.  
  44. VertexShaderOutput VertexShaderFunction(VertexShaderInput input, float3 Normal : NORMAL0)
  45. {
  46. VertexShaderOutput output;
  47.  
  48. float4 worldPosition = mul(input.Position, World);
  49. float4 viewPosition = mul(worldPosition, View);
  50. output.Position = mul(viewPosition, Projection);
  51. output.Normal = normalize(mul(Normal,World));
  52. output.BlendWeight = input.BlendWeight;
  53. output.TexCoords1 = input.TexCoords1;
  54. output.TexCoords2 = input.TexCoords2;
  55. output.Color = input.Color;
  56. // TODO: add your vertex shader code here.
  57.  
  58. return output;
  59. }
  60.  
  61. float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0
  62. {
  63. // TODO: add your pixel shader code here.
  64.  
  65. float4 norm = float4(input.Normal, 1.0);
  66. float4 diffuse = saturate(dot(-DiffuseDirection,norm));
  67.  
  68. float4 blend = tex2D(TextureSampler2, input.TexCoords2) * input.BlendWeight;
  69. float4 normtex = tex2D(TextureSampler, input.TexCoords1) * (1 - input.BlendWeight);
  70.  
  71. float4 merge = (blend + normtex) / 2;
  72.  
  73. return merge * (AmbientColor*AmbientIntensity + DiffuseIntensity*DiffuseColor*diffuse + input.Color);
  74.  
  75. // (AmbientColor*AmbientIntensity + DiffuseIntensity*DiffuseColor*diffuse)
  76. // return float4(1, 0, 0, 1);
  77. }
  78.  
  79. technique Technique1
  80. {
  81. pass Pass1
  82. {
  83. // TODO: set renderstates here.
  84.  
  85. VertexShader = compile vs_3_0 VertexShaderFunction();
  86. PixelShader = compile ps_3_0 PixelShaderFunction();
  87. }
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement