Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r735 - in branches/itanium2: Engine/Shadows Interface Model/Materials
- Date: Tue, 29 Nov 2005 10:50:20 -0700 (MST)
Author: bigler
Date: Tue Nov 29 10:50:18 2005
New Revision: 735
Modified:
branches/itanium2/Engine/Shadows/NoShadows.cc
branches/itanium2/Interface/RayPacket.h
branches/itanium2/Model/Materials/Lambertian.cc
branches/itanium2/Model/Materials/Phong.cc
Log:
Engine/Shadows/NoShadows.cc
Normalize the directions going into the shadow ray packet. Set the
NormalizedDirections flag in the shadow ray packet. This fixes a
bug where the colors were over saturated.
Interface/RayPacket.h
Added some documentation on the signMask computation.
Model/Materials/Lambertian.cc
Model/Materials/Phong.cc
Make sure you normalize incoming ray packet directions outside the
do/while loop. Normalize the ray directions for the shadow rays,
since we use the values in the computation of a dot product.
Modified: branches/itanium2/Engine/Shadows/NoShadows.cc
==============================================================================
--- branches/itanium2/Engine/Shadows/NoShadows.cc (original)
+++ branches/itanium2/Engine/Shadows/NoShadows.cc Tue Nov 29 10:50:18
2005
@@ -31,7 +31,6 @@
RayPacket::Element& e = rays.get(start++);
e.shadowBegin = sidx;
for(int l = 0;l<nlights;l++){
-
Color color;
Vector dir;
@@ -43,12 +42,16 @@
if(Dot(dir, e.normal) > 0){
sidx++;
- s.ray.setDirection(dir);
+ // Be sure to normalize the normals
+ s.ray.setDirection(dir.normal());
s.light = color;
}
}
e.shadowEnd = sidx;
}
+ // We already normalized the rays, so indicate that so we don't do
+ // redundant work.
+ shadowRays.setFlag( RayPacket::NormalizedDirections );
shadowRays.resize(sidx);
shadowRays.resetHit();
return start;
Modified: branches/itanium2/Interface/RayPacket.h
==============================================================================
--- branches/itanium2/Interface/RayPacket.h (original)
+++ branches/itanium2/Interface/RayPacket.h Tue Nov 29 10:50:18 2005
@@ -97,7 +97,7 @@
int shadowBegin, shadowEnd;
int whichEye;
- // Mask describing ray direction, 0==negative 1==positive
+ // Mask describing ray direction, 1==negative 0==positive,zero
// This is set at the same time as inverse direction.
int signMask[3];
};
@@ -166,7 +166,11 @@
// Set the sign mask at the same time. This shouldn't be done
// here. It should be done in a different function or a
- // function of a different name.
+ // function of a different name. Should this be done with the
+ // direction instead of the the inverseDirection? It would
+ // allow these expressions to be scheduled at the concurrently
+ // instead of consecutively. It won't matter if direction is
+ // zero, because 1/0 is +inf and +inf<0 is the same as 0<0.
data[i].signMask[0] = (data[i].inverseDirection[0] < 0);
data[i].signMask[1] = (data[i].inverseDirection[1] < 0);
data[i].signMask[2] = (data[i].inverseDirection[2] < 0);
Modified: branches/itanium2/Model/Materials/Lambertian.cc
==============================================================================
--- branches/itanium2/Model/Materials/Lambertian.cc (original)
+++ branches/itanium2/Model/Materials/Lambertian.cc Tue Nov 29 10:50:18
2005
@@ -40,13 +40,19 @@
// Compute ambient contributions for all rays
activeLights->getAmbientLight()->computeAmbient(context, rays);
+ // We normalized directions for proper dot product computation.
+ rays.normalizeDirections();
+
RayPacketData data;
int start = 0;
- rays.normalizeDirections();
+
do {
RayPacket shadowRays(data, 0, rays.getDepth(), 0);
int end = context.shadowAlgorithm->computeShadows(context, activeLights,
rays, start,
shadowRays);
+ // We normalized directions for proper dot product computation.
+ shadowRays.normalizeDirections();
+
for(int i=start;i<end;i++){
RayPacket::Element& e = rays.get(i);
Color totalLight(e.ambientLight);
Modified: branches/itanium2/Model/Materials/Phong.cc
==============================================================================
--- branches/itanium2/Model/Materials/Phong.cc (original)
+++ branches/itanium2/Model/Materials/Phong.cc Tue Nov 29 10:50:18 2005
@@ -64,21 +64,29 @@
// Compute ambient contributions for all rays
activeLights->getAmbientLight()->computeAmbient(context, rays);
+ // We normalized directions for proper dot product computation.
+ rays.normalizeDirections();
+
RayPacketData data;
int start = 0;
+
do {
RayPacket shadowRays(data, 0, rays.getDepth(), 0);
int end = context.shadowAlgorithm->computeShadows(context, activeLights,
rays, start,
shadowRays);
- rays.normalizeDirections();
+ // We normalized directions for proper dot product computation.
+ shadowRays.normalizeDirections();
+
for(int i=start;i<end;i++){
RayPacket::Element& e = rays.get(i);
+ // Initialize with the ambient contribution.
Color totalDiffuse(e.ambientLight);
Color totalSpecular = Color::black();
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();
- [MANTA] r735 - in branches/itanium2: Engine/Shadows Interface Model/Materials, bigler, 11/29/2005
Archive powered by MHonArc 2.6.16.