Assimp texture/material loading assignment
5
.gitattributes
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
*.obj
|
||||
*.jpg
|
||||
*.png
|
||||
*.mtl
|
||||
*.tga
|
||||
@ -174,7 +174,6 @@
|
||||
<ClInclude Include="imgui\stb_image.h" />
|
||||
<ClInclude Include="Light.h" />
|
||||
<ClInclude Include="Loader.h" />
|
||||
<ClInclude Include="Material.h" />
|
||||
<ClInclude Include="Models\Mesh.h" />
|
||||
<ClInclude Include="ModelView.h" />
|
||||
<ClInclude Include="MyGLWindow.h" />
|
||||
|
||||
@ -119,9 +119,6 @@
|
||||
<ClInclude Include="SceneContext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Material.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="imgui\stb_image.h">
|
||||
<Filter>imgui</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@ -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()
|
||||
{
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -1,11 +0,0 @@
|
||||
#pragma once
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
|
||||
struct Material
|
||||
{
|
||||
glm::vec3 ka;
|
||||
glm::vec3 kd;
|
||||
glm::vec3 ks;
|
||||
float shininess;
|
||||
};
|
||||
@ -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)
|
||||
|
||||
@ -52,13 +52,14 @@ public:
|
||||
aiColor3D dcolor;
|
||||
aiColor3D acolor;
|
||||
aiColor3D scolor;
|
||||
std::vector<Texture> 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<MeshEntry*> meshEntries;
|
||||
std::vector<Texture> textures;
|
||||
|
||||
private:
|
||||
std::vector<std::pair<glm::vec4, Transformation>> _transformations;
|
||||
@ -86,4 +88,5 @@ public:
|
||||
Shader *shader;
|
||||
void draw(SceneContext ctx);
|
||||
|
||||
void assignTexture(Texture &texture);
|
||||
};
|
||||
BIN
BaseGLProject/Models/mountain/ground_grass_3264_4062_Small.jpg
Normal file
|
After Width: | Height: | Size: 628 KiB |
21
BaseGLProject/Models/mountain/mount.blend1.mtl
Normal file
@ -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
|
||||
306
BaseGLProject/Models/sponza/sponza.mtl
Normal file
@ -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
|
||||
BIN
BaseGLProject/Models/sponza/textures/Thumbs.db
Normal file
BIN
BaseGLProject/Models/sponza/textures/background.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/background_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/chain_texture.tga
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/chain_texture_ddn.tga
Normal file
|
After Width: | Height: | Size: 768 KiB |
BIN
BaseGLProject/Models/sponza/textures/lion.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/lion2_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/lion_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/spnza_bricks_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/spnza_bricks_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_arch_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_arch_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_ceiling_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_ceiling_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_column_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_column_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_column_b_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_column_b_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_column_c_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_column_c_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
|
After Width: | Height: | Size: 12 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_curtain_ddn.tga
Normal file
|
After Width: | Height: | Size: 12 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_curtain_diff.tga
Normal file
|
After Width: | Height: | Size: 12 MiB |
|
After Width: | Height: | Size: 12 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_details_ddn.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_details_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_fabric_blue_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_fabric_ddn.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_fabric_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_flagpole_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_flagpole_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_floor_a_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_floor_a_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_roof_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_roof_diff.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_thorn_ddn.tga
Normal file
|
After Width: | Height: | Size: 192 KiB |
BIN
BaseGLProject/Models/sponza/textures/sponza_thorn_diff.tga
Normal file
|
After Width: | Height: | Size: 1.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/vase_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/vase_dif.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/vase_hanging.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/vase_hanging_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/vase_plant.tga
Normal file
|
After Width: | Height: | Size: 4.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/vase_round.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
BIN
BaseGLProject/Models/sponza/textures/vase_round_ddn.tga
Normal file
|
After Width: | Height: | Size: 3.0 MiB |
@ -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);
|
||||
}
|
||||
|
||||
@ -31,8 +31,8 @@ public:
|
||||
void resize(int w, int h);
|
||||
Viewer viewer;
|
||||
|
||||
private:
|
||||
SceneContext _scnctx;
|
||||
private:
|
||||
int m_width;
|
||||
int m_height;
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#include <map>
|
||||
#include <glm/mat3x3.hpp>
|
||||
#include <glm/mat4x4.hpp>
|
||||
#include <glm/vec3.hpp>
|
||||
#include "Texture.h"
|
||||
|
||||
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -6,11 +6,10 @@
|
||||
#include <functional>
|
||||
#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<Texture> 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;
|
||||
};
|
||||
|
||||
};
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -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()
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -1,19 +1,25 @@
|
||||
#pragma once
|
||||
#include <GL/glew.h>
|
||||
#include <string>
|
||||
#include <map>
|
||||
#include "imgui/stb_image.h"
|
||||
#include <glm/vec3.hpp>
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
BIN
BaseGLProject/default.jpg
Normal file
|
After Width: | Height: | Size: 266 B |
@ -45,6 +45,6 @@ Collapsed=0
|
||||
|
||||
[Window][First Window]
|
||||
Pos=20,20
|
||||
Size=322,75
|
||||
Size=321,139
|
||||
Collapsed=0
|
||||
|
||||
|
||||