Browse Source

Merge pull request #43679 from lawnjelly/ewok_rect_color_fix

Prevent poly color path when translating batches than are non-poly
Rémi Verschelde 4 years ago
parent
commit
3a8e1f324f
1 changed files with 13 additions and 7 deletions
  1. 13 7
      drivers/gles_common/rasterizer_canvas_batcher.h

+ 13 - 7
drivers/gles_common/rasterizer_canvas_batcher.h

@@ -579,7 +579,7 @@ private:
 	// translating vertex formats prior to rendering
 	// translating vertex formats prior to rendering
 	void _translate_batches_to_vertex_colored_FVF();
 	void _translate_batches_to_vertex_colored_FVF();
 	template <class BATCH_VERTEX_TYPE, bool INCLUDE_LIGHT_ANGLES, bool INCLUDE_MODULATE, bool INCLUDE_LARGE>
 	template <class BATCH_VERTEX_TYPE, bool INCLUDE_LIGHT_ANGLES, bool INCLUDE_MODULATE, bool INCLUDE_LARGE>
-	void _translate_batches_to_larger_FVF();
+	void _translate_batches_to_larger_FVF(uint32_t p_sequence_batch_type_flags);
 
 
 protected:
 protected:
 	// accessory funcs
 	// accessory funcs
@@ -2344,19 +2344,19 @@ PREAMBLE(void)::flush_render_batches(RasterizerCanvas::Item *p_first_item, Raste
 		case RasterizerStorageCommon::FVF_COLOR: {
 		case RasterizerStorageCommon::FVF_COLOR: {
 			// special case, where vertex colors are used (polys)
 			// special case, where vertex colors are used (polys)
 			if (!bdata.vertex_colors.size())
 			if (!bdata.vertex_colors.size())
-				_translate_batches_to_larger_FVF<BatchVertexColored, false, false, false>();
+				_translate_batches_to_larger_FVF<BatchVertexColored, false, false, false>(p_sequence_batch_type_flags);
 			else
 			else
 				// normal, reduce number of batches by baking batch colors
 				// normal, reduce number of batches by baking batch colors
 				_translate_batches_to_vertex_colored_FVF();
 				_translate_batches_to_vertex_colored_FVF();
 		} break;
 		} break;
 		case RasterizerStorageCommon::FVF_LIGHT_ANGLE:
 		case RasterizerStorageCommon::FVF_LIGHT_ANGLE:
-			_translate_batches_to_larger_FVF<BatchVertexLightAngled, true, false, false>();
+			_translate_batches_to_larger_FVF<BatchVertexLightAngled, true, false, false>(p_sequence_batch_type_flags);
 			break;
 			break;
 		case RasterizerStorageCommon::FVF_MODULATED:
 		case RasterizerStorageCommon::FVF_MODULATED:
-			_translate_batches_to_larger_FVF<BatchVertexModulated, true, true, false>();
+			_translate_batches_to_larger_FVF<BatchVertexModulated, true, true, false>(p_sequence_batch_type_flags);
 			break;
 			break;
 		case RasterizerStorageCommon::FVF_LARGE:
 		case RasterizerStorageCommon::FVF_LARGE:
-			_translate_batches_to_larger_FVF<BatchVertexLarge, true, true, true>();
+			_translate_batches_to_larger_FVF<BatchVertexLarge, true, true, true>(p_sequence_batch_type_flags);
 			break;
 			break;
 	}
 	}
 
 
@@ -2771,9 +2771,15 @@ PREAMBLE(void)::_translate_batches_to_vertex_colored_FVF() {
 // In addition this can optionally add light angles to the FVF, necessary for normal mapping.
 // In addition this can optionally add light angles to the FVF, necessary for normal mapping.
 T_PREAMBLE
 T_PREAMBLE
 template <class BATCH_VERTEX_TYPE, bool INCLUDE_LIGHT_ANGLES, bool INCLUDE_MODULATE, bool INCLUDE_LARGE>
 template <class BATCH_VERTEX_TYPE, bool INCLUDE_LIGHT_ANGLES, bool INCLUDE_MODULATE, bool INCLUDE_LARGE>
-void C_PREAMBLE::_translate_batches_to_larger_FVF() {
+void C_PREAMBLE::_translate_batches_to_larger_FVF(uint32_t p_sequence_batch_type_flags) {
 
 
-	bool include_poly_color = INCLUDE_LIGHT_ANGLES | INCLUDE_MODULATE | INCLUDE_LARGE;
+	bool include_poly_color = false;
+
+	// we ONLY want to include the color verts in translation when using polys,
+	// as rects do not write vertex colors, only colors per batch.
+	if (p_sequence_batch_type_flags & RasterizerStorageCommon::BTF_POLY) {
+		include_poly_color = INCLUDE_LIGHT_ANGLES | INCLUDE_MODULATE | INCLUDE_LARGE;
+	}
 
 
 	// zeros the size and sets up how big each unit is
 	// zeros the size and sets up how big each unit is
 	bdata.unit_vertices.prepare(sizeof(BATCH_VERTEX_TYPE));
 	bdata.unit_vertices.prepare(sizeof(BATCH_VERTEX_TYPE));