Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r975 - in trunk: Model/Primitives scenes
- Date: Tue, 7 Mar 2006 02:55:40 -0700 (MST)
Author: boulos
Date: Tue Mar 7 02:55:38 2006
New Revision: 975
Modified:
trunk/Model/Primitives/WaldTriangle.cc
trunk/Model/Primitives/WaldTriangle.h
trunk/scenes/perf.cc
Log:
Committing bugfix for WaldTriangle. On my laptop
the perf scene gets 6.2 fps with the default
Triangle class and 12.0 fps with the new WaldTriangle.
Command line used:
bin/manta -scene "lib/libscene_perf" -bench 100 25
Add -Wald to the perf scene args to use it instead.
Modified: trunk/Model/Primitives/WaldTriangle.cc
==============================================================================
--- trunk/Model/Primitives/WaldTriangle.cc (original)
+++ trunk/Model/Primitives/WaldTriangle.cc Tue Mar 7 02:55:38 2006
@@ -16,14 +16,14 @@
box.extendByPoint(_p2);
box.extendByPoint(_p3);
- Vector normal = Cross(_p3-_p1, _p2-_p1);
+ Vector normal = Cross(_p2-_p1, _p3-_p1);
normal.normalize();
unsigned int n, u, v;
n = 0;
- if ( fabsf(normal[1]) > fabsf(normal[n]) ) n = 1;
- if ( fabsf(normal[2]) > fabsf(normal[n]) ) n = 2;
+ if ( fabsf(normal[1]) > fabsf(normal[n])) n = 1;
+ if ( fabsf(normal[2]) > fabsf(normal[n])) n = 2;
switch ( n )
{
@@ -42,7 +42,7 @@
c_nu = + _p2[v] - _p1[v];
c_nv = - _p2[u] + _p1[u];
- c_d = - _p1[u] * c_nu + _p1[v] * c_nv;
+ c_d = - (_p1[u] * c_nu + _p1[v] * c_nv);
s = 1.f / ( _p3[u] * c_nu + _p3[v] * c_nv + c_d );
@@ -52,7 +52,7 @@
b_nu = + _p3[v] - _p1[v];
b_nv = - _p3[u] + _p1[u];
- b_d = - _p1[u] * b_nu + _p1[v] * b_nv;
+ b_d = - (_p1[u] * b_nu + _p1[v] * b_nv);
s = 1.f / ( _p2[u] * b_nu + _p2[v] * b_nv + b_d );
@@ -61,5 +61,4 @@
b_d *= s;
n_k = normal[k];
- cout << "Finished triangle" << endl;
}
Modified: trunk/Model/Primitives/WaldTriangle.h
==============================================================================
--- trunk/Model/Primitives/WaldTriangle.h (original)
+++ trunk/Model/Primitives/WaldTriangle.h Tue Mar 7 02:55:38 2006
@@ -10,9 +10,9 @@
namespace Manta
{
- class WaldTriangle : public PrimitiveCommon {
+ class WaldTriangle : public PrimitiveCommon
+ {
public:
-
WaldTriangle() { };
WaldTriangle(Material* mat,
const Vector& _p1, const Vector& _p2, const Vector& _p3);
@@ -38,26 +38,24 @@
float org_k, org_ku, org_kv, f0;
- const int begin = rays.begin();
- const int end = rays.end();
const bool RaysConstantOrigin = rays.getAllFlags() &
RayPacket::ConstantOrigin;
if (RaysConstantOrigin)
{
- org_k = data->origin[axis][begin];
- org_ku = data->origin[ku][begin];
- org_kv = data->origin[kv][begin];
+ org_k = data->origin[axis][rays.begin()];
+ org_ku = data->origin[ku][rays.begin()];
+ org_kv = data->origin[kv][rays.begin()];
f0 = n_d - (org_k + n_u * org_ku + n_v * org_kv);
}
- for (int i = begin; i < end; i++ )
+ for (int i = rays.begin(); i < rays.end(); i++ )
{
const float nd0 = n_u * dir_ku[i] + n_v * dir_kv[i] + dir_k[i];
const float nd = 1.f/nd0;
if (!RaysConstantOrigin)
{
- org_k = data->origin[axis][i];
+ org_k = data->origin[axis][i];
org_ku = data->origin[ku][i];
org_kv = data->origin[kv][i];
@@ -96,9 +94,10 @@
for ( int ray = rays.begin(); ray < rays.end(); ray++ )
{
data->normal[axis][ray] = mult;
- data->normal[ku][ray] = mult * n_u;
- data->normal[kv][ray] = mult * n_v;
+ data->normal[ku][ray] = mult * n_u;
+ data->normal[kv][ray] = mult * n_v;
}
+ rays.setFlag(RayPacket::HaveUnitNormals);
}
Modified: trunk/scenes/perf.cc
==============================================================================
--- trunk/scenes/perf.cc (original)
+++ trunk/scenes/perf.cc Tue Mar 7 02:55:38 2006
@@ -65,25 +65,41 @@
extern "C"
Scene* make_scene(const ReadContext& context, const vector<string>& args)
{
- Group* world = new Group();
+ bool use_wald = false;
+ for ( int i = 0; i < args.size(); i++ )
+ {
+ if ( args[i] == "-Wald" )
+ {
+ cout << "Using Wald Triangles" << endl;
+ use_wald = true;
+ }
+ }
- Material* matte_yellow= new NDotL(Vector(1,1,1), Color(RGB(.78,.78,.1)));
- Material* matte_blue = new NDotL(Vector(1,1,1), Color(RGB(.1, .1, .78)));
+ Group* world = new Group();
- // Add a simple sphere to the scene
- world->add(new Sphere( matte_yellow, Vector(0, 0, 0), 1.0 ) );
+ Material* matte_yellow= new NDotL(Vector(1,1,1), Color(RGB(.78,.78,.1)));
+ Material* matte_blue = new NDotL(Vector(1,1,1), Color(RGB(.1, .1,
.78)));
- //world->add(new Triangle(matte_blue,
Vector(-1,-1,-1),Vector(-1,-1,1),Vector(1,-1,1)));
- //world->add(new Triangle(matte_blue,
Vector(1,-1,1),Vector(-1,-1,-1),Vector(1,-1,-1)));
-
- world->add(new WaldTriangle(matte_blue,
Vector(-1,-1,-1),Vector(-1,-1,1),Vector(1,-1,1)));
- world->add(new WaldTriangle(matte_blue,
Vector(1,-1,1),Vector(-1,-1,-1),Vector(1,-1,-1)));
- Scene* scene = new Scene();
- scene->setBackground(new
ConstantBackground(ColorDB::getNamedColor("SkyBlue3")));
- scene->setObject(world);
- LightSet* lights = new LightSet();
-
- lights->setAmbientLight(new ConstantAmbient(Color::white()));
- scene->setLights(lights);
- return scene;
+ // Add a simple sphere to the scene
+ world->add(new Sphere( matte_yellow, Vector(0, 0, 0), 1.0 ) );
+
+ if (use_wald)
+ {
+ world->add(new WaldTriangle(matte_blue,
Vector(-1,-1,-1),Vector(-1,-1,1),Vector(1,-1,1)));
+ world->add(new WaldTriangle(matte_blue,
Vector(1,-1,1),Vector(-1,-1,-1),Vector(1,-1,-1)));
+ }
+ else
+ {
+ world->add(new Triangle(matte_blue,
Vector(-1,-1,-1),Vector(-1,-1,1),Vector(1,-1,1)));
+ world->add(new Triangle(matte_blue,
Vector(1,-1,1),Vector(-1,-1,-1),Vector(1,-1,-1)));
+ }
+
+ Scene* scene = new Scene();
+ scene->setBackground(new
ConstantBackground(ColorDB::getNamedColor("SkyBlue3")));
+ scene->setObject(world);
+ LightSet* lights = new LightSet();
+
+ lights->setAmbientLight(new ConstantAmbient(Color::white()));
+ scene->setLights(lights);
+ return scene;
}
- [MANTA] r975 - in trunk: Model/Primitives scenes, boulos, 03/07/2006
Archive powered by MHonArc 2.6.16.