diff options
author | Thomas Herzog <therzog@mail.de> | 2018-08-24 11:23:42 +0200 |
---|---|---|
committer | Thomas Herzog <therzog@mail.de> | 2018-08-24 11:23:42 +0200 |
commit | 211e0fa4aae880fb295804f3309588b50736a2a5 (patch) | |
tree | 8df70804fdc06d86bb2420e480e5af265015f85a | |
parent | 34e58fd831172bad1eebb748c97238c28864423a (diff) |
[GLES2] fix multimesh byte colors
When using float colors, everything works fine, but when using
the byte format, the colors were read incorrectly.
-rw-r--r-- | drivers/gles2/rasterizer_scene_gles2.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index 1655f55bfa..4078302027 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -1216,6 +1216,12 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { glDisableVertexAttribArray(15); // color glDisableVertexAttribArray(8); // custom data + if (!s->attribs[VS::ARRAY_COLOR].enabled) { + glDisableVertexAttribArray(VS::ARRAY_COLOR); + + glVertexAttrib4f(VS::ARRAY_COLOR, 1, 1, 1, 1); + } + glVertexAttrib4f(15, 1, 1, 1, 1); glVertexAttrib4f(8, 0, 0, 0, 0); @@ -1259,7 +1265,12 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) { } if (multi_mesh->color_floats) { - glVertexAttrib4fv(15, buffer + color_ofs); + if (multi_mesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + uint8_t *color_data = (uint8_t *)(buffer + color_ofs); + glVertexAttrib4f(15, color_data[0] / 255.0, color_data[1] / 255.0, color_data[2] / 255.0, color_data[3] / 255.0); + } else { + glVertexAttrib4fv(15, buffer + color_ofs); + } } if (multi_mesh->custom_data_floats) { |