Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1b0cc1d80b |
+1
-1
Submodule assets updated: e8174f630f...f7e349a316
@@ -1,53 +0,0 @@
|
|||||||
#ifndef DrawBloomPass_h__
|
|
||||||
#define DrawBloomPass_h__
|
|
||||||
|
|
||||||
#include "IRenderer.h"
|
|
||||||
#include "DrawBloomPassState.h"
|
|
||||||
//#include "LightCullingPass.h" Finalpass om den skall skickas in
|
|
||||||
#include "FrameBuffer.h"
|
|
||||||
#include "ShaderProgram.h"
|
|
||||||
//#include "Util/UnorderedMapVec2.h"
|
|
||||||
#include "Texture.h"
|
|
||||||
|
|
||||||
class DrawBloomPass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DrawBloomPass(IRenderer* renderer /* ,Texture or finalpass*/ );
|
|
||||||
~DrawBloomPass() { }
|
|
||||||
void InitializeTextures();
|
|
||||||
void InitializeFrameBuffers();
|
|
||||||
void InitializeShaderPrograms();
|
|
||||||
void InitializeBuffers();
|
|
||||||
void ClearBuffer();
|
|
||||||
|
|
||||||
void FillGaussianBuffer(FrameBuffer* fb);
|
|
||||||
|
|
||||||
void Draw(GLuint texture);
|
|
||||||
|
|
||||||
//Getters
|
|
||||||
//Return the blurred result of the texture that was sent into draw
|
|
||||||
GLuint GaussianTexture() const { return m_GaussianTexture_vert; }
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
|
||||||
|
|
||||||
Texture* m_WhiteTexture;
|
|
||||||
Model* m_ScreenQuad;
|
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
|
||||||
//const LightCullingPass* m_LightCullingPass
|
|
||||||
GLuint m_iterations = 9;
|
|
||||||
|
|
||||||
GLuint m_GaussianTexture_horiz;
|
|
||||||
GLuint m_GaussianTexture_vert;
|
|
||||||
|
|
||||||
FrameBuffer m_GaussianFrameBuffer_horiz;
|
|
||||||
FrameBuffer m_GaussianFrameBuffer_vert;
|
|
||||||
|
|
||||||
ShaderProgram* m_GaussianProgram_horiz;
|
|
||||||
ShaderProgram* m_GaussianProgram_vert;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#ifndef DrawBloomPassState_h__
|
|
||||||
#define DrawBloomPassState_h__
|
|
||||||
|
|
||||||
#include "Rendering/RenderState.h"
|
|
||||||
|
|
||||||
class DrawBloomPassState : public RenderState
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DrawBloomPassState();
|
|
||||||
~DrawBloomPassState();
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
#ifndef DrawColorCorrectionPass_h__
|
|
||||||
#define DrawColorCorrectionPass_h__
|
|
||||||
|
|
||||||
#include "IRenderer.h"
|
|
||||||
#include "DrawScreenQuadPassState.h"
|
|
||||||
#include "FrameBuffer.h"
|
|
||||||
#include "ShaderProgram.h"
|
|
||||||
//#include "Util/UnorderedMapVec2.h"
|
|
||||||
#include "Texture.h"
|
|
||||||
|
|
||||||
class DrawColorCorrectionPass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DrawColorCorrectionPass(IRenderer* renderer);
|
|
||||||
~DrawColorCorrectionPass() { }
|
|
||||||
void InitializeFrameBuffers();
|
|
||||||
void InitializeShaderPrograms();
|
|
||||||
|
|
||||||
void Draw(GLuint sceneTexture, GLuint bloomTexture);
|
|
||||||
private:
|
|
||||||
const IRenderer* m_Renderer;
|
|
||||||
|
|
||||||
ShaderProgram* m_ColorCorrectionProgram;
|
|
||||||
|
|
||||||
Model* m_ScreenQuad;
|
|
||||||
GLfloat m_Exposure;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -17,27 +17,17 @@ public:
|
|||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
void Draw(RenderScene& scene);
|
|
||||||
void ClearBuffer();
|
|
||||||
|
|
||||||
//Return the texture that is used in later stages to apply the bloom effect
|
void Draw(RenderScene& scene);
|
||||||
GLuint BloomTexture() const { return m_BloomTexture; }
|
|
||||||
//Return the texture with diffuse and lighting of the scene.
|
//Getters
|
||||||
GLuint SceneTexture() const { return m_SceneTexture; }
|
|
||||||
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
|
||||||
|
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
Texture* m_BlackTexture;
|
Texture* m_NeutralNormalMap;
|
||||||
|
|
||||||
FrameBuffer m_FinalPassFrameBuffer;
|
|
||||||
GLuint m_BloomTexture;
|
|
||||||
GLuint m_SceneTexture;
|
|
||||||
GLuint m_DepthBuffer;
|
|
||||||
|
|
||||||
const IRenderer* m_Renderer;
|
const IRenderer* m_Renderer;
|
||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
class DrawFinalPassState : public RenderState
|
class DrawFinalPassState : public RenderState
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawFinalPassState(GLuint frameBuffer);
|
DrawFinalPassState();
|
||||||
~DrawFinalPassState();
|
~DrawFinalPassState();
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
#ifndef DrawScreenQuadPass_h__
|
|
||||||
#define DrawScreenQuadPass_h__
|
|
||||||
|
|
||||||
#include "IRenderer.h"
|
|
||||||
#include "DrawScreenQuadPassState.h"
|
|
||||||
#include "FrameBuffer.h"
|
|
||||||
#include "ShaderProgram.h"
|
|
||||||
//#include "Util/UnorderedMapVec2.h"
|
|
||||||
#include "Texture.h"
|
|
||||||
|
|
||||||
class DrawScreenQuadPass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DrawScreenQuadPass(IRenderer* renderer);
|
|
||||||
~DrawScreenQuadPass() { }
|
|
||||||
void InitializeFrameBuffers();
|
|
||||||
void InitializeShaderPrograms();
|
|
||||||
|
|
||||||
void Draw(GLuint texture);
|
|
||||||
private:
|
|
||||||
const IRenderer* m_Renderer;
|
|
||||||
|
|
||||||
ShaderProgram* m_DrawQuadProgram;
|
|
||||||
|
|
||||||
Model* m_ScreenQuad;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#ifndef DrawScreenQuadPassState_h__
|
|
||||||
#define DrawScreenQuadPassState_h__
|
|
||||||
|
|
||||||
#include "Rendering/RenderState.h"
|
|
||||||
|
|
||||||
class DrawScreenQuadPassState : public RenderState
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
DrawScreenQuadPassState();
|
|
||||||
~DrawScreenQuadPassState();
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
#ifndef Font_h__
|
|
||||||
#define Font_h__
|
|
||||||
|
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
#include FT_GLYPH_H
|
|
||||||
#include <boost/tokenizer.hpp>
|
|
||||||
#include <boost/lexical_cast.hpp>
|
|
||||||
|
|
||||||
#include "../OpenGL.h"
|
|
||||||
#include "../GLM.h"
|
|
||||||
#include "../Core/ResourceManager.h"
|
|
||||||
|
|
||||||
class Font : public Resource
|
|
||||||
{
|
|
||||||
friend class ResourceManager;
|
|
||||||
private:
|
|
||||||
Font(std::string path);
|
|
||||||
|
|
||||||
public:
|
|
||||||
struct Character {
|
|
||||||
GLuint TextureID; // ID handle of the glyph texture
|
|
||||||
glm::ivec2 Size; // Size of glyph
|
|
||||||
glm::ivec2 Bearing; // Offset from baseline to left/top of glyph
|
|
||||||
GLuint Advance; // Offset to advance to next glyph
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int FontSize = 16;
|
|
||||||
|
|
||||||
~Font();
|
|
||||||
|
|
||||||
std::map<GLchar, Character> m_Characters;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
@@ -11,16 +11,49 @@
|
|||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "RenderJob.h"
|
#include "RenderJob.h"
|
||||||
#include "ModelJob.h"
|
#include "ModelJob.h"
|
||||||
#include "TextJob.h"
|
|
||||||
#include "PointLightJob.h"
|
#include "PointLightJob.h"
|
||||||
#include "DirectionalLightJob.h"
|
#include "DirectionalLightJob.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
struct SpriteJob : RenderJob
|
||||||
|
{
|
||||||
|
unsigned int ShaderID = 0;
|
||||||
|
unsigned int TextureID = 0;
|
||||||
|
|
||||||
|
glm::mat4 ModelMatrix;
|
||||||
|
const Texture* DiffuseTexture = nullptr;
|
||||||
|
const Texture* NormalTexture = nullptr;
|
||||||
|
const Texture* SpecularTexture = nullptr;
|
||||||
|
glm::vec4 Color;
|
||||||
|
|
||||||
|
void CalculateHash() override
|
||||||
|
{
|
||||||
|
Hash = TextureID;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PointLightJob : RenderJob
|
||||||
|
{
|
||||||
|
glm::vec4 Position;
|
||||||
|
glm::vec4 Color;
|
||||||
|
float Radius;
|
||||||
|
float Intensity;
|
||||||
|
float Falloff;
|
||||||
|
float padding = 123;
|
||||||
|
|
||||||
|
void CalculateHash() override
|
||||||
|
{
|
||||||
|
Hash = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
struct RenderScene
|
struct RenderScene
|
||||||
{
|
{
|
||||||
::Camera* Camera = nullptr;
|
::Camera* Camera = nullptr;
|
||||||
std::list<std::shared_ptr<RenderJob>> ForwardJobs;
|
std::list<std::shared_ptr<RenderJob>> ForwardJobs;
|
||||||
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
||||||
std::list<std::shared_ptr<RenderJob>> TextJobs;
|
|
||||||
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
||||||
Rectangle Viewport;
|
Rectangle Viewport;
|
||||||
bool ClearDepth = false;
|
bool ClearDepth = false;
|
||||||
@@ -29,7 +62,6 @@ struct RenderScene
|
|||||||
{
|
{
|
||||||
ForwardJobs.clear();
|
ForwardJobs.clear();
|
||||||
PointLightJobs.clear();
|
PointLightJobs.clear();
|
||||||
TextJobs.clear();
|
|
||||||
DirectionalLightJobs.clear();
|
DirectionalLightJobs.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -66,4 +98,5 @@ public:
|
|||||||
private:
|
private:
|
||||||
int m_Size = 0;
|
int m_Size = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -33,7 +33,6 @@ private:
|
|||||||
|
|
||||||
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
|
||||||
bool OnSetCamera(Events::SetCamera &event);
|
bool OnSetCamera(Events::SetCamera &event);
|
||||||
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
|
||||||
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||||
|
|||||||
@@ -13,15 +13,10 @@
|
|||||||
#include "PickingPass.h"
|
#include "PickingPass.h"
|
||||||
#include "LightCullingPass.h"
|
#include "LightCullingPass.h"
|
||||||
#include "DrawFinalPass.h"
|
#include "DrawFinalPass.h"
|
||||||
#include "DrawScreenQuadPass.h"
|
|
||||||
#include "DrawBloomPass.h"
|
|
||||||
#include "DrawColorCorrectionPass.h"
|
|
||||||
#include "../Core/EventBroker.h"
|
#include "../Core/EventBroker.h"
|
||||||
#include "ImGuiRenderPass.h"
|
#include "ImGuiRenderPass.h"
|
||||||
#include "Camera.h"
|
#include "Camera.h"
|
||||||
#include "../Core/Transform.h"
|
#include "../Core/Transform.h"
|
||||||
#include "imgui/imgui.h"
|
|
||||||
#include "TextPass.h"
|
|
||||||
|
|
||||||
class Renderer : public IRenderer
|
class Renderer : public IRenderer
|
||||||
{
|
{
|
||||||
@@ -39,7 +34,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
//----------------------Variables----------------------//
|
//----------------------Variables----------------------//
|
||||||
EventBroker* m_EventBroker;
|
EventBroker* m_EventBroker;
|
||||||
TextPass* m_TextPass;
|
|
||||||
|
|
||||||
Texture* m_ErrorTexture;
|
Texture* m_ErrorTexture;
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
@@ -48,15 +42,10 @@ private:
|
|||||||
Model* m_UnitQuad;
|
Model* m_UnitQuad;
|
||||||
Model* m_UnitSphere;
|
Model* m_UnitSphere;
|
||||||
|
|
||||||
int m_DebugTextureToDraw = 0;
|
|
||||||
|
|
||||||
PickingPass* m_PickingPass;
|
PickingPass* m_PickingPass;
|
||||||
LightCullingPass* m_LightCullingPass;
|
LightCullingPass* m_LightCullingPass;
|
||||||
ImGuiRenderPass* m_ImGuiRenderPass;
|
ImGuiRenderPass* m_ImGuiRenderPass;
|
||||||
DrawFinalPass* m_DrawFinalPass;
|
DrawFinalPass* m_DrawFinalPass;
|
||||||
DrawScreenQuadPass* m_DrawScreenQuadPass;
|
|
||||||
DrawBloomPass* m_DrawBloomPass;
|
|
||||||
DrawColorCorrectionPass* m_DrawColorCorrectionPass;
|
|
||||||
|
|
||||||
//----------------------Functions----------------------//
|
//----------------------Functions----------------------//
|
||||||
void InitializeWindow();
|
void InitializeWindow();
|
||||||
@@ -66,13 +55,14 @@ private:
|
|||||||
//TODO: Renderer: Get InputUpdate out of renderer
|
//TODO: Renderer: Get InputUpdate out of renderer
|
||||||
void InputUpdate(double dt);
|
void InputUpdate(double dt);
|
||||||
//void PickingPass(RenderQueueCollection& rq);
|
//void PickingPass(RenderQueueCollection& rq);
|
||||||
//void DrawScreenQuad(GLuint textureToDraw);
|
void DrawScreenQuad(GLuint textureToDraw);
|
||||||
|
|
||||||
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
|
||||||
void SortRenderJobsByDepth(RenderScene &scene);
|
void SortRenderJobsByDepth(RenderScene &scene);
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
|
||||||
//--------------------ShaderPrograms-------------------//
|
//--------------------ShaderPrograms-------------------//
|
||||||
ShaderProgram* m_BasicForwardProgram;
|
ShaderProgram* m_BasicForwardProgram;
|
||||||
|
ShaderProgram* m_DrawScreenQuadProgram;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
#ifndef TextJob_h__
|
|
||||||
#define TextJob_h__
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
#include "../Common.h"
|
|
||||||
#include "../GLM.h"
|
|
||||||
#include "../Core/ComponentWrapper.h"
|
|
||||||
#include "Texture.h"
|
|
||||||
#include "RenderJob.h"
|
|
||||||
#include "../Core/ResourceManager.h"
|
|
||||||
#include "Font.h"
|
|
||||||
|
|
||||||
struct TextJob : RenderJob
|
|
||||||
{
|
|
||||||
TextJob(glm::mat4 matrix, Font* font, ComponentWrapper textComponent)
|
|
||||||
: RenderJob()
|
|
||||||
{
|
|
||||||
Matrix = matrix;
|
|
||||||
Color = (glm::vec4)textComponent["Color"];
|
|
||||||
Content = (std::string)textComponent["Content"];
|
|
||||||
Resource = font;
|
|
||||||
|
|
||||||
if ((int)textComponent["Alignment"] == textComponent["Alignment"].Enum("Left")) {
|
|
||||||
Alignment = AlignmentEnum::Left;
|
|
||||||
} else if ((int)textComponent["Alignment"] == textComponent["Alignment"].Enum("Right")) {
|
|
||||||
Alignment = AlignmentEnum::Right;
|
|
||||||
} else if ((int)textComponent["Alignment"] == textComponent["Alignment"].Enum("Center")) {
|
|
||||||
Alignment = AlignmentEnum::Center;
|
|
||||||
} else {
|
|
||||||
LOG_ERROR("Text alignment invalid");
|
|
||||||
Alignment = AlignmentEnum::Left;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
enum class AlignmentEnum
|
|
||||||
{
|
|
||||||
Left,
|
|
||||||
Right,
|
|
||||||
Center
|
|
||||||
};
|
|
||||||
|
|
||||||
glm::mat4 Matrix;
|
|
||||||
glm::vec4 Color;
|
|
||||||
std::string Content;
|
|
||||||
Font* Resource;
|
|
||||||
AlignmentEnum Alignment;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void CalculateHash() override
|
|
||||||
{
|
|
||||||
Hash = 0;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
#ifndef TextRenderer_h__
|
|
||||||
#define TextRenderer_h__
|
|
||||||
|
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
|
|
||||||
#include "../OpenGL.h"
|
|
||||||
#include "../GLM.h"
|
|
||||||
#include "ShaderProgram.h"
|
|
||||||
#include "Font.h"
|
|
||||||
#include "../Core/ResourceManager.h"
|
|
||||||
#include "RenderQueue.h"
|
|
||||||
#include "TextPassState.h"
|
|
||||||
#include "FrameBuffer.h"
|
|
||||||
|
|
||||||
class TextPass
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextPass();
|
|
||||||
void Initialize();
|
|
||||||
void Update();
|
|
||||||
void Draw(RenderScene& scene, FrameBuffer& frameBuffer);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void renderText(std::string text, Font* font, TextJob::AlignmentEnum alignment, glm::vec4 color, glm::mat4 modelMatrix, glm::mat4 projectionMatrix, glm::mat4 viewMatrix);
|
|
||||||
|
|
||||||
Font* font;
|
|
||||||
GLuint VAO, VBO;
|
|
||||||
ShaderProgram* m_TextProgram;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#ifndef TextPassState_h__
|
|
||||||
#define TextPassState_h__
|
|
||||||
|
|
||||||
#include "Rendering/RenderState.h"
|
|
||||||
|
|
||||||
class TextPassState : public RenderState
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
TextPassState(GLuint frameBuffer);
|
|
||||||
~TextPassState();
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -18,7 +18,6 @@ public:
|
|||||||
void Bind(GLenum textureUnit = GL_TEXTURE0);
|
void Bind(GLenum textureUnit = GL_TEXTURE0);
|
||||||
|
|
||||||
GLuint m_Texture = 0;
|
GLuint m_Texture = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
#ifndef CommonFuntions_h__
|
|
||||||
#define CommonFuntions_h__
|
|
||||||
|
|
||||||
#include "../../Common.h"
|
|
||||||
#include "../../OpenGL.h"
|
|
||||||
#include "../../GLM.h"
|
|
||||||
|
|
||||||
class CommonFuntions
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
CommonFuntions() = delete;
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -19,7 +19,6 @@
|
|||||||
#include "Rendering/RenderSystem.h"
|
#include "Rendering/RenderSystem.h"
|
||||||
#include "Core/EntityFileParser.h"
|
#include "Core/EntityFileParser.h"
|
||||||
#include "Core/Octree.h"
|
#include "Core/Octree.h"
|
||||||
#include "Rendering/Font.h"
|
|
||||||
#include "Systems/InterpolationSystem.h"
|
#include "Systems/InterpolationSystem.h"
|
||||||
// Network
|
// Network
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
<xs:include schemaLocation="Components/Model.xsd"/>
|
<xs:include schemaLocation="Components/Model.xsd"/>
|
||||||
<xs:include schemaLocation="Components/RaptorCopter.xsd"/>
|
<xs:include schemaLocation="Components/RaptorCopter.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Player.xsd"/>
|
<xs:include schemaLocation="Components/Player.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Text.xsd"/>
|
|
||||||
<xs:include schemaLocation="Components/Camera.xsd"/>
|
<xs:include schemaLocation="Components/Camera.xsd"/>
|
||||||
<xs:include schemaLocation="Components/AABB.xsd"/>
|
<xs:include schemaLocation="Components/AABB.xsd"/>
|
||||||
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
|
||||||
<Text xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Text.xsd">
|
|
||||||
<Content>Text</Content>
|
|
||||||
<Resource></Resource>
|
|
||||||
<Color R="1" G="1" B="1" A="1"/>
|
|
||||||
<Visible>true</Visible>
|
|
||||||
<Alignment><Center/></Alignment>
|
|
||||||
</Text>
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
<?xml version="1.0"?>
|
|
||||||
|
|
||||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
|
||||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
|
||||||
|
|
||||||
<xs:complexType name="AlignmentEnum" mixed="true">
|
|
||||||
<xs:complexContent>
|
|
||||||
<xs:extension base="t:enum">
|
|
||||||
<xs:choice>
|
|
||||||
<xs:element name="Right" type="xs:integer" fixed="0" minOccurs="0"/>
|
|
||||||
<xs:element name="Left" type="xs:integer" fixed="1" minOccurs="0"/>
|
|
||||||
<xs:element name="Center" type="xs:integer" fixed="2" minOccurs="0"/>
|
|
||||||
</xs:choice>
|
|
||||||
</xs:extension>
|
|
||||||
</xs:complexContent>
|
|
||||||
</xs:complexType>
|
|
||||||
|
|
||||||
<xs:element name="Text">
|
|
||||||
<xs:annotation>
|
|
||||||
<xs:documentation>A visible font loaded from disk</xs:documentation>
|
|
||||||
</xs:annotation>
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:all>
|
|
||||||
<xs:element name="Content" type="t:string" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>the content of the string printed</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="Resource" type="t:string" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>The asset file, font resolution, example: Fonts/font.ttf,16</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="Color" type="t:Color" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>Color</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>Wether the text is visible or not</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
<xs:element name="Alignment" type="AlignmentEnum" minOccurs="0">
|
|
||||||
<xs:annotation><xs:documentation>Text alignment</xs:documentation></xs:annotation>
|
|
||||||
</xs:element>
|
|
||||||
</xs:all>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
</xs:schema>
|
|
||||||
@@ -1,262 +1,58 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
<?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">
|
<Entity xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd" xmlns:c="components">
|
||||||
|
|
||||||
<Components>
|
<Components>
|
||||||
<c:Transform/>
|
<c:Transform>
|
||||||
</Components>
|
<Position X="0" Y="0" Z="0"/>
|
||||||
|
<Orientation X="0" Y="0" Z="0"/>
|
||||||
<Children>
|
</c:Transform>
|
||||||
<Entity>
|
</Components>
|
||||||
<Components>
|
<Children>
|
||||||
<c:Camera>
|
<Entity>
|
||||||
<Name>ActionCamera</Name>
|
<Components>
|
||||||
</c:Camera>
|
<c:Transform>
|
||||||
<c:Model>
|
<Position X="0" Y="1" Z="10"/>
|
||||||
<Resource>Models/Camera.obj</Resource>
|
</c:Transform>
|
||||||
</c:Model>
|
<c:Model>
|
||||||
<c:Transform>
|
<Resource>Models/Camera.obj</Resource>
|
||||||
<Position X="-0.504807115" Y="6.00582743" Z="9.68687439"/>
|
</c:Model>
|
||||||
<Orientation X="-0.733036518" Y="0.000105090476" Z="5.12391125e-07"/>
|
<c:Camera>
|
||||||
</c:Transform>
|
<Name>MainCamera</Name>
|
||||||
</Components>
|
</c:Camera>
|
||||||
<Children>
|
</Components>
|
||||||
<Entity>
|
</Entity>
|
||||||
<Components>
|
<Entity>
|
||||||
<c:Text>
|
<Components>
|
||||||
<Content>Camera #2</Content>
|
<c:Transform>
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
<Position X="5" Y="1" Z="5"/>
|
||||||
<Alignment>0</Alignment>
|
</c:Transform>
|
||||||
</c:Text>
|
<c:Model>
|
||||||
<c:Transform>
|
<Resource>Models/Camera.obj</Resource>
|
||||||
<Position X="0.700063765" Y="0.310270816" Z="-1"/>
|
</c:Model>
|
||||||
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
|
<c:Camera>
|
||||||
</c:Transform>
|
<Name>ActionCamera</Name>
|
||||||
</Components>
|
</c:Camera>
|
||||||
<Children/>
|
</Components>
|
||||||
</Entity>
|
</Entity>
|
||||||
</Children>
|
<Entity>
|
||||||
</Entity>
|
<Components>
|
||||||
<Entity>
|
<c:Transform>
|
||||||
<Components>
|
<Position X="0" Y="-1" Z="0"/>
|
||||||
<c:Model>
|
<Scale X="100" Y="1" Z="100"/>
|
||||||
<Resource>Models/Core/UnitPlane.obj</Resource>
|
</c:Transform>
|
||||||
</c:Model>
|
<c:Model>
|
||||||
<c:Transform>
|
<Resource>Models/Core/UnitPlane.obj</Resource>
|
||||||
<Position X="0" Y="-1" Z="0.600000024"/>
|
</c:Model>
|
||||||
<Scale X="100" Y="1" Z="100"/>
|
</Components>
|
||||||
</c:Transform>
|
</Entity>
|
||||||
</Components>
|
<Entity>
|
||||||
<Children/>
|
<Components>
|
||||||
</Entity>
|
<c:Transform>
|
||||||
<Entity>
|
<Position X="0" Y="0" Z="0"/>
|
||||||
<Components>
|
</c:Transform>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Assault.obj</Resource>
|
<Resource>An error</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
<c:Transform>
|
</Components>
|
||||||
<Position X="-2.5" Y="0" Z="1"/>
|
</Entity>
|
||||||
</c:Transform>
|
</Children>
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Text>
|
|
||||||
<Content>Welcome!</Content>
|
|
||||||
<Resource>Fonts/DroidSans.ttf,1280</Resource>
|
|
||||||
</c:Text>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0" Z="0.700000048"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:RaptorCopter>
|
|
||||||
<Speed>2</Speed>
|
|
||||||
<Axis X="0" Y="1" Z="0"/>
|
|
||||||
</c:RaptorCopter>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="2.37320328" Z="0"/>
|
|
||||||
<Orientation X="0" Y="8252.15918" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Color A="1" B="1" G="0" R="1"/>
|
|
||||||
<Radius>6</Radius>
|
|
||||||
<Intensity>0.5</Intensity>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-2.5" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Color A="1" B="0" G="0" R="1"/>
|
|
||||||
<Radius>8</Radius>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-5" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Color A="1" B="0" G="1" R="1"/>
|
|
||||||
<Radius>6</Radius>
|
|
||||||
<Intensity>0.5</Intensity>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0" Z="-2.5"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Color A="1" B="0" G="1" R="0"/>
|
|
||||||
<Radius>8</Radius>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0" Z="-5"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Color A="1" B="1" G="1" R="0"/>
|
|
||||||
<Radius>6</Radius>
|
|
||||||
<Intensity>0.5</Intensity>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0" Z="2.5"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Color A="1" B="1" G="0.00784313772" R="0"/>
|
|
||||||
<Radius>8</Radius>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0" Y="0" Z="5"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Radius>6</Radius>
|
|
||||||
<Intensity>0.5</Intensity>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="2.5" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:PointLight>
|
|
||||||
<Radius>8</Radius>
|
|
||||||
</c:PointLight>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="5" Y="0" Z="0"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Assault.obj</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="2.5" Y="0" Z="1"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Camera>
|
|
||||||
<Name>MainCamera</Name>
|
|
||||||
</c:Camera>
|
|
||||||
<c:Listener/>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Camera.obj</Resource>
|
|
||||||
<Visible>false</Visible>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-1.27354908" Y="5.18422079" Z="10.6223917"/>
|
|
||||||
<Orientation X="-0.436328411" Y="-0.0523675606" Z="1.67869363e-08"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Text>
|
|
||||||
<Content>Taiwan #1</Content>
|
|
||||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
|
||||||
<Alignment>0</Alignment>
|
|
||||||
</c:Text>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="0.716896772" Y="0.296712071" Z="-1"/>
|
|
||||||
<Scale X="0.100000001" Y="0.100000001" Z="0.100000001"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:DirectionalLight>
|
|
||||||
<Color A="1" B="0.996078432" G="1" R="1"/>
|
|
||||||
<Intensity>0.80000001192092896</Intensity>
|
|
||||||
</c:DirectionalLight>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/DirectionalLightWidget.obj</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-0.0013256073" Y="1.89540339" Z="6.53467274"/>
|
|
||||||
<Orientation X="-0.859663308" Y="-0.100310192" Z="-0.404723018"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
<Entity>
|
|
||||||
<Components>
|
|
||||||
<c:Model>
|
|
||||||
<Resource>Models/Core/UnitCube.obj</Resource>
|
|
||||||
</c:Model>
|
|
||||||
<c:Transform>
|
|
||||||
<Position X="-5.4082036" Y="0" Z="-1.84950542"/>
|
|
||||||
</c:Transform>
|
|
||||||
</Components>
|
|
||||||
<Children/>
|
|
||||||
</Entity>
|
|
||||||
</Children>
|
|
||||||
|
|
||||||
</Entity>
|
</Entity>
|
||||||
@@ -16,7 +16,6 @@
|
|||||||
<xs:element ref="c:RaptorCopter" minOccurs="0"/>
|
<xs:element ref="c:RaptorCopter" minOccurs="0"/>
|
||||||
<xs:element ref="c:Player" minOccurs="0"/>
|
<xs:element ref="c:Player" minOccurs="0"/>
|
||||||
<xs:element ref="c:Camera" minOccurs="0"/>
|
<xs:element ref="c:Camera" minOccurs="0"/>
|
||||||
<xs:element ref="c:Text" minOccurs="0"/>
|
|
||||||
<xs:element ref="c:AABB" minOccurs="0"/>
|
<xs:element ref="c:AABB" minOccurs="0"/>
|
||||||
<xs:element ref="c:Trigger" minOccurs="0"/>
|
<xs:element ref="c:Trigger" minOccurs="0"/>
|
||||||
<xs:element ref="c:Health" minOccurs="0"/>
|
<xs:element ref="c:Health" minOccurs="0"/>
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D SceneTexture;
|
|
||||||
layout (binding = 1) uniform sampler2D BloomTexture;
|
|
||||||
uniform float Exposure;
|
|
||||||
|
|
||||||
in VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Input;
|
|
||||||
|
|
||||||
out vec4 fragmentColor;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
const float gamma = 2.2;
|
|
||||||
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
|
|
||||||
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
|
||||||
hdrColor += bloomColor;
|
|
||||||
|
|
||||||
//Toon mapping thingy
|
|
||||||
vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
|
|
||||||
|
|
||||||
//gamme correction
|
|
||||||
result = pow(result, vec3(1.0 / gamma));
|
|
||||||
|
|
||||||
fragmentColor = vec4(result, 1.0);
|
|
||||||
//fragmentColor = hdrColor;
|
|
||||||
//fragmentColor = bloomColor;
|
|
||||||
//fragmentColor = vec4(1,0.5,0.7,1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 Position;
|
|
||||||
|
|
||||||
out VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Output;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_Position = vec4(Position, 1.0);
|
|
||||||
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
|
||||||
}
|
|
||||||
@@ -5,8 +5,8 @@ uniform mat4 V;
|
|||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
uniform vec2 ScreenDimensions;
|
uniform vec2 ScreenDimensions;
|
||||||
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
layout(binding = 0) uniform sampler2D DiffuseTexture;
|
||||||
layout (binding = 1) uniform sampler2D GlowMap;
|
layout(binding = 1) uniform sampler2D NormalMapTexture;
|
||||||
|
|
||||||
#define TILE_SIZE 16
|
#define TILE_SIZE 16
|
||||||
|
|
||||||
@@ -45,12 +45,13 @@ layout (std430, binding = 4) buffer LightIndexBuffer
|
|||||||
in VertexData{
|
in VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
|
vec3 Tangent;
|
||||||
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 DiffuseColor;
|
vec4 DiffuseColor;
|
||||||
}Input;
|
}Input;
|
||||||
|
|
||||||
out vec4 sceneColor;
|
out vec4 fragmentColor;
|
||||||
out vec4 bloomColor;
|
|
||||||
|
|
||||||
vec4 scene_ambient = vec4(0.3,0.3,0.3,1);
|
vec4 scene_ambient = vec4(0.3,0.3,0.3,1);
|
||||||
|
|
||||||
@@ -98,13 +99,18 @@ LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensi
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
|
||||||
|
{
|
||||||
|
mat3 TBN = mat3(tangent, bitangent, normal);
|
||||||
|
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
|
||||||
|
return vec4(TBN * normalize(NormalMap), 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
|
vec4 texel = texture2D(DiffuseTexture, Input.TextureCoordinate);
|
||||||
vec4 glowTexel = texture2D(GlowMap, Input.TextureCoordinate);
|
|
||||||
vec4 position = V * M * vec4(Input.Position, 1.0);
|
vec4 position = V * M * vec4(Input.Position, 1.0);
|
||||||
vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, NormalMapTexture);
|
||||||
vec4 viewVec = normalize(-position);
|
vec4 viewVec = normalize(-position);
|
||||||
|
|
||||||
vec2 tilePos;
|
vec2 tilePos;
|
||||||
@@ -123,42 +129,30 @@ void main()
|
|||||||
int l = int(LightIndex[i]);
|
int l = int(LightIndex[i]);
|
||||||
LightSource light = LightSources.List[l];
|
LightSource light = LightSources.List[l];
|
||||||
|
|
||||||
LightResult light_result;
|
LightResult result;
|
||||||
//These if statements should be removed.
|
|
||||||
if(light.Type == 1) { // point
|
if(light.Type == 1) { // point
|
||||||
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
|
||||||
} else if (light.Type == 2) { //Directional
|
} else if (light.Type == 2) { //Directional
|
||||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||||
}
|
}
|
||||||
totalLighting.Diffuse += light_result.Diffuse;
|
totalLighting.Diffuse += result.Diffuse;
|
||||||
totalLighting.Specular += light_result.Specular;
|
totalLighting.Specular += result.Specular;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sceneColor += Input.DiffuseColor;
|
|
||||||
vec4 color_result = Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * diffuseTexel * Color;
|
|
||||||
//bloomColor = vec4(0.3, 0.8, 0.6, 1.0);
|
|
||||||
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
|
||||||
//These if statements should be removed if they are slow.
|
|
||||||
color_result += glowTexel;
|
|
||||||
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
|
|
||||||
/*
|
|
||||||
if(color_result.x > 1 || color_result.y > 1 || color_result.z > 1) {
|
|
||||||
bloomColor = vec4(color_result.xyz, 1.0);
|
|
||||||
} else {
|
|
||||||
bloomColor = vec4(0.0, 0.0, 0.0, 1.0);
|
|
||||||
} */
|
|
||||||
|
|
||||||
//sceneColor += Input.DiffuseColor * (totalLighting.Diffuse) * diffuseTexel * Color;
|
//fragmentColor += Input.DiffuseColor;
|
||||||
//sceneColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1);
|
fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * texel * Color;
|
||||||
//sceneColor = diffuseTexel * Input.DiffuseColor * Color;
|
//fragmentColor += Input.DiffuseColor * (totalLighting.Diffuse) * texel * Color;
|
||||||
//sceneColor += vec4(currentTile/3600.f, 0, 0, 1);
|
//fragmentColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1);
|
||||||
|
//fragmentColor = texel * Input.DiffuseColor * Color;
|
||||||
|
//fragmentColor += vec4(currentTile/3600.f, 0, 0, 1);
|
||||||
|
|
||||||
//Tiled Debug Code
|
//Tiled Debug Code
|
||||||
/*
|
/*
|
||||||
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) {
|
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) {
|
||||||
sceneColor += vec4(0.5, 0, 0, 0);
|
fragmentColor += vec4(0.5, 0, 0, 0);
|
||||||
} else {
|
} else {
|
||||||
sceneColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1);
|
fragmentColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1);
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ layout(location = 10) in vec4 BoneWeights2;
|
|||||||
out VertexData{
|
out VertexData{
|
||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
|
vec3 Tangent;
|
||||||
|
vec3 BiTangent;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
vec4 DiffuseColor;
|
vec4 DiffuseColor;
|
||||||
}Output;
|
}Output;
|
||||||
@@ -30,5 +32,7 @@ void main()
|
|||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
||||||
|
Output.Tangent = vec3(M * vec4(Tangent, 0.0));
|
||||||
|
Output.BiTangent = vec3(M * vec4(BiTangent, 0.0));
|
||||||
Output.DiffuseColor = DiffuseVertexColor;
|
Output.DiffuseColor = DiffuseVertexColor;
|
||||||
}
|
}
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D Texture;
|
|
||||||
|
|
||||||
in VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Input;
|
|
||||||
|
|
||||||
out vec4 fragmentColor;
|
|
||||||
|
|
||||||
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec2 tex_offset = 1.0 / textureSize(Texture, 0);
|
|
||||||
vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
|
||||||
|
|
||||||
for(int i = 1; i < 5; ++i) {
|
|
||||||
result += texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
||||||
result += texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0)).rgb * weight[i];
|
|
||||||
}
|
|
||||||
fragmentColor = vec4(result, 1.0);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 Position;
|
|
||||||
|
|
||||||
out VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Output;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_Position = vec4(Position, 1.0);
|
|
||||||
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout (binding = 0) uniform sampler2D Texture;
|
|
||||||
|
|
||||||
in VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Input;
|
|
||||||
|
|
||||||
out vec4 fragmentColor;
|
|
||||||
|
|
||||||
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec2 tex_offset = 1.0 / textureSize(Texture, 0);
|
|
||||||
vec3 result = texture(Texture, Input.TextureCoordinate).rgb * weight[0];
|
|
||||||
|
|
||||||
for(int i = 1; i < 5; ++i) {
|
|
||||||
result += texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
||||||
result += texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i)).rgb * weight[i];
|
|
||||||
}
|
|
||||||
fragmentColor = vec4(result, 1.0);
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#version 430
|
|
||||||
|
|
||||||
layout (location = 0) in vec3 Position;
|
|
||||||
|
|
||||||
out VertexData{
|
|
||||||
vec2 TextureCoordinate;
|
|
||||||
}Output;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_Position = vec4(Position, 1.0);
|
|
||||||
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
#version 430
|
|
||||||
in vec2 TexCoords;
|
|
||||||
out vec4 color;
|
|
||||||
|
|
||||||
uniform sampler2D text;
|
|
||||||
uniform vec4 textColor;
|
|
||||||
|
|
||||||
out vec4 sceneColor;
|
|
||||||
out vec4 bloomColor;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
vec4 sampled = vec4(1.0, 1.0, 1.0, texture(text, TexCoords).r);
|
|
||||||
vec4 color_result = textColor * sampled;
|
|
||||||
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
|
||||||
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0) * sampled;
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#version 430
|
|
||||||
layout (location = 0) in vec4 vertex; // <vec2 pos, vec2 tex>
|
|
||||||
out vec2 TexCoords;
|
|
||||||
|
|
||||||
uniform mat4 M;
|
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
|
|
||||||
void main()
|
|
||||||
{
|
|
||||||
gl_Position = P * V * M * vec4(vertex.xy, 0.0, 1.0);
|
|
||||||
TexCoords = vertex.zw;
|
|
||||||
}
|
|
||||||
@@ -8,7 +8,6 @@ find_package(assimp REQUIRED)
|
|||||||
find_package(ZLIB REQUIRED)
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(PNG REQUIRED)
|
find_package(PNG REQUIRED)
|
||||||
find_package(Xerces REQUIRED)
|
find_package(Xerces REQUIRED)
|
||||||
find_package(Freetype REQUIRED)
|
|
||||||
# Because FindOpenAL is retarded
|
# Because FindOpenAL is retarded
|
||||||
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/deps/include/OpenAL")
|
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "${CMAKE_SOURCE_DIR}/deps/include/OpenAL")
|
||||||
find_package(OpenAL REQUIRED)
|
find_package(OpenAL REQUIRED)
|
||||||
@@ -26,7 +25,6 @@ include_directories(
|
|||||||
${assimp_INCLUDE_DIRS}
|
${assimp_INCLUDE_DIRS}
|
||||||
${PNG_INCLUDE_DIRS}
|
${PNG_INCLUDE_DIRS}
|
||||||
${Xerces_INCLUDE_DIRS}
|
${Xerces_INCLUDE_DIRS}
|
||||||
${FREETYPE_INCLUDE_DIRS}
|
|
||||||
${OPENAL_INCLUDE_DIR}
|
${OPENAL_INCLUDE_DIR}
|
||||||
${X11_INCLUDE_DIRS}
|
${X11_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
@@ -128,7 +126,6 @@ set(LIBRARIES
|
|||||||
${assimp_LIBRARIES}
|
${assimp_LIBRARIES}
|
||||||
${PNG_LIBRARIES}
|
${PNG_LIBRARIES}
|
||||||
${Xerces_LIBRARIES}
|
${Xerces_LIBRARIES}
|
||||||
${FREETYPE_LIBRARIES}
|
|
||||||
${OPENAL_LIBRARY}
|
${OPENAL_LIBRARY}
|
||||||
${X11_LIBRARIES}
|
${X11_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
#include "Rendering/DrawBloomPass.h"
|
|
||||||
|
|
||||||
DrawBloomPass::DrawBloomPass(IRenderer* renderer)
|
|
||||||
{
|
|
||||||
m_Renderer = renderer;
|
|
||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
|
||||||
|
|
||||||
InitializeTextures();
|
|
||||||
InitializeBuffers();
|
|
||||||
InitializeShaderPrograms();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawBloomPass::InitializeTextures()
|
|
||||||
{
|
|
||||||
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawBloomPass::InitializeShaderPrograms()
|
|
||||||
{
|
|
||||||
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("##GaussianProgramHoriz");
|
|
||||||
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_horiz.vert.glsl")));
|
|
||||||
m_GaussianProgram_horiz->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl")));
|
|
||||||
m_GaussianProgram_horiz->Compile();
|
|
||||||
m_GaussianProgram_horiz->Link();
|
|
||||||
|
|
||||||
m_GaussianProgram_vert = ResourceManager::Load<ShaderProgram>("##GaussianProgramVert");
|
|
||||||
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Gaussian_vert.vert.glsl")));
|
|
||||||
m_GaussianProgram_vert->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Gaussian_vert.frag.glsl")));
|
|
||||||
m_GaussianProgram_vert->Compile();
|
|
||||||
m_GaussianProgram_vert->Link();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DrawBloomPass::InitializeBuffers()
|
|
||||||
{
|
|
||||||
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
|
||||||
m_GaussianFrameBuffer_horiz.Generate();
|
|
||||||
|
|
||||||
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
|
|
||||||
m_GaussianFrameBuffer_vert.Generate();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DrawBloomPass::ClearBuffer()
|
|
||||||
{
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
m_GaussianFrameBuffer_horiz.Unbind();
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
m_GaussianFrameBuffer_vert.Unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawBloomPass::Draw(GLuint texture)
|
|
||||||
{
|
|
||||||
GLERROR("DrawBloomPass::Draw: Pre");
|
|
||||||
|
|
||||||
DrawBloomPassState state;
|
|
||||||
|
|
||||||
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
|
|
||||||
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
|
|
||||||
|
|
||||||
|
|
||||||
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
|
||||||
m_GaussianProgram_horiz->Bind();
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
|
||||||
|
|
||||||
//Iterate some times to make it more gaussian.
|
|
||||||
for (int i = 1; i < m_iterations; i++) {
|
|
||||||
//Vertical pass
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
|
||||||
m_GaussianProgram_vert->Bind();
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
|
||||||
|
|
||||||
//horizontal pass
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_horiz.Bind();
|
|
||||||
m_GaussianProgram_horiz->Bind();
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
//final vertical gaussian after the iterations are done
|
|
||||||
|
|
||||||
m_GaussianFrameBuffer_vert.Bind();
|
|
||||||
m_GaussianProgram_vert->Bind();
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
|
||||||
|
|
||||||
GLERROR("DrawBloomPass::Draw: END");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
|
||||||
{
|
|
||||||
glGenTextures(1, texture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
|
|
||||||
GLERROR("Texture initialization failed");
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
#include "Rendering/DrawBloomPassState.h"
|
|
||||||
|
|
||||||
|
|
||||||
DrawBloomPassState::DrawBloomPassState()
|
|
||||||
{
|
|
||||||
//BindFramebuffer(0);
|
|
||||||
Disable(GL_BLEND);
|
|
||||||
Disable(GL_DEPTH_TEST);
|
|
||||||
Disable(GL_CULL_FACE);
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawBloomPassState::~DrawBloomPassState()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
#include "Rendering/DrawColorCorrectionPass.h"
|
|
||||||
|
|
||||||
DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer)
|
|
||||||
{
|
|
||||||
m_Renderer = renderer;
|
|
||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
|
||||||
m_Exposure = 1; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting.
|
|
||||||
|
|
||||||
InitializeShaderPrograms();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawColorCorrectionPass::InitializeShaderPrograms()
|
|
||||||
{
|
|
||||||
m_ColorCorrectionProgram = ResourceManager::Load<ShaderProgram>("#ColorCorrectionProgram");
|
|
||||||
m_ColorCorrectionProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/DrawColorCorrection.vert.glsl")));
|
|
||||||
m_ColorCorrectionProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/DrawColorCorrection.frag.glsl")));
|
|
||||||
m_ColorCorrectionProgram->Compile();
|
|
||||||
m_ColorCorrectionProgram->Link();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture)
|
|
||||||
{
|
|
||||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
|
||||||
|
|
||||||
DrawScreenQuadPassState state = DrawScreenQuadPassState();
|
|
||||||
m_ColorCorrectionProgram->Bind();
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
glUniform1f(glGetUniformLocation(m_ColorCorrectionProgram->GetHandle(), "Exposure"), m_Exposure);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, sceneTexture);
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, bloomTexture);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
|
||||||
}
|
|
||||||
@@ -6,31 +6,12 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling
|
|||||||
m_LightCullingPass = lightCullingPass;
|
m_LightCullingPass = lightCullingPass;
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
InitializeShaderPrograms();
|
InitializeShaderPrograms();
|
||||||
InitializeFrameBuffers();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeTextures()
|
void DrawFinalPass::InitializeTextures()
|
||||||
{
|
{
|
||||||
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
m_WhiteTexture = ResourceManager::Load<Texture>("Textures/Core/Blank.png");
|
||||||
m_BlackTexture = ResourceManager::Load<Texture>("Textures/Core/Black.png");
|
m_NeutralNormalMap = ResourceManager::Load<Texture>("Textures/Core/NeutralNormalMap.png");
|
||||||
}
|
|
||||||
|
|
||||||
void DrawFinalPass::InitializeFrameBuffers()
|
|
||||||
{
|
|
||||||
glGenRenderbuffers(1, &m_DepthBuffer);
|
|
||||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
|
||||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
|
||||||
|
|
||||||
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
|
||||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
|
||||||
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
|
||||||
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_FLOAT, 4);
|
|
||||||
|
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
|
||||||
m_FinalPassFrameBuffer.Generate();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeShaderPrograms()
|
void DrawFinalPass::InitializeShaderPrograms()
|
||||||
@@ -39,8 +20,6 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
m_ForwardPlusProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
|
m_ForwardPlusProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
|
||||||
m_ForwardPlusProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlus.frag.glsl")));
|
m_ForwardPlusProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlus.frag.glsl")));
|
||||||
m_ForwardPlusProgram->Compile();
|
m_ForwardPlusProgram->Compile();
|
||||||
m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor");
|
|
||||||
m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor");
|
|
||||||
m_ForwardPlusProgram->Link();
|
m_ForwardPlusProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,7 +27,7 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
{
|
{
|
||||||
GLERROR("DrawFinalPass::Draw: Pre");
|
GLERROR("DrawFinalPass::Draw: Pre");
|
||||||
|
|
||||||
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
DrawFinalPassState state;
|
||||||
|
|
||||||
m_ForwardPlusProgram->Bind();
|
m_ForwardPlusProgram->Bind();
|
||||||
GLuint shaderHandle = m_ForwardPlusProgram->GetHandle();
|
GLuint shaderHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
@@ -73,20 +52,22 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
if(modelJob->DiffuseTexture != nullptr) {
|
if(modelJob->DiffuseTexture != nullptr) {
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
|
||||||
} else {
|
} else {
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||||
}
|
}
|
||||||
glActiveTexture(GL_TEXTURE1);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
|
||||||
|
|
||||||
/*if(modelJob->GlowMap != nullptr) {
|
if (modelJob->NormalTexture != nullptr) {
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->GlowMap->m_Texture);
|
glActiveTexture(GL_TEXTURE1);
|
||||||
} else {
|
glBindTexture(GL_TEXTURE_2D, modelJob->NormalTexture->m_Texture);
|
||||||
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
}
|
||||||
}*/
|
else {
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_NeutralNormalMap->m_Texture);
|
||||||
|
}
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
@@ -95,42 +76,6 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_FinalPassFrameBuffer.Unbind();
|
|
||||||
GLERROR("DrawFinalPass::Draw: END");
|
GLERROR("DrawFinalPass::Draw: END");
|
||||||
delete state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void DrawFinalPass::ClearBuffer()
|
|
||||||
{
|
|
||||||
m_FinalPassFrameBuffer.Bind();
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
||||||
m_FinalPassFrameBuffer.Unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
|
||||||
{
|
|
||||||
glGenTextures(1, texture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr);//TODO: Renderer: Fix the precision and Resolution
|
|
||||||
GLERROR("Texture initialization failed");
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const
|
|
||||||
{
|
|
||||||
glGenTextures(1, texture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
|
||||||
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture);
|
|
||||||
glGenerateMipmap(GL_TEXTURE_2D);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
|
||||||
GLERROR("MipMap Texture initialization failed");
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
#include "Rendering/DrawFinalPassState.h"
|
#include "Rendering/DrawFinalPassState.h"
|
||||||
|
|
||||||
|
|
||||||
DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
DrawFinalPassState::DrawFinalPassState()
|
||||||
{
|
{
|
||||||
BindFramebuffer(frameBuffer);
|
BindFramebuffer(0);
|
||||||
Enable(GL_BLEND);
|
Enable(GL_BLEND);
|
||||||
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
Enable(GL_DEPTH_TEST);
|
Enable(GL_DEPTH_TEST);
|
||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f));
|
ClearColor(glm::vec4(200.f / 255, 0.f / 255, 200.f / 255, 0.f));
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawFinalPassState::~DrawFinalPassState()
|
DrawFinalPassState::~DrawFinalPassState()
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
#include "Rendering/DrawScreenQuadPass.h"
|
|
||||||
|
|
||||||
DrawScreenQuadPass::DrawScreenQuadPass(IRenderer* renderer)
|
|
||||||
{
|
|
||||||
m_Renderer = renderer;
|
|
||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
|
||||||
|
|
||||||
InitializeShaderPrograms();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawScreenQuadPass::InitializeShaderPrograms()
|
|
||||||
{
|
|
||||||
m_DrawQuadProgram = ResourceManager::Load<ShaderProgram>("#DrawScreenQuadProgram");
|
|
||||||
m_DrawQuadProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/DrawScreenQuad.vert.glsl")));
|
|
||||||
m_DrawQuadProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/DrawScreenQuad.frag.glsl")));
|
|
||||||
m_DrawQuadProgram->Compile();
|
|
||||||
m_DrawQuadProgram->Link();
|
|
||||||
}
|
|
||||||
|
|
||||||
void DrawScreenQuadPass::Draw(GLuint texture)
|
|
||||||
{
|
|
||||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
|
||||||
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
|
||||||
|
|
||||||
DrawScreenQuadPassState state = DrawScreenQuadPassState();
|
|
||||||
m_DrawQuadProgram->Bind();
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
|
||||||
|
|
||||||
glBindVertexArray(m_ScreenQuad->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
|
||||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
#include "Rendering/DrawScreenQuadPassState.h"
|
|
||||||
|
|
||||||
|
|
||||||
DrawScreenQuadPassState::DrawScreenQuadPassState()
|
|
||||||
{
|
|
||||||
GLERROR("---");
|
|
||||||
BindFramebuffer(0);
|
|
||||||
GLERROR("---");
|
|
||||||
Disable(GL_DEPTH_TEST);
|
|
||||||
Disable(GL_CULL_FACE);
|
|
||||||
Disable(GL_BLEND);
|
|
||||||
ClearColor(glm::vec4(0.f));
|
|
||||||
}
|
|
||||||
|
|
||||||
DrawScreenQuadPassState::~DrawScreenQuadPassState()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,108 +0,0 @@
|
|||||||
#include "Rendering/Font.h"
|
|
||||||
|
|
||||||
|
|
||||||
Font::Font(std::string path)
|
|
||||||
{
|
|
||||||
typedef boost::tokenizer<boost::char_separator<char>> tokenizer;
|
|
||||||
boost::char_separator<char> sep(",");
|
|
||||||
tokenizer tok(path, sep);
|
|
||||||
|
|
||||||
|
|
||||||
tokenizer::iterator it = tok.begin();
|
|
||||||
std::string filePath = "";
|
|
||||||
|
|
||||||
if (it != tok.end()) {
|
|
||||||
filePath = (*it).c_str();
|
|
||||||
it++;
|
|
||||||
if (it != tok.end()) {
|
|
||||||
if((*it).c_str() == "") {
|
|
||||||
throw std::runtime_error("");
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
FontSize = boost::lexical_cast<int>((*it).c_str());
|
|
||||||
} catch (boost::bad_lexical_cast const&) {
|
|
||||||
LOG_ERROR("input string did not have a valid font resolution");
|
|
||||||
throw std::runtime_error("");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw std::runtime_error("");;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FT_Library library;
|
|
||||||
FT_Face face;
|
|
||||||
|
|
||||||
if (FT_Init_FreeType(&library)) {
|
|
||||||
LOG_ERROR("FreeType error: init failed");
|
|
||||||
throw std::runtime_error("");;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FT_New_Face(library, filePath.c_str(), 0, &face)) {
|
|
||||||
LOG_ERROR("FreeType error: loading font");
|
|
||||||
throw std::runtime_error("");;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Set_Char_Size(face, 0, FontSize*64, 300, 300); // temp
|
|
||||||
FT_Set_Pixel_Sizes(face, 0, FontSize); //
|
|
||||||
|
|
||||||
if (FT_Load_Char(face, 'X', FT_LOAD_RENDER)) {
|
|
||||||
LOG_ERROR("FreeType error: loading char");
|
|
||||||
throw std::runtime_error("");;
|
|
||||||
}
|
|
||||||
|
|
||||||
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
|
|
||||||
|
|
||||||
for (GLubyte c = 0; c < 128; c++) {
|
|
||||||
|
|
||||||
|
|
||||||
//Load character glyph
|
|
||||||
if (FT_Load_Char(face, c, FT_LOAD_RENDER)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Generate texture
|
|
||||||
GLuint texture;
|
|
||||||
glGenTextures(1, &texture);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
|
||||||
|
|
||||||
glTexImage2D(
|
|
||||||
GL_TEXTURE_2D,
|
|
||||||
0,
|
|
||||||
GL_RED,
|
|
||||||
face->glyph->bitmap.width,
|
|
||||||
face->glyph->bitmap.rows,
|
|
||||||
0,
|
|
||||||
GL_RED,
|
|
||||||
GL_UNSIGNED_BYTE,
|
|
||||||
face->glyph->bitmap.buffer
|
|
||||||
);
|
|
||||||
// Set texture options
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
// Now store character for later use
|
|
||||||
Character character = {
|
|
||||||
texture,
|
|
||||||
glm::ivec2(face->glyph->bitmap.width, face->glyph->bitmap.rows),
|
|
||||||
glm::ivec2(face->glyph->bitmap_left, face->glyph->bitmap_top),
|
|
||||||
face->glyph->advance.x
|
|
||||||
};
|
|
||||||
|
|
||||||
m_Characters.insert(std::pair<GLchar, Character>(c, character));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
FT_Done_Face(face);
|
|
||||||
FT_Done_FreeType(library);
|
|
||||||
GLERROR("Font Load");
|
|
||||||
}
|
|
||||||
|
|
||||||
Font::~Font()
|
|
||||||
{
|
|
||||||
for (auto c : m_Characters) {
|
|
||||||
glDeleteTextures(1, &c.second.TextureID);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -55,9 +55,8 @@ void FrameBuffer::Generate()
|
|||||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
||||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
||||||
if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 ||
|
if ( (*it)->m_Attachment != GL_COLOR_ATTACHMENT0 ||
|
||||||
(*it)->m_Attachment != GL_COLOR_ATTACHMENT1 ||
|
|
||||||
(*it)->m_Attachment != GL_DEPTH_ATTACHMENT ||
|
(*it)->m_Attachment != GL_DEPTH_ATTACHMENT ||
|
||||||
(*it)->m_Attachment != GL_STENCIL_ATTACHMENT) //TODO: Viktor: Fixa detta
|
(*it)->m_Attachment != GL_STENCIL_ATTACHMENT)
|
||||||
{
|
{
|
||||||
LOG_ERROR("RenderBuffer Attachment not valid.");
|
LOG_ERROR("RenderBuffer Attachment not valid.");
|
||||||
}
|
}
|
||||||
@@ -70,8 +69,10 @@ void FrameBuffer::Generate()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
GLenum* bufferTextures = &attachments[0];
|
GLenum* bufferTextures = &attachments[0];
|
||||||
glDrawBuffers(attachments.size(), bufferTextures);
|
glDrawBuffers(1, bufferTextures);
|
||||||
|
|
||||||
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||||
LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
||||||
|
|||||||
@@ -47,56 +47,61 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
{
|
{
|
||||||
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle());
|
||||||
|
|
||||||
|
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
|
|
||||||
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
GLuint ShaderHandle = m_PickingProgram->GetHandle();
|
||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
|
|
||||||
if (scene.ClearDepth) {
|
if (scene.ClearDepth) {
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
m_Camera = scene.Camera;
|
|
||||||
|
|
||||||
for (auto &job : scene.ForwardJobs) {
|
m_Camera = scene.Camera;
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
|
||||||
|
|
||||||
if (modelJob) {
|
for (auto &job : scene.ForwardJobs) {
|
||||||
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
PickingInfo pickInfo;
|
if (modelJob) {
|
||||||
pickInfo.Entity = modelJob->Entity;
|
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
||||||
pickInfo.World = modelJob->World;
|
|
||||||
pickInfo.Camera = scene.Camera;
|
|
||||||
|
|
||||||
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
PickingInfo pickInfo;
|
||||||
if (color != m_EntityColors.end()) {
|
pickInfo.Entity = modelJob->Entity;
|
||||||
pickColor[0] = color->second[0];
|
pickInfo.World = modelJob->World;
|
||||||
pickColor[1] = color->second[1];
|
pickInfo.Camera = scene.Camera;
|
||||||
} else {
|
|
||||||
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
||||||
if (m_ColorCounter[0] > 255) {
|
if (color != m_EntityColors.end()) {
|
||||||
m_ColorCounter[0] = 0;
|
pickColor[0] = color->second[0];
|
||||||
m_ColorCounter[1]++;
|
pickColor[1] = color->second[1];
|
||||||
} else {
|
} else {
|
||||||
m_ColorCounter[0]++;
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
|
if (m_ColorCounter[0] > 255) {
|
||||||
|
m_ColorCounter[0] = 0;
|
||||||
|
m_ColorCounter[1]++;;
|
||||||
|
} else {
|
||||||
|
m_ColorCounter[0]++;;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(ShaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
|
||||||
glUniform2fv(glGetUniformLocation(ShaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
|
||||||
glDrawElementsBaseVertex(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, nullptr, modelJob->StartIndex);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
m_PickingBuffer.Unbind();
|
m_PickingBuffer.Unbind();
|
||||||
GLERROR("PickingPass Error");
|
GLERROR("PickingPass Error");
|
||||||
|
|
||||||
|
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ PickingPassState::PickingPassState(GLuint frameBuffer)
|
|||||||
GLERROR("---3");
|
GLERROR("---3");
|
||||||
Enable(GL_DEPTH_TEST);
|
Enable(GL_DEPTH_TEST);
|
||||||
Enable(GL_CULL_FACE);
|
Enable(GL_CULL_FACE);
|
||||||
Disable(GL_BLEND);
|
|
||||||
|
|
||||||
glm::vec4 clearColor = glm::vec4(0.f);
|
glm::vec4 clearColor = glm::vec4(0.f);
|
||||||
//ClearColor(clearColor);
|
//ClearColor(clearColor);
|
||||||
|
|||||||
@@ -110,42 +110,6 @@ void RenderSystem::fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RenderSystem::fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world)
|
|
||||||
{
|
|
||||||
auto texts = world->GetComponents("Text");
|
|
||||||
if (texts == nullptr) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& textComponent : *texts) {
|
|
||||||
bool visible = textComponent["Visible"];
|
|
||||||
if (!visible) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
std::string resource = textComponent["Resource"];
|
|
||||||
if (resource.empty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Font* font;
|
|
||||||
try {
|
|
||||||
font = ResourceManager::Load<Font>(resource);
|
|
||||||
} catch (const std::exception&) {
|
|
||||||
try {
|
|
||||||
font = ResourceManager::Load<Font>("Fonts/DroidSans.ttf,16");
|
|
||||||
} catch (const std::exception&) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glm::mat4 modelMatrix = Transform::ModelMatrix(textComponent.EntityID, world);
|
|
||||||
std::shared_ptr<TextJob> modelJob = std::shared_ptr<TextJob>(new TextJob(modelMatrix, font, textComponent));
|
|
||||||
jobs.push_back(modelJob);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RenderSystem::OnInputCommand(const Events::InputCommand& e)
|
bool RenderSystem::OnInputCommand(const Events::InputCommand& e)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@@ -168,7 +132,6 @@ void RenderSystem::Update(double dt)
|
|||||||
fillModels(scene.ForwardJobs);
|
fillModels(scene.ForwardJobs);
|
||||||
fillPointLights(scene.PointLightJobs, m_World);
|
fillPointLights(scene.PointLightJobs, m_World);
|
||||||
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
||||||
fillText(scene.TextJobs, m_World);
|
|
||||||
m_RenderFrame->Add(scene);
|
m_RenderFrame->Add(scene);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,6 @@ void Renderer::Initialize()
|
|||||||
glfwSwapInterval(m_VSYNC);
|
glfwSwapInterval(m_VSYNC);
|
||||||
InitializeShaders();
|
InitializeShaders();
|
||||||
InitializeTextures();
|
InitializeTextures();
|
||||||
m_TextPass = new TextPass();
|
|
||||||
m_TextPass->Initialize();
|
|
||||||
|
|
||||||
|
|
||||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
||||||
m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj");
|
m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj");
|
||||||
@@ -63,6 +60,12 @@ void Renderer::InitializeWindow()
|
|||||||
void Renderer::InitializeShaders()
|
void Renderer::InitializeShaders()
|
||||||
{
|
{
|
||||||
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
|
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
|
||||||
|
|
||||||
|
m_DrawScreenQuadProgram = ResourceManager::Load<ShaderProgram>("#DrawScreenQuadProgram");
|
||||||
|
m_DrawScreenQuadProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/DrawScreenQuad.vert.glsl")));
|
||||||
|
m_DrawScreenQuadProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/DrawScreenQuad.frag.glsl")));
|
||||||
|
m_DrawScreenQuadProgram->Compile();
|
||||||
|
m_DrawScreenQuadProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InputUpdate(double dt)
|
void Renderer::InputUpdate(double dt)
|
||||||
@@ -74,22 +77,15 @@ void Renderer::Update(double dt)
|
|||||||
{
|
{
|
||||||
m_EventBroker->Process<Renderer>();
|
m_EventBroker->Process<Renderer>();
|
||||||
InputUpdate(dt);
|
InputUpdate(dt);
|
||||||
m_TextPass->Update();
|
|
||||||
m_ImGuiRenderPass->Update(dt);
|
m_ImGuiRenderPass->Update(dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::Draw(RenderFrame& frame)
|
void Renderer::Draw(RenderFrame& frame)
|
||||||
{
|
{
|
||||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking");
|
glClearColor(255.f / 255, 163.f / 255, 176.f / 255, 0.f);
|
||||||
//clear buffer 0
|
|
||||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
//Clear other buffers
|
|
||||||
m_PickingPass->ClearPicking();
|
m_PickingPass->ClearPicking();
|
||||||
m_DrawFinalPass->ClearBuffer();
|
|
||||||
m_DrawBloomPass->ClearBuffer();
|
|
||||||
|
|
||||||
for (auto scene : frame.RenderScenes){
|
for (auto scene : frame.RenderScenes){
|
||||||
|
|
||||||
SortRenderJobsByDepth(*scene);
|
SortRenderJobsByDepth(*scene);
|
||||||
@@ -98,27 +94,9 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
m_LightCullingPass->FillLightList(*scene);
|
m_LightCullingPass->FillLightList(*scene);
|
||||||
m_LightCullingPass->CullLights(*scene);
|
m_LightCullingPass->CullLights(*scene);
|
||||||
m_DrawFinalPass->Draw(*scene);
|
m_DrawFinalPass->Draw(*scene);
|
||||||
|
//m_DrawScenePass->Draw(rq);
|
||||||
|
|
||||||
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
||||||
|
|
||||||
m_TextPass->Draw(*scene, *m_DrawFinalPass->FinalPassFrameBuffer());
|
|
||||||
|
|
||||||
}
|
|
||||||
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
|
||||||
if(m_DebugTextureToDraw == 0) {
|
|
||||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture());
|
|
||||||
}
|
|
||||||
if (m_DebugTextureToDraw == 1) {
|
|
||||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
|
||||||
}
|
|
||||||
if (m_DebugTextureToDraw == 2) {
|
|
||||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTexture());
|
|
||||||
}
|
|
||||||
if (m_DebugTextureToDraw == 3) {
|
|
||||||
m_DrawScreenQuadPass->Draw(m_DrawBloomPass->GaussianTexture());
|
|
||||||
}
|
|
||||||
if (m_DebugTextureToDraw == 4) {
|
|
||||||
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ImGuiRenderPass->Draw();
|
m_ImGuiRenderPass->Draw();
|
||||||
@@ -130,6 +108,27 @@ PickData Renderer::Pick(glm::vec2 screenCoord)
|
|||||||
return m_PickingPass->Pick(screenCoord);
|
return m_PickingPass->Pick(screenCoord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Renderer::DrawScreenQuad(GLuint textureToDraw)
|
||||||
|
{
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||||
|
|
||||||
|
glDisable(GL_DEPTH_TEST);
|
||||||
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
|
glClearColor(0.f, 0.f, 0.f, 1.f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
|
||||||
|
m_DrawScreenQuadProgram->Bind();
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, textureToDraw);
|
||||||
|
|
||||||
|
glBindVertexArray(m_ScreenQuad->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||||
|
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].EndIndex - m_ScreenQuad->MaterialGroups()[0].StartIndex +1
|
||||||
|
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].StartIndex);
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::InitializeTextures()
|
void Renderer::InitializeTextures()
|
||||||
{
|
{
|
||||||
m_ErrorTexture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
m_ErrorTexture = ResourceManager::Load<Texture>("Textures/Core/ErrorTexture.png");
|
||||||
@@ -160,7 +159,4 @@ void Renderer::InitializeRenderPasses()
|
|||||||
m_PickingPass = new PickingPass(this, m_EventBroker);
|
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||||
m_LightCullingPass = new LightCullingPass(this);
|
m_LightCullingPass = new LightCullingPass(this);
|
||||||
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass);
|
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass);
|
||||||
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
|
||||||
m_DrawBloomPass = new DrawBloomPass(this);
|
|
||||||
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,113 +0,0 @@
|
|||||||
#include "Rendering/TextPass.h"
|
|
||||||
|
|
||||||
TextPass::TextPass()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextPass::Initialize()
|
|
||||||
{
|
|
||||||
glGenVertexArrays(1, &VAO);
|
|
||||||
glGenBuffers(1, &VBO);
|
|
||||||
glBindVertexArray(VAO);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 6 * 4, NULL, GL_DYNAMIC_DRAW);
|
|
||||||
glEnableVertexAttribArray(0);
|
|
||||||
glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), 0);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
glBindVertexArray(0);
|
|
||||||
|
|
||||||
m_TextProgram = ResourceManager::Load<ShaderProgram>("#TextProgram");
|
|
||||||
m_TextProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Text.vert.glsl")));
|
|
||||||
m_TextProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/Text.frag.glsl")));
|
|
||||||
m_TextProgram->Compile();
|
|
||||||
m_TextProgram->BindFragDataLocation(0, "sceneColor");
|
|
||||||
m_TextProgram->BindFragDataLocation(1, "bloomColor");
|
|
||||||
m_TextProgram->Link();
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextPass::Update()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
|
|
||||||
{
|
|
||||||
GLERROR("Derp1");
|
|
||||||
TextPassState* state = new TextPassState(frameBuffer.GetHandle());
|
|
||||||
for (auto &job : scene.TextJobs) {
|
|
||||||
auto textJob = std::dynamic_pointer_cast<TextJob>(job);
|
|
||||||
if (textJob) {
|
|
||||||
|
|
||||||
renderText(textJob->Content, textJob->Resource, textJob->Alignment, textJob->Color, textJob->Matrix, scene.Camera->ProjectionMatrix(), scene.Camera->ViewMatrix());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GLERROR("Derp2");
|
|
||||||
delete state;
|
|
||||||
}
|
|
||||||
|
|
||||||
void TextPass::renderText(std::string text, Font* font, TextJob::AlignmentEnum alignment, glm::vec4 color, glm::mat4 modelMatrix, glm::mat4 projectionMatrix, glm::mat4 viewMatrix)
|
|
||||||
{
|
|
||||||
GLfloat penX = 0;
|
|
||||||
GLfloat penY = 0;
|
|
||||||
GLfloat scale = 1.0/font->FontSize;
|
|
||||||
|
|
||||||
GLfloat stringWidth = 0.f;
|
|
||||||
|
|
||||||
for (std::string::const_iterator c = text.begin(); c != text.end(); c++) {
|
|
||||||
Font::Character ch = font->m_Characters[*c];
|
|
||||||
stringWidth += (ch.Advance >> 6) * scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(alignment == TextJob::AlignmentEnum::Center) {
|
|
||||||
penX = -stringWidth/2.f;
|
|
||||||
} else if (alignment == TextJob::AlignmentEnum::Right) {
|
|
||||||
penX = -stringWidth;
|
|
||||||
} else {
|
|
||||||
penX = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
m_TextProgram->Bind();
|
|
||||||
glUniform4fv(glGetUniformLocation(m_TextProgram->GetHandle(), "textColor"), 1, glm::value_ptr(color));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_TextProgram->GetHandle(), "M"), 1, GL_FALSE, glm::value_ptr(modelMatrix));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_TextProgram->GetHandle(), "V"), 1, GL_FALSE, glm::value_ptr(viewMatrix));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_TextProgram->GetHandle(), "P"), 1, GL_FALSE, glm::value_ptr(projectionMatrix));
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
glBindVertexArray(VAO);
|
|
||||||
|
|
||||||
|
|
||||||
for (std::string::const_iterator c = text.begin(); c != text.end(); c++) {
|
|
||||||
Font::Character ch = font->m_Characters[*c];
|
|
||||||
|
|
||||||
GLfloat xpos = penX + ch.Bearing.x * scale;
|
|
||||||
GLfloat ypos = penY - (ch.Size.y - ch.Bearing.y) * scale;
|
|
||||||
|
|
||||||
GLfloat w = ch.Size.x * scale;
|
|
||||||
GLfloat h = ch.Size.y * scale;
|
|
||||||
|
|
||||||
GLfloat vertices[6][4] = {
|
|
||||||
{ xpos, ypos + h, 0.0, 0.0 },
|
|
||||||
{ xpos, ypos, 0.0, 1.0 },
|
|
||||||
{ xpos + w, ypos, 1.0, 1.0 },
|
|
||||||
|
|
||||||
{ xpos, ypos + h, 0.0, 0.0 },
|
|
||||||
{ xpos + w, ypos, 1.0, 1.0 },
|
|
||||||
{ xpos + w, ypos + h, 1.0, 0.0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, ch.TextureID);
|
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, VBO);
|
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertices), vertices);
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
|
||||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
|
||||||
penX += (ch.Advance >> 6) * scale; // Bitshift by 6 to get value in pixels (2^6 = 64)
|
|
||||||
}
|
|
||||||
glBindVertexArray(0);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, 0);
|
|
||||||
|
|
||||||
GLERROR("Text rendering Error");
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#include "Rendering/TextPassState.h"
|
|
||||||
|
|
||||||
|
|
||||||
TextPassState::TextPassState(GLuint frameBuffer)
|
|
||||||
{
|
|
||||||
BindFramebuffer(frameBuffer);
|
|
||||||
glEnable(GL_BLEND);
|
|
||||||
glDisable(GL_CULL_FACE);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
}
|
|
||||||
|
|
||||||
TextPassState::~TextPassState()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
#include "Rendering/Util/CommonFunctions.h"
|
|
||||||
|
|
||||||
@@ -20,7 +20,6 @@ Game::Game(int argc, char* argv[])
|
|||||||
ResourceManager::RegisterType<Texture>("Texture");
|
ResourceManager::RegisterType<Texture>("Texture");
|
||||||
ResourceManager::RegisterType<ShaderProgram>("ShaderProgram");
|
ResourceManager::RegisterType<ShaderProgram>("ShaderProgram");
|
||||||
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
ResourceManager::RegisterType<EntityFile>("EntityFile");
|
||||||
ResourceManager::RegisterType<Font>("FontFile");
|
|
||||||
|
|
||||||
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
m_Config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||||
ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true);
|
ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true);
|
||||||
|
|||||||
@@ -66,9 +66,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
|||||||
nextPossibleCapturePoint["Blue"] = -1;
|
nextPossibleCapturePoint["Blue"] = -1;
|
||||||
for (size_t i = 0; i < m_NumberOfCapturePoints; i++)
|
for (size_t i = 0; i < m_NumberOfCapturePoints; i++)
|
||||||
{
|
{
|
||||||
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
||||||
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) {
|
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint == 0) {
|
||||||
nextPossibleCapturePoint["Red"] = i + 1;
|
nextPossibleCapturePoint["Red"] = i + 1;
|
||||||
@@ -79,9 +76,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper
|
|||||||
}
|
}
|
||||||
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
|
for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
if (!m_World->HasComponent(m_CapturePointNumberToEntityIDMap[i], "Team")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
ComponentWrapper& capturePointOwnedBy = m_World->GetComponent(m_CapturePointNumberToEntityIDMap[i], "Team");
|
||||||
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) {
|
if ((int)capturePointOwnedBy["Team"] == redTeam && m_RedTeamHomeCapturePoint != 0) {
|
||||||
nextPossibleCapturePoint["Red"] = i - 1;
|
nextPossibleCapturePoint["Red"] = i - 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user