Models now get a standard normal and specular map if they dont have one

This commit is contained in:
tleety
2015-09-16 16:09:20 +02:00
parent 20fc1232d6
commit 825f6dc991
7 changed files with 22 additions and 6 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

+3 -2
View File
@@ -303,7 +303,7 @@ public:
glm::mat4 modelMatrix = glm::translate(glm::mat4(), absoluteTransform.Position)
* glm::toMat4(absoluteTransform.Orientation)
* glm::scale(absoluteTransform.Scale);
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color);
EnqueueModel(modelAsset, modelMatrix, modelComponent->Transparent, modelComponent->Color, modelComponent->ModelFile);
}
}
@@ -351,7 +351,7 @@ public:
}
//TODO: Get this out of engine.h
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color)
void EnqueueModel(Model* model, glm::mat4 modelMatrix, float transparent, glm::vec4 color, std::string fileName)
{
for (auto texGroup : model->TextureGroups)
{
@@ -366,6 +366,7 @@ public:
job.EndIndex = texGroup.EndIndex;
job.ModelMatrix = modelMatrix;
job.Color = color;
job.fileName = fileName;
m_RendererQueue.Deferred.Add(job);
}
+2
View File
@@ -52,6 +52,8 @@ struct ModelJob : RenderJob
unsigned int ShaderID;
unsigned int TextureID;
std::string fileName;
glm::mat4 ModelMatrix;
GLuint DiffuseTexture;
GLuint NormalTexture;
+2
View File
@@ -76,6 +76,8 @@ private:
GLuint m_ScreenQuad = 0;
Model* m_UnitSphere = nullptr;
Model* m_UnitQuad = nullptr;
Texture* m_StandardNormal;
Texture* m_StandardSpecular;
GLuint m_rbDepthBuffer = 0;
GLuint m_fbDeferred1 = 0;
+13 -2
View File
@@ -113,6 +113,8 @@ void dd::Renderer::CreateBuffers()
m_ScreenQuad = CreateQuad();
m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj");
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");
m_StandardNormal = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
m_StandardSpecular = ResourceManager::Load<Texture>("Textures/Core/NeutralSpecularMap.png");
glGenRenderbuffers(1, &m_rbDepthBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, m_rbDepthBuffer);
@@ -321,14 +323,23 @@ void dd::Renderer::DrawScene(RenderQueue &objects, ShaderProgram &program)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture);
if (modelJob->NormalTexture != 0) {
if (modelJob->NormalTexture != 0 && false) {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture);
} else {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, *m_StandardNormal);
}
if (modelJob->SpecularTexture != 0) {
if (modelJob->SpecularTexture != 0 && false) {
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, modelJob->SpecularTexture);
}
else {
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, *m_StandardSpecular);
}
glBindVertexArray(modelJob->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->ElementBuffer);
+1 -1
View File
@@ -116,7 +116,7 @@ void dd::Systems::LevelSystem::CreateBrick(int row, int line, glm::vec2 spacesBe
model->ModelFile = "Models/Test/Brick/Brick.obj";
float x = spaceToEdge + line * spacesBetweenBricks.x;
float y = spaceToEdge + row * spacesBetweenBricks.y;
transform->Scale = glm::vec3(1.6, 0.2, 0.5);
transform->Scale = glm::vec3(1.6, 0.35, 0.5);
transform->Position = glm::vec3(x - 7, y + 1, -10.f);
m_World->CommitEntity(brick);
return;
+1 -1
View File
@@ -199,7 +199,7 @@ bool dd::Systems::PadSystem::OnContact(const dd::Events::Contact &event)
auto ent = m_World->CreateEntity();
std::shared_ptr<Components::Transform> transform = m_World->AddComponent<Components::Transform>(ent);
transform->Position = glm::vec3(transformBall->Position.x, transformBall->Position.y + 0.01f, -10.f);
transform->Scale = glm::vec3(1.f, 1.f, 1.f);
transform->Scale = glm::vec3(0.5f, 0.5f, 0.5f);
auto model = m_World->AddComponent<Components::Model>(ent);
model->ModelFile = "Models/Test/Ball/Ballopus.obj";
//auto pointlight = m_World->AddComponent<Components::PointLight>(ent);