123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
-
- // Use this shader as a fallback when trying to render using a BatchRendererGroup with a shader that doesn't define a ScenePickingPass or SceneSelectionPass.
- Shader "Hidden/Universal Render Pipeline/BRGPicking"
- {
- // The shader does not use these properties, but they have to be declared to
- // make the shader SRP Batcher compatible.
- Properties
- {
- [HideInInspector] [MainTexture] _BaseMap("Albedo", 2D) = "white" {}
- [HideInInspector] [MainColor] _BaseColor("Color", Color) = (1,1,1,1)
- [HideInInspector] _Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
- }
-
- SubShader
- {
- // Universal Pipeline tag is required. If Universal render pipeline is not set in the graphics settings
- // this Subshader will fail. One can add a subshader below or fallback to Standard built-in to make this
- // material work with both Universal Render Pipeline and Builtin Unity Pipeline
- Tags{"RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "IgnoreProjector" = "True" "ShaderModel"="4.5"}
- LOD 300
-
- Pass
- {
- Name "ScenePickingPass"
- Tags { "LightMode" = "Picking" }
-
- Cull [_CullMode]
-
- HLSLPROGRAM
-
- #pragma target 4.5
-
- #pragma editor_sync_compilation
- #pragma multi_compile DOTS_INSTANCING_ON
-
- #pragma vertex Vert
- #pragma fragment Frag
-
- #define SCENEPICKINGPASS
-
- float4 _SelectionID;
-
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
-
- struct Attributes
- {
- float4 positionOS : POSITION;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
-
- struct Varyings
- {
- float4 positionCS : SV_POSITION;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
-
- Varyings Vert(Attributes input)
- {
- Varyings output = (Varyings)0;
- UNITY_SETUP_INSTANCE_ID(input);
- UNITY_TRANSFER_INSTANCE_ID(input, output);
-
- float4x4 objectToWorld = UNITY_DOTS_MATRIX_M;
-
- float4 positionWS = mul(objectToWorld, float4(input.positionOS.xyz, 1.0));
- output.positionCS = mul(unity_MatrixVP, positionWS);
-
- return output;
- }
-
- half4 Frag(Varyings input) : SV_Target
- {
- UNITY_SETUP_INSTANCE_ID(input);
- return unity_SelectionID;
- }
-
- ENDHLSL
- }
-
- Pass
- {
- Name "SceneSelectionPass"
- Tags {"LightMode" = "SceneSelectionPass"}
-
- Cull [_CullMode]
-
- HLSLPROGRAM
-
- #pragma target 4.5
- #pragma editor_sync_compilation
-
- #pragma multi_compile DOTS_INSTANCING_ON
-
- #pragma vertex Vert
- #pragma fragment Frag
-
- #define SCENESELECTIONPASS
-
- int _ObjectId;
- int _PassValue;
-
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
- #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/ShaderVariablesFunctions.hlsl"
- #include "Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl"
-
- struct Attributes
- {
- float4 positionOS : POSITION;
- float2 texcoord : TEXCOORD0;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
-
- struct Varyings
- {
- float4 positionCS : SV_POSITION;
- float2 uv : TEXCOORD0;
- UNITY_VERTEX_INPUT_INSTANCE_ID
- };
-
- Varyings Vert(Attributes input)
- {
- Varyings output = (Varyings)0;
- UNITY_SETUP_INSTANCE_ID(input);
- UNITY_TRANSFER_INSTANCE_ID(input, output);
-
- output.positionCS = TransformObjectToHClip(input.positionOS.xyz);
- output.uv = TRANSFORM_TEX(input.texcoord, _BaseMap);
-
- return output;
- }
-
- half4 Frag(Varyings input) : SV_Target
- {
- UNITY_SETUP_INSTANCE_ID(input);
- return half4(_ObjectId, _PassValue, 1.0, 1.0);
- }
-
- ENDHLSL
- }
- }
-
- FallBack Off
- }
|