Text archives Help
- From: boulos@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1499 - in trunk: Engine/PixelSamplers Interface Model/Lights Model/Primitives
- Date: Wed, 18 Jul 2007 17:40:11 -0600 (MDT)
Author: boulos
Date: Wed Jul 18 17:40:10 2007
New Revision: 1499
Modified:
trunk/Engine/PixelSamplers/JitterSampler.cc
trunk/Interface/Primitive.cc
trunk/Interface/Primitive.h
trunk/Interface/RandomNumberGenerator.cc
trunk/Interface/RandomNumberGenerator.h
trunk/Model/Lights/AreaLight.cc
trunk/Model/Primitives/Parallelogram.cc
trunk/Model/Primitives/Parallelogram.h
Log:
Engine/PixelSamplers/JitterSampler.cc
Interface/Primitive.cc
Interface/Primitive.h
Interface/RandomNumberGenerator.cc
Interface/RandomNumberGenerator.h
Model/Lights/AreaLight.cc
Model/Primitives/Parallelogram.cc
Model/Primitives/Parallelogram.h
Adding RayPacket to end of all sampling interfaces and removing
single getRandomPoint from Primitive.
Modified: trunk/Engine/PixelSamplers/JitterSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/JitterSampler.cc (original)
+++ trunk/Engine/PixelSamplers/JitterSampler.cc Wed Jul 18 17:40:10 2007
@@ -160,11 +160,11 @@
Packet<Real> r1;
Packet<Real> r2;
if (use_cheaprng) {
- rng.nextPacket(r1);
- rng.nextPacket(r2);
+ rng.nextPacket(r1, rays);
+ rng.nextPacket(r2, rays);
} else {
- random[thd_num].nextPacket(r1);
- random[thd_num].nextPacket(r2);
+ random[thd_num].nextPacket(r1, rays);
+ random[thd_num].nextPacket(r2, rays);
}
// We can compute at most RayPacket::MaxSize number of rays at time.
@@ -184,6 +184,8 @@
// average, and store the results in the fragment.
int fx = fragment.getX(frag_index);
int fy = fragment.getY(frag_index);
+ // Which sample does this ray packet start at?
+
for(int xs = 0; xs < nx; xs++) {
for(int ys = 0; ys < ny; ys++) {
Real x_sample = (xs + r1.get(sample_count)) * inx;
@@ -206,17 +208,18 @@
// the RayPacket again.
sample_count = 0;
+ // Make sure we start with a fresh slate
+ rays.resetHits();
+ rays.setAllFlags(flags);
+
// Grab more samples
if (use_cheaprng) {
- rng.nextPacket(r1);
- rng.nextPacket(r2);
+ rng.nextPacket(r1, rays);
+ rng.nextPacket(r2, rays);
} else {
- random[thd_num].nextPacket(r1);
- random[thd_num].nextPacket(r2);
+ random[thd_num].nextPacket(r1, rays);
+ random[thd_num].nextPacket(r2, rays);
}
- // Make sure we start with a fresh slate
- rays.resetHits();
- rays.setAllFlags(flags);
} // end packet shoot and reset test
}
} // end sample filling loops
Modified: trunk/Interface/Primitive.cc
==============================================================================
--- trunk/Interface/Primitive.cc (original)
+++ trunk/Interface/Primitive.cc Wed Jul 18 17:40:10 2007
@@ -5,34 +5,17 @@
using namespace Manta;
-Primitive::Primitive()
-{
+Primitive::Primitive() {
}
-Primitive::~Primitive()
-{
-}
-
-void Primitive::getRandomPoint(Vector& point,
- Vector& normal,
- Real& pdf,
- const RenderContext& context) const {
- throw SCIRun::InternalError("Unimplemented getRandomPoint for Primitive",
- __FILE__, __LINE__);
+Primitive::~Primitive() {
}
void Primitive::getRandomPoints(Packet<Vector>& points,
Packet<Vector>& normals,
Packet<Real>& pdfs,
- const RenderContext& context) const {
- for (int i = 0; i < Packet<Vector>::MaxSize; i++) {
- Vector point;
- Vector normal;
- Real pdf;
- getRandomPoint(point, normal, pdf, context);
-
- points.set(i, point);
- normals.set(i, normal);
- pdfs.set(i, pdf);
- }
+ const RenderContext& context,
+ RayPacket& rays) const {
+ throw SCIRun::InternalError("Unimplemented getRandomPoint for Primitive",
+ __FILE__, __LINE__);
}
Modified: trunk/Interface/Primitive.h
==============================================================================
--- trunk/Interface/Primitive.h (original)
+++ trunk/Interface/Primitive.h Wed Jul 18 17:40:10 2007
@@ -21,15 +21,11 @@
RayPacket& rays) const = 0;
virtual void setTexCoordMapper(const TexCoordMapper* new_tex) = 0;
- virtual void getRandomPoint(Vector& point,
- Vector& normal,
- Real& pdf,
- const RenderContext& context) const;
-
virtual void getRandomPoints(Packet<Vector>& points,
Packet<Vector>& normals,
Packet<Real>& pdfs,
- const RenderContext& context) const;
+ const RenderContext& context,
+ RayPacket& rays) const;
private:
Primitive(const Primitive&);
Primitive& operator=(const Primitive&);
Modified: trunk/Interface/RandomNumberGenerator.cc
==============================================================================
--- trunk/Interface/RandomNumberGenerator.cc (original)
+++ trunk/Interface/RandomNumberGenerator.cc Wed Jul 18 17:40:10 2007
@@ -11,10 +11,10 @@
return nextFloat();
}
- void RandomNumberGenerator::nextPacket(Packet<float>& results) {
+ void RandomNumberGenerator::nextPacket(Packet<float>& results, RayPacket&
rays) {
#ifdef MANTA_SSE
Packet<unsigned int> uints;
- nextIntPacket(uints);
+ nextIntPacket(uints, rays);
for (int i = 0; i < Packet<float>::MaxSize; i+= 4) {
#if 0
_mm_store_ps(&results.data[i],
@@ -50,7 +50,7 @@
return nextDouble();
}
- void RandomNumberGenerator::nextPacket(Packet<double>& results) {
+ void RandomNumberGenerator::nextPacket(Packet<double>& results, RayPacket&
rays) {
for (int i = 0; i < Packet<double>::MaxSize; i++) {
results.set(i, nextDouble());
}
Modified: trunk/Interface/RandomNumberGenerator.h
==============================================================================
--- trunk/Interface/RandomNumberGenerator.h (original)
+++ trunk/Interface/RandomNumberGenerator.h Wed Jul 18 17:40:10 2007
@@ -34,6 +34,7 @@
#include <MantaSSE.h>
#include <Interface/Packet.h>
+#include <Interface/RayPacket.h>
namespace Manta {
class RandomNumberGenerator {
@@ -45,7 +46,7 @@
// result = [0, 4294967295(UINT_MAX)]
virtual unsigned int nextInt() = 0;
- virtual void nextIntPacket(Packet<unsigned int>& results) {
+ virtual void nextIntPacket(Packet<unsigned int>& results, RayPacket&
rays) {
for (int i = 0; i < Packet<unsigned int>::MaxSize; i++) {
results.set(i, nextInt());
}
@@ -58,8 +59,8 @@
template<class T>
T next() { return 0; }
- virtual void nextPacket(Packet<float>& results);
- virtual void nextPacket(Packet<double>& results);
+ virtual void nextPacket(Packet<float>& results, RayPacket& rays);
+ virtual void nextPacket(Packet<double>& results, RayPacket& rays);
virtual double nextDouble() {
return ( (double)nextInt() * (1./4294967296.) );
Modified: trunk/Model/Lights/AreaLight.cc
==============================================================================
--- trunk/Model/Lights/AreaLight.cc (original)
+++ trunk/Model/Lights/AreaLight.cc Wed Jul 18 17:40:10 2007
@@ -21,7 +21,7 @@
Packet<Vector> positions;
Packet<Vector> normals;
Packet<Real> pdfs;
- primitive->getRandomPoints(positions, normals, pdfs, context);
+ primitive->getRandomPoints(positions, normals, pdfs, context, sourceRays);
// TODO(boulos): SSE version
#ifdef MANTA_SSE
Modified: trunk/Model/Primitives/Parallelogram.cc
==============================================================================
--- trunk/Model/Primitives/Parallelogram.cc (original)
+++ trunk/Model/Primitives/Parallelogram.cc Wed Jul 18 17:40:10 2007
@@ -545,24 +545,16 @@
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
-void Parallelogram::getRandomPoint(Vector& point,
- Vector& normal,
- Real& pdf,
- const RenderContext& context) const {
- pdf = inv_area;
- point = (anchor + context.rng->next<Real>() * v1_unscaled +
- context.rng->next<Real>() * v2_unscaled);
- normal = this->normal;
-}
-
void Parallelogram::getRandomPoints(Packet<Vector>& points,
Packet<Vector>& normals,
Packet<Real>& pdfs,
- const RenderContext& context) const {
+ const RenderContext& context,
+ RayPacket& rays) const {
+ // TODO(boulos): Change this code to only do work for active rays
Packet<Real> r1;
Packet<Real> r2;
- context.rng->nextPacket(r1);
- context.rng->nextPacket(r2);
+ context.rng->nextPacket(r1, rays);
+ context.rng->nextPacket(r2, rays);
#ifdef MANTA_SSE
for (int i = 0; i < Packet<Vector>::MaxSize; i+=4) {
Modified: trunk/Model/Primitives/Parallelogram.h
==============================================================================
--- trunk/Model/Primitives/Parallelogram.h (original)
+++ trunk/Model/Primitives/Parallelogram.h Wed Jul 18 17:40:10 2007
@@ -22,15 +22,11 @@
virtual void computeTexCoords3(const RenderContext& context,
RayPacket& rays) const;
- virtual void getRandomPoint(Vector& point,
- Vector& normal,
- Real& pdf,
- const RenderContext& context) const;
-
virtual void getRandomPoints(Packet<Vector>& points,
Packet<Vector>& normals,
Packet<Real>& pdfs,
- const RenderContext& context) const;
+ const RenderContext& context,
+ RayPacket& rays) const;
private:
Vector anchor;
Vector v1, v2;
- [MANTA] r1499 - in trunk: Engine/PixelSamplers Interface Model/Lights Model/Primitives, boulos, 07/18/2007
Archive powered by MHonArc 2.6.16.