Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GLES3 instanced rendering color and custom data defaults #81575

Merged
merged 1 commit into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions drivers/gles3/rasterizer_canvas_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,6 +1420,13 @@ void RasterizerCanvasGLES3::_render_batch(Light *p_lights, uint32_t p_index) {
glEnableVertexAttribArray(5);
glVertexAttribIPointer(5, 4, GL_UNSIGNED_INT, instance_stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(instance_color_offset * sizeof(float)));
glVertexAttribDivisor(5, 1);
} else {
// Set all default instance color and custom data values to 1.0 or 0.0 using a compressed format.
uint16_t zero = Math::make_half_float(0.0f);
uint16_t one = Math::make_half_float(1.0f);
GLuint default_color = (uint32_t(one) << 16) | one;
GLuint default_custom = (uint32_t(zero) << 16) | zero;
glVertexAttribI4ui(5, default_color, default_color, default_custom, default_custom);
}
}

Expand Down
8 changes: 8 additions & 0 deletions drivers/gles3/rasterizer_scene_gles3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2962,7 +2962,15 @@ void RasterizerSceneGLES3::_render_list_template(RenderListParameters *p_params,
glEnableVertexAttribArray(15);
glVertexAttribIPointer(15, 4, GL_UNSIGNED_INT, stride * sizeof(float), CAST_INT_TO_UCHAR_PTR(color_custom_offset * sizeof(float)));
glVertexAttribDivisor(15, 1);
} else {
// Set all default instance color and custom data values to 1.0 or 0.0 using a compressed format.
uint16_t zero = Math::make_half_float(0.0f);
uint16_t one = Math::make_half_float(1.0f);
GLuint default_color = (uint32_t(one) << 16) | one;
GLuint default_custom = (uint32_t(zero) << 16) | zero;
glVertexAttribI4ui(15, default_color, default_color, default_custom, default_custom);
}

if (use_index_buffer) {
glDrawElementsInstanced(primitive_gl, count, mesh_storage->mesh_surface_get_index_type(mesh_surface), 0, inst->instance_count);
} else {
Expand Down
Loading