diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2008-11-13 00:16:53 +0300 |
commit | bdfe7d89e2f1292644577972c716931b4ce3c6c3 (patch) | |
tree | d00eb50b749cb001e2b08272c91791e66740b05d /source/blender/gpu/GPU_material.h | |
parent | 78a1c27c4a6abe0ed31ca93ad21910f3df04da56 (diff) | |
parent | 7e4db234cee71ead34ee81a12e27da4bd548eb4b (diff) |
Merge of trunk into blender 2.5:
svn merge https://svn.blender.org/svnroot/bf-blender/trunk/blender -r12987:17416
Issues:
* GHOST/X11 had conflicting changes. Some code was added in 2.5, which was
later added in trunk also, but reverted partially, specifically revision
16683. I have left out this reversion in the 2.5 branch since I think it is
needed there.
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=16683
* Scons had various conflicting changes, I decided to go with trunk version
for everything except priorities and some library renaming.
* In creator.c, there were various fixes and fixes for fixes related to the -w
-W and -p options. In 2.5 -w and -W is not coded yet, and -p is done
differently. Since this is changed so much, and I don't think those fixes
would be needed in 2.5, I've left them out.
* Also in creator.c: there was code for a python bugfix where the screen was not
initialized when running with -P. The code that initializes the screen there
I had to disable, that can't work in 2.5 anymore but left it commented as a
reminder.
Further I had to disable some new function calls. using src/ and python/, as
was done already in this branch, disabled function calls:
* bpath.c: error reporting
* BME_conversions.c: editmesh conversion functions.
* SHD_dynamic: disabled almost completely, there is no python/.
* KX_PythonInit.cpp and Ketsji/ build files: Mathutils is not there, disabled.
* text.c: clipboard copy call.
* object.c: OB_SUPPORT_MATERIAL.
* DerivedMesh.c and subsurf_ccg, stipple_quarttone.
Still to be done:
* Go over files and functions that were moved to a different location but could
still use changes that were done in trunk.
Diffstat (limited to 'source/blender/gpu/GPU_material.h')
-rw-r--r-- | source/blender/gpu/GPU_material.h | 169 |
1 files changed, 169 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h new file mode 100644 index 00000000000..ccc687858f4 --- /dev/null +++ b/source/blender/gpu/GPU_material.h @@ -0,0 +1,169 @@ +/** + * $Id$ + * + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This shader 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. The Blender + * Foundation also sells licenses for use in proprietary software under + * the Blender License. See http://www.blender.org/BL/ for information + * about this. + * + * This shader 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 shader; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The Original Code is Copyright (C) 2005 Blender Foundation. + * All rights reserved. + * + * The Original Code is: all of this file. + * + * Contributor(s): Brecht Van Lommel. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __GPU_MATERIAL__ +#define __GPU_MATERIAL__ + +#ifdef __cplusplus +extern "C" { +#endif + +struct Image; +struct ImageUser; +struct Material; +struct Object; +struct Lamp; +struct bNode; +struct LinkNode; +struct Scene; +struct GPUVertexAttribs; +struct GPUNode; +struct GPUNodeLink; +struct GPUNodeStack; +struct GPUMaterial; +struct GPUTexture; +struct GPULamp; + +typedef struct GPUNode GPUNode; +typedef struct GPUNodeLink GPUNodeLink; +typedef struct GPUMaterial GPUMaterial; +typedef struct GPULamp GPULamp; + +/* Functions to create GPU Materials nodes */ + +typedef enum GPUType { + GPU_NONE = 0, + GPU_FLOAT = 1, + GPU_VEC2 = 2, + GPU_VEC3 = 3, + GPU_VEC4 = 4, + GPU_MAT3 = 9, + GPU_MAT4 = 16, + GPU_TEX1D = 1001, + GPU_TEX2D = 1002, + GPU_SHADOW2D = 1003, + GPU_ATTRIB = 3001 +} GPUType; + +typedef enum GPUBuiltin { + GPU_VIEW_MATRIX = 1, + GPU_OBJECT_MATRIX = 2, + GPU_INVERSE_VIEW_MATRIX = 4, + GPU_INVERSE_OBJECT_MATRIX = 8, + GPU_VIEW_POSITION = 16, + GPU_VIEW_NORMAL = 32, + GPU_OBCOLOR = 64 +} GPUBuiltin; + +typedef enum GPUBlendMode { + GPU_BLEND_SOLID = 0, + GPU_BLEND_ADD = 1, + GPU_BLEND_ALPHA = 2, + GPU_BLEND_CLIP = 4 +} GPUBlendMode; + +typedef struct GPUNodeStack { + GPUType type; + char *name; + float vec[4]; + struct GPUNodeLink *link; + short hasinput; + short hasoutput; + short sockettype; +} GPUNodeStack; + +GPUNodeLink *GPU_attribute(int type, char *name); +GPUNodeLink *GPU_uniform(float *num); +GPUNodeLink *GPU_dynamic_uniform(float *num); +GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser); +GPUNodeLink *GPU_texture(int size, float *pixels); +GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex); +GPUNodeLink *GPU_socket(GPUNodeStack *sock); +GPUNodeLink *GPU_builtin(GPUBuiltin builtin); + +int GPU_link(GPUMaterial *mat, char *name, ...); +int GPU_stack_link(GPUMaterial *mat, char *name, GPUNodeStack *in, GPUNodeStack *out, ...); + +void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link); +void GPU_material_enable_alpha(GPUMaterial *material); +GPUBlendMode GPU_material_blend_mode(GPUMaterial *material, float obcol[4]); + +/* High level functions to create and use GPU materials */ + +GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material *ma); +void GPU_material_free(struct Material *ma); + +void GPU_materials_free(); + +void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time); +void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]); +void GPU_material_unbind(GPUMaterial *material); +int GPU_material_bound(GPUMaterial *material); + +void GPU_material_vertex_attributes(GPUMaterial *material, + struct GPUVertexAttribs *attrib); + +/* Exported shading */ + +typedef struct GPUShadeInput { + GPUMaterial *gpumat; + struct Material *mat; + + GPUNodeLink *rgb, *specrgb, *vn, *view, *vcol, *ref; + GPUNodeLink *alpha, *refl, *spec, *emit, *har, *amb; +} GPUShadeInput; + +typedef struct GPUShadeResult { + GPUNodeLink *diff, *spec, *combined, *alpha; +} GPUShadeResult; + +void GPU_shadeinput_set(GPUMaterial *mat, struct Material *ma, GPUShadeInput *shi); +void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr); + +/* Lamps */ + +GPULamp *GPU_lamp_from_blender(struct Scene *scene, struct Object *ob, struct Object *par); +void GPU_lamp_free(struct Object *ob); + +int GPU_lamp_has_shadow_buffer(GPULamp *lamp); +void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize, float winmat[][4]); +void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp); + +void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4]); +int GPU_lamp_shadow_layer(GPULamp *lamp); + +#ifdef __cplusplus +} +#endif + +#endif /*__GPU_MATERIAL__*/ + |