Text archives Help
- From: "Thiago Ize" <thiago@sci.utah.edu>
- To: manta@sci.utah.edu
- Subject: [Manta] r2146 - in trunk: Engine/ImageTraversers Engine/Renderers Interface Model/MiscObjects
- Date: Thu, 20 Mar 2008 17:42:30 -0600 (MDT)
Author: thiago
Date: Thu Mar 20 17:42:29 2008
New Revision: 2146
Modified:
trunk/Engine/ImageTraversers/DeadlineImageTraverser.h
trunk/Engine/Renderers/KajiyaPathtracer.cc
trunk/Interface/RayPacket.cc
trunk/Interface/RayPacket.h
trunk/Model/MiscObjects/KeyFrameAnimation.cc
Log:
Interface/RayPacket:
-Added safeComputeGeometricNormals.
Engine/Renderers/KajiyaPathtracer.cc:
-Fixed bug where everything was in shadows. This was due to
hardshadow.cc switching over to using geometric normals. This code
in turn needed to be updated to work with geometric normals.
Model/MiscObjects/KeyFrameAnimation.cc:
-Removed tabs
Engine/ImageTraversers/DeadlineImageTraverser.h:
-Warning removal. Nothing fancy.
Modified: trunk/Engine/ImageTraversers/DeadlineImageTraverser.h
==============================================================================
--- trunk/Engine/ImageTraversers/DeadlineImageTraverser.h (original)
+++ trunk/Engine/ImageTraversers/DeadlineImageTraverser.h Thu Mar 20
17:42:29 2008
@@ -114,7 +114,7 @@
bool converged;
double StartFrameTime;
bool do_dart_benchmark;
- unsigned int max_spp; //max samples per pixel
+ int max_spp; //max samples per pixel
enum PriorityScheme {
FIFO, LuminanceVariance, Contrast, FIFO_to_LumVar, Center
};
Modified: trunk/Engine/Renderers/KajiyaPathtracer.cc
==============================================================================
--- trunk/Engine/Renderers/KajiyaPathtracer.cc (original)
+++ trunk/Engine/Renderers/KajiyaPathtracer.cc Thu Mar 20 17:42:29 2008
@@ -156,8 +156,8 @@
rays.resetHits();
context.scene->getObject()->intersect(context, rays);
rays.computeHitPositions();
- rays.safeComputeNormals(context);
- rays.computeFFNormals(context); // Must do this before writing over the
ray direction
+ rays.safeComputeGeometricNormals(context);
+ rays.computeFFGeometricNormals(context); // Must do this before writing
over the ray direction
// 3. Sort on materials, separating background rays
MatlSortMode msm = depth >=
static_cast<int>(matlsort_mode.size())?matlsort_mode[matlsort_mode.size()-1]:matlsort_mode[depth];
@@ -220,11 +220,11 @@
for(int i=shadowRays.begin(); i < shadowRays.end(); i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct lighting contributions.
- Vector normal = rays.getFFNormal(i);
- Vector light_dir = shadowRays.getDirection(i);
+ const Vector normal = rays.getFFGeometricNormal(i);
+ const Vector light_dir = shadowRays.getDirection(i);
// TODO(boulos): Replace this with BSDFEval
- double weight=Dot(normal, light_dir);
- Color light_color = shadowRays.getColor(i);
+ const double weight=Dot(normal, light_dir);
+ const Color light_color = shadowRays.getColor(i);
result.set(i, result.get(i) + total_attenuation.get(i) *
light_color * weight);
}
}
@@ -337,6 +337,14 @@
for(int k=0;k<3;k++)
swap(data->ffnormal[k], i, j);
+ // Conditionally: geometricNormal
+ for(int k=0;k<3;k++)
+ swap(data->geometricNormal[k], i, j);
+
+ // Conditionally: ffgeometricNormal,
+ for(int k=0;k<3;k++)
+ swap(data->ffgeometricNormal[k], i, j);
+
// Conditionally: hitPosition,
for(int k=0;k<3;k++)
swap(data->hitPosition[k], i, j);
@@ -404,6 +412,10 @@
for(int j=0;j<3;j++)
swap(data->ffnormal[j], i, newEnd);
+ // Move ffgeometricNormal
+ for(int j=0;j<3;j++)
+ swap(data->ffgeometricNormal[j], i, newEnd);
+
// Move hitPosition
for(int j=0;j<3;j++)
swap(data->hitPosition[j], i, newEnd);
@@ -508,6 +520,14 @@
for(int k=0;k<3;k++)
swap(data->ffnormal[k], i, j);
+ // Conditionally: geometricNormal
+ for(int k=0;k<3;k++)
+ swap(data->geometricNormal[k], i, j);
+
+ // Conditionally: ffgeometricNormal,
+ for(int k=0;k<3;k++)
+ swap(data->ffgeometricNormal[k], i, j);
+
// Conditionally: hitPosition,
for(int k=0;k<3;k++)
swap(data->hitPosition[k], i, j);
@@ -589,6 +609,14 @@
// Conditionally: ffnormal,
for(int k=0;k<3;k++)
swap(data->ffnormal[k], i, newBegin);
+
+ // Conditionally: geometricNormal
+ for(int k=0;k<3;k++)
+ swap(data->geometricNormal[k], i, newBegin);
+
+ // Conditionally: ffgeometricNormal,
+ for(int k=0;k<3;k++)
+ swap(data->ffgeometricNormal[k], i, newBegin);
// Conditionally: hitPosition,
for(int k=0;k<3;k++)
Modified: trunk/Interface/RayPacket.cc
==============================================================================
--- trunk/Interface/RayPacket.cc (original)
+++ trunk/Interface/RayPacket.cc Thu Mar 20 17:42:29 2008
@@ -217,6 +217,44 @@
flags |= HaveNormals | HaveUnitNormals;
}
+void RayPacket::safeComputeGeometricNormals(const RenderContext& context)
+{
+ if(flags & HaveGeometricNormals)
+ return;
+ // Compute geometric normals
+ for(int i=rayBegin;i<rayEnd;){
+ while(!data->hitMatl[i]){
+ i++;
+ if(i >= rayEnd) {
+ flags |= HaveGeometricNormals | HaveUnitGeometricNormals;
+ return;
+ }
+ }
+
+ const Primitive* prim = data->hitPrim[i];
+ int tend = i+1;
+ while(tend < rayEnd && data->hitPrim[tend] == prim)
+ tend++;
+ RayPacket subPacket(*this, i, tend);
+ prim->computeGeometricNormal(context, subPacket);
+ // BTW, == has higher precedence than &, so mind the ()'s.
+ if ((subPacket.flags & HaveUnitGeometricNormals) == 0) {
+ // Normalize the normals if they haven't been.
+ for(int s=i;s<tend;++s){
+ Real sum = 0;
+ for(int j=0;j<3;++j)
+ sum += data->geometricNormal[j][s] * data->geometricNormal[j][s];
+ Real scale = 1/Sqrt(sum);
+ for(int j=0;j<3;++j)
+ data->geometricNormal[j][s] *= scale;
+ }
+ }
+ i=tend;
+ }
+
+ flags |= HaveGeometricNormals | HaveUnitGeometricNormals;
+}
+
void RayPacket::actualComputeFFNormals(const RenderContext& context)
{
// We need to have normals
Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Thu Mar 20 17:42:29 2008
@@ -905,6 +905,7 @@
}
void safeComputeNormals(const RenderContext& context);
+ void safeComputeGeometricNormals(const RenderContext& context);
private:
void actualNormalizeDirections();
void actualComputeInverseDirections();
Modified: trunk/Model/MiscObjects/KeyFrameAnimation.cc
==============================================================================
--- trunk/Model/MiscObjects/KeyFrameAnimation.cc (original)
+++ trunk/Model/MiscObjects/KeyFrameAnimation.cc Thu Mar 20 17:42:29
2008
@@ -35,8 +35,8 @@
frames.push_back(objects);
if (!framesClipped)
{
- endFrame = frames.size() - 1;
- numFrames = frames.size();
+ endFrame = frames.size() - 1;
+ numFrames = frames.size();
}
}
@@ -86,52 +86,47 @@
if (frames.empty())
return;
if (context.proc == 0) {
- if (forceUpdate)
- {
- forceUpdate = false;
+ if (forceUpdate)
+ {
+ forceUpdate = false;
currGroup = frames[startFrame];
}
- }
-
+ }
+
//only one thread can do serial code
if (context.proc == 0) {
- if (repeating)
- {
- if ((context.time - startTime) >= (duration+repeatLastFrame))
- {
- repeating = false;
- updateToCurrTime = true;
- }
- }
- else
- {
- if (updateToCurrTime) {
- updateToCurrTime = false;
- differentFrame = isDifferentFrame(newTime);
- startTime = context.time - newTime;
- currTime = newTime;
- if (paused) {
- pauseTime = startTime;
- }
- }
- else if (paused) {
- differentFrame = false;
- }
- else {
- float newTime = wrapTime(context.time - startTime);
- differentFrame = isDifferentFrame(newTime);
- currTime = newTime;
- }
- if (!loop && (context.time - startTime) >=duration)
- {
- pauseAnimation();
- }
- if (loop && repeatLastFrame > 0.0f && (context.time -
startTime) >= duration)
- {
- repeating = true;
- }
- }
- }
+ if (repeating) {
+ if ((context.time - startTime) >= (duration+repeatLastFrame)) {
+ repeating = false;
+ updateToCurrTime = true;
+ }
+ }
+ else {
+ if (updateToCurrTime) {
+ updateToCurrTime = false;
+ differentFrame = isDifferentFrame(newTime);
+ startTime = context.time - newTime;
+ currTime = newTime;
+ if (paused) {
+ pauseTime = startTime;
+ }
+ }
+ else if (paused) {
+ differentFrame = false;
+ }
+ else {
+ float newTime = wrapTime(context.time - startTime);
+ differentFrame = isDifferentFrame(newTime);
+ currTime = newTime;
+ }
+ if (!loop && (context.time - startTime) >=duration) {
+ pauseAnimation();
+ }
+ if (loop && repeatLastFrame > 0.0f && (context.time - startTime) >=
duration) {
+ repeating = true;
+ }
+ }
+ }
//need to make sure proc 0 has updated the currTime.
//a barrier is a little heavy for this, but it's cleaner code (and I'm
lazy).
barrier.wait(context.numProcs);
@@ -140,7 +135,7 @@
float frame = currTime/duration * numFrames;
if (lockedFrames && lastFrame!=frame && (lastFrame+1)%(numFrames) !=
frame)
{
- frame = (lastFrame+1)%(numFrames);
+ frame = (lastFrame+1)%(numFrames);
}
lastFrame = static_cast<int>(frame);
@@ -187,32 +182,32 @@
//! make sure every frame is shown at least once
void KeyFrameAnimation::lockFrames(bool st)
{
- lockedFrames = st;
+ lockedFrames = st;
}
void KeyFrameAnimation::clipFrames(int start, int end)
{
- if (start < 0 || end >= int(frames.size()) || end < start)
- {
- cerr << "clipFrames out of bounds\n";
- return;
- }
- startFrame = start;
- endFrame = end;
- numFrames = end - start + 1;
- framesClipped = true;
- forceUpdate = true;
+ if (start < 0 || end >= int(frames.size()) || end < start)
+ {
+ cerr << "clipFrames out of bounds\n";
+ return;
+ }
+ startFrame = start;
+ endFrame = end;
+ numFrames = end - start + 1;
+ framesClipped = true;
+ forceUpdate = true;
}
void KeyFrameAnimation::repeatLastFrameForSeconds(float time)
{
- assert(time >= 0.0f);
- repeatLastFrame = time;
+ assert(time >= 0.0f);
+ repeatLastFrame = time;
}
void KeyFrameAnimation::loopAnimation(bool st)
{
- loop = st;
+ loop = st;
}
float KeyFrameAnimation::wrapTime(float time) const
- [Manta] r2146 - in trunk: Engine/ImageTraversers Engine/Renderers Interface Model/MiscObjects, Thiago Ize, 03/20/2008
Archive powered by MHonArc 2.6.16.