Advertisement
Guest User

Untitled

a guest
Jan 7th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. //================================================================
  2. //Texture
  3. sampler sampler0_ : register(s0);
  4.  
  5. //--------------------------------
  6. const float SCREEN_WIDTH = 640;
  7. const float SCREEN_HEIGHT = 480;
  8. texture textureMask_;
  9. sampler samplerMask_ = sampler_state
  10. {
  11. Texture = <textureMask_>;
  12. };
  13.  
  14.  
  15. //================================================================
  16. struct PS_INPUT
  17. {
  18. float4 diffuse : COLOR0;
  19. float2 texCoord : TEXCOORD0;
  20. float2 vPos : VPOS;
  21. };
  22.  
  23. //--------------------------------
  24.  
  25. struct PS_OUTPUT
  26. {
  27. float4 color : COLOR0;
  28. };
  29.  
  30.  
  31. //================================================================
  32. PS_OUTPUT PsMask( PS_INPUT In ) : COLOR0
  33. {
  34. PS_OUTPUT Out;
  35.  
  36. float4 colorTexture = tex2D(sampler0_, In.texCoord);
  37.  
  38. float4 colorDiffuse = In.diffuse;
  39.  
  40. float4 color = colorTexture * colorDiffuse;
  41. Out.color = color;
  42. if(color.a > 0)
  43. {
  44. //--------------------------------
  45. float2 maskUV;
  46.  
  47. maskUV.x = In.vPos.x / SCREEN_WIDTH;
  48. maskUV.y = In.vPos.y / SCREEN_HEIGHT;
  49. float4 colorMask = tex2D(samplerMask_, maskUV);
  50.  
  51. Out.color.a = ( colorMask.r + colorMask.g + colorMask.b ) * 0.3333f * color.a;
  52. }
  53.  
  54.  
  55. return Out;
  56. }
  57.  
  58.  
  59. //================================================================
  60. //--------------------------------
  61. //technique
  62. technique TecMask
  63. {
  64. pass P0
  65. {
  66. PixelShader = compile ps_3_0 PsMask();
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement