Text archives Help
- From: cgribble@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1078 - in trunk: Engine/Control Model/Materials scenes
- Date: Mon, 22 May 2006 17:51:34 -0600 (MDT)
Author: cgribble
Date: Mon May 22 17:51:34 2006
New Revision: 1078
Modified:
trunk/Engine/Control/DynPLTWorker.cc
trunk/Model/Materials/DynPLTMaterial.h
trunk/scenes/dynplt.cc
trunk/scenes/pnrrd.cc
Log:
Direct lighting in DynPLTWorker still not working; added some debugging
bookmarks to particle-related scenes
Modified: trunk/Engine/Control/DynPLTWorker.cc
==============================================================================
--- trunk/Engine/Control/DynPLTWorker.cc (original)
+++ trunk/Engine/Control/DynPLTWorker.cc Mon May 22 17:51:34 2006
@@ -107,15 +107,14 @@
if (!dynplt || dynplt->valid)
continue;
- // Intialize the texture (use memset?)
unsigned int xres=dynplt->getXRes();
unsigned int yres=dynplt->getYRes();
Real inv_width=1/static_cast<Real>(xres - 1);
Real inv_height=1/static_cast<Real>(yres - 1);
- for (unsigned int v=0; v<yres; ++v)
- for (unsigned int u=0; u<xres; ++u)
- dynplt->texture[u][v]=0;
+ // Intialize the textures
+ bzero(dynplt->texture, xres*yres*sizeof(float));
+ bzero(dynplt->inside, xres*yres*sizeof(float));
// Generate particle's texture
Vector center=particle->getCenter();
@@ -137,9 +136,9 @@
// Initialize a ray packet
int size=RayPacket::MaxSize;
if (size >= nsamples - s) {
- // Number of samples/texel isn't large enough to fill a ray
packet,
- // so set the size of the ray packet to the number of samples
that
- // remain
+ // Remaining number of samples isn't large enough to fill a ray
+ // packet, so set the size of the ray packet to the number of
samples
+ // that remain
size=nsamples - s;
}
@@ -176,7 +175,7 @@
RayPacket::HaveUnitNormals);
// Compute direct lighting at current hit positions
- const LightSet* activeLights=scene->getLights();
+ const LightSet* activeLights=dynplt->getActiveLights();
ShadowAlgorithm::StateBuffer stateBuffer;
bool firstTime=true;
bool done;
@@ -198,14 +197,14 @@
// Normalize directions for proper dot product computation
shadowRays.normalizeDirections();
-
+
// XXX: we're not actually getting shadows...
- for (int i=shadowRays.begin(); i < shadowRays.end(); ++i) {
+ for (int i=shadowRays.begin(); i<shadowRays.end(); ++i) {
if (!shadowRays.wasHit(i)) {
// Not in shadow, so compute the direct contribution
Vector normal=rays.getNormal(i);
Vector shadowdir=shadowRays.getDirection(i);
- ColorComponent cos_theta=Dot(shadowdir, normal);
+ Real cos_theta=Dot(shadowdir, normal);
Color light=shadowRays.getColor(i);
result += atten.get(i)*light.luminance()*cos_theta;
}
@@ -214,9 +213,11 @@
firstTime=false;
} while(!done);
+ // Don't fill/trace ray packet if it's not going to contribute
if (d >= max_depth - 1)
break;
+#if 0
// XXX: not sure if this is correct...
for (int i=rays.begin(); i<rays.end(); ++i) {
// Compute an ONB at the surface point
@@ -232,9 +233,10 @@
Vector2D hemi=sample_groups[hidx[d]][i];
Real hphi=2.0*M_PI*hemi.x();
Real hr=SCIRun::Sqrt(hemi.y());
- Real hx=r*cos(hphi);
- Real hy=r*sin(hphi);
- Real hz=SCIRun::Sqrt(1 - hx*hx - hy*hy);
+ Real hx=hr*cos(hphi);
+ Real hy=hr*sin(hphi);
+ Real hz=1 - hx*hx - hy*hy;
+ hz=(hz>0?SCIRun::Sqrt(hz):0);
Vector out=Vector(hx, hy, hz).normal();
Vector dir=v0*out.x() + v1*out.y() + normal*out.z();
@@ -249,12 +251,12 @@
atten.set(i, atten.get(i)*Dot(normal, dir));
}
- // Reset flags
+ // Reset ray packet
rays.setAllFlags(0);
rays.setFlag(RayPacket::NormalizedDirections);
+ rays.resetHits();
// Intersect rays with the geometry
- rays.resetHits();
scene->getObject()->intersect(rctx, rays);
// Prepare ray packet for next iteration
@@ -303,7 +305,7 @@
++end;
#if 0
- // Shade them, and accumulate background color
+ // Shade the rays, and accumulate background color
RayPacket sub(rays, i, end);
scene->getBackground()->shade(rctx, sub);
@@ -322,6 +324,7 @@
// Update the ray packet configuration, loop to next depth
rays.setDepth(rays.getDepth() + 1);
rays.resize(validRays);
+#endif
}
// Store the result
@@ -336,6 +339,8 @@
if (context->dilate)
dynplt->dilate(context);
+ // XXX: maybe use a transaction to mark the texture as valid and prevent
+ // tearing in the middle of a frame
dynplt->valid=true;
}
}
@@ -343,7 +348,12 @@
void DynPLTWorker::terminate(MantaInterface*)
{
SCIRun::Semaphore semaphore("DynPLTWorker Exit Semaphore", 0);
+
+ // Notify worker to exit
exitSem=&semaphore;
- context->queue->send(0);
+ const Sphere* fake=0;
+ context->queue->send(fake);
+
+ // Block the calling thread until it does...
semaphore.down();
}
Modified: trunk/Model/Materials/DynPLTMaterial.h
==============================================================================
--- trunk/Model/Materials/DynPLTMaterial.h (original)
+++ trunk/Model/Materials/DynPLTMaterial.h Mon May 22 17:51:34 2006
@@ -26,9 +26,10 @@
virtual void shade(const RenderContext& context, RayPacket& rays) const;
-
unsigned int getXRes(void) const { return XRES; }
unsigned int getYRes(void) const { return YRES; }
+
+ const LightSet* getActiveLights(void) const { return activeLights; }
void dilate(const DynPLTContext* context);
Modified: trunk/scenes/dynplt.cc
==============================================================================
--- trunk/scenes/dynplt.cc (original)
+++ trunk/scenes/dynplt.cc Mon May 22 17:51:34 2006
@@ -32,8 +32,12 @@
Group* world=0;
string fname="";
int max_depth=3;
+ int ngroups=100;
int nsamples=32;
int nthreads=1;
+ int qsize=10; // XXX: what's a good default value? should be based (very
+ // roughly) on the number of textures/sec a typical
thread
+ // can process
double radius=1.;
int ridx=-1;
@@ -51,6 +55,9 @@
} else if (arg=="-i") {
if (!getStringArg(i, args, fname))
throw IllegalArgument("scene dynplt -i", i, args);
+ } else if (arg=="-ngroups") {
+ if (!getIntArg(i, args, ngroups))
+ throw IllegalArgument("scene dynplt -ngroups", i, args);
} else if (arg=="-nsamples") {
if (!getIntArg(i, args, nsamples))
throw IllegalArgument("scene dynplt -nsamples", i, args);
@@ -63,12 +70,18 @@
} else if (arg=="-ridx") {
if (!getIntArg(i, args, ridx))
throw IllegalArgument("scene dynplt -ridx", i, args);
+ } else if (arg=="-qsize") {
+ if (!getIntArg(i, args, qsize))
+ throw IllegalArgument("scene dynplt -qsize", i, args);
} else {
cerr<<"Valid options for scene dynplt:\n";
cerr<<" -bv <string> bounding volume {bvh|grid|group}\n";
cerr<<" -depth <int> path trace depth\n";
cerr<<" -i <string> particle data filename\n";
+ cerr<<" -ngroups <int> number of sample groups\n";
+ cerr<<" -nsamples <int> number of samples/texel\n";
cerr<<" -nthreads <int> number of dynplt workers\n";
+ cerr<<" -qsize <int> queue qsize\n";
cerr<<" -radius <float> particle radius\n";
cerr<<" -ridx <int> radius index\n";
throw IllegalArgument("scene dynplt", i, args);
@@ -82,11 +95,10 @@
Scene* scene=new Scene();
// Create DynPLT work queue
- unsigned int size=100; // XXX: this should be a cmdln parameter
- Mailbox<const Sphere*>* queue=new Mailbox<const Sphere*>("DynPLT Work
Queue", size);
+ Mailbox<const Sphere*>* queue=new Mailbox<const Sphere*>("DynPLT Work
Queue",
+ nthreads*qsize);
// Create DynPLTContext
- unsigned int ngroups=100; // XXX: this should be a cmdln parameter
DynPLTContext* dpltctx=new DynPLTContext(queue, scene, ngroups, nsamples,
max_depth);
@@ -101,7 +113,8 @@
thread->activate(false);
// Register termination callback
-
context.manta_interface->registerTerminationCallback(Callback::create(worker,
&DynPLTWorker::terminate));
+
context.manta_interface->registerTerminationCallback(Callback::create(worker,
+ &DynPLTWorker::terminate));
}
// Load particle data, add particles to group
@@ -132,6 +145,12 @@
lights->setAmbientLight(new ConstantAmbient(Color(RGB(0.4, 0.4, 0.4))));
scene->setLights(lights);
+ scene->addBookmark("shadow debug 0", Vector(4.55511, 5.33192, 1.09352),
+ Vector(0.00492657, 0.0220694, 0.198221),
+ Vector(0.378617, -0.459881, 0.803217), 0.00103794);
+ scene->addBookmark("shadow debug 1", Vector(4.55511, 5.33192, 1.09352),
+ Vector(0.00492657, 0.0220694, 0.198221),
+ Vector(0.378617, -0.459881, 0.803217), 0.00909911);
scene->addBookmark("view 0", Vector(0.02, 1.02, 0.20),
Vector(0.02, 0.02, 0.20), Vector(0, 0, 1),
0.59);
Modified: trunk/scenes/pnrrd.cc
==============================================================================
--- trunk/scenes/pnrrd.cc (original)
+++ trunk/scenes/pnrrd.cc Mon May 22 17:51:34 2006
@@ -83,5 +83,9 @@
lights->setAmbientLight(new ConstantAmbient(Color(RGB(0.4, 0.4, 0.4))));
scene->setLights(lights);
+ scene->addBookmark("shadow debug", Vector(4.55511, 5.33192, 1.09352),
+ Vector(0.00492657, 0.0220694, 0.198221),
+ Vector(0.378617, -0.459881, 0.803217), 0.00103794);
+
return scene;
}
- [MANTA] r1078 - in trunk: Engine/Control Model/Materials scenes, cgribble, 05/22/2006
Archive powered by MHonArc 2.6.16.