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:
authorClément Foucault <foucault.clem@gmail.com>2018-10-09 18:32:13 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-10-09 18:34:04 +0300
commite234ce9b2272323ef2666d3f0718ecb8c688b693 (patch)
tree44b5d18a5fb306b747791671239d9c48ac434d4c /source/blender/gpu
parent6d6e3869ce52085bbd4351de96cbc0e6b51b974b (diff)
Eevee: Add support/Fix Object Info node
Caveat: Random output does not yet work with instance (dupli) objects.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_shader_interface.h1
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c12
-rw-r--r--source/blender/gpu/intern/gpu_codegen.h2
-rw-r--r--source/blender/gpu/intern/gpu_material.c1
-rw-r--r--source/blender/gpu/intern/gpu_shader_interface.c1
5 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h
index 458a49a366b..af89e487cf8 100644
--- a/source/blender/gpu/GPU_shader_interface.h
+++ b/source/blender/gpu/GPU_shader_interface.h
@@ -58,6 +58,7 @@ typedef enum {
GPU_UNIFORM_COLOR, /* vec4 color */
GPU_UNIFORM_EYE, /* vec3 eye */
GPU_UNIFORM_CALLID, /* int callId */
+ GPU_UNIFORM_OBJECT_INFO, /* vec3 objectInfo */
GPU_UNIFORM_CUSTOM, /* custom uniform, not one of the above built-ins */
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index c1e6b9b53a0..808cb985bf5 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -759,7 +759,7 @@ static void codegen_call_functions(DynStr *ds, ListBase *nodes, GPUOutput *final
BLI_dynstr_append(ds, ";\n");
}
-static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUOutput *output)
+static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUOutput *output, int *rbuiltins)
{
DynStr *ds = BLI_dynstr_new();
char *code;
@@ -770,14 +770,13 @@ static char *code_generate_fragment(GPUMaterial *material, ListBase *nodes, GPUO
#endif
codegen_set_unique_ids(nodes);
- builtins = codegen_process_uniforms_functions(material, ds, nodes);
-
+ *rbuiltins = builtins = codegen_process_uniforms_functions(material, ds, nodes);
if (builtins & GPU_BARYCENTRIC_TEXCO)
- BLI_dynstr_append(ds, "\tin vec2 barycentricTexCo;\n");
+ BLI_dynstr_append(ds, "in vec2 barycentricTexCo;\n");
if (builtins & GPU_BARYCENTRIC_DIST)
- BLI_dynstr_append(ds, "\tflat in vec3 barycentricDist;\n");
+ BLI_dynstr_append(ds, "flat in vec3 barycentricDist;\n");
BLI_dynstr_append(ds, "Closure nodetree_exec(void)\n{\n");
@@ -1790,6 +1789,7 @@ GPUPass *GPU_generate_pass(
GPUNodeLink *frag_outlink,
struct GPUVertexAttribs *attribs,
ListBase *nodes,
+ int *builtins,
const char *vert_code,
const char *geom_code,
const char *frag_lib,
@@ -1804,7 +1804,7 @@ GPUPass *GPU_generate_pass(
GPU_nodes_get_vertex_attributes(nodes, attribs);
/* generate code */
- char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output);
+ char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output, builtins);
/* Cache lookup: Reuse shaders already compiled */
uint32_t hash = gpu_pass_hash(fragmentgen, defines, attribs);
diff --git a/source/blender/gpu/intern/gpu_codegen.h b/source/blender/gpu/intern/gpu_codegen.h
index 39d946d89a0..96be3a1a422 100644
--- a/source/blender/gpu/intern/gpu_codegen.h
+++ b/source/blender/gpu/intern/gpu_codegen.h
@@ -179,7 +179,7 @@ typedef struct GPUPass GPUPass;
GPUPass *GPU_generate_pass(
GPUMaterial *material,
GPUNodeLink *frag_outlink, struct GPUVertexAttribs *attribs,
- ListBase *nodes,
+ ListBase *nodes, int *builtins,
const char *vert_code, const char *geom_code,
const char *frag_lib, const char *defines);
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c
index ac97867f40f..986003c99e6 100644
--- a/source/blender/gpu/intern/gpu_material.c
+++ b/source/blender/gpu/intern/gpu_material.c
@@ -688,6 +688,7 @@ GPUMaterial *GPU_material_from_nodetree(
mat->outlink,
&mat->attribs,
&mat->nodes,
+ &mat->builtins,
vert_code,
geom_code,
frag_lib,
diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c
index f6bbc228ae9..d46fc979363 100644
--- a/source/blender/gpu/intern/gpu_shader_interface.c
+++ b/source/blender/gpu/intern/gpu_shader_interface.c
@@ -72,6 +72,7 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u)
[GPU_UNIFORM_COLOR] = "color",
[GPU_UNIFORM_EYE] = "eye",
[GPU_UNIFORM_CALLID] = "callId",
+ [GPU_UNIFORM_OBJECT_INFO] = "unfobjectinfo",
[GPU_UNIFORM_CUSTOM] = NULL,
[GPU_NUM_UNIFORMS] = NULL,