Compare commits

..

4 Commits

Author SHA1 Message Date
Teejoon cc5943fcee WIP fix? 2016-02-26 18:36:49 +01:00
Teejoon 62e22d3821 Fix 2016-02-26 13:32:16 +01:00
Teejoon 0805375483 Deleted SSAO sliders except Quality 2016-02-26 13:25:19 +01:00
Teejoon f56705d921 You can now change the quality of SSAO by sliding the SSAO Quality 2016-02-26 11:51:20 +01:00
37 changed files with 459 additions and 269 deletions
@@ -24,7 +24,6 @@ public:
private: private:
Octree<EntityAABB>* m_Octree; Octree<EntityAABB>* m_Octree;
std::vector<EntityAABB> m_OctreeResult; std::vector<EntityAABB> m_OctreeResult;
std::unordered_map<EntityWrapper, glm::vec3> m_PrevPositions;
}; };
#endif #endif
-2
View File
@@ -29,7 +29,6 @@ struct EntityWrapper
EntityWrapper Parent(); EntityWrapper Parent();
EntityWrapper FirstChildByName(const std::string& name); EntityWrapper FirstChildByName(const std::string& name);
EntityWrapper FirstParentWithComponent(const std::string& componentType); EntityWrapper FirstParentWithComponent(const std::string& componentType);
EntityWrapper Clone(EntityWrapper parent = EntityWrapper::Invalid);
bool IsChildOf(EntityWrapper potentialParent); bool IsChildOf(EntityWrapper potentialParent);
bool Valid() const; bool Valid() const;
@@ -40,7 +39,6 @@ struct EntityWrapper
private: private:
EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent); EntityWrapper firstChildByNameRecursive(const std::string& name, EntityID parent);
EntityWrapper cloneRecursive(EntityWrapper entity, EntityWrapper parent);
}; };
namespace std namespace std
+1 -1
View File
@@ -40,7 +40,7 @@ public:
// Change the parent of an entity // Change the parent of an entity
void SetParent(EntityID entity, EntityID parent); void SetParent(EntityID entity, EntityID parent);
// Get children of an entity // Get children of an entity
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> GetDirectChildren(EntityID entity); const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> GetChildren(EntityID entity);
// Get all component pools // Get all component pools
const std::unordered_map<std::string, ComponentPool*>& GetComponentPools() const { return m_ComponentPools; } const std::unordered_map<std::string, ComponentPool*>& GetComponentPools() const { return m_ComponentPools; }
// Get the entity children map // Get the entity children map
-8
View File
@@ -73,12 +73,6 @@ public:
// Called when the user means to rename an entity. // Called when the user means to rename an entity.
typedef std::function<void(EntityWrapper, const std::string&)> OnEntityChangeName_t; typedef std::function<void(EntityWrapper, const std::string&)> OnEntityChangeName_t;
void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; } void SetEntityChangeNameCallback(OnEntityChangeName_t f) { m_OnEntityChangeName = f; }
// Called when the user pastes an entity previously "copied"
// @param EntityWrapper The entity to copy
// @param EntityWrapper The entity to parent the new copy to
// @return The new copy of the entity
typedef std::function<EntityWrapper(EntityWrapper, EntityWrapper)> OnEntityPaste_t;
void SetEntityPasteCallback(OnEntityPaste_t f) { m_OnEntityPaste = f; }
// Called when the user means to attach a new component to an entity. // Called when the user means to attach a new component to an entity.
typedef std::function<void(EntityWrapper, const std::string&)> OnComponentAttach_t; typedef std::function<void(EntityWrapper, const std::string&)> OnComponentAttach_t;
void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; } void SetComponentAttachCallback(OnComponentAttach_t f) { m_OnComponentAttach = f; }
@@ -117,7 +111,6 @@ private:
std::string m_DroppedFile = ""; std::string m_DroppedFile = "";
bool m_Paused = false; bool m_Paused = false;
bool m_MouseLocked = false; bool m_MouseLocked = false;
EntityWrapper m_CopyTarget = EntityWrapper::Invalid;
// Callbacks // Callbacks
OnEntitySelectedCallback_t m_OnEntitySelected = nullptr; OnEntitySelectedCallback_t m_OnEntitySelected = nullptr;
@@ -131,7 +124,6 @@ private:
OnComponentDelete_t m_OnComponentDelete = nullptr; OnComponentDelete_t m_OnComponentDelete = nullptr;
OnWidgetMode_t m_OnWidgetMode = nullptr; OnWidgetMode_t m_OnWidgetMode = nullptr;
OnWidgetSpace_t m_OnWidgetSpace = nullptr; OnWidgetSpace_t m_OnWidgetSpace = nullptr;
OnEntityPaste_t m_OnEntityPaste = nullptr;
// Events // Events
EventRelay<EditorGUI, Events::KeyDown> m_EKeyDown; EventRelay<EditorGUI, Events::KeyDown> m_EKeyDown;
-1
View File
@@ -56,7 +56,6 @@ private:
void OnEntityDelete(EntityWrapper entity); void OnEntityDelete(EntityWrapper entity);
void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent); void OnEntityChangeParent(EntityWrapper entity, EntityWrapper parent);
void OnEntityChangeName(EntityWrapper entity, const std::string& name); void OnEntityChangeName(EntityWrapper entity, const std::string& name);
EntityWrapper OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent);
void OnComponentAttach(EntityWrapper entity, const std::string& componentType); void OnComponentAttach(EntityWrapper entity, const std::string& componentType);
void OnComponentDelete(EntityWrapper entity, const std::string& componentType); void OnComponentDelete(EntityWrapper entity, const std::string& componentType);
void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace); void OnWidgetSpace(EditorGUI::WidgetSpace widgetSpace);
-1
View File
@@ -19,7 +19,6 @@
#include "Core/World.h" #include "Core/World.h"
#include "Core/EventBroker.h" #include "Core/EventBroker.h"
#include "Core/ConfigFile.h" #include "Core/ConfigFile.h"
#include "Core/EPlayerDeath.h"
#include "Input/EInputCommand.h" #include "Input/EInputCommand.h"
#include "Core/EPlayerDamage.h" #include "Core/EPlayerDamage.h"
#include "../Game/Events/EDoubleJump.h" #include "../Game/Events/EDoubleJump.h"
+15 -4
View File
@@ -12,7 +12,7 @@
class DrawBloomPass class DrawBloomPass
{ {
public: public:
DrawBloomPass(IRenderer* renderer /* ,Texture or finalpass*/ ); DrawBloomPass(IRenderer* renderer, ConfigFile* config);
~DrawBloomPass() { } ~DrawBloomPass() { }
void InitializeTextures(); void InitializeTextures();
void InitializeFrameBuffers(); void InitializeFrameBuffers();
@@ -23,23 +23,34 @@ public:
void FillGaussianBuffer(FrameBuffer* fb); void FillGaussianBuffer(FrameBuffer* fb);
void Draw(GLuint texture); void Draw(GLuint texture);
void ChangeQuality(int quality);
void OnWindowResize(); void OnWindowResize();
//Getters //Getters
//Return the blurred result of the texture that was sent into draw //Return the blurred result of the texture that was sent into draw
GLuint GaussianTexture() const { return m_GaussianTexture_vert; } GLuint GaussianTexture() const {
if (m_Quality == 0) {
return m_BlackTexture->m_Texture;
}
else {
return m_GaussianTexture_vert;
}
}
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;
Texture* m_WhiteTexture; Texture* m_BlackTexture;
Model* m_ScreenQuad; Model* m_ScreenQuad;
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
ConfigFile* m_Config;
//const LightCullingPass* m_LightCullingPass //const LightCullingPass* m_LightCullingPass
GLuint m_iterations = 9; int m_Iterations = 7;
int m_Quality = 3;
GLuint m_GaussianTexture_horiz; GLuint m_GaussianTexture_horiz;
GLuint m_GaussianTexture_vert; GLuint m_GaussianTexture_vert;
+5 -3
View File
@@ -5,6 +5,7 @@
#include "DrawFinalPassState.h" #include "DrawFinalPassState.h"
#include "LightCullingPass.h" #include "LightCullingPass.h"
#include "CubeMapPass.h" #include "CubeMapPass.h"
#include "SSAOPass.h"
#include "FrameBuffer.h" #include "FrameBuffer.h"
#include "ShaderProgram.h" #include "ShaderProgram.h"
#include "Util/UnorderedMapVec2.h" #include "Util/UnorderedMapVec2.h"
@@ -14,12 +15,12 @@
class DrawFinalPass class DrawFinalPass
{ {
public: public:
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass); DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass);
~DrawFinalPass() { } ~DrawFinalPass() { }
void InitializeTextures(); void InitializeTextures();
void InitializeFrameBuffers(); void InitializeFrameBuffers();
void InitializeShaderPrograms(); void InitializeShaderPrograms();
void Draw(RenderScene& scene, GLuint SSAOTexture); void Draw(RenderScene& scene);
void ClearBuffer(); void ClearBuffer();
void OnWindowResize(); void OnWindowResize();
@@ -38,7 +39,7 @@ private:
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const; void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene); void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture); void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
@@ -71,6 +72,7 @@ private:
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
const LightCullingPass* m_LightCullingPass; const LightCullingPass* m_LightCullingPass;
const CubeMapPass* m_CubeMapPass; const CubeMapPass* m_CubeMapPass;
const SSAOPass* m_SSAOPass;
ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ForwardPlusProgram;
ShaderProgram* m_ExplosionEffectProgram; ShaderProgram* m_ExplosionEffectProgram;
+1
View File
@@ -5,6 +5,7 @@
#include "../OpenGL.h" #include "../OpenGL.h"
#include "../GLM.h" #include "../GLM.h"
#include "../Core/Util/Rectangle.h" #include "../Core/Util/Rectangle.h"
#include "../Core/ConfigFile.h"
#include "Util/ScreenCoords.h" #include "Util/ScreenCoords.h"
#include "Camera.h" #include "Camera.h"
#include "RenderQueue.h" #include "RenderQueue.h"
+6 -8
View File
@@ -32,8 +32,9 @@ class Renderer : public IRenderer
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height); static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
public: public:
Renderer(EventBroker* eventBroker) Renderer(EventBroker* eventBroker, ConfigFile* config)
: m_EventBroker(eventBroker) : m_EventBroker(eventBroker)
, m_Config(config)
{ } { }
virtual void Initialize() override; virtual void Initialize() override;
@@ -47,6 +48,7 @@ private:
//----------------------Variables----------------------// //----------------------Variables----------------------//
static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer; static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer;
ConfigFile* m_Config;
EventBroker* m_EventBroker; EventBroker* m_EventBroker;
TextPass* m_TextPass; TextPass* m_TextPass;
@@ -61,12 +63,8 @@ private:
int m_DebugTextureToDraw = 0; int m_DebugTextureToDraw = 0;
int m_CubeMapTexture = 0; int m_CubeMapTexture = 0;
bool m_ResizeWindow = false; bool m_ResizeWindow = false;
float m_SSAO_Radius = 1.0f; int m_SSAO_Quality = 0;
float m_SSAO_Bias = 0.05f; int m_GLOW_Quality = 2;
float m_SSAO_Contrast = 1.5f;
float m_SSAO_IntensityScale = 1.0f;
int m_SSAO_NumOfSamples = 24;
int m_SSAO_NumOfTurns = 7;
PickingPass* m_PickingPass; PickingPass* m_PickingPass;
LightCullingPass* m_LightCullingPass; LightCullingPass* m_LightCullingPass;
+34 -8
View File
@@ -13,18 +13,32 @@
class SSAOPass class SSAOPass
{ {
public: public:
SSAOPass(IRenderer* rendere); SSAOPass(IRenderer* renderer, ConfigFile* config);
~SSAOPass() { ~SSAOPass() { };
delete m_DrawBloomPass;
}; void ChangeQuality(int quality);
void Draw(GLuint depthBuffer, Camera* camera); void Draw(GLuint depthBuffer, Camera* camera);
void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns); void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality);
void ClearBuffer(); void ClearBuffer();
void OnWindowResize(); void OnWindowResize();
//Return the SSAO of the texture sent to Draw //Return the SSAO of the texture sent to Draw
GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); } GLuint SSAOTexture() const {
if (m_Quality == 0) {
return m_WhiteTexture->m_Texture;
} else {
return m_GaussianTexture_vert;
}
}
int TextureQuality() const {
if (m_Quality == 0) {
return 13;
} else {
return m_TextureQuality;
}
}
private: private:
void InitializeTexture(); void InitializeTexture();
@@ -40,6 +54,7 @@ private:
Model* m_ScreenQuad; Model* m_ScreenQuad;
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
ConfigFile* m_Config;
float m_Radius; float m_Radius;
float m_Bias; float m_Bias;
@@ -47,6 +62,11 @@ private:
float m_IntensityScale; float m_IntensityScale;
int m_NumOfSamples; int m_NumOfSamples;
int m_NumOfTurns; int m_NumOfTurns;
int m_Iterations;
int m_TextureQuality;
int m_Quality = 0;
Texture* m_WhiteTexture;
GLuint m_SSAOTexture; GLuint m_SSAOTexture;
FrameBuffer m_SSAOFramBuffer; FrameBuffer m_SSAOFramBuffer;
@@ -54,10 +74,16 @@ private:
GLuint m_SSAOViewSpaceZTexture; GLuint m_SSAOViewSpaceZTexture;
FrameBuffer m_SSAOViewSpaceZFramBuffer; FrameBuffer m_SSAOViewSpaceZFramBuffer;
GLuint m_GaussianTexture_horiz;
GLuint m_GaussianTexture_vert;
FrameBuffer m_GaussianFrameBuffer_horiz;
FrameBuffer m_GaussianFrameBuffer_vert;
ShaderProgram* m_SSAOProgram; ShaderProgram* m_SSAOProgram;
ShaderProgram* m_SSAOViewSpaceZProgram; ShaderProgram* m_SSAOViewSpaceZProgram;
ShaderProgram* m_GaussianProgram_horiz;
DrawBloomPass* m_DrawBloomPass; ShaderProgram* m_GaussianProgram_vert;
}; };
#endif #endif
+34 -1
View File
@@ -36,4 +36,37 @@ ResourceLoading=true
[Sound] [Sound]
BGMVolume=1.0 BGMVolume=1.0
SFXVolume=1.0 SFXVolume=1.0
Announcer=female Announcer=female
[SSAO]
Quality=0
[SSAO1]
Radius=1.0
Bias=0.02
Contrast=1.5
Intensity=1.0
NumSamples=8
NumTurns=3
NumIterations=5
TextureQuality=2
[SSAO2]
Radius=1.0
Bias=0.02
Contrast=1.5
Intensity=1.0
NumSamples=16
NumTurns=13
NumIterations=9
TextureQuality=1
[SSAO3]
Radius=1.0
Bias=0.02
Contrast=1.5
Intensity=1.0
NumSamples=24
NumTurns=17
NumIterations=13
TextureQuality=0
+1
View File
@@ -2,6 +2,7 @@
<Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd"> <Physics xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Physics.xsd">
<Velocity X="0" Y="0" Z="0"/> <Velocity X="0" Y="0" Z="0"/>
<Gravity>true</Gravity> <Gravity>true</Gravity>
<PrevOrigin X="-9876.5" Y="-9876.5" Z="-9876.5"/>
<IsOnGround>false</IsOnGround> <IsOnGround>false</IsOnGround>
<VerticalStepHeight>0.33</VerticalStepHeight> <VerticalStepHeight>0.33</VerticalStepHeight>
</Physics> </Physics>
+1
View File
@@ -13,6 +13,7 @@
<xs:annotation><xs:documentation>m/s^2</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>m/s^2</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="Gravity" type="t:bool" minOccurs="0"/> <xs:element name="Gravity" type="t:bool" minOccurs="0"/>
<xs:element name="PrevOrigin" type="t:Vector" minOccurs="0"/>
<xs:element name="IsOnGround" type="t:bool" minOccurs="0"/> <xs:element name="IsOnGround" type="t:bool" minOccurs="0"/>
<xs:element name="VerticalStepHeight" type="t:double" minOccurs="0"> <xs:element name="VerticalStepHeight" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>The largest height of a "stair-step" that can be walked over</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>The largest height of a "stair-step" that can be walked over</xs:documentation></xs:annotation>
+1
View File
@@ -13,6 +13,7 @@
<c:DashAbility/> <c:DashAbility/>
<c:Health/> <c:Health/>
<c:Physics> <c:Physics>
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/> <Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
</c:Physics> </c:Physics>
<c:Player> <c:Player>
+1
View File
@@ -13,6 +13,7 @@
<c:DashAbility/> <c:DashAbility/>
<c:Health/> <c:Health/>
<c:Physics> <c:Physics>
<PrevOrigin X="0" Y="0.772000015" Z="0"/>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/> <Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
</c:Physics> </c:Physics>
<c:Player> <c:Player>
+2 -1
View File
@@ -13,6 +13,7 @@ uniform vec4 AmbientColor;
uniform float FillPercentage; uniform float FillPercentage;
uniform float GlowIntensity = 10; uniform float GlowIntensity = 10;
uniform vec3 CameraPosition; uniform vec3 CameraPosition;
uniform int SSAOQuality;
uniform vec2 DiffuseUVRepeat; uniform vec2 DiffuseUVRepeat;
uniform vec2 NormalUVRepeat; uniform vec2 NormalUVRepeat;
@@ -125,7 +126,7 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
void main() void main()
{ {
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat); vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat); vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
@@ -11,6 +11,7 @@ uniform vec4 DiffuseColor;
uniform vec4 FillColor; uniform vec4 FillColor;
uniform vec4 Color; uniform vec4 Color;
uniform vec4 AmbientColor; uniform vec4 AmbientColor;
uniform int SSAOQuality;
//Get bineded at the same time as the textures //Get bineded at the same time as the textures
uniform vec2 DiffuseUVRepeat1; uniform vec2 DiffuseUVRepeat1;
@@ -177,7 +178,7 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
void main() void main()
{ {
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate); vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
+7 -12
View File
@@ -2,11 +2,11 @@
//Number of samples per pixel //Number of samples per pixel
uniform int uNumOfSamples; uniform int uNumOfSamples;
//#define NUM_SAMPLES (11) //#define uNumOfSamples (11)
//Number of turns around the cirle //Number of turns around the cirle
uniform int uNumOfTurns; uniform int uNumOfTurns;
//#define NUM_TURNS (7) //#define uNumOfTurns (7)
layout (binding = 0) uniform sampler2D ViewSpaceZ; layout (binding = 0) uniform sampler2D ViewSpaceZ;
@@ -16,15 +16,16 @@ uniform float uProjScale;
//#define ProjScale 500 //#define ProjScale 500
uniform float uRadius; uniform float uRadius;
//#define Radius 1.0f //#define uRadius 1.0f
uniform float uBias; uniform float uBias;
//#define Bias 0.012f //#define uBias 0.05f
uniform float uContrast; uniform float uContrast;
//#define IntensityDivR6 1 //#define uContrast 1.5f
uniform float uIntensityScale; uniform float uIntensityScale;
//#define uIntensityScale 1.0f
out float AO; out float AO;
@@ -88,13 +89,7 @@ void main() {
vec3 origin = getVSPosition(originScreenCoord); vec3 origin = getVSPosition(originScreenCoord);
float radius; float radius = min(origin.z, uRadius);
if(origin.z < uRadius){
radius = origin.z;
} else {
radius = uRadius;
}
vec3 originNormal = getVSFaceNormal(origin); vec3 originNormal = getVSFaceNormal(origin);
+5
View File
@@ -2,7 +2,12 @@
layout (location = 0) in vec3 Position; layout (location = 0) in vec3 Position;
out VertexData{
vec2 TextureCoordinate;
}Output;
void main() void main()
{ {
gl_Position = vec4(Position, 1.0); gl_Position = vec4(Position, 1.0);
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
} }
+5 -1
View File
@@ -3,11 +3,15 @@
layout (binding = 0) uniform sampler2D DepthBuffer; layout (binding = 0) uniform sampler2D DepthBuffer;
uniform vec3 ClipInfo; uniform vec3 ClipInfo;
in VertexData{
vec2 TextureCoordinate;
}Input;
out float depthLinear; out float depthLinear;
//Just for Debug, should be depthLinear //Just for Debug, should be depthLinear
//out vec4 fragmentColor; //out vec4 fragmentColor;
void main() { void main() {
float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r; float depthSample = texture2D(DepthBuffer, Input.TextureCoordinate).r;
depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]); depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]);
//float depthLinear = (NearClip) / ( -depthSample + 1.0f); //float depthLinear = (NearClip) / ( -depthSample + 1.0f);
//fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f); //fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f);
+43 -45
View File
@@ -16,51 +16,51 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
EntityAABB& boxA = *boundingBox; EntityAABB& boxA = *boundingBox;
bool everHitTheGround = false; bool everHitTheGround = false;
auto prevPosIt = m_PrevPositions.find(entity); glm::vec3 size = boxA.Size();
if (prevPosIt != m_PrevPositions.end()) { float diameter = std::min(size.x, size.z);
glm::vec3 size = boxA.Size(); glm::vec3 prevOrigin = (glm::vec3)cPhysics["PrevOrigin"];
float diameter = std::min(size.x, size.z); glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin;
glm::vec3 prevOrigin = prevPosIt->second; float rayLength = glm::length(toCurrentPos) + 0.5f*diameter;
glm::vec3 toCurrentPos = boxA.Origin() - prevOrigin; //If the entity has moved farther than the size of its box, we need to handle it specially.
float rayLength = glm::length(toCurrentPos) + 0.5f*diameter; bool traceCollision = rayLength > diameter;
//If the entity has moved farther than the size of its box, we need to handle it specially. //hack solution: If prevOrigin is less than -9000 in all dimensions,
if (rayLength > diameter) { //then it means it is not set, i.e. this is the first collision check for the entity.
Ray ray(prevOrigin, toCurrentPos); if (traceCollision && glm::any(glm::greaterThan((glm::vec3)cPhysics["PrevOrigin"], glm::vec3(-9000.f)))) {
m_OctreeResult.clear(); Ray ray(prevOrigin, toCurrentPos);
m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult); m_OctreeResult.clear();
for (auto& boxB : m_OctreeResult) { m_Octree->ObjectsPossiblyHitByRay(ray, m_OctreeResult);
if (boxA.Entity == boxB.Entity) { for (auto& boxB : m_OctreeResult) {
if (boxA.Entity == boxB.Entity) {
continue;
}
bool hit;
float dist;
if (boxB.Entity.HasComponent("Model")) {
RawModel* model;
std::string res = (std::string)boxB.Entity["Model"]["Resource"];
try {
model = ResourceManager::Load<RawModel, true>(res);
} catch (const std::exception&) {
continue; continue;
} }
bool hit; float u, v;
float dist; hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v);
if (boxB.Entity.HasComponent("Model")) { } else {
RawModel* model; hit = Collision::RayVsAABB(ray, boxB, dist);
std::string res = (std::string)boxB.Entity["Model"]["Resource"]; }
try { if (hit && dist < rayLength) {
model = ResourceManager::Load<RawModel, true>(res); //Set the entity to where it was colliding, minus the maximum box size.
} catch (const std::exception&) { //TODO: Perhaps this should be done slightly more properly.
continue; glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction();
} glm::vec3 resolve = newOriginPos - boxA.Origin();
float u, v; (glm::vec3&)cTransform["Position"] += resolve;
hit = Collision::RayVsModel(ray, model->Vertices(), model->m_Indices, Transform::ModelMatrix(boxB.Entity), dist, u, v); boxA = *Collision::EntityAbsoluteAABB(entity);
} else { if (resolve.y > 0) {
hit = Collision::RayVsAABB(ray, boxB, dist); everHitTheGround = true;
} (bool)cPhysics["IsOnGround"] = true;
if (hit && dist < rayLength) { ((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
//Set the entity to where it was colliding, minus the maximum box size.
//TODO: Perhaps this should be done slightly more properly.
glm::vec3 newOriginPos = ray.Origin() + (dist - 0.707107f*diameter) * ray.Direction();
glm::vec3 resolve = newOriginPos - boxA.Origin();
(glm::vec3&)cTransform["Position"] += resolve;
boxA = *Collision::EntityAbsoluteAABB(entity);
if (resolve.y > 0) {
everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true;
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
}
break;
} }
break;
} }
} }
} }
@@ -90,7 +90,6 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
(glm::vec3&)cTransform["Position"] += resolutionVector; (glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity; cPhysics["Velocity"] = inOutVelocity;
if (isOnGround) { if (isOnGround) {
everHitTheGround = true; everHitTheGround = true;
@@ -100,7 +99,6 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
} else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) { } else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
//Enter here if boxB has no Model. //Enter here if boxB has no Model.
(glm::vec3&)cTransform["Position"] += resolutionVector; (glm::vec3&)cTransform["Position"] += resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity);
if (resolutionVector.y > 0) { if (resolutionVector.y > 0) {
everHitTheGround = true; everHitTheGround = true;
(bool)cPhysics["IsOnGround"] = true; (bool)cPhysics["IsOnGround"] = true;
@@ -114,5 +112,5 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
(bool)cPhysics["IsOnGround"] = false; (bool)cPhysics["IsOnGround"] = false;
} }
m_PrevPositions[entity] = boxA.Origin(); (glm::vec3&)cPhysics["PrevOrigin"] = boxA.Origin();
} }
+1 -36
View File
@@ -51,17 +51,6 @@ EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& compone
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
EntityWrapper EntityWrapper::Clone(EntityWrapper parent /*= Invalid*/)
{
if (!Valid()) {
return EntityWrapper::Invalid;
}
EntityWrapper clone = cloneRecursive(*this, EntityWrapper::Invalid);
this->World->SetParent(clone.ID, parent.ID);
return clone;
}
bool EntityWrapper::IsChildOf(EntityWrapper potentialParent) bool EntityWrapper::IsChildOf(EntityWrapper potentialParent)
{ {
EntityWrapper entity = *this; EntityWrapper entity = *this;
@@ -122,7 +111,7 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name,
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
auto itPair = this->World->GetDirectChildren(parent); auto itPair = this->World->GetChildren(parent);
if (itPair.first == itPair.second) { if (itPair.first == itPair.second) {
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
@@ -142,27 +131,3 @@ EntityWrapper EntityWrapper::firstChildByNameRecursive(const std::string& name,
return EntityWrapper::Invalid; return EntityWrapper::Invalid;
} }
EntityWrapper EntityWrapper::cloneRecursive(EntityWrapper entity, EntityWrapper parent)
{
EntityWrapper clone = EntityWrapper(entity.World, entity.World->CreateEntity(parent.ID));
entity.World->SetName(clone.ID, entity.Name());
// Clone components
for (auto& kv : entity.World->GetComponentPools()) {
if (kv.second->KnowsEntity(entity.ID)) {
ComponentWrapper c1 = kv.second->GetByEntity(entity.ID);
ComponentWrapper c2 = entity.World->AttachComponent(clone.ID, kv.first);
c1.Copy(c2);
}
}
// Clone children
auto children = entity.World->GetDirectChildren(entity.ID);
for (auto it = children.first; it != children.second; ++it) {
EntityWrapper child(entity.World, it->second);
cloneRecursive(child, clone);
}
return clone;
}
+1 -1
View File
@@ -127,7 +127,7 @@ void World::SetParent(EntityID entity, EntityID parent)
m_EntityChildren.insert(std::make_pair(parent, entity)); m_EntityChildren.insert(std::make_pair(parent, entity));
} }
const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> World::GetDirectChildren(EntityID entity) const std::pair<std::unordered_multimap<EntityID, EntityID>::const_iterator, std::unordered_multimap<EntityID, EntityID>::const_iterator> World::GetChildren(EntityID entity)
{ {
return m_EntityChildren.equal_range(entity); return m_EntityChildren.equal_range(entity);
} }
-18
View File
@@ -580,11 +580,6 @@ void EditorGUI::createWidgetToolButton(WidgetMode mode)
bool EditorGUI::OnKeyDown(const Events::KeyDown& e) bool EditorGUI::OnKeyDown(const Events::KeyDown& e)
{ {
ImGuiIO& io = ImGui::GetIO();
if (io.WantCaptureKeyboard) {
return false;
}
if (e.ModCtrl && e.KeyCode == GLFW_KEY_S) { if (e.ModCtrl && e.KeyCode == GLFW_KEY_S) {
if (m_CurrentSelection.Valid()) { if (m_CurrentSelection.Valid()) {
EntityWrapper baseParent = m_CurrentSelection; EntityWrapper baseParent = m_CurrentSelection;
@@ -603,19 +598,6 @@ bool EditorGUI::OnKeyDown(const Events::KeyDown& e)
entityImport(m_World); entityImport(m_World);
} }
if (e.ModCtrl && e.KeyCode == GLFW_KEY_C) {
m_CopyTarget = m_CurrentSelection;
}
if (e.ModCtrl && e.KeyCode == GLFW_KEY_V) {
if (m_OnEntityPaste != nullptr) {
EntityWrapper copy = m_OnEntityPaste(m_CopyTarget, m_CurrentSelection);
if (copy != EntityWrapper::Invalid) {
SelectEntity(copy);
}
}
}
if (e.KeyCode == GLFW_KEY_DELETE) { if (e.KeyCode == GLFW_KEY_DELETE) {
if (m_CurrentSelection.Valid()) { if (m_CurrentSelection.Valid()) {
entityDelete(m_CurrentSelection); entityDelete(m_CurrentSelection);
-6
View File
@@ -28,7 +28,6 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1)); m_EditorGUI->SetEntityDeleteCallback(std::bind(&EditorSystem::OnEntityDelete, this, std::placeholders::_1));
m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetEntityChangeParentCallback(std::bind(&EditorSystem::OnEntityChangeParent, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetEntityChangeNameCallback(std::bind(&EditorSystem::OnEntityChangeName, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetEntityPasteCallback(std::bind(&EditorSystem::OnEntityPaste, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentAttachCallback(std::bind(&EditorSystem::OnComponentAttach, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2)); m_EditorGUI->SetComponentDeleteCallback(std::bind(&EditorSystem::OnComponentDelete, this, std::placeholders::_1, std::placeholders::_2));
m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1)); m_EditorGUI->SetWidgetModeCallback(std::bind(&EditorSystem::setWidgetMode, this, std::placeholders::_1));
@@ -161,11 +160,6 @@ void EditorSystem::OnEntityChangeName(EntityWrapper entity, const std::string& n
} }
} }
EntityWrapper EditorSystem::OnEntityPaste(EntityWrapper entityToCopy, EntityWrapper parent)
{
return entityToCopy.Clone(parent);
}
void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType) void EditorSystem::OnComponentAttach(EntityWrapper entity, const std::string& componentType)
{ {
if (entity.Valid()) { if (entity.Valid()) {
+2 -8
View File
@@ -261,14 +261,8 @@ void Client::parseEntityDeletion(Packet & packet)
if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) { if (m_ServerIDToClientID.find(entityToDelete) != m_ServerIDToClientID.end()) {
EntityID localEntity = m_ServerIDToClientID.at(entityToDelete); EntityID localEntity = m_ServerIDToClientID.at(entityToDelete);
if (m_World->ValidEntity(localEntity)) { if (m_World->ValidEntity(localEntity)) {
if (m_World->HasComponent(localEntity,"Player")) { m_World->DeleteEntity(localEntity);
Events::PlayerDeath e; deleteFromServerClientMaps(entityToDelete, localEntity);
e.Player = EntityWrapper(m_World, localEntity);
m_EventBroker->Publish(e);
} else {
m_World->DeleteEntity(localEntity);
deleteFromServerClientMaps(entityToDelete, localEntity);
}
} }
} }
} }
+3 -3
View File
@@ -186,7 +186,7 @@ void Server::addInputCommandsToPacket(Packet& packet)
void Server::addPlayersToPacket(Packet & packet, EntityID entityID) void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
{ {
auto itPair = m_World->GetDirectChildren(entityID); auto itPair = m_World->GetChildren(entityID);
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools(); std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
// Loop through every child // Loop through every child
for (auto it = itPair.first; it != itPair.second; it++) { for (auto it = itPair.first; it != itPair.second; it++) {
@@ -234,7 +234,7 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
void Server::addChildrenToPacket(Packet & packet, EntityID entityID) void Server::addChildrenToPacket(Packet & packet, EntityID entityID)
{ {
auto itPair = m_World->GetDirectChildren(entityID); auto itPair = m_World->GetChildren(entityID);
std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools(); std::unordered_map<std::string, ComponentPool*> worldComponentPools = m_World->GetComponentPools();
// Loop through every child // Loop through every child
for (auto it = itPair.first; it != itPair.second; it++) { for (auto it = itPair.first; it != itPair.second; it++) {
@@ -601,7 +601,7 @@ void Server::parsePlayerTransform(Packet& packet)
bool Server::shouldSendToClient(EntityWrapper childEntity) bool Server::shouldSendToClient(EntityWrapper childEntity)
{ {
auto children = m_World->GetDirectChildren(childEntity.ID); auto children = m_World->GetChildren(childEntity.ID);
for (auto it = children.first; it != children.second; it++) { for (auto it = children.first; it != children.second; it++) {
EntityWrapper child(m_World, it->second); EntityWrapper child(m_World, it->second);
if(child.HasComponent("CapturePoint")) { if(child.HasComponent("CapturePoint")) {
+1 -1
View File
@@ -17,7 +17,7 @@ void CubeMapPass::LoadTextures(std::string input)
m_CubeMapTextures.push_back(img); m_CubeMapTextures.push_back(img);
} }
GenerateCubeMapTexture(); GenerateCubeMapTexture();
m_PreviusCubeMapTexture = input; m_PreviusCubeMapTexture = input;
} }
} }
+50 -13
View File
@@ -1,19 +1,42 @@
#include "Rendering/DrawBloomPass.h" #include "Rendering/DrawBloomPass.h"
DrawBloomPass::DrawBloomPass(IRenderer* renderer) DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
: m_Renderer(renderer)
, m_Config(config)
{ {
m_Renderer = renderer; InitializeTextures();
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh"); ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2));
InitializeTextures();
InitializeBuffers();
InitializeShaderPrograms();
} }
void DrawBloomPass::InitializeTextures() void DrawBloomPass::InitializeTextures()
{ {
m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false); m_BlackTexture = CommonFunctions::LoadTexture("Textures/Core/Black.png", false);
}
void DrawBloomPass::ChangeQuality(int quality)
{
if (m_Quality == quality) {
return;
}
m_Quality = quality;
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
if (m_Quality == 0) {
glDeleteTextures(1, &m_GaussianTexture_horiz);
glDeleteTextures(1, &m_GaussianTexture_vert);
return;
}
InitializeTextures();
InitializeBuffers();
InitializeShaderPrograms();
std::string qStr = std::to_string(m_Quality);
m_Iterations = m_Config->Get<float>("GLOW" + qStr + ".NumIterations", 0);
InitializeBuffers();
InitializeShaderPrograms();
} }
void DrawBloomPass::InitializeShaderPrograms() void DrawBloomPass::InitializeShaderPrograms()
@@ -40,18 +63,25 @@ void DrawBloomPass::InitializeBuffers()
{ {
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) {
m_GaussianFrameBuffer_horiz.Generate(); 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->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
m_GaussianFrameBuffer_vert.Generate(); m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
}
m_GaussianFrameBuffer_vert.Generate();
} }
void DrawBloomPass::ClearBuffer() void DrawBloomPass::ClearBuffer()
{ {
if (m_Quality == 0) {
return;
}
GLERROR("PRE"); GLERROR("PRE");
m_GaussianFrameBuffer_horiz.Bind(); m_GaussianFrameBuffer_horiz.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
@@ -66,6 +96,9 @@ void DrawBloomPass::ClearBuffer()
void DrawBloomPass::Draw(GLuint texture) void DrawBloomPass::Draw(GLuint texture)
{ {
if (m_Quality == 0) {
return;
}
GLERROR("DrawBloomPass::Draw: Pre"); GLERROR("DrawBloomPass::Draw: Pre");
DrawBloomPassState state; DrawBloomPassState state;
@@ -84,7 +117,7 @@ void DrawBloomPass::Draw(GLuint texture)
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
//Iterate some times to make it more gaussian. //Iterate some times to make it more gaussian.
for (int i = 1; i < m_iterations; i++) { for (int i = 1; i < m_Iterations; i++) {
//Vertical pass //Vertical pass
m_GaussianFrameBuffer_vert.Bind(); m_GaussianFrameBuffer_vert.Bind();
m_GaussianProgram_vert->Bind(); m_GaussianProgram_vert->Bind();
@@ -125,6 +158,9 @@ void DrawBloomPass::Draw(GLuint texture)
void DrawBloomPass::OnWindowResize() void DrawBloomPass::OnWindowResize()
{ {
if (m_Quality == 0) {
return;
}
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_GaussianFrameBuffer_vert.Generate(); m_GaussianFrameBuffer_vert.Generate();
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
@@ -133,6 +169,7 @@ void DrawBloomPass::OnWindowResize()
void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const void DrawBloomPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
{ {
glDeleteTextures(1, texture);
glGenTextures(1, texture); glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture); glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
+21 -19
View File
@@ -1,9 +1,9 @@
#include "Rendering/DrawFinalPass.h" #include "Rendering/DrawFinalPass.h"
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass)
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass) : m_Renderer(renderer)
: m_Renderer(renderer) , m_LightCullingPass(lightCullingPass)
, m_LightCullingPass(lightCullingPass) , m_CubeMapPass(cubeMapPass)
, m_CubeMapPass(cubeMapPass) , m_SSAOPass(ssaoPass)
{ {
//TODO: Make sure that uniforms are not sent into shader if not needed. //TODO: Make sure that uniforms are not sent into shader if not needed.
m_ShieldPixelRate = 8; m_ShieldPixelRate = 8;
@@ -162,20 +162,20 @@ void DrawFinalPass::InitializeShaderPrograms()
m_FillDepthBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram"); m_FillDepthBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram");
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl"))); m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl")));
m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); // m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
m_FillDepthBufferProgram->Compile(); m_FillDepthBufferProgram->Compile();
m_FillDepthBufferProgram->Link(); m_FillDepthBufferProgram->Link();
GLERROR("Creating DepthFill program"); GLERROR("Creating DepthFill program");
m_FillDepthBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned"); m_FillDepthBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned");
m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl"))); m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl")));
m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl"))); // m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
m_FillDepthBufferSkinnedProgram->Compile(); m_FillDepthBufferSkinnedProgram->Compile();
m_FillDepthBufferSkinnedProgram->Link(); m_FillDepthBufferSkinnedProgram->Link();
GLERROR("Creating DepthFill program"); GLERROR("Creating DepthFill program");
} }
void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) void DrawFinalPass::Draw(RenderScene& scene)
{ {
GLERROR("Pre"); GLERROR("Pre");
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
@@ -191,10 +191,10 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
//Fill depth buffer //Fill depth buffer
state->StencilMask(0x00); state->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects"); GLERROR("OpaqueObjects");
state->BlendFunc(GL_ONE, GL_ONE); state->BlendFunc(GL_ONE, GL_ONE);
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
GLERROR("TransparentObjects"); GLERROR("TransparentObjects");
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawSprites(scene.Jobs.SpriteJob, scene); DrawSprites(scene.Jobs.SpriteJob, scene);
@@ -210,11 +210,11 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
//Draw Opaque shielded objects //Draw Opaque shielded objects
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF); state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
state->StencilMask(0x00); state->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
GLERROR("Shielded Opaque object"); GLERROR("Shielded Opaque object");
//Draw Transparen Shielded objects //Draw Transparen Shielded objects
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene, SSAOTexture); //might need changing DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing
GLERROR("Shielded Transparent objects"); GLERROR("Shielded Transparent objects");
GLERROR("END"); GLERROR("END");
@@ -250,9 +250,9 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
stateLowRes->Enable(GL_DEPTH_TEST); stateLowRes->Enable(GL_DEPTH_TEST);
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF); stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
stateLowRes->StencilMask(0x00); stateLowRes->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects"); GLERROR("OpaqueObjects");
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
GLERROR("TransparentObjects"); GLERROR("TransparentObjects");
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
@@ -340,7 +340,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
GLERROR("MipMap Texture initialization failed"); GLERROR("MipMap Texture initialization failed");
} }
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture) void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{ {
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
GLERROR("forwardHandle"); GLERROR("forwardHandle");
@@ -364,7 +364,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, SSAOTexture); glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture());
for (auto &job : jobs) { for (auto &job : jobs) {
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job); auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
@@ -383,7 +383,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) { if (explosionEffectJob->AnimationOffset.animation != nullptr) {
@@ -401,7 +401,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
BindExplosionTextures(explosionHandle, explosionEffectJob); BindExplosionTextures(explosionHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
} }
break; break;
@@ -463,7 +463,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
BindModelTextures(forwardSkinnedHandle, modelJob); BindModelTextures(forwardSkinnedHandle, modelJob);
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) { if (modelJob->AnimationOffset.animation != nullptr) {
@@ -753,6 +753,7 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene) void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
{ {
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
GLERROR("Bind 1 uniform"); GLERROR("Bind 1 uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
GLERROR("Bind 2 uniform"); GLERROR("Bind 2 uniform");
@@ -801,6 +802,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene) void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
{ {
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
GLERROR("Bind 1 uniform"); GLERROR("Bind 1 uniform");
GLint Location_M = glGetUniformLocation(shaderHandle, "M"); GLint Location_M = glGetUniformLocation(shaderHandle, "M");
glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix));
@@ -9,6 +9,7 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
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);
glDepthFunc(GL_LEQUAL);
Enable(GL_STENCIL_TEST); Enable(GL_STENCIL_TEST);
StencilFunc(GL_NOTEQUAL, 1, 0xFF); StencilFunc(GL_NOTEQUAL, 1, 0xFF);
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+21 -21
View File
@@ -42,33 +42,33 @@ void FrameBuffer::Generate()
GLERROR("PRE"); GLERROR("PRE");
std::vector<GLenum> attachments; std::vector<GLenum> attachments;
if (m_BufferHandle == 0) {
glGenFramebuffers(1, &m_BufferHandle); glGenFramebuffers(1, &m_BufferHandle);
}
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle); glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
GLERROR("1"); GLERROR("1");
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) { for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
switch ((*it)->m_ResourceType) { switch ((*it)->m_ResourceType) {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
GLERROR("FrameBuffer generate: glFramebufferTexture2D"); GLERROR("FrameBuffer generate: glFramebufferTexture2D");
break; break;
case GL_RENDERBUFFER: case GL_RENDERBUFFER:
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");
break; break;
} }
GLERROR("2"); GLERROR("2");
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) { if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
attachments.push_back((*it)->m_Attachment); attachments.push_back((*it)->m_Attachment);
} }
GLERROR("Attachment"); GLERROR("Attachment");
}
GLERROR("3");
}
GLERROR("3");
GLenum* bufferTextures = &attachments[0]; GLenum* bufferTextures = &attachments[0];
glDrawBuffers(attachments.size(), bufferTextures); glDrawBuffers(attachments.size(), bufferTextures);
+15 -14
View File
@@ -4,6 +4,8 @@ std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
void Renderer::Initialize() void Renderer::Initialize()
{ {
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
m_GLOW_Quality = m_Config->Get<int>("GLOW.Quality", 0);
InitializeWindow(); InitializeWindow();
InitializeRenderPasses(); InitializeRenderPasses();
@@ -107,6 +109,7 @@ void Renderer::Update(double dt)
void Renderer::Draw(RenderFrame& frame) void Renderer::Draw(RenderFrame& frame)
{ {
GLERROR("PRE"); GLERROR("PRE");
glBindFramebuffer(GL_FRAMEBUFFER, 0);
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
if(m_CubeMapTexture == 0) { if(m_CubeMapTexture == 0) {
@@ -115,19 +118,16 @@ void Renderer::Draw(RenderFrame& frame)
m_CubeMapPass->LoadTextures("Sky"); m_CubeMapPass->LoadTextures("Sky");
} }
ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3);
ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f); ImGui::SliderInt("Glow Quality", &m_GLOW_Quality, 0, 3);
ImGui::SliderFloat("SSAO contrast", &m_SSAO_Contrast, 0.0f, 10.0f); m_SSAOPass->ChangeQuality(m_SSAO_Quality);
ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f); m_DrawBloomPass->ChangeQuality(m_GLOW_Quality);
ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100);
ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50);
m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns);
GLERROR("SSAO Settings"); GLERROR("SSAO Settings");
//clear buffer 0 //clear buffer 0
glClearColor(0.f, 0.f, 0.f, 0.f); 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 //Clear other buffers
PerformanceTimer::StartTimer("Renderer-ClearBuffers"); PerformanceTimer::StartTimer("Renderer-ClearBuffers");
m_PickingPass->ClearPicking(); m_PickingPass->ClearPicking();
m_DrawFinalPass->ClearBuffer(); m_DrawFinalPass->ClearBuffer();
@@ -141,10 +141,10 @@ void Renderer::Draw(RenderFrame& frame)
GLERROR("Drawing pickingpass"); GLERROR("Drawing pickingpass");
PerformanceTimer::StopTimer("Renderer-Depth"); PerformanceTimer::StopTimer("Renderer-Depth");
} }
PerformanceTimer::StartTimer("AO generation"); PerformanceTimer::StartTimer("Renderer-AO generation");
m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera);
GLuint ao = m_SSAOPass->SSAOTexture(); GLuint ao = m_SSAOPass->SSAOTexture();
PerformanceTimer::StopTimer("AO generation"); PerformanceTimer::StopTimer("Renderer-AO generation");
for (auto scene : frame.RenderScenes){ for (auto scene : frame.RenderScenes){
PerformanceTimer::StartTimer("Renderer-Drawing PickingPass"); PerformanceTimer::StartTimer("Renderer-Drawing PickingPass");
@@ -159,7 +159,7 @@ void Renderer::Draw(RenderFrame& frame)
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
m_LightCullingPass->CullLights(*scene); m_LightCullingPass->CullLights(*scene);
GLERROR("LightCulling"); GLERROR("LightCulling");
m_DrawFinalPass->Draw(*scene, ao); m_DrawFinalPass->Draw(*scene);
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
GLERROR("Draw Geometry+Light"); GLERROR("Draw Geometry+Light");
//m_DrawScenePass->Draw(*scene); //m_DrawScenePass->Draw(*scene);
@@ -248,9 +248,10 @@ 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_CubeMapPass = new CubeMapPass(this); m_CubeMapPass = new CubeMapPass(this);
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass); m_SSAOPass = new SSAOPass(this, m_Config);
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass);
m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
m_DrawBloomPass = new DrawBloomPass(this); m_DrawBloomPass = new DrawBloomPass(this, m_Config);
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
m_SSAOPass = new SSAOPass(this);
} }
+177 -29
View File
@@ -1,50 +1,130 @@
#include "Rendering/SSAOPass.h" #include "Rendering/SSAOPass.h"
SSAOPass::SSAOPass(IRenderer* renderer) SSAOPass::SSAOPass(IRenderer* renderer, ConfigFile* config)
: m_Renderer(renderer)
, m_Config(config)
{ {
m_Renderer = renderer; m_WhiteTexture = CommonFunctions::LoadTexture("Textures/Core/White.png", false);
ChangeQuality(m_Config->Get<int>("SSAO.Quality", 0));
}
void SSAOPass::ChangeQuality(int quality)
{
if (m_Quality == quality) {
return;
}
m_Quality = quality;
if (m_Quality == 0) {
glDeleteTextures(1, &m_SSAOTexture);
glDeleteTextures(1, &m_SSAOViewSpaceZTexture);
glDeleteTextures(1, &m_GaussianTexture_horiz);
glDeleteTextures(1, &m_GaussianTexture_vert);
return;
}
std::string qStr = std::to_string(m_Quality);
Setting(
m_Config->Get<float>("SSAO" + qStr + ".Radius", 0.01),
m_Config->Get<float>("SSAO" + qStr + ".Bias", 0.012),
m_Config->Get<float>("SSAO" + qStr + ".Contrast", 1.0),
m_Config->Get<float>("SSAO" + qStr + ".Intensity", 1.0),
m_Config->Get<int>("SSAO" + qStr + ".NumSamples", 0),
m_Config->Get<int>("SSAO" + qStr + ".NumTurns", 0),
m_Config->Get<int>("SSAO" + qStr + ".NumIterations", 0),
m_Config->Get<int>("SSAO" + qStr + ".TextureQuality", 4)
);
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh"); m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
InitializeTexture(); InitializeTexture();
InitializeBuffer(); InitializeBuffer();
InitializeShaderProgram(); InitializeShaderProgram();
Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7);
m_DrawBloomPass = new DrawBloomPass(renderer);
} }
void SSAOPass::InitializeShaderProgram() void SSAOPass::InitializeShaderProgram()
{ {
m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram"); m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram");
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl"))); if (m_SSAOProgram->GetHandle() == 0) {
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl"))); m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
m_SSAOProgram->Compile(); m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl")));
m_SSAOProgram->Link(); m_SSAOProgram->Compile();
m_SSAOProgram->Link();
}
m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram"); m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram");
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl"))); if (m_SSAOViewSpaceZProgram->GetHandle() == 0) {
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl"))); m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
m_SSAOViewSpaceZProgram->Compile(); m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl")));
m_SSAOViewSpaceZProgram->Link(); m_SSAOViewSpaceZProgram->Compile();
m_SSAOViewSpaceZProgram->Link();
}
m_GaussianProgram_horiz = ResourceManager::Load<ShaderProgram>("##GaussianProgramHoriz");
if (m_GaussianProgram_horiz->GetHandle() == 0) {
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");
if (m_GaussianProgram_vert->GetHandle() == 0) {
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 SSAOPass::InitializeTexture() { void SSAOPass::InitializeTexture() {
GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RED, GL_FLOAT);
GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R32F, GL_RED, GL_FLOAT);
GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT);
GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width >> m_TextureQuality, m_Renderer->GetViewportSize().Height >> m_TextureQuality), GL_R8, GL_RGB, GL_FLOAT);
} }
void SSAOPass::InitializeBuffer() void SSAOPass::InitializeBuffer()
{ {
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); if (m_SSAOFramBuffer.GetHandle() == 0) {
m_SSAOFramBuffer.Generate(); m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0)));
}
m_SSAOFramBuffer.Generate();
if (m_SSAOViewSpaceZFramBuffer.GetHandle() == 0) {
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
}
m_SSAOViewSpaceZFramBuffer.Generate();
if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) {
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
}
m_GaussianFrameBuffer_horiz.Generate();
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) {
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0)));
}
m_GaussianFrameBuffer_vert.Generate();
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
m_SSAOViewSpaceZFramBuffer.Generate();
} }
void SSAOPass::ClearBuffer() void SSAOPass::ClearBuffer()
{ {
if (m_Quality == 0) {
return;
}
m_SSAOFramBuffer.Bind(); m_SSAOFramBuffer.Bind();
glClearColor(1.f, 1.f, 1.f, 1.f); glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
@@ -54,19 +134,32 @@ void SSAOPass::ClearBuffer()
glClearColor(1.f, 1.f, 1.f, 1.f); glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_SSAOViewSpaceZFramBuffer.Unbind(); m_SSAOViewSpaceZFramBuffer.Unbind();
m_GaussianFrameBuffer_horiz.Bind();
glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_GaussianFrameBuffer_horiz.Unbind();
m_GaussianFrameBuffer_vert.Bind();
glClearColor(1.f, 1.f, 1.f, 1.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_GaussianFrameBuffer_vert.Unbind();
} }
void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns) { void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int numOfTurns, int iterations, int quality) {
m_Radius = radius; m_Radius = radius;
m_Bias = bias; m_Bias = bias;
m_Contrast = contrast; m_Contrast = contrast;
m_IntensityScale = intensityScale; m_IntensityScale = intensityScale;
m_NumOfSamples = numOfSamples; m_NumOfSamples = numOfSamples;
m_NumOfTurns = NumOfTurns; m_NumOfTurns = numOfTurns;
m_Iterations = iterations;
m_TextureQuality = quality;
} }
void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
{ {
glDeleteTextures(1, texture);
glGenTextures(1, texture); glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture); glBindTexture(GL_TEXTURE_2D, *texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
@@ -79,6 +172,10 @@ void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin
void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
{ {
if (m_Quality == 0) {
return;
}
SSAOPassState state; SSAOPassState state;
GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle(); GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle();
GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle(); GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle();
@@ -98,6 +195,7 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
(-1.0f), (-1.0f),
(+1.0f) (+1.0f)
);*/ );*/
glViewport(0, 0, (m_Renderer->GetViewportSize().Width >> m_TextureQuality), (m_Renderer->GetViewportSize().Height >> m_TextureQuality)); //JOHAN TODO: Get this into state
glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo)); glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo));
glBindVertexArray(m_ScreenQuad->VAO); glBindVertexArray(m_ScreenQuad->VAO);
@@ -107,9 +205,9 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glm::vec4 projInfo = glm::vec4( glm::vec4 projInfo = glm::vec4(
((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]), ((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]),
(-2.0 / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])), (-2.0 / ((m_Renderer->GetViewportSize().Width >> m_TextureQuality) * camera->ProjectionMatrix()[0][0])),
((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]), ((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]),
(-2.0 / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1])) (-2.0 / ((m_Renderer->GetViewportSize().Height >> m_TextureQuality) * camera->ProjectionMatrix()[1][1]))
); );
@@ -120,26 +218,76 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture); glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture);
// How many pixel there are in a 1m long object 1m away from the camera // How many pixel there are in a 1m long object 1m away from the camera
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f))); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), (m_Renderer->GetViewportSize().Height >> m_TextureQuality) / (-2.0f * glm::tan(camera->FOV() * 0.5f)));
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius);
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias);
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast);
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale); glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale);
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples); glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples);
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);; glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);
glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo)); glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo));
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
m_DrawBloomPass->ClearBuffer(); DrawBloomPassState BloomState;
m_DrawBloomPass->Draw(m_SSAOTexture); GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_SSAOTexture);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->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].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->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].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->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].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
glViewport(0, 0, (m_Renderer->GetViewportSize().Width), (m_Renderer->GetViewportSize().Height));
} }
void SSAOPass::OnWindowResize() { void SSAOPass::OnWindowResize() {
m_DrawBloomPass->OnWindowResize(); if (m_Quality == 0) {
return;
}
InitializeTexture(); InitializeTexture();
m_SSAOFramBuffer.Generate();
m_SSAOViewSpaceZFramBuffer.Generate();
} }
+1 -1
View File
@@ -54,7 +54,7 @@ Game::Game(int argc, char* argv[])
m_EventBroker = new EventBroker(); m_EventBroker = new EventBroker();
// Create the renderer // Create the renderer
m_Renderer = new Renderer(m_EventBroker); m_Renderer = new Renderer(m_EventBroker, m_Config);
m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false)); m_Renderer->SetFullscreen(m_Config->Get<bool>("Video.Fullscreen", false));
m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false)); m_Renderer->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
m_Renderer->SetResolution(Rectangle::Rectangle( m_Renderer->SetResolution(Rectangle::Rectangle(
+1 -1
View File
@@ -36,7 +36,7 @@ EntityWrapper SpawnerSystem::Spawn(EntityWrapper spawner, EntityWrapper parent /
} }
// Find any SpawnPoints existing as children of spawner // Find any SpawnPoints existing as children of spawner
auto children = spawner.World->GetDirectChildren(spawner.ID); auto children = spawner.World->GetChildren(spawner.ID);
std::vector<EntityWrapper> spawnPoints; std::vector<EntityWrapper> spawnPoints;
for (auto kv = children.first; kv != children.second; ++kv) { for (auto kv = children.first; kv != children.second; ++kv) {
const EntityID& child = kv->second; const EntityID& child = kv->second;