144 lines
4.3 KiB
Plaintext
144 lines
4.3 KiB
Plaintext
|
|
// 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
|
|
}
|