Update shader to support instancing

This commit is contained in:
Santiago Lo Coco 2024-10-19 22:35:40 +02:00
parent 69dcce681c
commit a791d7011d
1 changed files with 8 additions and 1 deletions

View File

@ -24,6 +24,7 @@ Shader "WebView/Unlit"
{ {
float4 vertex : POSITION; float4 vertex : POSITION;
float2 uv : TEXCOORD0; float2 uv : TEXCOORD0;
UNITY_VERTEX_INPUT_INSTANCE_ID
}; };
struct v2f struct v2f
@ -31,6 +32,8 @@ Shader "WebView/Unlit"
float2 uv : TEXCOORD0; float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1) UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION; float4 vertex : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
UNITY_VERTEX_OUTPUT_STEREO
}; };
float _Brightness; float _Brightness;
@ -40,6 +43,9 @@ Shader "WebView/Unlit"
v2f vert (appdata v) v2f vert (appdata v)
{ {
v2f o; v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_TRANSFER_INSTANCE_ID(v, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex); o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex); o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex); UNITY_TRANSFER_FOG(o,o.vertex);
@ -48,6 +54,7 @@ Shader "WebView/Unlit"
fixed4 frag (v2f i) : SV_Target fixed4 frag (v2f i) : SV_Target
{ {
UNITY_SETUP_INSTANCE_ID(i);
// sample the texture // sample the texture
fixed4 col = tex2D(_MainTex, i.uv); fixed4 col = tex2D(_MainTex, i.uv);
col.rgb = GammaToLinearSpace(col.rgb) * _Brightness; col.rgb = GammaToLinearSpace(col.rgb) * _Brightness;