updated scenes/die.fart, moved where backface checking was occurring in main/Scene
git-svn-id: svn://anubis/fart/trunk@217 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
7d9eb65fde
commit
584160265f
2 files changed
+33
-14
No files matched your search
+4
-10
@@ -159,15 +159,12 @@ Color Scene::traceRayRecurse(const Ray & ray, int depth, double factor)
|
||||
/* compute the Phong lighting for each hit */
|
||||
refptr<Material> material = hit.shape->getMaterial();
|
||||
|
||||
/* TODO: make sure this can be removed */
|
||||
#if 0
|
||||
/* check for backfaces */
|
||||
if (ray.getDirection() % surfaceNormal > 0.0)
|
||||
if (ray.getDirection() % hit.normal > 0.0)
|
||||
{
|
||||
/* if dot product is positive, this is a back-face */
|
||||
surfaceNormal = -surfaceNormal;
|
||||
hit.normal = -hit.normal;
|
||||
}
|
||||
#endif
|
||||
|
||||
color = computePhong(material,
|
||||
ray,
|
||||
@@ -252,9 +249,6 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
double shininess = material->getShininess();
|
||||
const Color & diffuseColor = material->getDiffuseColor();
|
||||
const Color & specularColor = material->getSpecularColor();
|
||||
Vector normal = surfaceNormal;
|
||||
if (normal % viewRay.getDirection() > 0.0) /* back face */
|
||||
normal = -normal;
|
||||
|
||||
for (std::vector< refptr<Light> >::const_iterator it = m_lights.begin();
|
||||
it != m_lights.end();
|
||||
@@ -263,7 +257,7 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
Vector directionToLight = (*it)->getPosition() - surfacePoint;
|
||||
directionToLight.normalize();
|
||||
Vector reflectedLightDirection =
|
||||
directionToLight.reflect(normal);
|
||||
directionToLight.reflect(surfaceNormal);
|
||||
|
||||
Ray surfaceToLight(surfacePoint, directionToLight);
|
||||
Color light_contribution =
|
||||
@@ -274,7 +268,7 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
|| light_contribution.b > 0.0 )
|
||||
{
|
||||
/* calculate the diffuse term */
|
||||
double diffuse_coef = directionToLight % normal;
|
||||
double diffuse_coef = directionToLight % surfaceNormal;
|
||||
if (diffuse_coef > 0.0)
|
||||
{
|
||||
result += diffuseColor
|
||||
|
||||
Reference in new issue
Block a user