[Bf-blender-cvs] [1b0ecb2f891] master: refactor: minor changes to previous commit - rename boolean is_zero by more descriptive has_specularity - add some clarifying comments (and TODO)

Gaia Clary noreply at git.blender.org
Mon May 17 20:06:20 CEST 2021


Commit: 1b0ecb2f891e256eabea9f71575aea207fbee08f
Author: Gaia Clary
Date:   Mon May 17 20:04:56 2021 +0200
Branches: master
https://developer.blender.org/rB1b0ecb2f891e256eabea9f71575aea207fbee08f

refactor: minor changes to previous commit
- rename boolean is_zero by more descriptive has_specularity
- add some clarifying comments (and TODO)

===================================================================

M	source/blender/io/collada/Materials.cpp

===================================================================

diff --git a/source/blender/io/collada/Materials.cpp b/source/blender/io/collada/Materials.cpp
index 508844de042..4b90e459e61 100644
--- a/source/blender/io/collada/Materials.cpp
+++ b/source/blender/io/collada/Materials.cpp
@@ -376,13 +376,13 @@ void MaterialNode::set_opacity(COLLADAFW::ColorOrTexture &cot)
 
 void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot)
 {
-  bool is_zero = false;
+  bool has_specularity = true;
   int locy = -300 * (node_map.size() - 2);
   if (cot.isColor()) {
     COLLADAFW::Color col = cot.getColor();
 
     if (col.getRed() == 0 && col.getGreen() == 0 && col.getBlue() == 0) {
-      is_zero = true;
+      has_specularity = false;
     }
     else {
       bNode *node = add_node(SH_NODE_RGB, -300, locy, "Specular");
@@ -390,17 +390,21 @@ void MaterialNode::set_specular(COLLADAFW::ColorOrTexture &cot)
       /* TODO: Connect node */
     }
   }
-  /* texture */
   else if (cot.isTexture()) {
     add_texture_node(cot, -300, locy, "Specular");
     /* TODO: Connect node */
   }
-  /* not specified (no specular term) */
   else {
-    is_zero = true;
+    /* no specular term) */
+    has_specularity = false;
   }
 
-  if (is_zero) {
+  if (!has_specularity) {
+    /* If specularity is black or not defined reset the Specular value to 0
+       TODO: This is a solution only for a corner case. We must find a better
+       way to handle specularity in general. Also note that currently we
+       do not export specularity values, see EffectExporter::operator()
+    */
     bNodeSocket *socket = nodeFindSocket(shader_node, SOCK_IN, "Specular");
     ((bNodeSocketValueFloat *)socket->default_value)->value = 0.0f;
   }



More information about the Bf-blender-cvs mailing list