Skip to content

Commit 7b40522

Browse files
committed
feat(General): Unlit shader is now compatible with SRP batching
1 parent bd0aad7 commit 7b40522

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

General/Shader/Unlit.shader

+14-5
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,12 @@ Shader "47E/Unlit"
4646
CGPROGRAM
4747
#pragma vertex vert
4848
#pragma fragment frag
49+
#pragma multi_compile_instancing
4950

5051
#include "UnityCG.cginc"
5152

52-
#pragma shader_feature ALPHA_CLIP
53-
#pragma shader_feature VERTEX_COLOR
53+
#pragma multi_compile ALPHA_CLIP
54+
#pragma multi_compile VERTEX_COLOR
5455

5556
struct appdata
5657
{
@@ -64,24 +65,32 @@ Shader "47E/Unlit"
6465

6566
struct v2f
6667
{
68+
float4 vertex : SV_POSITION;
6769
float2 uv : TEXCOORD0;
68-
float4 vertex : SV_POSITION;
6970
#ifdef VERTEX_COLOR
7071
fixed4 color : COLOR;
7172
#endif
7273
UNITY_VERTEX_OUTPUT_STEREO
7374
};
74-
75+
76+
UNITY_INSTANCING_BUFFER_START(UnityPerMaterial)
7577
sampler2D _MainTex;
76-
fixed4 _MainTex_ST;
78+
float4 _MainTex_ST;
7779
fixed4 _Color;
80+
#ifdef ALPHA_CLIP
7881
fixed _AlphaClip;
82+
#endif
7983
fixed _AlphaMultiplier;
84+
UNITY_INSTANCING_BUFFER_END(UnityPerMaterial)
8085

8186
v2f vert(appdata v)
8287
{
8388
v2f o;
8489
UNITY_SETUP_INSTANCE_ID(v);
90+
//https://forum.unity.com/threads/gpu-instancing-with-single-pass-stereo-rendering.1222533/
91+
//#ifdef UNITY_STEREO_INSTANCING_ENABLED
92+
//InstanceID = InstanceID/2;
93+
//#endif
8594
UNITY_INITIALIZE_OUTPUT(v2f, o);
8695
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
8796

General/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "com.fortysevene.youneiti-toolbox",
3-
"version": "1.1.24",
3+
"version": "1.1.25",
44
"unity": "2019.3",
55
"displayName": "YouNeiTi Toolbox",
66
"description": "A collection of handy tools making unity devs happier",

0 commit comments

Comments
 (0)