From 08ab3cbcce1eb9c2de4953a83b50cabc44479d3c Mon Sep 17 00:00:00 2001 From: OmarSquircleArt Date: Thu, 22 Aug 2019 14:26:09 +0200 Subject: Shading: Add object color to Object Info node. The object color property is added as an additional output in the Object Info node. Reviewers: brecht Differential Revision: https://developer.blender.org/D5554 --- source/blender/gpu/GPU_material.h | 2 +- source/blender/gpu/GPU_shader_interface.h | 7 ++++--- source/blender/gpu/intern/gpu_codegen.c | 4 ++-- source/blender/gpu/intern/gpu_shader_interface.c | 1 + source/blender/gpu/shaders/gpu_shader_material.glsl | 3 +++ 5 files changed, 11 insertions(+), 6 deletions(-) (limited to 'source/blender/gpu') diff --git a/source/blender/gpu/GPU_material.h b/source/blender/gpu/GPU_material.h index dd5292d9c58..2e0dc750e46 100644 --- a/source/blender/gpu/GPU_material.h +++ b/source/blender/gpu/GPU_material.h @@ -92,7 +92,7 @@ typedef enum eGPUBuiltin { GPU_INVERSE_OBJECT_MATRIX = (1 << 3), GPU_VIEW_POSITION = (1 << 4), GPU_VIEW_NORMAL = (1 << 5), - GPU_OBCOLOR = (1 << 6), + GPU_OBJECT_COLOR = (1 << 6), GPU_AUTO_BUMPSCALE = (1 << 7), GPU_CAMERA_TEXCO_FACTORS = (1 << 8), GPU_PARTICLE_SCALAR_PROPS = (1 << 9), diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index d3a9a18b392..ec97e1b085e 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -48,9 +48,10 @@ typedef enum { GPU_UNIFORM_ORCO, /* vec3 OrcoTexCoFactors[] */ GPU_UNIFORM_CLIPPLANES, /* vec4 WorldClipPlanes[] */ - GPU_UNIFORM_COLOR, /* vec4 color */ - GPU_UNIFORM_CALLID, /* int callId */ - GPU_UNIFORM_OBJECT_INFO, /* vec3 objectInfo */ + GPU_UNIFORM_COLOR, /* vec4 color */ + GPU_UNIFORM_CALLID, /* int callId */ + GPU_UNIFORM_OBJECT_INFO, /* vec3 objectInfo */ + GPU_UNIFORM_OBJECT_COLOR, /* vec4 objectColor */ 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 0e15fdd000b..55337596cbe 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -542,8 +542,8 @@ const char *GPU_builtin_name(eGPUBuiltin builtin) else if (builtin == GPU_VIEW_NORMAL) { return "varnormal"; } - else if (builtin == GPU_OBCOLOR) { - return "unfobcolor"; + else if (builtin == GPU_OBJECT_COLOR) { + return "unfobjectcolor"; } else if (builtin == GPU_AUTO_BUMPSCALE) { return "unfobautobumpscale"; diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index e34c6e23024..f205ef31ed2 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -67,6 +67,7 @@ static const char *BuiltinUniform_name(GPUUniformBuiltin u) [GPU_UNIFORM_COLOR] = "color", [GPU_UNIFORM_CALLID] = "callId", [GPU_UNIFORM_OBJECT_INFO] = "unfobjectinfo", + [GPU_UNIFORM_OBJECT_COLOR] = "unfobjectcolor", [GPU_UNIFORM_CUSTOM] = NULL, [GPU_NUM_UNIFORMS] = NULL, diff --git a/source/blender/gpu/shaders/gpu_shader_material.glsl b/source/blender/gpu/shaders/gpu_shader_material.glsl index acd28789364..24fef4f05d8 100644 --- a/source/blender/gpu/shaders/gpu_shader_material.glsl +++ b/source/blender/gpu/shaders/gpu_shader_material.glsl @@ -3629,14 +3629,17 @@ void node_light_falloff( } void node_object_info(mat4 obmat, + vec4 obcolor, vec4 info, float mat_index, out vec3 location, + out vec4 color, out float object_index, out float material_index, out float random) { location = obmat[3].xyz; + color = obcolor; object_index = info.x; material_index = mat_index; random = info.z; -- cgit v1.2.3