mirror of
https://github.com/JoeyDeVries/LearnOpenGL.git
synced 2026-01-03 23:33:23 +08:00
Fix geometry shader normal homogenous coordinate, and use std::string instead of aString for model loading.
This commit is contained in:
@@ -33,7 +33,7 @@ struct Vertex {
|
|||||||
struct Texture {
|
struct Texture {
|
||||||
unsigned int id;
|
unsigned int id;
|
||||||
string type;
|
string type;
|
||||||
aiString path;
|
string path;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Mesh {
|
class Mesh {
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ private:
|
|||||||
bool skip = false;
|
bool skip = false;
|
||||||
for(unsigned int j = 0; j < textures_loaded.size(); j++)
|
for(unsigned int j = 0; j < textures_loaded.size(); j++)
|
||||||
{
|
{
|
||||||
if(std::strcmp(textures_loaded[j].path.C_Str(), str.C_Str()) == 0)
|
if(std::strcmp(textures_loaded[j].path.data(), str.C_Str()) == 0)
|
||||||
{
|
{
|
||||||
textures.push_back(textures_loaded[j]);
|
textures.push_back(textures_loaded[j]);
|
||||||
skip = true; // a texture with the same filepath has already been loaded, continue to next one. (optimization)
|
skip = true; // a texture with the same filepath has already been loaded, continue to next one. (optimization)
|
||||||
@@ -191,7 +191,7 @@ private:
|
|||||||
Texture texture;
|
Texture texture;
|
||||||
texture.id = TextureFromFile(str.C_Str(), this->directory);
|
texture.id = TextureFromFile(str.C_Str(), this->directory);
|
||||||
texture.type = typeName;
|
texture.type = typeName;
|
||||||
texture.path = str;
|
texture.path = str.C_Str();
|
||||||
textures.push_back(texture);
|
textures.push_back(texture);
|
||||||
textures_loaded.push_back(texture); // store it as texture loaded for entire model, to ensure we won't unnecesery load duplicate textures.
|
textures_loaded.push_back(texture); // store it as texture loaded for entire model, to ensure we won't unnecesery load duplicate textures.
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,6 +13,6 @@ uniform mat4 model;
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
mat3 normalMatrix = mat3(transpose(inverse(view * model)));
|
mat3 normalMatrix = mat3(transpose(inverse(view * model)));
|
||||||
vs_out.normal = vec3(projection * vec4(normalMatrix * aNormal, 1.0));
|
vs_out.normal = vec3(projection * vec4(normalMatrix * aNormal, 0.0));
|
||||||
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
gl_Position = projection * view * model * vec4(aPos, 1.0);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user