Fix for bug #5680:

Vertex color node worked only if VCol Paint/Light was enabled. Fixed
that, and removed the vertex color node making it part of the geometry
node instead.

Also, preview.blend had black vertex colors for the sphere, so set them
to white like the other primitives.
This commit is contained in:
Brecht Van Lommel 2007-01-14 15:19:27 +00:00
parent d4f4bf85be
commit 878d9f9c68
8 changed files with 13718 additions and 13575 deletions

Binary file not shown.

@ -183,7 +183,6 @@ struct ShadeResult;
#define SH_NODE_MATH 115
#define SH_NODE_VECT_MATH 116
#define SH_NODE_SQUEEZE 117
#define SH_NODE_VERTEX_COL 118
/* custom defines: options for Material node */
#define SH_NODE_MAT_DIFF 1
#define SH_NODE_MAT_SPEC 2
@ -195,7 +194,7 @@ extern bNodeType *node_all_shaders[];
/* API */
void ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
int ntreeShaderGetTexco(struct bNodeTree *ntree, int osa);
void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
void nodeShaderSynchronizeID(struct bNode *node, int copyto);
/* switch material render loop */

@ -650,7 +650,7 @@ static void init_render_nodetree(bNodeTree *ntree, Material *basemat, int r_mode
}
}
/* parses the geom+tex nodes */
basemat->texco |= ntreeShaderGetTexco(ntree, r_mode);
ntreeShaderGetTexcoMode(ntree, r_mode, &basemat->texco, &basemat->mode_l);
}
void init_render_material(Material *mat, int r_mode, float *amb)

@ -787,8 +787,6 @@ bNode *nodeAddNodeType(bNodeTree *ntree, int type, bNodeTree *ngroup)
node->storage= curvemapping_add(4, 0.0f, 0.0f, 1.0f, 1.0f);
else if(type==SH_NODE_GEOMETRY)
node->storage= MEM_callocN(sizeof(NodeGeometry), "NodeGeometry");
else if(type==SH_NODE_VERTEX_COL)
node->storage= MEM_callocN(sizeof(NodeVertexCol), "NodeVertexCol");
}
else if(ntree->type==NTREE_COMPOSIT) {
if(type==CMP_NODE_VALTORGB)

@ -171,6 +171,7 @@ static bNodeType sh_node_output= {
#define GEOM_OUT_ORCO 3
#define GEOM_OUT_UV 4
#define GEOM_OUT_NORMAL 5
#define GEOM_OUT_VCOL 6
/* output socket type definition */
static bNodeSocketType sh_node_geom_out[]= {
@ -180,6 +181,7 @@ static bNodeSocketType sh_node_geom_out[]= {
{ SOCK_VECTOR, 0, "Orco", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
{ SOCK_VECTOR, 0, "UV", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
{ SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
{ SOCK_RGBA, 0, "Vertex Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
@ -188,11 +190,13 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **in, bNod
{
if(data) {
ShadeInput *shi= ((ShaderCallData *)data)->shi;
ShadeInputUV *suv= &shi->uv[0];
NodeGeometry *ngeo= (NodeGeometry*)node->storage;
ShadeInputUV *suv= &shi->uv[0];
static float defaultvcol[4] = {1.0f, 1.0f, 1.0f, 1.0f};
int i;
if(ngeo->uvname[0]) {
/* find uv layer by name */
for(i = 0; i < shi->totuv; i++) {
if(strcmp(shi->uv[i].name, ngeo->uvname)==0) {
suv= &shi->uv[i];
@ -200,14 +204,33 @@ static void node_shader_exec_geom(void *data, bNode *node, bNodeStack **in, bNod
}
}
}
/* out: global, local, view, orco, uv, normal */
/* out: global, local, view, orco, uv, normal, vertex color */
VECCOPY(out[GEOM_OUT_GLOB]->vec, shi->gl);
VECCOPY(out[GEOM_OUT_LOCAL]->vec, shi->co);
VECCOPY(out[GEOM_OUT_VIEW]->vec, shi->view);
VECCOPY(out[GEOM_OUT_ORCO]->vec, shi->lo);
VECCOPY(out[GEOM_OUT_UV]->vec, suv->uv);
VECCOPY(out[GEOM_OUT_NORMAL]->vec, shi->vno);
if (shi->totcol) {
/* find vertex color layer by name */
ShadeInputCol *scol= &shi->col[0];
if(ngeo->colname[0]) {
for(i = 0; i < shi->totcol; i++) {
if(strcmp(shi->col[i].name, ngeo->colname)==0) {
scol= &shi->col[i];
break;
}
}
}
VECCOPY(out[GEOM_OUT_VCOL]->vec, scol->col);
out[GEOM_OUT_VCOL]->vec[3]= 1.0f;
}
else
memcpy(out[GEOM_OUT_VCOL]->vec, defaultvcol, sizeof(defaultvcol));
if(shi->osatex) {
out[GEOM_OUT_GLOB]->data= shi->dxgl;
@ -1069,51 +1092,6 @@ static bNodeType sh_node_rgbtobw= {
};
/* **************** VERTEX COLOR ******************** */
/* output socket type definition */
static bNodeSocketType sh_node_vertexcol_out[]= {
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
{ -1, 0, "" }
};
/* node execute callback */
static void node_shader_exec_vertexcol(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
{
if(data) {
ShadeInput *shi= ((ShaderCallData *)data)->shi;
ShadeInputCol *scol= &shi->col[0];
NodeVertexCol *nvcol= (NodeVertexCol*)node->storage;
int i;
if(nvcol->name[0]) {
for(i = 0; i < shi->totcol; i++) {
if(strcmp(shi->col[i].name, nvcol->name)==0) {
scol= &shi->col[i];
break;
}
}
}
VECCOPY(out[0]->vec, scol->col);
out[0]->vec[3]= 1.0f;
}
}
/* node type definition */
static bNodeType sh_node_vertexcol= {
/* type code */ SH_NODE_VERTEX_COL,
/* name */ "Vertex Color",
/* width+range */ 120, 80, 160,
/* class+opts */ NODE_CLASS_INPUT, NODE_OPTIONS,
/* input sock */ NULL,
/* output sock */ sh_node_vertexcol_out,
/* storage */ "NodeVertexCol",
/* execfunc */ node_shader_exec_vertexcol
};
/* ****************** types array for all shaders ****************** */
bNodeType *node_all_shaders[]= {
@ -1135,7 +1113,6 @@ bNodeType *node_all_shaders[]= {
&sh_node_math,
&sh_node_vect_math,
&sh_node_squeeze,
&sh_node_vertexcol,
NULL
};
@ -1162,20 +1139,20 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
/* go over all used Geometry and Texture nodes, and return a texco flag */
/* no group inside needed, this function is called for groups too */
int ntreeShaderGetTexco(bNodeTree *ntree, int r_mode)
void ntreeShaderGetTexcoMode(bNodeTree *ntree, int r_mode, short *texco, int *mode)
{
bNode *node;
bNodeSocket *sock;
int texco= 0, a;
int a;
ntreeSocketUseFlags(ntree);
for(node= ntree->nodes.first; node; node= node->next) {
if(node->type==SH_NODE_TEXTURE) {
if((r_mode & R_OSA) && node->id) {
Tex *tex= (Tex *)node->id;
if ELEM3(tex->type, TEX_IMAGE, TEX_PLUGIN, TEX_ENVMAP)
texco |= TEXCO_OSA|NEED_UV;
*texco |= TEXCO_OSA|NEED_UV;
}
}
else if(node->type==SH_NODE_GEOMETRY) {
@ -1184,22 +1161,22 @@ int ntreeShaderGetTexco(bNodeTree *ntree, int r_mode)
if(sock->flag & SOCK_IN_USE) {
switch(a) {
case GEOM_OUT_GLOB:
texco |= TEXCO_GLOB|NEED_UV; break;
*texco |= TEXCO_GLOB|NEED_UV; break;
case GEOM_OUT_VIEW:
texco |= TEXCO_VIEW|NEED_UV; break;
*texco |= TEXCO_VIEW|NEED_UV; break;
case GEOM_OUT_ORCO:
texco |= TEXCO_ORCO|NEED_UV; break;
*texco |= TEXCO_ORCO|NEED_UV; break;
case GEOM_OUT_UV:
texco |= TEXCO_UV|NEED_UV; break;
*texco |= TEXCO_UV|NEED_UV; break;
case GEOM_OUT_NORMAL:
texco |= TEXCO_NORM|NEED_UV; break;
*texco |= TEXCO_NORM|NEED_UV; break;
case GEOM_OUT_VCOL:
*texco |= NEED_UV; *mode |= MA_VERTEXCOL; break;
}
}
}
}
}
return texco;
}
/* nodes that use ID data get synced with local data */

@ -215,6 +215,7 @@ typedef struct NodeChroma {
typedef struct NodeGeometry {
char uvname[32];
char colname[32];
} NodeGeometry;
typedef struct NodeVertexCol {

@ -604,24 +604,13 @@ static int node_shader_buts_geometry(uiBlock *block, bNodeTree *ntree, bNode *no
if(block) {
NodeGeometry *ngeo= (NodeGeometry*)node->storage;
uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "UV:", butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, ngeo->uvname, 0, 31, 0, 0, "Set name of UV layer to use, default is active UV layer");
uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "UV:", butr->xmin, butr->ymin+20, butr->xmax-butr->xmin, 20, ngeo->uvname, 0, 31, 0, 0, "Set name of UV layer to use, default is active UV layer");
uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "Col:", butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, ngeo->colname, 0, 31, 0, 0, "Set name of vertex color layer to use, default is active vertex color layer");
}
return 20;
return 40;
}
static int node_shader_buts_vertexcol(uiBlock *block, bNodeTree *ntree, bNode *node, rctf *butr)
{
if(block) {
NodeVertexCol *nvcol= (NodeVertexCol*)node->storage;
uiDefBut(block, TEX, B_NODE_EXEC+node->nr, "Name:", butr->xmin, butr->ymin, butr->xmax-butr->xmin, 20, nvcol->name, 0, 31, 0, 0, "Set name of vertex color layer to use, default is active vertex color layer");
}
return 20;
}
/* only once called */
static void node_shader_set_butfunc(bNodeType *ntype)
{
@ -668,9 +657,6 @@ static void node_shader_set_butfunc(bNodeType *ntype)
case SH_NODE_GEOMETRY:
ntype->butfunc= node_shader_buts_geometry;
break;
case SH_NODE_VERTEX_COL:
ntype->butfunc= node_shader_buts_vertexcol;
break;
default:
ntype->butfunc= NULL;
}

File diff suppressed because it is too large Load Diff