Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[Manta] r1762 - trunk/scenes


Chronological Thread 
  • From: shirley@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [Manta] r1762 - trunk/scenes
  • Date: Sun, 7 Oct 2007 11:12:17 -0600 (MDT)

Author: shirley
Date: Sun Oct  7 11:12:16 2007
New Revision: 1762

Modified:
   trunk/scenes/softshadow.cc
Log:
Added:
  CLAs for light width and num samples (default num = 16)
  Hammersley arrangement of lights

I am going to skip textures for now

There is still an acne bug related to epsilons-- suggestions appreciated.



Modified: trunk/scenes/softshadow.cc
==============================================================================
--- trunk/scenes/softshadow.cc  (original)
+++ trunk/scenes/softshadow.cc  Sun Oct  7 11:12:16 2007
@@ -4,6 +4,7 @@
 #include <Model/Groups/ObjGroup.h>
 #include <Model/Groups/DynBVH.h>
 
+
 #include <Model/Materials/Checker.h>
 #include <Model/Materials/CopyTextureMaterial.h>
 #include <Model/Materials/Dielectric.h>
@@ -23,6 +24,8 @@
 #include <Model/AmbientLights/ArcAmbient.h>
 
 #include <Core/Exceptions/IllegalArgument.h>
+#include <Core/Exceptions/IllegalValue.h>
+#include <Core/Util/Args.h>
 
 #include <iostream>
 
@@ -63,17 +66,6 @@
   }
 };
 
-void usage()
-{
-  cerr << "Valid options for scene:\n";
-  cerr << " -model    - Required. The file to load.\n";
-}
-
-void argumentError(int i, const vector<string>& args)
-{
-  usage();
-  throw IllegalArgument("scene teapotRoom", i, args);
-}
 
 void addFence(Group* group)
 {
@@ -108,34 +100,74 @@
   Material* white = new Lambertian(Color::white() * 0.8);
 
   Object* floor=new Rect(white,
-                         Vector(0,0,-200),
-                         Vector(1600,0,0),
-                         Vector(0,1600,0));
+                         Vector(-1000,-1000,-200),
+                         Vector(3200,0,0),
+                         Vector(0,3200,0));
   group->add(floor);
 }
 
-void addLights( LightSet* lights, int num_lights)
+// generate N points on [0,1]^2
+void getLightSamples( float *u_, float *v_, int n) 
 {
-  float minx = -2000; float scalex = 600;
-  float minz = 4000; float scalez = 600;
+  //for (int i = 0; i < n; i++) { 
+  // u[i] = drand48();
+  //   v[i] = drand48();
+  //}
+  // hammersley from 97 jgt article
+  float p, u, v;
+  int k, kk, pos;
+  
+  for (k=0, pos=0 ; k<n ; k++)
+  {
+    u = 0;
+    for (p=0.5, kk=k ; kk ; p*=0.5, kk>>=1)
+      if (kk & 1)                           // kk mod 2 == 1
+       u += p;
+
+    v = (k + 0.5) / n;
+
+    u_[k] = u;
+    v_[k] = v;
+  }
+}
+
+void addLights( LightSet* lights, int num_lights, float width_scale)
+{
+  float minx = -2000; float scalex = 300*width_scale;
+  float minz = 4000; float scalez = 300*width_scale;
   float y = 4000;
   Color col = Color(RGB(0.8,0.8,0.8)) * (1.0/num_lights);
+  float *u = new float[num_lights];
+  float *v = new float[num_lights];
+  getLightSamples( u, v, num_lights );
   for (int i = 0; i < num_lights; i++) { 
-     float u = drand48();
-     float v = drand48();
-     lights->add(new PointLight(Vector(minx + u * scalex, y, minz + 
v*scalez), col));
+     lights->add(new PointLight(Vector(minx + u[i] * scalex, y, minz + 
v[i]*scalez), col));
   }
+  delete [] u;
+  delete [] v;
 }
 
 
 extern "C"
 Scene* make_scene(const ReadContext&, const vector<string>& args)
 {
-  for(size_t i=0;i<args.size();i++){
+  int num_lights = 16;
+  double width_scale= 1.0;
+
+  for(size_t i = 0; i < args.size(); ++i) {
     string arg = args[i];
-    if (arg == "--help") {
-      usage();
-      return 0;
+
+    if(arg == "-num") {
+      if(!getIntArg(i, args, num_lights))
+        throw IllegalArgument("scene softshadow -num", i, args);
+    } else if (arg == "-width_scale") {
+      if(!getDoubleArg(i, args, width_scale))
+        throw IllegalArgument("scene softshadow -width_scale", i , args);
+    } else {
+      cerr << "Valid options for softshadow:\n"
+           << "  -num - number of point lights\n"
+           << "  -width_scale - multiplier for light width\n" ;
+      throw IllegalArgument("scene complexitytest", i, args);
     }
   }
 
@@ -153,7 +185,7 @@
   scene->setObject(bvh);
 
   LightSet* lights = new LightSet();
-  addLights(lights, 100);
+  addLights(lights, num_lights, width_scale);
   Color cup(RGB(0.5, 0.5, 0));
   Color cdown(RGB(0.1, 0.1, 0.7));
   Vector up(0,0,1);
@@ -162,8 +194,8 @@
   scene->setLights(lights);
 
   // Add a default camera
-  Vector eye(1400,1500,600);
-  Vector lookat(0,0,150);
+  Vector eye(-2000,-2000,800);
+  Vector lookat(-300,-300,0);
   Real fov=45;
   scene->addBookmark("default view", eye, lookat, up, fov, fov);
 





Archive powered by MHonArc 2.6.16.

Top of page