added ambient parameter in global options{} for parser to set scene's global ambient color
git-svn-id: svn://anubis/fart/trunk@260 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
70a5ef74d4
commit
c115dec69b
@ -198,6 +198,10 @@ void Scene::processOptions(refptr<Node> node)
|
||||
{
|
||||
m_max_depth = (*it)->getInteger();
|
||||
}
|
||||
else if ( typeid(**it) == typeid(AmbientNode) )
|
||||
{
|
||||
setAmbientLight(Color((*it)->getVector()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -230,6 +230,7 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
Vector lightPlaneX = directionToLightC.getPerpendicular().normalize();
|
||||
Vector lightPlaneY = (directionToLightC * lightPlaneX).normalize();
|
||||
int jitter_samples = 0, jitter_level = (*it)->getJitter();;
|
||||
Color jitterResult;
|
||||
for (int jitter_index = 0; jitter_index < jitter_level; jitter_index++)
|
||||
{
|
||||
double jitterRadius = jitter_index * lightRadius
|
||||
@ -259,7 +260,7 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
double diffuse_coef = directionToLight % surfaceNormal;
|
||||
if (diffuse_coef > 0.0)
|
||||
{
|
||||
result += diffuseColor
|
||||
jitterResult += diffuseColor
|
||||
* (*it)->getDiffuseColor()
|
||||
* diffuse_coef
|
||||
* light_contribution;
|
||||
@ -269,7 +270,7 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
double specular_coef = reflectedLightDirection % viewDirection;
|
||||
if (specular_coef > 0.0)
|
||||
{
|
||||
result += specularColor
|
||||
jitterResult += specularColor
|
||||
* (*it)->getSpecularColor()
|
||||
* pow(specular_coef, shininess)
|
||||
* light_contribution;
|
||||
@ -277,7 +278,8 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
}
|
||||
}
|
||||
}
|
||||
result /= jitter_samples;
|
||||
jitterResult /= jitter_samples;
|
||||
result += jitterResult;
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -311,6 +311,9 @@ options_item: WIDTH DEC_NUMBER {
|
||||
| EXPOSURE number {
|
||||
$$ = new ExposureNode($2->getNumber());
|
||||
}
|
||||
| AMBIENT vector {
|
||||
$$ = new AmbientNode($2->getVector());
|
||||
}
|
||||
;
|
||||
|
||||
plane: PLANE LCURLY plane_items RCURLY {
|
||||
|
@ -4,6 +4,7 @@ scene
|
||||
options
|
||||
{
|
||||
multisample 3
|
||||
ambient <0.2, 0.2, 0.2>
|
||||
}
|
||||
|
||||
camera
|
||||
|
Loading…
x
Reference in New Issue
Block a user