diff options
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_materials.c')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_materials.c | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_materials.c b/source/blender/draw/engines/workbench/workbench_materials.c index 6f43e1f8707..cf0ed3147d0 100644 --- a/source/blender/draw/engines/workbench/workbench_materials.c +++ b/source/blender/draw/engines/workbench/workbench_materials.c @@ -8,17 +8,15 @@ #include "BLI_hash.h" #define HSV_SATURATION 0.5 -#define HSV_VALUE 0.9 +#define HSV_VALUE 0.8 void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Material *mat, WORKBENCH_MaterialData *data) { /* When V3D_SHADING_TEXTURE_COLOR is active, use V3D_SHADING_MATERIAL_COLOR as fallback when no texture could be determined */ int color_type = wpd->shading.color_type == V3D_SHADING_TEXTURE_COLOR ? V3D_SHADING_MATERIAL_COLOR : wpd->shading.color_type; - static float default_diffuse_color[] = {0.8f, 0.8f, 0.8f, 1.0f}; - static float default_specular_color[] = {0.5f, 0.5f, 0.5f, 0.5f}; - copy_v4_v4(data->diffuse_color, default_diffuse_color); - copy_v4_v4(data->specular_color, default_specular_color); - data->roughness = 0.5f; + copy_v4_fl4(data->diffuse_color, 0.8f, 0.8f, 0.8f, 1.0f); + copy_v4_fl4(data->specular_color, 0.05f, 0.05f, 0.05f, 1.0f); /* Dielectric: 5% reflective. */ + data->roughness = 0.5; /* sqrtf(0.25f); */ if (color_type == V3D_SHADING_SINGLE_COLOR) { copy_v3_v3(data->diffuse_color, wpd->shading.single_color); @@ -36,9 +34,15 @@ void workbench_material_update_data(WORKBENCH_PrivateData *wpd, Object *ob, Mate else { /* V3D_SHADING_MATERIAL_COLOR */ if (mat) { - copy_v3_v3(data->diffuse_color, &mat->r); - copy_v3_v3(data->specular_color, &mat->specr); - data->roughness = mat->roughness; + if (SPECULAR_HIGHLIGHT_ENABLED(wpd)) { + mul_v3_v3fl(data->diffuse_color, &mat->r, 1.0f - mat->metallic); + mul_v3_v3fl(data->specular_color, &mat->r, mat->metallic); + add_v3_fl(data->specular_color, 0.05f * (1.0f - mat->metallic)); + data->roughness = sqrtf(mat->roughness); /* Remap to disney roughness. */ + } + else { + copy_v3_v3(data->diffuse_color, &mat->r); + } } } } @@ -161,21 +165,6 @@ int workbench_material_get_shader_index(WORKBENCH_PrivateData *wpd, bool use_tex return index; } -void workbench_material_set_normal_world_matrix( - DRWShadingGroup *grp, WORKBENCH_PrivateData *wpd, float persistent_matrix[3][3]) -{ - if (STUDIOLIGHT_ORIENTATION_WORLD_ENABLED(wpd)) { - float view_matrix_inverse[4][4]; - float rot_matrix[4][4]; - float matrix[4][4]; - axis_angle_to_mat4_single(rot_matrix, 'Z', -wpd->shading.studiolight_rot_z); - DRW_viewport_matrix_get(view_matrix_inverse, DRW_MAT_VIEWINV); - mul_m4_m4m4(matrix, rot_matrix, view_matrix_inverse); - copy_m3_m4(persistent_matrix, matrix); - DRW_shgroup_uniform_mat3(grp, "normalWorldMatrix", persistent_matrix); - } -} - int workbench_material_determine_color_type(WORKBENCH_PrivateData *wpd, Image *ima, Object *ob) { int color_type = wpd->shading.color_type; |