Няма описание
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. // Use this shader as a fallback when trying to render using a BatchRendererGroup with a shader that doesn't define a ScenePickingPass or SceneSelectionPass.
  2. Shader "Hidden/Universal Render Pipeline/BRGPicking"
  3. {
  4. // The shader does not use these properties, but they have to be declared to
  5. // make the shader SRP Batcher compatible.
  6. Properties
  7. {
  8. [HideInInspector] [MainTexture] _BaseMap("Albedo", 2D) = "white" {}
  9. [HideInInspector] [MainColor] _BaseColor("Color", Color) = (1,1,1,1)
  10. [HideInInspector] _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
  11. }
  12. SubShader
  13. {
  14. // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
  15. // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
  16. // material work with both Universal Render Pipeline and Builtin Unity Pipeline
  17. Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True" "ShaderModel"="4.5"}
  18. LOD 300
  19. Pass
  20. {
  21. Name "ScenePickingPass"
  22. Tags { "LightMode" = "Picking" }
  23. Cull [_CullMode]
  24. HLSLPROGRAM
  25. #pragma target 4.5
  26. #pragma editor_sync_compilation
  27. #pragma multi_compile DOTS_INSTANCING_ON
  28. #pragma vertex Vert
  29. #pragma fragment Frag
  30. #define SCENEPICKINGPASS
  31. float4 _SelectionID;
  32. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  33. struct Attributes
  34. {
  35. float4 positionOS : POSITION;
  36. UNITY_VERTEX_INPUT_INSTANCE_ID
  37. };
  38. struct Varyings
  39. {
  40. float4 positionCS : SV_POSITION;
  41. UNITY_VERTEX_INPUT_INSTANCE_ID
  42. };
  43. Varyings Vert(Attributes input)
  44. {
  45. Varyings output = (Varyings)0;
  46. UNITY_SETUP_INSTANCE_ID(input);
  47. UNITY_TRANSFER_INSTANCE_ID(input, output);
  48. float4x4 objectToWorld = UNITY_DOTS_MATRIX_M;
  49. float4 positionWS = mul(objectToWorld, float4(input.positionOS.xyz, 1.0));
  50. output.positionCS = mul(unity_MatrixVP, positionWS);
  51. return output;
  52. }
  53. half4 Frag(Varyings input) : SV_Target
  54. {
  55. UNITY_SETUP_INSTANCE_ID(input);
  56. return unity_SelectionID;
  57. }
  58. ENDHLSL
  59. }
  60. Pass
  61. {
  62. Name "SceneSelectionPass"
  63. Tags {"LightMode" = "SceneSelectionPass"}
  64. Cull [_CullMode]
  65. HLSLPROGRAM
  66. #pragma target 4.5
  67. #pragma editor_sync_compilation
  68. #pragma multi_compile DOTS_INSTANCING_ON
  69. #pragma vertex Vert
  70. #pragma fragment Frag
  71. #define SCENESELECTIONPASS
  72. int _ObjectId;
  73. int _PassValue;
  74. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  75. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl"
  76. #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
  77. struct Attributes
  78. {
  79. float4 positionOS : POSITION;
  80. float2 texcoord : TEXCOORD0;
  81. UNITY_VERTEX_INPUT_INSTANCE_ID
  82. };
  83. struct Varyings
  84. {
  85. float4 positionCS : SV_POSITION;
  86. float2 uv : TEXCOORD0;
  87. UNITY_VERTEX_INPUT_INSTANCE_ID
  88. };
  89. Varyings Vert(Attributes input)
  90. {
  91. Varyings output = (Varyings)0;
  92. UNITY_SETUP_INSTANCE_ID(input);
  93. UNITY_TRANSFER_INSTANCE_ID(input, output);
  94. output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
  95. output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
  96. return output;
  97. }
  98. half4 Frag(Varyings input) : SV_Target
  99. {
  100. UNITY_SETUP_INSTANCE_ID(input);
  101. return half4(_ObjectId, _PassValue, 1.0, 1.0);
  102. }
  103. ENDHLSL
  104. }
  105. }
  106. FallBack Off
  107. }