Light primative

This commit is contained in:
Ben
2019-12-04 20:40:45 +00:00
parent 76402afec1
commit b3c74832b3
5 changed files with 18 additions and 25 deletions

View File

@@ -12,7 +12,7 @@ add_definitions(-DRESOURCES="${CMAKE_SOURCE_DIR}/resources/")
set(executable output)
set(SrcDIR ./src)
set(TestDIR ./test)
set(CurrentTest stanford_dragon_cornell.cpp)
set(CurrentTest main.cpp)
set(IncludeDIR ./include)

View File

@@ -39,4 +39,10 @@ public:
: Material(colour, 0.0f, 0.0f, 1.0f, 0.0f, false, false) { };
};
class Light : public Material {
public:
Light(glm::vec3 colour, float intensity)
: Material(colour, intensity, 0.0f, 1.0f, 0.0f, false, false) { };
};
#endif

View File

@@ -18,7 +18,8 @@ int main(int argc, char** argv) {
Sky* sky = new SolidSky({ 0.0f, 0.0f, 0.0f }, 0.0f);
scene->sky = sky;
Material* mat = new GlossyMaterial({ 1.0f, 1.0f, 1.0f }, 0.2f, fastDegreetoRadian(30.0f));
// Material* mat = new GlossyMaterial({ 1.0f, 1.0f, 1.0f }, 0.2f, fastDegreetoRadian(30.0f));
Material* mat = new MatteMaterial({ 1.0f, 1.0f, 1.0f });
std::string models = RESOURCES + std::string("//models//");
std::string lucy = RESOURCES + std::string("//models//lucy.obj");

View File

@@ -18,26 +18,12 @@ int main(int argc, char** argv) {
Scene* scene = new Scene(width, height);
Sky* sky = new GradientSky({ 35.0f / 255.0f, 148.0f / 255.0f, 235.0f / 255.0f }, { 1.0f, 1.0f, 1.0f }, 3.0f);
scene->sky = sky;
scene->sky = new GradientSky({ 35.0f / 255.0f, 148.0f / 255.0f, 235.0f / 255.0f }, { 1.0f, 1.0f, 1.0f }, 3.0f);;
scene->camera = new Camera(width, height);
//Sphere sphere1({ 1.3f, -0.8f, -5.0f }, 0.2f, new Material({ 0.817f, 0.374, 0.574 }));
//scene->objects.push_back(&sphere1);
Sphere sphere({ -2.1f, 0.0f, -8.0f }, 1.0f, new Material({ 0.817f, 0.374, 0.574 }, 0.0f, 0.0f, 0.0f, 0.0f, false, false));
scene->objects.push_back(&sphere);
Sphere sphere1({ 0.0f, 0.0f, -8.0f }, 1.0f, new GlossyMaterial({ 0.817f, 0.374, 0.574 }, 0.7f, fastDegreetoRadian(30.0f)));
scene->objects.push_back(&sphere1);
Sphere sphere2({ 2.1f, 0.0f, -8.0f }, 1.0f, new GlossyMaterial({ 0.817f, 0.374, 0.574 }, 0.7f, fastDegreetoRadian(60.0f)));
scene->objects.push_back(&sphere2);
Sphere light({ 35.0f, 50.0f, 25.0f }, 25.0f, new Material({ 1.0f, 1.0f, 1.0f }, 100.0f, 0.0f, 1.5f, 0.0f, false, true));
scene->objects.push_back(&light);
Plane plane({ 0.0f, -1.0f, 0.0f }, { 0.0f, -1.0f, 0.0f }, new Material({ 0.2f, 0.2f, 0.2f }, 0.0f, 0.0f, 1.5f, 0.0f, false, false));
scene->objects.push_back(&plane);
scene->objects.push_back(new Sphere({ 0.0f, 0.0f, -6.0f }, 1.0f, new MatteMaterial({ 0.2f, 0.2f, 0.2f })));
scene->objects.push_back(new Sphere({ -5.0f, -5.0f, -1.0f }, 1.0f, new Light({ 0.2f, 0.2f, 0.2f }, 5.0f)));
inferno.SetScene(scene);

View File

@@ -26,13 +26,13 @@ int main(int argc, char** argv) {
std::string cornell = RESOURCES + std::string("//models//cornell-box.obj");
// Material* mat = new GlossyMaterial({ 1.0f, 1.0f, 1.0f }, 0.2f, fastDegreetoRadian(30.0f));
Material* mat = new MatteMaterial({ 1.0f, 1.0f, 1.0f });
std::vector<Triangle*> tris = LoadTrianglesBasic(dragon, models, mat);
// Material* mat = new MatteMaterial({ 1.0f, 1.0f, 1.0f });
// std::vector<Triangle*> tris = LoadTrianglesBasic(dragon, models, mat);
Mesh* mesh = new Mesh(tris);
mesh->Translate({ 0.01f, -1.0, -3.6f });
mesh->Optimise();
scene->meshs.push_back(mesh);
// Mesh* mesh = new Mesh(tris);
// mesh->Translate({ 0.01f, -1.0, -3.6f });
// mesh->Optimise();
// scene->meshs.push_back(mesh);
std::vector<Triangle*> tris1 = LoadTrianglesBasic(cornell, models);