libgarbage: support instancing

This commit is contained in:
Crispy 2023-07-25 12:35:36 +02:00
parent a1030ca528
commit 299cf8ff32

View file

@ -82,12 +82,14 @@ START_RAYS_IN_SPHERE // TODO: implement
struct AppData { struct AppData {
float4 vertex : POSITION; float4 vertex : POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID
}; };
struct V2F { struct V2F {
float4 vertex : SV_POSITION; float4 vertex : SV_POSITION;
float3 cam_pos : TEXCOORD0; float3 cam_pos : TEXCOORD0;
float3 hit_pos : TEXCOORD1; float3 hit_pos : TEXCOORD1;
UNITY_VERTEX_OUTPUT_STEREO
}; };
struct FragOut { struct FragOut {
@ -139,6 +141,9 @@ Ray cast_ray(float3 p, float3 d, float startDist = 0);
V2F vert (AppData v) { V2F vert (AppData v) {
V2F o; V2F o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(V2F, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.vertex = UnityObjectToClipPos(v.vertex); o.vertex = UnityObjectToClipPos(v.vertex);
#ifdef USE_WORLD_SPACE #ifdef USE_WORLD_SPACE
o.cam_pos = _WorldSpaceCameraPos; o.cam_pos = _WorldSpaceCameraPos;