More node goodies!

First note; this is a WIP project, some commits might change things that
make formerly saved situations not to work identically... like now!

------ New Material integration ------

Until now, the Node system worked on top of the 'current' Material, just
like how the Material Layers worked. That's quite confusing in practice,
especially to see what Material is a Node, or what is the "base material"

Best solution is to completely separate the two. This has been implemented
as follows now;

- The confusing "Input" node has been removed.
- When choosing a Material in Blender, you can define this Material to be
  either 'normal' (default) or be the root of a Node tree.
- If a Material is a Node tree, you have to add Nodes in the tree to see
  something happen. An empty Node tree doesn't do anything (black).
- If a Material is a Node Tree, the 'data browse' menus show it with an
  'N' mark before the name. The 'data block' buttons display it with the
  suffix 'NT' (instead of 'MA').
- In a Node Tree, any Material can be inserted, including itself. Only in
  that case the Material is being used itself for shading.

UI changes:

Added a new Panel "Links", which shows:
- where the Material is linked to (Object, Mesh, etc)
- if the Material is a NodeTree or not
- the actual active Material in the Tree

The "Node" Panel itself now only shows buttons from the other nodes, when
they are active.

Further the Material Nodes themselves allow browsing and renaming or adding
new Materials now too.

Second half of today's work was cleaning up selection when the Nodes
overlap... it was possible to drag links from invisible sockets, or click
headers for invisible nodes, etc. This because the mouse input code was
not checking for visibility yet.
Works now even for buttons. :)
This commit is contained in:
2005-12-29 18:08:01 +00:00
parent fa24217b2c
commit 8d35213990
33 changed files with 618 additions and 682 deletions

View File

@@ -1029,7 +1029,6 @@ static void shade_lamp_loop_preview(ShadeInput *shi, ShadeResult *shr)
static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y, char *rect, short pr_rectx, short pr_recty)
{
Material *mat;
MaterialLayer *ml;
ShadeResult shr;
float v1;
float eul[3], tmat[3][3], imat[3][3], col[4];
@@ -1112,33 +1111,12 @@ static void shade_preview_pixel(ShadeInput *shi, float *vec, int x, int y, char
// Normalise(shi->vn);
}
/* ------ main shading loop with material layers */
VECCOPY(shi->vno, shi->vn);
if(mat->ml_flag & ML_RENDER)
shade_lamp_loop_preview(shi, &shr);
else {
memset(&shr, 0, sizeof(ShadeResult));
shr.alpha= 1.0f;
}
if(mat->nodetree && mat->use_nodes) {
ntreeShaderExecTree(mat->nodetree, shi, &shr);
}
else {
for(ml= mat->layers.first; ml; ml= ml->next) {
if(ml->mat && (ml->flag & ML_RENDER)) {
ShadeResult shrlay;
shi->mat= ml->mat;
shi->layerfac= ml->blendfac;
VECCOPY(shi->vn, shi->vno);
if(ml->flag & ML_NEG_NORMAL)
VecMulf(shi->vn, -1.0);
shade_lamp_loop_preview(shi, &shrlay);
matlayer_blend(ml, shi->layerfac, &shr, &shrlay);
}
}
shade_lamp_loop_preview(shi, &shr);
}
shi->mat= mat; /* restore, shade input is re-used! */