4
* ***** BEGIN GPL LICENSE BLOCK *****
6
* This shader is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU General Public License
8
* as published by the Free Software Foundation; either version 2
9
* of the License, or (at your option) any later version. The Blender
10
* Foundation also sells licenses for use in proprietary software under
11
* the Blender License. See http://www.blender.org/BL/ for information
14
* This shader is distributed in the hope that it will be useful,
15
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
* GNU General Public License for more details.
19
* You should have received a copy of the GNU General Public License
20
* along with this shader; if not, write to the Free Software Foundation,
21
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
* The Original Code is Copyright (C) 2005 Blender Foundation.
24
* All rights reserved.
26
* The Original Code is: all of this file.
28
* Contributor(s): Brecht Van Lommel.
30
* ***** END GPL LICENSE BLOCK *****
33
#ifndef __GPU_MATERIAL__
34
#define __GPU_MATERIAL__
48
struct GPUVertexAttribs;
56
typedef struct GPUNode GPUNode;
57
typedef struct GPUNodeLink GPUNodeLink;
58
typedef struct GPUMaterial GPUMaterial;
59
typedef struct GPULamp GPULamp;
61
/* Functions to create GPU Materials nodes */
63
typedef enum GPUType {
77
typedef enum GPUBuiltin {
79
GPU_OBJECT_MATRIX = 2,
80
GPU_INVERSE_VIEW_MATRIX = 4,
81
GPU_INVERSE_OBJECT_MATRIX = 8,
82
GPU_VIEW_POSITION = 16,
87
typedef enum GPUBlendMode {
94
typedef struct GPUNodeStack {
98
struct GPUNodeLink *link;
104
GPUNodeLink *GPU_attribute(int type, char *name);
105
GPUNodeLink *GPU_uniform(float *num);
106
GPUNodeLink *GPU_dynamic_uniform(float *num);
107
GPUNodeLink *GPU_image(struct Image *ima, struct ImageUser *iuser);
108
GPUNodeLink *GPU_texture(int size, float *pixels);
109
GPUNodeLink *GPU_dynamic_texture(struct GPUTexture *tex);
110
GPUNodeLink *GPU_socket(GPUNodeStack *sock);
111
GPUNodeLink *GPU_builtin(GPUBuiltin builtin);
113
int GPU_link(GPUMaterial *mat, char *name, ...);
114
int GPU_stack_link(GPUMaterial *mat, char *name, GPUNodeStack *in, GPUNodeStack *out, ...);
116
void GPU_material_output_link(GPUMaterial *material, GPUNodeLink *link);
117
void GPU_material_enable_alpha(GPUMaterial *material);
118
GPUBlendMode GPU_material_blend_mode(GPUMaterial *material, float obcol[4]);
120
/* High level functions to create and use GPU materials */
122
GPUMaterial *GPU_material_from_blender(struct Scene *scene, struct Material *ma);
123
void GPU_material_free(struct Material *ma);
125
void GPU_materials_free();
127
void GPU_material_bind(GPUMaterial *material, int oblay, int viewlay, double time);
128
void GPU_material_bind_uniforms(GPUMaterial *material, float obmat[][4], float viewmat[][4], float viewinv[][4], float obcol[4]);
129
void GPU_material_unbind(GPUMaterial *material);
130
int GPU_material_bound(GPUMaterial *material);
132
void GPU_material_vertex_attributes(GPUMaterial *material,
133
struct GPUVertexAttribs *attrib);
135
/* Exported shading */
137
typedef struct GPUShadeInput {
139
struct Material *mat;
141
GPUNodeLink *rgb, *specrgb, *vn, *view, *vcol, *ref;
142
GPUNodeLink *alpha, *refl, *spec, *emit, *har, *amb;
145
typedef struct GPUShadeResult {
146
GPUNodeLink *diff, *spec, *combined, *alpha;
149
void GPU_shadeinput_set(GPUMaterial *mat, struct Material *ma, GPUShadeInput *shi);
150
void GPU_shaderesult_set(GPUShadeInput *shi, GPUShadeResult *shr);
154
GPULamp *GPU_lamp_from_blender(struct Scene *scene, struct Object *ob, struct Object *par);
155
void GPU_lamp_free(struct Object *ob);
157
int GPU_lamp_has_shadow_buffer(GPULamp *lamp);
158
void GPU_lamp_shadow_buffer_bind(GPULamp *lamp, float viewmat[][4], int *winsize, float winmat[][4]);
159
void GPU_lamp_shadow_buffer_unbind(GPULamp *lamp);
161
void GPU_lamp_update(GPULamp *lamp, int lay, float obmat[][4]);
162
int GPU_lamp_shadow_layer(GPULamp *lamp);
168
#endif /*__GPU_MATERIAL__*/