ParticlesEditorPass.hlsl 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #ifndef UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED
  2. #define UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED
  3. #include "Packages/com.unity.render-pipelines.universal/Shaders/Particles/ParticlesInput.hlsl"
  4. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Particles.hlsl"
  5. float _ObjectId;
  6. float _PassValue;
  7. float4 _SelectionID;
  8. ///////////////////////////////////////////////////////////////////////////////
  9. // Vertex and Fragment functions //
  10. ///////////////////////////////////////////////////////////////////////////////
  11. VaryingsParticle vertParticleEditor(AttributesParticle input)
  12. {
  13. VaryingsParticle output = (VaryingsParticle)0;
  14. UNITY_SETUP_INSTANCE_ID(input);
  15. UNITY_TRANSFER_INSTANCE_ID(input, output);
  16. UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
  17. VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
  18. output.clipPos = vertexInput.positionCS;
  19. output.color = GetParticleColor(input.color);
  20. #if defined(_FLIPBOOKBLENDING_ON) && !defined(UNITY_PARTICLE_INSTANCING_ENABLED)
  21. GetParticleTexcoords(output.texcoord, output.texcoord2AndBlend, input.texcoords, input.texcoordBlend);
  22. #else
  23. GetParticleTexcoords(output.texcoord, input.texcoords.xy);
  24. #endif
  25. return output;
  26. }
  27. void fragParticleSceneClip(VaryingsParticle input)
  28. {
  29. UNITY_SETUP_INSTANCE_ID(input);
  30. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(input);
  31. float2 uv = input.texcoord;
  32. float3 blendUv = float3(0, 0, 0);
  33. #if defined(_FLIPBOOKBLENDING_ON)
  34. blendUv = input.texcoord2AndBlend;
  35. #endif
  36. float4 projectedPosition = float4(0, 0, 0, 0);
  37. half4 albedo = SampleAlbedo(uv, blendUv, _BaseColor, input.color, projectedPosition, TEXTURE2D_ARGS(_BaseMap, sampler_BaseMap));
  38. half alpha = albedo.a;
  39. #ifdef _ALPHATEST_ON
  40. clip(alpha - _Cutoff);
  41. #endif
  42. }
  43. half4 fragParticleSceneHighlight(VaryingsParticle input) : SV_Target
  44. {
  45. fragParticleSceneClip(input);
  46. return float4(_ObjectId, _PassValue, 1, 1);
  47. }
  48. half4 fragParticleScenePicking(VaryingsParticle input) : SV_Target
  49. {
  50. fragParticleSceneClip(input);
  51. return _SelectionID;
  52. }
  53. #endif // UNIVERSAL_PARTICLES_EDITOR_PASS_INCLUDED