capping colors in main/Lighting; colors are maxing out too easily, might need a better reduction method
git-svn-id: svn://anubis/fart/trunk@74 7f9b0f55-74a9-4bce-be96-3c2cd072584d
This commit is contained in:
parent
6fbdf46122
commit
7181a894a4
@ -1,6 +1,8 @@
|
|||||||
|
|
||||||
#include "Lighting.h"
|
#include "Lighting.h"
|
||||||
#include <math.h> /* pow() */
|
#include <math.h> /* pow() */
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
Color Lighting::computePhong(const Material & material,
|
Color Lighting::computePhong(const Material & material,
|
||||||
const std::vector<Light *> & lights,
|
const std::vector<Light *> & lights,
|
||||||
@ -26,15 +28,31 @@ Color Lighting::computePhong(const Material & material,
|
|||||||
directionToLight.reflect(surfaceNormal);
|
directionToLight.reflect(surfaceNormal);
|
||||||
|
|
||||||
/* calculate the diffuse term */
|
/* calculate the diffuse term */
|
||||||
result += diffuseColor
|
double diffuse_coef = directionToLight % surfaceNormal;
|
||||||
* (*it)->getDiffuseColor()
|
if (diffuse_coef > 0.0)
|
||||||
* (directionToLight % surfaceNormal);
|
{
|
||||||
|
result += diffuseColor
|
||||||
|
* (*it)->getDiffuseColor()
|
||||||
|
* diffuse_coef;
|
||||||
|
}
|
||||||
|
|
||||||
/* calculate the specular term */
|
/* calculate the specular term */
|
||||||
result += specularColor
|
double specular_coef = reflectedLightDirection % viewDirection;
|
||||||
* (*it)->getSpecularColor()
|
if (specular_coef > 0.0)
|
||||||
* pow(reflectedLightDirection % viewDirection, shininess);
|
{
|
||||||
|
result += specularColor
|
||||||
|
* (*it)->getSpecularColor()
|
||||||
|
* pow(specular_coef, shininess);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: figure out better scaling */
|
||||||
|
if (result.r > 1.0)
|
||||||
|
result.r = 1.0;
|
||||||
|
if (result.g > 1.0)
|
||||||
|
result.g = 1.0;
|
||||||
|
if (result.b > 1.0)
|
||||||
|
result.b = 1.0;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@ Scene::Scene(const map<string, const char *> & options,
|
|||||||
m_vfov = 60.0;
|
m_vfov = 60.0;
|
||||||
m_verbose = false;
|
m_verbose = false;
|
||||||
m_data = NULL;
|
m_data = NULL;
|
||||||
|
m_ambient_light = Color(0.1, 0.1, 0.1);
|
||||||
|
|
||||||
load(filename);
|
load(filename);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user