mirror of https://github.com/godotengine/godot
Merge pull request #103348 from huwpascoe/render_params_fix
Fix 2D instance params crashing using outside of `main()`
This commit is contained in:
commit
8777f088cc
|
|
@ -1837,7 +1837,7 @@ RendererCanvasRenderRD::RendererCanvasRenderRD() {
|
|||
actions.base_varying_index = 5;
|
||||
|
||||
actions.global_buffer_array_variable = "global_shader_uniforms.data";
|
||||
actions.instance_uniform_index_variable = "draw_data.instance_uniforms_ofs";
|
||||
actions.instance_uniform_index_variable = "instances.data[instance_index].instance_uniforms_ofs";
|
||||
|
||||
shader.compiler.initialize(actions);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ layout(set = 1, binding = 0, std140) uniform MaterialUniforms {
|
|||
/* clang-format on */
|
||||
#endif
|
||||
|
||||
uint instance_index;
|
||||
|
||||
#GLOBALS
|
||||
|
||||
#ifdef USE_ATTRIBUTES
|
||||
|
|
@ -66,9 +68,9 @@ void main() {
|
|||
#endif
|
||||
|
||||
#ifdef USE_ATTRIBUTES
|
||||
uint instance_index = params.base_instance_index;
|
||||
instance_index = params.base_instance_index;
|
||||
#else
|
||||
uint instance_index = gl_InstanceIndex + params.base_instance_index;
|
||||
instance_index = gl_InstanceIndex + params.base_instance_index;
|
||||
instance_index_interp = instance_index;
|
||||
#endif // USE_ATTRIBUTES
|
||||
const InstanceData draw_data = instances.data[instance_index];
|
||||
|
|
@ -240,7 +242,7 @@ void main() {
|
|||
#include "canvas_uniforms_inc.glsl"
|
||||
|
||||
#ifndef USE_ATTRIBUTES
|
||||
layout(location = 4) in flat uint instance_index;
|
||||
layout(location = 4) in flat uint instance_index_interp;
|
||||
#endif // USE_ATTRIBUTES
|
||||
|
||||
layout(location = 0) in vec2 uv_interp;
|
||||
|
|
@ -287,6 +289,8 @@ vec2 sdf_to_screen_uv(vec2 p_sdf) {
|
|||
return p_sdf * canvas_data.sdf_to_screen;
|
||||
}
|
||||
|
||||
uint instance_index;
|
||||
|
||||
#GLOBALS
|
||||
|
||||
#ifdef LIGHT_CODE_USED
|
||||
|
|
@ -461,10 +465,11 @@ void main() {
|
|||
vec2 vertex = vertex_interp;
|
||||
|
||||
#ifdef USE_ATTRIBUTES
|
||||
const InstanceData draw_data = instances.data[params.base_instance_index];
|
||||
instance_index = params.base_instance_index;
|
||||
#else
|
||||
const InstanceData draw_data = instances.data[instance_index];
|
||||
instance_index = instance_index_interp;
|
||||
#endif // USE_ATTRIBUTES
|
||||
const InstanceData draw_data = instances.data[instance_index];
|
||||
|
||||
#if !defined(USE_ATTRIBUTES) && !defined(USE_PRIMITIVE)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue