Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenoit Bolsee <benoit.bolsee@online.be>2011-09-09 15:55:38 +0400
committerBenoit Bolsee <benoit.bolsee@online.be>2011-09-09 15:55:38 +0400
commit01744abd8187d1566b336bf38033673aa05b6786 (patch)
tree848742d2ce1be126a4b6381aecf03b6c2e9d93b4 /source/blender/gpu/intern/gpu_codegen.h
parent2b33c6b0b27c0a4fee5a1a405e012eb4032bba05 (diff)
GPU: add gpu python module with export_shader() function to export GLSL shader.
shader = gpu.export_shader(scene,material) Returns the GLSL shader that blender generates to produce the visual effect of material in scene for the purpose of reusing the shader in an external engine. This function is meant to be used in a material exporter so that the GLSL shader can be exported entirely. The return value is a dictionary containing the shader source code and all associated data. The full documentation is under sphinx. Warning: there has been an API between the patch and this commit: uniform['lamp'] and uniform['image'] now return python reference to ID block instead of ID name as before. The X3D exporter that uses this function must be adapted.
Diffstat (limited to 'source/blender/gpu/intern/gpu_codegen.h')
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h103
1 files changed, 102 insertions, 1 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index b0a131f5989..1e44eba89d4 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -39,12 +39,15 @@
#define __GPU_CODEGEN_H__
#include "DNA_listBase.h"
+#include "GPU_material.h"
+#include "GL/glew.h"
struct ListBase;
struct GPUShader;
struct GPUOutput;
struct GPUNode;
struct GPUVertexAttribs;
+struct GPUFrameBuffer;
#define MAX_FUNCTION_NAME 64
#define MAX_PARAMETER 32
@@ -68,7 +71,105 @@ GPUFunction *GPU_lookup_function(const char *name);
at the end if used.
*/
-struct GPUPass;
+typedef enum GPUDataSource {
+ GPU_SOURCE_VEC_UNIFORM,
+ GPU_SOURCE_BUILTIN,
+ GPU_SOURCE_TEX_PIXEL,
+ GPU_SOURCE_TEX,
+ GPU_SOURCE_ATTRIB
+} GPUDataSource;
+
+struct GPUNode {
+ struct GPUNode *next, *prev;
+
+ const char *name;
+ int tag;
+
+ ListBase inputs;
+ ListBase outputs;
+};
+
+struct GPUNodeLink {
+ GPUNodeStack *socket;
+
+ int attribtype;
+ const char *attribname;
+
+ int image;
+
+ int texture;
+ int texturesize;
+
+ void *ptr1, *ptr2;
+
+ int dynamic;
+ int dynamictype;
+
+ int type;
+ int users;
+
+ GPUTexture *dynamictex;
+
+ GPUBuiltin builtin;
+
+ struct GPUOutput *output;
+};
+
+typedef struct GPUOutput {
+ struct GPUOutput *next, *prev;
+
+ GPUNode *node;
+ int type; /* data type = length of vector/matrix */
+ GPUNodeLink *link; /* output link */
+ int id; /* unique id as created by code generator */
+} GPUOutput;
+
+typedef struct GPUInput {
+ struct GPUInput *next, *prev;
+
+ GPUNode *node;
+
+ int type; /* datatype */
+ int source; /* data source */
+
+ int id; /* unique id as created by code generator */
+ int texid; /* number for multitexture */
+ int attribid; /* id for vertex attributes */
+ int bindtex; /* input is responsible for binding the texture? */
+ int definetex; /* input is responsible for defining the pixel? */
+ int textarget; /* GL_TEXTURE_* */
+ int textype; /* datatype */
+
+ struct Image *ima; /* image */
+ struct ImageUser *iuser;/* image user */
+ float *dynamicvec; /* vector data in case it is dynamic */
+ int dynamictype; /* origin of the dynamic uniform (GPUDynamicType) */
+ void *dynamicdata; /* data source of the dynamic uniform */
+ GPUTexture *tex; /* input texture, only set at runtime */
+ int shaderloc; /* id from opengl */
+ char shadername[32]; /* name in shader */
+
+ float vec[16]; /* vector data */
+ GPUNodeLink *link;
+ int dynamictex; /* dynamic? */
+ int attribtype; /* attribute type */
+ char attribname[32]; /* attribute name */
+ int attribfirst; /* this is the first one that is bound */
+ GPUBuiltin builtin; /* builtin uniform */
+} GPUInput;
+
+struct GPUPass {
+ struct GPUPass *next, *prev;
+
+ ListBase inputs;
+ struct GPUOutput *output;
+ struct GPUShader *shader;
+ char *fragmentcode;
+ char *vertexcode;
+ const char *libcode;
+};
+
+
typedef struct GPUPass GPUPass;
GPUPass *GPU_generate_pass(ListBase *nodes, struct GPUNodeLink *outlink,