Boost

Untitled

Aug 10th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. #include "$ENGINE$/BasePass.bslinc"
  2. #include "$ENGINE$/ForwardLighting.bslinc"
  3.  
  4. options
  5. {
  6. transparent = true;
  7. // Make render before cells
  8. priority = 10;
  9. };
  10.  
  11. shader CompoundCloud {
  12.  
  13. mixin BasePass;
  14. mixin ForwardLighting;
  15.  
  16. blend
  17. {
  18. target
  19. {
  20. enabled = true;
  21. color = { srcA, srcIA, add };
  22. };
  23. };
  24.  
  25. depth
  26. {
  27. write = false;
  28. };
  29.  
  30. code {
  31.  
  32. [alias(gDensityTex)]
  33. SamplerState gDensitySamp;
  34. Texture2D gDensityTex;
  35.  
  36. [alias(gNoiseTex)]
  37. SamplerState gNoiseSamp;
  38. Texture2D gNoiseTex = white;
  39.  
  40. cbuffer CloudColours {
  41. float4 gCloudColour1;
  42. float4 gCloudColour2;
  43. float4 gCloudColour3;
  44. float4 gCloudColour4;
  45. }
  46.  
  47. float4 fsmain(in VStoFS input) : SV_Target0 {
  48. // Setting this too high makes the clouds invisible
  49. float CLOUD_DISSIPATION = 2.0;
  50.  
  51. float4 concentrations = gDensityTex.Sample(gDensitySamp, input.uv0);
  52.  
  53. float cloud1 = concentrations.r * pow(gNoiseTex.Sample(gNoiseSamp, input.uv0).r, CLOUD_DISSIPATION);
  54. float cloud2 = concentrations.g * pow(gNoiseTex.Sample(gNoiseSamp, input.uv0 + 0.2f).r, CLOUD_DISSIPATION);
  55. float cloud3 = concentrations.b * pow(gNoiseTex.Sample(gNoiseSamp, input.uv0 + 0.4f).r, CLOUD_DISSIPATION);
  56. float cloud4 = concentrations.a * pow(gNoiseTex.Sample(gNoiseSamp, input.uv0 + 0.6f).r, CLOUD_DISSIPATION);
  57.  
  58. float4 colour =
  59. // first
  60. gCloudColour1 * cloud1
  61. + // second
  62. gCloudColour2 * cloud2
  63. + // third
  64. gCloudColour3 * cloud3
  65. + // fourth
  66. gCloudColour4 * cloud4;
  67.  
  68. colour.a = min(cloud1 + cloud2 + cloud3 + cloud4, 0.9f);
  69.  
  70. return colour;
  71. }
  72. };
  73. };
Advertisement
Add Comment
Please, Sign In to add comment