Fixed blendmaps
Merge remote-tracking branch 'origin/gui' into deffered_rendering Conflicts: vs11/Returngeance/Returngeance.vcxproj.filters
This commit is contained in:
+1
-1
Submodule assets updated: 62d8e73c68...066c47ecd7
@@ -9,12 +9,14 @@ namespace Components
|
|||||||
struct BlendMap : Component
|
struct BlendMap : Component
|
||||||
{
|
{
|
||||||
BlendMap()
|
BlendMap()
|
||||||
: TextureRed("Textures/Ground/Asphalt")
|
: TextureRed("Textures/ErrorTextureRed.png")
|
||||||
, TextureGreen("Textures/Ground/Grass")
|
, TextureGreen("Textures/ErrorTextureGreen.png")
|
||||||
, TextureBlue("Textures/Ground/Sand")
|
, TextureBlue("Textures/ErrorTextureBlue.png")
|
||||||
, TextureRepeats(100.f) { }
|
, TextureRepeats(100.f) { }
|
||||||
|
|
||||||
std::string TextureRed, TextureGreen, TextureBlue;
|
std::string TextureRed;
|
||||||
|
std::string TextureGreen;
|
||||||
|
std::string TextureBlue;
|
||||||
float TextureRepeats;
|
float TextureRepeats;
|
||||||
|
|
||||||
virtual BlendMap* Clone() const override { return new BlendMap(*this); }
|
virtual BlendMap* Clone() const override { return new BlendMap(*this); }
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ namespace Components
|
|||||||
struct Health : Component
|
struct Health : Component
|
||||||
{
|
{
|
||||||
Health()
|
Health()
|
||||||
: health(1.0f){ }
|
: Amount(1.0f) { }
|
||||||
|
|
||||||
float health;
|
float Amount;
|
||||||
|
|
||||||
virtual Health* Clone() const override { return new Health(*this); }
|
virtual Health* Clone() const override { return new Health(*this); }
|
||||||
};
|
};
|
||||||
|
|||||||
+3
-3
@@ -5,13 +5,13 @@
|
|||||||
|
|
||||||
namespace Events
|
namespace Events
|
||||||
{
|
{
|
||||||
|
|
||||||
struct Damage : Event
|
struct Damage : Event
|
||||||
{
|
{
|
||||||
EntityID Entity;
|
EntityID Entity;
|
||||||
float damage;
|
float Amount;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif // Events_Damage_h__
|
#endif // Events_Damage_h__
|
||||||
+3
-2
@@ -36,8 +36,7 @@ public:
|
|||||||
|
|
||||||
// Create a frame as a child
|
// Create a frame as a child
|
||||||
Frame(Frame* parent, std::string name)
|
Frame(Frame* parent, std::string name)
|
||||||
: Rectangle(static_cast<Rectangle>(*parent)) // Clone parent rectangle using copy constructor
|
: m_Name(name)
|
||||||
, m_Name(name)
|
|
||||||
, m_Layer(0)
|
, m_Layer(0)
|
||||||
{ SetParent(std::shared_ptr<Frame>(parent)); }
|
{ SetParent(std::shared_ptr<Frame>(parent)); }
|
||||||
|
|
||||||
@@ -52,6 +51,8 @@ public:
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Width = parent->Width;
|
||||||
|
Height = parent->Height;
|
||||||
m_Layer = parent->Layer() + 1;
|
m_Layer = parent->Layer() + 1;
|
||||||
parent->AddChild(std::shared_ptr<Frame>(this));
|
parent->AddChild(std::shared_ptr<Frame>(this));
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
|
|||||||
+9
-20
@@ -5,8 +5,7 @@
|
|||||||
#include "GUI/WorldFrame.h"
|
#include "GUI/WorldFrame.h"
|
||||||
#include "GUI/Viewport.h"
|
#include "GUI/Viewport.h"
|
||||||
#include "GUI/TextureFrame.h"
|
#include "GUI/TextureFrame.h"
|
||||||
|
#include "GUI/PlayerHUD.h"
|
||||||
#include "Events/Damage.h"
|
|
||||||
|
|
||||||
#include "GameWorld.h"
|
#include "GameWorld.h"
|
||||||
|
|
||||||
@@ -19,42 +18,32 @@ public:
|
|||||||
GameFrame(Frame* parent, std::string name)
|
GameFrame(Frame* parent, std::string name)
|
||||||
: Frame(parent, name)
|
: Frame(parent, name)
|
||||||
{
|
{
|
||||||
EVENT_SUBSCRIBE_MEMBER(m_EDamage, &GameFrame::OnDamage);
|
|
||||||
|
|
||||||
m_World = std::make_shared<GameWorld>(EventBroker, ResourceManager);
|
m_World = std::make_shared<GameWorld>(EventBroker, ResourceManager);
|
||||||
auto worldFrame = new WorldFrame(this, "GameWorldFrame", m_World);
|
auto worldFrame = new WorldFrame(this, "GameWorldFrame", m_World);
|
||||||
{
|
{
|
||||||
vp1 = new Viewport(worldFrame, "Viewport1", m_World);
|
vp1 = new Viewport(worldFrame, "Viewport1", m_World);
|
||||||
vp1->X = 0;
|
vp1->X = 0;
|
||||||
vp1->Width = 640;
|
vp1->Width = 640;
|
||||||
|
vp1->Height = 720 / 2;
|
||||||
|
new PlayerHUD(vp1, "PlayerHUD", m_World, 1);
|
||||||
|
|
||||||
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
vp2 = new Viewport(worldFrame, "Viewport2", m_World);
|
||||||
vp2->X = vp1->Right();
|
vp2->X = vp1->Right();
|
||||||
vp2->Width = 640;
|
vp2->Width = 640;
|
||||||
|
vp2->Height = 720 / 2;
|
||||||
|
new PlayerHUD(vp2, "PlayerHUD", m_World, 2);
|
||||||
|
|
||||||
tex = new TextureFrame(vp1, "TextureFrameThingy");
|
auto vpc = new Viewport(worldFrame, "ViewportFreeCam", m_World);
|
||||||
tex->SetTexture("Textures/GUI/hurt.png");
|
vpc->Y = 720 / 2;
|
||||||
|
vpc->Height = 720 / 2;
|
||||||
}
|
}
|
||||||
m_World->Initialize();
|
m_World->Initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update(double dt)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool OnDamage(const Events::Damage &event)
|
|
||||||
{
|
|
||||||
//tex->SetTexture("Textures/GUI/hurt.png");
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
EventRelay<Frame, Events::Damage> m_EDamage;
|
|
||||||
std::shared_ptr<GameWorld> m_World;
|
std::shared_ptr<GameWorld> m_World;
|
||||||
Viewport* vp1;
|
Viewport* vp1;
|
||||||
Viewport* vp2;
|
Viewport* vp2;
|
||||||
TextureFrame* tex;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,53 @@
|
|||||||
|
#ifndef GUI_HealthOverlay_h__
|
||||||
|
#define GUI_HealthOverlay_h__
|
||||||
|
|
||||||
|
#include "GUI/TextureFrame.h"
|
||||||
|
#include "World.h"
|
||||||
|
#include "Events/Damage.h"
|
||||||
|
#include "Components/Player.h"
|
||||||
|
#include "Components/Health.h"
|
||||||
|
|
||||||
|
namespace GUI
|
||||||
|
{
|
||||||
|
|
||||||
|
class HealthOverlay : public TextureFrame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
HealthOverlay(Frame* parent, std::string name, std::shared_ptr<World> world, int playerID)
|
||||||
|
: TextureFrame(parent, name)
|
||||||
|
, m_World(world)
|
||||||
|
, m_PlayerID(playerID)
|
||||||
|
{
|
||||||
|
EVENT_SUBSCRIBE_MEMBER(m_EDamage, &HealthOverlay::OnDamage);
|
||||||
|
|
||||||
|
SetTexture("Textures/GUI/hurt.png");
|
||||||
|
SetColor(glm::vec4(0.f));
|
||||||
|
}
|
||||||
|
|
||||||
|
bool OnDamage(const Events::Damage &event)
|
||||||
|
{
|
||||||
|
auto player = m_World->GetComponent<Components::Player>(event.Entity);
|
||||||
|
if (!player)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (player->ID != m_PlayerID)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
||||||
|
if (!health)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
SetColor(glm::vec4(1.f, 1.f, 1.f, 1 - health->Amount / 100.f));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<World> m_World;
|
||||||
|
int m_PlayerID;
|
||||||
|
EventRelay<Frame, Events::Damage> m_EDamage;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GUI_TextureFrame_h__
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#include "GUI/Frame.h"
|
||||||
|
#include "GUI/HealthOverlay.h"
|
||||||
|
|
||||||
|
#ifndef GUI_PlayerHUD_h__
|
||||||
|
#define GUI_PlayerHUD_h__
|
||||||
|
|
||||||
|
namespace GUI
|
||||||
|
{
|
||||||
|
|
||||||
|
class PlayerHUD : public Frame
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
PlayerHUD(Frame* parent, std::string name, std::shared_ptr<World> world, int playerID)
|
||||||
|
: Frame(parent, name)
|
||||||
|
, m_World(world)
|
||||||
|
, m_PlayerID(playerID)
|
||||||
|
{
|
||||||
|
m_HealthOverlay = new HealthOverlay(this, "HealthOverlay", m_World, m_PlayerID);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<World> m_World;
|
||||||
|
int m_PlayerID;
|
||||||
|
|
||||||
|
HealthOverlay* m_HealthOverlay;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // GUI_TextureFrame_h__
|
||||||
+13
-4
@@ -11,7 +11,10 @@ class TextureFrame : public Frame
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TextureFrame(Frame* parent, std::string name)
|
TextureFrame(Frame* parent, std::string name)
|
||||||
: Frame(parent, name) { }
|
: Frame(parent, name)
|
||||||
|
, m_Texture(nullptr)
|
||||||
|
, m_Color(glm::vec4(1.f, 1.f, 1.f, 1.f))
|
||||||
|
{ }
|
||||||
|
|
||||||
void Draw(std::shared_ptr<Renderer> renderer) override
|
void Draw(std::shared_ptr<Renderer> renderer) override
|
||||||
{
|
{
|
||||||
@@ -22,20 +25,26 @@ public:
|
|||||||
SpriteJob job;
|
SpriteJob job;
|
||||||
job.TextureID = m_Texture->ResourceID;
|
job.TextureID = m_Texture->ResourceID;
|
||||||
job.Texture = *m_Texture;
|
job.Texture = *m_Texture;
|
||||||
|
job.Color = m_Color;
|
||||||
RenderQueue.Add(job);
|
RenderQueue.Add(job);
|
||||||
|
|
||||||
renderer->SetCamera(nullptr);
|
renderer->SetCamera(nullptr);
|
||||||
renderer->DrawFrame(RenderQueue);
|
renderer->DrawFrame(RenderQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<::Texture> Texture() const { return m_Texture; }
|
::Texture* Texture() const { return m_Texture; }
|
||||||
void SetTexture(std::string resourceName)
|
void SetTexture(std::string resourceName)
|
||||||
{
|
{
|
||||||
m_Texture = std::shared_ptr<::Texture>(ResourceManager->Load<::Texture>("Texture", resourceName));
|
m_Texture = ResourceManager->Load<::Texture>("Texture", resourceName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::vec4 Color() const { return m_Color; }
|
||||||
|
void SetColor(glm::vec4 val) { m_Color = val; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::shared_ptr<::Texture> m_Texture;
|
::Texture* m_Texture;
|
||||||
|
glm::vec4 m_Color;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+726
-1091
File diff suppressed because it is too large
Load Diff
@@ -58,6 +58,9 @@ public:
|
|||||||
|
|
||||||
void Initialize();
|
void Initialize();
|
||||||
|
|
||||||
|
EntityID CreateTank(int playerID);
|
||||||
|
EntityID CreateJeep(int playerID);
|
||||||
|
|
||||||
void RegisterSystems() override;
|
void RegisterSystems() override;
|
||||||
void AddSystems() override;
|
void AddSystems() override;
|
||||||
void RegisterComponents() override;
|
void RegisterComponents() override;
|
||||||
|
|||||||
+2
-2
@@ -30,10 +30,10 @@ struct ModelJob : RenderJob
|
|||||||
unsigned int ShaderID;
|
unsigned int ShaderID;
|
||||||
unsigned int TextureID;
|
unsigned int TextureID;
|
||||||
|
|
||||||
GLuint ShaderProgram;
|
|
||||||
GLuint DiffuseTexture;
|
GLuint DiffuseTexture;
|
||||||
GLuint NormalTexture;
|
GLuint NormalTexture;
|
||||||
GLuint SpecularTexture;
|
GLuint SpecularTexture;
|
||||||
|
glm::vec4 Color;
|
||||||
GLuint VAO;
|
GLuint VAO;
|
||||||
unsigned int StartIndex;
|
unsigned int StartIndex;
|
||||||
unsigned int EndIndex;
|
unsigned int EndIndex;
|
||||||
@@ -58,8 +58,8 @@ struct SpriteJob : RenderJob
|
|||||||
unsigned int ShaderID;
|
unsigned int ShaderID;
|
||||||
unsigned int TextureID;
|
unsigned int TextureID;
|
||||||
|
|
||||||
GLuint ShaderProgram;
|
|
||||||
GLuint Texture;
|
GLuint Texture;
|
||||||
|
glm::vec4 Color;
|
||||||
glm::mat4 ModelMatrix;
|
glm::mat4 ModelMatrix;
|
||||||
|
|
||||||
void CalculateHash() override
|
void CalculateHash() override
|
||||||
|
|||||||
+57
-58
@@ -108,10 +108,10 @@ void Renderer::LoadContent()
|
|||||||
m_ShaderProgramDebugAABB.Compile();
|
m_ShaderProgramDebugAABB.Compile();
|
||||||
m_ShaderProgramDebugAABB.Link();*/
|
m_ShaderProgramDebugAABB.Link();*/
|
||||||
|
|
||||||
m_BlendMapProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/BlendMap.vert.glsl")));
|
m_BlendMapProgram.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/BlendMap.vert.glsl")));
|
||||||
m_BlendMapProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/BlendMap.frag.glsl")));
|
m_BlendMapProgram.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/BlendMap.frag.glsl")));
|
||||||
m_BlendMapProgram.Compile();
|
m_BlendMapProgram.Compile();
|
||||||
m_BlendMapProgram.Link();
|
m_BlendMapProgram.Link();
|
||||||
|
|
||||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Skybox.vert.glsl")));
|
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Skybox.vert.glsl")));
|
||||||
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Skybox.frag.glsl")));
|
m_ShaderProgramSkybox.AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Skybox.frag.glsl")));
|
||||||
@@ -264,8 +264,8 @@ void Renderer::Draw(double dt)
|
|||||||
void Renderer::DrawFrame(RenderQueue &rq)
|
void Renderer::DrawFrame(RenderQueue &rq)
|
||||||
{
|
{
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
glViewport(m_Viewport.X, -m_Viewport.Y, m_Viewport.Width, m_Viewport.Height);
|
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||||
glScissor(m_Viewport.X, -m_Viewport.Y, m_Viewport.Width, m_Viewport.Height);
|
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||||
|
|
||||||
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
//glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
|
//glClearColor(0.0f, 0.5f, 0.0f, 1.0f);
|
||||||
@@ -346,6 +346,7 @@ void Renderer::DrawFrame(RenderQueue &rq)
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "M"), 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(), "V"), 1, GL_FALSE, glm::value_ptr(glm::mat4()));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ForwardRendering.GetHandle(), "P"), 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);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, spriteJob->Texture);
|
glBindTexture(GL_TEXTURE_2D, spriteJob->Texture);
|
||||||
@@ -367,8 +368,8 @@ void Renderer::DrawWorld(RenderQueue &rq)
|
|||||||
Base pass
|
Base pass
|
||||||
*/
|
*/
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fbBasePass);
|
||||||
glViewport(m_Viewport.X, -m_Viewport.Y, m_Viewport.Width, m_Viewport.Height);
|
glViewport(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||||
glScissor(m_Viewport.X, -m_Viewport.Y, m_Viewport.Width, m_Viewport.Height);
|
glScissor(m_Viewport.X, m_Height - m_Viewport.Y - m_Viewport.Height, m_Viewport.Width, m_Viewport.Height);
|
||||||
//glViewport(0, 0, m_Width, m_Height);
|
//glViewport(0, 0, m_Width, m_Height);
|
||||||
|
|
||||||
// Clear G-buffer
|
// Clear G-buffer
|
||||||
@@ -439,7 +440,6 @@ void Renderer::Swap()
|
|||||||
glfwSwapBuffers(m_Window);
|
glfwSwapBuffers(m_Window);
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma region TempRegion
|
|
||||||
|
|
||||||
void Renderer::DrawSkybox()
|
void Renderer::DrawSkybox()
|
||||||
{
|
{
|
||||||
@@ -762,8 +762,6 @@ void Renderer::ClearStuff()
|
|||||||
Lights.clear();
|
Lights.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
#pragma endregion
|
|
||||||
|
|
||||||
void Renderer::FrameBufferTextures()
|
void Renderer::FrameBufferTextures()
|
||||||
{
|
{
|
||||||
m_fbBasePass = 0;
|
m_fbBasePass = 0;
|
||||||
@@ -976,17 +974,62 @@ void Renderer::DrawFBOScene(RenderQueue &rq)
|
|||||||
glm::vec3 sunDirection = m_SunTarget - m_SunPosition;
|
glm::vec3 sunDirection = m_SunTarget - m_SunPosition;
|
||||||
glm::vec3 sunDirection_cameraview = glm::vec3(cameraProjection * m_Camera->ViewMatrix() * glm::vec4(sunDirection, 1.0));
|
glm::vec3 sunDirection_cameraview = glm::vec3(cameraProjection * m_Camera->ViewMatrix() * glm::vec4(sunDirection, 1.0));
|
||||||
|
|
||||||
m_FirstPassProgram.Bind();
|
|
||||||
GLuint ShaderProgramHandle = m_FirstPassProgram.GetHandle();
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
|
glBindTexture(GL_TEXTURE_2D, m_ShadowDepthTexture);
|
||||||
|
|
||||||
for (auto &job : rq)
|
for (auto &job : rq)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
auto blendMapJob = std::dynamic_pointer_cast<BlendMapModelJob>(job);
|
||||||
|
if(blendMapJob)
|
||||||
|
{
|
||||||
|
m_BlendMapProgram.Bind();
|
||||||
|
GLuint ShaderProgramHandle = m_BlendMapProgram.GetHandle();
|
||||||
|
|
||||||
|
glm::mat4 modelMatrix = blendMapJob->ModelMatrix;
|
||||||
|
|
||||||
|
MVP = cameraMatrix * modelMatrix;
|
||||||
|
depthMVP = depthCameraMatrix * modelMatrix;
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthMVP));
|
||||||
|
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));
|
||||||
|
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview));
|
||||||
|
glUniform1f(glGetUniformLocation(ShaderProgramHandle, "TextureRepeats"), blendMapJob->TextureRepeat);
|
||||||
|
|
||||||
|
glBindVertexArray(blendMapJob->VAO);
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, blendMapJob->DiffuseTexture);
|
||||||
|
if (blendMapJob->NormalTexture != 0)
|
||||||
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE2);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, blendMapJob->NormalTexture);
|
||||||
|
}
|
||||||
|
if (blendMapJob->SpecularTexture)
|
||||||
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE3);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, blendMapJob->SpecularTexture);
|
||||||
|
}
|
||||||
|
|
||||||
|
glActiveTexture(GL_TEXTURE4);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRed);
|
||||||
|
glActiveTexture(GL_TEXTURE5);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreen);
|
||||||
|
glActiveTexture(GL_TEXTURE6);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlue);
|
||||||
|
|
||||||
|
glDrawArrays(GL_TRIANGLES, blendMapJob->StartIndex, blendMapJob->EndIndex - blendMapJob->StartIndex + 1);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
if (modelJob)
|
if (modelJob)
|
||||||
{
|
{
|
||||||
|
m_FirstPassProgram.Bind();
|
||||||
|
GLuint ShaderProgramHandle = m_FirstPassProgram.GetHandle();
|
||||||
|
|
||||||
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
glm::mat4 modelMatrix = modelJob->ModelMatrix;
|
||||||
|
|
||||||
MVP = cameraMatrix * modelMatrix;
|
MVP = cameraMatrix * modelMatrix;
|
||||||
@@ -1041,50 +1084,6 @@ void Renderer::DrawFBOScene(RenderQueue &rq)
|
|||||||
|
|
||||||
// continue;
|
// continue;
|
||||||
//}
|
//}
|
||||||
|
|
||||||
m_BlendMapProgram.Bind();
|
|
||||||
GLuint ShaderProgramHandle = m_BlendMapProgram.GetHandle();
|
|
||||||
|
|
||||||
auto blendMapJob = std::dynamic_pointer_cast<BlendMapModelJob>(job);
|
|
||||||
if(blendMapJob)
|
|
||||||
{
|
|
||||||
glm::mat4 modelMatrix = blendMapJob->ModelMatrix;
|
|
||||||
|
|
||||||
MVP = cameraMatrix * modelMatrix;
|
|
||||||
depthMVP = depthCameraMatrix * modelMatrix;
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderProgramHandle, "DepthMVP"), 1, GL_FALSE, glm::value_ptr(depthMVP));
|
|
||||||
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));
|
|
||||||
glUniform3fv(glGetUniformLocation(ShaderProgramHandle, "SunDirection_cameraspace"), 1, glm::value_ptr(sunDirection_cameraview));
|
|
||||||
glUniform1f(glGetUniformLocation(ShaderProgramHandle, "TextureRepeats"), blendMapJob->TextureRepeat);
|
|
||||||
|
|
||||||
glBindVertexArray(blendMapJob->VAO);
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->DiffuseTexture);
|
|
||||||
if (blendMapJob->NormalTexture != 0)
|
|
||||||
{
|
|
||||||
glActiveTexture(GL_TEXTURE2);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->NormalTexture);
|
|
||||||
}
|
|
||||||
if (blendMapJob->SpecularTexture)
|
|
||||||
{
|
|
||||||
glActiveTexture(GL_TEXTURE3);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->SpecularTexture);
|
|
||||||
}
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE4);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureRed);
|
|
||||||
glActiveTexture(GL_TEXTURE5);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureGreen);
|
|
||||||
glActiveTexture(GL_TEXTURE6);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, blendMapJob->BlendMapTextureBlue);
|
|
||||||
|
|
||||||
glDrawArrays(GL_TRIANGLES, blendMapJob->StartIndex, modelJob->EndIndex - modelJob->StartIndex + 1);
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ float Shadow(vec4 ShadowCoord, vec3 normal)
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 BlendMap = texture2D(DiffuseTexture, Input.TextureCoord.st);
|
vec4 BlendMap = texture(DiffuseTexture, Input.TextureCoord);
|
||||||
|
|
||||||
vec4 TextureRedTexel = texture2D(TextureRed, Input.TextureCoord.st * TextureRepeats);
|
vec4 TextureRedTexel = texture(TextureRed, Input.TextureCoord * TextureRepeats);
|
||||||
vec4 TextureGreenTexel = texture2D(TextureGreen, Input.TextureCoord.st * TextureRepeats);
|
vec4 TextureGreenTexel = texture(TextureGreen, Input.TextureCoord * TextureRepeats);
|
||||||
vec4 TextureBlueTexel = texture2D(TextureBlue, Input.TextureCoord.st * TextureRepeats);
|
vec4 TextureBlueTexel = texture(TextureBlue, Input.TextureCoord * TextureRepeats);
|
||||||
|
|
||||||
//Mix the Terrain-textures together
|
//Mix the Terrain-textures together
|
||||||
TextureRedTexel *= BlendMap.r;
|
TextureRedTexel *= BlendMap.r;
|
||||||
@@ -79,7 +79,7 @@ void main()
|
|||||||
//frag_Normal = vec4(Input.Normal, 0.0);
|
//frag_Normal = vec4(Input.Normal, 0.0);
|
||||||
|
|
||||||
// Diffuse Texture
|
// Diffuse Texture
|
||||||
frag_Diffuse = finalBlendTexel * Shadow(Input.ShadowCoord, vec3(frag_Normal));
|
frag_Diffuse = finalBlendTexel;
|
||||||
|
|
||||||
//G-buffer Specular
|
//G-buffer Specular
|
||||||
frag_Specular = texture(SpecularMapTexture, Input.TextureCoord);
|
frag_Specular = texture(SpecularMapTexture, Input.TextureCoord);
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
|
uniform vec4 Color;
|
||||||
|
|
||||||
layout(binding=0) uniform sampler2D texture0;
|
layout(binding=0) uniform sampler2D texture0;
|
||||||
|
|
||||||
in VertexData {
|
in VertexData {
|
||||||
@@ -14,5 +16,5 @@ void main() {
|
|||||||
// Texture
|
// Texture
|
||||||
vec4 texel = texture(texture0, Input.TextureCoord);
|
vec4 texel = texture(texture0, Input.TextureCoord);
|
||||||
|
|
||||||
fragmentColor = texel;
|
fragmentColor = texel * Color;
|
||||||
}
|
}
|
||||||
@@ -16,7 +16,7 @@ void Systems::DamageSystem::Initialize()
|
|||||||
bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
|
bool Systems::DamageSystem::OnDamage( const Events::Damage &event )
|
||||||
{
|
{
|
||||||
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
auto health = m_World->GetComponent<Components::Health>(event.Entity);
|
||||||
health->health -= event.damage;
|
health->Amount -= event.Amount;
|
||||||
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->health);
|
LOG_INFO("Damaged entity %i, Health left: %f", event.Entity, health->Amount);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ void Systems::FreeSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
|
|
||||||
glm::quat mouseOrientationPitch = glm::quat(m_InputController->MouseOrientation * glm::vec3(1, 0, 0));
|
glm::quat mouseOrientationPitch = glm::quat(m_InputController->MouseOrientation * glm::vec3(1, 0, 0));
|
||||||
glm::quat mouseOrientationYaw = glm::quat(m_InputController->MouseOrientation * glm::vec3(0, 1, 0));
|
glm::quat mouseOrientationYaw = glm::quat(m_InputController->MouseOrientation * glm::vec3(0, 1, 0));
|
||||||
|
m_InputController->MouseOrientation = glm::vec3(0);
|
||||||
|
|
||||||
glm::vec3 controllerOrientationEuler = m_InputController->ControllerOrientation * (float)dt;
|
glm::vec3 controllerOrientationEuler = m_InputController->ControllerOrientation * (float)dt;
|
||||||
glm::quat controllerOrientationPitch = glm::quat(controllerOrientationEuler * glm::vec3(1, 0, 0));
|
glm::quat controllerOrientationPitch = glm::quat(controllerOrientationEuler * glm::vec3(1, 0, 0));
|
||||||
@@ -53,8 +54,6 @@ void Systems::FreeSteeringSystem::UpdateEntity(double dt, EntityID entity, Entit
|
|||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// TOUCHING THIS CODE MIGHT CAUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
// TOUCHING THIS CODE MIGHT CAUSE THE UNIVERSE TO IMPLODE, ALSO DRAGONS
|
||||||
}
|
}
|
||||||
|
|
||||||
m_InputController->MouseOrientation = glm::vec3(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Systems::FreeSteeringSystem::FreeSteeringInputController::OnCommand(const Events::InputCommand &event)
|
bool Systems::FreeSteeringSystem::FreeSteeringInputController::OnCommand(const Events::InputCommand &event)
|
||||||
@@ -80,7 +79,7 @@ bool Systems::FreeSteeringSystem::FreeSteeringInputController::OnCommand(const E
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mouse click
|
// Mouse click
|
||||||
else if (event.Command == "cam_attack")
|
else if (event.Command == "cam_lock")
|
||||||
{
|
{
|
||||||
OrientationActive = event.Value > 0;
|
OrientationActive = event.Value > 0;
|
||||||
|
|
||||||
@@ -113,6 +112,7 @@ bool Systems::FreeSteeringSystem::FreeSteeringInputController::OnMouseMove(const
|
|||||||
if (OrientationActive)
|
if (OrientationActive)
|
||||||
{
|
{
|
||||||
MouseOrientation = -glm::vec3(event.DeltaY / 300.f, event.DeltaX / 300.f, 0.f);
|
MouseOrientation = -glm::vec3(event.DeltaY / 300.f, event.DeltaX / 300.f, 0.f);
|
||||||
|
LOG_DEBUG("Mouse DX: %f", event.DeltaX);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ bool Systems::TankSteeringSystem::OnCollision( const Events::Collision &e )
|
|||||||
{
|
{
|
||||||
Events::Damage d;
|
Events::Damage d;
|
||||||
d.Entity = physicsEntity;
|
d.Entity = physicsEntity;
|
||||||
d.damage = (1.f - pow(distance / radius, 2)) * shellComponent->Damage;
|
d.Amount = (1.f - pow(distance / radius, 2)) * shellComponent->Damage;
|
||||||
EventBroker->Publish(d);
|
EventBroker->Publish(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -196,6 +196,8 @@
|
|||||||
<ClInclude Include="..\..\src\GUI\Frame.h" />
|
<ClInclude Include="..\..\src\GUI\Frame.h" />
|
||||||
<ClInclude Include="..\..\src\EventBroker.h" />
|
<ClInclude Include="..\..\src\EventBroker.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\GameFrame.h" />
|
<ClInclude Include="..\..\src\GUI\GameFrame.h" />
|
||||||
|
<ClInclude Include="..\..\src\GUI\HealthOverlay.h" />
|
||||||
|
<ClInclude Include="..\..\src\GUI\PlayerHUD.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\WorldFrame.h" />
|
<ClInclude Include="..\..\src\GUI\WorldFrame.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\TextureFrame.h" />
|
<ClInclude Include="..\..\src\GUI\TextureFrame.h" />
|
||||||
<ClInclude Include="..\..\src\GUI\Viewport.h" />
|
<ClInclude Include="..\..\src\GUI\Viewport.h" />
|
||||||
|
|||||||
@@ -472,6 +472,12 @@
|
|||||||
<ClInclude Include="..\..\src\GUI\GameFrame.h">
|
<ClInclude Include="..\..\src\GUI\GameFrame.h">
|
||||||
<Filter>GUI</Filter>
|
<Filter>GUI</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\GUI\HealthOverlay.h">
|
||||||
|
<Filter>GUI</Filter>
|
||||||
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\src\GUI\PlayerHUD.h">
|
||||||
|
<Filter>GUI</Filter>
|
||||||
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
<ClInclude Include="..\..\src\Components\BlendMap.h">
|
||||||
<Filter>Rendering\Components</Filter>
|
<Filter>Rendering\Components</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
Reference in New Issue
Block a user