Guest User

Untitled

a guest
Apr 25th, 2016
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.31 KB | None | 0 0
  1. //
  2. // invert.fx
  3. //
  4.  
  5. //---------------------------------------------------------------------
  6. // Settings
  7. //---------------------------------------------------------------------
  8. float4x4 gWorldViewProjection : WORLDVIEWPROJECTION;
  9.  
  10. texture sBaseTexture;
  11.  
  12. //---------------------------------------------------------------------
  13. // Sampler
  14. //---------------------------------------------------------------------
  15. sampler BaseSampler = sampler_state
  16. {
  17. Texture = (sBaseTexture);
  18. AddressU = Mirror;
  19. AddressV = Mirror;
  20. MinFilter = Linear;
  21. MagFilter = Linear;
  22. MipFilter = Linear;
  23. };
  24.  
  25. //---------------------------------------------------------------------
  26. // Structure of data sent to the pixel shader ( from the vertex shader )
  27. //---------------------------------------------------------------------
  28. struct VSInput
  29. {
  30. float3 Position : POSITION0;
  31. float2 TexCoord : TEXCOORD0;
  32. };
  33.  
  34. struct PSInput
  35. {
  36. float4 Position : POSITION0;
  37. float2 TexCoord : TEXCOORD0;
  38. };
  39.  
  40. //------------------------------------------------------------------------------------------
  41. // VertexShaderFunction
  42. //------------------------------------------------------------------------------------------
  43.  
  44. PSInput VertexShaderFunction(VSInput VS)
  45. {
  46. PSInput PS = (PSInput)0;
  47. PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection);
  48. PS.TexCoord = VS.TexCoord;
  49. return PS;
  50. }
  51.  
  52. //------------------------------------------------------------------------------------------
  53. // PixelShaderFunction
  54. //------------------------------------------------------------------------------------------
  55. float4 PixelShaderFunction(PSInput PS) : COLOR0
  56. {
  57. float4 color = tex2D(BaseSampler, PS.TexCoord);
  58. color.rgb = float3(1 - color.r, 1 - color.g, 1 - color.b);
  59. color.rgb = saturate(color.rgb);
  60. return color;
  61. }
  62.  
  63.  
  64. //------------------------------------------------------------------------------------------
  65. // Techniques
  66. //------------------------------------------------------------------------------------------
  67. technique invert
  68. {
  69. pass P0
  70. {
  71. VertexShader = compile vs_2_0 VertexShaderFunction();
  72. PixelShader = compile ps_2_0 PixelShaderFunction();
  73. }
  74. }
  75.  
  76. // Fallback
  77. technique fallback
  78. {
  79. pass P0
  80. {
  81. // Just draw normally
  82. }
  83. }
Add Comment
Please, Sign In to add comment