Commits

Cliff Biffle  committed 07ab7c2

Renderers now compute false colors only when lighting is disabled. This improves lit surface quality and reduces CPU usage.

  • Participants
  • Parent commits c1b9a63

Comments (0)

Files changed (3)

File KVPointCloudRenderer.m

   // Avoid the property message send for a significant perf win.
   // (Sending a message doubles our render time.)
   BOOL textured = self.textured;
+  BOOL lit = self.useLighting;
   const projective_transform_t xform = self.colorTransform;
   KVAbstractRendererProjector projector =
       (KVAbstractRendererProjector) [self methodForSelector: @selector(projectInto:x:y:z:)];
         const rgb_t *pixelColor = &colors->pixels[colorY][colorX];
         
         glColor3ubv(&pixelColor->r);
-      } else {
+      } else if (!lit) {
         vec3f_t falseColor = vector_scale(baseColor, 1.F - depth/10.F);
         glColor3fv(&falseColor.x);
       }

File KVQuadRenderer.m

                              colors: (const colors_t *)colors {
   // Avoid message send for large performance win.
   BOOL textured = self.textured;
+  BOOL lit = self.useLighting;
   projective_transform_t xform = self.colorTransform;
   KVAbstractRendererProjector projector =
       (KVAbstractRendererProjector) [self methodForSelector: @selector(projectInto:x:y:z:)];
       
       if (skip) continue;
       
-      // Note: the normal is correct for the upper-left half only.
-      compute_normal(&coords[0], &coords[1], &coords[2], &normal);
-      glNormal3fv(&normal.x);
+      if (lit) {
+        // Note: the normal is correct for the upper-left half only.
+        compute_normal(&coords[0], &coords[1], &coords[2], &normal);
+        glNormal3fv(&normal.x);
+      }
       
       for (int i = 0; i < 4; i++) {
         if (textured) {
           const rgb_t *pixelColor = &colors->pixels[colorY][colorX];
           
           glColor3ubv(&pixelColor->r);
-        } else {
+        } else if (!lit) {
           vec3f_t falseColor = vector_scale(baseColor, vcolors[i]);
           glColor3fv(&falseColor.x);
         }

File KVTriStripRenderer.m

   
   // Avoid message send for a large performance win.
   BOOL textured = self.textured;
+  BOOL lit = self.useLighting;
   const projective_transform_t xform = self.colorTransform;
 
   KVAbstractRendererProjector projector =
         
         projector(self, @selector(projectInto:x:y:z:), &coord, x, y + step, d);
         
-        compute_normal(&prev[0], &prev[1], &coord, &normal);
-        glNormal3fv(&normal.x);
+        if (lit) {
+          compute_normal(&prev[0], &prev[1], &coord, &normal);
+          glNormal3fv(&normal.x);
+        }
 
         if (textured) {
           int colorX = (int) (x * xform.scale.x + xform.offset.x);
           const rgb_t *pixelColor = &colors->pixels[colorY][colorX];
           
           glColor3ubv(&pixelColor->r);
-        } else {
+        } else if (!lit) {
           vec3f_t falseColor = vector_scale(baseColor, 1.F - d/10.F);
           glColor3fv(&falseColor.x);
         }