Merge remote-tracking branch 'origin/deffered_rendering' into particles
This commit is contained in:
+1
-1
Submodule assets updated: 20edf7934a...74035fae26
@@ -10,13 +10,25 @@ namespace Components
|
||||
{
|
||||
BlendMap()
|
||||
: TextureRed("Textures/ErrorTextureRed.png")
|
||||
, TextureRedNormal("Textures/NeutralNormalMap.png")
|
||||
, TextureRedSpecular("Textures/NeutralSpecularMap.png")
|
||||
, TextureGreen("Textures/ErrorTextureGreen.png")
|
||||
, TextureGreenNormal("Textures/NeutralNormalMap.png")
|
||||
, TextureGreenSpecular("Textures/NeutralSpecularMap.png")
|
||||
, TextureBlue("Textures/ErrorTextureBlue.png")
|
||||
, TextureBlueNormal("Textures/NeutralNormalMap.png")
|
||||
, TextureBlueSpecular("Textures/NeutralSpecularMap.png")
|
||||
, TextureRepeats(100.f) { }
|
||||
|
||||
std::string TextureRed;
|
||||
std::string TextureRedNormal;
|
||||
std::string TextureRedSpecular;
|
||||
std::string TextureGreen;
|
||||
std::string TextureGreenNormal;
|
||||
std::string TextureGreenSpecular;
|
||||
std::string TextureBlue;
|
||||
std::string TextureBlueNormal;
|
||||
std::string TextureBlueSpecular;
|
||||
float TextureRepeats;
|
||||
|
||||
virtual BlendMap* Clone() const override { return new BlendMap(*this); }
|
||||
|
||||
+35
-8
@@ -61,11 +61,24 @@ public:
|
||||
auto blendmapComponent = m_World->GetComponent<Components::BlendMap>(entity);
|
||||
if (blendmapComponent)
|
||||
{
|
||||
auto textureRed = ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRed);
|
||||
auto textureGreen = ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreen);
|
||||
auto textureBlue = ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlue);
|
||||
BlendMapTexture RedTexture;
|
||||
RedTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRed);
|
||||
RedTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRedNormal);
|
||||
RedTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureRedSpecular);
|
||||
|
||||
BlendMapTexture GreenTexture;
|
||||
GreenTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreen);
|
||||
GreenTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreenNormal);
|
||||
GreenTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureGreenSpecular);
|
||||
|
||||
BlendMapTexture BlueTexture;
|
||||
BlueTexture.Diffuse = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlue);
|
||||
BlueTexture.Normal = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlueNormal);
|
||||
BlueTexture.Specular = *ResourceManager->Load<Texture>("Texture", blendmapComponent->TextureBlueSpecular);
|
||||
|
||||
float textureRepeat = blendmapComponent->TextureRepeats;
|
||||
EnqueueBlendMapModel(modelAsset, textureRed, textureGreen, textureBlue, textureRepeat, modelMatrix);
|
||||
|
||||
EnqueueBlendMapModel(modelAsset, RedTexture, GreenTexture, BlueTexture, textureRepeat, modelMatrix);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -113,6 +126,13 @@ protected:
|
||||
std::shared_ptr<World> m_World;
|
||||
|
||||
private:
|
||||
struct BlendMapTexture
|
||||
{
|
||||
GLuint Diffuse;
|
||||
GLuint Normal;
|
||||
GLuint Specular;
|
||||
};
|
||||
|
||||
EventRelay<Frame, Events::SetViewportCamera> m_ESetViewportCamera;
|
||||
bool OnSetViewportCamera(const Events::SetViewportCamera &event)
|
||||
{
|
||||
@@ -157,7 +177,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
void EnqueueBlendMapModel(Model* model, Texture* textureRed, Texture* textureGreen, Texture* textureBlue, float textureRepeat, glm::mat4 modelMatrix)
|
||||
void EnqueueBlendMapModel(Model* model, BlendMapTexture textureRed, BlendMapTexture textureGreen, BlendMapTexture textureBlue, float textureRepeat, glm::mat4 modelMatrix)
|
||||
{
|
||||
for (auto texGroup : model->TextureGroups)
|
||||
{
|
||||
@@ -166,9 +186,15 @@ private:
|
||||
job.DiffuseTexture = *texGroup.Texture;
|
||||
job.NormalTexture = (texGroup.NormalMap) ? *texGroup.NormalMap : 0;
|
||||
job.SpecularTexture = (texGroup.SpecularMap) ? *texGroup.SpecularMap : 0;
|
||||
job.BlendMapTextureRed = (*textureRed);
|
||||
job.BlendMapTextureGreen = (*textureGreen);
|
||||
job.BlendMapTextureBlue = (*textureBlue);
|
||||
job.BlendMapTextureRed = textureRed.Diffuse;
|
||||
job.BlendMapTextureRedNormal = textureRed.Normal;
|
||||
job.BlendMapTextureRedSpecular = textureRed.Specular;
|
||||
job.BlendMapTextureGreen = textureGreen.Diffuse;
|
||||
job.BlendMapTextureGreenNormal = textureGreen.Normal;
|
||||
job.BlendMapTextureGreenSpecular = textureGreen.Specular;
|
||||
job.BlendMapTextureBlue = textureBlue.Diffuse;
|
||||
job.BlendMapTextureBlueNormal = textureBlue.Normal;
|
||||
job.BlendMapTextureBlueSpecular = textureBlue.Specular;
|
||||
job.TextureRepeat = textureRepeat;
|
||||
job.VAO = model->VAO;
|
||||
job.StartIndex = texGroup.StartIndex;
|
||||
@@ -188,6 +214,7 @@ private:
|
||||
|
||||
RenderQueue.Forward.Add(job);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
+6
-3
@@ -106,9 +106,12 @@ void GameWorld::Initialize()
|
||||
auto model = AddComponent<Components::Model>(ground_middle);
|
||||
model->ModelFile = "Models/TerrainFiveIstles/Middle.obj";
|
||||
auto blendmap = AddComponent<Components::BlendMap>(ground_middle);
|
||||
blendmap->TextureRed = "Textures/Ground/Sand.png";
|
||||
blendmap->TextureGreen = "Textures/Ground/Grass.png";
|
||||
blendmap->TextureBlue = "Textures/Ground/Rock.png";
|
||||
blendmap->TextureRed = "Textures/Ground/SoilBeach0087_11_S.jpg";
|
||||
blendmap->TextureBlueNormal = "Textures/Ground/SoilBeach0087_11_SNM.png";
|
||||
blendmap->TextureGreen = "Textures/Ground/Grass0126_2_S.jpg";
|
||||
blendmap->TextureBlueNormal = "Textures/Ground/Grass0126_2_SNM.png";
|
||||
blendmap->TextureBlue = "Textures/Ground/Cliffs2.png";
|
||||
blendmap->TextureBlueNormal = "Textures/Ground/Cliffs2NM.png";
|
||||
blendmap->TextureRepeats = 30.f;
|
||||
|
||||
auto physics = AddComponent<Components::Physics>(ground_middle);
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ Model::Model(std::shared_ptr<ResourceManager> rm, OBJ &obj)
|
||||
if (Vertices.size() > 0)
|
||||
{
|
||||
CreateTangents();
|
||||
//getSimilarVertexIndex();
|
||||
getSimilarVertexIndex();
|
||||
CreateBuffers(Vertices, Normals, TangentNormals, BiTangentNormals, TextureCoords);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -49,8 +49,14 @@ struct ModelJob : RenderJob
|
||||
struct BlendMapModelJob : ModelJob
|
||||
{
|
||||
GLuint BlendMapTextureRed;
|
||||
GLuint BlendMapTextureRedNormal;
|
||||
GLuint BlendMapTextureRedSpecular;
|
||||
GLuint BlendMapTextureGreen;
|
||||
GLuint BlendMapTextureGreenNormal;
|
||||
GLuint BlendMapTextureGreenSpecular;
|
||||
GLuint BlendMapTextureBlue;
|
||||
GLuint BlendMapTextureBlueNormal;
|
||||
GLuint BlendMapTextureBlueSpecular;
|
||||
float TextureRepeat;
|
||||
};
|
||||
|
||||
|
||||
+31
-1
@@ -490,6 +490,7 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "V"), 1, GL_FALSE, glm::value_ptr(m_Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "P"), 1, GL_FALSE, glm::value_ptr(cameraProjection));
|
||||
glUniform4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||
|
||||
glBindVertexArray(modelJob->VAO);
|
||||
|
||||
@@ -509,6 +510,23 @@ void Renderer::ForwardRendering(RenderQueue &rq)
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||
if (spriteJob)
|
||||
{
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||
glUniform4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "Color"), 1, glm::value_ptr(spriteJob->Color));
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->Texture);
|
||||
glBindVertexArray(m_ScreenQuad);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//glDepthMask (GL_TRUE);
|
||||
//glDisable (GL_BLEND);
|
||||
@@ -1142,9 +1160,21 @@ void Renderer::DrawFBOScene(RenderQueue &rq)
|
||||
glActiveTexture(GL_TEXTURE4);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRed);
|
||||
glActiveTexture(GL_TEXTURE5);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreen);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRedNormal);
|
||||
glActiveTexture(GL_TEXTURE6);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRedSpecular);
|
||||
glActiveTexture(GL_TEXTURE7);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreen);
|
||||
glActiveTexture(GL_TEXTURE8);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreenNormal);
|
||||
glActiveTexture(GL_TEXTURE9);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreenSpecular);
|
||||
glActiveTexture(GL_TEXTURE10);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlue);
|
||||
glActiveTexture(GL_TEXTURE11);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlueNormal);
|
||||
glActiveTexture(GL_TEXTURE12);
|
||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlueSpecular);
|
||||
|
||||
glDrawArrays(GL_TRIANGLES, blendMapJob->StartIndex, blendMapJob->EndIndex - blendMapJob->StartIndex + 1);
|
||||
|
||||
|
||||
@@ -7,8 +7,14 @@ layout (binding=3) uniform sampler2D SpecularMapTexture;
|
||||
|
||||
//TerrainTextures
|
||||
layout (binding=4) uniform sampler2D TextureRed;
|
||||
layout (binding=5) uniform sampler2D TextureGreen;
|
||||
layout (binding=6) uniform sampler2D TextureBlue;
|
||||
layout (binding=5) uniform sampler2D TextureRedNormal;
|
||||
layout (binding=6) uniform sampler2D TextureRedSpecular;
|
||||
layout (binding=7) uniform sampler2D TextureGreen;
|
||||
layout (binding=8) uniform sampler2D TextureGreenNormal;
|
||||
layout (binding=9) uniform sampler2D TextureGreenSpecular;
|
||||
layout (binding=10) uniform sampler2D TextureBlue;
|
||||
layout (binding=11) uniform sampler2D TextureBlueNormal;
|
||||
layout (binding=12) uniform sampler2D TextureBlueSpecular;
|
||||
|
||||
uniform float TextureRepeats; //Determines how many times the textures will loop over the terrain
|
||||
uniform vec3 SunDirection_cameraspace;
|
||||
@@ -61,21 +67,37 @@ void main()
|
||||
vec4 BlendMap = texture(DiffuseTexture, Input.TextureCoord);
|
||||
|
||||
vec4 TextureRedTexel = texture(TextureRed, Input.TextureCoord * TextureRepeats);
|
||||
vec4 TextureRedTexelNormal = texture(TextureRedNormal, Input.TextureCoord * TextureRepeats);
|
||||
//vec4 TextureRedTexelSpecular = texture(TextureRedSpecular, Input.TextureCoord * TextureRepeats);
|
||||
|
||||
vec4 TextureGreenTexel = texture(TextureGreen, Input.TextureCoord * TextureRepeats);
|
||||
vec4 TextureGreenTexelNormal = texture(TextureGreenNormal, Input.TextureCoord * TextureRepeats);
|
||||
//vec4 TextureGreenTexelSpecular = texture(TextureGreenSpecular, Input.TextureCoord * TextureRepeats);
|
||||
|
||||
vec4 TextureBlueTexel = texture(TextureBlue, Input.TextureCoord * TextureRepeats);
|
||||
vec4 TextureBlueTexelNormal = texture(TextureBlueNormal, Input.TextureCoord * TextureRepeats);
|
||||
//vec4 TextureBlueTexelSpecular = texture(TextureBlueSpecular, Input.TextureCoord * TextureRepeats);
|
||||
|
||||
//Mix the Terrain-textures together
|
||||
TextureRedTexel *= BlendMap.r;
|
||||
TextureGreenTexel = mix(TextureRedTexel, TextureGreenTexel, BlendMap.g);
|
||||
vec4 finalBlendTexel = mix(TextureGreenTexel, TextureBlueTexel, BlendMap.b);
|
||||
|
||||
TextureRedTexelNormal *= BlendMap.r;
|
||||
TextureGreenTexelNormal = mix(TextureRedTexelNormal, TextureGreenTexelNormal, BlendMap.g);
|
||||
vec4 finalBlendTexelNormal = mix(TextureGreenTexelNormal, TextureBlueTexelNormal, BlendMap.b);
|
||||
|
||||
//TextureRedTexelSpecular *= BlendMap.r;
|
||||
//TextureGreenTexelSpecular = mix(TextureRedTexelSpecular, TextureGreenTexelSpecular, BlendMap.g);
|
||||
//vec4 finalBlendTexelSpecular = mix(TextureGreenTexelSpecular, TextureBlueTexelSpecular, BlendMap.b);
|
||||
|
||||
// G-buffer Position
|
||||
frag_Position = vec4(Input.Position.xyz, 1.0);
|
||||
|
||||
// G-buffer Normal
|
||||
mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal);
|
||||
frag_Normal = normalize(vec4(TBN * vec3(texture(NormalMapTexture, Input.TextureCoord)), 0.0));
|
||||
//frag_Diffuse = normalize(vec4(TBN * vec3(texture(NormalMapTexture, Input.TextureCoord)), 0.0));
|
||||
frag_Normal = normalize(vec4(TBN * vec3(finalBlendTexelNormal), 0.0));
|
||||
//frag_Diffuse = normalize(vec4(TBN * vec3(finalBlendTexelNormal), 0.0));
|
||||
//frag_Normal = vec4(Input.Normal, 0.0);
|
||||
|
||||
// Diffuse Texture
|
||||
|
||||
@@ -16,5 +16,5 @@ void main() {
|
||||
// Texture
|
||||
vec4 texel = texture(texture0, Input.TextureCoord);
|
||||
|
||||
frag_Diffuse = texel;
|
||||
frag_Diffuse = texel * Color;
|
||||
}
|
||||
Reference in New Issue
Block a user