Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7cd4dac909 | |||
| 4aaba03852 | |||
| 2c18068059 | |||
| 09aec08d0e | |||
| 4cf8c3d8d7 | |||
| 37414ce124 | |||
| adceccf402 | |||
| 201480b17f |
@@ -1,18 +0,0 @@
|
||||
#ifndef EAmmoPickup_h__
|
||||
#define EAmmoPickup_h__
|
||||
|
||||
#include "EventBroker.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AmmoPickup : Event
|
||||
{
|
||||
EntityWrapper Player;
|
||||
int AmmoGain;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,18 +0,0 @@
|
||||
#ifndef EPlayerHealthPickup_h__
|
||||
#define EPlayerHealthPickup_h__
|
||||
|
||||
#include "EventBroker.h"
|
||||
#include "../Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct PlayerHealthPickup : Event
|
||||
{
|
||||
EntityWrapper Player;
|
||||
double HealthAmount;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,20 +0,0 @@
|
||||
#ifndef EWin_h__
|
||||
#define EWin_h__
|
||||
|
||||
#include "EventBroker.h"
|
||||
#include "../Core/Entity.h"
|
||||
#include "Engine/GLM.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
//triggers when a team has captured all capturePoints
|
||||
struct Win : Event
|
||||
{
|
||||
//can be 0 = none, 1,2
|
||||
int TeamThatWon;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef EntitySystem_h__
|
||||
#define EntitySystem_h__
|
||||
|
||||
#include "World.h"
|
||||
#include "SystemPipeline.h"
|
||||
|
||||
// An "EntitySystem" is defined as the combination of a World with a SystemPipeline
|
||||
template <typename WorldType>
|
||||
class EntitySystem : public WorldType, public SystemPipeline
|
||||
{
|
||||
static_assert(std::is_base_of<World, WorldType>::value, "WorldType must inherit from World");
|
||||
public:
|
||||
EntitySystem(EventBroker* eventBroker, bool isClient, bool isServer)
|
||||
: WorldType(eventBroker)
|
||||
, SystemPipeline(this, eventBroker, isClient, isServer)
|
||||
{ }
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
void InitializeTextures();
|
||||
void InitializeFrameBuffers();
|
||||
void InitializeShaderPrograms();
|
||||
void Draw(RenderScene& scene);
|
||||
void Draw(RenderScene& scene, GLuint SSAOTexture);
|
||||
void ClearBuffer();
|
||||
void OnWindowResize();
|
||||
|
||||
@@ -37,7 +37,7 @@ private:
|
||||
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 DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
|
||||
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture);
|
||||
void DrawShieldToStencilBuffer(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);
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "DrawScreenQuadPass.h"
|
||||
#include "DrawBloomPass.h"
|
||||
#include "DrawColorCorrectionPass.h"
|
||||
#include "SSAOPass.h"
|
||||
#include "../Core/EventBroker.h"
|
||||
#include "ImGuiRenderPass.h"
|
||||
#include "Camera.h"
|
||||
@@ -58,6 +59,12 @@ private:
|
||||
|
||||
int m_DebugTextureToDraw = 0;
|
||||
bool m_ResizeWindow = false;
|
||||
float m_SSAO_Radius = 1.0f;
|
||||
float m_SSAO_Bias = 0.05f;
|
||||
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;
|
||||
LightCullingPass* m_LightCullingPass;
|
||||
@@ -66,6 +73,7 @@ private:
|
||||
DrawScreenQuadPass* m_DrawScreenQuadPass;
|
||||
DrawBloomPass* m_DrawBloomPass;
|
||||
DrawColorCorrectionPass* m_DrawColorCorrectionPass;
|
||||
SSAOPass* m_SSAOPass;
|
||||
|
||||
//----------------------Functions----------------------//
|
||||
void InitializeWindow();
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
#ifndef SSAOPass_h__
|
||||
#define SSAOPass_h__
|
||||
|
||||
#include "IRenderer.h"
|
||||
#include "SSAOPassState.h"
|
||||
//#include "LightCullingPass.h" Finalpass om den skall skickas in
|
||||
#include "FrameBuffer.h"
|
||||
#include "ShaderProgram.h"
|
||||
#include "DrawBloomPass.h"
|
||||
//#include "Util/UnorderedMapVec2.h"
|
||||
#include "Texture.h"
|
||||
|
||||
class SSAOPass
|
||||
{
|
||||
public:
|
||||
SSAOPass(IRenderer* rendere);
|
||||
~SSAOPass() { };
|
||||
|
||||
void Draw(GLuint depthBuffer, Camera* camera);
|
||||
void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns);
|
||||
void ClearBuffer();
|
||||
|
||||
//Return the SSAO of the texture sent to Draw
|
||||
GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); }
|
||||
|
||||
private:
|
||||
void InitializeTexture();
|
||||
void InitializeFrameBuffer();
|
||||
void InitializeShaderProgram();
|
||||
void InitializeBuffer();
|
||||
|
||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||
|
||||
void ComputeAO(GLuint depthBuffer, Camera* camera);
|
||||
//void blurHorizontal(GLuint depthBuffer);
|
||||
//void blurVertical(GLuint depthBuffer);
|
||||
|
||||
Model* m_ScreenQuad;
|
||||
|
||||
const IRenderer* m_Renderer;
|
||||
|
||||
float m_Radius;
|
||||
float m_Bias;
|
||||
float m_Contrast;
|
||||
float m_IntensityScale;
|
||||
int m_NumOfSamples;
|
||||
int m_NumOfTurns;
|
||||
|
||||
GLuint m_SSAOTexture;
|
||||
FrameBuffer m_SSAOFramBuffer;
|
||||
|
||||
GLuint m_SSAOViewSpaceZTexture;
|
||||
FrameBuffer m_SSAOViewSpaceZFramBuffer;
|
||||
|
||||
ShaderProgram* m_SSAOProgram;
|
||||
ShaderProgram* m_SSAOViewSpaceZProgram;
|
||||
|
||||
DrawBloomPass* m_DrawBloomPass;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef SSAOPassState_h__
|
||||
#define SSAOPassState_h__
|
||||
|
||||
#include "Rendering/RenderState.h"
|
||||
|
||||
class SSAOPassState : public RenderState
|
||||
{
|
||||
public:
|
||||
SSAOPassState();
|
||||
~SSAOPassState();
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "Core/EntitySystem.h"
|
||||
#include "Rendering/IRenderer.h"
|
||||
#include "Core/Octree.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
|
||||
class CapturePointsEntitySystem : public EntitySystem<World>
|
||||
{
|
||||
public:
|
||||
CapturePointsEntitySystem(EventBroker* eventBroker, bool isClient, bool isServer, IRenderer* renderer, RenderFrame* renderFrame);
|
||||
~CapturePointsEntitySystem();
|
||||
|
||||
private:
|
||||
IRenderer* m_Renderer;
|
||||
RenderFrame* m_RenderFrame;
|
||||
Octree<EntityAABB>* m_OctreeCollision = nullptr;
|
||||
Octree<EntityAABB>* m_OctreeTrigger = nullptr;
|
||||
Octree<EntityAABB>* m_OctreeFrustrumCulling = nullptr;
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef EAmmoPickup_h__
|
||||
#define EAmmoPickup_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct AmmoPickup : Event
|
||||
{
|
||||
EntityWrapper Player;
|
||||
int AmmoGain;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,14 +1,13 @@
|
||||
#ifndef ECaptured_h__
|
||||
#define ECaptured_h__
|
||||
|
||||
#include "EventBroker.h"
|
||||
#include "../Core/Entity.h"
|
||||
#include "Engine/GLM.h"
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
//triggers when a capturePoint has been taken over
|
||||
//triggers when a capturePoint has been taken over
|
||||
struct Captured : Event
|
||||
{
|
||||
int TeamNumberThatCapturedCapturePoint;
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef EGameEnd_h__
|
||||
#define EGameEnd_h__
|
||||
|
||||
#include "Core/Event.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct GameEnd : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,16 @@
|
||||
#ifndef EGameStart_h__
|
||||
#define EGameStart_h__
|
||||
|
||||
#include "Core/Event.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct GameStart : Event
|
||||
{
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,18 @@
|
||||
#ifndef EPlayerHealthPickup_h__
|
||||
#define EPlayerHealthPickup_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/EntityWrapper.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
struct PlayerHealthPickup : Event
|
||||
{
|
||||
EntityWrapper Player;
|
||||
double HealthAmount;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef EWin_h__
|
||||
#define EWin_h__
|
||||
|
||||
#include "Core/EventBroker.h"
|
||||
#include "Core/Entity.h"
|
||||
|
||||
namespace Events
|
||||
{
|
||||
|
||||
//triggers when a team has captured all capturePoints
|
||||
struct Win : Event
|
||||
{
|
||||
// The winning team corresponding to TeamEnum
|
||||
ComponentInfo::EnumType Team;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
+3
-9
@@ -12,18 +12,16 @@
|
||||
#include "Input/InputProxy.h"
|
||||
#include "Input/KeyboardInputHandler.h"
|
||||
#include "Input/MouseInputHandler.h"
|
||||
#include "Core/EKeyDown.h"
|
||||
#include "Core/EntityFilePreprocessor.h"
|
||||
#include "Core/SystemPipeline.h"
|
||||
#include "Core/EntitySystem.h"
|
||||
#include "Systems/ExplosionEffectSystem.h"
|
||||
#include "Editor/EditorSystem.h"
|
||||
#include "Core/EntityFile.h"
|
||||
#include "Rendering/RenderSystem.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/Octree.h"
|
||||
#include "Rendering/Font.h"
|
||||
#include "Systems/InterpolationSystem.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
|
||||
// Network
|
||||
#include <boost/thread.hpp>
|
||||
#include "Network/Network.h"
|
||||
@@ -55,11 +53,7 @@ private:
|
||||
IRenderer* m_Renderer;
|
||||
InputManager* m_InputManager;
|
||||
InputProxy* m_InputProxy;
|
||||
World* m_World;
|
||||
Octree<EntityAABB>* m_OctreeCollision;
|
||||
Octree<EntityAABB>* m_OctreeTrigger;
|
||||
Octree<EntityAABB>* m_OctreeFrustrumCulling;
|
||||
SystemPipeline* m_SystemPipeline;
|
||||
EntitySystem<World>* m_EntitySystem;
|
||||
RenderFrame* m_RenderFrame;
|
||||
Client* m_NetworkClient = nullptr;
|
||||
Server* m_NetworkServer = nullptr;
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "Core/Transform.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EPickupSpawned.h"
|
||||
#include "Core/EAmmoPickup.h"
|
||||
#include "Events/EPickupSpawned.h"
|
||||
#include "Events/EAmmoPickup.h"
|
||||
#include "Engine/Collision/ETrigger.h"
|
||||
#include "Common.h"
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
#include "Common.h"
|
||||
#include "Core/System.h"
|
||||
#include "Engine/Collision/ETrigger.h"
|
||||
#include "Core/ECaptured.h"
|
||||
#include "Core/EWin.h"
|
||||
#include "Events/ECaptured.h"
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "Core/System.h"
|
||||
#include "Events/EGameStart.h"
|
||||
#include "Events/EGameEnd.h"
|
||||
#include "Events/ECaptured.h"
|
||||
#include "Events/EWin.h"
|
||||
|
||||
class CapturePointsGamemode : public ImpureSystem
|
||||
{
|
||||
public:
|
||||
CapturePointsGamemode(SystemParams params);
|
||||
|
||||
virtual void Update(double dt) override;
|
||||
|
||||
private:
|
||||
bool m_GameRuning = false;
|
||||
double m_GameTime = 0.0;
|
||||
|
||||
EventRelay<CapturePointsGamemode, Events::GameStart> m_EGameStart;
|
||||
bool OnGameStart(const Events::GameStart& e);
|
||||
EventRelay<CapturePointsGamemode, Events::Captured> m_ECaptured;
|
||||
bool OnCaptured(const Events::Captured& e);
|
||||
|
||||
boost::optional<ComponentWrapper> currentGamemode();
|
||||
bool isCurrentGamemode();
|
||||
boost::optional<ComponentInfo::EnumType> winCondition();
|
||||
void setRunning(bool running);
|
||||
};
|
||||
@@ -7,8 +7,8 @@
|
||||
#include "Common.h"
|
||||
#include "Core/System.h"
|
||||
#include "Core/EPlayerDamage.h"
|
||||
#include "Core/EPlayerHealthPickup.h"
|
||||
#include "Core/EPlayerDeath.h"
|
||||
#include "Events/EPlayerHealthPickup.h"
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
#include "Core/Transform.h"
|
||||
#include "Core/ResourceManager.h"
|
||||
#include "Core/EntityFileParser.h"
|
||||
#include "Core/EPickupSpawned.h"
|
||||
#include "Core/EPlayerHealthPickup.h"
|
||||
#include "Events/EPickupSpawned.h"
|
||||
#include "Events/EPlayerHealthPickup.h"
|
||||
#include "Engine/Collision/ETrigger.h"
|
||||
#include "Common.h"
|
||||
#include <tuple>
|
||||
|
||||
@@ -13,10 +13,10 @@
|
||||
#include "../Engine/Core/EShoot.h"
|
||||
#include "../Engine/Core/EPlayerSpawned.h"
|
||||
#include "../Engine/Input/EInputCommand.h"
|
||||
#include "../Engine/Core/ECaptured.h"
|
||||
#include "Events/ECaptured.h"
|
||||
#include "../Engine/Core/EPlayerDamage.h"
|
||||
#include "../Engine/Core/EPlayerDeath.h"
|
||||
#include "../Engine/Core/EPlayerHealthPickup.h"
|
||||
#include "Events/EPlayerHealthPickup.h"
|
||||
#include "../Engine/Collision/ETrigger.h"
|
||||
#include "../Engine/Sound/EPlaySoundOnEntity.h"
|
||||
#include "../Engine/Sound/EPlayBackgroundMusic.h"
|
||||
|
||||
@@ -45,4 +45,5 @@
|
||||
<xs:include schemaLocation="Components/KillFeed.xsd"/>
|
||||
<xs:include schemaLocation="Components/Page.xsd"/>
|
||||
<xs:include schemaLocation="Components/Button.xsd"/>
|
||||
<xs:include schemaLocation="Components/Gamemode.xsd"/>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Gamemode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Gamemode.xsd">
|
||||
<Gamemode><CapturePoints/></Gamemode>
|
||||
<RoundTime>0</RoundTime>
|
||||
<Running>false</Running>
|
||||
</Gamemode>
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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="GamemodeEnum" mixed="true">
|
||||
<xs:complexContent>
|
||||
<xs:extension base="t:enum">
|
||||
<xs:choice>
|
||||
<xs:element name="CapturePoints" type="t:int" fixed="1" minOccurs="0"/>
|
||||
</xs:choice>
|
||||
</xs:extension>
|
||||
</xs:complexContent>
|
||||
</xs:complexType>
|
||||
|
||||
<xs:element name="Gamemode">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="Gamemode" type="GamemodeEnum" minOccurs="0"/>
|
||||
<xs:element name="RoundTime" type="t:double" minOccurs="0"/>
|
||||
<xs:element name="Running" type="t:bool" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -349,13 +349,12 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>1.6050530664521858</Time1>
|
||||
<Time1>1.8314163732853146</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
||||
<Color A="1" B="1" G="0.309803933" R="0"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
@@ -367,11 +366,10 @@
|
||||
</c:BoneAttachment>
|
||||
<c:Model>
|
||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.12043035" Y="-0.234149337" Z="-0.181454644"/>
|
||||
<Orientation X="0.0104045281" Y="-0.00268131681" Z="0.0428438708"/>
|
||||
<Position X="0.120430619" Y="-0.229687244" Z="-0.181454629"/>
|
||||
<Orientation X="0.0104048112" Y="-0.0026817855" Z="0.0428442657"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -477,7 +475,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>1.620305457513453</Time1>
|
||||
<Time1>0.16333512901638159</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:AnimationOffset>
|
||||
@@ -501,8 +499,8 @@
|
||||
<Resource>Models/Weapons/Blue/AssaultWeaponBlue.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.160351232" Y="1.02591991" Z="-0.215102971"/>
|
||||
<Orientation X="-0.0627480298" Y="-0.0432248674" Z="0.119431816"/>
|
||||
<Position X="0.158296332" Y="1.03131664" Z="-0.21615544"/>
|
||||
<Orientation X="-0.0626514703" Y="-0.0352048129" Z="0.12013837"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
|
||||
@@ -349,13 +349,12 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>1.6050530664521858</Time1>
|
||||
<Time1>0.018170670865885086</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
<Resource>Models/Characters/Assault/FirstPerson.mesh</Resource>
|
||||
<Color A="1" B="0" G="0" R="1"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
@@ -367,11 +366,10 @@
|
||||
</c:BoneAttachment>
|
||||
<c:Model>
|
||||
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.12043035" Y="-0.234149337" Z="-0.181454644"/>
|
||||
<Orientation X="0.0104045281" Y="-0.00268131681" Z="0.0428438708"/>
|
||||
<Position X="0.120430693" Y="-0.2284486" Z="-0.181454509"/>
|
||||
<Orientation X="0.0104046017" Y="-0.00268172775" Z="0.0428442247"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -477,7 +475,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<AnimationName1>Idle</AnimationName1>
|
||||
<Time1>1.620305457513453</Time1>
|
||||
<Time1>0.11675631578762591</Time1>
|
||||
<Speed1>1</Speed1>
|
||||
</c:Animation>
|
||||
<c:AnimationOffset>
|
||||
@@ -501,8 +499,8 @@
|
||||
<Resource>Models/Weapons/Red/AssaultWeaponRed.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.160351232" Y="1.02591991" Z="-0.215102971"/>
|
||||
<Orientation X="-0.0627480298" Y="-0.0432248674" Z="0.119431816"/>
|
||||
<Position X="0.157842755" Y="1.03184748" Z="-0.216178894"/>
|
||||
<Orientation X="-0.0626459867" Y="-0.0335309952" Z="0.120309927"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
<xs:element ref="c:Menu" minOccurs="0"/>
|
||||
<xs:element ref="c:Page" minOccurs="0"/>
|
||||
<xs:element ref="c:Button" minOccurs="0"/>
|
||||
<xs:element ref="c:Gamemode" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -19,6 +19,8 @@ void main()
|
||||
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
||||
vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate);
|
||||
vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate);
|
||||
|
||||
//hdrColor = hdrColor * SSAO;
|
||||
hdrColor += bloomColor;
|
||||
hdrColorLowRes;
|
||||
|
||||
@@ -33,7 +35,6 @@ void main()
|
||||
|
||||
//gamme correction
|
||||
result = pow(result, vec3(1.0 / Gamma));
|
||||
|
||||
fragmentColor = vec4(result, 1.0);
|
||||
//fragmentColor = hdrColor;
|
||||
//fragmentColor = bloomColor;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#version 430
|
||||
|
||||
#define MIN_AMBIENT_LIGHT 0.3
|
||||
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
@@ -15,10 +17,11 @@ uniform vec2 DiffuseUVRepeat;
|
||||
uniform vec2 NormalUVRepeat;
|
||||
uniform vec2 SpecularUVRepeat;
|
||||
uniform vec2 GlowUVRepeat;
|
||||
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding = 1) uniform sampler2D NormalMapTexture;
|
||||
layout (binding = 2) uniform sampler2D SpecularMapTexture;
|
||||
layout (binding = 3) uniform sampler2D GlowMapTexture;
|
||||
layout (binding = 0) uniform sampler2D AOTexture;
|
||||
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
||||
layout (binding = 2) uniform sampler2D NormalMapTexture;
|
||||
layout (binding = 3) uniform sampler2D SpecularMapTexture;
|
||||
layout (binding = 4) uniform sampler2D GlowMapTexture;
|
||||
|
||||
#define TILE_SIZE 16
|
||||
|
||||
@@ -120,6 +123,8 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
|
||||
|
||||
void main()
|
||||
{
|
||||
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r;
|
||||
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 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
||||
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
||||
@@ -134,7 +139,7 @@ void main()
|
||||
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
||||
|
||||
LightResult totalLighting;
|
||||
totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0);
|
||||
totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0);
|
||||
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
||||
|
||||
int start = int(LightGrids.Data[currentTile].Start);
|
||||
@@ -152,8 +157,8 @@ void main()
|
||||
} else if (light.Type == 2) { //Directional
|
||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||
}
|
||||
totalLighting.Diffuse += light_result.Diffuse;
|
||||
totalLighting.Specular += light_result.Specular;
|
||||
totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a);
|
||||
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
|
||||
}
|
||||
|
||||
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#version 430
|
||||
|
||||
#define MIN_AMBIENT_LIGHT 0.3
|
||||
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
@@ -23,19 +25,20 @@ uniform vec2 SpecularUVRepeat3;
|
||||
uniform vec2 GlowUVRepeat1;
|
||||
uniform vec2 GlowUVRepeat2;
|
||||
uniform vec2 GlowUVRepeat3;
|
||||
layout (binding = 0) uniform sampler2D SplatMapTexture;
|
||||
layout (binding = 1) uniform sampler2D DiffuseTexture1;
|
||||
layout (binding = 2) uniform sampler2D DiffuseTexture2;
|
||||
layout (binding = 3) uniform sampler2D DiffuseTexture3;
|
||||
layout (binding = 4) uniform sampler2D NormalMapTexture1;
|
||||
layout (binding = 5) uniform sampler2D NormalMapTexture2;
|
||||
layout (binding = 6) uniform sampler2D NormalMapTexture3;
|
||||
layout (binding = 7) uniform sampler2D SpecularMapTexture1;
|
||||
layout (binding = 8) uniform sampler2D SpecularMapTexture2;
|
||||
layout (binding = 9) uniform sampler2D SpecularMapTexture3;
|
||||
layout (binding = 10) uniform sampler2D GlowMapTexture1;
|
||||
layout (binding = 11) uniform sampler2D GlowMapTexture2;
|
||||
layout (binding = 12) uniform sampler2D GlowMapTexture3;
|
||||
layout (binding = 0) uniform sampler2D AOTexture;
|
||||
layout (binding = 1) uniform sampler2D SplatMapTexture;
|
||||
layout (binding = 2) uniform sampler2D DiffuseTexture1;
|
||||
layout (binding = 3) uniform sampler2D DiffuseTexture2;
|
||||
layout (binding = 4) uniform sampler2D DiffuseTexture3;
|
||||
layout (binding = 5) uniform sampler2D NormalMapTexture1;
|
||||
layout (binding = 6) uniform sampler2D NormalMapTexture2;
|
||||
layout (binding = 7) uniform sampler2D NormalMapTexture3;
|
||||
layout (binding = 8) uniform sampler2D SpecularMapTexture1;
|
||||
layout (binding = 9) uniform sampler2D SpecularMapTexture2;
|
||||
layout (binding = 10) uniform sampler2D SpecularMapTexture3;
|
||||
layout (binding = 11) uniform sampler2D GlowMapTexture1;
|
||||
layout (binding = 12) uniform sampler2D GlowMapTexture2;
|
||||
layout (binding = 13) uniform sampler2D GlowMapTexture3;
|
||||
|
||||
#define TILE_SIZE 16
|
||||
|
||||
@@ -174,6 +177,9 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
|
||||
|
||||
void main()
|
||||
{
|
||||
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r;
|
||||
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 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3,
|
||||
@@ -195,7 +201,7 @@ void main()
|
||||
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
|
||||
|
||||
LightResult totalLighting;
|
||||
totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0);
|
||||
totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0);
|
||||
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
|
||||
|
||||
int start = int(LightGrids.Data[currentTile].Start);
|
||||
@@ -213,8 +219,8 @@ void main()
|
||||
} else if (light.Type == 2) { //Directional
|
||||
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
|
||||
}
|
||||
totalLighting.Diffuse += light_result.Diffuse;
|
||||
totalLighting.Specular += light_result.Specular;
|
||||
totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a);
|
||||
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
|
||||
}
|
||||
|
||||
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
#version 430
|
||||
|
||||
//Number of samples per pixel
|
||||
uniform int uNumOfSamples;
|
||||
//#define NUM_SAMPLES (11)
|
||||
|
||||
//Number of turns around the cirle
|
||||
uniform int uNumOfTurns;
|
||||
//#define NUM_TURNS (7)
|
||||
|
||||
layout (binding = 0) uniform sampler2D ViewSpaceZ;
|
||||
|
||||
uniform vec4 uProjInfo;
|
||||
|
||||
uniform float uProjScale;
|
||||
//#define ProjScale 500
|
||||
|
||||
uniform float uRadius;
|
||||
//#define Radius 1.0f
|
||||
|
||||
uniform float uBias;
|
||||
//#define Bias 0.012f
|
||||
|
||||
uniform float uContrast;
|
||||
//#define IntensityDivR6 1
|
||||
|
||||
uniform float uIntensityScale;
|
||||
|
||||
out float AO;
|
||||
|
||||
vec3 getVSPosition(ivec2 ScreenSpaceCoord) {
|
||||
float z = texelFetch(ViewSpaceZ, ScreenSpaceCoord, 0).r;
|
||||
//Get the xy view space coordinates and add the z value from ViewSpaceZ buffer.
|
||||
return vec3((uProjInfo[0] + (ScreenSpaceCoord.x * uProjInfo[1])) * z, (uProjInfo[2] + (ScreenSpaceCoord.y * uProjInfo[3])) * z, z);
|
||||
}
|
||||
|
||||
vec3 getVSFaceNormal(vec3 ViewSpacePosition) {
|
||||
// Get tangets vector for the plane and ViewSpacePositin... don't ask how this functions works. It's pure magic.
|
||||
// They do this and it just works... I would guess that they approximate the function of a plane from pixels close to the pixel were on now.
|
||||
return normalize(cross(dFdx(ViewSpacePosition), dFdy(ViewSpacePosition)));
|
||||
}
|
||||
|
||||
|
||||
vec3 getSampleViewSpacePos(ivec2 ScreenSpaceCoord, int SampleIndex, float RotationAngle, float ScreenSpaceSampleRadius){
|
||||
// Pure Magic...
|
||||
float alpha = float(SampleIndex) * (1.0 / uNumOfSamples);
|
||||
|
||||
// Angle to where to sample
|
||||
float angle = alpha * (uNumOfTurns * 6.28) + RotationAngle;
|
||||
|
||||
//Lenght to were to sample
|
||||
ScreenSpaceSampleRadius = ScreenSpaceSampleRadius * alpha;
|
||||
|
||||
vec2 screenSpaceSampleOffsetVecor = vec2(cos(angle), sin(angle));
|
||||
|
||||
// Get texel coordinate on where to sample by going screenSpaceSampleOffsetVecor direction in ScreenSpaceSampleRadius units from ScreenSpaceCoord (the point being shaded);
|
||||
ivec2 screenSpaceSampleTexel = ivec2(ScreenSpaceSampleRadius * screenSpaceSampleOffsetVecor) + ScreenSpaceCoord;
|
||||
|
||||
return getVSPosition(screenSpaceSampleTexel);
|
||||
}
|
||||
|
||||
|
||||
|
||||
float sampleAO(ivec2 ScreenSpaceCoord, vec3 Origin, vec3 OriginNormal, float ScreenSpaceSampleRadius, int SampleIndex, float RotationAngle, float Radius) {
|
||||
float radius2 = Radius * Radius;
|
||||
vec3 sampleViewSpacePosition = getSampleViewSpacePos(ScreenSpaceCoord, SampleIndex, RotationAngle, ScreenSpaceSampleRadius);
|
||||
|
||||
vec3 sampleVector = Origin - sampleViewSpacePosition;
|
||||
|
||||
// vv = sampleVectorLenght ^ 2
|
||||
float vv = dot(sampleVector, sampleVector);
|
||||
// vn = angle between sampleVector and Normal
|
||||
float vn = dot(sampleVector, OriginNormal);
|
||||
|
||||
const float epsilon = 0.0001f;
|
||||
|
||||
// vv < radius2 if the vector is shorter then the radius;
|
||||
// vn - bias, offset the angle to reduse self occlusion.
|
||||
// epsilon is here to make divison by 0 impossible.
|
||||
return float(vv < radius2) * max((vn - uBias) / (epsilon + vv), 0.0);
|
||||
//float f = max(radius2 - vv, 0.0);
|
||||
//return f * f * f * max((vn - uBias) / (epsilon + vv), 0.0);
|
||||
}
|
||||
|
||||
|
||||
void main() {
|
||||
ivec2 originScreenCoord = ivec2(gl_FragCoord.xy);
|
||||
|
||||
vec3 origin = getVSPosition(originScreenCoord);
|
||||
|
||||
float radius;
|
||||
if(origin.z < uRadius){
|
||||
radius = origin.z;
|
||||
} else {
|
||||
radius = uRadius;
|
||||
}
|
||||
|
||||
|
||||
vec3 originNormal = getVSFaceNormal(origin);
|
||||
|
||||
float screenSpaceSampleRadius = -uProjScale * radius / origin.z;
|
||||
|
||||
float rotationAngleOffset = 30 * originScreenCoord.x ^ originScreenCoord.y + 10 * originScreenCoord.x * originScreenCoord.y;
|
||||
|
||||
float sum = 0.0;
|
||||
for (int i = 0; i < uNumOfSamples; i++) {
|
||||
sum += sampleAO(originScreenCoord, origin, originNormal, screenSpaceSampleRadius, i, rotationAngleOffset, radius);
|
||||
}
|
||||
|
||||
//float A = max(0.0, 1.0 - sum * (2.0f / uNumOfSamples));
|
||||
float A = 1.0 - sum * (2.0f * uIntensityScale / float(uNumOfSamples));
|
||||
AO = clamp(pow(A, uContrast), 0.0f, 1.0f);
|
||||
//AO = vec4(originNormal, 1.0f);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
#version 430
|
||||
|
||||
layout (location = 0) in vec3 Position;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#version 430
|
||||
|
||||
layout (binding = 0) uniform sampler2D DepthBuffer;
|
||||
uniform vec3 ClipInfo;
|
||||
|
||||
out float depthLinear;
|
||||
//Just for Debug, should be depthLinear
|
||||
//out vec4 fragmentColor;
|
||||
void main() {
|
||||
float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r;
|
||||
depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]);
|
||||
//float depthLinear = (NearClip) / ( -depthSample + 1.0f);
|
||||
//fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f);
|
||||
}
|
||||
@@ -7,8 +7,8 @@ uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
|
||||
layout (binding = 0) uniform sampler2D DiffuseTexture;
|
||||
layout (binding = 1) uniform sampler2D GlowMapTexture;
|
||||
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
||||
layout (binding = 2) uniform sampler2D GlowMapTexture;
|
||||
|
||||
|
||||
in VertexData{
|
||||
|
||||
@@ -19,16 +19,20 @@ void DrawBloomPass::InitializeTextures()
|
||||
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();
|
||||
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");
|
||||
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();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,15 +75,12 @@ void DrawBloomPass::Draw(GLuint texture)
|
||||
//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].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
|
||||
@@ -92,7 +93,6 @@ void DrawBloomPass::Draw(GLuint texture)
|
||||
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();
|
||||
@@ -112,7 +112,6 @@ void DrawBloomPass::Draw(GLuint texture)
|
||||
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
|
||||
|
||||
@@ -27,6 +27,7 @@ void DrawFinalPass::InitializeFrameBuffers()
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
GLERROR("RenderBuffer generation");
|
||||
|
||||
|
||||
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
@@ -173,25 +174,25 @@ void DrawFinalPass::InitializeShaderPrograms()
|
||||
GLERROR("Creating DepthFill program");
|
||||
}
|
||||
|
||||
void DrawFinalPass::Draw(RenderScene& scene)
|
||||
void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
|
||||
{
|
||||
GLERROR("Pre");
|
||||
|
||||
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
||||
if (scene.ClearDepth) {
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||
state->Disable(GL_DEPTH_TEST);
|
||||
state->DepthMask(GL_FALSE);
|
||||
}
|
||||
//TODO: Do we need check for this or will it be per scene always?
|
||||
glClearStencil(0x00);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
//Fill depth buffer
|
||||
|
||||
|
||||
|
||||
state->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||
GLERROR("OpaqueObjects");
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||
GLERROR("TransparentObjects");
|
||||
DrawSprites(scene.Jobs.SpriteJob, scene);
|
||||
GLERROR("SpriteJobs");
|
||||
@@ -206,11 +207,11 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
//Draw Opaque shielded objects
|
||||
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||
state->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing
|
||||
GLERROR("Shielded Opaque object");
|
||||
|
||||
//Draw Transparen Shielded objects
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene, SSAOTexture); //might need changing
|
||||
GLERROR("Shielded Transparent objects");
|
||||
|
||||
GLERROR("END");
|
||||
@@ -241,14 +242,14 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||
GLERROR("StencilPass");
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
||||
stateLowRes->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||
GLERROR("OpaqueObjects");
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||
GLERROR("TransparentObjects");
|
||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
@@ -321,7 +322,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
|
||||
GLERROR("MipMap Texture initialization failed");
|
||||
}
|
||||
|
||||
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene, GLuint SSAOTexture)
|
||||
{
|
||||
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||
GLERROR("forwardHandle");
|
||||
@@ -344,6 +345,9 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, SSAOTexture);
|
||||
|
||||
for (auto &job : jobs) {
|
||||
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||
if (explosionEffectJob) {
|
||||
@@ -690,14 +694,14 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
|
||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
if (spriteJob->DiffuseTexture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
|
||||
} else {
|
||||
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
if (spriteJob->IncandescenceTexture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, spriteJob->IncandescenceTexture->m_Texture);
|
||||
} else {
|
||||
@@ -807,7 +811,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
case RawModel::MaterialType::Basic:
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat));
|
||||
@@ -817,7 +821,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
|
||||
@@ -827,7 +831,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat));
|
||||
@@ -837,7 +841,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glActiveTexture(GL_TEXTURE4);
|
||||
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat));
|
||||
@@ -850,7 +854,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptr<E
|
||||
}
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, job->SplatMap->Texture->m_Texture);
|
||||
|
||||
int texturePosition = GL_TEXTURE1;
|
||||
@@ -925,7 +929,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
||||
case RawModel::MaterialType::SingleTextures:
|
||||
case RawModel::MaterialType::Basic:
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
if (job->DiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat));
|
||||
@@ -935,7 +939,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
if (job->NormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat));
|
||||
@@ -945,7 +949,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
if (job->SpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat));
|
||||
@@ -955,7 +959,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(glm::vec2(1.0f, 1.0f)));
|
||||
}
|
||||
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glActiveTexture(GL_TEXTURE4);
|
||||
if (job->IncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) {
|
||||
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture);
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat));
|
||||
@@ -968,10 +972,10 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptr<Model
|
||||
}
|
||||
case RawModel::MaterialType::SplatMapping:
|
||||
{
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, job->SplatMap->Texture->m_Texture);
|
||||
|
||||
int texturePosition = GL_TEXTURE1;
|
||||
int texturePosition = GL_TEXTURE2;
|
||||
|
||||
//Bind 5 diffuse textures
|
||||
std::string UniformName = "DiffuseUVRepeat";
|
||||
|
||||
@@ -25,11 +25,20 @@ void PickingPass::InitializeTextures()
|
||||
|
||||
void PickingPass::InitializeFrameBuffers()
|
||||
{
|
||||
glGenRenderbuffers(1, &m_DepthBuffer);
|
||||
/* glGenRenderbuffers(1, &m_DepthBuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);*/
|
||||
|
||||
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
||||
glGenTextures(1, &m_DepthBuffer);
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, m_DepthBuffer);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width), (int)(m_Renderer->GetViewportSize().Height), 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||
|
||||
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
||||
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0)));
|
||||
m_PickingBuffer.Generate();
|
||||
}
|
||||
@@ -63,7 +72,9 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
m_PickingProgram->Bind();
|
||||
|
||||
if (scene.ClearDepth) {
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||
state->Disable(GL_DEPTH_TEST);
|
||||
state->DepthMask(GL_FALSE);
|
||||
}
|
||||
m_Camera = scene.Camera;
|
||||
|
||||
|
||||
@@ -108,7 +108,15 @@ void Renderer::Update(double dt)
|
||||
|
||||
void Renderer::Draw(RenderFrame& frame)
|
||||
{
|
||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking");
|
||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
|
||||
|
||||
ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f);
|
||||
ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f);
|
||||
ImGui::SliderFloat("SSAO contrast", &m_SSAO_Contrast, 0.0f, 10.0f);
|
||||
ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f);
|
||||
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);
|
||||
//clear buffer 0
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
@@ -119,15 +127,21 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
m_DrawFinalPass->ClearBuffer();
|
||||
m_DrawBloomPass->ClearBuffer();
|
||||
PerformanceTimer::StopTimer("Renderer-ClearBuffers");
|
||||
|
||||
for (auto scene : frame.RenderScenes) {
|
||||
PerformanceTimer::StartTimer("Renderer-Depth");
|
||||
m_PickingPass->Draw(*scene);
|
||||
GLERROR("Drawing pickingpass");
|
||||
PerformanceTimer::StopTimer("Renderer-Depth");
|
||||
}
|
||||
PerformanceTimer::StartTimer("AO generation");
|
||||
m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera);
|
||||
GLuint ao = m_SSAOPass->SSAOTexture();
|
||||
PerformanceTimer::StopTimer("AO generation");
|
||||
for (auto scene : frame.RenderScenes){
|
||||
|
||||
PerformanceTimer::StartTimer("Renderer-Depth");
|
||||
PerformanceTimer::StartTimer("Renderer-Drawing PickingPass");
|
||||
SortRenderJobsByDepth(*scene);
|
||||
GLERROR("SortByDepth");
|
||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Drawing PickingPass");
|
||||
m_PickingPass->Draw(*scene);
|
||||
GLERROR("Drawing pickingpass");
|
||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums");
|
||||
m_LightCullingPass->GenerateNewFrustum(*scene);
|
||||
GLERROR("Generate frustums");
|
||||
@@ -137,8 +151,8 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
||||
m_LightCullingPass->CullLights(*scene);
|
||||
GLERROR("LightCulling");
|
||||
m_DrawFinalPass->Draw(*scene, ao);
|
||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
||||
m_DrawFinalPass->Draw(*scene);
|
||||
GLERROR("Draw Geometry+Light");
|
||||
//m_DrawScenePass->Draw(*scene);
|
||||
|
||||
@@ -147,14 +161,17 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
GLERROR("Draw Text");
|
||||
PerformanceTimer::StopTimer("Renderer-Draw Text");
|
||||
}
|
||||
|
||||
PerformanceTimer::StartTimer("Renderer-Draw Bloom");
|
||||
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
||||
PerformanceTimer::StopTimer("Renderer-Draw Bloom");
|
||||
|
||||
if (m_DebugTextureToDraw == 0) {
|
||||
PerformanceTimer::StartTimer("Renderer-Color Correction Pass");
|
||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure);
|
||||
PerformanceTimer::StopTimer("Renderer-Color Correction Pass");
|
||||
}
|
||||
|
||||
PerformanceTimer::StartTimer("Renderer-Misc Debug Draws");
|
||||
if (m_DebugTextureToDraw == 1) {
|
||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
||||
@@ -174,7 +191,10 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
if (m_DebugTextureToDraw == 6) {
|
||||
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
|
||||
}
|
||||
PerformanceTimer::StopTimer("Renderer-Misc Debug Draws");
|
||||
if (m_DebugTextureToDraw == 7) {
|
||||
m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture());
|
||||
}
|
||||
PerformanceTimer::StopTimer("Renderer-Misc Debug Draws");
|
||||
|
||||
PerformanceTimer::StartTimer("Renderer-ImGuiRenderPass");
|
||||
m_ImGuiRenderPass->Draw();
|
||||
@@ -223,4 +243,5 @@ void Renderer::InitializeRenderPasses()
|
||||
m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
|
||||
m_DrawBloomPass = new DrawBloomPass(this);
|
||||
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
||||
m_SSAOPass = new SSAOPass(this);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,141 @@
|
||||
#include "Rendering/SSAOPass.h"
|
||||
|
||||
SSAOPass::SSAOPass(IRenderer* renderer)
|
||||
{
|
||||
m_Renderer = renderer;
|
||||
|
||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||
|
||||
InitializeBuffer();
|
||||
InitializeShaderProgram();
|
||||
Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7);
|
||||
|
||||
m_DrawBloomPass = new DrawBloomPass(renderer);
|
||||
}
|
||||
|
||||
void SSAOPass::InitializeShaderProgram()
|
||||
{
|
||||
m_SSAOProgram = ResourceManager::Load<ShaderProgram>("##SSAOProgram");
|
||||
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
||||
m_SSAOProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAO.frag.glsl")));
|
||||
m_SSAOProgram->Compile();
|
||||
m_SSAOProgram->Link();
|
||||
|
||||
m_SSAOViewSpaceZProgram = ResourceManager::Load<ShaderProgram>("##SSAOViewSpaceZProgram");
|
||||
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/SSAO.vert.glsl")));
|
||||
m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl")));
|
||||
m_SSAOViewSpaceZProgram->Compile();
|
||||
m_SSAOViewSpaceZProgram->Link();
|
||||
}
|
||||
|
||||
|
||||
void SSAOPass::InitializeBuffer()
|
||||
{
|
||||
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);
|
||||
|
||||
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0)));
|
||||
m_SSAOFramBuffer.Generate();
|
||||
|
||||
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);
|
||||
|
||||
m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0)));
|
||||
m_SSAOViewSpaceZFramBuffer.Generate();
|
||||
}
|
||||
|
||||
void SSAOPass::ClearBuffer()
|
||||
{
|
||||
m_SSAOFramBuffer.Bind();
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
m_SSAOFramBuffer.Unbind();
|
||||
|
||||
m_SSAOViewSpaceZFramBuffer.Bind();
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
m_SSAOViewSpaceZFramBuffer.Unbind();
|
||||
}
|
||||
|
||||
void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns) {
|
||||
m_Radius = radius;
|
||||
m_Bias = bias;
|
||||
m_Contrast = contrast;
|
||||
m_IntensityScale = intensityScale;
|
||||
m_NumOfSamples = numOfSamples;
|
||||
m_NumOfTurns = NumOfTurns;
|
||||
}
|
||||
|
||||
void SSAOPass::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);
|
||||
GLERROR("Texture initialization failed");
|
||||
}
|
||||
|
||||
void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
||||
{
|
||||
SSAOPassState state;
|
||||
GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle();
|
||||
GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle();
|
||||
|
||||
m_SSAOViewSpaceZFramBuffer.Bind();
|
||||
m_SSAOViewSpaceZProgram->Bind();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, depthBuffer);
|
||||
glm::vec3 clipInfo = glm::vec3(
|
||||
(camera->NearClip() * camera->FarClip()),
|
||||
(camera->NearClip() - camera->FarClip()),
|
||||
(camera->FarClip())
|
||||
);
|
||||
/*glm::vec3 clipInfo = glm::vec3(
|
||||
(camera->NearClip()),
|
||||
(-1.0f),
|
||||
(+1.0f)
|
||||
);*/
|
||||
glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo));
|
||||
|
||||
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);
|
||||
|
||||
glm::vec4 projInfo = glm::vec4(
|
||||
((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]),
|
||||
(-2.0 / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])),
|
||||
((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]),
|
||||
(-2.0 / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1]))
|
||||
);
|
||||
|
||||
|
||||
m_SSAOFramBuffer.Bind();
|
||||
m_SSAOProgram->Bind();
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture);
|
||||
|
||||
// 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, "uRadius"), m_Radius);
|
||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias);
|
||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast);
|
||||
glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale);
|
||||
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples);
|
||||
glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);;
|
||||
|
||||
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
|
||||
, GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
|
||||
|
||||
m_DrawBloomPass->ClearBuffer();
|
||||
m_DrawBloomPass->Draw(m_SSAOTexture);
|
||||
}
|
||||
|
||||
void ComputeAO(GLuint depthBuffer, Camera* camera) {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
#include "Rendering/SSAOPassState.h"
|
||||
|
||||
|
||||
SSAOPassState::SSAOPassState()
|
||||
{
|
||||
//BindFramebuffer(0);
|
||||
Disable(GL_BLEND);
|
||||
Disable(GL_DEPTH_TEST);
|
||||
Disable(GL_CULL_FACE);
|
||||
}
|
||||
|
||||
SSAOPassState::~SSAOPassState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -98,8 +98,7 @@ void ShaderProgram::AddShader(std::shared_ptr<Shader> shader)
|
||||
|
||||
void ShaderProgram::Compile()
|
||||
{
|
||||
if (m_ShaderProgramHandle == 0)
|
||||
{
|
||||
if (m_ShaderProgramHandle == 0) {
|
||||
m_ShaderProgramHandle = glCreateProgram();
|
||||
}
|
||||
|
||||
|
||||
@@ -33,10 +33,16 @@ file(GLOB SOURCE_FILES_Network
|
||||
"Network/*.cpp"
|
||||
)
|
||||
source_group(Network FILES ${SOURCE_FILES_Network})
|
||||
|
||||
file(GLOB SOURCE_FILES
|
||||
"${INCLUDE_PATH}/*.h"
|
||||
"*.cpp"
|
||||
)
|
||||
list(REMOVE_ITEM SOURCE_FILES "${CMAKE_CURRENT_SOURCE_DIR}/main.cpp")
|
||||
source_group(Game FILES ${SOURCE_FILES})
|
||||
|
||||
set(SOURCE_FILES
|
||||
${SOURCE_FILES}
|
||||
"Game.cpp"
|
||||
"MiniDump.cpp"
|
||||
${SOURCE_FILES_Systems}
|
||||
${SOURCE_FILES_Systems_Weapon}
|
||||
${SOURCE_FILES_Events}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
#include "CapturePointsEntitySystem.h"
|
||||
#include "Systems/InterpolationSystem.h"
|
||||
#include "Systems/SoundSystem.h"
|
||||
#include "Systems/RaptorCopterSystem.h"
|
||||
#include "Systems/ExplosionEffectSystem.h"
|
||||
#include "Systems/HealthSystem.h"
|
||||
#include "Systems/PlayerMovementSystem.h"
|
||||
#include "Systems/SpawnerSystem.h"
|
||||
#include "Systems/PlayerSpawnSystem.h"
|
||||
#include "Systems/Weapon/WeaponSystem.h"
|
||||
#include "Systems/LifetimeSystem.h"
|
||||
#include "Systems/CapturePointSystem.h"
|
||||
#include "Systems/CapturePointHUDSystem.h"
|
||||
#include "Systems/PickupSpawnSystem.h"
|
||||
#include "Systems/AmmoPickupSystem.h"
|
||||
#include "Systems/DamageIndicatorSystem.h"
|
||||
#include "Systems/AmmunitionHUDSystem.h"
|
||||
#include "Systems/KillFeedSystem.h"
|
||||
#include "GUI/ButtonSystem.h"
|
||||
#include "GUI/MainMenuSystem.h"
|
||||
#include "Collision/FillOctreeSystem.h"
|
||||
#include "Collision/FillFrustumOctreeSystem.h"
|
||||
#include "Rendering/AnimationSystem.h"
|
||||
#include "Core/UniformScaleSystem.h"
|
||||
#include "Systems/HealthHUDSystem.h"
|
||||
#include "Systems/PlayerDeathSystem.h"
|
||||
#include "Rendering/BoneAttachmentSystem.h"
|
||||
#include "Collision/CollisionSystem.h"
|
||||
#include "Collision/TriggerSystem.h"
|
||||
#include "Rendering/RenderSystem.h"
|
||||
#include "Editor/EditorSystem.h"
|
||||
|
||||
CapturePointsEntitySystem::CapturePointsEntitySystem(EventBroker* eventBroker, bool isClient, bool isServer, IRenderer* renderer, RenderFrame* renderFrame)
|
||||
: EntitySystem(eventBroker, isClient, isServer)
|
||||
, m_Renderer(renderer)
|
||||
, m_RenderFrame(renderFrame)
|
||||
{
|
||||
// Create Octrees
|
||||
// TODO: Perhaps the world bounds should be set in some non-arbitrary way instead of this.
|
||||
AABB boxContainingTheWorld(glm::vec3(-300), glm::vec3(300));
|
||||
m_OctreeCollision = new Octree<EntityAABB>(boxContainingTheWorld, 4);
|
||||
m_OctreeTrigger = new Octree<EntityAABB>(boxContainingTheWorld, 4);
|
||||
m_OctreeFrustrumCulling = new Octree<EntityAABB>(boxContainingTheWorld, 4);
|
||||
|
||||
// All systems with orderlevel 0 will be updated first.
|
||||
unsigned int updateOrderLevel = 0;
|
||||
AddSystem<InterpolationSystem>(updateOrderLevel);
|
||||
++updateOrderLevel;
|
||||
AddSystem<SoundSystem>(updateOrderLevel);
|
||||
AddSystem<RaptorCopterSystem>(updateOrderLevel);
|
||||
AddSystem<ExplosionEffectSystem>(updateOrderLevel);
|
||||
AddSystem<HealthSystem>(updateOrderLevel);
|
||||
AddSystem<PlayerMovementSystem>(updateOrderLevel);
|
||||
AddSystem<SpawnerSystem>(updateOrderLevel);
|
||||
AddSystem<PlayerSpawnSystem>(updateOrderLevel);
|
||||
AddSystem<WeaponSystem>(updateOrderLevel, m_Renderer, m_OctreeCollision);
|
||||
AddSystem<LifetimeSystem>(updateOrderLevel);
|
||||
AddSystem<CapturePointSystem>(updateOrderLevel);
|
||||
AddSystem<CapturePointHUDSystem>(updateOrderLevel);
|
||||
AddSystem<PickupSpawnSystem>(updateOrderLevel);
|
||||
AddSystem<AmmoPickupSystem>(updateOrderLevel);
|
||||
AddSystem<DamageIndicatorSystem>(updateOrderLevel);
|
||||
AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
|
||||
AddSystem<KillFeedSystem>(updateOrderLevel);
|
||||
AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
|
||||
AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer);
|
||||
// Populate Octree with collidables
|
||||
++updateOrderLevel;
|
||||
AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||
AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
||||
AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
|
||||
AddSystem<AnimationSystem>(updateOrderLevel);
|
||||
AddSystem<UniformScaleSystem>(updateOrderLevel);
|
||||
AddSystem<HealthHUDSystem>(updateOrderLevel);
|
||||
AddSystem<PlayerDeathSystem>(updateOrderLevel);
|
||||
// Collision and TriggerSystem should update after player.
|
||||
++updateOrderLevel;
|
||||
AddSystem<BoneAttachmentSystem>(updateOrderLevel);
|
||||
AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
|
||||
AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeTrigger);
|
||||
++updateOrderLevel;
|
||||
AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
|
||||
++updateOrderLevel;
|
||||
AddSystem<EditorSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
||||
}
|
||||
|
||||
CapturePointsEntitySystem::~CapturePointsEntitySystem()
|
||||
{
|
||||
if (m_OctreeFrustrumCulling != nullptr) {
|
||||
delete m_OctreeFrustrumCulling;
|
||||
}
|
||||
if (m_OctreeCollision != nullptr) {
|
||||
delete m_OctreeCollision;
|
||||
}
|
||||
if (m_OctreeTrigger != nullptr) {
|
||||
delete m_OctreeTrigger;
|
||||
}
|
||||
}
|
||||
+13
-100
@@ -1,34 +1,8 @@
|
||||
#include "Game.h"
|
||||
#include "Collision/FillOctreeSystem.h"
|
||||
#include "Collision/FillFrustumOctreeSystem.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
#include "Collision/TriggerSystem.h"
|
||||
#include "Collision/CollisionSystem.h"
|
||||
#include "Systems/RaptorCopterSystem.h"
|
||||
#include "Systems/HealthSystem.h"
|
||||
#include "Systems/PlayerMovementSystem.h"
|
||||
#include "Systems/SpawnerSystem.h"
|
||||
#include "Systems/PlayerSpawnSystem.h"
|
||||
#include "Systems/PlayerDeathSystem.h"
|
||||
#include "Core/EntityFileWriter.h"
|
||||
#include "Game/Systems/CapturePointSystem.h"
|
||||
#include "Game/Systems/CapturePointHUDSystem.h"
|
||||
#include "Game/Systems/PickupSpawnSystem.h"
|
||||
#include "Game/Systems/AmmoPickupSystem.h"
|
||||
#include "Game/Systems/DamageIndicatorSystem.h"
|
||||
#include "Game/Systems/Weapon/WeaponSystem.h"
|
||||
#include "Rendering/AnimationSystem.h"
|
||||
#include "Game/Systems/HealthHUDSystem.h"
|
||||
#include "Rendering/BoneAttachmentSystem.h"
|
||||
#include "Game/Systems/LifetimeSystem.h"
|
||||
#include "../Engine/Core/UniformScaleSystem.h"
|
||||
#include "Rendering/AnimationSystem.h"
|
||||
#include "Network/MultiplayerSnapshotFilter.h"
|
||||
#include "Game/Systems/AmmunitionHUDSystem.h"
|
||||
#include "Game/Systems/KillFeedSystem.h"
|
||||
#include "GUI/ButtonSystem.h"
|
||||
#include "GUI/MainMenuSystem.h"
|
||||
|
||||
#include "Systems/PlayerSpawnSystem.h"
|
||||
#include "CapturePointsEntitySystem.h"
|
||||
|
||||
Game::Game(int argc, char* argv[])
|
||||
{
|
||||
@@ -48,6 +22,7 @@ Game::Game(int argc, char* argv[])
|
||||
ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true);
|
||||
DisableMemoryPool::Value = m_Config->Get<bool>("Debug.DisableMemoryPool", false);
|
||||
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
|
||||
// HACK: This shouldn't be a config variable
|
||||
PlayerSpawnSystem::SetRespawnTime(m_Config->Get<float>("Debug.RespawnTime", 15.0f));
|
||||
|
||||
// Create the core event broker
|
||||
@@ -74,91 +49,30 @@ Game::Game(int argc, char* argv[])
|
||||
m_InputProxy->AddHandler<MouseInputHandler>();
|
||||
m_InputProxy->LoadBindings("Input.ini");
|
||||
|
||||
// Create a world
|
||||
m_World = new World(m_EventBroker);
|
||||
std::string mapToLoad = m_Config->Get<std::string>("Debug.LoadMap", "");
|
||||
if (!mapToLoad.empty()) {
|
||||
auto file = ResourceManager::Load<EntityFile>(mapToLoad);
|
||||
EntityFilePreprocessor fpp(file);
|
||||
fpp.RegisterComponents(m_World);
|
||||
EntityFileParser fp(file);
|
||||
fp.MergeEntities(m_World);
|
||||
}
|
||||
|
||||
// Create the sound manager
|
||||
m_SoundManager = new SoundManager(m_World, m_EventBroker);
|
||||
//m_SoundManager = new SoundManager(m_World, m_EventBroker);
|
||||
|
||||
// Create an entity system
|
||||
m_EntitySystem = new CapturePointsEntitySystem(m_EventBroker, m_IsClient, m_IsServer, m_Renderer, m_RenderFrame);
|
||||
|
||||
// Initialize network
|
||||
if (m_Config->Get<bool>("Networking.StartNetwork", false)) {
|
||||
if (m_IsServer) {
|
||||
m_NetworkServer = new Server(m_World, m_EventBroker, m_NetworkPort);
|
||||
m_NetworkServer = new Server(m_EntitySystem, m_EventBroker, m_NetworkPort);
|
||||
m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " SERVER");
|
||||
} else if (m_IsClient) {
|
||||
m_NetworkClient = new Client(m_World, m_EventBroker, std::make_unique<MultiplayerSnapshotFilter>(m_EventBroker));
|
||||
m_NetworkClient = new Client(m_EntitySystem, m_EventBroker, std::make_unique<MultiplayerSnapshotFilter>(m_EventBroker));
|
||||
m_NetworkClient->Connect(m_NetworkAddress, m_NetworkPort);
|
||||
m_Renderer->SetWindowTitle(m_Renderer->WindowTitle() + " CLIENT");
|
||||
}
|
||||
}
|
||||
|
||||
// Create Octrees
|
||||
// TODO: Perhaps the world bounds should be set in some non-arbitrary way instead of this.
|
||||
AABB boxContainingTheWorld(glm::vec3(-300), glm::vec3(300));
|
||||
m_OctreeCollision = new Octree<EntityAABB>(boxContainingTheWorld, 4);
|
||||
m_OctreeTrigger = new Octree<EntityAABB>(boxContainingTheWorld, 4);
|
||||
m_OctreeFrustrumCulling = new Octree<EntityAABB>(boxContainingTheWorld, 4);
|
||||
// Create system pipeline
|
||||
m_SystemPipeline = new SystemPipeline(m_World, m_EventBroker, m_IsClient, m_IsServer);
|
||||
|
||||
// All systems with orderlevel 0 will be updated first.
|
||||
unsigned int updateOrderLevel = 0;
|
||||
m_SystemPipeline->AddSystem<InterpolationSystem>(updateOrderLevel);
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<SoundSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<RaptorCopterSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<ExplosionEffectSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<HealthSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<SpawnerSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<PlayerSpawnSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<WeaponSystem>(updateOrderLevel, m_Renderer, m_OctreeCollision);
|
||||
m_SystemPipeline->AddSystem<LifetimeSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<CapturePointSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<CapturePointHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmoPickupSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<DamageIndicatorSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AmmunitionHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<KillFeedSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<ButtonSystem>(updateOrderLevel, m_Renderer);
|
||||
m_SystemPipeline->AddSystem<MainMenuSystem>(updateOrderLevel, m_Renderer);
|
||||
// Populate Octree with collidables
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
||||
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
|
||||
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<UniformScaleSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<HealthHUDSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<PlayerDeathSystem>(updateOrderLevel);
|
||||
// Collision and TriggerSystem should update after player.
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<BoneAttachmentSystem>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
|
||||
m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeTrigger);
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<EditorSystem>(updateOrderLevel, m_Renderer, m_RenderFrame);
|
||||
|
||||
m_LastTime = glfwGetTime();
|
||||
}
|
||||
|
||||
Game::~Game()
|
||||
{
|
||||
delete m_SystemPipeline;
|
||||
delete m_OctreeFrustrumCulling;
|
||||
delete m_OctreeCollision;
|
||||
delete m_OctreeTrigger;
|
||||
delete m_EntitySystem;
|
||||
delete m_SoundManager;
|
||||
if (m_NetworkClient != nullptr) {
|
||||
delete m_NetworkClient;
|
||||
@@ -166,7 +80,6 @@ Game::~Game()
|
||||
if (m_NetworkServer != nullptr) {
|
||||
delete m_NetworkServer;
|
||||
}
|
||||
delete m_World;
|
||||
delete m_InputProxy;
|
||||
delete m_InputManager;
|
||||
delete m_RenderFrame;
|
||||
@@ -195,7 +108,7 @@ void Game::Tick()
|
||||
m_EventBroker->Swap();
|
||||
|
||||
PerformanceTimer::StartTimerAndStopPrevious("SoundManager");
|
||||
m_SoundManager->Update(dt);
|
||||
//m_SoundManager->Update(dt);
|
||||
|
||||
// Update network
|
||||
PerformanceTimer::StartTimerAndStopPrevious("Network");
|
||||
@@ -209,9 +122,9 @@ void Game::Tick()
|
||||
//m_SoundManager->Update(dt);
|
||||
|
||||
// Iterate through systems and update world!
|
||||
PerformanceTimer::StartTimerAndStopPrevious("SystemPipeline");
|
||||
PerformanceTimer::StartTimerAndStopPrevious("EntitySystem");
|
||||
m_EventBroker->Process<SystemPipeline>();
|
||||
m_SystemPipeline->Update(dt);
|
||||
m_EntitySystem->Update(dt);
|
||||
PerformanceTimer::StartTimerAndStopPrevious("RendererUpdate");
|
||||
m_Renderer->Update(dt);
|
||||
PerformanceTimer::StartTimerAndStopPrevious("RendererDraw");
|
||||
|
||||
@@ -192,27 +192,6 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
//NextPossibleCapturePoint will be calculated in the next update...
|
||||
}
|
||||
}
|
||||
|
||||
//check for possible winCondition = check if the homebase is owned by the other team
|
||||
bool checkForWinner = false;
|
||||
if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam)
|
||||
{
|
||||
checkForWinner = true;
|
||||
}
|
||||
if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam)
|
||||
{
|
||||
checkForWinner = true;
|
||||
}
|
||||
|
||||
if (checkForWinner && !m_WinnerWasFound)
|
||||
{
|
||||
//publish Win event
|
||||
Events::Win e;
|
||||
e.TeamThatWon = ownedBy;
|
||||
m_EventBroker->Publish(e);
|
||||
m_WinnerWasFound = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
|
||||
|
||||
@@ -0,0 +1,117 @@
|
||||
#include "Systems/CapturePointsGamemode.h"
|
||||
|
||||
CapturePointsGamemode::CapturePointsGamemode(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointsGamemode::OnCaptured);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EGameStart, &CapturePointsGamemode::OnGameStart);
|
||||
}
|
||||
|
||||
void CapturePointsGamemode::Update(double dt)
|
||||
{
|
||||
if (!m_GameRuning) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto cGamemode = currentGamemode();
|
||||
if (!cGamemode) {
|
||||
setRunning(false);
|
||||
return;
|
||||
}
|
||||
|
||||
m_GameTime += dt;
|
||||
(double&)(*cGamemode)["RoundTime"] = m_GameTime;
|
||||
}
|
||||
|
||||
bool CapturePointsGamemode::OnGameStart(const Events::GameStart& e)
|
||||
{
|
||||
if (!isCurrentGamemode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
setRunning(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CapturePointsGamemode::OnCaptured(const Events::Captured& e)
|
||||
{
|
||||
if (!m_GameRuning) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto cGamemode = currentGamemode();
|
||||
if (!cGamemode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
auto winningTeam = winCondition();
|
||||
if (winningTeam) {
|
||||
setRunning(false);
|
||||
|
||||
Events::Win e;
|
||||
e.Team = *winningTeam;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boost::optional<ComponentWrapper> CapturePointsGamemode::currentGamemode()
|
||||
{
|
||||
auto cGamemodes = m_World->GetComponents("Gamemode");
|
||||
if (cGamemodes->begin() == cGamemodes->end()) {
|
||||
return boost::none;
|
||||
}
|
||||
return *cGamemodes->begin();
|
||||
}
|
||||
|
||||
bool CapturePointsGamemode::isCurrentGamemode()
|
||||
{
|
||||
auto cGamemode = currentGamemode();
|
||||
if (!cGamemode) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that we're the current gamemode
|
||||
if ((ComponentInfo::EnumType)(*cGamemode)["Gamemode"] == (*cGamemode)["Gamemode"].Enum("CapturePoints")) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boost::optional<ComponentInfo::EnumType> CapturePointsGamemode::winCondition()
|
||||
{
|
||||
auto cCapturePoints = m_World->GetComponents("CapturePoint");
|
||||
|
||||
// If all capture points are owned by the same team, they won
|
||||
ComponentInfo::EnumType winningTeam = -1;
|
||||
for (auto& c : *cCapturePoints) {
|
||||
EntityWrapper e(m_World, c.EntityID);
|
||||
ComponentInfo::EnumType team = e["Team"]["Team"];
|
||||
if (winningTeam != -1 && winningTeam != team) {
|
||||
return boost::none;
|
||||
} else {
|
||||
winningTeam = team;
|
||||
}
|
||||
}
|
||||
|
||||
return winningTeam;
|
||||
}
|
||||
|
||||
void CapturePointsGamemode::setRunning(bool running)
|
||||
{
|
||||
m_GameRuning = running;
|
||||
if (running) {
|
||||
m_GameTime = 0.0;
|
||||
}
|
||||
|
||||
auto cGamemode = currentGamemode();
|
||||
if (cGamemode) {
|
||||
m_GameRuning = running;
|
||||
if (running) {
|
||||
(*cGamemode)["RoundTime"] = 0.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,7 @@ SoundSystem::SoundSystem(SystemParams params)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &SoundSystem::OnTriggerTouch);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerHealthPickup, &SoundSystem::OnPlayerHealthPickup);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user