ParticlesSimpleLitInput.hlsl 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef UNIVERSAL_PARTICLES_SIMPLE_LIT_INPUT_INCLUDED
  2. #define UNIVERSAL_PARTICLES_SIMPLE_LIT_INPUT_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
  4. CBUFFER_START(UnityPerMaterial)
  5. float4 _SoftParticleFadeParams;
  6. float4 _CameraFadeParams;
  7. float4 _BaseMap_ST;
  8. half4 _BaseColor;
  9. half4 _EmissionColor;
  10. half4 _BaseColorAddSubDiff;
  11. half _Cutoff;
  12. half4 _SpecColor;
  13. half _Smoothness;
  14. half _DistortionStrengthScaled;
  15. half _DistortionBlend;
  16. CBUFFER_END
  17. TEXTURE2D(_SpecGlossMap); SAMPLER(sampler_SpecGlossMap);
  18. #define SOFT_PARTICLE_NEAR_FADE _SoftParticleFadeParams.x
  19. #define SOFT_PARTICLE_INV_FADE_DISTANCE _SoftParticleFadeParams.y
  20. #define CAMERA_NEAR_FADE _CameraFadeParams.x
  21. #define CAMERA_INV_FADE_DISTANCE _CameraFadeParams.y
  22. half4 SampleAlbedo(float2 uv, float3 blendUv, half4 color, float4 particleColor, float4 projectedPosition, TEXTURE2D_PARAM(albedoMap, sampler_albedoMap))
  23. {
  24. half4 albedo = BlendTexture(TEXTURE2D_ARGS(albedoMap, sampler_albedoMap), uv, blendUv) * color;
  25. half4 colorAddSubDiff = half4(0, 0, 0, 0);
  26. #if defined (_COLORADDSUBDIFF_ON)
  27. colorAddSubDiff = _BaseColorAddSubDiff;
  28. #endif
  29. albedo = MixParticleColor(albedo, particleColor, colorAddSubDiff);
  30. AlphaDiscard(albedo.a, _Cutoff);
  31. #if defined(_SOFTPARTICLES_ON)
  32. ALBEDO_MUL *= SoftParticles(SOFT_PARTICLE_NEAR_FADE, SOFT_PARTICLE_INV_FADE_DISTANCE, projectedPosition);
  33. #endif
  34. #if defined(_FADING_ON)
  35. ALBEDO_MUL *= CameraFade(CAMERA_NEAR_FADE, CAMERA_INV_FADE_DISTANCE, projectedPosition);
  36. #endif
  37. return albedo;
  38. }
  39. half4 SampleSpecularSmoothness(float2 uv, float3 blendUv, half alpha, half4 specColor, TEXTURE2D_PARAM(specGlossMap, sampler_specGlossMap))
  40. {
  41. half4 specularGloss = half4(0.0h, 0.0h, 0.0h, 1.0h);
  42. #ifdef _SPECGLOSSMAP
  43. specularGloss = BlendTexture(TEXTURE2D_ARGS(specGlossMap, sampler_specGlossMap), uv, blendUv);
  44. #elif defined(_SPECULAR_COLOR)
  45. specularGloss = specColor;
  46. #endif
  47. #ifdef _GLOSSINESS_FROM_BASE_ALPHA
  48. specularGloss.a = alpha;
  49. #endif
  50. specularGloss.a = exp2(10 * specularGloss.a + 1);
  51. return specularGloss;
  52. }
  53. #endif // UNIVERSAL_PARTICLES_SIMPLE_LIT_INPUT_INCLUDED