Added texture tiling to shaders (exkluding ExplosinEffects)

This commit is contained in:
Teejoon
2016-02-07 15:27:26 +01:00
parent 92ab22e779
commit 43719f8304
6 changed files with 162 additions and 82 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ private:
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
void BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& job);
void BindModelTextures(std::shared_ptr<ModelJob>& job);
void BindModelTextures(GLuint shaderHandle, std::shared_ptr<ModelJob>& job);
Texture* m_WhiteTexture;
Texture* m_BlackTexture;
+18 -18
View File
@@ -46,19 +46,19 @@ struct ModelJob : RenderJob
::RawModel::MaterialSingleTextures* singleTextures = static_cast<::RawModel::MaterialSingleTextures*>(matProp.material);
TextureID = (singleTextures->ColorMap.Texture) ? singleTextures->ColorMap.Texture->ResourceID : 0;
if (modelComponent["DiffuseTexture"]) {
DiffuseTexture.push_back(singleTextures->ColorMap.Texture.get());
DiffuseTexture.push_back(&singleTextures->ColorMap);
}
if (modelComponent["NormalMap"]) {
NormalTexture.push_back(singleTextures->NormalMap.Texture.get());
NormalTexture.push_back(&singleTextures->NormalMap);
}
if (modelComponent["SpecularMap"]) {
SpecularTexture.push_back(singleTextures->SpecularMap.Texture.get());
SpecularTexture.push_back(&singleTextures->SpecularMap);
}
if (modelComponent["GlowMap"]) {
IncandescenceTexture.push_back(singleTextures->IncandescenceMap.Texture.get());
IncandescenceTexture.push_back(&singleTextures->IncandescenceMap);
}
}
break;
@@ -72,30 +72,30 @@ struct ModelJob : RenderJob
}
::RawModel::MaterialSplatMapping* SplatTextures = static_cast<::RawModel::MaterialSplatMapping*>(matProp.material);
SplatMap = SplatTextures->SplatMap.Texture.get();
SplatMap = &SplatTextures->SplatMap;
TextureID = (SplatTextures->ColorMaps[0].Texture) ? SplatTextures->ColorMaps[0].Texture->ResourceID : 0;
if (modelComponent["DiffuseTexture"]) {
for (auto texture : SplatTextures->ColorMaps) {
DiffuseTexture.push_back(texture.Texture.get());
for (auto& texture : SplatTextures->ColorMaps) {
DiffuseTexture.push_back(&texture);
}
}
if (modelComponent["NormalMap"]) {
for (auto texture : SplatTextures->NormalMaps) {
NormalTexture.push_back(texture.Texture.get());
for (auto& texture : SplatTextures->NormalMaps) {
NormalTexture.push_back(&texture);
}
}
if (modelComponent["SpecularMap"]) {
for (auto texture : SplatTextures->SpecularMaps) {
SpecularTexture.push_back(texture.Texture.get());
for (auto& texture : SplatTextures->SpecularMaps) {
SpecularTexture.push_back(&texture);
}
}
if (modelComponent["GlowMap"]) {
for (auto texture : SplatTextures->IncandescenceMaps) {
IncandescenceTexture.push_back(texture.Texture.get());
for (auto& texture : SplatTextures->IncandescenceMaps) {
IncandescenceTexture.push_back(&texture);
}
}
}
@@ -132,11 +132,11 @@ struct ModelJob : RenderJob
::RawModel::MaterialType Type;
EntityID Entity;
glm::mat4 Matrix;
const Texture* SplatMap;
std::vector<const Texture*> DiffuseTexture;
std::vector<const Texture*> NormalTexture;
std::vector<const Texture*> SpecularTexture;
std::vector<const Texture*> IncandescenceTexture;
const ::RawModel::TextureProperties* SplatMap;
std::vector<const ::RawModel::TextureProperties*> DiffuseTexture;
std::vector<const ::RawModel::TextureProperties*> NormalTexture;
std::vector<const ::RawModel::TextureProperties*> SpecularTexture;
std::vector<const ::RawModel::TextureProperties*> IncandescenceTexture;
float Shininess = 0.f;
glm::vec4 Color;
const ::Model* Model = nullptr;
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity>
<Components>
<c:SceneLight/>
<c:Model>
<Resource>Models/Test/SplatMapTest.mesh</Resource>
</c:Model>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
+9 -4
View File
@@ -9,6 +9,11 @@ uniform vec2 ScreenDimensions;
uniform vec4 FillColor;
uniform vec4 AmbientColor;
uniform float FillPercentage;
uniform vec2 DiffuseUVRepeat;
uniform vec2 NormalUVRepeat;
uniform vec2 SpecularUVRepeat;
uniform vec2 GlowUVRepeat;
layout (binding = 0) uniform sampler2D DiffuseTexture;
layout (binding = 1) uniform sampler2D NormalMapTexture;
layout (binding = 2) uniform sampler2D SpecularMapTexture;
@@ -114,11 +119,11 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
void main()
{
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate);
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate);
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
vec4 position = V * M * vec4(Input.Position, 1.0);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-position);
+51 -19
View File
@@ -9,6 +9,28 @@ uniform vec4 DiffuseColor;
uniform vec4 FillColor;
uniform vec4 Color;
uniform vec4 AmbientColor;
//Get bineded at the same time as the textures
uniform vec2 DiffuseUVRepeat1;
uniform vec2 DiffuseUVRepeat2;
uniform vec2 DiffuseUVRepeat3;
uniform vec2 DiffuseUVRepeat4;
uniform vec2 DiffuseUVRepeat5;
uniform vec2 NormalUVRepeat1;
uniform vec2 NormalUVRepeat2;
uniform vec2 NormalUVRepeat3;
uniform vec2 NormalUVRepeat4;
uniform vec2 NormalUVRepeat5;
uniform vec2 SpecularUVRepeat1;
uniform vec2 SpecularUVRepeat2;
uniform vec2 SpecularUVRepeat3;
uniform vec2 SpecularUVRepeat4;
uniform vec2 SpecularUVRepeat5;
uniform vec2 GlowUVRepeat1;
uniform vec2 GlowUVRepeat2;
uniform vec2 GlowUVRepeat3;
uniform vec2 GlowUVRepeat4;
uniform vec2 GlowUVRepeat5;
layout (binding = 0) uniform sampler2D SplatMapTexture;
layout (binding = 1) uniform sampler2D DiffuseTexture1;
layout (binding = 2) uniform sampler2D DiffuseTexture2;
@@ -131,12 +153,13 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
#define TEXTURE_TILE 5.0
vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sampler2D A, sampler2D D, vec2 tileValues){
vec4 R_Channel = texture2D(R, Input.TextureCoordinate * tileValues);
vec4 G_Channel = texture2D(G, Input.TextureCoordinate * tileValues);
vec4 B_Channel = texture2D(B, Input.TextureCoordinate * tileValues);
vec4 A_Channel = texture2D(A, Input.TextureCoordinate * tileValues);
vec4 D_Channel = texture2D(D, Input.TextureCoordinate * tileValues);
vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sampler2D A, sampler2D D,
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues, vec2 A_TileValues, vec2 D_TileValues){
vec4 R_Channel = texture2D(R, Input.TextureCoordinate * R_TileValues);
vec4 G_Channel = texture2D(G, Input.TextureCoordinate * G_TileValues);
vec4 B_Channel = texture2D(B, Input.TextureCoordinate * B_TileValues);
vec4 A_Channel = texture2D(A, Input.TextureCoordinate * A_TileValues);
vec4 D_Channel = texture2D(D, Input.TextureCoordinate * D_TileValues);
float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a;
if(total > 1.0f){
@@ -154,18 +177,23 @@ vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sa
+ D_percent * D_Channel;
}
vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sampler2D A, sampler2D D, vec2 tileValues){
vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, sampler2D A, sampler2D D,
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues, vec2 A_TileValues, vec2 D_TileValues){
mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal);
vec3 R_Channel = texture(R, Input.TextureCoordinate * tileValues).xyz * 2.0 - vec3(1.0);
vec3 G_Channel = texture(G, Input.TextureCoordinate * tileValues).xyz * 2.0 - vec3(1.0);
vec3 B_Channel = texture(B, Input.TextureCoordinate * tileValues).xyz * 2.0 - vec3(1.0);
vec3 A_Channel = texture(A, Input.TextureCoordinate * tileValues).xyz * 2.0 - vec3(1.0);
vec3 D_Channel = texture(D, Input.TextureCoordinate * tileValues).xyz * 2.0 - vec3(1.0);
vec3 R_Channel = texture(R, Input.TextureCoordinate * R_TileValues).xyz * 2.0 - vec3(1.0);
vec3 G_Channel = texture(G, Input.TextureCoordinate * G_TileValues).xyz * 2.0 - vec3(1.0);
vec3 B_Channel = texture(B, Input.TextureCoordinate * B_TileValues).xyz * 2.0 - vec3(1.0);
vec3 A_Channel = texture(A, Input.TextureCoordinate * A_TileValues).xyz * 2.0 - vec3(1.0);
vec3 D_Channel = texture(D, Input.TextureCoordinate * D_TileValues).xyz * 2.0 - vec3(1.0);
if(blendValue.length() > 1.0f){
blendValue = normalize(blendValue);
float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a;
if(total > 1.0f){
blendValue.r / total;
blendValue.g / total;
blendValue.b / total;
blendValue.a / total;
}
float D_percent = 1.0f - blendValue.r - blendValue.g - blendValue.b - blendValue.a;
float D_percent = clamp( 1.0f - total, 0.0f, 1.0f);
vec3 Normal_result = blendValue.r * R_Channel
+ blendValue.g * G_Channel
@@ -180,12 +208,16 @@ void main()
{
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
vec4 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3, DiffuseTexture4, DiffuseTexture5, vec2(TEXTURE_TILE, TEXTURE_TILE));
vec4 glowTexel = CalcBlendedTexel(splatTexel, GlowMapTexture1, GlowMapTexture2, GlowMapTexture3, GlowMapTexture4, GlowMapTexture5, vec2(TEXTURE_TILE, TEXTURE_TILE));
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3, SpecularMapTexture4, SpecularMapTexture5, vec2(TEXTURE_TILE, TEXTURE_TILE));
vec4 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3, DiffuseTexture4, DiffuseTexture5,
DiffuseUVRepeat1, DiffuseUVRepeat2, DiffuseUVRepeat3, DiffuseUVRepeat4, DiffuseUVRepeat5);
vec4 glowTexel = CalcBlendedTexel(splatTexel, GlowMapTexture1, GlowMapTexture2, GlowMapTexture3, GlowMapTexture4, GlowMapTexture5,
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3, GlowUVRepeat4, GlowUVRepeat5);
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3, SpecularMapTexture4, SpecularMapTexture5,
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3, SpecularUVRepeat4, SpecularUVRepeat5);
vec4 position = V * M * vec4(Input.Position, 1.0);
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3, NormalMapTexture4, NormalMapTexture5, vec2(TEXTURE_TILE, TEXTURE_TILE));
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3, NormalMapTexture4, NormalMapTexture5,
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3, NormalUVRepeat4, NormalUVRepeat5);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-position);
+62 -40
View File
@@ -190,6 +190,10 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
GLERROR("Bind Forward program");
//bind uniforms
BindModelUniforms(forwardHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardHandle, modelJob);
GLERROR("asdasd");
break;
}
case RawModel::MaterialType::SplatMapping:
@@ -198,16 +202,14 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
GLERROR("Bind SplatMap program");
//bind uniforms
BindModelUniforms(forwardSplatHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardSplatHandle, modelJob);
GLERROR("asdasd");
break;
}
}
//bind textures
BindModelTextures(modelJob);
GLERROR("asdasd");
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
if (modelJob->Animation != nullptr) {
@@ -294,120 +296,140 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
void DrawFinalPass::BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& job)
{
glActiveTexture(GL_TEXTURE0);
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->m_Texture); //JOHAN TODO: support multiple diffuse Textures
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture); //JOHAN TODO: support multiple diffuse Textures
} else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
}
glActiveTexture(GL_TEXTURE1);
if (job->NormalTexture.size() > 0 && job->NormalTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->m_Texture); //JOHAN TODO: support multiple diffuse Textures
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture); //JOHAN TODO: support multiple diffuse Textures
} else {
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
}
glActiveTexture(GL_TEXTURE2);
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->m_Texture); //JOHAN TODO: support multiple diffuse Textures
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture); //JOHAN TODO: support multiple diffuse Textures
} else {
glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture);
}
glActiveTexture(GL_TEXTURE3);
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->m_Texture); //JOHAN TODO: support multiple diffuse Textures
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture); //JOHAN TODO: support multiple diffuse Textures
} else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
}
}
void DrawFinalPass::BindModelTextures(std::shared_ptr<ModelJob>& job)
void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<ModelJob>& job)
{
switch (job->Type) {
case RawModel::MaterialType::SingleTextures:
case RawModel::MaterialType::Basic:
{
glActiveTexture(GL_TEXTURE0);
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->m_Texture);
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat));
}
else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
glActiveTexture(GL_TEXTURE1);
if (job->NormalTexture.size() > 0 && job->NormalTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->m_Texture);
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
}
else {
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
glActiveTexture(GL_TEXTURE2);
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->m_Texture);
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat));
}
else {
glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
glActiveTexture(GL_TEXTURE3);
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->m_Texture);
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat));
}
else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
break;
}
case RawModel::MaterialType::SplatMapping:
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, job->SplatMap->m_Texture);
glBindTexture(GL_TEXTURE_2D, job->SplatMap->Texture->m_Texture);
int texturePosition = GL_TEXTURE1;
//Bind 5 diffuse textures
std::string UniformName = "DiffuseUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
glActiveTexture(texturePosition);
if (job->DiffuseTexture.size() > i && job->DiffuseTexture[i] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[i]->m_Texture);
}
else {
if (job->DiffuseTexture.size() > i && job->DiffuseTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->DiffuseTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}
//Bind 5 Normal textures
UniformName = "NormalUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
glActiveTexture(texturePosition);
if (job->NormalTexture.size() > i && job->NormalTexture[i] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[i]->m_Texture);
}
else {
if (job->NormalTexture.size() > i && job->NormalTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->NormalTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}
//Bind 5 Specular textures
UniformName = "SpecularUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
glActiveTexture(texturePosition);
if (job->SpecularTexture.size() > i && job->SpecularTexture[i] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[i]->m_Texture);
}
else {
if (job->SpecularTexture.size() > i && job->SpecularTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->SpecularTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_GreyTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}
//Bind 5 Incandescence textures
UniformName = "GlowUVRepeat";
for (unsigned int i = 0; i < 5; i++) {
glActiveTexture(texturePosition);
if (job->IncandescenceTexture.size() > i && job->IncandescenceTexture[i] != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[i]->m_Texture);
}
else {
if (job->IncandescenceTexture.size() > i && job->IncandescenceTexture[i]->Texture != nullptr) {
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[i]->Texture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(job->IncandescenceTexture[i]->UVRepeat));
} else {
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
glUniform2fv(glGetUniformLocation(shaderHandle, std::string(UniformName + ((char)(i + '1'))).c_str()), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
}
texturePosition++;
}