2011-02-23 10:52:22 +00:00
|
|
|
/*
|
2007-03-24 06:57:29 +00:00
|
|
|
* ***** 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-09-05 21:01:50 +00:00
|
|
|
/** \file blender/nodes/shader/node_shader_util.h
|
2011-02-27 20:13:22 +00:00
|
|
|
* \ingroup nodes
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#ifndef NODE_SHADER_UTIL_H_
|
|
|
|
#define NODE_SHADER_UTIL_H_
|
2007-03-24 06:57:29 +00:00
|
|
|
|
2007-03-24 18:41:54 +00:00
|
|
|
#include <math.h>
|
2008-01-01 18:16:10 +00:00
|
|
|
#include <float.h>
|
2007-03-24 18:41:54 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2007-03-24 06:57:29 +00:00
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
|
|
|
|
#include "DNA_color_types.h"
|
2011-11-08 11:38:16 +00:00
|
|
|
#include "DNA_customdata_types.h"
|
2007-03-24 06:57:29 +00:00
|
|
|
#include "DNA_ID.h"
|
|
|
|
#include "DNA_image_types.h"
|
|
|
|
#include "DNA_material_types.h"
|
|
|
|
#include "DNA_node_types.h"
|
|
|
|
#include "DNA_object_types.h"
|
|
|
|
#include "DNA_scene_types.h"
|
|
|
|
#include "DNA_texture_types.h"
|
|
|
|
|
|
|
|
#include "BKE_blender.h"
|
|
|
|
#include "BKE_colortools.h"
|
|
|
|
#include "BKE_global.h"
|
|
|
|
#include "BKE_image.h"
|
|
|
|
#include "BKE_main.h"
|
|
|
|
#include "BKE_material.h"
|
2011-02-07 09:33:36 +00:00
|
|
|
#include "BKE_node.h"
|
2007-03-24 06:57:29 +00:00
|
|
|
#include "BKE_texture.h"
|
2011-01-07 19:18:31 +00:00
|
|
|
|
2007-03-24 18:41:54 +00:00
|
|
|
#include "BKE_library.h"
|
2007-03-24 06:57:29 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
#include "NOD_shader.h"
|
2007-04-04 13:58:12 +00:00
|
|
|
#include "node_util.h"
|
2007-03-24 06:57:29 +00:00
|
|
|
|
2009-11-10 20:43:45 +00:00
|
|
|
#include "BLI_math.h"
|
2007-03-24 06:57:29 +00:00
|
|
|
#include "BLI_blenlib.h"
|
|
|
|
#include "BLI_rand.h"
|
|
|
|
#include "BLI_threads.h"
|
2011-01-07 18:36:47 +00:00
|
|
|
#include "BLI_utildefines.h"
|
2007-03-24 06:57:29 +00:00
|
|
|
|
|
|
|
#include "IMB_imbuf_types.h"
|
|
|
|
#include "IMB_imbuf.h"
|
|
|
|
|
|
|
|
#include "RE_pipeline.h"
|
|
|
|
#include "RE_shader_ext.h"
|
|
|
|
|
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
|
|
|
#include "GPU_material.h"
|
|
|
|
|
2007-03-24 06:57:29 +00:00
|
|
|
/* ********* exec data struct, remains internal *********** */
|
|
|
|
|
|
|
|
typedef struct ShaderCallData {
|
|
|
|
ShadeInput *shi; /* from render pipe */
|
|
|
|
ShadeResult *shr; /* from render pipe */
|
|
|
|
} ShaderCallData;
|
|
|
|
|
|
|
|
/* output socket defines */
|
|
|
|
#define GEOM_OUT_GLOB 0
|
|
|
|
#define GEOM_OUT_LOCAL 1
|
|
|
|
#define GEOM_OUT_VIEW 2
|
|
|
|
#define GEOM_OUT_ORCO 3
|
|
|
|
#define GEOM_OUT_UV 4
|
|
|
|
#define GEOM_OUT_NORMAL 5
|
|
|
|
#define GEOM_OUT_VCOL 6
|
2011-07-24 17:40:02 +00:00
|
|
|
#define GEOM_OUT_VCOL_ALPHA 7
|
|
|
|
#define GEOM_OUT_FRONTBACK 8
|
== 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
|
|
|
|
2007-03-24 06:57:29 +00:00
|
|
|
|
|
|
|
/* input socket defines */
|
|
|
|
#define MAT_IN_COLOR 0
|
|
|
|
#define MAT_IN_SPEC 1
|
|
|
|
#define MAT_IN_REFL 2
|
|
|
|
#define MAT_IN_NORMAL 3
|
== 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
|
|
|
#define MAT_IN_MIR 4
|
2008-07-25 01:17:37 +00:00
|
|
|
#define MAT_IN_AMB 5
|
|
|
|
#define MAT_IN_EMIT 6
|
|
|
|
#define MAT_IN_SPECTRA 7
|
|
|
|
#define MAT_IN_RAY_MIRROR 8
|
|
|
|
#define MAT_IN_ALPHA 9
|
|
|
|
#define MAT_IN_TRANSLUCENCY 10
|
2011-05-31 17:54:48 +00:00
|
|
|
#define NUM_MAT_IN 11 /* for array size */
|
== 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
|
|
|
|
|
|
|
/* output socket defines */
|
|
|
|
#define MAT_OUT_COLOR 0
|
|
|
|
#define MAT_OUT_ALPHA 1
|
|
|
|
#define MAT_OUT_NORMAL 2
|
|
|
|
#define MAT_OUT_DIFFUSE 3
|
|
|
|
#define MAT_OUT_SPEC 4
|
|
|
|
#define MAT_OUT_AO 5
|
2007-03-24 06:57:29 +00:00
|
|
|
|
|
|
|
|
|
|
|
extern void node_ID_title_cb(void *node_v, void *unused_v);
|
2007-03-24 18:41:54 +00:00
|
|
|
void nodestack_get_vec(float *in, short type_in, bNodeStack *ns);
|
2007-03-24 06:57:29 +00:00
|
|
|
|
2011-09-05 21:01:50 +00:00
|
|
|
void node_gpu_stack_from_data(struct GPUNodeStack *gs, int type, struct bNodeStack *ns);
|
|
|
|
void node_data_from_gpu_stack(struct bNodeStack *ns, struct GPUNodeStack *gs);
|
2011-11-08 11:38:16 +00:00
|
|
|
void node_shader_gpu_tex_mapping(struct GPUMaterial *mat, struct bNode *node, struct GPUNodeStack *in, struct GPUNodeStack *out);
|
2011-09-05 21:01:50 +00:00
|
|
|
|
|
|
|
void ntreeExecGPUNodes(struct bNodeTreeExec *exec, struct GPUMaterial *mat, int do_outputs);
|
|
|
|
|
2011-11-20 16:38:23 +00:00
|
|
|
void node_shader_pass_on(void *data, int thread, struct bNode *node, void *nodedata, struct bNodeStack **in, struct bNodeStack **out);
|
|
|
|
int gpu_shader_pass_on(struct GPUMaterial *mat, struct bNode *node, void *nodedata, struct GPUNodeStack *in, struct GPUNodeStack *out);
|
|
|
|
|
2007-03-24 18:41:54 +00:00
|
|
|
#endif
|