Text archives Help
- From: "Thiago Ize" <
>
- To:
- Subject: [Manta] r2304 - in trunk: Engine/PixelSamplers Engine/Renderers Engine/Shadows Interface Model/AmbientLights Model/Instances Model/Materials Model/Primitives Model/Textures
- Date: Thu, 17 Jul 2008 12:02:37 -0600 (MDT)
Author: thiago
Date: Thu Jul 17 12:02:34 2008
New Revision: 2304
Modified:
trunk/Engine/PixelSamplers/JitterSampler.cc
trunk/Engine/Renderers/KajiyaPathtracer.cc
trunk/Engine/Renderers/NPREdges.cc
trunk/Engine/Shadows/HardShadows.cc
trunk/Engine/Shadows/NoShadows.cc
trunk/Interface/Primitive.cc
trunk/Interface/RayPacket.cc
trunk/Interface/RayPacket.h
trunk/Model/AmbientLights/ArcAmbient.cc
trunk/Model/Instances/Instance.cc
trunk/Model/Materials/AmbientOcclusion.cc
trunk/Model/Materials/Dielectric.cc
trunk/Model/Materials/Flat.cc
trunk/Model/Materials/Lambertian.cc
trunk/Model/Materials/MetalMaterial.cc
trunk/Model/Materials/NDotL.cc
trunk/Model/Materials/OrenNayar.cc
trunk/Model/Materials/Phong.cc
trunk/Model/Materials/ThinDielectric.cc
trunk/Model/Materials/Transparent.cc
trunk/Model/Primitives/Cone.cc
trunk/Model/Primitives/GridSpheres.cc
trunk/Model/Primitives/Torus.cc
trunk/Model/Textures/NormalTexture.cc
trunk/Model/Textures/NormalTexture.h
Log:
Valgrind was detecting uninitialized values in several places (often
while path tracing). This can cause or be indicative of weird hard to
track bugs. For instance, during path tracing, the interpolated
triangle normals were using the wrong barycentric coordinates. This
would result in the reflected rays being slightly off. It's a hard
effect to notice, but it is wrong.
In the process, instead of having a safecompute* and a normal compute*
function with lots of redundant code, I combined the two using a
template flag. Performance should be the same and the code is
cleaner. I also removed some of the actualCompute* functions which
might result in slower code (but it makes it cleaner). If we notice
any slowdowns at all, I'll divide the compute functions back into the
often called inlined part and the seldom called actualCompute part.
Model/Materials/Lambertian.cc:
-Fixed a bug where sse shading was iterating over the rays and not
shadowrays. This results in unintialized data being accesed as well
as slower code.
Model/Primitives/Torus.cc:
-Added an assert to require positive radius values.
Engine/PixelSamplers/JitterSampler.cc:
-Need to initialize rng. Otherwise you're using an uninitialized
variable.
Engine/Renderers/KajiyaPathtracer.cc:
-Need to swap scratchpads. It's possible other things, such as the
scratchpad<char> and other data members also need to be swapped.
Modified: trunk/Engine/PixelSamplers/JitterSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/JitterSampler.cc (original)
+++ trunk/Engine/PixelSamplers/JitterSampler.cc Thu Jul 17 12:02:34 2008
@@ -143,6 +143,8 @@
else
random[thd_num].seed(fragment.getX(b)*ci.xres+fragment.getY(b));
}
+ else if (use_cheaprng)
+ rng.seed(0); //need to initialize rng.
int depth = 0;
RayPacketData raydata;
Modified: trunk/Engine/Renderers/KajiyaPathtracer.cc
==============================================================================
--- trunk/Engine/Renderers/KajiyaPathtracer.cc (original)
+++ trunk/Engine/Renderers/KajiyaPathtracer.cc Thu Jul 17 12:02:34 2008
@@ -156,8 +156,7 @@
rays.resetHits();
context.scene->getObject()->intersect(context, rays);
rays.computeHitPositions();
- rays.safeComputeGeometricNormals(context);
- rays.computeFFGeometricNormals(context); // Must do this before writing
over the ray direction
+ rays.computeFFGeometricNormals<false>(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];
@@ -357,18 +356,24 @@
for(int k=0;k<3;k++)
swap(data->dPdv[k], i, j);
+ // Move importance
+ for(int k=0;k<3;k++)
+ swap(data->importance[k], i, j);
+
// Move sample_id, region_id
swap(data->sample_id, i, j);
swap(data->region_id, i, j);
+ //Move scratchpad
+ for (int k=0; k < RayPacketData::MaxScratchpad4; ++k)
+ swap(data->scratchpad4[k], i, j);
+ for (int k=0; k < RayPacketData::MaxScratchpad8; ++k)
+ swap(data->scratchpad8[k], i, j);
+
// Move result
for(int k=0;k<3;k++)
swap(result.colordata[k], i, j);
- // Move importance
- for(int k=0;k<3;k++)
- swap(data->importance[k], i, j);
-
// Move permute
swap(permute.data, i, j);
}
@@ -422,11 +427,22 @@
// Look at one-way move optimization
swap(data->time, i, newEnd);
+ // Move importance
+ // Look at one-way move optimization
+ for(int j=0;j<3;j++)
+ swap(data->importance[j], i, newEnd);
+
// Move sample_id, region_id
// Look at one-way move optimization
swap(data->sample_id, i, newEnd);
swap(data->region_id, i, newEnd);
+ //Move scratchpad
+ for (int k=0; k < RayPacketData::MaxScratchpad4; ++k)
+ swap(data->scratchpad4[k], i, newEnd);
+ for (int k=0; k < RayPacketData::MaxScratchpad8; ++k)
+ swap(data->scratchpad8[k], i, newEnd);
+
// Move result
for(int j=0;j<3;j++)
swap(result.colordata[j], i, newEnd);
@@ -436,11 +452,6 @@
for(int j=0;j<3;j++)
swap(reflectance.colordata[j], i, newEnd);
- // Move importance
- // Look at one-way move optimization
- for(int j=0;j<3;j++)
- swap(data->importance[j], i, newEnd);
-
// Move rr
// Look at one-way move optimization
swap(rr.data, i, newEnd);
@@ -538,21 +549,28 @@
for(int k=0;k<3;k++)
swap(data->dPdv[k], i, j);
+ // Move importance
+ for(int k=0;k<3;k++)
+ swap(data->importance[k], i, j);
+
// Move sample_id, region_id
swap(data->sample_id, i, j);
swap(data->region_id, i, j);
+ //Move scratchpad
+ for (int k=0; k < RayPacketData::MaxScratchpad4; ++k)
+ swap(data->scratchpad4[k], i, j);
+ for (int k=0; k < RayPacketData::MaxScratchpad8; ++k)
+ swap(data->scratchpad8[k], i, j);
+
// Move result
for(int k=0;k<3;k++)
swap(result.colordata[k], i, j);
- // Move importance
- for(int k=0;k<3;k++)
- swap(data->importance[k], i, j);
-
// Move permute
swap(permute.data, i, j);
i++;
+
// Find another hole
while(i <= j && data->hitMatl[i] == matl)
i++;
@@ -583,7 +601,7 @@
// that did not hit anything
RayPacketData* data = rays.data;
int newBegin = rays.begin();
- while(!data->hitMatl[newBegin] && newBegin < rays.end())
+ while(newBegin < rays.end() && !data->hitMatl[newBegin])
newBegin++;
for(int i=rays.end()-1;i>=newBegin;i--){
if(!data->hitMatl[i]){
@@ -627,17 +645,23 @@
for(int k=0;k<3;k++)
swap(data->dPdv[k], i, newBegin);
+ // Move importance
+ for(int k=0;k<3;k++)
+ swap(data->importance[k], i, newBegin);
+
// Move sample_id, region_id
swap(data->sample_id, i, newBegin);
swap(data->region_id, i, newBegin);
+ //Move scratchpad
+ for (int k=0; k < RayPacketData::MaxScratchpad4; ++k)
+ swap(data->scratchpad4[k], i, newBegin);
+ for (int k=0; k < RayPacketData::MaxScratchpad8; ++k)
+ swap(data->scratchpad8[k], i, newBegin);
+
// Move result
for(int k=0;k<3;k++)
swap(result.colordata[k], i, newBegin);
-
- // Move importance
- for(int k=0;k<3;k++)
- swap(data->importance[k], i, newBegin);
// Move permute
swap(permute.data, i, newBegin);
Modified: trunk/Engine/Renderers/NPREdges.cc
==============================================================================
--- trunk/Engine/Renderers/NPREdges.cc (original)
+++ trunk/Engine/Renderers/NPREdges.cc Thu Jul 17 12:02:34 2008
@@ -38,12 +38,12 @@
const string& arg = args[i];
if(arg == "-width"){
if(!getArg(i, args, lineWidth))
- throw IllegalArgument("NPREdges -width", i, args);
+ throw IllegalArgument("NPREdges -width", i, args);
}
else if(arg == "-normal-threshold"){
Real val;
if(!getArg(i, args, val))
- throw IllegalArgument("NPREdges -normal-threshold", i, args);
+ throw IllegalArgument("NPREdges -normal-threshold", i, args);
this->setNormalThreshold(val);
threshold_set = true;
@@ -120,14 +120,14 @@
// Shade the scene as normal (NPR lines will go as an overlay on
// top). Create a render context for default shading.
RenderContext subContext(context.rtrt_int,
- context.channelIndex, context.proc,
context.numProcs,
- context.frameState,
- context.loadBalancer, context.pixelSampler,
- raytracer, context.shadowAlgorithm,
- context.camera, context.scene,
- context.storage_allocator,
- context.rng,
- context.sample_generator);
+ context.channelIndex, context.proc,
context.numProcs,
+ context.frameState,
+ context.loadBalancer, context.pixelSampler,
+ raytracer, context.shadowAlgorithm,
+ context.camera, context.scene,
+ context.storage_allocator,
+ context.rng,
+ context.sample_generator);
raytracer->traceRays(subContext, rays);
if(noshade)
@@ -206,10 +206,10 @@
RayPacket normLeft(stencil[last_ring + 4*N], i, j);
RayPacket normDown(stencil[last_ring + 6*N], i, j);
- normRight.computeFFNormals(context);
- normLeft.computeFFNormals(context);
- normUp.computeFFNormals(context);
- normDown.computeFFNormals(context);
+ normRight.computeFFNormals<true>(context);
+ normLeft.computeFFNormals<true>(context);
+ normUp.computeFFNormals<true>(context);
+ normDown.computeFFNormals<true>(context);
for(int k=i; k<j; k++){
bool checkSelfOccluding = true;
@@ -279,13 +279,13 @@
const Primitive *hit = sample.getHitPrimitive(i);
for(int j=0; j<stencil_size; j++)
if(!(stencil[j].wasHit(i) && (stencil[j].getHitPrimitive(i) == hit)))
- return Intersection;
+ return Intersection;
}
else{
// The sample ray struck the background; check if this is an
intersection sample.
for(int j=0; j<stencil_size; j++)
if(stencil[j].wasHit(i))
- return Intersection;
+ return Intersection;
// If all the stencil rays strike the background, this is a background
sample.
return Background;
Modified: trunk/Engine/Shadows/HardShadows.cc
==============================================================================
--- trunk/Engine/Shadows/HardShadows.cc (original)
+++ trunk/Engine/Shadows/HardShadows.cc Thu Jul 17 12:02:34 2008
@@ -59,7 +59,7 @@
// Compute the hit positions.
sourceRays.computeHitPositions();
- sourceRays.computeFFGeometricNormals( context );
+ sourceRays.computeFFGeometricNormals<true>( context );
int j;
if(stateBuffer.state == StateBuffer::Finished){
Modified: trunk/Engine/Shadows/NoShadows.cc
==============================================================================
--- trunk/Engine/Shadows/NoShadows.cc (original)
+++ trunk/Engine/Shadows/NoShadows.cc Thu Jul 17 12:02:34 2008
@@ -30,7 +30,7 @@
// Compute the hit positions.
sourceRays.computeHitPositions();
- sourceRays.computeFFNormals( context );
+ sourceRays.computeFFNormals<true>( context );
int j;
if(stateBuffer.state == StateBuffer::Finished){
Modified: trunk/Interface/Primitive.cc
==============================================================================
--- trunk/Interface/Primitive.cc (original)
+++ trunk/Interface/Primitive.cc Thu Jul 17 12:02:34 2008
@@ -23,7 +23,7 @@
void Primitive::computeGeometricNormal(const RenderContext& context,
RayPacket& rays) const {
- rays.computeNormals(context);
+ rays.computeNormals<true>(context);
for(int i = 0; i < 3; ++i) {
memcpy(&rays.data->geometricNormal[i][rays.begin()],
@@ -38,7 +38,7 @@
void Primitive::computeSurfaceDerivatives(const RenderContext& context,
RayPacket& rays) const {
- rays.computeNormals(context);
+ rays.computeNormals<true>(context);
for (int i = rays.begin(); i < rays.end(); i++) {
Vector U = rays.getNormal(i).findPerpendicular();
Vector V = Cross(rays.getNormal(i), U);
Modified: trunk/Interface/RayPacket.cc
==============================================================================
--- trunk/Interface/RayPacket.cc (original)
+++ trunk/Interface/RayPacket.cc Thu Jul 17 12:02:34 2008
@@ -147,55 +147,37 @@
flags |= HaveHitPositions;
}
-void RayPacket::actualComputeNormals(const RenderContext& context)
-{
- // Compute normals
- for(int i=rayBegin;i<rayEnd;){
- const Primitive* prim = data->hitPrim[i];
- int tend = i+1;
- while(tend < rayEnd && data->hitPrim[tend] == prim)
- tend++;
- RayPacket subPacket(*this, i, tend);
- prim->computeNormal(context, subPacket);
- // BTW, == has higher precedence than &, so mind the ()'s.
- if ((subPacket.flags & HaveUnitNormals) == 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->normal[j][s] * data->normal[j][s];
- Real scale = 1/Sqrt(sum);
- for(int j=0;j<3;++j)
- data->normal[j][s] *= scale;
- }
- }
- i=tend;
- }
- flags |= HaveNormals | HaveUnitNormals;
-}
+template void RayPacket::computeNormals<true>(const RenderContext& context);
+template void RayPacket::computeNormals<false>(const RenderContext& context);
-/*
- * Compute normals, but watch for the hit information (currently flagged by
matl)
- * This can be called on a packet where some of the rays may have hit the
background
- */
-void RayPacket::safeComputeNormals(const RenderContext& context)
+template<bool allHit>
+void RayPacket::computeNormals(const RenderContext& context)
{
if(flags & HaveNormals)
return;
+
// Compute normals
for(int i=rayBegin;i<rayEnd;){
- while(!data->hitMatl[i]){
- i++;
- if(i >= rayEnd) {
- flags |= HaveNormals | HaveUnitNormals;
- return;
+ if (!allHit) {
+ /*
+ * Compute normals, but watch for the hit information (currently
+ * flagged by matl) This can be called on a packet where some of
+ * the rays may have hit the background
+ */
+ while(!data->hitMatl[i]){
+ i++;
+ if(i >= rayEnd) {
+ flags |= HaveNormals | HaveUnitNormals;
+ return;
+ }
}
}
-
+
const Primitive* prim = data->hitPrim[i];
int tend = i+1;
- while(tend < rayEnd && data->hitPrim[tend] == prim)
+ while(tend < rayEnd && (allHit || data->hitMatl[tend]) &&
+ data->hitPrim[tend] == prim)
tend++;
RayPacket subPacket(*this, i, tend);
prim->computeNormal(context, subPacket);
@@ -213,57 +195,34 @@
}
i=tend;
}
-
flags |= HaveNormals | HaveUnitNormals;
}
-void RayPacket::safeComputeGeometricNormals(const RenderContext& context)
+template void RayPacket::computeFFNormals<true>(const RenderContext&
context);
+template void RayPacket::computeFFNormals<false>(const RenderContext&
context);
+
+template<bool allHit>
+void RayPacket::computeFFNormals(const RenderContext& context)
{
- if(flags & HaveGeometricNormals)
+ if(flags & HaveFFNormals)
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
- computeNormals(context);
+ computeNormals<allHit>(context);
for(int i = rayBegin; i < rayEnd; ++i) {
+ if (!allHit) {
+ while(!data->hitMatl[i]) {
+ i++;
+ if(i >= rayEnd) {
+ flags |= HaveFFNormals;
+ return;
+ }
+ }
+ }
// Compute the dot product
Vector normal(getNormal(i));
- if (Dot(normal, getDirection(i)) <= 0) {
+ if (Dot(normal, getDirection(i)) <= 0) {
setFFNormal(i, normal);
} else {
setFFNormal(i, -normal);
@@ -273,12 +232,30 @@
flags |= HaveFFNormals;
}
-void RayPacket::actualComputeGeometricNormals(const RenderContext& context)
+//do some explicit instantiations so the linker is happy
+template void RayPacket::computeGeometricNormals<true>(const RenderContext&
context);
+template void RayPacket::computeGeometricNormals<false>(const RenderContext&
context);
+
+template<bool allHit>
+void RayPacket::computeGeometricNormals(const RenderContext& context)
{
- for(int i = rayBegin; i < rayEnd;) {
+ if(flags & HaveGeometricNormals)
+ return;
+ // Compute geometric normals
+ for(int i=rayBegin;i<rayEnd;) {
+ if (!allHit) {
+ 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)
+ while(tend < rayEnd && (allHit || data->hitMatl[tend]) &&
+ data->hitPrim[tend] == prim)
tend++;
RayPacket subPacket(*this, i, tend);
prim->computeGeometricNormal(context, subPacket);
@@ -298,12 +275,28 @@
flags |= HaveGeometricNormals | HaveUnitGeometricNormals;
}
-void RayPacket::actualComputeFFGeometricNormals(const RenderContext& context)
+template void RayPacket::computeFFGeometricNormals<true>(const
RenderContext& context);
+template void RayPacket::computeFFGeometricNormals<false>(const
RenderContext& context);
+
+template<bool allHit>
+void RayPacket::computeFFGeometricNormals(const RenderContext& context)
{
+ if(flags & HaveFFGeometricNormals)
+ return;
+
// We need to have normals
- computeGeometricNormals(context);
+ computeGeometricNormals<allHit>(context);
- for(int i = rayBegin; i < rayEnd; ++i) {
+ for(int i=rayBegin; i<rayEnd; ++i) {
+ if (!allHit) {
+ while(!data->hitMatl[i]) {
+ i++;
+ if(i >= rayEnd) {
+ flags |= HaveFFGeometricNormals;
+ return;
+ }
+ }
+ }
// Compute the dot product
Vector normal(getGeometricNormal(i));
if (Dot(normal, getDirection(i)) <= 0) {
Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Thu Jul 17 12:02:34 2008
@@ -818,38 +818,20 @@
Vector getSurfaceDerivativeV(int which) const {
return Vector(data->dPdv[0][which], data->dPdv[1][which],
data->dPdv[2][which]);
}
- void computeNormals(const RenderContext& context)
- {
- if(flags & HaveNormals)
- return;
- actualComputeNormals(context);
- }
+ template<bool allHit>
+ void computeNormals(const RenderContext& context);
+
// Compute the forward facing normals. These are normals that all
// point towards the ray origin.
- void computeFFNormals(const RenderContext& context)
- {
- if(flags & HaveFFNormals)
- return;
+ template<bool allHit>
+ void computeFFNormals(const RenderContext& context);
- actualComputeFFNormals(context);
- }
+ template<bool allHit>
+ void computeGeometricNormals(const RenderContext& context);
- void computeGeometricNormals(const RenderContext& context)
- {
- if(flags & HaveGeometricNormals)
- return;
-
- actualComputeGeometricNormals(context);
- }
-
- void computeFFGeometricNormals(const RenderContext& context)
- {
- if(flags & HaveFFGeometricNormals)
- return;
-
- actualComputeFFGeometricNormals(context);
- }
+ template<bool allHit>
+ void computeFFGeometricNormals(const RenderContext& context);
// Compute the surface derivatives
void computeSurfaceDerivatives(const RenderContext& context) {
@@ -904,18 +886,11 @@
}
}
- void safeComputeNormals(const RenderContext& context);
- void safeComputeGeometricNormals(const RenderContext& context);
private:
void actualNormalizeDirections();
void actualComputeInverseDirections();
void actualComputeHitPositions();
- void actualComputeNormals(const RenderContext& context);
- void actualComputeFFNormals(const RenderContext& context);
- void actualComputeGeometricNormals(const RenderContext& context);
- void actualComputeFFGeometricNormals(const RenderContext& context);
void actualComputeSurfaceDerivatives(const RenderContext& context);
-
void actualComputeTextureCoordinates2(const RenderContext& context);
void actualComputeTextureCoordinates3(const RenderContext& context);
Modified: trunk/Model/AmbientLights/ArcAmbient.cc
==============================================================================
--- trunk/Model/AmbientLights/ArcAmbient.cc (original)
+++ trunk/Model/AmbientLights/ArcAmbient.cc Thu Jul 17 12:02:34 2008
@@ -15,7 +15,7 @@
}
ArcAmbient::ArcAmbient(const Color& cup, const Color& cdown,
- const Vector& up)
+ const Vector& up)
: cup(cup), cdown(cdown), up(up)
{
}
@@ -32,7 +32,7 @@
RayPacket& rays,
ColorArray ambient) const
{
- rays.computeNormals(context);
+ rays.computeNormals<true>(context);
for(int i=rays.begin();i<rays.end();i++){
Real cosine = Dot(rays.getNormal(i), up);
Real sine = 1-cosine*cosine;
Modified: trunk/Model/Instances/Instance.cc
==============================================================================
--- trunk/Model/Instances/Instance.cc (original)
+++ trunk/Model/Instances/Instance.cc Thu Jul 17 12:02:34 2008
@@ -365,8 +365,8 @@
end++;
// Compute a group of normals and texcoords
RayPacket sub_packet(instance_rays, i, end);
- sub_packet.computeNormals(context);
- sub_packet.computeGeometricNormals(context);
+ sub_packet.computeNormals<true>(context);
+ sub_packet.computeGeometricNormals<true>(context);
// NOTE(boulos): Once the texcoords are separated, there will be
// another call to texcoords 3 here
sub_packet.computeTextureCoordinates2(context);
Modified: trunk/Model/Materials/AmbientOcclusion.cc
==============================================================================
--- trunk/Model/Materials/AmbientOcclusion.cc (original)
+++ trunk/Model/Materials/AmbientOcclusion.cc Thu Jul 17 12:02:34 2008
@@ -60,7 +60,7 @@
RayPacket& rays) const
{
// Compute normals
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
rays.computeHitPositions();
// We are going to first compute the ambient values.
Modified: trunk/Model/Materials/Dielectric.cc
==============================================================================
--- trunk/Model/Materials/Dielectric.cc (original)
+++ trunk/Model/Materials/Dielectric.cc Thu Jul 17 12:02:34 2008
@@ -71,7 +71,7 @@
rays.computeHitPositions();
rays.normalizeDirections();
- rays.computeNormals(context);
+ rays.computeNormals<true>(context);
Packet<Real> n_values;
Packet<Real> nt_values;
Modified: trunk/Model/Materials/Flat.cc
==============================================================================
--- trunk/Model/Materials/Flat.cc (original)
+++ trunk/Model/Materials/Flat.cc Thu Jul 17 12:02:34 2008
@@ -58,7 +58,7 @@
void Flat::shade(const RenderContext& context, RayPacket& rays) const
{
rays.normalizeDirections();
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
// Compute colors
Packet<Color> colors;
colortex->mapValues(colors, context, rays);
Modified: trunk/Model/Materials/Lambertian.cc
==============================================================================
--- trunk/Model/Materials/Lambertian.cc (original)
+++ trunk/Model/Materials/Lambertian.cc Thu Jul 17 12:02:34 2008
@@ -78,7 +78,7 @@
colortex->mapValues(diffuse, context, rays);
// Compute normals
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
// Compute ambient contributions for all rays
MANTA_ALIGN(16) ColorArray totalLight;
@@ -99,10 +99,15 @@
shadowRays.normalizeDirections();
#ifdef MANTA_SSE
- int b = (rays.rayBegin + 3) & (~3);
- int e = rays.rayEnd & (~3);
+ //we iterate over the shadowRays instead of the rays for both
+ //performance reasons (the shadowRays iteration bounds are a
+ //subset of the rays bounds), and for correctness reasons
+ //(shadowRays might not be defined for certain rays since they are
+ //a subset).
+ int b = (shadowRays.rayBegin + 3) & (~3);
+ int e = shadowRays.rayEnd & (~3);
if(b >= e){
- for(int i = rays.begin(); i < rays.end(); i++){
+ 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);
@@ -114,7 +119,7 @@
}
}
} else {
- int i = rays.rayBegin;
+ int i = shadowRays.rayBegin;
for(;i<b;i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct lighting contributions.
@@ -168,7 +173,7 @@
}
}
// Pick up the trailing bits
- for(;i<rays.rayEnd;i++){
+ for(;i<shadowRays.rayEnd;i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct lighting contributions.
Vector normal = rays.getFFNormal(i);
@@ -249,7 +254,7 @@
context.sample_generator->nextSeeds(context, r1, rays);
Packet<Real> r2;
context.sample_generator->nextSeeds(context, r2, rays);
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
#ifdef MANTA_SSE
int b = (rays.rayBegin + 3) & (~3);
Modified: trunk/Model/Materials/MetalMaterial.cc
==============================================================================
--- trunk/Model/Materials/MetalMaterial.cc (original)
+++ trunk/Model/Materials/MetalMaterial.cc Thu Jul 17 12:02:34 2008
@@ -42,7 +42,7 @@
// Compute only if we haven't hit the max ray depth.
if(rays.getDepth() < context.scene->getRenderParameters().maxDepth) {
rays.normalizeDirections();
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
Packet<Color> specular;
specular_reflectance->mapValues(specular, context, rays);
Modified: trunk/Model/Materials/NDotL.cc
==============================================================================
--- trunk/Model/Materials/NDotL.cc (original)
+++ trunk/Model/Materials/NDotL.cc Thu Jul 17 12:02:34 2008
@@ -59,7 +59,7 @@
void NDotL::shade(const RenderContext& context, RayPacket& rays) const
{
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
// Compute colors
Packet<Color> colors;
colortex->mapValues(colors, context, rays);
Modified: trunk/Model/Materials/OrenNayar.cc
==============================================================================
--- trunk/Model/Materials/OrenNayar.cc (original)
+++ trunk/Model/Materials/OrenNayar.cc Thu Jul 17 12:02:34 2008
@@ -77,7 +77,7 @@
// Compute normals
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
// Compute ambient contributions for all rays
MANTA_ALIGN(16) ColorArray totalLight;
Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc (original)
+++ trunk/Model/Materials/Phong.cc Thu Jul 17 12:02:34 2008
@@ -147,7 +147,7 @@
speculartex->mapValues(specular, context, rays);
// Compute normals
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
// Compute ambient contributions for all rays
MANTA_ALIGN(16) ColorArray ambientAndDiffuseLight;
Modified: trunk/Model/Materials/ThinDielectric.cc
==============================================================================
--- trunk/Model/Materials/ThinDielectric.cc (original)
+++ trunk/Model/Materials/ThinDielectric.cc Thu Jul 17 12:02:34 2008
@@ -88,7 +88,7 @@
rays.computeHitPositions();
rays.normalizeDirections();
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
Packet<Real> eta_values;
Packet<Color> sigma_a_values;
Modified: trunk/Model/Materials/Transparent.cc
==============================================================================
--- trunk/Model/Materials/Transparent.cc (original)
+++ trunk/Model/Materials/Transparent.cc Thu Jul 17 12:02:34 2008
@@ -69,7 +69,7 @@
// Determine lambertian contribution.
// Compute normals
- rays.computeFFNormals(context);
+ rays.computeFFNormals<true>(context);
rays.computeHitPositions();
// Compute colors
Modified: trunk/Model/Primitives/Cone.cc
==============================================================================
--- trunk/Model/Primitives/Cone.cc (original)
+++ trunk/Model/Primitives/Cone.cc Thu Jul 17 12:02:34 2008
@@ -37,7 +37,6 @@
r = 0.0f;
for (size_t i=0; i < keyframes.size(); ++i) {
- Interpolable::keyframe_t kt = keyframes[i];
Cone *cone = dynamic_cast<Cone*>(keyframes[i].keyframe);
if (cone == NULL)
return notInterpolable;
Modified: trunk/Model/Primitives/GridSpheres.cc
==============================================================================
--- trunk/Model/Primitives/GridSpheres.cc (original)
+++ trunk/Model/Primitives/GridSpheres.cc Thu Jul 17 12:02:34 2008
@@ -561,7 +561,7 @@
ColorArray& totalLight) const
{
// Compute normals
- rays.computeNormals(context);
+ rays.computeNormals<true>(context);
// Compute colors
Packet<Color> diffuse;
@@ -613,7 +613,7 @@
RayPacket& rays) const
{
rays.computeHitPositions();
- rays.computeNormals(context);
+ rays.computeNormals<true>(context);
for(int i=rays.begin();i<rays.end();i++){
Vector n=rays.getNormal(i);
Real angle=Clamp(n.z(), (Real)-1, (Real)1);
@@ -633,7 +633,7 @@
RayPacket& rays) const
{
rays.computeHitPositions();
- rays.computeNormals(context);
+ rays.computeNormals<true>(context);
for(int i=rays.begin();i<rays.end();i++){
Vector n=rays.getNormal(i);
Real angle=Clamp(n.z(), (Real)-1, (Real)1);
Modified: trunk/Model/Primitives/Torus.cc
==============================================================================
--- trunk/Model/Primitives/Torus.cc (original)
+++ trunk/Model/Primitives/Torus.cc Thu Jul 17 12:02:34 2008
@@ -2,7 +2,7 @@
#include <Interface/RayPacket.h>
#include <Core/Geometry/BBox.h>
#include <Core/Math/Expon.h>
-
+#include <assert.h>
using namespace Manta;
using namespace std;
@@ -134,6 +134,7 @@
Torus::Torus(Material* mat, double minor_radius, double major_radius)
: PrimitiveCommon(mat, this), minor_radius(minor_radius),
major_radius(major_radius)
{
+ assert(minor_radius >= 0 && major_radius >= 0);
}
Torus* Torus::clone(CloneDepth depth, Clonable* incoming)
@@ -157,7 +158,6 @@
major_radius = 0.0f;
for (size_t i=0; i < keyframes.size(); ++i) {
- Interpolable::keyframe_t kt = keyframes[i];
Torus *torus = dynamic_cast<Torus*>(keyframes[i].keyframe);
if (torus == NULL)
return notInterpolable;
@@ -169,8 +169,12 @@
void Torus::computeBounds(const PreprocessContext&, BBox& bbox) const
{
- bbox.extendByBox(BBox( Vector( -major_radius - minor_radius, -major_radius
- minor_radius, -minor_radius ),
- Vector( major_radius + minor_radius, major_radius +
minor_radius, minor_radius ) ));
+ bbox.extendByBox(BBox( Vector( -major_radius - minor_radius,
+ -major_radius - minor_radius,
+ -minor_radius ),
+ Vector( major_radius + minor_radius,
+ major_radius + minor_radius,
+ minor_radius ) ));
}
void Torus::intersect(const RenderContext&, RayPacket& rays) const
Modified: trunk/Model/Textures/NormalTexture.cc
==============================================================================
--- trunk/Model/Textures/NormalTexture.cc (original)
+++ trunk/Model/Textures/NormalTexture.cc Thu Jul 17 12:02:34 2008
@@ -46,10 +46,10 @@
const RenderContext& context,
RayPacket& rays) const
{
-
+
// Compute the normal for each ray.
- rays.computeNormals( context );
-
+ rays.computeNormals<true>( context );
+
// Iterate over the packet and set the colors.
for (int i=rays.begin();i<rays.end();++i) {
@@ -61,7 +61,7 @@
results.set(i, Color( RGB( (ColorComponent)normal[0],
(ColorComponent)normal[1],
(ColorComponent)normal[2] )));
- }
+ }
}
///////////////////////////////////////////////////////////////////////////////
@@ -74,11 +74,11 @@
const RenderContext&,
RayPacket& rays) const
{
-
+
// Compute the directions for each ray.
rays.computeInverseDirections();
rays.computeSigns();
-
+
// Iterate over the packet and set the colors.
for (int i=rays.begin();i<rays.end();++i) {
@@ -94,7 +94,7 @@
(scale*sign[1])*0.5+0.5,
(scale*sign[2])*0.5+0.5 )));
-
+
}
}
Modified: trunk/Model/Textures/NormalTexture.h
==============================================================================
--- trunk/Model/Textures/NormalTexture.h (original)
+++ trunk/Model/Textures/NormalTexture.h Thu Jul 17 12:02:34 2008
@@ -103,7 +103,7 @@
{
// Compute the normal for each ray.
- rays.computeNormals( context );
+ rays.computeNormals<true>( context );
// Lookup dependent texture values.
Packet<ValueType> texture_values;
- [Manta] r2304 - in trunk: Engine/PixelSamplers Engine/Renderers Engine/Shadows Interface Model/AmbientLights Model/Instances Model/Materials Model/Primitives Model/Textures, Thiago Ize, 07/17/2008
Archive powered by MHonArc 2.6.16.