From ad731aebcbb4c3e68d590585ec6eb01beab6aa33 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Tue, 14 Jun 2022 10:30:54 -0700 Subject: [PATCH] fix getInstanceIndex() it would be initialized after user material code was called. --- shaders/src/main.vs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shaders/src/main.vs b/shaders/src/main.vs index 61e0c33b56..d6ed71ac7d 100644 --- a/shaders/src/main.vs +++ b/shaders/src/main.vs @@ -7,6 +7,12 @@ */ void main() { +#if defined(TARGET_METAL_ENVIRONMENT) || defined(TARGET_VULKAN_ENVIRONMENT) + instance_index = gl_InstanceIndex; +#else + instance_index = gl_InstanceID; +#endif + // Initialize the inputs to sensible default values, see material_inputs.vs #if defined(USE_OPTIMIZED_DEPTH_VERTEX_SHADER) @@ -179,12 +185,6 @@ void main() { vertex_worldPosition.w = depth; #endif -#if defined(TARGET_METAL_ENVIRONMENT) || defined(TARGET_VULKAN_ENVIRONMENT) - instance_index = gl_InstanceIndex; -#else - instance_index = gl_InstanceID; -#endif - // this must happen before we compensate for vulkan below vertex_position = gl_Position;