From 634beba7a27b27b9c4304b03c4cb1b39bde42931 Mon Sep 17 00:00:00 2001 From: Ben Date: Sat, 21 Sep 2019 21:53:14 +0100 Subject: [PATCH] tweaks - need to add new renderes --- .../material.hpp | 37 +++++++++++++++ resources/models/cornell-box.mtl | 45 +++---------------- src/definitions/materials/material.hpp | 2 +- src/engine/progressiverenderer.cpp | 19 +++----- test/stanford_dragon_cornell.cpp | 3 ++ 5 files changed, 55 insertions(+), 51 deletions(-) create mode 100644 enc_temp_folder/c9f4116a2f82234d49d6f64d789f833/material.hpp diff --git a/enc_temp_folder/c9f4116a2f82234d49d6f64d789f833/material.hpp b/enc_temp_folder/c9f4116a2f82234d49d6f64d789f833/material.hpp new file mode 100644 index 0000000..dcd5e3b --- /dev/null +++ b/enc_temp_folder/c9f4116a2f82234d49d6f64d789f833/material.hpp @@ -0,0 +1,37 @@ +#ifndef INFERNO_DEFINITIONS_MATERIALS_MATERIAL_H_ +#define INFERNO_DEFINITIONS_MATERIALS_MATERIAL_H_ + +#include "../../common.hpp" +#include "../../maths.hpp" + +class Texture; + +class Material { +public: + Material(); + Material(glm::vec3 col, float specularity = 0.0f, float emmitance = 0.0f); + Material(glm::vec3 colour, float emittance, float Specularity, float index, float gloss, bool transparent, bool emissive); + + glm::vec3 Bounce(glm::vec3 in, glm::vec3 normal); + + glm::vec3 Colour; + Texture* Tex = nullptr; + Texture* NormalTexture = nullptr; + Texture* GlossTexture = nullptr; + float Emittance; + float Specularity; // 1.0f = perfect reflective + float Index; // refractive index + float Gloss; // reflection cone angle in radians + // float Tint; // specular and refractive tinting + // float Reflectivity; // metallic reflection + bool Transparent; + bool Emissive; +}; + +class GlossyMaterial : public Material { +public: + GlossyMaterial(glm::vec3 colour, float shine, float gloss) + : Material(colour, 0.0f, shine, 1.0f, gloss, false, false) { }; +}; + +#endif diff --git a/resources/models/cornell-box.mtl b/resources/models/cornell-box.mtl index 51dbc69..f1b7599 100644 --- a/resources/models/cornell-box.mtl +++ b/resources/models/cornell-box.mtl @@ -4,61 +4,30 @@ newmtl backWall Ns 9.803922 Ka 0.705000 0.705000 0.705000 -Kd 0.900000 0.900000 0.900000 -Ks 0.000000 0.000000 0.000000 -Ke 0.000000 0.000000 0.000000 -Ni 1.000000 -d 1.000000 -#illum 2 +Kd 0.725 0.71 0.68 newmtl ceiling Ns 9.803922 Ka 0.705000 0.705000 0.705000 -Kd 0.900000 0.900000 0.900000 -Ks 0.000000 0.000000 0.000000 -Ke 0.000000 0.000000 0.000000 -Ni 1.000000 -d 1.000000 -#illum 2 +Kd 0.725 0.71 0.68 newmtl floor Ns 9.803922 Ka 0.705000 0.705000 0.705000 -Kd 0.900000 0.900000 0.900000 -Ks 0.000000 0.000000 0.000000 -Ke 0.000000 0.000000 0.000000 -Ni 1.000000 -d 1.000000 -#illum 2 +Kd 0.725 0.71 0.68 newmtl leftWall Ns 9.803922 Ka 0.248333 0.248333 0.248333 -Kd 1.000000 0.000000 0.000000 -#Kd 0.750000 0.250000 0.250000 -Ks 0.000000 0.000000 0.000000 -Ke 0.000000 0.000000 0.000000 -Ni 1.500000 -d 1.000000 -#illum 2 +Kd 0.63 0.065 0.05 newmtl light Ns 9.803922 Ka 0.780000 0.780000 0.780000 -Kd 0.900000 0.900000 0.900000 -Ks 0.000000 0.000000 0.000000 -Ke 0.000000 0.000000 0.000000 -Ni 1.000000 -d 1.000000 -illum 30 +Kd 85.0 60.0 20.0 +illum 1 newmtl rightWall Ns 9.803922 Ka 0.227000 0.227000 0.227000 -Kd 0.000000 1.000000 0.000000 -#Kd 0.250000 0.250000 0.750000 -Ks 0.000000 0.000000 0.000000 -Ke 0.000000 0.000000 0.000000 -Ni 1.500000 -d 1.000000 -#illum 2 +Kd 0.14 0.45 0.091 diff --git a/src/definitions/materials/material.hpp b/src/definitions/materials/material.hpp index dcd5e3b..1abb56c 100644 --- a/src/definitions/materials/material.hpp +++ b/src/definitions/materials/material.hpp @@ -21,7 +21,7 @@ public: float Emittance; float Specularity; // 1.0f = perfect reflective float Index; // refractive index - float Gloss; // reflection cone angle in radians + float Gloss; // specular lobe angle in radians // float Tint; // specular and refractive tinting // float Reflectivity; // metallic reflection bool Transparent; diff --git a/src/engine/progressiverenderer.cpp b/src/engine/progressiverenderer.cpp index 9e5e1a6..35f64df 100644 --- a/src/engine/progressiverenderer.cpp +++ b/src/engine/progressiverenderer.cpp @@ -40,19 +40,14 @@ void ProgressiveRenderer::Input() { const Uint8* state = SDL_GetKeyboardState(NULL); - //glm::vec3 pos = m_scene->objects[0]->center; - //if (state[SDL_SCANCODE_W]) m_scene->objects[0]->center.y += 0.01f; - //if (state[SDL_SCANCODE_S]) m_scene->objects[0]->center.y -= 0.01f; - //if (state[SDL_SCANCODE_D]) m_scene->objects[0]->center.x += 0.01f; - //if (state[SDL_SCANCODE_A]) m_scene->objects[0]->center.x -= 0.01f; - //if (state[SDL_SCANCODE_R]) m_scene->objects[0]->center.z += 0.01f; - //if (state[SDL_SCANCODE_F]) m_scene->objects[0]->center.z -= 0.01f; - //glm::vec3 newpos = m_scene->objects[0]->center; + //if (state[SDL_SCANCODE_W]) m_scene->objects[0]->center.y += 0.001f; + //if (state[SDL_SCANCODE_S]) m_scene->objects[0]->center.y -= 0.001f; + //if (state[SDL_SCANCODE_D]) m_scene->objects[0]->center.x += 0.001f; + //if (state[SDL_SCANCODE_A]) m_scene->objects[0]->center.x -= 0.001f; + //if (state[SDL_SCANCODE_R]) m_scene->objects[0]->center.z += 0.001f; + //if (state[SDL_SCANCODE_F]) m_scene->objects[0]->center.z -= 0.001f; - //if (newpos.x != pos.x || newpos.y != pos.y || newpos.z != pos.z) { - // m_threadPool->ThreadFrameBuffer->ClearFramebuffer(); - // m_engine->SPP = 0; m_engine->SPPDepth = 0; - //} + //std::cout << m_scene->objects[0]->center.x << " " << m_scene->objects[0]->center.y << " " << m_scene->objects[0]->center.z << std::endl; if (!m_interface->ImGui) return; diff --git a/test/stanford_dragon_cornell.cpp b/test/stanford_dragon_cornell.cpp index 9dcc6bc..f43028b 100644 --- a/test/stanford_dragon_cornell.cpp +++ b/test/stanford_dragon_cornell.cpp @@ -18,6 +18,9 @@ int main(int argc, char** argv) { Sky* sky = new SolidSky({ 0.0f, 0.0f, 0.0f }, 0.0f); scene->sky = sky; + Sphere* sphere = new Sphere({ -0.302, -0.385999, -3.74202 }, 0.03f, new Material({ 0.345f, 0.133f, 0.050f }, 300.0f, 0.0f, 0.0f, 0.0f, false, true)); + scene->objects.push_back(sphere); + Plane* plane = new Plane({ 0.0f, 0.0f, 0.0f }, { 0.0f, 0.0f, 1.0f }, new Material({ 1.0f, 1.0f, 1.0f }, 0.0f, 0.0f, 0.0f, 0.0f, false, false)); scene->objects.push_back(plane);