SelectionPickingPass.hlsl 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef SG_SELECTION_PICKING_PASS_INCLUDED
  2. #define SG_SELECTION_PICKING_PASS_INCLUDED
  3. PackedVaryings vert(Attributes input)
  4. {
  5. Varyings output = (Varyings)0;
  6. output = BuildVaryings(input);
  7. PackedVaryings packedOutput = (PackedVaryings)0;
  8. packedOutput = PackVaryings(output);
  9. return packedOutput;
  10. }
  11. half4 frag(PackedVaryings packedInput) : SV_TARGET
  12. {
  13. Varyings unpacked = UnpackVaryings(packedInput);
  14. UNITY_SETUP_INSTANCE_ID(unpacked);
  15. UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(unpacked);
  16. SurfaceDescription surfaceDescription = BuildSurfaceDescription(unpacked);
  17. #if _ALPHATEST_ON
  18. // This isn't defined in the sprite passes. It looks like the built-in legacy shader will use this as it's default constant
  19. float alphaClipThreshold = 0.01f;
  20. #if ALPHA_CLIP_THRESHOLD
  21. alphaClipThreshold = surfaceDescription.AlphaClipThreshold;
  22. #endif
  23. clip(surfaceDescription.Alpha - alphaClipThreshold);
  24. #endif
  25. half4 outColor = 0;
  26. #ifdef SCENESELECTIONPASS
  27. // We use depth prepass for scene selection in the editor, this code allow to output the outline correctly
  28. outColor = half4(_ObjectId, _PassValue, 1.0, 1.0);
  29. #elif defined(SCENEPICKINGPASS)
  30. outColor = _SelectionID;
  31. #endif
  32. return outColor;
  33. }
  34. #endif