Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r795 - branches/vertical/Model/Materials


Chronological Thread 
  • From: sparker@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r795 - branches/vertical/Model/Materials
  • Date: Mon, 19 Dec 2005 11:32:27 -0700 (MST)

Author: sparker
Date: Mon Dec 19 11:32:24 2005
New Revision: 795

Modified:
   branches/vertical/Model/Materials/Phong.cc
Log:
Partial implementation of new shadow algorithm stuff


Modified: branches/vertical/Model/Materials/Phong.cc
==============================================================================
--- branches/vertical/Model/Materials/Phong.cc  (original)
+++ branches/vertical/Model/Materials/Phong.cc  Mon Dec 19 11:32:24 2005
@@ -63,52 +63,43 @@
   rays.computeNormals(context);
 
   // Compute ambient contributions for all rays
-  ColorArray ambientLight;
-  activeLights->getAmbientLight()->computeAmbient(context, rays, 
ambientLight);
+  ColorArray ambientAndDiffuseLight;
+  activeLights->getAmbientLight()->computeAmbient(context, rays, 
ambientAndDiffuseLight);
 
   // We normalized directions for proper dot product computation.
   rays.normalizeDirections();
 
-  RayPacketData data;
-  int start = 0;
+  ColorArray totalSpecular = Color::black();
+  ShadowData shadowState;
+  for(int light = 0; light < activeLights.size(); ){
+    RayPacketData shadowData;
+    RayPacket shadowRays(shadowData, 0, rays.getDepth(), 0);
 
-#if 0
-  do {
-    RayPacket shadowRays(data, 0, rays.getDepth(), 0);
-    int end = context.shadowAlgorithm->computeShadows(context, activeLights,
-                                                     rays, start, 
shadowRays);
+    // Call the shadowalgorithm to generate shadow rays.  The shadowAlgorithm
+    // will potentially increment the light index.  If some lights do not
+    // get any shadows, it can increment by more than one at a time.
+    context.shadowAlgorithm->computeShadows(context, activeLights, light,
+                                            rays, shadowRays);
 
     // We normalized directions for proper dot product computation.
     shadowRays.normalizeDirections();
-
-    for(int i=start;i<end;i++){
-      // Initialize with the ambient contribution.
-      Color totalDiffuse;
-      for(int j=0;j<Color::NumComponents;j++)
-        totalDiffuse[j] = ambientLight[j][i];
-      Color totalSpecular = Color::black();
-      NOT_FINISHED("Phong lighting");
-#if 0
-      for(int j=e.shadowBegin;j<e.shadowEnd;j++){
-        RayPacket::Element& s = shadowRays.get(j);
-        if(!s.hitInfo.wasHit()){
-          // Not in shadow, so compute the direct and specular contributions.
-          ColorComponent cos_theta = Dot(s.ray.direction(), e.normal);
-          totalDiffuse += s.light*cos_theta;
-          Vector H = s.ray.direction()-e.ray.direction();
-          ColorComponent cos_alpha = Dot(H, e.normal);
+    for(int i=0;i<shadowRays.size();i++){
+      if(!shadowRays.wasHit(i)){
+        // Not in shadow, so compute the direct and specular contributions.
+        ColorComponent cos_theta = Dot(shadowRays.getDirection(i), e.normal);
+        totalAmbientAndDiffuse += s.light*cos_theta;
+        Vector H = shadowRays.getDirection(i)-rays.getDirection(i???);
+        ColorComponent cos_alpha = Dot(H, rays.getNormal(???));
           if(cos_alpha > 0){
             ColorComponent length = H.length();
             totalSpecular += s.light * ipow(cos_alpha/length, specpow);
           }
         }
       }
-#endif
       rays.setResult(i, diffuse[i]*totalDiffuse+specular[i]*totalSpecular);
     }
     start = end;
   } while(start < rays.getSize());
-#endif
 
   // Compute reflections
   if(do_refl && rays.getDepth() < 
context.scene->getRenderParameters().maxDepth){




  • [MANTA] r795 - branches/vertical/Model/Materials, sparker, 12/19/2005

Archive powered by MHonArc 2.6.16.

Top of page