Procházet zdrojové kódy

Merge pull request #67416 from clayjohn/GLES3-primitive

Fix drawing of 2D primitives in OpenGL3 renderer
Rémi Verschelde před 2 roky
rodič
revize
6feded171b
1 změnil soubory, kde provedl 8 přidání a 7 odebrání
  1. 8 7
      drivers/gles3/rasterizer_canvas_gles3.cpp

+ 8 - 7
drivers/gles3/rasterizer_canvas_gles3.cpp

@@ -1013,7 +1013,7 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, const Tran
 				_add_to_batch(r_index, r_batch_broken);
 
 				if (primitive->point_count == 4) {
-					// Reset base data
+					// Reset base data.
 					_update_transform_2d_to_mat2x3(base_transform * draw_transform, state.instance_data_array[r_index].world);
 					state.instance_data_array[r_index].color_texture_pixel_size[0] = 0.0;
 					state.instance_data_array[r_index].color_texture_pixel_size[1] = 0.0;
@@ -1021,12 +1021,13 @@ void RasterizerCanvasGLES3::_record_item_commands(const Item *p_item, const Tran
 					state.instance_data_array[r_index].flags = base_flags | (state.instance_data_array[r_index - 1].flags & (FLAGS_DEFAULT_NORMAL_MAP_USED | FLAGS_DEFAULT_SPECULAR_MAP_USED)); //reset on each command for sanity, keep canvastexture binding config
 
 					for (uint32_t j = 0; j < 3; j++) {
-						//second half of triangle
-						state.instance_data_array[r_index].points[j * 2 + 0] = primitive->points[j + 1].x;
-						state.instance_data_array[r_index].points[j * 2 + 1] = primitive->points[j + 1].y;
-						state.instance_data_array[r_index].uvs[j * 2 + 0] = primitive->uvs[j + 1].x;
-						state.instance_data_array[r_index].uvs[j * 2 + 1] = primitive->uvs[j + 1].y;
-						Color col = primitive->colors[j + 1] * base_color;
+						int offset = j == 0 ? 0 : 1;
+						// Second triangle in the quad. Uses vertices 0, 2, 3.
+						state.instance_data_array[r_index].points[j * 2 + 0] = primitive->points[j + offset].x;
+						state.instance_data_array[r_index].points[j * 2 + 1] = primitive->points[j + offset].y;
+						state.instance_data_array[r_index].uvs[j * 2 + 0] = primitive->uvs[j + offset].x;
+						state.instance_data_array[r_index].uvs[j * 2 + 1] = primitive->uvs[j + offset].y;
+						Color col = primitive->colors[j + offset] * base_color;
 						state.instance_data_array[r_index].colors[j * 2 + 0] = (uint32_t(Math::make_half_float(col.g)) << 16) | Math::make_half_float(col.r);
 						state.instance_data_array[r_index].colors[j * 2 + 1] = (uint32_t(Math::make_half_float(col.a)) << 16) | Math::make_half_float(col.b);
 					}