Compare commits
16 Commits
CubeMap
...
TempBranchSak
| Author | SHA1 | Date | |
|---|---|---|---|
| cc5943fcee | |||
| 62e22d3821 | |||
| 0805375483 | |||
| f56705d921 | |||
| 748a178801 | |||
| eac9a9daf6 | |||
| 059fe5c6c0 | |||
| fb465ede81 | |||
| f66fa7a183 | |||
| 508d8a6f00 | |||
| 8ce6308649 | |||
| f10958c268 | |||
| da1c7b3093 | |||
| ef87102d1f | |||
| 9a41bda4cf | |||
| fa13c1d065 |
@@ -21,6 +21,7 @@
|
||||
#include "Core/ConfigFile.h"
|
||||
#include "Input/EInputCommand.h"
|
||||
#include "Core/EPlayerDamage.h"
|
||||
#include "../Game/Events/EDoubleJump.h"
|
||||
#include "Network/EInterpolate.h"
|
||||
#include "Network/SnapshotFilter.h"
|
||||
#include "Core/EPlayerSpawned.h"
|
||||
@@ -47,7 +48,9 @@ public:
|
||||
|
||||
void Connect(std::string address, int port);
|
||||
void Update() override;
|
||||
|
||||
private:
|
||||
UDPClient m_Unreliable;
|
||||
TCPClient m_Reliable;
|
||||
std::vector<Events::PlayerSpawned> m_PlayerSpawnEvents;
|
||||
void parseSpawnEvents();
|
||||
// Save for children
|
||||
@@ -101,9 +104,9 @@ public:
|
||||
void parseEntityDeletion(Packet& packet);
|
||||
void parsePlayerDamage(Packet& packet);
|
||||
void parseComponentDeletion(Packet& packet);
|
||||
void parseDoubleJump(Packet& packet);
|
||||
void InterpolateFields(Packet & packet, const ComponentInfo & componentInfo, const EntityID & entityID, const std::string & componentType);
|
||||
void parseSnapshot(Packet& packet);
|
||||
void UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD);
|
||||
void identifyPacketLoss();
|
||||
void hasServerTimedOut();
|
||||
EntityID createPlayer();
|
||||
@@ -127,11 +130,10 @@ public:
|
||||
EventRelay<Client, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawned(const Events::PlayerSpawned& e);
|
||||
EventRelay< Client, Events::SearchForServers> m_ESearchForServers;
|
||||
EventRelay<Client, Events::DoubleJump> m_EDoubleJump;
|
||||
bool OnDoubleJump(Events::DoubleJump & e);
|
||||
bool OnSearchForServers(const Events::SearchForServers& e);
|
||||
private:
|
||||
UDPClient m_Unreliable;
|
||||
UDPClient m_ServerlistRequest;
|
||||
TCPClient m_Reliable;
|
||||
std::vector<ServerInfo> m_Serverlist;
|
||||
bool m_SearchingForServers = false;
|
||||
std::clock_t m_StartSearchTime;
|
||||
|
||||
@@ -19,6 +19,7 @@ enum class MessageType
|
||||
EntityDeleted,
|
||||
ComponentDeleted,
|
||||
PlayerTransform,
|
||||
OnDoubleJump,
|
||||
ServerlistRequest,
|
||||
Invalid
|
||||
};
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#include "Network/TCPServer.h"
|
||||
#include "Network/UDPServer.h"
|
||||
#include "Network/UDPClient.h" //LOL
|
||||
#include "Network/MessageType.h"
|
||||
#include "Network/PlayerDefinition.h"
|
||||
#include "Core/World.h"
|
||||
@@ -18,6 +17,7 @@
|
||||
#include "Core/EPlayerDamage.h"
|
||||
#include "Network/EPlayerDisconnected.h"
|
||||
#include "Core/EPlayerSpawned.h"
|
||||
#include "../Game/Events/EDoubleJump.h"
|
||||
#include "Core/EEntityDeleted.h"
|
||||
#include "Core/EComponentDeleted.h"
|
||||
|
||||
@@ -81,8 +81,9 @@ private:
|
||||
void parseOnInputCommand(Packet& packet);
|
||||
void parseClientPing();
|
||||
void parsePing();
|
||||
void parseUDPConnect(Packet & packet);
|
||||
void parseTCPConnect(Packet & packet);
|
||||
bool parseDoubleJump(Packet& packet);
|
||||
void parseUDPConnect(Packet& packet);
|
||||
void parseTCPConnect(Packet& packet);
|
||||
void parseDisconnect();
|
||||
void parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint);
|
||||
bool shouldSendToClient(EntityWrapper childEntity);
|
||||
|
||||
@@ -25,10 +25,9 @@ private:
|
||||
std::unique_ptr<boost::asio::ip::tcp::acceptor> acceptor;
|
||||
boost::shared_ptr<boost::asio::ip::tcp::socket> lastReceivedSocket;
|
||||
|
||||
void handle_accept(boost::shared_ptr<boost::asio::ip::tcp::socket> socket,
|
||||
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||
const boost::system::error_code& error);
|
||||
int readBuffer(PlayerDefinition& playerDefinition);
|
||||
PlayerID getPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||
boost::asio::ip::address address, unsigned short port);
|
||||
int GetPort();
|
||||
std::string GetAddress();
|
||||
int m_Port = 0;
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
class DrawBloomPass
|
||||
{
|
||||
public:
|
||||
DrawBloomPass(IRenderer* renderer /* ,Texture or finalpass*/ );
|
||||
DrawBloomPass(IRenderer* renderer, ConfigFile* config);
|
||||
~DrawBloomPass() { }
|
||||
void InitializeTextures();
|
||||
void InitializeFrameBuffers();
|
||||
@@ -23,23 +23,34 @@ public:
|
||||
void FillGaussianBuffer(FrameBuffer* fb);
|
||||
|
||||
void Draw(GLuint texture);
|
||||
void ChangeQuality(int quality);
|
||||
|
||||
void OnWindowResize();
|
||||
|
||||
//Getters
|
||||
//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:
|
||||
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;
|
||||
|
||||
const IRenderer* m_Renderer;
|
||||
ConfigFile* m_Config;
|
||||
//const LightCullingPass* m_LightCullingPass
|
||||
GLuint m_iterations = 9;
|
||||
int m_Iterations = 7;
|
||||
int m_Quality = 3;
|
||||
|
||||
GLuint m_GaussianTexture_horiz;
|
||||
GLuint m_GaussianTexture_vert;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "DrawFinalPassState.h"
|
||||
#include "LightCullingPass.h"
|
||||
#include "CubeMapPass.h"
|
||||
#include "SSAOPass.h"
|
||||
#include "FrameBuffer.h"
|
||||
#include "ShaderProgram.h"
|
||||
#include "Util/UnorderedMapVec2.h"
|
||||
@@ -14,12 +15,12 @@
|
||||
class DrawFinalPass
|
||||
{
|
||||
public:
|
||||
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass);
|
||||
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass);
|
||||
~DrawFinalPass() { }
|
||||
void InitializeTextures();
|
||||
void InitializeFrameBuffers();
|
||||
void InitializeShaderPrograms();
|
||||
void Draw(RenderScene& scene, GLuint SSAOTexture);
|
||||
void Draw(RenderScene& scene);
|
||||
void ClearBuffer();
|
||||
void OnWindowResize();
|
||||
|
||||
@@ -38,7 +39,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, 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 DrawShieldedModelRenderQueue(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 LightCullingPass* m_LightCullingPass;
|
||||
const CubeMapPass* m_CubeMapPass;
|
||||
const SSAOPass* m_SSAOPass;
|
||||
|
||||
ShaderProgram* m_ForwardPlusProgram;
|
||||
ShaderProgram* m_ExplosionEffectProgram;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "../OpenGL.h"
|
||||
#include "../GLM.h"
|
||||
#include "../Core/Util/Rectangle.h"
|
||||
#include "../Core/ConfigFile.h"
|
||||
#include "Util/ScreenCoords.h"
|
||||
#include "Camera.h"
|
||||
#include "RenderQueue.h"
|
||||
|
||||
@@ -32,8 +32,9 @@ class Renderer : public IRenderer
|
||||
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
|
||||
|
||||
public:
|
||||
Renderer(EventBroker* eventBroker)
|
||||
: m_EventBroker(eventBroker)
|
||||
Renderer(EventBroker* eventBroker, ConfigFile* config)
|
||||
: m_EventBroker(eventBroker)
|
||||
, m_Config(config)
|
||||
{ }
|
||||
|
||||
virtual void Initialize() override;
|
||||
@@ -47,6 +48,7 @@ private:
|
||||
//----------------------Variables----------------------//
|
||||
|
||||
static std::unordered_map <GLFWwindow*, Renderer*> m_WindowToRenderer;
|
||||
ConfigFile* m_Config;
|
||||
|
||||
EventBroker* m_EventBroker;
|
||||
TextPass* m_TextPass;
|
||||
@@ -61,12 +63,8 @@ private:
|
||||
int m_DebugTextureToDraw = 0;
|
||||
int m_CubeMapTexture = 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;
|
||||
int m_SSAO_Quality = 0;
|
||||
int m_GLOW_Quality = 2;
|
||||
|
||||
PickingPass* m_PickingPass;
|
||||
LightCullingPass* m_LightCullingPass;
|
||||
|
||||
@@ -13,18 +13,32 @@
|
||||
class SSAOPass
|
||||
{
|
||||
public:
|
||||
SSAOPass(IRenderer* rendere);
|
||||
~SSAOPass() {
|
||||
delete m_DrawBloomPass;
|
||||
};
|
||||
SSAOPass(IRenderer* renderer, ConfigFile* config);
|
||||
~SSAOPass() { };
|
||||
|
||||
void ChangeQuality(int quality);
|
||||
|
||||
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 OnWindowResize();
|
||||
|
||||
//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:
|
||||
void InitializeTexture();
|
||||
@@ -40,6 +54,7 @@ private:
|
||||
Model* m_ScreenQuad;
|
||||
|
||||
const IRenderer* m_Renderer;
|
||||
ConfigFile* m_Config;
|
||||
|
||||
float m_Radius;
|
||||
float m_Bias;
|
||||
@@ -47,6 +62,11 @@ private:
|
||||
float m_IntensityScale;
|
||||
int m_NumOfSamples;
|
||||
int m_NumOfTurns;
|
||||
int m_Iterations;
|
||||
int m_TextureQuality;
|
||||
int m_Quality = 0;
|
||||
|
||||
Texture* m_WhiteTexture;
|
||||
|
||||
GLuint m_SSAOTexture;
|
||||
FrameBuffer m_SSAOFramBuffer;
|
||||
@@ -54,10 +74,16 @@ private:
|
||||
GLuint m_SSAOViewSpaceZTexture;
|
||||
FrameBuffer m_SSAOViewSpaceZFramBuffer;
|
||||
|
||||
GLuint m_GaussianTexture_horiz;
|
||||
GLuint m_GaussianTexture_vert;
|
||||
|
||||
FrameBuffer m_GaussianFrameBuffer_horiz;
|
||||
FrameBuffer m_GaussianFrameBuffer_vert;
|
||||
|
||||
ShaderProgram* m_SSAOProgram;
|
||||
ShaderProgram* m_SSAOViewSpaceZProgram;
|
||||
|
||||
DrawBloomPass* m_DrawBloomPass;
|
||||
ShaderProgram* m_GaussianProgram_horiz;
|
||||
ShaderProgram* m_GaussianProgram_vert;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -8,7 +8,7 @@ namespace Events
|
||||
|
||||
struct DoubleJump : public Event
|
||||
{
|
||||
|
||||
EntityID entityID;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ private:
|
||||
double AmmoGain;
|
||||
double RespawnTimer;
|
||||
double DecreaseThisRespawnTimer;
|
||||
EntityID parentID;
|
||||
};
|
||||
std::vector<NewAmmoPickup> m_ETriggerTouchVector;
|
||||
};
|
||||
|
||||
@@ -27,6 +27,7 @@ private:
|
||||
double HealthGain;
|
||||
double RespawnTimer;
|
||||
double DecreaseThisRespawnTimer;
|
||||
EntityID parentID;
|
||||
};
|
||||
std::vector<NewHealthPickup> m_ETriggerTouchVector;
|
||||
};
|
||||
|
||||
@@ -34,9 +34,13 @@ private:
|
||||
glm::vec3 m_LastPosition = glm::vec3();
|
||||
// The logic for making the sound play when player is moving
|
||||
void playerStep(double dt);
|
||||
// Spawn a hexagon at origin of an Entity
|
||||
void spawnHexagon(EntityWrapper target);
|
||||
|
||||
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||
EventRelay<PlayerMovementSystem, Events::DoubleJump> m_EDoubleJump;
|
||||
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e);
|
||||
|
||||
void updateMovementControllers(double dt);
|
||||
void updateVelocity(EntityWrapper player, double dt);
|
||||
|
||||
@@ -36,4 +36,37 @@ ResourceLoading=true
|
||||
[Sound]
|
||||
BGMVolume=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
|
||||
@@ -2,18 +2,18 @@
|
||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:AmmoPickup/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/PickUps/AmmoPickUp.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:RaptorCopter>
|
||||
<Speed>0.1</Speed>
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
<Speed>8</Speed>
|
||||
<Axis X="0" Y="0.100000001" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="1" Z="0"/>
|
||||
<Scale X="0.3" Y="0.3" Z="0.3"/>
|
||||
<Position X="0" Y="2.36784196" Z="0"/>
|
||||
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
|
||||
<Orientation X="0" Y="18717.9453" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
|
||||
|
||||
<Components>
|
||||
<c:AABB/>
|
||||
<c:HealthPickup/>
|
||||
<c:Model>
|
||||
<Resource>Models/Props/PickUps/HealthPickUp.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:RaptorCopter>
|
||||
<Speed>0.1</Speed>
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
<Speed>8</Speed>
|
||||
<Axis X="0" Y="0.100000001" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="1" Z="0"/>
|
||||
<Scale X="0.3" Y="0.3" Z="0.3"/>
|
||||
<Position X="0" Y="2.36784196" Z="0"/>
|
||||
<Scale X="0.600000024" Y="0.600000024" Z="0.600000024"/>
|
||||
<Orientation X="0" Y="18767.0273" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Trigger/>
|
||||
</Components>
|
||||
|
||||
@@ -13,6 +13,7 @@ uniform vec4 AmbientColor;
|
||||
uniform float FillPercentage;
|
||||
uniform float GlowIntensity = 10;
|
||||
uniform vec3 CameraPosition;
|
||||
uniform int SSAOQuality;
|
||||
|
||||
uniform vec2 DiffuseUVRepeat;
|
||||
uniform vec2 NormalUVRepeat;
|
||||
@@ -125,7 +126,7 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu
|
||||
|
||||
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);
|
||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
||||
|
||||
@@ -11,6 +11,7 @@ uniform vec4 DiffuseColor;
|
||||
uniform vec4 FillColor;
|
||||
uniform vec4 Color;
|
||||
uniform vec4 AmbientColor;
|
||||
uniform int SSAOQuality;
|
||||
|
||||
//Get bineded at the same time as the textures
|
||||
uniform vec2 DiffuseUVRepeat1;
|
||||
@@ -177,7 +178,7 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
|
||||
|
||||
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);
|
||||
|
||||
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
//Number of samples per pixel
|
||||
uniform int uNumOfSamples;
|
||||
//#define NUM_SAMPLES (11)
|
||||
//#define uNumOfSamples (11)
|
||||
|
||||
//Number of turns around the cirle
|
||||
uniform int uNumOfTurns;
|
||||
//#define NUM_TURNS (7)
|
||||
//#define uNumOfTurns (7)
|
||||
|
||||
layout (binding = 0) uniform sampler2D ViewSpaceZ;
|
||||
|
||||
@@ -16,15 +16,16 @@ uniform float uProjScale;
|
||||
//#define ProjScale 500
|
||||
|
||||
uniform float uRadius;
|
||||
//#define Radius 1.0f
|
||||
//#define uRadius 1.0f
|
||||
|
||||
uniform float uBias;
|
||||
//#define Bias 0.012f
|
||||
//#define uBias 0.05f
|
||||
|
||||
uniform float uContrast;
|
||||
//#define IntensityDivR6 1
|
||||
//#define uContrast 1.5f
|
||||
|
||||
uniform float uIntensityScale;
|
||||
//#define uIntensityScale 1.0f
|
||||
|
||||
out float AO;
|
||||
|
||||
@@ -88,13 +89,7 @@ void main() {
|
||||
|
||||
vec3 origin = getVSPosition(originScreenCoord);
|
||||
|
||||
float radius;
|
||||
if(origin.z < uRadius){
|
||||
radius = origin.z;
|
||||
} else {
|
||||
radius = uRadius;
|
||||
}
|
||||
|
||||
float radius = min(origin.z, uRadius);
|
||||
|
||||
vec3 originNormal = getVSFaceNormal(origin);
|
||||
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
|
||||
layout (location = 0) in vec3 Position;
|
||||
|
||||
out VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(Position, 1.0);
|
||||
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
|
||||
}
|
||||
@@ -3,11 +3,15 @@
|
||||
layout (binding = 0) uniform sampler2D DepthBuffer;
|
||||
uniform vec3 ClipInfo;
|
||||
|
||||
in VertexData{
|
||||
vec2 TextureCoordinate;
|
||||
}Input;
|
||||
|
||||
out float depthLinear;
|
||||
//Just for Debug, should be depthLinear
|
||||
//out vec4 fragmentColor;
|
||||
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]);
|
||||
//float depthLinear = (NearClip) / ( -depthSample + 1.0f);
|
||||
//fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f);
|
||||
|
||||
@@ -32,6 +32,7 @@ void Client::Connect(std::string address, int port)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &Client::OnInputCommand);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &Client::OnPlayerDamage);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &Client::OnPlayerSpawned);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &Client::OnDoubleJump);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ESearchForServers, &Client::OnSearchForServers);
|
||||
auto config = ResourceManager::Load<ConfigFile>("Config.ini");
|
||||
m_Address = address;
|
||||
@@ -140,6 +141,9 @@ void Client::parseMessageType(Packet& packet)
|
||||
case MessageType::OnPlayerDamage:
|
||||
parsePlayerDamage(packet);
|
||||
break;
|
||||
case MessageType::OnDoubleJump:
|
||||
parseDoubleJump(packet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -272,6 +276,20 @@ void Client::parseComponentDeletion(Packet & packet)
|
||||
}
|
||||
}
|
||||
|
||||
void Client::parseDoubleJump(Packet & packet)
|
||||
{
|
||||
EntityID serverID = packet.ReadPrimitive<EntityID>();
|
||||
if (!serverClientMapsHasEntity(serverID)) {
|
||||
return;
|
||||
}
|
||||
Events::DoubleJump e;
|
||||
e.entityID = m_ServerIDToClientID.at(serverID);
|
||||
// If player is local player do not publish to prevent infinite feedback loop
|
||||
if (e.entityID != m_LocalPlayer.ID) {
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::updateFields(Packet& packet, const ComponentInfo& componentInfo, const EntityID& entityID)
|
||||
{
|
||||
for (auto field : componentInfo.FieldsInOrder) {
|
||||
@@ -348,9 +366,7 @@ void Client::parseSnapshot(Packet& packet)
|
||||
EntityWrapper localEntity(m_World, localEntityID);
|
||||
// Update entity
|
||||
if (m_World->HasComponent(localEntityID, componentType)) {
|
||||
if (localEntity.Name() == "CapturePointHUD") {
|
||||
UpdateLocalCapturePointHUD(localEntity);
|
||||
}
|
||||
// TODO Fix memory leak here
|
||||
SharedComponentWrapper newComponent = createSharedComponent(packet, localEntityID, componentInfo);
|
||||
bool shouldApply = true;
|
||||
// Apply potential filter function
|
||||
@@ -361,6 +377,7 @@ void Client::parseSnapshot(Packet& packet)
|
||||
ComponentWrapper currentComponent = m_World->GetComponent(localEntityID, componentType);
|
||||
memcpy(currentComponent.Data, newComponent.Data, componentInfo.Stride);
|
||||
}
|
||||
|
||||
//if (localEntity != m_LocalPlayer && !localEntity.IsChildOf(m_LocalPlayer)) {
|
||||
// updateFields(packet, componentInfo, localEntityID);
|
||||
//} else {
|
||||
@@ -377,7 +394,11 @@ void Client::parseSnapshot(Packet& packet)
|
||||
if (serverParentID == EntityID_Invalid) {
|
||||
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
|
||||
} else {
|
||||
newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID));
|
||||
if (serverClientMapsHasEntity(serverParentID)) {
|
||||
newLocalEntityID = m_World->CreateEntity(m_ServerIDToClientID.at(serverParentID));
|
||||
} else {
|
||||
newLocalEntityID = m_World->CreateEntity(EntityID_Invalid);
|
||||
}
|
||||
}
|
||||
m_World->SetName(newLocalEntityID, serverEntityName);
|
||||
insertIntoServerClientMaps(serverEntityID, newLocalEntityID);
|
||||
@@ -387,26 +408,16 @@ void Client::parseSnapshot(Packet& packet)
|
||||
}
|
||||
// Parent logic
|
||||
// This should be enough beacause we know that the entities arives in pre-order (there will always be a parent)
|
||||
if (serverParentID != EntityID_Invalid) {
|
||||
if (serverParentID != EntityID_Invalid && serverClientMapsHasEntity(serverParentID)) {
|
||||
EntityID localEntityID = m_ServerIDToClientID.at(serverEntityID);
|
||||
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID));
|
||||
if (m_World->GetParent(localEntityID) != m_ServerIDToClientID.at(serverParentID)) {
|
||||
m_World->SetParent(localEntityID, m_ServerIDToClientID.at(serverParentID));
|
||||
}
|
||||
}
|
||||
}
|
||||
parseSpawnEvents();
|
||||
}
|
||||
|
||||
|
||||
void Client::UpdateLocalCapturePointHUD(EntityWrapper capturePointHUD)
|
||||
{
|
||||
//auto children = m_World->GetChildren(capturePointHUD.ID);
|
||||
//for (auto it = children.first; it != children.second; it++) {
|
||||
// it->first
|
||||
//}
|
||||
//
|
||||
//EntityWrapper& localHUD = m_LocalPlayer.FirstChildByName("HUD").FirstChildByName("CapturePointHUD");
|
||||
//m_World->GetComponentPools()
|
||||
}
|
||||
|
||||
void Client::disconnect()
|
||||
{
|
||||
m_IsConnected = false;
|
||||
@@ -469,6 +480,11 @@ bool Client::OnPlayerDamage(const Events::PlayerDamage & e)
|
||||
if (e.Inflictor != m_LocalPlayer) {
|
||||
return false;
|
||||
}
|
||||
// Could this happen?
|
||||
//if (!clientServerMapsHasEntity(e.Inflictor.ID)
|
||||
// || !clientServerMapsHasEntity(e.Victim.ID)) {
|
||||
// return;
|
||||
//}
|
||||
|
||||
Packet packet(MessageType::OnPlayerDamage, m_SendPacketID);
|
||||
packet.WritePrimitive(m_ClientIDToServerID.at(e.Inflictor.ID));
|
||||
@@ -503,7 +519,7 @@ void Client::parsePlayerDamage(Packet& packet)
|
||||
Events::PlayerDamage e;
|
||||
PlayerID victimID = packet.ReadPrimitive<EntityID>();
|
||||
PlayerID inflictorID = packet.ReadPrimitive<EntityID>();
|
||||
if(!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)){
|
||||
if (!serverClientMapsHasEntity(victimID) || !serverClientMapsHasEntity(inflictorID)) {
|
||||
return;
|
||||
}
|
||||
e.Inflictor = EntityWrapper(m_World, m_ServerIDToClientID.at(victimID));
|
||||
@@ -515,6 +531,17 @@ void Client::parsePlayerDamage(Packet& packet)
|
||||
}
|
||||
}
|
||||
|
||||
bool Client::OnDoubleJump(Events::DoubleJump & e)
|
||||
{
|
||||
if (!clientServerMapsHasEntity(e.entityID) || e.entityID != m_LocalPlayer.ID) {
|
||||
return false;
|
||||
}
|
||||
Packet packet(MessageType::OnDoubleJump);
|
||||
packet.WritePrimitive(m_ClientIDToServerID.at(e.entityID));
|
||||
m_Reliable.Send(packet);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Client::sendLocalPlayerTransform()
|
||||
{
|
||||
if (!m_LocalPlayer.Valid()) {
|
||||
|
||||
@@ -29,9 +29,8 @@ Server::~Server()
|
||||
|
||||
void Server::Update()
|
||||
{
|
||||
PlayerDefinition pd;
|
||||
|
||||
m_Reliable.AcceptNewConnections(m_NextPlayerID, m_ConnectedPlayers);
|
||||
|
||||
for (auto& kv : m_ConnectedPlayers) {
|
||||
while (kv.second.TCPSocket->available()) {
|
||||
// Packet will get real data in receive
|
||||
@@ -47,6 +46,7 @@ void Server::Update()
|
||||
}
|
||||
}
|
||||
|
||||
PlayerDefinition pd;
|
||||
while (m_Unreliable.IsSocketAvailable()) {
|
||||
// Packet will get real data in receive
|
||||
Packet packet(MessageType::Invalid);
|
||||
@@ -65,7 +65,7 @@ void Server::Update()
|
||||
PlayerDefinition localArea;
|
||||
localArea.Endpoint = boost::asio::ip::udp::endpoint();
|
||||
m_ServerlistRequest.Receive(packet, localArea);
|
||||
if(packet.GetMessageType() == MessageType::ServerlistRequest) {
|
||||
if (packet.GetMessageType() == MessageType::ServerlistRequest) {
|
||||
packet.ReadPrimitive<int>(); // Pop size
|
||||
packet.ReadPrimitive<int>(); // Pop MsgType
|
||||
packet.ReadPrimitive<int>(); // Pop packet ID
|
||||
@@ -76,7 +76,7 @@ void Server::Update()
|
||||
}
|
||||
|
||||
// Check if players have disconnected
|
||||
for (int i = 0; i < m_PlayersToDisconnect.size(); i++) {
|
||||
for (int i = 0; i < m_PlayersToDisconnect.size(); i++) {
|
||||
disconnect(m_PlayersToDisconnect.at(i));
|
||||
}
|
||||
m_PlayersToDisconnect.clear();
|
||||
@@ -136,7 +136,10 @@ void Server::parseMessageType(Packet& packet)
|
||||
parseOnPlayerDamage(packet);
|
||||
break;
|
||||
case MessageType::PlayerTransform:
|
||||
parsePlayerTransform(packet);
|
||||
parsePlayerTransform(packet);
|
||||
break;
|
||||
case MessageType::OnDoubleJump:
|
||||
parseDoubleJump(packet);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -191,43 +194,41 @@ void Server::addPlayersToPacket(Packet & packet, EntityID entityID)
|
||||
// HACK: Only sync players for now, since the map turned out to be TOO LARGE to send in one snapshot and Simon's computer shits itself
|
||||
// HACK: Also checked CapturePointHUD for now. (this would get out of sync);
|
||||
EntityWrapper childEntity(m_World, childEntityID);
|
||||
if (!shouldSendToClient(childEntity)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Write EntityID and parentsID and Entity name
|
||||
packet.WritePrimitive(childEntityID);
|
||||
packet.WritePrimitive(entityID);
|
||||
packet.WriteString(m_World->GetName(childEntityID));
|
||||
// Write components to child
|
||||
int numberOfComponents = 0;
|
||||
for (auto& i : worldComponentPools) {
|
||||
if (i.second->KnowsEntity(childEntityID)) {
|
||||
numberOfComponents++;
|
||||
if (shouldSendToClient(childEntity)) {
|
||||
// Write EntityID and parentsID and Entity name
|
||||
packet.WritePrimitive(childEntityID);
|
||||
packet.WritePrimitive(entityID);
|
||||
packet.WriteString(m_World->GetName(childEntityID));
|
||||
// Write components to child
|
||||
int numberOfComponents = 0;
|
||||
for (auto& i : worldComponentPools) {
|
||||
if (i.second->KnowsEntity(childEntityID)) {
|
||||
numberOfComponents++;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Write how many components should be read
|
||||
packet.WritePrimitive(numberOfComponents);
|
||||
for (auto& i : worldComponentPools) {
|
||||
// If the entity exist in the pool
|
||||
if (i.second->KnowsEntity(childEntityID)) {
|
||||
ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID);
|
||||
// ComponentType
|
||||
packet.WriteString(componentWrapper.Info.Name);
|
||||
// Loop through fields
|
||||
for (auto& componentField : componentWrapper.Info.FieldsInOrder) {
|
||||
ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField);
|
||||
if (fieldInfo.Type == "string") {
|
||||
std::string& value = componentWrapper[componentField];
|
||||
packet.WriteString(value);
|
||||
} else {
|
||||
packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride);
|
||||
// Write how many components should be read
|
||||
packet.WritePrimitive(numberOfComponents);
|
||||
for (auto& i : worldComponentPools) {
|
||||
// If the entity exist in the pool
|
||||
if (i.second->KnowsEntity(childEntityID)) {
|
||||
ComponentWrapper componentWrapper = i.second->GetByEntity(childEntityID);
|
||||
// ComponentType
|
||||
packet.WriteString(componentWrapper.Info.Name);
|
||||
// Loop through fields
|
||||
for (auto& componentField : componentWrapper.Info.FieldsInOrder) {
|
||||
ComponentInfo::Field_t fieldInfo = componentWrapper.Info.Fields.at(componentField);
|
||||
if (fieldInfo.Type == "string") {
|
||||
std::string& value = componentWrapper[componentField];
|
||||
packet.WriteString(value);
|
||||
} else {
|
||||
packet.WriteData(componentWrapper.Data + fieldInfo.Offset, fieldInfo.Stride);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Go to to your children
|
||||
addChildrenToPacket(packet, childEntityID);
|
||||
addPlayersToPacket(packet, childEntityID);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -343,7 +344,7 @@ void Server::parseTCPConnect(Packet & packet)
|
||||
// Read packet ID
|
||||
m_PreviousPacketID = m_PacketID; // Set previous packet id
|
||||
m_PacketID = packet.ReadPrimitive<int>(); //Read new packet id
|
||||
|
||||
|
||||
LOG_INFO("Parsing connections");
|
||||
// Check if player is already connected
|
||||
// Ska vara till lagd i TCPServer receive
|
||||
@@ -455,8 +456,7 @@ bool Server::OnInputCommand(const Events::InputCommand & e)
|
||||
}
|
||||
isReadingData = !isReadingData;
|
||||
m_SaveDataTimer = std::clock();
|
||||
}
|
||||
else if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||
} else if (e.Command == "KickPlayer" && e.Value > 0) {
|
||||
kick(0);
|
||||
}
|
||||
|
||||
@@ -507,7 +507,7 @@ bool Server::OnPlayerDamage(const Events::PlayerDamage& e)
|
||||
packet.WritePrimitive(e.Damage);
|
||||
reliableBroadcast(packet);
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Server::parseClientPing()
|
||||
@@ -536,6 +536,12 @@ void Server::parsePing()
|
||||
}
|
||||
}
|
||||
|
||||
bool Server::parseDoubleJump(Packet & packet)
|
||||
{
|
||||
reliableBroadcast(packet);
|
||||
return true;
|
||||
}
|
||||
|
||||
void Server::parseOnInputCommand(Packet& packet)
|
||||
{
|
||||
PlayerID player = -1;
|
||||
@@ -595,8 +601,15 @@ void Server::parsePlayerTransform(Packet& packet)
|
||||
|
||||
bool Server::shouldSendToClient(EntityWrapper childEntity)
|
||||
{
|
||||
auto children = m_World->GetChildren(childEntity.ID);
|
||||
for (auto it = children.first; it != children.second; it++) {
|
||||
EntityWrapper child(m_World, it->second);
|
||||
if(child.HasComponent("CapturePoint")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return childEntity.HasComponent("Player") || childEntity.FirstParentWithComponent("Player").Valid()
|
||||
|| childEntity.HasComponent("CapturePoint") || childEntity.FirstParentWithComponent("CapturePoint").Valid();
|
||||
|| childEntity.HasComponent("CapturePoint");
|
||||
}
|
||||
|
||||
PlayerID Server::GetPlayerIDFromEndpoint()
|
||||
|
||||
@@ -4,6 +4,8 @@ using namespace boost::asio::ip;
|
||||
TCPServer::TCPServer()
|
||||
{
|
||||
acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666)));
|
||||
// Make the acceptor non-blocking so we wont get stuck in AcceptNewConnections().
|
||||
acceptor->non_blocking(true);
|
||||
m_Port = GetPort();
|
||||
m_Address = GetAddress();
|
||||
}
|
||||
@@ -13,14 +15,24 @@ TCPServer::~TCPServer()
|
||||
|
||||
void TCPServer::AcceptNewConnections(int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers)
|
||||
{
|
||||
boost::system::error_code error;
|
||||
boost::shared_ptr<tcp::socket> newSocket = boost::shared_ptr<tcp::socket>(new tcp::socket(m_IOService));
|
||||
m_IOService.poll();
|
||||
acceptor->async_accept(*newSocket,
|
||||
boost::bind(&TCPServer::handle_accept, this, newSocket, boost::ref(nextPlayerID), boost::ref(connectedPlayers),
|
||||
boost::asio::placeholders::error));
|
||||
acceptor->accept(*newSocket, error);
|
||||
// If no error occured add new tcp connection
|
||||
if (!error) {
|
||||
// Add tcp socket to connections
|
||||
boost::asio::ip::tcp::no_delay option(true);
|
||||
newSocket->set_option(option);
|
||||
PlayerDefinition pd;
|
||||
pd.StopTime = std::clock();
|
||||
pd.TCPSocket = newSocket;
|
||||
pd.TCPAddress = newSocket.get()->remote_endpoint().address();
|
||||
pd.TCPPort = newSocket.get()->remote_endpoint().port();
|
||||
connectedPlayers[nextPlayerID++] = pd;
|
||||
}
|
||||
}
|
||||
|
||||
PlayerID GetPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||
PlayerID TCPServer::getPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||
boost::asio::ip::address address, unsigned short port)
|
||||
{
|
||||
for (auto& kv : connectedPlayers) {
|
||||
@@ -32,24 +44,6 @@ PlayerID GetPlayerIDFromEndpoint(const std::map<PlayerID, PlayerDefinition>& con
|
||||
return -1;
|
||||
}
|
||||
|
||||
void TCPServer::handle_accept(boost::shared_ptr<tcp::socket> socket,
|
||||
int& nextPlayerID, std::map<PlayerID, PlayerDefinition>& connectedPlayers,
|
||||
const boost::system::error_code& error)
|
||||
{
|
||||
if (!error && GetPlayerIDFromEndpoint(connectedPlayers, socket->remote_endpoint().address(),
|
||||
socket->remote_endpoint().port()) == -1) {
|
||||
// Add tcp socket to connections
|
||||
boost::asio::ip::tcp::no_delay option(true);
|
||||
socket->set_option(option);
|
||||
PlayerDefinition pd;
|
||||
pd.StopTime = std::clock();
|
||||
pd.TCPSocket = socket;
|
||||
pd.TCPAddress = socket.get()->remote_endpoint().address();
|
||||
pd.TCPPort = socket.get()->remote_endpoint().port();
|
||||
connectedPlayers[nextPlayerID++] = pd;
|
||||
}
|
||||
}
|
||||
|
||||
void TCPServer::Send(Packet & packet, PlayerDefinition & playerDefinition)
|
||||
{
|
||||
packet.UpdateSize();
|
||||
|
||||
@@ -17,6 +17,7 @@ void CubeMapPass::LoadTextures(std::string input)
|
||||
m_CubeMapTextures.push_back(img);
|
||||
}
|
||||
GenerateCubeMapTexture();
|
||||
m_PreviusCubeMapTexture = input;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,42 @@
|
||||
#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");
|
||||
|
||||
InitializeTextures();
|
||||
InitializeBuffers();
|
||||
InitializeShaderPrograms();
|
||||
ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2));
|
||||
}
|
||||
|
||||
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()
|
||||
@@ -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);
|
||||
|
||||
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0)));
|
||||
m_GaussianFrameBuffer_horiz.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();
|
||||
|
||||
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)));
|
||||
m_GaussianFrameBuffer_vert.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();
|
||||
}
|
||||
|
||||
|
||||
void DrawBloomPass::ClearBuffer()
|
||||
{
|
||||
if (m_Quality == 0) {
|
||||
return;
|
||||
}
|
||||
GLERROR("PRE");
|
||||
m_GaussianFrameBuffer_horiz.Bind();
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
@@ -66,6 +96,9 @@ void DrawBloomPass::ClearBuffer()
|
||||
|
||||
void DrawBloomPass::Draw(GLuint texture)
|
||||
{
|
||||
if (m_Quality == 0) {
|
||||
return;
|
||||
}
|
||||
GLERROR("DrawBloomPass::Draw: Pre");
|
||||
|
||||
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
|
||||
, 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++) {
|
||||
for (int i = 1; i < m_Iterations; i++) {
|
||||
//Vertical pass
|
||||
m_GaussianFrameBuffer_vert.Bind();
|
||||
m_GaussianProgram_vert->Bind();
|
||||
@@ -125,6 +158,9 @@ void DrawBloomPass::Draw(GLuint texture)
|
||||
|
||||
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);
|
||||
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);
|
||||
@@ -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
|
||||
{
|
||||
glDeleteTextures(1, texture);
|
||||
glGenTextures(1, texture);
|
||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#include "Rendering/DrawFinalPass.h"
|
||||
|
||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass)
|
||||
: m_Renderer(renderer)
|
||||
, m_LightCullingPass(lightCullingPass)
|
||||
, m_CubeMapPass(cubeMapPass)
|
||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass)
|
||||
: m_Renderer(renderer)
|
||||
, m_LightCullingPass(lightCullingPass)
|
||||
, m_CubeMapPass(cubeMapPass)
|
||||
, m_SSAOPass(ssaoPass)
|
||||
{
|
||||
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
||||
m_ShieldPixelRate = 8;
|
||||
@@ -162,20 +162,20 @@ void DrawFinalPass::InitializeShaderPrograms()
|
||||
|
||||
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 FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||
// m_FillDepthBufferProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||
m_FillDepthBufferProgram->Compile();
|
||||
m_FillDepthBufferProgram->Link();
|
||||
GLERROR("Creating DepthFill program");
|
||||
|
||||
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 FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||
// m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
|
||||
m_FillDepthBufferSkinnedProgram->Compile();
|
||||
m_FillDepthBufferSkinnedProgram->Link();
|
||||
GLERROR("Creating DepthFill program");
|
||||
}
|
||||
|
||||
void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
|
||||
void DrawFinalPass::Draw(RenderScene& scene)
|
||||
{
|
||||
GLERROR("Pre");
|
||||
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
||||
@@ -191,10 +191,10 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
|
||||
//Fill depth buffer
|
||||
|
||||
state->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
GLERROR("OpaqueObjects");
|
||||
state->BlendFunc(GL_ONE, GL_ONE);
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||
GLERROR("TransparentObjects");
|
||||
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
DrawSprites(scene.Jobs.SpriteJob, scene);
|
||||
@@ -210,11 +210,11 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
|
||||
//Draw Opaque shielded objects
|
||||
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||
state->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
|
||||
GLERROR("Shielded Opaque object");
|
||||
|
||||
//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("END");
|
||||
@@ -250,9 +250,9 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture)
|
||||
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
||||
stateLowRes->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
GLERROR("OpaqueObjects");
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture);
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||
GLERROR("TransparentObjects");
|
||||
glViewport(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");
|
||||
}
|
||||
|
||||
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();
|
||||
GLERROR("forwardHandle");
|
||||
@@ -364,7 +364,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
glBindTexture(GL_TEXTURE_2D, SSAOTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture());
|
||||
|
||||
for (auto &job : jobs) {
|
||||
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||
@@ -383,7 +383,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
|
||||
glActiveTexture(GL_TEXTURE5);
|
||||
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;
|
||||
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
|
||||
@@ -401,7 +401,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
BindExplosionTextures(explosionHandle, explosionEffectJob);
|
||||
glActiveTexture(GL_TEXTURE5);
|
||||
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;
|
||||
@@ -463,7 +463,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
BindModelTextures(forwardSkinnedHandle, modelJob);
|
||||
glActiveTexture(GL_TEXTURE5);
|
||||
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;
|
||||
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)
|
||||
{
|
||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
GLERROR("Bind 1 uniform");
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||
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)
|
||||
{
|
||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||
GLERROR("Bind 1 uniform");
|
||||
GLint Location_M = glGetUniformLocation(shaderHandle, "M");
|
||||
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);
|
||||
Enable(GL_DEPTH_TEST);
|
||||
Enable(GL_CULL_FACE);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
Enable(GL_STENCIL_TEST);
|
||||
StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
|
||||
@@ -42,33 +42,33 @@ void FrameBuffer::Generate()
|
||||
GLERROR("PRE");
|
||||
|
||||
std::vector<GLenum> attachments;
|
||||
|
||||
glGenFramebuffers(1, &m_BufferHandle);
|
||||
if (m_BufferHandle == 0) {
|
||||
glGenFramebuffers(1, &m_BufferHandle);
|
||||
}
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_BufferHandle);
|
||||
GLERROR("1");
|
||||
|
||||
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
|
||||
switch ((*it)->m_ResourceType) {
|
||||
case GL_TEXTURE_2D:
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
|
||||
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
||||
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
|
||||
switch ((*it)->m_ResourceType) {
|
||||
case GL_TEXTURE_2D:
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
|
||||
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
|
||||
|
||||
break;
|
||||
case GL_RENDERBUFFER:
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
||||
break;
|
||||
}
|
||||
GLERROR("2");
|
||||
break;
|
||||
case GL_RENDERBUFFER:
|
||||
glFramebufferRenderbuffer(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle);
|
||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
||||
break;
|
||||
}
|
||||
GLERROR("2");
|
||||
|
||||
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);
|
||||
}
|
||||
GLERROR("Attachment");
|
||||
|
||||
}
|
||||
GLERROR("3");
|
||||
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);
|
||||
}
|
||||
GLERROR("Attachment");
|
||||
|
||||
}
|
||||
GLERROR("3");
|
||||
|
||||
GLenum* bufferTextures = &attachments[0];
|
||||
glDrawBuffers(attachments.size(), bufferTextures);
|
||||
|
||||
@@ -4,6 +4,8 @@ std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
|
||||
|
||||
void Renderer::Initialize()
|
||||
{
|
||||
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
|
||||
m_GLOW_Quality = m_Config->Get<int>("GLOW.Quality", 0);
|
||||
InitializeWindow();
|
||||
|
||||
InitializeRenderPasses();
|
||||
@@ -107,6 +109,7 @@ void Renderer::Update(double dt)
|
||||
void Renderer::Draw(RenderFrame& frame)
|
||||
{
|
||||
GLERROR("PRE");
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
|
||||
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
|
||||
if(m_CubeMapTexture == 0) {
|
||||
@@ -115,19 +118,16 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
m_CubeMapPass->LoadTextures("Sky");
|
||||
}
|
||||
|
||||
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);
|
||||
ImGui::SliderInt("SSAO Quality", &m_SSAO_Quality, 0, 3);
|
||||
ImGui::SliderInt("Glow Quality", &m_GLOW_Quality, 0, 3);
|
||||
m_SSAOPass->ChangeQuality(m_SSAO_Quality);
|
||||
m_DrawBloomPass->ChangeQuality(m_GLOW_Quality);
|
||||
GLERROR("SSAO Settings");
|
||||
//clear buffer 0
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
//Clear other buffers
|
||||
//Clear other buffers
|
||||
PerformanceTimer::StartTimer("Renderer-ClearBuffers");
|
||||
m_PickingPass->ClearPicking();
|
||||
m_DrawFinalPass->ClearBuffer();
|
||||
@@ -141,10 +141,10 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
GLERROR("Drawing pickingpass");
|
||||
PerformanceTimer::StopTimer("Renderer-Depth");
|
||||
}
|
||||
PerformanceTimer::StartTimer("AO generation");
|
||||
PerformanceTimer::StartTimer("Renderer-AO generation");
|
||||
m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera);
|
||||
GLuint ao = m_SSAOPass->SSAOTexture();
|
||||
PerformanceTimer::StopTimer("AO generation");
|
||||
PerformanceTimer::StopTimer("Renderer-AO generation");
|
||||
for (auto scene : frame.RenderScenes){
|
||||
|
||||
PerformanceTimer::StartTimer("Renderer-Drawing PickingPass");
|
||||
@@ -159,7 +159,7 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Light Culling");
|
||||
m_LightCullingPass->CullLights(*scene);
|
||||
GLERROR("LightCulling");
|
||||
m_DrawFinalPass->Draw(*scene, ao);
|
||||
m_DrawFinalPass->Draw(*scene);
|
||||
PerformanceTimer::StartTimerAndStopPrevious("Renderer-Draw Geometry+Light");
|
||||
GLERROR("Draw Geometry+Light");
|
||||
//m_DrawScenePass->Draw(*scene);
|
||||
@@ -248,9 +248,10 @@ void Renderer::InitializeRenderPasses()
|
||||
m_PickingPass = new PickingPass(this, m_EventBroker);
|
||||
m_LightCullingPass = new LightCullingPass(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_DrawBloomPass = new DrawBloomPass(this);
|
||||
m_DrawBloomPass = new DrawBloomPass(this, m_Config);
|
||||
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
|
||||
m_SSAOPass = new SSAOPass(this);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,50 +1,130 @@
|
||||
#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");
|
||||
|
||||
InitializeTexture();
|
||||
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();
|
||||
if (m_SSAOProgram->GetHandle() == 0) {
|
||||
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();
|
||||
if (m_SSAOViewSpaceZProgram->GetHandle() == 0) {
|
||||
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();
|
||||
}
|
||||
|
||||
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() {
|
||||
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_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_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_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()
|
||||
{
|
||||
m_SSAOFramBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0)));
|
||||
m_SSAOFramBuffer.Generate();
|
||||
if (m_SSAOFramBuffer.GetHandle() == 0) {
|
||||
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()
|
||||
{
|
||||
if (m_Quality == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_SSAOFramBuffer.Bind();
|
||||
glClearColor(1.f, 1.f, 1.f, 1.f);
|
||||
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);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
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_Bias = bias;
|
||||
m_Contrast = contrast;
|
||||
m_IntensityScale = intensityScale;
|
||||
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
|
||||
{
|
||||
glDeleteTextures(1, texture);
|
||||
glGenTextures(1, texture);
|
||||
glBindTexture(GL_TEXTURE_2D, *texture);
|
||||
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)
|
||||
{
|
||||
if (m_Quality == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
SSAOPassState state;
|
||||
GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle();
|
||||
GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle();
|
||||
@@ -98,6 +195,7 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
||||
(-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));
|
||||
|
||||
glBindVertexArray(m_ScreenQuad->VAO);
|
||||
@@ -107,9 +205,9 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
|
||||
|
||||
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])),
|
||||
(-2.0 / ((m_Renderer->GetViewportSize().Width >> m_TextureQuality) * camera->ProjectionMatrix()[0][0])),
|
||||
((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);
|
||||
|
||||
// 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, "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);;
|
||||
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);
|
||||
DrawBloomPassState BloomState;
|
||||
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() {
|
||||
m_DrawBloomPass->OnWindowResize();
|
||||
if (m_Quality == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
InitializeTexture();
|
||||
m_SSAOFramBuffer.Generate();
|
||||
m_SSAOViewSpaceZFramBuffer.Generate();
|
||||
}
|
||||
+1
-1
@@ -54,7 +54,7 @@ Game::Game(int argc, char* argv[])
|
||||
m_EventBroker = new EventBroker();
|
||||
|
||||
// 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->SetVSYNC(m_Config->Get<bool>("Video.VSYNC", false));
|
||||
m_Renderer->SetResolution(Rectangle::Rectangle(
|
||||
|
||||
@@ -29,6 +29,7 @@ void AmmoPickupSystem::Update(double dt)
|
||||
newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos;
|
||||
newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain;
|
||||
newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer;
|
||||
m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID);
|
||||
|
||||
//erase the current element (AmmoPickupPosition)
|
||||
m_ETriggerTouchVector.erase(it);
|
||||
@@ -69,8 +70,8 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
||||
|
||||
//copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
||||
//we need to copy all values since each value can be different for each ammoPickup
|
||||
m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["AmmoPickup"]["AmmoGain"],
|
||||
e.Trigger["AmmoPickup"]["RespawnTimer"],e.Trigger["AmmoPickup"]["RespawnTimer"] });
|
||||
m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"],
|
||||
e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
||||
|
||||
//delete the ammopickup
|
||||
m_World->DeleteEntity(e.Trigger.ID);
|
||||
|
||||
@@ -6,9 +6,11 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||
, PureSystem("CapturePoint")
|
||||
{
|
||||
//subscribe/listenTo playerdamage,healthpickup events (using the eventBroker)
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||
if (!IsClient) {
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +18,9 @@ CapturePointSystem::CapturePointSystem(SystemParams params)
|
||||
//NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt
|
||||
void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt)
|
||||
{
|
||||
if (IsClient) {
|
||||
return;
|
||||
}
|
||||
if (m_WinnerWasFound) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ void PickupSpawnSystem::Update(double dt)
|
||||
newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos;
|
||||
newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain;
|
||||
newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer;
|
||||
m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID);
|
||||
|
||||
//erase the current element (healthPickupPosition)
|
||||
m_ETriggerTouchVector.erase(it);
|
||||
@@ -58,7 +59,7 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e)
|
||||
//copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object)
|
||||
//we need to copy all values since each value can be different for each healthPickup
|
||||
m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["HealthPickup"]["HealthGain"],
|
||||
e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"] });
|
||||
e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) });
|
||||
|
||||
//delete the healthpickup
|
||||
m_World->DeleteEntity(e.Trigger.ID);
|
||||
|
||||
@@ -4,6 +4,7 @@ PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
|
||||
: System(params)
|
||||
{
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
|
||||
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
|
||||
}
|
||||
|
||||
PlayerMovementSystem::~PlayerMovementSystem()
|
||||
@@ -36,7 +37,6 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
if (!player.Valid()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Aim pitch
|
||||
EntityWrapper cameraEntity = player.FirstChildByName("Camera");
|
||||
if (cameraEntity.Valid()) {
|
||||
@@ -122,15 +122,14 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
|
||||
if (isOnGround) {
|
||||
controller->SetDoubleJumping(false);
|
||||
} else {
|
||||
// If IsServer and network is off this will not work
|
||||
if (IsClient) {
|
||||
//put a hexagon at the players feet
|
||||
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityFileParser parser(hexagonEffect);
|
||||
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||
hexagonEW["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
|
||||
spawnHexagon(player);
|
||||
controller->SetDoubleJumping(true);
|
||||
// Publish event for client to listen to
|
||||
Events::DoubleJump e;
|
||||
e.entityID = player.ID;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
}
|
||||
@@ -295,3 +294,26 @@ bool PlayerMovementSystem::OnPlayerSpawned(Events::PlayerSpawned& e)
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PlayerMovementSystem::OnDoubleJump(Events::DoubleJump & e)
|
||||
{
|
||||
// If entity does not exist, exit
|
||||
if (!EntityWrapper(m_World, e.entityID).Valid()) {
|
||||
return false;
|
||||
}
|
||||
// If entity IsLocalPlayer, exit
|
||||
if (e.entityID == m_LocalPlayer.ID) {
|
||||
return false;
|
||||
}
|
||||
spawnHexagon(EntityWrapper(m_World, e.entityID));
|
||||
}
|
||||
|
||||
void PlayerMovementSystem::spawnHexagon(EntityWrapper target)
|
||||
{
|
||||
//put a hexagon at the entitys... feet?
|
||||
auto hexagonEffect = ResourceManager::Load<EntityFile>("Schema/Entities/DoubleJumpHexagon.xml");
|
||||
EntityFileParser parser(hexagonEffect);
|
||||
EntityID hexagonEffectID = parser.MergeEntities(m_World);
|
||||
EntityWrapper hexagonEW = EntityWrapper(m_World, hexagonEffectID);
|
||||
hexagonEW["Transform"]["Position"] = (glm::vec3)target["Transform"]["Position"];
|
||||
}
|
||||
Reference in New Issue
Block a user