diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-10-09 18:32:13 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-10-09 18:34:04 +0300 |
commit | e234ce9b2272323ef2666d3f0718ecb8c688b693 (patch) | |
tree | 44b5d18a5fb306b747791671239d9c48ac434d4c /source/blender/gpu/intern | |
parent | 6d6e3869ce52085bbd4351de96cbc0e6b51b974b (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/intern')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 12 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.h | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_interface.c | 1 |
4 files changed, 9 insertions, 7 deletions
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, |