2
0

ParticlesUnlit.bsl 1019 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. #if SOFT
  2. #define VIEW_DEPTH
  3. #endif
  4. #include "$ENGINE$\ParticleVertex.bslinc"
  5. #include "$ENGINE$\DepthInput.bslinc"
  6. options
  7. {
  8. transparent = true;
  9. };
  10. shader Surface
  11. {
  12. mixin ParticleVertex;
  13. mixin DepthInput;
  14. variations
  15. {
  16. SOFT = { false, true };
  17. };
  18. blend
  19. {
  20. target
  21. {
  22. enabled = true;
  23. color = { srcA, srcIA, add };
  24. };
  25. };
  26. depth
  27. {
  28. write = false;
  29. };
  30. code
  31. {
  32. [alias(gTexture)]
  33. SamplerState gSampler;
  34. Texture2D gTexture = white;
  35. cbuffer Params
  36. {
  37. [hideInInspector]
  38. float gInvDepthRange = 1.0f;
  39. };
  40. float4 fsmain(in VStoFS input, in float4 screenPos : SV_Position) : SV_Target0
  41. {
  42. float4 output = gTexture.Sample(gSampler, input.uv0) * input.color;
  43. #if SOFT
  44. float particleDepth = input.depth;
  45. float sceneDepth = -convertFromDeviceZ(gDepthBufferTex.Load(int3(screenPos.xy, 0)).r);
  46. float diff = sceneDepth - particleDepth;
  47. float fade = saturate(diff * gInvDepthRange);
  48. output.a *= fade;
  49. #endif
  50. return output;
  51. }
  52. };
  53. };