Advertisement
Guest User

mtaParticleColorShader

a guest
May 17th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //-----------------------------------------------------------------------
  2. //-- Settings
  3. //-----------------------------------------------------------------------
  4. float4 theColorYouWant;
  5.  
  6. //---------------------------------------------------------------------
  7. // Include some common stuff
  8. //---------------------------------------------------------------------
  9. #include "mta-helper.fx"
  10.  
  11. //-----------------------------------------------------------------------
  12. //-- Sampler for the new texture
  13. //-----------------------------------------------------------------------
  14. sampler Sampler0 = sampler_state
  15. {
  16.     Texture = (gTexture0);
  17. };
  18.  
  19. //-----------------------------------------------------------------------
  20. //-- Structure of data sent to the vertex shader
  21. //-----------------------------------------------------------------------
  22. struct VSInput
  23. {
  24.     float3 Position : POSITION0;
  25.     float3 Normal : NORMAL0;
  26.     float4 Diffuse : COLOR0;
  27.     float2 TexCoord : TEXCOORD0;
  28. };
  29.  
  30. //-----------------------------------------------------------------------
  31. //-- Structure of data sent to the pixel shader ( from the vertex shader )
  32. //-----------------------------------------------------------------------
  33. struct PSInput
  34. {
  35.     float4 Position : POSITION0;
  36.     float4 Diffuse : COLOR0;
  37.     float2 TexCoord : TEXCOORD0;
  38. };
  39.  
  40.  
  41. //--------------------------------------------------------------------------------------------
  42. //-- VertexShaderFunction
  43. //--  1. Read from VS structure
  44. //--  2. Process
  45. //--  3. Write to PS structure
  46. //--------------------------------------------------------------------------------------------
  47. PSInput VertexShaderFunction(VSInput VS)
  48. {
  49.     PSInput PS = (PSInput)0;
  50.  
  51.     //-- Calculate screen pos of vertex
  52.     PS.Position = mul(float4(VS.Position, 1), gWorldViewProjection);
  53.  
  54.     //-- Pass through tex coord
  55.     PS.TexCoord = VS.TexCoord;
  56.  
  57.     //-- Calculate GTA lighting for buildings
  58.     PS.Diffuse = MTACalcGTABuildingDiffuse( VS.Diffuse );
  59.  
  60.     return PS;
  61. }
  62.  
  63.  
  64. //--------------------------------------------------------------------------------------------
  65. //-- PixelShaderFunction
  66. //--  1. Read from PS structure
  67. //--  2. Process
  68. //--  3. Return pixel color
  69. //--------------------------------------------------------------------------------------------
  70. float4 PixelShaderFunction(PSInput PS) : COLOR0
  71. {
  72.     //-- Get texture pixel
  73.     float4 texel = tex2D(Sampler0, PS.TexCoord);
  74.  
  75.     //-- Apply diffuse lighting
  76.     float4 finalColor = texel * PS.Diffuse * theColorYouWant;
  77.  
  78.     return finalColor;
  79. }
  80.  
  81.  
  82. //--------------------------------------------------------------------------------------------
  83. //-- Techniques
  84. //--------------------------------------------------------------------------------------------
  85. technique tec
  86. {
  87.     pass P0
  88.     {
  89.         VertexShader = compile vs_2_0 VertexShaderFunction();
  90.         PixelShader = compile ps_2_0 PixelShaderFunction();
  91.     }
  92. }
  93.  
  94. //-- Fallback
  95. technique fallback
  96. {
  97.     pass P0
  98.     {
  99.         //-- Replace texture
  100.         Texture[0] = gTexture0;
  101.  
  102.         //-- Leave the rest of the states to the default settings
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement