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;