Usability

- Cycles materials now render in Blender Internal too, skipping the nodes.
  Not very useful, but at least things then show up on renders and in
  previews.

- Node editor: if wrong shader nodes are in a tree, they draw with thene
  color RED ALERT headers now. (Switching render engine will show it).
This commit is contained in:
Ton Roosendaal 2013-01-24 16:11:07 +00:00
parent 1da7d7d1a0
commit b12a019948
8 changed files with 47 additions and 9 deletions

@ -577,7 +577,7 @@ struct ShadeResult;
struct bNodeTreeExec *ntreeShaderBeginExecTree(struct bNodeTree *ntree, int use_tree_data);
void ntreeShaderEndExecTree(struct bNodeTreeExec *exec, int use_tree_data);
void ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
int ntreeShaderExecTree(struct bNodeTree *ntree, struct ShadeInput *shi, struct ShadeResult *shr);
void ntreeShaderGetTexcoMode(struct bNodeTree *ntree, int osa, short *texco, int *mode);
void nodeShaderSynchronizeID(struct bNode *node, int copyto);

@ -701,6 +701,20 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
if (node->flag & NODE_MUTED)
UI_ThemeColorBlend(color_id, TH_REDALERT, 0.5f);
/* debug info: using wrong shaders in wrong context */
if (ntree->type == NTREE_SHADER) {
if (snode->flag & SNODE_NEW_SHADERS) {
if (node->typeinfo->compatibility == NODE_OLD_SHADING)
UI_ThemeColor(TH_REDALERT);
}
else {
if (node->typeinfo->compatibility == NODE_NEW_SHADING)
UI_ThemeColor(TH_REDALERT);
}
}
#ifdef WITH_COMPOSITOR
if (ntree->type == NTREE_COMPOSIT && (snode->flag & SNODE_SHOW_HIGHLIGHT)) {
@ -795,6 +809,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
/* outline active and selected emphasis */
if (node->flag & SELECT) {
glEnable(GL_BLEND);
glEnable(GL_LINE_SMOOTH);
@ -802,6 +817,7 @@ static void node_draw_basis(const bContext *C, ARegion *ar, SpaceNode *snode, bN
UI_ThemeColorShadeAlpha(TH_ACTIVE, 0, -40);
else
UI_ThemeColorShadeAlpha(TH_SELECT, 0, -40);
uiSetRoundBox(UI_CNR_ALL);
uiDrawBox(GL_LINE_LOOP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, BASIS_RAD);

@ -550,6 +550,12 @@ void snode_set_context(SpaceNode *snode, Scene *scene)
snode->id = snode->from = NULL;
if (snode->treetype == NTREE_SHADER) {
/* we use this to signal warnings, when node shaders are drawn in wrong render engine */
if (BKE_scene_use_new_shading_nodes(scene))
snode->flag |= SNODE_NEW_SHADERS;
else
snode->flag &= ~SNODE_NEW_SHADERS;
/* need active object, or we allow pinning... */
if (snode->shaderfrom == SNODE_SHADER_OBJECT) {
if (ob) {

@ -917,6 +917,7 @@ typedef enum eSpaceNode_Flag {
SNODE_AUTO_RENDER = (1 << 5),
SNODE_SHOW_HIGHLIGHT = (1 << 6),
SNODE_USE_HIDDEN_PREVIEW = (1 << 10),
SNODE_NEW_SHADERS = (1 << 11),
} eSpaceNode_Flag;
/* snode->texfrom */

@ -287,7 +287,7 @@ void ntreeReleaseThreadStack(bNodeThreadStack *nts)
nts->used = 0;
}
void ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *callerdata, int thread)
int ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *callerdata, int thread)
{
bNodeStack *nsin[MAX_SOCKET]; /* arbitrary... watch this */
bNodeStack *nsout[MAX_SOCKET]; /* arbitrary... watch this */
@ -305,10 +305,17 @@ void ntreeExecThreadNodes(bNodeTreeExec *exec, bNodeThreadStack *nts, void *call
* If the mute func is not set, assume the node should never be muted,
* and hence execute it!
*/
if (node->typeinfo->compatibility != NODE_OLD_SHADING)
break;
if (node->typeinfo->execfunc)
node->typeinfo->execfunc(callerdata, node, nsin, nsout);
else if (node->typeinfo->newexecfunc)
node->typeinfo->newexecfunc(callerdata, thread, node, nodeexec->data, nsin, nsout);
}
}
/* signal to switch back to no-node render */
if (node)
return 0;
return 1;
}

@ -79,6 +79,6 @@ void ntree_exec_end(struct bNodeTreeExec *exec);
struct bNodeThreadStack *ntreeGetThreadStack(struct bNodeTreeExec *exec, int thread);
void ntreeReleaseThreadStack(struct bNodeThreadStack *nts);
void ntreeExecThreadNodes(struct bNodeTreeExec *exec, struct bNodeThreadStack *nts, void *callerdata, int thread);
int ntreeExecThreadNodes(struct bNodeTreeExec *exec, struct bNodeThreadStack *nts, void *callerdata, int thread);
#endif

@ -248,7 +248,8 @@ void ntreeShaderEndExecTree(bNodeTreeExec *exec, int use_tree_data)
}
}
void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
/* only for Blender internal */
int ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
{
ShaderCallData scd;
/**
@ -258,6 +259,7 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
Material *mat = shi->mat;
bNodeThreadStack *nts = NULL;
bNodeTreeExec *exec = ntree->execdata;
int compat;
/* convert caller data to struct */
scd.shi = shi;
@ -277,13 +279,17 @@ void ntreeShaderExecTree(bNodeTree *ntree, ShadeInput *shi, ShadeResult *shr)
}
nts = ntreeGetThreadStack(exec, shi->thread);
ntreeExecThreadNodes(exec, nts, &scd, shi->thread);
compat = ntreeExecThreadNodes(exec, nts, &scd, shi->thread);
ntreeReleaseThreadStack(nts);
// \note: set material back to preserved material
shi->mat = mat;
/* better not allow negative for now */
if (shr->combined[0] < 0.0f) shr->combined[0] = 0.0f;
if (shr->combined[1] < 0.0f) shr->combined[1] = 0.0f;
if (shr->combined[2] < 0.0f) shr->combined[2] = 0.0f;
/* if compat is zero, it has been using non-compatible nodes */
return compat;
}

@ -151,6 +151,7 @@ void shade_material_loop(ShadeInput *shi, ShadeResult *shr)
/* do a shade, finish up some passes, apply mist */
void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr)
{
int compat = 0;
float alpha;
/* ------ main shading loop -------- */
@ -158,10 +159,11 @@ void shade_input_do_shade(ShadeInput *shi, ShadeResult *shr)
memset(&shi->raycounter, 0, sizeof(shi->raycounter));
#endif
if (shi->mat->nodetree && shi->mat->use_nodes) {
ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
}
else {
if (shi->mat->nodetree && shi->mat->use_nodes)
compat = ntreeShaderExecTree(shi->mat->nodetree, shi, shr);
/* also run this when node shaders fail, due to incompatible shader nodes */
if (compat == 0) {
/* copy all relevant material vars, note, keep this synced with render_types.h */
shade_input_init_material(shi);