changed Scene::calculateLightContribution() to return a Color instead of a double and take into account the color of any semi-transparent objects that are passed through en route to the light source... this leads to shadow colors tainted by the color of the objects through which the light is travelling
git-svn-id: svn://anubis/fart/trunk@211 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
a24452af01
commit
86888fa461
5 files changed
+21
-8
No files matched your search
+10
-5
@@ -263,10 +263,12 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
directionToLight.reflect(surfaceNormal);
|
||||
|
||||
Ray surfaceToLight(surfacePoint, directionToLight);
|
||||
double light_contribution =
|
||||
Color light_contribution =
|
||||
calculateLightContribution(surfaceToLight.shift(0.0001), *it);
|
||||
|
||||
if (light_contribution > 0.0)
|
||||
if ( light_contribution.r > 0.0
|
||||
|| light_contribution.g > 0.0
|
||||
|| light_contribution.b > 0.0 )
|
||||
{
|
||||
/* calculate the diffuse term */
|
||||
double diffuse_coef = directionToLight % surfaceNormal;
|
||||
@@ -301,10 +303,10 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
return result;
|
||||
}
|
||||
|
||||
double Scene::calculateLightContribution(const Ray & toLight,
|
||||
Color Scene::calculateLightContribution(const Ray & toLight,
|
||||
refptr<Light> light)
|
||||
{
|
||||
double contrib = 1.0;
|
||||
Color contrib(1.0, 1.0, 1.0);
|
||||
double dist_to_light = toLight.getOrigin().dist_to(light->getPosition());
|
||||
double dist_so_far = 0.0;
|
||||
|
||||
@@ -323,8 +325,11 @@ double Scene::calculateLightContribution(const Ray & toLight,
|
||||
break;
|
||||
|
||||
contrib *= hit.shape->getMaterial()->getTransparency();
|
||||
contrib *= hit.shape->getMaterial()->getDiffuseColor();
|
||||
|
||||
if ( contrib < SCENE_FACTOR_THRESHOLD )
|
||||
if ( contrib.r < SCENE_FACTOR_THRESHOLD
|
||||
&& contrib.g < SCENE_FACTOR_THRESHOLD
|
||||
&& contrib.b < SCENE_FACTOR_THRESHOLD )
|
||||
break;
|
||||
|
||||
dist_so_far += offset;
|
||||
|
||||
+2
-2
@@ -42,8 +42,8 @@ class Scene
|
||||
const Ray & viewRay,
|
||||
const Vector & surfacePoint,
|
||||
const Vector & surfaceNormal);
|
||||
double calculateLightContribution(const Ray & toLight,
|
||||
refptr<Light> light);
|
||||
Color calculateLightContribution(const Ray & toLight,
|
||||
refptr<Light> light);
|
||||
|
||||
/* In Scene-load.cc */
|
||||
void load(const char * filename);
|
||||
|
||||
Reference in new issue
Block a user