2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2007-03-24 06:57:29 +00:00
|
|
|
* $Id$
|
|
|
|
|
*
|
|
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2007-03-24 06:57:29 +00:00
|
|
|
*
|
|
|
|
|
* The Original Code is Copyright (C) 2005 Blender Foundation.
|
|
|
|
|
* All rights reserved.
|
|
|
|
|
*
|
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
|
*
|
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
|
*
|
|
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
|
|
|
|
*/
|
|
|
|
|
|
2011-02-27 20:13:22 +00:00
|
|
|
/** \file blender/nodes/intern/SHD_nodes/SHD_material.c
|
|
|
|
|
* \ingroup shdnodes
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2007-03-24 06:57:29 +00:00
|
|
|
#include "../SHD_util.h"
|
|
|
|
|
|
|
|
|
|
/* **************** MATERIAL ******************** */
|
|
|
|
|
|
|
|
|
|
static bNodeSocketType sh_node_material_in[]= {
|
|
|
|
|
{ SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_RGBA, 1, "Spec", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "Refl", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VECTOR, 1, "Normal", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
|
|
|
|
|
{ -1, 0, "" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static bNodeSocketType sh_node_material_out[]= {
|
|
|
|
|
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
|
|
|
|
|
{ -1, 0, "" }
|
|
|
|
|
};
|
|
|
|
|
|
== Shader nodes ==
* Geometry node: Front/back output
This is used as a mask for determining whether you're looking at the front side or back side of a mesh, useful for blending materials, my practical need was giving different materials to the pages of a magazine: http://mke3.net/blender/etc/frontback-h264.mov
Give 1.0 if it's the front side, and 0.0 if it's the back side.
* Extended material node
This is the same as the material node, but gives more available inputs and outputs, (basically just connecting up more of ShadeInput and ShadeResult to the node). I didn't want to add it to the normal simple Material node since you don't always need all that stuff, and it would make the node huge, but when you do need it, it's nice to have it.
== Comp nodes ==
* Invert node
Inverting is something that happens all the time in a node setup, and this makes it easier. It's been possible to invert previously by adding a mix node and subtracting the input from 1.0, but it's not the best way of doing it. This node:
- makes it a lot faster to set up, rather than all the clicking required with the mix node
- is a lot more usable amidst a complex comp setup, when you're looking at a node tree, it's very helpful to be able to see at a glance what's going on. Using subtract for inverting is easily mixed up with other nodes in which you are actually subtracting, not inverting, and looks very similar to all the other mix nodes that usually litter a comp tree.
- has options to invert the RGB channels, the Alpha channel, or both. This saves adding lots of extra nodes (separate RGBA, subtract, set alpha) when you want to do something simple like invert an alpha channel. I'd like to add this option to other nodes too.
There's also a shader node version too.
* Also a few fixes that I committed ages ago, but seems to have been overwritten in Bob's node refactor:
- adding new compbufs to the set alpha and alphaover nodes when you have only one noodle connected to the lower input
- making the fac value on RGB curves still work when there's nothing connected to it
2007-05-31 06:55:02 +00:00
|
|
|
/* **************** EXTENDED MATERIAL ******************** */
|
|
|
|
|
|
|
|
|
|
static bNodeSocketType sh_node_material_ext_in[]= {
|
|
|
|
|
{ SOCK_RGBA, 1, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_RGBA, 1, "Spec", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "Refl", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VECTOR, 1, "Normal", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
|
|
|
|
|
{ SOCK_RGBA, 1, "Mirror", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "Ambient", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "Emit", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "SpecTra", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "Ray Mirror", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "Alpha", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 1, "Translucency", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ -1, 0, "" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static bNodeSocketType sh_node_material_ext_out[]= {
|
|
|
|
|
{ SOCK_RGBA, 0, "Color", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VALUE, 0, "Alpha", 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_VECTOR, 0, "Normal", 0.0f, 0.0f, 0.0f, 1.0f, -1.0f, 1.0f},
|
|
|
|
|
{ SOCK_RGBA, 0, "Diffuse", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_RGBA, 0, "Spec", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ SOCK_RGBA, 0, "AO", 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f},
|
|
|
|
|
{ -1, 0, "" }
|
|
|
|
|
};
|
|
|
|
|
|
2007-03-24 06:57:29 +00:00
|
|
|
static void node_shader_exec_material(void *data, bNode *node, bNodeStack **in, bNodeStack **out)
|
|
|
|
|
{
|
|
|
|
|
if(data && node->id) {
|
|
|
|
|
ShadeResult shrnode;
|
|
|
|
|
ShadeInput *shi;
|
|
|
|
|
ShaderCallData *shcd= data;
|
|
|
|
|
float col[4];
|
|
|
|
|
|
|
|
|
|
shi= shcd->shi;
|
|
|
|
|
shi->mat= (Material *)node->id;
|
|
|
|
|
|
|
|
|
|
/* copy all relevant material vars, note, keep this synced with render_types.h */
|
|
|
|
|
memcpy(&shi->r, &shi->mat->r, 23*sizeof(float));
|
|
|
|
|
shi->har= shi->mat->har;
|
|
|
|
|
|
|
|
|
|
/* write values */
|
|
|
|
|
if(in[MAT_IN_COLOR]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->r, SOCK_VECTOR, in[MAT_IN_COLOR]);
|
|
|
|
|
|
|
|
|
|
if(in[MAT_IN_SPEC]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->specr, SOCK_VECTOR, in[MAT_IN_SPEC]);
|
|
|
|
|
|
|
|
|
|
if(in[MAT_IN_REFL]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->refl, SOCK_VALUE, in[MAT_IN_REFL]);
|
|
|
|
|
|
|
|
|
|
/* retrieve normal */
|
|
|
|
|
if(in[MAT_IN_NORMAL]->hasinput) {
|
|
|
|
|
nodestack_get_vec(shi->vn, SOCK_VECTOR, in[MAT_IN_NORMAL]);
|
2009-11-10 20:43:45 +00:00
|
|
|
normalize_v3(shi->vn);
|
2007-03-24 06:57:29 +00:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
VECCOPY(shi->vn, shi->vno);
|
|
|
|
|
|
|
|
|
|
/* custom option to flip normal */
|
|
|
|
|
if(node->custom1 & SH_NODE_MAT_NEG) {
|
|
|
|
|
shi->vn[0]= -shi->vn[0];
|
|
|
|
|
shi->vn[1]= -shi->vn[1];
|
|
|
|
|
shi->vn[2]= -shi->vn[2];
|
|
|
|
|
}
|
|
|
|
|
|
== Shader nodes ==
* Geometry node: Front/back output
This is used as a mask for determining whether you're looking at the front side or back side of a mesh, useful for blending materials, my practical need was giving different materials to the pages of a magazine: http://mke3.net/blender/etc/frontback-h264.mov
Give 1.0 if it's the front side, and 0.0 if it's the back side.
* Extended material node
This is the same as the material node, but gives more available inputs and outputs, (basically just connecting up more of ShadeInput and ShadeResult to the node). I didn't want to add it to the normal simple Material node since you don't always need all that stuff, and it would make the node huge, but when you do need it, it's nice to have it.
== Comp nodes ==
* Invert node
Inverting is something that happens all the time in a node setup, and this makes it easier. It's been possible to invert previously by adding a mix node and subtracting the input from 1.0, but it's not the best way of doing it. This node:
- makes it a lot faster to set up, rather than all the clicking required with the mix node
- is a lot more usable amidst a complex comp setup, when you're looking at a node tree, it's very helpful to be able to see at a glance what's going on. Using subtract for inverting is easily mixed up with other nodes in which you are actually subtracting, not inverting, and looks very similar to all the other mix nodes that usually litter a comp tree.
- has options to invert the RGB channels, the Alpha channel, or both. This saves adding lots of extra nodes (separate RGBA, subtract, set alpha) when you want to do something simple like invert an alpha channel. I'd like to add this option to other nodes too.
There's also a shader node version too.
* Also a few fixes that I committed ages ago, but seems to have been overwritten in Bob's node refactor:
- adding new compbufs to the set alpha and alphaover nodes when you have only one noodle connected to the lower input
- making the fac value on RGB curves still work when there's nothing connected to it
2007-05-31 06:55:02 +00:00
|
|
|
if (node->type == SH_NODE_MATERIAL_EXT) {
|
|
|
|
|
if(in[MAT_IN_MIR]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->mirr, SOCK_VECTOR, in[MAT_IN_MIR]);
|
|
|
|
|
if(in[MAT_IN_AMB]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->amb, SOCK_VALUE, in[MAT_IN_AMB]);
|
|
|
|
|
if(in[MAT_IN_EMIT]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->emit, SOCK_VALUE, in[MAT_IN_EMIT]);
|
|
|
|
|
if(in[MAT_IN_SPECTRA]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->spectra, SOCK_VALUE, in[MAT_IN_SPECTRA]);
|
|
|
|
|
if(in[MAT_IN_RAY_MIRROR]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->ray_mirror, SOCK_VALUE, in[MAT_IN_RAY_MIRROR]);
|
|
|
|
|
if(in[MAT_IN_ALPHA]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->alpha, SOCK_VALUE, in[MAT_IN_ALPHA]);
|
|
|
|
|
if(in[MAT_IN_TRANSLUCENCY]->hasinput)
|
|
|
|
|
nodestack_get_vec(&shi->translucency, SOCK_VALUE, in[MAT_IN_TRANSLUCENCY]);
|
|
|
|
|
}
|
|
|
|
|
|
2009-05-26 13:46:08 +00:00
|
|
|
shi->nodes= 1; /* temp hack to prevent trashadow recursion */
|
2007-03-24 06:57:29 +00:00
|
|
|
node_shader_lamp_loop(shi, &shrnode); /* clears shrnode */
|
2009-05-26 13:46:08 +00:00
|
|
|
shi->nodes= 0;
|
2007-03-24 06:57:29 +00:00
|
|
|
|
|
|
|
|
/* write to outputs */
|
|
|
|
|
if(node->custom1 & SH_NODE_MAT_DIFF) {
|
|
|
|
|
VECCOPY(col, shrnode.combined);
|
|
|
|
|
if(!(node->custom1 & SH_NODE_MAT_SPEC)) {
|
2010-04-23 23:57:00 +00:00
|
|
|
sub_v3_v3(col, shrnode.spec);
|
2007-03-24 06:57:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if(node->custom1 & SH_NODE_MAT_SPEC) {
|
|
|
|
|
VECCOPY(col, shrnode.spec);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
col[0]= col[1]= col[2]= 0.0f;
|
|
|
|
|
|
|
|
|
|
col[3]= shrnode.alpha;
|
|
|
|
|
|
|
|
|
|
if(shi->do_preview)
|
2011-03-07 11:51:09 +00:00
|
|
|
nodeAddToPreview(node, col, shi->xs, shi->ys, shi->do_manage);
|
2007-03-24 06:57:29 +00:00
|
|
|
|
|
|
|
|
VECCOPY(out[MAT_OUT_COLOR]->vec, col);
|
|
|
|
|
out[MAT_OUT_ALPHA]->vec[0]= shrnode.alpha;
|
|
|
|
|
|
|
|
|
|
if(node->custom1 & SH_NODE_MAT_NEG) {
|
|
|
|
|
shi->vn[0]= -shi->vn[0];
|
|
|
|
|
shi->vn[1]= -shi->vn[1];
|
|
|
|
|
shi->vn[2]= -shi->vn[2];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VECCOPY(out[MAT_OUT_NORMAL]->vec, shi->vn);
|
|
|
|
|
|
== Shader nodes ==
* Geometry node: Front/back output
This is used as a mask for determining whether you're looking at the front side or back side of a mesh, useful for blending materials, my practical need was giving different materials to the pages of a magazine: http://mke3.net/blender/etc/frontback-h264.mov
Give 1.0 if it's the front side, and 0.0 if it's the back side.
* Extended material node
This is the same as the material node, but gives more available inputs and outputs, (basically just connecting up more of ShadeInput and ShadeResult to the node). I didn't want to add it to the normal simple Material node since you don't always need all that stuff, and it would make the node huge, but when you do need it, it's nice to have it.
== Comp nodes ==
* Invert node
Inverting is something that happens all the time in a node setup, and this makes it easier. It's been possible to invert previously by adding a mix node and subtracting the input from 1.0, but it's not the best way of doing it. This node:
- makes it a lot faster to set up, rather than all the clicking required with the mix node
- is a lot more usable amidst a complex comp setup, when you're looking at a node tree, it's very helpful to be able to see at a glance what's going on. Using subtract for inverting is easily mixed up with other nodes in which you are actually subtracting, not inverting, and looks very similar to all the other mix nodes that usually litter a comp tree.
- has options to invert the RGB channels, the Alpha channel, or both. This saves adding lots of extra nodes (separate RGBA, subtract, set alpha) when you want to do something simple like invert an alpha channel. I'd like to add this option to other nodes too.
There's also a shader node version too.
* Also a few fixes that I committed ages ago, but seems to have been overwritten in Bob's node refactor:
- adding new compbufs to the set alpha and alphaover nodes when you have only one noodle connected to the lower input
- making the fac value on RGB curves still work when there's nothing connected to it
2007-05-31 06:55:02 +00:00
|
|
|
/* Extended material options */
|
|
|
|
|
if (node->type == SH_NODE_MATERIAL_EXT) {
|
|
|
|
|
/* Shadow, Reflect, Refract, Radiosity, Speed seem to cause problems inside
|
|
|
|
|
* a node tree :( */
|
|
|
|
|
VECCOPY(out[MAT_OUT_DIFFUSE]->vec, shrnode.diff);
|
|
|
|
|
VECCOPY(out[MAT_OUT_SPEC]->vec, shrnode.spec);
|
|
|
|
|
VECCOPY(out[MAT_OUT_AO]->vec, shrnode.ao);
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-24 06:57:29 +00:00
|
|
|
/* copy passes, now just active node */
|
2010-03-31 20:39:08 +00:00
|
|
|
if(node->flag & NODE_ACTIVE_ID) {
|
|
|
|
|
float combined[4], alpha;
|
|
|
|
|
|
|
|
|
|
copy_v4_v4(combined, shcd->shr->combined);
|
|
|
|
|
alpha= shcd->shr->alpha;
|
|
|
|
|
|
2007-03-24 06:57:29 +00:00
|
|
|
*(shcd->shr)= shrnode;
|
2010-03-31 20:39:08 +00:00
|
|
|
|
|
|
|
|
copy_v4_v4(shcd->shr->combined, combined);
|
|
|
|
|
shcd->shr->alpha= alpha;
|
|
|
|
|
}
|
2007-03-24 06:57:29 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void node_shader_init_material(bNode* node)
|
|
|
|
|
{
|
|
|
|
|
node->custom1= SH_NODE_MAT_DIFF|SH_NODE_MAT_SPEC;
|
|
|
|
|
}
|
|
|
|
|
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
static int gpu_shader_material(GPUMaterial *mat, bNode *node, GPUNodeStack *in, GPUNodeStack *out)
|
|
|
|
|
{
|
|
|
|
|
if(node->id) {
|
|
|
|
|
GPUShadeInput shi;
|
|
|
|
|
GPUShadeResult shr;
|
|
|
|
|
|
|
|
|
|
GPU_shadeinput_set(mat, (Material*)node->id, &shi);
|
|
|
|
|
|
|
|
|
|
/* write values */
|
|
|
|
|
if(in[MAT_IN_COLOR].hasinput)
|
|
|
|
|
shi.rgb = in[MAT_IN_COLOR].link;
|
|
|
|
|
|
|
|
|
|
if(in[MAT_IN_SPEC].hasinput)
|
|
|
|
|
shi.specrgb = in[MAT_IN_SPEC].link;
|
|
|
|
|
|
|
|
|
|
if(in[MAT_IN_REFL].hasinput)
|
|
|
|
|
shi.refl = in[MAT_IN_REFL].link;
|
|
|
|
|
|
|
|
|
|
/* retrieve normal */
|
|
|
|
|
if(in[MAT_IN_NORMAL].hasinput) {
|
|
|
|
|
GPUNodeLink *tmp;
|
|
|
|
|
shi.vn = in[MAT_IN_NORMAL].link;
|
|
|
|
|
GPU_link(mat, "vec_math_normalize", shi.vn, &shi.vn, &tmp);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* custom option to flip normal */
|
|
|
|
|
if(node->custom1 & SH_NODE_MAT_NEG)
|
|
|
|
|
GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
|
|
|
|
|
|
|
|
|
|
if (node->type == SH_NODE_MATERIAL_EXT) {
|
|
|
|
|
if(in[MAT_IN_AMB].hasinput)
|
|
|
|
|
shi.amb= in[MAT_IN_AMB].link;
|
|
|
|
|
if(in[MAT_IN_EMIT].hasinput)
|
|
|
|
|
shi.emit= in[MAT_IN_EMIT].link;
|
|
|
|
|
if(in[MAT_IN_ALPHA].hasinput)
|
|
|
|
|
shi.alpha= in[MAT_IN_ALPHA].link;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GPU_shaderesult_set(&shi, &shr); /* clears shr */
|
|
|
|
|
|
|
|
|
|
/* write to outputs */
|
|
|
|
|
if(node->custom1 & SH_NODE_MAT_DIFF) {
|
2010-11-22 22:23:50 +00:00
|
|
|
out[MAT_OUT_COLOR].link= shr.combined;
|
|
|
|
|
|
|
|
|
|
if(!(node->custom1 & SH_NODE_MAT_SPEC)) {
|
|
|
|
|
GPUNodeLink *link;
|
|
|
|
|
GPU_link(mat, "vec_math_sub", shr.combined, shr.spec, &out[MAT_OUT_COLOR].link, &link);
|
|
|
|
|
}
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
}
|
|
|
|
|
else if(node->custom1 & SH_NODE_MAT_SPEC) {
|
|
|
|
|
out[MAT_OUT_COLOR].link= shr.spec;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
GPU_link(mat, "set_rgb_zero", &out[MAT_OUT_COLOR].link);
|
|
|
|
|
|
|
|
|
|
GPU_link(mat, "mtex_alpha_to_col", out[MAT_OUT_COLOR].link, shr.alpha, &out[MAT_OUT_COLOR].link);
|
|
|
|
|
|
|
|
|
|
out[MAT_OUT_ALPHA].link = shr.alpha; //
|
|
|
|
|
|
|
|
|
|
if(node->custom1 & SH_NODE_MAT_NEG)
|
|
|
|
|
GPU_link(mat, "vec_math_negate", shi.vn, &shi.vn);
|
|
|
|
|
out[MAT_OUT_NORMAL].link = shi.vn;
|
|
|
|
|
|
|
|
|
|
if (node->type == SH_NODE_MATERIAL_EXT) {
|
|
|
|
|
out[MAT_OUT_DIFFUSE].link = shr.diff;
|
|
|
|
|
out[MAT_OUT_SPEC].link = shr.spec;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-03-24 06:57:29 +00:00
|
|
|
|
2011-02-08 09:02:16 +00:00
|
|
|
void register_node_type_sh_material(ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
static bNodeType ntype;
|
|
|
|
|
|
|
|
|
|
node_type_base(&ntype, SH_NODE_MATERIAL, "Material", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW,
|
|
|
|
|
sh_node_material_in, sh_node_material_out);
|
|
|
|
|
node_type_size(&ntype, 120, 80, 240);
|
|
|
|
|
node_type_init(&ntype, node_shader_init_material);
|
|
|
|
|
node_type_exec(&ntype, node_shader_exec_material);
|
|
|
|
|
node_type_gpu(&ntype, gpu_shader_material);
|
|
|
|
|
|
|
|
|
|
nodeRegisterType(lb, &ntype);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void register_node_type_sh_material_ext(ListBase *lb)
|
|
|
|
|
{
|
|
|
|
|
static bNodeType ntype;
|
|
|
|
|
|
|
|
|
|
node_type_base(&ntype, SH_NODE_MATERIAL_EXT, "Extended Material", NODE_CLASS_INPUT, NODE_OPTIONS|NODE_PREVIEW,
|
|
|
|
|
sh_node_material_ext_in, sh_node_material_ext_out);
|
|
|
|
|
node_type_size(&ntype, 120, 80, 240);
|
|
|
|
|
node_type_init(&ntype, node_shader_init_material);
|
|
|
|
|
node_type_exec(&ntype, node_shader_exec_material);
|
|
|
|
|
node_type_gpu(&ntype, gpu_shader_material);
|
|
|
|
|
|
|
|
|
|
nodeRegisterType(lb, &ntype);
|
|
|
|
|
}
|
2007-03-24 06:57:29 +00:00
|
|
|
|
== Shader nodes ==
* Geometry node: Front/back output
This is used as a mask for determining whether you're looking at the front side or back side of a mesh, useful for blending materials, my practical need was giving different materials to the pages of a magazine: http://mke3.net/blender/etc/frontback-h264.mov
Give 1.0 if it's the front side, and 0.0 if it's the back side.
* Extended material node
This is the same as the material node, but gives more available inputs and outputs, (basically just connecting up more of ShadeInput and ShadeResult to the node). I didn't want to add it to the normal simple Material node since you don't always need all that stuff, and it would make the node huge, but when you do need it, it's nice to have it.
== Comp nodes ==
* Invert node
Inverting is something that happens all the time in a node setup, and this makes it easier. It's been possible to invert previously by adding a mix node and subtracting the input from 1.0, but it's not the best way of doing it. This node:
- makes it a lot faster to set up, rather than all the clicking required with the mix node
- is a lot more usable amidst a complex comp setup, when you're looking at a node tree, it's very helpful to be able to see at a glance what's going on. Using subtract for inverting is easily mixed up with other nodes in which you are actually subtracting, not inverting, and looks very similar to all the other mix nodes that usually litter a comp tree.
- has options to invert the RGB channels, the Alpha channel, or both. This saves adding lots of extra nodes (separate RGBA, subtract, set alpha) when you want to do something simple like invert an alpha channel. I'd like to add this option to other nodes too.
There's also a shader node version too.
* Also a few fixes that I committed ages ago, but seems to have been overwritten in Bob's node refactor:
- adding new compbufs to the set alpha and alphaover nodes when you have only one noodle connected to the lower input
- making the fac value on RGB curves still work when there's nothing connected to it
2007-05-31 06:55:02 +00:00
|
|
|
|