added ambient_occlusion global scene option to parser and vim keywords; added ambient_occlusion scene file
git-svn-id: svn://anubis/fart/trunk@263 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
1 parent
f5ac18d34f
commit
96f2b7d276
9 files changed
+69
-4
No files matched your search
@@ -202,6 +202,10 @@ void Scene::processOptions(refptr<Node> node)
|
||||
{
|
||||
setAmbientLight(Color((*it)->getVector()));
|
||||
}
|
||||
else if ( typeid(**it) == typeid(AmbientOcclusionNode) )
|
||||
{
|
||||
m_ambient_occlusion_level = (*it)->getInteger();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-3
@@ -30,6 +30,7 @@ Scene::Scene(const map<string, const char *> & options,
|
||||
m_ambient_light = Color(0.2, 0.2, 0.2);
|
||||
m_max_depth = 10;
|
||||
m_exposure = 1.0f;
|
||||
m_ambient_occlusion_level = 0;
|
||||
m_transforms.push(Transform());
|
||||
|
||||
load(filename);
|
||||
@@ -215,8 +216,12 @@ Color Scene::computePhong(const refptr<Material> material,
|
||||
const Vector & surfacePoint,
|
||||
const Vector & surfaceNormal)
|
||||
{
|
||||
Color result = m_ambient_light * material->getAmbientColor()
|
||||
* calculateAmbientOcclusion(Ray(surfacePoint, surfaceNormal).shift(1e-7));
|
||||
Color result = m_ambient_light * material->getAmbientColor();
|
||||
if (m_ambient_occlusion_level > 0)
|
||||
{
|
||||
result *= calculateAmbientOcclusion(
|
||||
Ray(surfacePoint, surfaceNormal).shift(1e-7));
|
||||
}
|
||||
|
||||
Vector viewDirection = -viewRay.getDirection();
|
||||
double shininess = material->getShininess();
|
||||
@@ -327,7 +332,8 @@ Color Scene::calculateLightContribution(const Ray & toLight,
|
||||
Color Scene::calculateAmbientOcclusion(const Ray & surfaceNormal)
|
||||
{
|
||||
Color result(1, 1, 1);
|
||||
const int nISteps = 30, nJSteps = 15;
|
||||
const int nISteps = m_ambient_occlusion_level * 6;
|
||||
const int nJSteps = nISteps / 2;
|
||||
int nRays = 0;
|
||||
Vector perpX = surfaceNormal.getDirection().getPerpendicular().normalize();
|
||||
Vector perpY = (surfaceNormal.getDirection() * perpX).normalize();
|
||||
|
||||
@@ -37,6 +37,7 @@ class Scene
|
||||
int getWidth() { return m_width; }
|
||||
int getHeight() { return m_height; }
|
||||
int getMultisampleLevel() { return m_multisample_level; }
|
||||
int getAmbientOcclusionLevel() { return m_ambient_occlusion_level; }
|
||||
double getVFOV() { return m_vfov; }
|
||||
|
||||
protected:
|
||||
@@ -79,6 +80,7 @@ class Scene
|
||||
Color m_ambient_light;
|
||||
int m_max_depth;
|
||||
double m_exposure;
|
||||
int m_ambient_occlusion_level;
|
||||
|
||||
/* private data */
|
||||
std::vector< refptr<Shape> > m_shapes;
|
||||
|
||||
@@ -187,6 +187,7 @@ int main(int argc, char * argv[])
|
||||
cout << " Width: " << width << endl;
|
||||
cout << " Height: " << height << endl;
|
||||
cout << " Multisample Level: " << scene.getMultisampleLevel() << endl;
|
||||
cout << " Ambient Occlusion Level: " << scene.getAmbientOcclusionLevel() << endl;
|
||||
cout << " Vertical Field of View: " << scene.getVFOV() << endl;
|
||||
cout << "----------------------------------------" << endl;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user