Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Everything coded, but artifacted results and not multithreaded.

  • Loading branch information...
commit 27abad28e7fbe83654c9b6080f7740afe9cacd4b 1 parent 35640c9
@ryanschmitty authored
View
4 assets/cornell_simp.pov
@@ -10,9 +10,9 @@ camera {
}
//TOP LIGHT
-//light_source {<0, 10, 0> color rgb <3, 2.55, 1.29>}
+light_source {<0, 10, 0> color rgb <3, 2.55, 1.29>}
//doubled the real colors, it was too dark
-light_source {<0, 10, 0> color rgb <2, 1.7, 0.86>}
+//light_source {<0, 10, 0> color rgb <2, 1.7, 0.86>}
//halved the real colors, so it is subtle
//light_source {<0, 5, 15> color rgb <0.1, 0.085, 0.043>}
View
10 src/POVRayParser.cpp
@@ -7,8 +7,6 @@
#include "POVRayParser.h"
#include "RDSbvh.h"
-#include "RDSPointDistribution.h"
-#include "RDSSurfelCloud.h"
#include <iostream>
#include <sstream>
#include <cctype>
@@ -68,7 +66,7 @@ namespace RDST
objs->push_back(pBox);
//Generate surfels
- GenerateSurfels(*surfels, *pBox);
+// GenerateSurfels(*surfels, *pBox);
}
pos = line.find("cone");
if (pos != std::string::npos) {
@@ -92,7 +90,7 @@ namespace RDST
objs->push_back(pSphere);
//Generate surfels
- GenerateSurfels(*surfels, *pSphere);
+// GenerateSurfels(*surfels, *pSphere);
}
pos = line.find("triangle");
@@ -105,7 +103,7 @@ namespace RDST
objs->push_back(pTri);
//Generate surfels
- surfels->push_back(pTri);
+// surfels->push_back(pTri);
//Get point cloud and generate surfels
// float minDist = 0.f;
@@ -134,7 +132,7 @@ namespace RDST
}
}
std::cout << "Done." << std::endl;
- return SceneDescription(pCam, lights, areaLights, objs, planes, BVH(objs), BVH(surfels), surfels);
+ return SceneDescription(pCam, lights, areaLights, objs, planes, BVH(objs), BVH(objs/*surfels*/), surfels);
}
std::string&
View
63 src/RDSIndirectIllum.cpp
@@ -8,6 +8,7 @@
#include "RDSIndirectIllum.h"
#define GLM_FORCE_INLINE
#include <glm/gtx/rotate_vector.hpp>
+#include <glm/gtx/vector_angle.hpp>
namespace RDST
{
@@ -48,7 +49,7 @@ namespace RDST
}
glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); //unbind fbo for now
- printf("lol\n");
+// printf("lol\n");
loadVBO(desc);
@@ -66,6 +67,8 @@ namespace RDST
void Rasterizer::initGL()
{
+ glCullFace(GL_BACK);
+ glEnable(GL_CULL_FACE);
// int argc = 0;
// char** argv;
// glutInit(&argc, argv);
@@ -200,7 +203,8 @@ namespace RDST
void Rasterizer::lights(const SceneDescription& desc) {
/* LIGHTS */
- glEnable(GL_LIGHTING);
+// glEnable(GL_LIGHTING);
+ glDisable(GL_LIGHTING);
int i=0;
unsigned int curLight = GL_LIGHT0;
for(std::vector<PointLightPtr>::const_iterator it = desc.lights().begin(); it != desc.lights().end(); ++it) {
@@ -210,9 +214,10 @@ namespace RDST
glm::vec4 lcolor = (*it)->getColor();
//Point light position
GLfloat lightPos[] = {lpos.x, lpos.y, lpos.z, 0.0};
- GLfloat ambientComp[] = {0.0, 0.0, 0.0, 0.0};
+ GLfloat ambientComp[] = {lcolor.r, lcolor.g, lcolor.b, 0.0};
//Diffuse composition
- GLfloat diffuseComp[] = {lcolor.r, lcolor.g, lcolor.b, 0.0};
+// GLfloat diffuseComp[] = {lcolor.r, lcolor.g, lcolor.b, 0.0};
+ GLfloat diffuseComp[] = {0.f, 0.f, 0.f, 0.f};
//Specular composition
GLfloat specularComp[] = {0.0, 0.0, 0.0, 0.0};
//Point light
@@ -250,7 +255,6 @@ namespace RDST
return colortexture;
}
-
glm::vec3 IndirectIllumMonteCarlo(const Intersection& intrs, const SceneDescription& scene, unsigned int recursionsLeft)
{
glm::vec3 indirectColor(0.f);
@@ -291,42 +295,63 @@ namespace RDST
glm::vec3 tan = fabs(intrs.n.y) == 1.f ? glm::vec3(1,0,0) : glm::normalize(k - ((glm::dot(k, intrs.n))*intrs.n)); //Gram-Schmidt Process
//Generate 6 cube faces (i.e. 5 cameras)
::Camera cameras [5];
+ float near = 0.01f, far = 15.f;
+ glm::vec3 loc = intrs.p + (near*intrs.n);
+// glm::vec3 loc = intrs.p;
+ glm::vec3 dir1 = tan;
+ glm::vec3 dir2 = glm::rotate(tan, 90.f, intrs.n);
+ glm::vec3 dir3 = glm::rotate(tan, 180.f, intrs.n);
+ glm::vec3 dir4 = glm::rotate(tan, 270.f, intrs.n);
+ glm::vec3 dir5 = intrs.n;
for (int i=0; i<4; ++i) {
- glm::vec3 dir(0.f);
- if (i==0) dir = tan;
- else if (i==1) dir = glm::rotate(tan, 90.f, intrs.n);
- else if (i==2) dir = glm::rotate(tan, 180.f, intrs.n);
- else /*(i==3)*/ dir = glm::rotate(tan, 270.f, intrs.n);
+ glm::vec3 dir;
+ if (i==0) dir = dir1;
+ else if (i==1) dir = dir2;
+ else if (i==2) dir = dir3;
+ else /*(i==3)*/ dir = dir4;
cameras[i] = ::Camera(90, //fov
- intrs.p.x, intrs.p.y, intrs.p.z, //loc
+ loc.x, loc.y, loc.z, //loc
dir.x, dir.y, dir.z, //dir
intrs.n.x, intrs.n.y, intrs.n.z, //up
- 0.01f, 100.f); //near/far
+ near, far); //clipping planes
}
cameras[4] = ::Camera(90, //fov
- intrs.p.x, intrs.p.y, intrs.p.z, //loc
- intrs.n.x, intrs.n.y, intrs.n.z, //dir
+ loc.x, loc.y, loc.z, //loc
+ dir5.x, dir5.y, dir5.z, //dir
tan.x, tan.y, tan.z, //up
- 0.01f, 100.f); //near/far
+ near, far); //clipping planes
//Rasterize cube faces (i.e. render 8x8 texture per camera)
static Rasterizer rstr(8, 8, scene); //TODO: static? or should I redesign?
unsigned char pixelData[4*64];
+// printf("\nPoint!\n");
for (int i=0; i<5; ++i) {
GLuint tex = rstr.rasterSurfels(cameras[i]);
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixelData);
+ float weight = 0.f;
for (int j=0; j<64; ++j) {
-// printf("<%f %f %f> ", pixelData[4*j]/255.f, pixelData[4*j+1]/255.f, pixelData[4*j+2]/255.f);
-// if (j%8 == 0) printf("\n");
+ int x = j%8, y = j/8;
+ glm::vec3 U(cameras[i].up.x, cameras[i].up.y, cameras[i].up.z);
+ glm::vec3 D(cameras[i].dir.x, cameras[i].dir.y, cameras[i].dir.z);
+ glm::vec3 R = -glm::cross(U, D);
+ glm::vec3 M = loc + (near*D);
+ glm::vec3 pt = M + (-0.875f*near + 0.25f*(float)x*near)*R + (-0.875f*near + 0.25f*(float)y*near)*U;
+ glm::vec3 v = glm::normalize(pt - intrs.p);
+ weight = glm::dot(intrs.n, v);
+// if (j%8 == 0) printf("\n");
+// printf("<%f %f %f, %f> ", pixelData[4*j]/255.f, pixelData[4*j+1]/255.f, pixelData[4*j+2]/255.f, weight);
+// printf("%f ", weight);
indirectColor.r += pixelData[4*j+0]/255.f; //red
indirectColor.g += pixelData[4*j+1]/255.f; //green
indirectColor.b += pixelData[4*j+2]/255.f; //blue
-// indirectColor += pixelData[4*j+3]; //alpha
+ //indirectColor += pixelData[4*j+3]; //alpha
+ indirectColor *= weight;
}
// printf("\n");
}
+// printf("Point done!\n");
indirectColor /= 64.f * 5.f;
// printf("final color: %f %f %f\n", indirectColor.r, indirectColor.g, indirectColor.b);
- return indirectColor;
+ return 6.f*indirectColor;
}
}
View
159 src/RDSPointDistribution.h
@@ -18,6 +18,7 @@
#include <boost/shared_ptr.hpp>
#include "RandUtil.h"
#include "RDSScene.h"
+#include "RDSTracer.h"
namespace RDST
{
@@ -35,56 +36,99 @@ namespace RDST
boost::shared_ptr< std::vector<glm::vec3> >
GenerateDistributedPoints(int numPoints, const RDST::Triangle& tri, int maxIterations, float* minDist)
{
- int minp1, minp2;
- float mind;
- int n = 4*numPoints;
- int numU1s = (int)sqrtf((float)n);
- int numU2s = n / numU1s;
+ int minp1, minp2;
+ float mind;
+ int n = 4*numPoints;
+ int numU1s = (int)sqrtf((float)n);
+ int numU2s = n / numU1s;
+
+ //Allocate memory (smart pointer to a vec3 array)
+ boost::shared_ptr< std::vector<glm::vec3> > pPointVec = boost::shared_ptr< std::vector<glm::vec3> >(new std::vector<glm::vec3>());
+ pPointVec->reserve(numU1s*numU2s);
+
+ // Create the initial random cloud
+ glm::vec3 v0 = tri.getVertex0();
+ glm::vec3 v1 = tri.getVertex1();
+ glm::vec3 v2 = tri.getVertex2();
+ glm::vec3 v01 = v1 - v0;
+ glm::vec3 v02 = v2 - v0;
+ for (int i=0; i<numU1s; ++i) {
+ for (int j=0; j<numU2s; ++j) {
+ float u1 = (float)i/numU1s + RDST::unifRand()/numU1s;
+ float u2 = (float)j/numU2s + RDST::unifRand()/numU2s;
+ glm::vec3 p;
+ // Inside or outside the triangle?
+ if (u1 + u2 < 1) //inside
+ p = v0 + u1*v01 + u2*v02;
+ else //outside, so project it back
+ p = v0 + (1.f-u1)*v01 + (1.f-u2)*v02;
+
+ p = glm::vec3(tri.getModelXform()*glm::vec4(p,1.f));
+ pPointVec->push_back(p);
+ }
+ }
- //Allocate memory (smart pointer to a vec3 array)
- boost::shared_ptr< std::vector<glm::vec3> > pPointVec = boost::shared_ptr< std::vector<glm::vec3> >(new std::vector<glm::vec3>());
- pPointVec->reserve(numU1s*numU2s);
-
- // Create the initial random cloud
- glm::vec3 v0 = tri.getVertex0();
- glm::vec3 v1 = tri.getVertex1();
- glm::vec3 v2 = tri.getVertex2();
- glm::vec3 v01 = v1 - v0;
- glm::vec3 v02 = v2 - v0;
- for (int i=0; i<numU1s; ++i) {
- for (int j=0; j<numU2s; ++j) {
- float u1 = (float)i/numU1s + RDST::unifRand()/numU1s;
- float u2 = (float)j/numU2s + RDST::unifRand()/numU2s;
- glm::vec3 p;
- // Inside or outside the triangle?
- if (u1 + u2 < 1) //inside
- p = v0 + u1*v01 + u2*v02;
- else //outside, so project it back
- p = v0 + (1.f-u1)*v01 + (1.f-u2)*v02;
-
- p = glm::vec3(tri.getModelXform()*glm::vec4(p,1.f));
- pPointVec->push_back(p);
- }
- }
+ // Prune the points
+ while ((int)pPointVec->size() > numPoints) {
- // Prune the points
- while ((int)pPointVec->size() > numPoints) {
+ FindClosestPoints(&minp1, &minp2, &mind, pPointVec);
- FindClosestPoints(&minp1, &minp2, &mind, pPointVec);
+ //Remove one offending point
+ pPointVec->erase(pPointVec->begin()+minp1);
+ }
- //Remove one offending point
- pPointVec->erase(pPointVec->begin()+minp1);
- }
+ //Record min distance
+ FindClosestPoints(&minp1, &minp2, &mind, pPointVec);
+ // For disk surfels, we'd use mind as a radius, however, for triangles
+ // we need to solve for the correct distance from the center to each
+ // equilateral vertex such that the surface area is preserved.
+ // Note: we also multiply by 2 to cover any gaps.
+ *minDist = 2.f*sqrt((3.14159265359*mind*mind) / 1.29903810568);
- //Record min distance
- FindClosestPoints(&minp1, &minp2, &mind, pPointVec);
- // For disk surfels, we'd use mind as a radius, however, for triangles
- // we need to solve for the correct distance from the center to each
- // equilateral vertex such that the surface area is preserved.
- // Note: we also multiply by 2 to cover any gaps.
- *minDist = 0.5f*sqrt((3.14159265359*mind*mind) / 1.29903810568);
+ return pPointVec;
+ }
- return pPointVec;
+ void
+ GenerateSurfels(std::vector<GeomObjectPtr>& surfels, const SceneDescription& scene, Triangle& tri) {
+ // Use raw triangles and average color of 3 vertex
+// float oneThird = 1.f/3.f;
+// glm::vec3 v0 = tri.getVertex0(), v1 = tri.getVertex1(), v2 = tri.getVertex2();
+// glm::vec3 center(oneThird * (v0.x + v1.x + v2.x), oneThird * (v0.y + v1.y + v2.y), oneThird * (v0.z + v1.z + v2.z));
+// Intersection intrs;
+// intrs.n = tri.getNormal();
+// intrs.p = v0;
+// intrs.incDir = -intrs.n;
+// intrs.surf = Surface(tri.getColor(), tri.getFinish());
+// glm::vec3 color1 = Tracer::CalcDirectIllum(intrs, scene, 0);
+// color1 = glm::clamp(color1, 0.f, FLT_MAX);
+// intrs.p = v1;
+// glm::vec3 color2 = Tracer::CalcDirectIllum(intrs, scene, 0);
+// color2 = glm::clamp(color2, 0.f, FLT_MAX);
+// intrs.p = v2;
+// glm::vec3 color3 = Tracer::CalcDirectIllum(intrs, scene, 0);
+// color3 = glm::clamp(color3, 0.f, FLT_MAX);
+// surfels.push_back(TrianglePtr(new Triangle(v0, v1, v2, glm::vec4((color1+color2+color3)*oneThird,1.f), glm::mat4(1.f), tri.getFinish())));
+ float minDist = 0.f;
+ boost::shared_ptr< std::vector<glm::vec3> > pPoints = GenerateDistributedPoints(500, tri, 100000, &minDist);
+ std::vector<glm::vec3>::const_iterator cit = pPoints->begin();
+ for (; cit != pPoints->end(); ++cit) {
+ glm::vec3 n = tri.getNormal();
+ glm::vec3 tan = glm::normalize(tri.getVertex0()-tri.getVertex1());
+ glm::vec3 v0,v1,v2;
+ float randDegreeOffset = unifRand(0.f, 359.f);
+ v0 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset, n);
+ v1 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset + 120.f, n);
+ v2 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset + 240.f, n);
+ Intersection intrs;
+ intrs.n = n;
+ intrs.p = *cit;
+ intrs.incDir = -n;
+ intrs.surf = Surface(tri.getColor(), tri.getFinish());
+ glm::vec3 color = Tracer::CalcDirectIllum(intrs, scene, 0);
+ color = glm::clamp(color, 0.f, FLT_MAX);
+ surfels.push_back(TrianglePtr(new Triangle(v0, v1, v2, glm::vec4(color,1.f), glm::mat4(1.f), tri.getFinish())));
+// surfels.push_back(DiskPtr(new Disk(*cit, n, minDist, sphere.getColor(), glm::mat4(1.f), sphere.getFinish())));
+ }
}
/*
@@ -169,13 +213,13 @@ namespace RDST
// we need to solve for the correct distance from the center to each
// equilateral vertex such that the surface area is preserved.
// Note: we also multiply by 2 to cover any gaps.
- *minDist = 0.5f*sqrt((3.14159265359*mind*mind) / 1.29903810568);
+ *minDist = 2.f*sqrt((3.14159265359*mind*mind) / 1.29903810568);
return pPointVec;
}
void
- GenerateSurfels(std::vector<GeomObjectPtr>& surfels, Box& box) {
+ GenerateSurfels(std::vector<GeomObjectPtr>& surfels, const SceneDescription& scene, Box& box) {
float minDist = 0.f;
boost::shared_ptr< std::vector<glm::vec4> > pPoints = GenerateDistributedPoints(500, box, &minDist);
std::vector<glm::vec4>::const_iterator cit = pPoints->begin();
@@ -201,7 +245,15 @@ namespace RDST
v0 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset, n);
v1 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset + 120.f, n);
v2 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset + 240.f, n);
- surfels.push_back(TrianglePtr(new Triangle(v0, v1, v2, box.getColor(), glm::mat4(1.f), box.getFinish())));
+ Intersection intrs;
+ intrs.n = n;
+ intrs.p = glm::vec3(*cit);
+ intrs.incDir = -n;
+ intrs.surf = Surface(box.getColor(), box.getFinish());
+ glm::vec3 color = Tracer::CalcDirectIllum(intrs, scene, 0);
+// printf("%f %f %f\n", color.r, color.g, color.b);
+ color = glm::clamp(color, 0.f, FLT_MAX);
+ surfels.push_back(TrianglePtr(new Triangle(v0, v1, v2, glm::vec4(color,1.f), glm::mat4(1.f), box.getFinish())));
// surfels.push_back(DiskPtr(new Disk(glm::vec3(*cit), n, minDist, box.getColor(), glm::mat4(1.f), box.getFinish())));
}
}
@@ -256,13 +308,13 @@ namespace RDST
// we need to solve for the correct distance from the center to each
// equilateral vertex such that the surface area is preserved.
// Note: we also multiply by 2 to cover any gaps.
- *minDist = 0.5f*sqrt((3.14159265359*mind*mind) / 1.29903810568);
+ *minDist = 2.f*sqrt((3.14159265359*mind*mind) / 1.29903810568);
return p;
}
void
- GenerateSurfels(std::vector<GeomObjectPtr>& surfels, Sphere& sphere) {
+ GenerateSurfels(std::vector<GeomObjectPtr>& surfels, const SceneDescription& scene, Sphere& sphere) {
float minDist = 0.f;
boost::shared_ptr< std::vector<glm::vec3> > pPoints = GenerateDistributedPoints(500, sphere, 100000, &minDist);
std::vector<glm::vec3>::const_iterator cit = pPoints->begin();
@@ -275,7 +327,14 @@ namespace RDST
v0 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset, n);
v1 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset + 120.f, n);
v2 = glm::vec3(*cit) + minDist*glm::rotate(tan, randDegreeOffset + 240.f, n);
- surfels.push_back(TrianglePtr(new Triangle(v0, v1, v2, sphere.getColor(), glm::mat4(1.f), sphere.getFinish())));
+ Intersection intrs;
+ intrs.n = n;
+ intrs.p = *cit;
+ intrs.incDir = -n;
+ intrs.surf = Surface(sphere.getColor(), sphere.getFinish());
+ glm::vec3 color = Tracer::CalcDirectIllum(intrs, scene, 0);
+ color = glm::clamp(color, 0.f, FLT_MAX);
+ surfels.push_back(TrianglePtr(new Triangle(v0, v1, v2, glm::vec4(color,1.f), glm::mat4(1.f), sphere.getFinish())));
// surfels.push_back(DiskPtr(new Disk(*cit, n, minDist, sphere.getColor(), glm::mat4(1.f), sphere.getFinish())));
}
}
View
36 src/RDSSurfelCloud.h
@@ -1,36 +0,0 @@
-/**
- * RDSSurfelCloud.h
- * --------------------
- * A Surfel Cloud representation.
- * Author: Ryan Schmitt
- */
-
-#ifndef __RDS_SURFEL_CLOUD_H__
-#define __RDS_SURFEL_CLOUD_H__
-
-#include "RDSScene.h"
-#include <glm/glm.hpp>
-#include <boost/shared_ptr.hpp>
-
-namespace RDST
-{
- /**
- * Surfel Cloud class.
- */
- class SurfelCloud
- {
- public:
- explicit SurfelCloud(GeomObjectPtrListPtr pGeomObjects)
- : _pRawSurfelList(pGeomObjects)
- {}
-
- //Non-mutable
- const std::vector<GeomObjectPtr>& rawSurfels() const
- { return *_pRawSurfelList; }
-
- private:
- GeomObjectPtrListPtr _pRawSurfelList;
- };
- typedef boost::shared_ptr<SurfelCloud> SurfelCloudPtr;
-}
-#endif
View
54 src/RDSSurfelGen.h
@@ -0,0 +1,54 @@
+/**
+ * RDSSurfelGen.h
+ * --------------------
+ * Generates a surfel cloud.
+ * Author: Ryan Schmitt
+ */
+
+#ifndef __RDS_SURFEL_GEN_H__
+#define __RDS_SURFEL_GEN_H__
+
+#include "RDSPointDistribution.h"
+#include "RDSScene.h"
+#include <glm/glm.hpp>
+#include <boost/shared_ptr.hpp>
+
+namespace RDST
+{
+ /**
+ * Surfel Generator class.
+ */
+ class SurfelGenerator
+ {
+ private:
+ /* Hidden ctors */
+ explicit SurfelGenerator()
+ {}
+ explicit SurfelGenerator(const SurfelGenerator& rhs)
+ {}
+ ~SurfelGenerator()
+ {}
+
+ public:
+ static void GenerateSurfels(SceneDescription& scene) {
+ boost::shared_ptr< std::vector<GeomObjectPtr> > surfels(new std::vector<GeomObjectPtr>());
+ std::vector<GeomObjectPtr>::const_iterator cit = scene.objs().begin();
+ for (; cit != scene.objs().end(); ++cit) {
+ Sphere* pSphere = dynamic_cast<Sphere*>(cit->get());
+ Triangle* pTriangle = dynamic_cast<Triangle*>(cit->get());
+ Box* pBox = dynamic_cast<Box*>(cit->get());
+ if (pSphere != NULL) {
+ RDST::GenerateSurfels(*surfels, scene, *pSphere);
+ }
+ else if (pTriangle != NULL) {
+ RDST::GenerateSurfels(*surfels, scene, *pTriangle);
+ }
+ else if (pBox != NULL) {
+ RDST::GenerateSurfels(*surfels, scene, *pBox);
+ }
+ }
+ scene.setSurfelCloud(surfels);
+ }
+ };
+}
+#endif
View
39 src/RDSTracer.cpp
@@ -245,10 +245,45 @@ namespace RDST
indirect = IndirectIllumSurfelRaster(intrs, scene);
}
-// return (direct + reflection + refraction) + (PI*indirect);
- return (direct + reflection + refraction) + (indirect);
+// return indirect;
+ return (direct + reflection + refraction) + (PI*indirect);
+// return (direct + reflection + refraction) + (indirect);
}
+// glm::vec3 Tracer::ShadePointNoIndirect(const Intersection& intrs, const SceneDescription& scene, unsigned int recursionsLeft)
+// {
+// //return (intrs.n+1.f) * 0.5f;
+// //Reflection
+// float reflAmt = intrs.surf.finish.getReflection();
+// glm::vec3 reflection(0.f);
+// if (reflAmt > 0.f) {
+// reflection = reflAmt * CalcReflection(intrs, scene, recursionsLeft);
+// reflection = glm::clamp(reflection, 0.f, FLT_MAX);
+// }
+//
+// //Refraction
+// float refrAmt = 0.f;
+// glm::vec3 refraction(0.f);
+// if (intrs.surf.finish.getRefraction() > 0.f) {
+// refrAmt = intrs.surf.color.a;
+// refraction = CalcRefraction(intrs, scene, recursionsLeft);
+// if (glm::length(refraction) <= 0.f)
+// refrAmt = 0.f;
+// else
+// refraction = glm::clamp(refrAmt*refraction, 0.f, FLT_MAX);
+// }
+//
+// //Direct illumination
+// float dirAmt = 1.f - reflAmt - refrAmt;
+// glm::vec3 direct(0.f);
+// if (dirAmt > 0.f) {
+// direct = dirAmt * CalcDirectIllum(intrs, scene, recursionsLeft);
+// direct = glm::clamp(direct, 0.f, FLT_MAX);
+// }
+//
+// return (direct + reflection + refraction);
+// }
+
void Tracer::DoAreaLights(glm::vec3& ambient, glm::vec3& diffuse, glm::vec3& specular, const Intersection& intrs, const SceneDescription& scene)
{
//For each light
View
48 src/main.cpp
@@ -17,6 +17,7 @@
#include "RDSbvh.h"
#include "RandUtil.h"
#include "realtime_surfels.h"
+#include "RDSSurfelGen.h"
#include <glew.h>
#include <GLUT/glut.h>
@@ -122,31 +123,32 @@ int main(int argc, char** argv)
RDST::Image img(opts.width, opts.height, opts.enableGammaCorrection, opts.gamma);
RDST::SceneDescription desc = RDST::POVRayParser::ParseFile(opts.povRayFile);
desc.setOpts(opts);
-
-// int argc2 = 0;
-// char** argv2;
-// glutInit(&argc2, argv2);
-// glutInitWindowSize(8, 8); // 8x8 cube faces, not that this setting matters for the FBO
-// glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
-// glutCreateWindow("Surfel Rasterizing");
-// glEnable(GL_DEPTH_TEST);
-// glEnable(GL_NORMALIZE);
-// glClearColor(0.0, 0.0, 0.0, 1.0);
-// glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
-// glEnable(GL_COLOR_MATERIAL);
-// glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
-//
-// //Error check
-// GLenum err = glewInit();
-// if (err != GLEW_OK || !glewIsSupported("GL_VERSION_2_0")) {
-// printf("OpenGL 2.0 not supported. No shaders!\n");
-// printf("%s\n", glewGetErrorString(err));
-// printf("%s\n", (char*)glGetString( GL_VERSION ) );
-// exit(-1);
-// }
-// printf("OpenGL 2.0 supported. Using OpenGL %s \n\n",(char*)glGetString( GL_VERSION ));
+ RDST::SurfelGenerator::GenerateSurfels(desc);
if (!opts.realtime) {
+ int argc2 = 0;
+ char** argv2;
+ glutInit(&argc2, argv2);
+ glutInitWindowSize(8, 8); // 8x8 cube faces, not that this setting matters for the FBO
+ glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH);
+ glutCreateWindow("Surfel Rasterizing");
+ glEnable(GL_DEPTH_TEST);
+ glEnable(GL_NORMALIZE);
+ glClearColor(0.0, 0.0, 0.0, 1.0);
+ glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
+ glEnable(GL_COLOR_MATERIAL);
+ glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
+
+ //Error check
+ GLenum err = glewInit();
+ if (err != GLEW_OK || !glewIsSupported("GL_VERSION_2_0")) {
+ printf("OpenGL 2.0 not supported. No shaders!\n");
+ printf("%s\n", glewGetErrorString(err));
+ printf("%s\n", (char*)glGetString( GL_VERSION ) );
+ exit(-1);
+ }
+ printf("OpenGL 2.0 supported. Using OpenGL %s \n\n",(char*)glGetString( GL_VERSION ));
+
RDST::Tracer::RayTrace(desc, img);
img.writeToDisk(opts.imgname);
}
View
11 src/realtime_surfels.cpp
@@ -151,7 +151,9 @@ void RealtimeSurfels::view() {
void RealtimeSurfels::lights() {
/* LIGHTS */
- glEnable(GL_LIGHTING);
+// glEnable(GL_LIGHTING);
+ glDisable(GL_LIGHTING);
+ return;
int i=0;
unsigned int curLight = GL_LIGHT0;
for(std::vector<PointLightPtr>::const_iterator it = desc->lights().begin(); it != desc->lights().end(); ++it) {
@@ -162,10 +164,11 @@ void RealtimeSurfels::lights() {
//Point light position
GLfloat lightPos[] = {lpos.x, lpos.y, lpos.z, 0.0};
//Ambient composition
-// GLfloat ambientComp[] = {lcolor.r, lcolor.g, lcolor.b, 0.0};
- GLfloat ambientComp[] = {0.0, 0.0, 0.0, 0.0};
+ GLfloat ambientComp[] = {lcolor.r, lcolor.g, lcolor.b, 0.0};
+// GLfloat ambientComp[] = {0.0, 0.0, 0.0, 0.0};
//Diffuse composition
- GLfloat diffuseComp[] = {lcolor.r, lcolor.g, lcolor.b, 0.0};
+// GLfloat diffuseComp[] = {lcolor.r, lcolor.g, lcolor.b, 0.0};
+ GLfloat diffuseComp[] = {0.0, 0.0, 0.0, 0.0};
//Specular composition
GLfloat specularComp[] = {0.0, 0.0, 0.0, 0.0};
//Ambient light
Please sign in to comment.
Something went wrong with that request. Please try again.