Page MenuHome

vcolbake_1to2.patch

File Metadata

Author
Alex Fraser (adfries)
Created
Nov 13 2013, 4:02 PM

vcolbake_1to2.patch

diff --git a/source/blender/render/intern/source/rendercore.c b/source/blender/render/intern/source/rendercore.c
index 344caf1..3ebc022 100644
--- a/source/blender/render/intern/source/rendercore.c
+++ b/source/blender/render/intern/source/rendercore.c
@@ -2482,6 +2482,11 @@ static int get_next_bake_face(BakeShade *bs)
if(obr->ob->type != OB_MESH)
continue;
me = obr->ob->data;
+#if 0
+ /* Only shade selected faces. */
+ if((me->mface[*origindex].flag & ME_FACE_SEL) == 0)
+ continue;
+#endif
vcollayer = CustomData_get_render_layer_index(&me->fdata, CD_MCOL);
if(vcollayer == -1)
@@ -2553,7 +2558,6 @@ static void shade_verts(BakeShade *bs)
{
VlakRen *vlr= bs->vlr;
MCol *basevcol;
- float vec[4][2];
int i1, i2, i3, i4;
/* Disable baking to image; write to vcol instead (pointer set below). */
@@ -2563,30 +2567,47 @@ static void shade_verts(BakeShade *bs)
bs->quad= 0;
- i1= 0; i2= 1; i3= 2;
- vlr_set_uv_indices(vlr, &i1, &i2, &i3);
- bake_set_vlr_dxyco(bs, vec[i1], vec[i2], vec[i3]);
+ /* No anti-aliasing for vertices. */
+ bs->dxco[0]= bs->dxco[1]= bs->dxco[2]= 0.0f;
+ bs->dyco[0]= bs->dyco[1]= bs->dyco[2]= 0.0f;
/* Shade each vertex of the face. u and v are barycentric coordinates; since
we're only interested in vertices, these will be 0 or 1. */
basevcol = bs->vcol;
- bs->vcol= basevcol + i1;
- do_bake_shade(bs, 0, 0, 1.0f, 0.0f);
- bs->vcol= basevcol + i2;
- do_bake_shade(bs, 0, 0, 0.0f, 1.0f);
- bs->vcol= basevcol + i3;
- do_bake_shade(bs, 0, 0, 0.0f, 0.0f);
+ if((vlr->flag & R_FACE_SPLIT) == 0) {
+ /* Processing triangle face, whole quad, or first half of split quad.
+ Vertex indices have to be corrected for possible split. */
+ i1= 0; i2= 1; i3= 2;
+ vlr_set_uv_indices(vlr, &i1, &i2, &i3);
+
+ bs->vcol= basevcol + i1;
+ do_bake_shade(bs, 0, 0, 1.0f, 0.0f);
+ bs->vcol= basevcol + i2;
+ do_bake_shade(bs, 0, 0, 0.0f, 1.0f);
+ bs->vcol= basevcol + i3;
+ do_bake_shade(bs, 0, 0, 0.0f, 0.0f);
- if(vlr->v4) {
- bs->quad= 1;
- bake_set_vlr_dxyco(bs, vec[0], vec[2], vec[3]);
- /* Find index to use for fourth vertex. */
- for(i4=0; i4<4; i4++) {
- if(i4 != i1 && i4 != i2 && i4 != i3)
- break;
+ if(vlr->v4) {
+ bs->quad= 1;
+ /* Find index to use for fourth vertex. */
+ for(i4=0; i4<4; i4++) {
+ if(i4 != i1 && i4 != i2 && i4 != i3)
+ break;
+ }
+ bs->vcol= basevcol + i4;
+ do_bake_shade(bs, 0, 0, 0.0f, 0.0f);
+ }
+ }
+ else {
+ /* Processing second half of split quad. Only one vertex to go. */
+ if(vlr->flag &R_DIVIDE_24) {
+ bs->vcol= basevcol + 2;
+ do_bake_shade(bs, 0, 0, 0.0f, 1.0f);
+ }
+ else {
+ bs->vcol= basevcol + 3;
+ do_bake_shade(bs, 0, 0, 0.0f, 0.0f);
}
- bs->vcol= basevcol + i4;
- do_bake_shade(bs, 0, 0, 0.0f, 0.0f);
}
bs->vcol = basevcol;
}
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index 55d3703..c472240 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -238,7 +238,8 @@ void vlr_set_uv_indices(VlakRen *vlr, int *i1, int *i2, int *i3)
/* |0\ | |/ 0| */
/* 1---2 1---2 0 = orig face, 1 = new face */
- /* Update vert nums to point to correct verts of original face */
+ /* Update vert nums to point to correct verts of original face. See also
+ splitting logic in check_non_flat_quads. */
if(vlr->flag & R_DIVIDE_24) {
if(vlr->flag & R_FACE_SPLIT) {
(*i1)++; (*i2)++; (*i3)++;

Event Timeline