58 lines
1.4 KiB
Plaintext
58 lines
1.4 KiB
Plaintext
Shader "Custom/InstancedIndirectColor"
|
|
{
|
|
SubShader
|
|
{
|
|
Tags
|
|
{
|
|
"RenderType" = "Opaque"
|
|
}
|
|
|
|
Pass
|
|
{
|
|
HLSLPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
|
|
#include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl"
|
|
|
|
struct appdata_t
|
|
{
|
|
float4 vertex : POSITION;
|
|
half4 color : COLOR;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
float4 color : COLOR;
|
|
};
|
|
|
|
struct MeshProperties
|
|
{
|
|
float4x4 mat;
|
|
float4 color;
|
|
};
|
|
|
|
StructuredBuffer<MeshProperties> _Properties;
|
|
|
|
v2f vert(appdata_t i, uint instanceID: SV_InstanceID)
|
|
{
|
|
v2f o;
|
|
|
|
const MeshProperties properties = _Properties[instanceID];
|
|
float4 pos = mul(properties.mat, i.vertex);
|
|
float4 worldPos = mul(UNITY_MATRIX_M, pos);
|
|
o.vertex = mul(UNITY_MATRIX_VP, worldPos);
|
|
o.color = properties.color;
|
|
|
|
return o;
|
|
}
|
|
|
|
half4 frag(v2f i) : SV_Target
|
|
{
|
|
return i.color;
|
|
}
|
|
ENDHLSL
|
|
}
|
|
}
|
|
} |