diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..063f330 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,5 @@ +*.obj +*.jpg +*.png +*.mtl +*.tga \ No newline at end of file diff --git a/BaseGLProject/BaseGLProject.vcxproj b/BaseGLProject/BaseGLProject.vcxproj index 1a8b4be..59b3131 100644 --- a/BaseGLProject/BaseGLProject.vcxproj +++ b/BaseGLProject/BaseGLProject.vcxproj @@ -174,7 +174,6 @@ - diff --git a/BaseGLProject/BaseGLProject.vcxproj.filters b/BaseGLProject/BaseGLProject.vcxproj.filters index d74ba42..fe72011 100644 --- a/BaseGLProject/BaseGLProject.vcxproj.filters +++ b/BaseGLProject/BaseGLProject.vcxproj.filters @@ -119,9 +119,6 @@ Header Files - - Header Files - imgui diff --git a/BaseGLProject/Light.cpp b/BaseGLProject/Light.cpp index d1f2601..e57e2c1 100644 --- a/BaseGLProject/Light.cpp +++ b/BaseGLProject/Light.cpp @@ -15,6 +15,8 @@ Light::Light(glm::vec3 intensity_, glm::vec4 location_, float spot_cutoff_, floa direction = lookAtPosition_; } +Light::Light() : location(glm::vec4(0)), intensity(glm::vec3(1)) +{} Light::~Light() { diff --git a/BaseGLProject/Light.h b/BaseGLProject/Light.h index 742dc8b..dd67c37 100644 --- a/BaseGLProject/Light.h +++ b/BaseGLProject/Light.h @@ -11,7 +11,7 @@ public: BASE, SPOT }; - + Light(); Light(glm::vec3 intensity, glm::vec4 location); Light(glm::vec3 intensity, glm::vec4 location, float spot_cutoff, float spot_inner_cutoff, diff --git a/BaseGLProject/Material.h b/BaseGLProject/Material.h deleted file mode 100644 index e310585..0000000 --- a/BaseGLProject/Material.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include - - -struct Material -{ - glm::vec3 ka; - glm::vec3 kd; - glm::vec3 ks; - float shininess; -}; \ No newline at end of file diff --git a/BaseGLProject/Models/Mesh.cpp b/BaseGLProject/Models/Mesh.cpp index 95082e2..e580137 100644 --- a/BaseGLProject/Models/Mesh.cpp +++ b/BaseGLProject/Models/Mesh.cpp @@ -93,7 +93,7 @@ Mesh::MeshEntry::MeshEntry(Dataset &set, Mesh *m) } -Mesh::MeshEntry::MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m) +Mesh::MeshEntry::MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m, std::string dirname) { renderType = OBJ; parent = m; @@ -121,8 +121,8 @@ Mesh::MeshEntry::MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m) glBindBuffer(GL_ARRAY_BUFFER, vbo[VERTEX_BUFFER]); glBufferData(GL_ARRAY_BUFFER, 3 * mesh->mNumVertices * sizeof(GLfloat), vertices, GL_STATIC_DRAW); - glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, NULL); - glEnableVertexAttribArray(0); + glVertexAttribPointer(VERTEX_BUFFER, 3, GL_FLOAT, GL_FALSE, 0, NULL); + glEnableVertexAttribArray(VERTEX_BUFFER); delete[] vertices; } @@ -139,8 +139,8 @@ Mesh::MeshEntry::MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m) glBindBuffer(GL_ARRAY_BUFFER, vbo[NORMAL_BUFFER]); glBufferData(GL_ARRAY_BUFFER, 3 * mesh->mNumVertices * sizeof(GLfloat), normals, GL_STATIC_DRAW); - glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, 0, NULL); - glEnableVertexAttribArray(1); + glVertexAttribPointer(NORMAL_BUFFER, 3, GL_FLOAT, GL_FALSE, 0, NULL); + glEnableVertexAttribArray(NORMAL_BUFFER); delete[] normals; } @@ -156,13 +156,12 @@ Mesh::MeshEntry::MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m) glBindBuffer(GL_ARRAY_BUFFER, vbo[TEXCOORD_BUFFER]); glBufferData(GL_ARRAY_BUFFER, 2 * mesh->mNumVertices * sizeof(GLfloat), texCoords, GL_STATIC_DRAW); - glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, 0, NULL); - glEnableVertexAttribArray(2); + glVertexAttribPointer(TEXCOORD_BUFFER, 2, GL_FLOAT, GL_FALSE, 0, NULL); + glEnableVertexAttribArray(TEXCOORD_BUFFER); delete[] texCoords; } - if (mesh->HasFaces()) { unsigned int *indices = new unsigned int[mesh->mNumFaces * 3]; for (unsigned int i = 0; i < mesh->mNumFaces; ++i) { @@ -175,8 +174,8 @@ Mesh::MeshEntry::MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo[INDEX_BUFFER]); glBufferData(GL_ELEMENT_ARRAY_BUFFER, 3 * mesh->mNumFaces * sizeof(GLuint), indices, GL_STATIC_DRAW); - glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, 0, NULL); - glEnableVertexAttribArray(3); + glVertexAttribPointer(INDEX_BUFFER, 3, GL_FLOAT, GL_FALSE, 0, NULL); + glEnableVertexAttribArray(INDEX_BUFFER); delete[] indices; } @@ -188,8 +187,6 @@ Mesh::MeshEntry::MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m) material->Get(AI_MATKEY_COLOR_DIFFUSE, dcolor); material->Get(AI_MATKEY_COLOR_AMBIENT, acolor); material->Get(AI_MATKEY_COLOR_SPECULAR, scolor); - - } glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -230,14 +227,15 @@ void Mesh::MeshEntry::render(SceneContext &ctx, Shader *shd) { glEnable(GL_TEXTURE_2D); - for (GLuint i = 0; i < shd->textures.size(); i++) + for (GLuint i = 0; i < parent->textures.size(); i++) { glActiveTexture(GL_TEXTURE0 + i); - glBindTexture(GL_TEXTURE_2D, shd->textures[i].tex_ref); + glBindTexture(GL_TEXTURE_2D, parent->textures[i].tex_ref); + shd->applyTextureMaterial(parent->textures[i]); shd->addUniform("tex[" + std::to_string(i) + "]", (int)i); } - if (shd->textures.size() > 0) - shd->addUniform("TexCount", (int)shd->textures.size()); + if (parent->textures.size() > 0) + shd->addUniform("TexCount", (int)parent->textures.size()); glBindVertexArray(vao); if (renderType == NO_INDEX) @@ -263,10 +261,12 @@ Mesh::Mesh(const char *filename, Shader *sh) std::string fullname; fullname = std::string("./Models/")+ std::string(filename); + std::string dirname = fullname; + dirname.resize(fullname.find_last_of('/')); Assimp::Importer importer; //aiProcessPreset_TargetRealtime_Fast const aiScene* scene = importer.ReadFile(fullname.c_str(), aiProcess_Triangulate | aiProcess_FlipUVs | aiProcess_GenSmoothNormals | aiProcess_OptimizeMeshes); - + // Check for errors if (!scene || scene->mFlags == AI_SCENE_FLAGS_INCOMPLETE || !scene->mRootNode) // if is Not Zero { @@ -274,8 +274,34 @@ Mesh::Mesh(const char *filename, Shader *sh) return; } + for (unsigned int i = 0; i < scene->mNumMaterials; i++) { + const aiMaterial* pMaterial = scene->mMaterials[i]; + if (pMaterial->GetTextureCount(aiTextureType_DIFFUSE) > 0) { //we only care diffuse texture + aiString Path; + if (pMaterial->GetTexture(aiTextureType_DIFFUSE, 0, &Path, NULL, NULL, NULL, + NULL, NULL) == AI_SUCCESS) { + + std::string FullPath = dirname + "/" + Path.data; //texture file + + aiColor3D diffuse; + aiColor3D specular; + aiColor3D ambient; + + pMaterial->Get(AI_MATKEY_COLOR_DIFFUSE, diffuse); + pMaterial->Get(AI_MATKEY_COLOR_SPECULAR, specular); + pMaterial->Get(AI_MATKEY_COLOR_AMBIENT, ambient); + textures.push_back(Texture(FullPath)); + textures.back().mat.enabled = true; + textures.back().mat.ka = glm::vec3(ambient.r, ambient.g, ambient.b); + textures.back().mat.kd = glm::vec3(diffuse.r, diffuse.g, diffuse.b); + textures.back().mat.ks = glm::vec3(specular.r, specular.g, specular.b); + } + } + } + + for (unsigned int i = 0; i < scene->mNumMeshes; ++i) { - meshEntries.push_back(new Mesh::MeshEntry(scene->mMeshes[i], scene, this)); + meshEntries.push_back(new Mesh::MeshEntry(scene->mMeshes[i], scene, this, dirname)); } } @@ -370,6 +396,11 @@ void Mesh::draw(SceneContext ctx) { shader->disable(); } +void Mesh::assignTexture(Texture &texture) +{ + textures.emplace_back(texture); +} + void Mesh::effectTransformations() { for (auto pair : _transformations) diff --git a/BaseGLProject/Models/Mesh.h b/BaseGLProject/Models/Mesh.h index 4520a8e..df50ff9 100644 --- a/BaseGLProject/Models/Mesh.h +++ b/BaseGLProject/Models/Mesh.h @@ -52,13 +52,14 @@ public: aiColor3D dcolor; aiColor3D acolor; aiColor3D scolor; + std::vector textures; float shininessStrength; - MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m); + MeshEntry(aiMesh *mesh, const aiScene* scene, Mesh * m, std::string dirname); MeshEntry(Dataset &set, Mesh *m); ~MeshEntry(); Mesh * parent; - void render(SceneContext &ctx, Shader * shd); + void render(SceneContext &ctx, Shader *shd); }; public: @@ -66,6 +67,7 @@ public: Mesh(Dataset &dataset, Shader *sh); ~Mesh(void); std::vector meshEntries; + std::vector textures; private: std::vector> _transformations; @@ -86,4 +88,5 @@ public: Shader *shader; void draw(SceneContext ctx); + void assignTexture(Texture &texture); }; \ No newline at end of file diff --git a/BaseGLProject/Models/mountain/ground_grass_3264_4062_Small.jpg b/BaseGLProject/Models/mountain/ground_grass_3264_4062_Small.jpg new file mode 100644 index 0000000..dc6eca0 Binary files /dev/null and b/BaseGLProject/Models/mountain/ground_grass_3264_4062_Small.jpg differ diff --git a/BaseGLProject/Models/mountain/mount.blend1.mtl b/BaseGLProject/Models/mountain/mount.blend1.mtl new file mode 100644 index 0000000..60a7e66 --- /dev/null +++ b/BaseGLProject/Models/mountain/mount.blend1.mtl @@ -0,0 +1,21 @@ +# Blender MTL File: 'mount.blend1.blend' +# Material Count: 2 + +newmtl Material +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.050977 0.050977 0.050977 +Ks 0.001641 0.001641 0.001641 +Ni 1.000000 +d 1.000000 +illum 2 + +newmtl Material.001 +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.640000 0.640000 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 1.000000 +illum 1 +map_Kd ground_grass_3264_4062_Small.jpg diff --git a/BaseGLProject/Models/sponza/sponza.mtl b/BaseGLProject/Models/sponza/sponza.mtl new file mode 100644 index 0000000..cefdb90 --- /dev/null +++ b/BaseGLProject/Models/sponza/sponza.mtl @@ -0,0 +1,306 @@ +# Blender MTL File: 'None' +# Material Count: 25 + +newmtl Material__25 +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/lion.tga +map_Disp textures/lion_ddn.tga +map_Ka textures/lion.tga + +newmtl Material__298 +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/background.tga +map_Disp textures/background_ddn.tga +map_Ka textures/background.tga + +newmtl Material__47 +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 + + +newmtl Material__57 +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd textures/vase_plant.tga +map_d textures/vase_plant_mask.tga +map_Ka textures/vase_plant.tga + +newmtl arch +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_arch_diff.tga +map_Ka textures/sponza_arch_diff.tga +map_Disp textures/sponza_arch_ddn.tga + +newmtl bricks +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/spnza_bricks_a_diff.tga +map_Disp textures/spnza_bricks_a_ddn.tga +map_Ka textures/spnza_bricks_a_diff.tga + +newmtl ceiling +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_ceiling_a_diff.tga +map_Ka textures/sponza_ceiling_a_diff.tga +map_Disp textures/sponza_ceiling_a_ddn.tga + +newmtl chain +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd textures/chain_texture.tga +map_d textures/chain_texture_mask.tga +map_Disp textures/chain_texture_ddn.tga +map_Ka textures/chain_texture.tga + +newmtl column_a +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_column_a_diff.tga +map_Disp textures/sponza_column_a_ddn.tga +map_Ka textures/sponza_column_a_diff.tga + +newmtl column_b +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_column_b_diff.tga +map_Disp textures/sponza_column_b_ddn.tga +map_Ka textures/sponza_column_b_diff.tga + +newmtl column_c +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_column_c_diff.tga +map_Disp textures/sponza_column_c_ddn.tga +map_Ka textures/sponza_column_c_diff.tga + +newmtl details +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_details_diff.tga +map_Ka textures/sponza_details_diff.tga +map_Disp textures/sponza_details_ddn.tga + +newmtl fabric_a +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_fabric_diff.tga +map_Ka textures/sponza_fabric_diff.tga +map_Disp textures/sponza_fabric_ddn.tga + +newmtl fabric_c +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_curtain_diff.tga +map_Ka textures/sponza_curtain_diff.tga +map_Disp textures/sponza_curtain_ddn.tga + + +newmtl fabric_d +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_fabric_blue_diff.tga +map_Ka textures/sponza_fabric_blue_diff.tga +map_Disp textures/sponza_fabric_ddn.tga + + +newmtl fabric_e +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_fabric_green_diff.tga +map_Ka textures/sponza_fabric_green_diff.tga +map_Disp textures/sponza_fabric_ddn.tga + + +newmtl fabric_f +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_curtain_green_diff.tga +map_Ka textures/sponza_curtain_green_diff.tga +map_Disp textures/sponza_curtain_ddn.tga + +newmtl fabric_g +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_curtain_blue_diff.tga +map_Ka textures/sponza_curtain_blue_diff.tga +map_Disp textures/sponza_curtain_ddn.tga + + +newmtl flagpole +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_flagpole_diff.tga +map_Ka textures/sponza_flagpole_diff.tga +map_Disp textures/sponza_flagpole_ddn.tga + +newmtl floor +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_floor_a_diff.tga +map_Ka textures/sponza_floor_a_diff.tga +map_Disp textures/sponza_floor_a_ddn.tga + +newmtl leaf +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd textures/sponza_thorn_diff.tga +map_d textures/sponza_thorn_mask.tga +map_Disp textures/sponza_thorn_ddn.tga +map_Ka textures/sponza_thorn_diff.tga + +newmtl roof +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/sponza_roof_diff.tga +map_Ka textures/sponza_roof_diff.tga +map_Ka textures/sponza_roof_ddn.tga + +newmtl vase +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/vase_dif.tga +map_Ka textures/vase_dif.tga +map_Disp textures/vase_ddn.tga + +newmtl vase_hanging +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/vase_hanging.tga +map_Ka textures/vase_hanging.tga +map_Disp textures/vase_hanging_ddn.tga + +newmtl vase_round +Ns 7.843137 +Ka 0.000000 0.000000 0.000000 +Kd 0.470400 0.470400 0.470400 +Ks 0.000000 0.000000 0.000000 +Ni 1.000000 +d 0.000000 +illum 2 +map_Kd textures/vase_round.tga +map_Disp textures/vase_round_ddn.tga +map_Ka textures/vase_round.tga diff --git a/BaseGLProject/Models/sponza/textures/Thumbs.db b/BaseGLProject/Models/sponza/textures/Thumbs.db new file mode 100644 index 0000000..70b4ac6 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/Thumbs.db differ diff --git a/BaseGLProject/Models/sponza/textures/background.tga b/BaseGLProject/Models/sponza/textures/background.tga new file mode 100644 index 0000000..19da1d3 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/background.tga differ diff --git a/BaseGLProject/Models/sponza/textures/background_ddn.tga b/BaseGLProject/Models/sponza/textures/background_ddn.tga new file mode 100644 index 0000000..3839936 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/background_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/chain_texture.tga b/BaseGLProject/Models/sponza/textures/chain_texture.tga new file mode 100644 index 0000000..297274b Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/chain_texture.tga differ diff --git a/BaseGLProject/Models/sponza/textures/chain_texture_ddn.tga b/BaseGLProject/Models/sponza/textures/chain_texture_ddn.tga new file mode 100644 index 0000000..c597acb Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/chain_texture_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/lion.tga b/BaseGLProject/Models/sponza/textures/lion.tga new file mode 100644 index 0000000..6888e9e Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/lion.tga differ diff --git a/BaseGLProject/Models/sponza/textures/lion2_ddn.tga b/BaseGLProject/Models/sponza/textures/lion2_ddn.tga new file mode 100644 index 0000000..8ab961f Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/lion2_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/lion_ddn.tga b/BaseGLProject/Models/sponza/textures/lion_ddn.tga new file mode 100644 index 0000000..16a1c78 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/lion_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/spnza_bricks_a_ddn.tga b/BaseGLProject/Models/sponza/textures/spnza_bricks_a_ddn.tga new file mode 100644 index 0000000..31dcfc2 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/spnza_bricks_a_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/spnza_bricks_a_diff.tga b/BaseGLProject/Models/sponza/textures/spnza_bricks_a_diff.tga new file mode 100644 index 0000000..2124b32 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/spnza_bricks_a_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_arch_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_arch_ddn.tga new file mode 100644 index 0000000..09851c6 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_arch_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_arch_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_arch_diff.tga new file mode 100644 index 0000000..01c425e Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_arch_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_ceiling_a_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_ceiling_a_ddn.tga new file mode 100644 index 0000000..5d7a0a4 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_ceiling_a_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_ceiling_a_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_ceiling_a_diff.tga new file mode 100644 index 0000000..16cfc25 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_ceiling_a_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_column_a_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_column_a_ddn.tga new file mode 100644 index 0000000..5a99322 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_column_a_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_column_a_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_column_a_diff.tga new file mode 100644 index 0000000..ba10c95 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_column_a_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_column_b_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_column_b_ddn.tga new file mode 100644 index 0000000..c716b38 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_column_b_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_column_b_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_column_b_diff.tga new file mode 100644 index 0000000..8478671 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_column_b_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_column_c_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_column_c_ddn.tga new file mode 100644 index 0000000..0c384e7 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_column_c_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_column_c_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_column_c_diff.tga new file mode 100644 index 0000000..61ea0c0 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_column_c_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_curtain_blue_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_curtain_blue_diff.tga new file mode 100644 index 0000000..6cd4c52 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_curtain_blue_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_curtain_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_curtain_ddn.tga new file mode 100644 index 0000000..16b8f4e Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_curtain_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_curtain_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_curtain_diff.tga new file mode 100644 index 0000000..af23d3e Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_curtain_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_curtain_green_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_curtain_green_diff.tga new file mode 100644 index 0000000..d8f9a28 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_curtain_green_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_details_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_details_ddn.tga new file mode 100644 index 0000000..3448ef9 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_details_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_details_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_details_diff.tga new file mode 100644 index 0000000..31b67d8 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_details_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_fabric_blue_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_fabric_blue_diff.tga new file mode 100644 index 0000000..7a37c26 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_fabric_blue_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_fabric_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_fabric_ddn.tga new file mode 100644 index 0000000..7628952 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_fabric_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_fabric_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_fabric_diff.tga new file mode 100644 index 0000000..c9f933a Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_fabric_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_fabric_green_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_fabric_green_diff.tga new file mode 100644 index 0000000..7693da3 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_fabric_green_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_flagpole_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_flagpole_ddn.tga new file mode 100644 index 0000000..c6d202f Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_flagpole_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_flagpole_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_flagpole_diff.tga new file mode 100644 index 0000000..8600a6b Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_flagpole_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_floor_a_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_floor_a_ddn.tga new file mode 100644 index 0000000..4ef1409 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_floor_a_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_floor_a_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_floor_a_diff.tga new file mode 100644 index 0000000..e9587e3 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_floor_a_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_roof_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_roof_ddn.tga new file mode 100644 index 0000000..72b1cbe Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_roof_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_roof_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_roof_diff.tga new file mode 100644 index 0000000..a8fd321 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_roof_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_thorn_ddn.tga b/BaseGLProject/Models/sponza/textures/sponza_thorn_ddn.tga new file mode 100644 index 0000000..2fee918 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_thorn_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/sponza_thorn_diff.tga b/BaseGLProject/Models/sponza/textures/sponza_thorn_diff.tga new file mode 100644 index 0000000..da77e00 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/sponza_thorn_diff.tga differ diff --git a/BaseGLProject/Models/sponza/textures/vase_ddn.tga b/BaseGLProject/Models/sponza/textures/vase_ddn.tga new file mode 100644 index 0000000..2f78759 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/vase_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/vase_dif.tga b/BaseGLProject/Models/sponza/textures/vase_dif.tga new file mode 100644 index 0000000..c147b37 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/vase_dif.tga differ diff --git a/BaseGLProject/Models/sponza/textures/vase_hanging.tga b/BaseGLProject/Models/sponza/textures/vase_hanging.tga new file mode 100644 index 0000000..8954561 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/vase_hanging.tga differ diff --git a/BaseGLProject/Models/sponza/textures/vase_hanging_ddn.tga b/BaseGLProject/Models/sponza/textures/vase_hanging_ddn.tga new file mode 100644 index 0000000..451250a Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/vase_hanging_ddn.tga differ diff --git a/BaseGLProject/Models/sponza/textures/vase_plant.tga b/BaseGLProject/Models/sponza/textures/vase_plant.tga new file mode 100644 index 0000000..6ddbe2f Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/vase_plant.tga differ diff --git a/BaseGLProject/Models/sponza/textures/vase_round.tga b/BaseGLProject/Models/sponza/textures/vase_round.tga new file mode 100644 index 0000000..6f83f61 Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/vase_round.tga differ diff --git a/BaseGLProject/Models/sponza/textures/vase_round_ddn.tga b/BaseGLProject/Models/sponza/textures/vase_round_ddn.tga new file mode 100644 index 0000000..dddc76a Binary files /dev/null and b/BaseGLProject/Models/sponza/textures/vase_round_ddn.tga differ diff --git a/BaseGLProject/MyGLWindow.cpp b/BaseGLProject/MyGLWindow.cpp index 7d54b7f..46799ca 100644 --- a/BaseGLProject/MyGLWindow.cpp +++ b/BaseGLProject/MyGLWindow.cpp @@ -62,9 +62,9 @@ void MyGlWindow::textureSetup() glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT); - _scnctx.textures.emplace("BrickTex", Texture("brick1.jpg", GL_RGB)); - _scnctx.textures.emplace("MossTex", Texture(std::string("moss.png"), GL_RGBA)); - _scnctx.textures.emplace("EarthTex", Texture("earth.jpg", GL_RGB)); + _scnctx.textures.emplace("BrickTex", Texture("brick1.jpg")); + _scnctx.textures.emplace("MossTex", Texture("moss.png")); + _scnctx.textures.emplace("EarthTex", Texture("earth.jpg")); } void MyGlWindow::shaderSetup() @@ -75,24 +75,18 @@ void MyGlWindow::shaderSetup() shaders["BaseLight"] = new Shader("base_light.vert", "base_light.frag"); shaders["Fog"] = new Shader("fog.vert", "fog.frag"); - shaders["BrickBaseLight"] = new Shader("tex_base_light.vert", "tex_base_light.frag"); - shaders["BrickBaseLight"]->assignTexture(_scnctx.textures["BrickTex"]); - shaders["BrickBaseLight"]->assignTexture(_scnctx.textures["MossTex"]); - - shaders["EarthBaseLight"] = new Shader("tex_base_light.vert", "tex_base_light.frag"); - shaders["EarthBaseLight"]->assignTexture(_scnctx.textures["EarthTex"]); + shaders["TexBaseLight"] = new Shader("tex_base_light.vert", "tex_base_light.frag"); shaders["SpotLight"] = new Shader("spotlight.vert", "spotlight.frag"); shaders["SpotLight"]->light_type = Light::LightType::SPOT; shaders["TexSpotLight"] = new Shader("tex_spotlight.vert", "tex_spotlight.frag"); shaders["TexSpotLight"]->light_type = Light::LightType::SPOT; - shaders["Silhouette"] = new Shader("silhouette.vert", "silhouette.frag"); shaders["Silhouette"]->uniformFlags = ShaderFlags::MVP_FLAG; shaders["Silhouette"]->addUniform("fColor", glm::vec3(237 / 255, 229 / 255, 194 / 255)); shaders["Silhouette"]->addUniform("sil_offset", 0.1f); - + shaders["Toon"] = new Shader("base_light.vert", "toon.frag"); //Removing useless specular component shaders["Toon"]->uniformFlags &= ~ShaderFlags::KS_FLAG; @@ -102,15 +96,15 @@ void MyGlWindow::shaderSetup() void MyGlWindow::lightSetup() { //Showcase lights - _scnctx.lights.emplace("Spotlight1", Light(glm::vec3(0.8f), glm::vec4(3, 10, 5, 1), - 24, 12, 2, glm::vec4(0, 1, 0, 1))); + _scnctx.lights.emplace("Spotlight1", Light(glm::vec3(0.8f), glm::vec4(0, 11, 4.3, 1))); + // 24, 12, 2, glm::vec4(0, 1, 0, 1))); //Party lights - /*_scnctx.lights.emplace("Light1", Light(glm::vec3(0.0f, 0.5f, 0.5f), glm::vec4(10, 10, 0, 1))); - _scnctx.lights.emplace("Light2", Light(glm::vec3(0.0f, 0.0f, 0.5f), glm::vec4(3.09, 10, 9.51, 1))); - _scnctx.lights.emplace("Light3", Light(glm::vec3(0.5f, 0.0f, 0.0f), glm::vec4(-8.09, 10, 5.87, 1))); - _scnctx.lights.emplace("Light4", Light(glm::vec3(0.0f, 0.5f, 0.0f), glm::vec4(-8.09, 10, -5.87, 1))); - _scnctx.lights.emplace("Light5", Light(glm::vec3(0.5f, 0.5f, 0.5f), glm::vec4(3.09, 10, -9.51, 1)));*/ + //_scnctx.lights.emplace("Light1", Light(glm::vec3(0.0f, 0.5f, 0.5f), glm::vec4(10, 10, 0, 1))); + //_scnctx.lights.emplace("Light2", Light(glm::vec3(0.0f, 0.0f, 0.5f), glm::vec4(3.09, 10, 9.51, 1))); + //_scnctx.lights.emplace("Light3", Light(glm::vec3(0.5f, 0.0f, 0.0f), glm::vec4(-8.09, 10, 5.87, 1))); + //_scnctx.lights.emplace("Light4", Light(glm::vec3(0.0f, 0.5f, 0.0f), glm::vec4(-8.09, 10, -5.87, 1))); + //_scnctx.lights.emplace("Light5", Light(glm::vec3(0.5f, 0.5f, 0.5f), glm::vec4(3.09, 10, -9.51, 1))); } void MyGlWindow::setup() @@ -118,27 +112,47 @@ void MyGlWindow::setup() textureSetup(); shaderSetup(); lightSetup(); - + + /* + meshes.emplace("Buddha", new Mesh("buddha.obj", shaders["BaseLight"])); + meshes["Buddha"]->addTranslation(glm::vec4(-4, 3, -4, 0)); + meshes["Buddha"]->addScaling(glm::vec4(4, 4, 4, 0)); + meshes["Buddha"]->addRotation(glm::vec4(0, 1, 0, 180)); + Dataset moddata; - moddata.checkeredFloor(20, 20, glm::vec3(0.1, 0.1, 0.1), glm::vec3(0.7, 0.7, 0.7)); - meshes.emplace("Floor", new Mesh(moddata, shaders["SpotLight"])); - meshes["Floor"]->addTranslation(glm::vec4(0, -0.05, 0, 1)); - meshes["Floor"]->cullMode = BACK; + moddata.simpleCube(); + meshes.emplace("Cube", new Mesh(moddata, shaders["TexBaseLight"])); + meshes["Cube"]->assignTexture(_scnctx.textures["BrickTex"]); + meshes["Cube"]->assignTexture(_scnctx.textures["MossTex"]); + meshes["Cube"]->addTranslation(glm::vec4(4, 3, -4, 0)); - /*moddata.simpleCube(); - meshes.emplace("Cube", new Mesh(moddata, shaders["BrickBaseLight"])); - meshes["Cube"]->addTranslation(glm::vec4(0, 1, 0, 1)); + meshes.emplace("Mountain", new Mesh("mountain/mount.blend1.obj", shaders["TexBaseLight"])); */ + meshes.emplace("Sponza", new Mesh("sponza/sponza.obj", shaders["TexBaseLight"])); + meshes["Sponza"]->addScaling(glm::vec4(0.2, 0.2, 0.2, 1)); + meshes["Sponza"]->cullMode = CullFace::BACK; - moddata.sphere(1, 100, 100); - meshes.emplace("Sphere", new Mesh(moddata, shaders["EarthBaseLight"])); - meshes["Sphere"]->addTranslation(glm::vec4(-5, 1, -3, 1)); + - meshes.emplace("TeapotSilhouette", new Mesh("teapot.obj", shaders["Silhouette"])); - meshes["TeapotSilhouette"]->addTranslation(glm::vec4(5, 0 ,3, 1)); - meshes["TeapotSilhouette"]->cullMode = FRONT; - meshes.emplace("Teapot", new Mesh("teapot.obj", shaders["Toon"])); - meshes["Teapot"]->addTranslation(glm::vec4(5, 0, 3, 1)); - meshes["Teapot"]->cullMode = BACK;*/ + //moddata.checkeredFloor(20, 20, glm::vec3(0.1, 0.1, 0.1), glm::vec3(0.7, 0.7, 0.7)); + //meshes.emplace("Floor", new Mesh(moddata, shaders["BaseLight"])); + //meshes["Floor"]->addTranslation(glm::vec4(0, -0.05, 0, 1)); + //meshes["Floor"]->cullMode = BACK; + + //moddata.simpleCube(); + //meshes.emplace("Cube", new Mesh(moddata, shaders["BrickBaseLight"])); + //meshes["Cube"]->addTranslation(glm::vec4(0, 1, 0, 1)); + + //moddata.sphere(1, 100, 100); + //meshes.emplace("Sphere", new Mesh(moddata, shaders["TexBaseLight"])); + //meshes["Sphere"]->assignTexture(_scnctx.textures["EarthTex"]); + //meshes["Sphere"]->addTranslation(glm::vec4(-5, 1, -3, 1)); + + //meshes.emplace("TeapotSilhouette", new Mesh("teapot.obj", shaders["Silhouette"])); + //meshes["TeapotSilhouette"]->addTranslation(glm::vec4(5, 0 ,3, 1)); + //meshes["TeapotSilhouette"]->cullMode = FRONT; + //meshes.emplace("Teapot", new Mesh("teapot.obj", shaders["Toon"])); + //meshes["Teapot"]->addTranslation(glm::vec4(5, 0, 3, 1)); + //meshes["Teapot"]->cullMode = BACK; } @@ -159,7 +173,7 @@ void MyGlWindow::draw() _scnctx.viewMatrix = view; _scnctx.projectionMatrix = projection; - _scnctx.adjustSpots(); + //_scnctx.adjustSpots(); for (auto it = meshes.begin(); it != meshes.end(); it++) (*it).second->draw(_scnctx); } diff --git a/BaseGLProject/MyGLWindow.h b/BaseGLProject/MyGLWindow.h index 7d5d7f8..4553bf8 100644 --- a/BaseGLProject/MyGLWindow.h +++ b/BaseGLProject/MyGLWindow.h @@ -31,8 +31,8 @@ public: void resize(int w, int h); Viewer viewer; -private: SceneContext _scnctx; +private: int m_width; int m_height; diff --git a/BaseGLProject/SceneContext.h b/BaseGLProject/SceneContext.h index 6f4847a..689a320 100644 --- a/BaseGLProject/SceneContext.h +++ b/BaseGLProject/SceneContext.h @@ -2,6 +2,7 @@ #include #include #include +#include #include "Texture.h" diff --git a/BaseGLProject/Shader.cpp b/BaseGLProject/Shader.cpp index 6f933a9..7f9d287 100644 --- a/BaseGLProject/Shader.cpp +++ b/BaseGLProject/Shader.cpp @@ -63,9 +63,8 @@ void Shader::setLights(SceneContext ctx) } i++; } - } - _program.addUniform("LightCount"); - glUniform1i(_program.uniform("LightCount"), i); + } + glUniform1i(_program.addUniform("LightCount"), i); } void Shader::setUniforms(SceneContext ctx) diff --git a/BaseGLProject/Shader.h b/BaseGLProject/Shader.h index df7cbad..079b690 100644 --- a/BaseGLProject/Shader.h +++ b/BaseGLProject/Shader.h @@ -6,11 +6,10 @@ #include #include "glm/gtc/type_ptr.hpp" -#include "Texture.h" -#include "Material.h" #include "Light.h" #include "SceneContext.h" #include "Loader.h" +#include "Texture.h" enum ShaderFlags { @@ -31,11 +30,10 @@ public: Shader() {}; Shader(const std::string vtx_name, const std::string frag_name); ~Shader(); - - std::vector textures; - int uniformFlags = KD_FLAG | KA_FLAG | KS_FLAG | SHINE_FLAG | MVP_FLAG | NORMAL_MAT_FLAG | MODELVIEW_FLAG | LIGHTS_FLAG; - Material mat; + + int uniformFlags = KD_FLAG | KA_FLAG | KS_FLAG | SHINE_FLAG | MVP_FLAG | NORMAL_MAT_FLAG | MODELVIEW_FLAG | LIGHTS_FLAG; Light::LightType light_type = Light::LightType::BASE; + Material mat; void enable(); void disable(); @@ -56,9 +54,14 @@ public: _program.use(); glUniform1fv(_program.addUniform(name), 1, &data); } - void assignTexture(Texture &texture) + void applyTextureMaterial(Texture &tex) { - textures.emplace_back(texture); + if (mat.enabled) + { + addUniform("Ka", tex.mat.ka); + addUniform("Kd", tex.mat.kd); + addUniform("Ks", tex.mat.ks); + } } private: @@ -68,5 +71,4 @@ private: private: ShaderProgram _program; -}; - +}; \ No newline at end of file diff --git a/BaseGLProject/Source.cpp b/BaseGLProject/Source.cpp index 7ac0683..204451d 100644 --- a/BaseGLProject/Source.cpp +++ b/BaseGLProject/Source.cpp @@ -175,9 +175,13 @@ int loop(GLFWwindow *window) { ImGui::SetWindowPos(ImVec2(20, 20)); - static float bgColor[3] = { .0f, .0f, .1f }; + static float bgColor[3] = { 0.6f, 0.6f, 0.9f }; ImGui::ColorEdit3("Background", bgColor, 0); glWin.setBgColor(bgColor); + + ImGui::SliderFloat("Light X", &(glWin._scnctx.lights["Spotlight1"].location.x), -20, 20); + ImGui::SliderFloat("Light Y", &(glWin._scnctx.lights["Spotlight1"].location.y), -20, 20); + ImGui::SliderFloat("Light Z", &(glWin._scnctx.lights["Spotlight1"].location.z), -20, 20); ImGui::End(); } diff --git a/BaseGLProject/Texture.cpp b/BaseGLProject/Texture.cpp index 625c8aa..965532d 100644 --- a/BaseGLProject/Texture.cpp +++ b/BaseGLProject/Texture.cpp @@ -1,6 +1,7 @@ -#include "Texture.h" +#include "Shader.h" +#include "imgui/stb_image.h" -Texture::Texture(std::string file_name, GLuint enum_rgb) +Texture::Texture(std::string file_name) { int width, height, channel; unsigned char * image; @@ -10,6 +11,8 @@ Texture::Texture(std::string file_name, GLuint enum_rgb) image = stbi_load(file_name.c_str(), &width, &height, &channel, 0); + GLuint enum_rgb = GL_RGB + (channel == 4); + glTexImage2D(GL_TEXTURE_2D, 0, enum_rgb, width, height, 0, enum_rgb, GL_UNSIGNED_BYTE, image); glGenerateMipmap(GL_TEXTURE_2D); @@ -23,6 +26,7 @@ Texture::Texture(const Texture &other) tex_ref = other.tex_ref; } + Texture::~Texture() { -} +} \ No newline at end of file diff --git a/BaseGLProject/Texture.h b/BaseGLProject/Texture.h index da6d9b5..6c7a667 100644 --- a/BaseGLProject/Texture.h +++ b/BaseGLProject/Texture.h @@ -1,19 +1,25 @@ #pragma once -#include #include -#include -#include "imgui/stb_image.h" +#include + +struct Material +{ + glm::vec3 ka; + glm::vec3 kd; + glm::vec3 ks; + float shininess; + bool enabled = false; + +}; class Texture { -public: +public: + Material mat; GLuint tex_ref; - Texture(std::string file_name, GLuint enum_rgb); - Texture(const Texture &other); + Texture(std::string file_name); + Texture(const Texture &other); Texture() {}; - ~Texture(); - - void sendUniform(GLuint uni); + ~Texture(); }; - diff --git a/BaseGLProject/default.jpg b/BaseGLProject/default.jpg new file mode 100644 index 0000000..de7f284 Binary files /dev/null and b/BaseGLProject/default.jpg differ diff --git a/BaseGLProject/imgui.ini b/BaseGLProject/imgui.ini index 7a9553e..fcb4f74 100644 --- a/BaseGLProject/imgui.ini +++ b/BaseGLProject/imgui.ini @@ -45,6 +45,6 @@ Collapsed=0 [Window][First Window] Pos=20,20 -Size=322,75 +Size=321,139 Collapsed=0