Merge branch 'master' into blender2.8
[blender.git] / source / blender / blenkernel / intern / editderivedmesh.c
index 5fba6c2..e30dbd7 100644 (file)
@@ -1402,6 +1402,24 @@ static void emDM_drawMappedFacesTex(
        emDM_drawFacesTex_common(dm, NULL, setDrawOptions, compareDrawOptions, userData);
 }
 
+static void emdm_pass_attrib_update_uniforms(const DMVertexAttribs *attribs)
+{
+       int i;
+       if (attribs->totorco) {
+               glUniform1i(attribs->orco.gl_info_index, 0);
+       }
+       for (i = 0; i < attribs->tottface; i++) {
+               glUniform1i(attribs->tface[i].gl_info_index, 0);
+       }
+       for (i = 0; i < attribs->totmcol; i++) {
+               glUniform1i(attribs->mcol[i].gl_info_index, GPU_ATTR_INFO_SRGB);
+       }
+
+       for (i = 0; i < attribs->tottang; i++) {
+               glUniform1i(attribs->tang[i].gl_info_index, 0);
+       }
+}
+
 /**
  * \note
  *
@@ -1428,7 +1446,6 @@ static void emdm_pass_attrib_vertex_glsl(const DMVertexAttribs *attribs, const B
                        glTexCoord3fv(orco);
                else
                        glVertexAttrib3fv(attribs->orco.gl_index, orco);
-               glUniform1i(attribs->orco.gl_info_index, 0);
        }
        for (i = 0; i < attribs->tottface; i++) {
                const float *uv;
@@ -1445,7 +1462,6 @@ static void emdm_pass_attrib_vertex_glsl(const DMVertexAttribs *attribs, const B
                        glTexCoord2fv(uv);
                else
                        glVertexAttrib2fv(attribs->tface[i].gl_index, uv);
-               glUniform1i(attribs->tface[i].gl_info_index, 0);
        }
        for (i = 0; i < attribs->totmcol; i++) {
                float col[4];
@@ -1457,7 +1473,6 @@ static void emdm_pass_attrib_vertex_glsl(const DMVertexAttribs *attribs, const B
                        col[0] = 0.0f; col[1] = 0.0f; col[2] = 0.0f; col[3] = 0.0f;
                }
                glVertexAttrib4fv(attribs->mcol[i].gl_index, col);
-               glUniform1i(attribs->mcol[i].gl_info_index, GPU_ATTR_INFO_SRGB);
        }
 
        for (i = 0; i < attribs->tottang; i++) {
@@ -1469,7 +1484,6 @@ static void emdm_pass_attrib_vertex_glsl(const DMVertexAttribs *attribs, const B
                        tang = zero;
                }
                glVertexAttrib4fv(attribs->tang[i].gl_index, tang);
-               glUniform1i(attribs->tang[i].gl_info_index, 0);
        }
 }
 
@@ -1526,6 +1540,7 @@ static void emDM_drawMappedFacesGLSL(
                        do_draw = setMaterial(matnr = new_matnr, &gattribs);
                        if (do_draw) {
                                DM_vertex_attributes_from_gpu(dm, &gattribs, &attribs);
+                               emdm_pass_attrib_update_uniforms(&attribs);
                                if (UNLIKELY(attribs.tottang && bm->elem_index_dirty & BM_LOOP)) {
                                        BM_mesh_elem_index_ensure(bm, BM_LOOP);
                                }