Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r691 - in branches/itanium2: Core/Geometry Model/Backgrounds Model/Textures StandAlone
- Date: Wed, 2 Nov 2005 16:58:18 -0700 (MST)
Author: bigler
Date: Wed Nov 2 16:58:18 2005
New Revision: 691
Modified:
branches/itanium2/Core/Geometry/BBox.h
branches/itanium2/Model/Backgrounds/TextureBackground.cc
branches/itanium2/Model/Textures/MarbleTexture.cc
branches/itanium2/Model/Textures/MarbleTexture.h
branches/itanium2/StandAlone/manta.cc
Log:
Core/Geometry/BBox.h
Turns out I wanted the multipliedBy function instead of multiplyBy
which returns void instead of Point.
Model/Backgrounds/TextureBackground.cc
Changed the computeTexCoords3 function to simply map the normal to
the texture coords. This looked much better for things like
MarbleTexture.
Model/Textures/MarbleTexture.cc
Model/Textures/MarbleTexture.h
Use Real and ColorComponent types instead of double. Marginal
improvement on performance. The Turbulence function is still all
done in double precision.
StandAlone/manta.cc
Different value for the scale used for the MarbleTexture background
to look better.
Modified: branches/itanium2/Core/Geometry/BBox.h
==============================================================================
--- branches/itanium2/Core/Geometry/BBox.h (original)
+++ branches/itanium2/Core/Geometry/BBox.h Wed Nov 2 16:58:18 2005
@@ -39,15 +39,11 @@
return bounds[1] - bounds[0];
}
Point center() const {
- // return SCIRun::Interpolate(bounds[0], bounds[1],
(Point::ScalarType)0.5);
-
// The code used to be writen as b[0]+(b[1]-b[0])*0.5. Using
// some algebra you can write this as (b[0]+b[1])*0.5. You save
// having to do the subtraction which introduces additional
// inaccuracy and computation.
- Point result(bounds[0]+Vector(bounds[1]));
- result.multiplyBy((Point::ScalarType)0.5);
- return result;
+ return
(bounds[0]+Vector(bounds[1])).multipliedBy((Point::ScalarType)0.5);
}
void extendByBox( const BBox &box ) {
Modified: branches/itanium2/Model/Backgrounds/TextureBackground.cc
==============================================================================
--- branches/itanium2/Model/Backgrounds/TextureBackground.cc (original)
+++ branches/itanium2/Model/Backgrounds/TextureBackground.cc Wed Nov 2
16:58:18 2005
@@ -66,19 +66,13 @@
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
-// Same code as computeTexCoords2
+// Just map the normal to the texture coordinate
void TextureBackground::computeTexCoords3(const RenderContext&,
RayPacket& rays) const
{
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- Vector n = e.ray.direction();
- Real angle = Clamp(n.z(), (Real)-1, (Real)1);
- Real theta = Acos(angle);
- Real phi = Atan2(n.x(), n.y());
- Real x = (phi+(Real)M_PI)*((Real)0.5*(Real)M_1_PI);
- Real y = theta*(Real)M_1_PI;
- e.texCoords = Point(x, y, 0);
+ e.texCoords = Point(e.ray.direction());
}
rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
Modified: branches/itanium2/Model/Textures/MarbleTexture.cc
==============================================================================
--- branches/itanium2/Model/Textures/MarbleTexture.cc (original)
+++ branches/itanium2/Model/Textures/MarbleTexture.cc Wed Nov 2 16:58:18
2005
@@ -4,6 +4,7 @@
#include <Core/Geometry/PointVector.h>
#include <Core/Math/Noise.h>
#include <Core/Math/MiscMath.h>
+#include <Core/Math/Trig.h>
namespace Manta {
@@ -11,12 +12,12 @@
MarbleTexture< ValueType >::MarbleTexture(
ValueType const &value1,
ValueType const &value2,
- double const scale,
- double const fscale,
- double const tscale,
+ Real const scale,
+ Real const fscale,
+ Real const tscale,
int const octaves,
- double const lacunarity,
- double const gain )
+ Real const lacunarity,
+ Real const gain )
: value1( value1 ),
value2( value2 ),
scale ( scale ),
@@ -43,7 +44,9 @@
for( int i = 0; i < rays.getSize(); i++ ) {
RayPacket::Element &e = rays.get( i );
Point T = e.texCoords.multipliedBy(scale * fscale);
- double value = 0.5 * cos( e.texCoords.x() * scale + tscale *
Turbulence( T, octaves, lacunarity, gain ) ) * 0.5;
+ ColorComponent value = (Real)0.25 *
+ Cos( e.texCoords.x() * scale + tscale *
+ (Real)Turbulence( T, octaves, lacunarity, gain ) );
results[ i ] = SCIRun::Interpolate( value1, value2, value );
}
}
Modified: branches/itanium2/Model/Textures/MarbleTexture.h
==============================================================================
--- branches/itanium2/Model/Textures/MarbleTexture.h (original)
+++ branches/itanium2/Model/Textures/MarbleTexture.h Wed Nov 2 16:58:18
2005
@@ -13,12 +13,12 @@
MarbleTexture(
ValueType const &value1,
ValueType const &value2,
- double const scale,
- double const fscale,
- double const tscale,
+ Real const scale,
+ Real const fscale,
+ Real const tscale,
int const octaves,
- double const lacunarity,
- double const gain );
+ Real const lacunarity,
+ Real const gain );
virtual ~MarbleTexture();
virtual void mapValues(
RenderContext const &context,
@@ -32,12 +32,12 @@
ValueType value1;
ValueType value2;
- double scale;
- double fscale;
- double tscale;
+ Real scale;
+ Real fscale;
+ Real tscale;
int octaves;
- double lacunarity;
- double gain;
+ Real lacunarity;
+ Real gain;
};
}
Modified: branches/itanium2/StandAlone/manta.cc
==============================================================================
--- branches/itanium2/StandAlone/manta.cc (original)
+++ branches/itanium2/StandAlone/manta.cc Wed Nov 2 16:58:18 2005
@@ -363,7 +363,7 @@
scene->setBackground(new TextureBackground
(new MarbleTexture<Color>(Color(RGB(0.1,0.2,0.5)),
Color(RGB(0.7,0.8,1.0)),
- 10.0, 1.0, 15.0,
+ 1.0, 1.0, 15.0,
6, 2.0, 0.6 ),
Vector(0,1,0)));
#elif 0
- [MANTA] r691 - in branches/itanium2: Core/Geometry Model/Backgrounds Model/Textures StandAlone, bigler, 11/02/2005
Archive powered by MHonArc 2.6.16.