Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1219 - in trunk: Core/Color Engine/Factory Engine/Shadows Interface Model/Materials
- Date: Thu, 12 Oct 2006 17:23:53 -0600 (MDT)
Author: bigler
Date: Thu Oct 12 17:23:52 2006
New Revision: 1219
Removed:
trunk/Engine/Shadows/BeamShadows.cc
trunk/Engine/Shadows/BeamShadows.h
Modified:
trunk/Core/Color/ColorSpace_fancy.h
trunk/Engine/Factory/RegisterKnownComponents.cc
trunk/Engine/Shadows/CMakeLists.txt
trunk/Engine/Shadows/HardShadows.cc
trunk/Engine/Shadows/NoShadows.cc
trunk/Interface/RayPacket.cc
trunk/Interface/RayPacket.h
trunk/Model/Materials/AmbientOcclusion.cc
trunk/Model/Materials/Lambertian.cc
trunk/Model/Materials/MetalMaterial.cc
trunk/Model/Materials/NDotL.cc
trunk/Model/Materials/NDotL.h
trunk/Model/Materials/Phong.cc
trunk/Model/Materials/Transparent.cc
trunk/Model/Materials/Transparent.h
Log:
Core/Color/ColorSpace_fancy.h
Forgot std:: on ostringstream.
Engine/Factory/RegisterKnownComponents.cc
Engine/Shadows/BeamShadows.cc
Engine/Shadows/BeamShadows.h
Engine/Shadows/CMakeLists.txt
Removed unmaintained experimental BeamShadow code.
Interface/RayPacket.cc
Interface/RayPacket.h
Added forward facing normals in addition to the surface normals.
Engine/Shadows/HardShadows.cc
Engine/Shadows/NoShadows.cc
Model/Materials/AmbientOcclusion.cc
Model/Materials/Lambertian.cc
Model/Materials/MetalMaterial.cc
Model/Materials/NDotL.cc
Model/Materials/Phong.cc
Model/Materials/Transparent.cc
Model/Materials/Transparent.h - also added new constructor
Use forward facing normals instead of surface normals for lighting:
rays.computeNormals() => rays.computeFFNormals()
rays.getNormal(which) => rays.getFFNormal()
rays.data->normal => rays.data->ffnormal
Model/Materials/NDotL.h
Don't store a pointer to an object (direction) that will go out of
scope.
Modified: trunk/Core/Color/ColorSpace_fancy.h
==============================================================================
--- trunk/Core/Color/ColorSpace_fancy.h (original)
+++ trunk/Core/Color/ColorSpace_fancy.h Thu Oct 12 17:23:52 2006
@@ -9,7 +9,7 @@
template<typename Traits>
std::string ColorSpace<Traits>::toString() const {
- ostringstream out;
+ std::ostringstream out;
out << "ColorSpace("<<NumComponents<<")(";
for(int i=0;i<NumComponents-1;i++)
out << data[i] << ", ";
Modified: trunk/Engine/Factory/RegisterKnownComponents.cc
==============================================================================
--- trunk/Engine/Factory/RegisterKnownComponents.cc (original)
+++ trunk/Engine/Factory/RegisterKnownComponents.cc Thu Oct 12 17:23:52
2006
@@ -22,7 +22,6 @@
#include <Engine/Renderers/Raydumper.h>
#include <Engine/Renderers/RayGen.h>
#include <Engine/Renderers/Raytracer.h>
-#include <Engine/Shadows/BeamShadows.h>
#include <Engine/Shadows/HardShadows.h>
#include <Engine/Shadows/NoShadows.h>
#include <Image/Pixel.h>
@@ -96,7 +95,6 @@
// Register shadow algorithms
engine->registerComponent("noshadows", &NoShadows::create);
engine->registerComponent("hard", &HardShadows::create);
- engine->registerComponent("beam", &BeamShadows::create);
// Idle modes
engine->registerComponent("zoom", &ZoomIdleMode::create);
Modified: trunk/Engine/Shadows/CMakeLists.txt
==============================================================================
--- trunk/Engine/Shadows/CMakeLists.txt (original)
+++ trunk/Engine/Shadows/CMakeLists.txt Thu Oct 12 17:23:52 2006
@@ -1,9 +1,7 @@
SET (Manta_Shadows_SRCS
- Shadows/NoShadows.h
- Shadows/NoShadows.cc
Shadows/HardShadows.h
Shadows/HardShadows.cc
- Shadows/BeamShadows.h
- Shadows/BeamShadows.cc
+ Shadows/NoShadows.h
+ Shadows/NoShadows.cc
)
Modified: trunk/Engine/Shadows/HardShadows.cc
==============================================================================
--- trunk/Engine/Shadows/HardShadows.cc (original)
+++ trunk/Engine/Shadows/HardShadows.cc Thu Oct 12 17:23:52 2006
@@ -39,7 +39,7 @@
// Compute the hit positions.
sourceRays.computeHitPositions();
- sourceRays.computeNormals( context );
+ sourceRays.computeFFNormals( context );
int j;
if(firstTime){
@@ -59,7 +59,7 @@
if(b == e){
for(int i = sourceRays.begin(); i < sourceRays.end(); i++){
Vector dir = shadowRays.getDirection(i);
- if(Dot(dir, sourceRays.getNormal(i)) > 0) {
+ if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
// If so normalize and compute length.
Real length = dir.normalize();
@@ -75,7 +75,7 @@
int i = shadowRays.rayBegin;
for(;i<b;i++){
Vector dir = shadowRays.getDirection(i);
- if(Dot(dir, sourceRays.getNormal(i)) > 0) {
+ if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
// If so normalize and compute length.
Real length = dir.normalize();
@@ -91,9 +91,9 @@
RayPacketData* sourceData = sourceRays.data;
RayPacketData* shadowData = shadowRays.data;
for(;i<e;i+=4){
- __m128 normalx = _mm_load_ps(&sourceData->normal[0][i]);
- __m128 normaly = _mm_load_ps(&sourceData->normal[1][i]);
- __m128 normalz = _mm_load_ps(&sourceData->normal[2][i]);
+ __m128 normalx = _mm_load_ps(&sourceData->ffnormal[0][i]);
+ __m128 normaly = _mm_load_ps(&sourceData->ffnormal[1][i]);
+ __m128 normalz = _mm_load_ps(&sourceData->ffnormal[2][i]);
__m128 dx = _mm_load_ps(&shadowData->direction[0][i]);
__m128 dy = _mm_load_ps(&shadowData->direction[1][i]);
__m128 dz = _mm_load_ps(&shadowData->direction[2][i]);
@@ -136,7 +136,7 @@
}
for(;i<sourceRays.rayEnd;i++){
Vector dir = shadowRays.getDirection(i);
- if(Dot(dir, sourceRays.getNormal(i)) > 0) {
+ if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
// If so normalize and compute length.
Real length = dir.normalize();
@@ -150,11 +150,11 @@
}
}
}
-#else
+#else // ifdef MANTA_SSE
for(int i = sourceRays.begin(); i < sourceRays.end(); i++){
// Check to see if the light is on the front face.
Vector dir = shadowRays.getDirection(i);
- if(Dot(dir, sourceRays.getNormal(i)) > 0) {
+ if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
// If so normalize and compute length.
Real length = dir.normalize();
@@ -167,7 +167,7 @@
shadowRays.maskRay(i);
}
}
-#endif
+#endif // ifdef MANTA_SSE
j++;
} while(last == -1 && j < nlights);
Modified: trunk/Engine/Shadows/NoShadows.cc
==============================================================================
--- trunk/Engine/Shadows/NoShadows.cc (original)
+++ trunk/Engine/Shadows/NoShadows.cc Thu Oct 12 17:23:52 2006
@@ -27,7 +27,7 @@
// Compute the hit positions.
sourceRays.computeHitPositions();
- sourceRays.computeNormals( context );
+ sourceRays.computeFFNormals( context );
int j;
if(firstTime){
@@ -43,7 +43,7 @@
for(int i = sourceRays.begin(); i < sourceRays.end(); i++){
// Check to see if the light is on the front face.
Vector dir = shadowRays.getDirection(i);
- if(Dot(dir, sourceRays.getNormal(i)) > 0) {
+ if(Dot(dir, sourceRays.getFFNormal(i)) > 0) {
// If so normalize and compute length.
Real length = dir.normalize();
Modified: trunk/Interface/RayPacket.cc
==============================================================================
--- trunk/Interface/RayPacket.cc (original)
+++ trunk/Interface/RayPacket.cc Thu Oct 12 17:23:52 2006
@@ -201,3 +201,21 @@
flags |= HaveNormals | HaveUnitNormals;
}
+void RayPacket::actualComputeFFNormals(const RenderContext& context)
+{
+ // We need to have normals
+ computeNormals(context);
+
+ for(int i = rayBegin; i < rayEnd; ++i) {
+ // Compute the dot product
+ Vector normal(getNormal(i));
+ Real side = Dot(normal, getDirection(i));
+ if (side <= 0)
+ setFFNormal(i, normal);
+ else
+ setFFNormal(i, -normal);
+
+ }
+
+ flags |= HaveFFNormals;
+}
Modified: trunk/Interface/RayPacket.h
==============================================================================
--- trunk/Interface/RayPacket.h (original)
+++ trunk/Interface/RayPacket.h Thu Oct 12 17:23:52 2006
@@ -92,6 +92,7 @@
MANTA_ALIGN(16) Real image[2][MaxSize];
MANTA_ALIGN(16) Real normal[3][MaxSize];
+ MANTA_ALIGN(16) Real ffnormal[3][MaxSize]; // Forward facing normals
MANTA_ALIGN(16) Real hitPosition[3][MaxSize];
MANTA_ALIGN(16) Real texCoords[3][MaxSize];
@@ -130,9 +131,10 @@
// whether the normals computed
// have been normalized.
HaveNormals = 0x0200,
- HaveInverseDirections = 0x0400,
- HaveSigns = 0x0800,
- ConstantSigns = 0x1000,
+ HaveFFNormals = 0x0400,
+ HaveInverseDirections = 0x0800,
+ HaveSigns = 0x1000,
+ ConstantSigns = 0x2000,
DebugPacket = 0x8000
};
@@ -576,10 +578,19 @@
for(int i=0;i<3;i++)
data->normal[i][which] = normal[i];
}
+ void setFFNormal(int which, const Vector& normal)
+ {
+ for(int i=0;i<3;i++)
+ data->ffnormal[i][which] = normal[i];
+ }
Vector getNormal(int which) const
{
return Vector(data->normal[0][which], data->normal[1][which],
data->normal[2][which]);
}
+ Vector getFFNormal(int which) const
+ {
+ return Vector(data->ffnormal[0][which], data->ffnormal[1][which],
data->ffnormal[2][which]);
+ }
void computeNormals(const RenderContext& context)
{
if(flags & HaveNormals)
@@ -587,6 +598,15 @@
actualComputeNormals(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;
+
+ actualComputeFFNormals(context);
+ }
// Hit positions
Vector getHitPosition(int which) const
@@ -635,6 +655,7 @@
void actualNormalizeDirections();
void actualComputeHitPositions();
void actualComputeNormals(const RenderContext& context);
+ void actualComputeFFNormals(const RenderContext& context);
// Prevent accidental copying of RayPackets
RayPacket(const RayPacket&);
Modified: trunk/Model/Materials/AmbientOcclusion.cc
==============================================================================
--- trunk/Model/Materials/AmbientOcclusion.cc (original)
+++ trunk/Model/Materials/AmbientOcclusion.cc Thu Oct 12 17:23:52 2006
@@ -61,7 +61,7 @@
RayPacket& rays) const
{
// Compute normals
- rays.computeNormals(context);
+ rays.computeFFNormals(context);
rays.computeHitPositions();
// We are going to first compute the ambient values.
@@ -69,7 +69,7 @@
for(int i = rays.begin(); i < rays.end(); ++i) {
// for each position, compute a local coordinate frame
// and build a set of rays to push into a ray packet
- Vector W(rays.getNormal(i)); // surface ONB
+ Vector W(rays.getFFNormal(i)); // surface ONB
Vector U(Cross(W, Vector(1,0,0)));
Real squared_length = U.length2();
if ( squared_length < (Real)1e-6 )
@@ -129,7 +129,7 @@
for(int j=shadowRays.begin(); j < shadowRays.end(); j++){
if(!shadowRays.wasHit(j)){
// Not in shadow, so compute the direct and specular contributions.
- Vector normal = rays.getNormal(j);
+ Vector normal = rays.getFFNormal(j);
Vector shadowdir = shadowRays.getDirection(j);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(j);
Modified: trunk/Model/Materials/Lambertian.cc
==============================================================================
--- trunk/Model/Materials/Lambertian.cc (original)
+++ trunk/Model/Materials/Lambertian.cc Thu Oct 12 17:23:52 2006
@@ -58,7 +58,7 @@
// object and are all of the same material
// Compute normals
- rays.computeNormals(context);
+ rays.computeFFNormals(context);
// Compute colors
Packet<Color> diffuse;
@@ -98,7 +98,7 @@
for(int i = rays.begin(); i < rays.end(); i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct lighting contributions.
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
@@ -111,7 +111,7 @@
for(;i<b;i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct lighting contributions.
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
@@ -149,9 +149,9 @@
// Not in shadow, so compute the direct light contributions.
// Vector normal = rays.getNormal(i)
- __m128 normalx = _mm_load_ps(&data->normal[0][i]);
- __m128 normaly = _mm_load_ps(&data->normal[1][i]);
- __m128 normalz = _mm_load_ps(&data->normal[2][i]);
+ __m128 normalx = _mm_load_ps(&data->ffnormal[0][i]);
+ __m128 normaly = _mm_load_ps(&data->ffnormal[1][i]);
+ __m128 normalz = _mm_load_ps(&data->ffnormal[2][i]);
// Vector shadowdir = shadowRays.getDirection(i);
__m128 sdx = _mm_load_ps(&shadowData->direction[0][i]);
__m128 sdy = _mm_load_ps(&shadowData->direction[1][i]);
@@ -180,7 +180,7 @@
for(;i<rays.rayEnd;i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct lighting contributions.
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
@@ -193,7 +193,7 @@
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.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
Modified: trunk/Model/Materials/MetalMaterial.cc
==============================================================================
--- trunk/Model/Materials/MetalMaterial.cc (original)
+++ trunk/Model/Materials/MetalMaterial.cc Thu Oct 12 17:23:52 2006
@@ -34,7 +34,7 @@
// Compute only if we haven't hit the max ray depth.
if(rays.getDepth() < context.scene->getRenderParameters().maxDepth) {
rays.normalizeDirections();
- rays.computeNormals(context);
+ rays.computeFFNormals(context);
Packet<Color> specular;
specular_reflectance->mapValues(specular, context, rays);
@@ -44,7 +44,7 @@
rays.getDepth()+1, RayPacket::NormalizedDirections);
for(int i=rays.begin();i<rays.end();i++) {
Vector rayD = rays.getDirection(i);
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector refl_dir = rayD - normal*(2*Dot(normal, rayD));
refl_rays.setRay(i, rays.getHitPosition(i), refl_dir);
refl_rays.setImportance(i, rays.getImportance(i));
@@ -54,8 +54,10 @@
context.renderer->traceRays(context, refl_rays);
for(int i=rays.begin();i<rays.end();i++) {
// compute Schlick Fresnel approximation
- Real cosine = -Dot(rays.getNormal(i), rays.getDirection(i));
- if(cosine < 0) cosine =-cosine;
+ Real cosine = -Dot(rays.getFFNormal(i), rays.getDirection(i));
+ // Since we are using forward facing normals the dot product will
+ // always be negative.
+ // if(cosine < 0) cosine =-cosine;
Real k = 1 - cosine;
k*=k*k*k*k;
Modified: trunk/Model/Materials/NDotL.cc
==============================================================================
--- trunk/Model/Materials/NDotL.cc (original)
+++ trunk/Model/Materials/NDotL.cc Thu Oct 12 17:23:52 2006
@@ -37,13 +37,15 @@
using namespace Manta;
-
-NDotL::NDotL(const Vector& d, const Color& color) : direction(d.normal())
+NDotL::NDotL(const Vector& d, const Color& color)
+ : direction(d.normal())
{
colortex = new Constant<Color>(color);
}
-NDotL::NDotL(const Vector& d, const Texture<Color>* colortex) :
direction(d.normal()), colortex(colortex)
+NDotL::NDotL(const Vector& d, const Texture<Color>* colortex)
+ : direction(d.normal()),
+ colortex(colortex)
{
}
@@ -55,17 +57,9 @@
{
}
-Vector FaceForward(const Vector& N, const Vector& V)
-{
- if (Dot(N,V) > 0)
- return N;
- else
- return -N;
-}
-
void NDotL::shade(const RenderContext& context, RayPacket& rays) const
{
- rays.computeNormals(context);
+ rays.computeFFNormals(context);
// Compute colors
Packet<Color> colors;
colortex->mapValues(colors, context, rays);
@@ -73,11 +67,10 @@
// Copy the colors into the ray packet.
for(int i=rays.begin();i<rays.end();i++)
{
- ColorComponent cosine = Dot(FaceForward(rays.getNormal(i),
rays.getDirection(i)),
- direction);
+ ColorComponent cosine = Dot(rays.getFFNormal(i), direction);
+
if (cosine < 0)
cosine = 0;
- //rays.setColor( i, colors[i] * cosine );
- rays.setColor(i, colors.get(i));
+ rays.setColor( i, colors.get(i) * cosine );
}
}
Modified: trunk/Model/Materials/NDotL.h
==============================================================================
--- trunk/Model/Materials/NDotL.h (original)
+++ trunk/Model/Materials/NDotL.h Thu Oct 12 17:23:52 2006
@@ -47,8 +47,8 @@
virtual void preprocess(const PreprocessContext&);
virtual void shade(const RenderContext& context, RayPacket& rays)
const;
+ const Vector direction;
private:
- const Vector& direction;
Texture<Color> const *colortex;
};
}
Modified: trunk/Model/Materials/Phong.cc
==============================================================================
--- trunk/Model/Materials/Phong.cc (original)
+++ trunk/Model/Materials/Phong.cc Thu Oct 12 17:23:52 2006
@@ -99,7 +99,7 @@
speculartex->mapValues(specular, context, rays);
// Compute normals
- rays.computeNormals(context);
+ rays.computeFFNormals(context);
// Compute ambient contributions for all rays
MANTA_ALIGN(16) ColorArray ambientAndDiffuseLight;
@@ -138,7 +138,7 @@
for(int i = rays.begin(); i < rays.end(); i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct and specular contributions.
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
@@ -162,7 +162,7 @@
for(;i<b;i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct and specular contributions.
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
@@ -199,21 +199,21 @@
(double)(size_t)shadowData->hitMatl[i+3] ),
_mm_setzero_pd() ));
-#endif
+#endif // _mm_load_pd hack
__m128 mask = _mm_shuffle_ps(masklo, maskhi, _MM_SHUFFLE(2, 0, 2,
0));
#else
__m128 mask =
_mm_cmpeq_ps(_mm_load_ps((float*)&shadowData->hitMatl[i]), _mm_setzero_ps());
-#endif
+#endif // __x86_64
if(_mm_movemask_ps(mask) == 0)
continue;
// Not in shadow, so compute the direct and specular contributions.
- __m128 normalx = _mm_load_ps(&data->normal[0][i]);
- __m128 normaly = _mm_load_ps(&data->normal[1][i]);
- __m128 normalz = _mm_load_ps(&data->normal[2][i]);
+ __m128 normalx = _mm_load_ps(&data->ffnormal[0][i]);
+ __m128 normaly = _mm_load_ps(&data->ffnormal[1][i]);
+ __m128 normalz = _mm_load_ps(&data->ffnormal[2][i]);
__m128 sdx = _mm_load_ps(&shadowData->direction[0][i]);
__m128 sdy = _mm_load_ps(&shadowData->direction[1][i]);
__m128 sdz = _mm_load_ps(&shadowData->direction[2][i]);
@@ -267,7 +267,7 @@
for(;i<rays.rayEnd;i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct and specular contributions.
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
@@ -287,11 +287,11 @@
}
}
}
-#else
+#else // ifdef MANTA_SSE
for(int i=shadowRays.begin(); i < shadowRays.end(); i++){
if(!shadowRays.wasHit(i)){
// Not in shadow, so compute the direct and specular contributions.
- Vector normal = rays.getNormal(i);
+ Vector normal = rays.getFFNormal(i);
Vector shadowdir = shadowRays.getDirection(i);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(i);
@@ -308,7 +308,7 @@
}
}
}
-#endif
+#endif // ifdef MANTA_SSE
firstTime = false;
} while(!done);
@@ -344,14 +344,14 @@
rays.setColor(i, result);
}
}
-#else
+#else // ifdef MANTA_SSE
for(int i = rays.begin(); i < rays.end(); i++){
Color result;
for(int j=0;j<Color::NumComponents;j++)
result[j] = specularLight[j][i] * specular.colordata[j][i] +
ambientAndDiffuseLight[j][i] * diffuse.colordata[j][i];
rays.setColor(i, result);
}
-#endif
+#endif // ifdef MANTA_SSE
// Compute reflections
if(do_refl && rays.getDepth() <
context.scene->getRenderParameters().maxDepth){
@@ -368,7 +368,7 @@
if(b == e){
for(int i = rays.begin(); i < rays.end(); i++){
Vector refl_dir = (rays.getDirection(i) -
- rays.getNormal(i)*(2*Dot(rays.getNormal(i),
rays.getDirection(i) )));
+ rays.getFFNormal(i)*(2*Dot(rays.getFFNormal(i),
rays.getDirection(i) )));
refl_rays.setRay(i, rays.getHitPosition(i), refl_dir);
refl_rays.setImportance(i, rays.getImportance(i) * refl.data[i]);
}
@@ -376,7 +376,7 @@
int i = rays.rayBegin;
for(;i<b;i++){
Vector refl_dir = (rays.getDirection(i) -
- rays.getNormal(i)*(2*Dot(rays.getNormal(i),
rays.getDirection(i) )));
+ rays.getFFNormal(i)*(2*Dot(rays.getFFNormal(i),
rays.getDirection(i) )));
refl_rays.setRay(i, rays.getHitPosition(i), refl_dir);
refl_rays.setImportance(i, rays.getImportance(i) * refl.data[i]);
}
@@ -386,9 +386,9 @@
__m128 dx = _mm_load_ps(&data->direction[0][i]);
__m128 dy = _mm_load_ps(&data->direction[1][i]);
__m128 dz = _mm_load_ps(&data->direction[2][i]);
- __m128 normalx = _mm_load_ps(&data->normal[0][i]);
- __m128 normaly = _mm_load_ps(&data->normal[1][i]);
- __m128 normalz = _mm_load_ps(&data->normal[2][i]);
+ __m128 normalx = _mm_load_ps(&data->ffnormal[0][i]);
+ __m128 normaly = _mm_load_ps(&data->ffnormal[1][i]);
+ __m128 normalz = _mm_load_ps(&data->ffnormal[2][i]);
__m128 cos_theta = _mm_add_ps(_mm_add_ps(_mm_mul_ps(dx, normalx),
_mm_mul_ps(dy, normaly)), _mm_mul_ps(dz, normalz));
__m128 scale = _mm_mul_ps(_mm_set1_ps(2.0f), cos_theta);
__m128 rx = _mm_sub_ps(dx, _mm_mul_ps(normalx, scale));
@@ -408,19 +408,19 @@
}
for(;i<rays.rayEnd;i++){
Vector refl_dir = (rays.getDirection(i) -
- rays.getNormal(i)*(2*Dot(rays.getNormal(i),
rays.getDirection(i) )));
+ rays.getFFNormal(i)*(2*Dot(rays.getFFNormal(i),
rays.getDirection(i) )));
refl_rays.setRay(i, rays.getHitPosition(i), refl_dir);
refl_rays.setImportance(i, rays.getImportance(i) * refl.data[i]);
}
}
-#else
+#else // ifdef MANTA_SSE
for(int i = rays.begin(); i < rays.end(); i++){
Vector refl_dir = (rays.getDirection(i) -
- rays.getNormal(i)*(2*Dot(rays.getNormal(i),
rays.getDirection(i) )));
+ rays.getFFNormal(i)*(2*Dot(rays.getFFNormal(i),
rays.getDirection(i) )));
refl_rays.setRay(i, rays.getHitPosition(i), refl_dir);
refl_rays.setImportance(i, rays.getImportance(i) * refl.data[i]);
}
-#endif
+#endif // ifdef MANTA_SSE
refl_rays.resetHits();
context.renderer->traceRays(context, refl_rays);
@@ -446,10 +446,10 @@
rays.setColor(i, rays.getColor(i) + refl_rays.getColor(i) *
refl.data[i]);
}
}
-#else
+#else // ifdef MANTA_SSE
for(int i = rays.begin(); i < rays.end(); i++){
rays.setColor(i, rays.getColor(i) + refl_rays.getColor(i) *
refl.data[i]);
}
-#endif
+#endif // ifdef MANTA_SSE
}
}
Modified: trunk/Model/Materials/Transparent.cc
==============================================================================
--- trunk/Model/Materials/Transparent.cc (original)
+++ trunk/Model/Materials/Transparent.cc Thu Oct 12 17:23:52 2006
@@ -46,11 +46,18 @@
alpha = new Constant<ColorComponent>(alpha_);
}
-Transparent::Transparent(const Texture<Color>* color_, const
Texture<ColorComponent> *alpha_ )
+Transparent::Transparent(const Texture<Color>* color_,
+ const Texture<ColorComponent> *alpha_ )
: color(color_), alpha(alpha_)
{
}
+Transparent::Transparent(const Texture<Color>* color_, ColorComponent alpha_
)
+ : color(color_)
+{
+ alpha = new Constant<ColorComponent>(alpha_);
+}
+
Transparent::~Transparent()
{
}
@@ -61,7 +68,7 @@
// Determine lambertian contribution.
// Compute normals
- rays.computeNormals(context);
+ rays.computeFFNormals(context);
rays.computeHitPositions();
// Compute colors
@@ -98,7 +105,7 @@
for(int j=shadowRays.begin(); j < shadowRays.end(); j++){
if(!shadowRays.wasHit(j)){
// Not in shadow, so compute the direct and specular contributions.
- Vector normal = rays.getNormal(j);
+ Vector normal = rays.getFFNormal(j);
Vector shadowdir = shadowRays.getDirection(j);
ColorComponent cos_theta = Dot(shadowdir, normal);
Color light = shadowRays.getColor(j);
Modified: trunk/Model/Materials/Transparent.h
==============================================================================
--- trunk/Model/Materials/Transparent.h (original)
+++ trunk/Model/Materials/Transparent.h Thu Oct 12 17:23:52 2006
@@ -42,8 +42,9 @@
class Transparent : public LitMaterial {
public:
Transparent( const Color& color, ColorComponent alpha_ );
- Transparent( const Texture<Color>* color_, const Texture<ColorComponent>
*alpha_ );
- Transparent() { };
+ Transparent( const Texture<Color>* color_,
+ const Texture<ColorComponent> *alpha_ );
+ Transparent(const Texture<Color>* color_, ColorComponent alpha_ );
virtual ~Transparent();
virtual void shade(const RenderContext& context, RayPacket& rays) const;
- [MANTA] r1219 - in trunk: Core/Color Engine/Factory Engine/Shadows Interface Model/Materials, bigler, 10/12/2006
Archive powered by MHonArc 2.6.16.