Skip to content
Snippets Groups Projects
Commit b3230d49 authored by bobarna's avatar bobarna
Browse files

fixed depth buffer -- yaaaaay

parent 495b4cd1
Branches
No related tags found
1 merge request!2Head propagate
...@@ -29,6 +29,7 @@ Scene Scene(WIDTH, HEIGHT); ...@@ -29,6 +29,7 @@ Scene Scene(WIDTH, HEIGHT);
static void Initialize() { static void Initialize() {
glViewport(0, 0, WIDTH, HEIGHT); glViewport(0, 0, WIDTH, HEIGHT);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glDepthMask(GL_TRUE);
glLoadIdentity(); glLoadIdentity();
glClearColor(196.0f / 255.0f, 233.0f / 255.0f, 241.0f / 255.0f, 1.0f); glClearColor(196.0f / 255.0f, 233.0f / 255.0f, 241.0f / 255.0f, 1.0f);
} }
......
...@@ -24,26 +24,26 @@ void Scene::Build() { ...@@ -24,26 +24,26 @@ void Scene::Build() {
auto sphere = new Sphere(); auto sphere = new Sphere();
Shader *phongShader = new PhongShader(); Shader *phongShader = new PhongShader();
Material *headMaterial = new Material; Material *headMaterial = new Material;
headMaterial->kd = vec3(0.6f, 0.2f, .2f); headMaterial->kd = vec3(0.5f, 0.3f, .3f);
headMaterial->ks = vec3(.3, .2, .2); headMaterial->ks = vec3(.1, .05, .05);
headMaterial->ka = vec3(.2f, .2f, .2f); headMaterial->ka = vec3(.2f, .2f, .2f);
headMaterial->shininess = 100; headMaterial->shininess = 20;
// Texture *headTexture = new UniformColorTexture(.6f, .2f, 0); Texture *headTexture = new UniformColorTexture(.6f, .2f, 0);
Texture *headTexture = new CheckerBoardTexture(10, 10); // Texture *headTexture = new CheckerBoardTexture(1, 0);
auto headObject = new HeadObject(phongShader, sphere, headMaterial, headTexture); auto headObject = new HeadObject(phongShader, sphere, headMaterial, headTexture);
headObject->Scale(vec3(.15, .1, .1)); headObject->Scale(vec3(.15, .1, .1));
// objects.push_back(headObject); objects.push_back(headObject);
auto PBDSim = new PBDSimulation(headObject, nrSims, nrSegments, lSeg); auto PBDSim = new PBDSimulation(headObject, nrSims, nrSegments, lSeg);
auto simulationObject = new HairSimObject(headObject, basicShader, PBDSim); auto simulationObject = new HairSimObject(headObject, basicShader, PBDSim);
// sims.push_back(simulationObject); sims.push_back(simulationObject);
auto testObject = auto testObject =
new Object(phongShader, new Object(phongShader,
new ObjGeometry("../data/susanne.obj"), new ObjGeometry("../data/plane.obj"),
headMaterial, headMaterial,
headTexture); headTexture);
...@@ -67,8 +67,9 @@ void Scene::Build() { ...@@ -67,8 +67,9 @@ void Scene::Build() {
void Scene::Render() { void Scene::Render() {
RenderState state = camera.getState(); RenderState state = camera.getState();
state.lights = lights; state.lights = lights;
for (auto *o: objects) o->Draw(state);
for (auto *so: sims) so->Draw(state); for (auto *so: sims) so->Draw(state);
for (auto *o: objects) o->Draw(state);
} }
//delta_t is infinitesimal //delta_t is infinitesimal
......
...@@ -72,7 +72,7 @@ class PhongShader : public Shader { ...@@ -72,7 +72,7 @@ class PhongShader : public Shader {
void main() { void main() {
vec3 N = normalize(wNormal); vec3 N = normalize(wNormal);
vec3 V = normalize(wView); vec3 V = normalize(wView);
if (dot(N, V) < 0) N = -N; // prepare for one-sided surfaces like Mobius or Klein // if (dot(N, V) < 0) N = -N; // prepare for one-sided surfaces like Mobius or Klein
vec3 texColor = texture(diffuseTexture, texcoord).rgb; vec3 texColor = texture(diffuseTexture, texcoord).rgb;
vec3 ka = materials.ka * texColor; vec3 ka = materials.ka * texColor;
vec3 kd = materials.kd * texColor; vec3 kd = materials.kd * texColor;
...@@ -87,7 +87,7 @@ class PhongShader : public Shader { ...@@ -87,7 +87,7 @@ class PhongShader : public Shader {
(kd * texColor * cost + materials.ks * pow(cosd, materials.shininess)) * lights[i].Le; (kd * texColor * cost + materials.ks * pow(cosd, materials.shininess)) * lights[i].Le;
} }
fragmentColor = vec4(radiance, 1); fragmentColor = vec4(radiance, 1);
fragmentColor = vec4(texcoord.xy, 0, 1); // fragmentColor = vec4(N, 1);
} }
)"; )";
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment