Text archives Help
- From: sparker@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r804 - in branches/vertical/Model: Materials Primitives
- Date: Tue, 27 Dec 2005 14:24:00 -0700 (MST)
Author: sparker
Date: Tue Dec 27 14:23:59 2005
New Revision: 804
Modified:
branches/vertical/Model/Materials/Phong.cc
branches/vertical/Model/Primitives/Parallelogram.cc
Log:
Avoid redundant loads in Phong and Parallelogram to improve results of
optimizer. Gcc still generates lousy code for most things even with all
of the fancy compiler flags on the mac.
Vertical raypackets are now about 5% faster than the trunk version.
Modified: branches/vertical/Model/Materials/Phong.cc
==============================================================================
--- branches/vertical/Model/Materials/Phong.cc (original)
+++ branches/vertical/Model/Materials/Phong.cc Tue Dec 27 14:23:59 2005
@@ -87,13 +87,16 @@
// Initialize with the ambient contribution.
Color totalDiffuse(rays.getAmbientLight(i));
Color totalSpecular = Color::black();
+ Vector normal = rays.getNormal(i);
+ Vector dir = rays.getDirection(i);
for(int j=rays.shadowBegin(i);j<rays.shadowEnd(i);j++){
if(!shadowRays.wasHit(j)){
// Not in shadow, so compute the direct and specular contributions.
- ColorComponent cos_theta = Dot(shadowRays.getDirection(j),
rays.getNormal(i));
+ Vector shadowdir = shadowRays.getDirection(j);
+ ColorComponent cos_theta = Dot(shadowdir, normal);
totalDiffuse += shadowRays.getLight(j)*cos_theta;
- Vector H = shadowRays.getDirection(j)-rays.getDirection(i);
- ColorComponent cos_alpha = Dot(H, rays.getNormal(i));
+ Vector H = shadowdir-dir;
+ ColorComponent cos_alpha = Dot(H, normal);
if(cos_alpha > 0){
ColorComponent length = H.length();
totalSpecular += shadowRays.getLight(j) * ipow(cos_alpha/length,
specpow);
Modified: branches/vertical/Model/Primitives/Parallelogram.cc
==============================================================================
--- branches/vertical/Model/Primitives/Parallelogram.cc (original)
+++ branches/vertical/Model/Primitives/Parallelogram.cc Tue Dec 27 14:23:59
2005
@@ -72,13 +72,15 @@
}
} else {
for(int i=rays.begin();i<rays.end();i++){
- Real dt=Dot(rays.getDirection(i), normal);
+ Vector dir = rays.getDirection(i);
+ Real dt=Dot(dir, normal);
if(Abs(dt) < (Real)1.e-6)
continue;
- Real t=(d-Dot(normal, rays.getOrigin(i)))/dt;
+ Point origin = rays.getOrigin(i);
+ Real t=(d-Dot(normal, origin))/dt;
if(t>rays.getMinT(i))
continue;
- Point p(rays.getOrigin(i)+rays.getDirection(i)*t);
+ Point p(origin+dir*t);
Vector vi(p-anchor);
Real a1 = Dot(v1, vi);
if (a1 < 0 || a1 > 1)
- [MANTA] r804 - in branches/vertical/Model: Materials Primitives, sparker, 12/27/2005
Archive powered by MHonArc 2.6.16.