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:
parent
7d9eb65fde
commit
584160265f
@ -159,15 +159,12 @@ Color Scene::traceRayRecurse(const Ray & ray, int depth, double factor)
|
|||||||
/* compute the Phong lighting for each hit */
|
/* compute the Phong lighting for each hit */
|
||||||
refptr<Material> material = hit.shape->getMaterial();
|
refptr<Material> material = hit.shape->getMaterial();
|
||||||
|
|
||||||
/* TODO: make sure this can be removed */
|
|
||||||
#if 0
|
|
||||||
/* check for backfaces */
|
/* 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 */
|
/* if dot product is positive, this is a back-face */
|
||||||
surfaceNormal = -surfaceNormal;
|
hit.normal = -hit.normal;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
color = computePhong(material,
|
color = computePhong(material,
|
||||||
ray,
|
ray,
|
||||||
@ -252,9 +249,6 @@ Color Scene::computePhong(const refptr<Material> material,
|
|||||||
double shininess = material->getShininess();
|
double shininess = material->getShininess();
|
||||||
const Color & diffuseColor = material->getDiffuseColor();
|
const Color & diffuseColor = material->getDiffuseColor();
|
||||||
const Color & specularColor = material->getSpecularColor();
|
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();
|
for (std::vector< refptr<Light> >::const_iterator it = m_lights.begin();
|
||||||
it != m_lights.end();
|
it != m_lights.end();
|
||||||
@ -263,7 +257,7 @@ Color Scene::computePhong(const refptr<Material> material,
|
|||||||
Vector directionToLight = (*it)->getPosition() - surfacePoint;
|
Vector directionToLight = (*it)->getPosition() - surfacePoint;
|
||||||
directionToLight.normalize();
|
directionToLight.normalize();
|
||||||
Vector reflectedLightDirection =
|
Vector reflectedLightDirection =
|
||||||
directionToLight.reflect(normal);
|
directionToLight.reflect(surfaceNormal);
|
||||||
|
|
||||||
Ray surfaceToLight(surfacePoint, directionToLight);
|
Ray surfaceToLight(surfacePoint, directionToLight);
|
||||||
Color light_contribution =
|
Color light_contribution =
|
||||||
@ -274,7 +268,7 @@ Color Scene::computePhong(const refptr<Material> material,
|
|||||||
|| light_contribution.b > 0.0 )
|
|| light_contribution.b > 0.0 )
|
||||||
{
|
{
|
||||||
/* calculate the diffuse term */
|
/* calculate the diffuse term */
|
||||||
double diffuse_coef = directionToLight % normal;
|
double diffuse_coef = directionToLight % surfaceNormal;
|
||||||
if (diffuse_coef > 0.0)
|
if (diffuse_coef > 0.0)
|
||||||
{
|
{
|
||||||
result += diffuseColor
|
result += diffuseColor
|
||||||
|
@ -8,14 +8,39 @@ scene
|
|||||||
|
|
||||||
camera
|
camera
|
||||||
{
|
{
|
||||||
position <1.2, -2, 1.2>
|
position <1.2, -2, 1>
|
||||||
look_at <0, 0, 0>
|
look_at <0, 0, 0>
|
||||||
}
|
}
|
||||||
|
|
||||||
light { position <10, 4, 10> color <.7, .7, .7> }
|
light { position <10, -12, 8> }
|
||||||
light { position <-10, -5, 10> color <.7, .7, .7> }
|
|
||||||
|
|
||||||
plane { position <0, 0, 1>, 0.501 }
|
plane
|
||||||
|
{
|
||||||
|
position <0, 0, 1>, 0.501
|
||||||
|
material
|
||||||
|
{
|
||||||
|
color <0.4, 1, 0.4>
|
||||||
|
reflectance 0.4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plane
|
||||||
|
{
|
||||||
|
position <1, 0, 0>, 1
|
||||||
|
material
|
||||||
|
{
|
||||||
|
color <1, 0.4, 0.4>
|
||||||
|
reflectance 0.4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
plane
|
||||||
|
{
|
||||||
|
position <0, -1, 0>, 1
|
||||||
|
material
|
||||||
|
{
|
||||||
|
color <0.4, 0.4, 1>
|
||||||
|
reflectance 0.4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
subtract
|
subtract
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user