ParticlesUnlitInput.hlsl 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #ifndef UNIVERSAL_PARTICLES_UNLIT_INPUT_INCLUDED
  2. #define UNIVERSAL_PARTICLES_UNLIT_INPUT_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  4. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl"
  5. // NOTE: Do not ifdef the properties here as SRP batcher can not handle different layouts.
  6. CBUFFER_START(UnityPerMaterial)
  7. float4 _SoftParticleFadeParams;
  8. float4 _CameraFadeParams;
  9. float4 _BaseMap_ST;
  10. half4 _BaseColor;
  11. half4 _EmissionColor;
  12. half4 _BaseColorAddSubDiff;
  13. half _Cutoff;
  14. half _DistortionStrengthScaled;
  15. half _DistortionBlend;
  16. half _Surface;
  17. CBUFFER_END
  18. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
  19. #define SOFT_PARTICLE_NEAR_FADE _SoftParticleFadeParams.x
  20. #define SOFT_PARTICLE_INV_FADE_DISTANCE _SoftParticleFadeParams.y
  21. #define CAMERA_NEAR_FADE _CameraFadeParams.x
  22. #define CAMERA_INV_FADE_DISTANCE _CameraFadeParams.y
  23. #define _BumpScale 1.0
  24. half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap))
  25. {
  26. half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), uv, blendUv) * color;
  27. // No distortion Support
  28. half4 colorAddSubDiff = half4(0, 0, 0, 0);
  29. #if defined (_COLORADDSUBDIFF_ON)
  30. colorAddSubDiff = _BaseColorAddSubDiff;
  31. #endif
  32. albedo = MixParticleColor(albedo, half4(particleColor), colorAddSubDiff);
  33. AlphaDiscard(albedo.a, _Cutoff);
  34. albedo.rgb = AlphaModulate(albedo.rgb, albedo.a);
  35. #if defined(_SOFTPARTICLES_ON)
  36. albedo = SOFT_PARTICLE_MUL_ALBEDO(albedo, half(SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, projectedPosition)));
  37. #endif
  38. #if defined(_FADING_ON)
  39. ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, projectedPosition);
  40. #endif
  41. return albedo;
  42. }
  43. half4 SampleAlbedo(TEXTURE2D_PARAM(albedoMap, sampler_albedoMap), ParticleParams params)
  44. {
  45. half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), params.uv, params.blendUv) * params.baseColor;
  46. // No distortion Support
  47. #if defined (_COLORADDSUBDIFF_ON)
  48. half4 colorAddSubDiff = _BaseColorAddSubDiff;
  49. #else
  50. half4 colorAddSubDiff = half4(0, 0, 0, 0);
  51. #endif
  52. albedo = MixParticleColor(albedo, half4(params.vertexColor), colorAddSubDiff);
  53. AlphaDiscard(albedo.a, _Cutoff);
  54. albedo.rgb = AlphaModulate(albedo.rgb, albedo.a);
  55. #if defined(_SOFTPARTICLES_ON)
  56. albedo = SOFT_PARTICLE_MUL_ALBEDO(albedo, half(SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, params)));
  57. #endif
  58. #if defined(_FADING_ON)
  59. ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, params.projectedPosition);
  60. #endif
  61. return albedo;
  62. }
  63. #endif // UNIVERSAL_PARTICLES_PBR_INCLUDED