diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-29 10:59:37 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-29 10:59:37 +0300 |
commit | 15ebe30bc5bdb9d515c8a8a478db6c7770ff0fb1 (patch) | |
tree | b290c41f93bbbe98ff2dbea50544c4e54a2fd409 /source/blender/draw/engines/workbench/workbench_materials.c | |
parent | 3169160a9741ff399059ce9900ac8cd503707b2f (diff) |
Workbench: remove runtime warnings
Added feature check when uploading material uniforms
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_materials.c')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_materials.c | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 69900ca09ac..56b177d1afc 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -2,6 +2,8 @@ #include "workbench_private.h" +#include "BIF_gl.h" + #include "BLI_dynstr.h" #define HSV_SATURATION 0.5 @@ -177,11 +179,21 @@ int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *i return color_type; } -void workbench_material_shgroup_uniform(DRWShadingGroup *grp, WORKBENCH_MaterialData *material) +void workbench_material_shgroup_uniform(WORKBENCH_PrivateData *wpd, DRWShadingGroup *grp, WORKBENCH_MaterialData *material) { - DRW_shgroup_uniform_vec4(grp, "materialDiffuseColor", material->diffuse_color, 1); - DRW_shgroup_uniform_vec4(grp, "materialSpecularColor", material->specular_color, 1); - DRW_shgroup_uniform_float(grp, "materialRoughness", &material->roughness, 1); + if (workbench_material_determine_color_type(wpd, material->ima) == V3D_SHADING_TEXTURE_COLOR) + { + GPUTexture *tex = GPU_texture_from_blender(material->ima, NULL, GL_TEXTURE_2D, false, 0.0f); + DRW_shgroup_uniform_texture(grp, "image", tex); + } + else { + DRW_shgroup_uniform_vec4(grp, "materialDiffuseColor", material->diffuse_color, 1); + } + + if (SPECULAR_HIGHLIGHT_ENABLED(wpd)) { + DRW_shgroup_uniform_vec4(grp, "materialSpecularColor", material->specular_color, 1); + DRW_shgroup_uniform_float(grp, "materialRoughness", &material->roughness, 1); + } } void workbench_material_copy(WORKBENCH_MaterialData *dest_material, const WORKBENCH_MaterialData *source_material) |