Compare commits

..

1 Commits

Author SHA1 Message Date
William Moberg bdcb33d992 Mouse always unlocked on game start and on disconnecting (i.e when menu shows). 2016-03-10 12:46:06 +01:00
47 changed files with 338 additions and 931 deletions
+1 -1
Submodule assets updated: 298641b1af...3af64d8b1f
+3 -9
View File
@@ -33,14 +33,12 @@ public:
if (m_Quality == 0) {
return m_BlackTexture->m_Texture;
} else {
return m_FinalGaussianTexture;
return m_GaussianTexture_vert;
}
}
private:
void GaussianLodPass(GLuint mipMap, GLuint texture);
void CombineGaussianBlur();
Texture* m_BlackTexture;
Model* m_ScreenQuad;
@@ -49,19 +47,15 @@ private:
//const LightCullingPass* m_LightCullingPass
int m_Iterations;
int m_Quality = 0;
int m_BloomLod = 5;
GLuint m_GaussianTexture_horiz = 0;
GLuint m_GaussianTexture_vert = 0;
GLuint m_FinalGaussianTexture = 0;
FrameBuffer* m_GaussianFrameBuffer_horiz = nullptr;
FrameBuffer* m_GaussianFrameBuffer_vert = nullptr;
FrameBuffer m_GaussianCombineBuffer;
FrameBuffer m_GaussianFrameBuffer_horiz;
FrameBuffer m_GaussianFrameBuffer_vert;
ShaderProgram* m_GaussianProgram_horiz;
ShaderProgram* m_GaussianProgram_vert;
ShaderProgram* m_GaussianCombineProgram;
};
@@ -1,19 +0,0 @@
#ifndef EResolutionChanged_h__
#define EResolutionChanged_h__
#include "../Core/Event.h"
#include "../Core/Util/Rectangle.h"
namespace Events
{
// Fired when the framebuffer size changes
struct ResolutionChanged : Event
{
Rectangle OldResolution;
Rectangle NewResolution;
};
}
#endif
+7 -8
View File
@@ -7,12 +7,11 @@
class BufferResource
{
public:
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod);
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment);
GLuint* m_ResourceHandle;
GLenum m_ResourceType;
GLenum m_Attachment;
GLuint m_MipMapLod = 0;
private:
};
@@ -21,15 +20,15 @@ template <GLenum RESOURCETYPE>
class ResourceType : public BufferResource
{
public:
ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod)
: BufferResource(resourceHandle, RESOURCETYPE, attachment, mipMapLod) { }
ResourceType(GLuint* resourceHandle, GLenum attachment)
: BufferResource(resourceHandle, RESOURCETYPE, attachment) { }
};
class Texture2D : public ResourceType<GL_TEXTURE_2D>
{
public:
Texture2D(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod = 0)
: ResourceType(resourceHandle, attachment, mipMapLod) { };
Texture2D(GLuint* resourceHandle, GLenum attachment)
: ResourceType(resourceHandle, attachment) { };
~Texture2D();
};
@@ -38,7 +37,7 @@ class RenderBuffer : public ResourceType<GL_RENDERBUFFER>
{
public:
RenderBuffer(GLuint* resourceHandle, GLenum attachment)
: ResourceType(resourceHandle, attachment, 0)
: ResourceType(resourceHandle, attachment)
{ };
~RenderBuffer();
@@ -48,7 +47,7 @@ class Texture2DArray : public ResourceType<GL_TEXTURE_2D_ARRAY>
{
public:
Texture2DArray(GLuint* resourceHandle, GLenum attachment)
: ResourceType(resourceHandle, attachment, 0)
: ResourceType(resourceHandle, attachment)
{ };
~Texture2DArray();
+3 -3
View File
@@ -54,7 +54,7 @@ private:
struct Frustum {
Plane Planes[4];
};
Frustum* m_Frustums = nullptr;
Frustum* m_Frustums;
//This should be a component
struct LightSource {
@@ -74,11 +74,11 @@ private:
glm::vec2 Padding = glm::vec2(1.f, 2.f);
};
LightGrid* m_LightGrid = nullptr;
LightGrid* m_LightGrid;
int m_LightOffset = 0;
float* m_LightIndex = nullptr;
float* m_LightIndex;
};
-3
View File
@@ -19,7 +19,6 @@
#include "../Core/Octree.h"
#include "../Collision/EntityAABB.h"
#include "../Core/ConfigFile.h"
#include "EResolutionChanged.h"
class RenderSystem : public ImpureSystem
{
@@ -37,8 +36,6 @@ private:
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
Octree<EntityAABB>* m_Octree;
EventRelay<RenderSystem, Events::ResolutionChanged> m_EResolutionChanged;
bool OnResolutionChanged(Events::ResolutionChanged &event);
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
bool OnSetCamera(Events::SetCamera &event);
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
+2 -8
View File
@@ -28,12 +28,10 @@
#include "Util/CommonFunctions.h"
#include "Core/PerformanceTimer.h"
#include "ShadowPass.h"
#include "EResolutionChanged.h"
class Renderer : public IRenderer
{
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
static void glfwWindowSizeCallback(GLFWwindow* window, int width, int height);
public:
Renderer(EventBroker* eventBroker, ConfigFile* config)
@@ -42,14 +40,13 @@ public:
{ }
~Renderer();
virtual void SetResolution(const Rectangle& resolution) override;
virtual void Initialize() override;
virtual void Update(double dt) override;
virtual void Draw(RenderFrame& frame) override;
virtual PickData Pick(glm::vec2 screenCoord) override;
private:
//----------------------Variables----------------------//
@@ -93,14 +90,11 @@ private:
void InputUpdate(double dt);
//void PickingPass(RenderQueueCollection& rq);
//void DrawScreenQuad(GLuint textureToDraw);
void setWindowSize(Rectangle size);
void updateFramebufferSize();
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
void SortRenderJobsByDepth(RenderScene &scene);
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
//--------------------ShaderPrograms-------------------//
//--------------------ShaderPrograms-------------------//
ShaderProgram* m_BasicForwardProgram;
ShaderProgram* m_ExplosionEffectProgram;
+2 -26
View File
@@ -21,14 +21,13 @@ struct SpriteJob : RenderJob
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator)
: RenderJob()
{
Model = ResourceManager::Load<::Model>((std::string)cSprite["Model"]);
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh");
::RawModel::MaterialProperties matProp = Model->MaterialGroups().front();
TextureID = 0;
DiffuseTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["DiffuseTexture"]);
IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]);
Linear = (bool)cSprite["Linear"];
IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]);
StartIndex = matProp.material->StartIndex;
EndIndex = matProp.material->EndIndex;
@@ -49,26 +48,6 @@ struct SpriteJob : RenderJob
FillColor = fillColor;
FillPercentage = fillPercentage;
glm::vec3 scale = Transform::AbsoluteScale(world, cSprite.EntityID);
if((bool)cSprite["KeepRatio"] == true) {
if(scale.y >= scale.x) {
ScaleY = (scale.x)/(scale.y);
ScaleX = 1.f;
} else {
ScaleY = 1.f;
ScaleX = (scale.x)/(scale.y);
}
} else {
if ((bool)cSprite["KeepRatioX"] == true) {
ScaleX = scale.x;
}
if ((bool)cSprite["KeepRatioY"] == true) {
ScaleY = scale.y;
}
}
};
unsigned int TextureID;
@@ -90,9 +69,6 @@ struct SpriteJob : RenderJob
bool Pickable;
bool IsIndicator = false;
bool BlurBackground = false;
float ScaleX = 1;
float ScaleY = 1;
bool Linear = false;
glm::vec4 FillColor = glm::vec4(0);
float FillPercentage = 0.0;
-4
View File
@@ -16,11 +16,7 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig
return false;
}
#ifdef DEBUG
#define GLERROR(function) \
_GLERROR(function, __BASE_FILE__, __func__, __LINE__)
#else
#define GLERROR(function) false
#endif
#endif
@@ -3,6 +3,7 @@
#include "Core/System.h"
#include "Input/EInputCommand.h"
#include "Network/EPlayerDisconnected.h"
class SpectatorCameraSystem : public ImpureSystem
{
@@ -17,6 +18,8 @@ private:
EventRelay<SpectatorCameraSystem, Events::InputCommand> m_EInputCommand;
bool OnInputCommand(const Events::InputCommand& e);
EventRelay<SpectatorCameraSystem, Events::PlayerDisconnected> m_EDisconnect;
bool OnDisconnect(const Events::PlayerDisconnected& e);
};
#endif
@@ -27,12 +27,9 @@ private:
std::random_device m_RandomDevice;
std::mt19937 m_RandomEngine;
// Weapon functions
void fireShell(ComponentWrapper cWeapon, WeaponInfo& wi);
void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, const std::vector<glm::vec2>& pattern);
void spawnTracers(ComponentWrapper cWeapon, WeaponInfo& wi, std::vector<glm::vec2> pattern);
void dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage);
bool canFire(ComponentWrapper cWeapon, WeaponInfo& wi);
// Utility
+2
View File
@@ -30,3 +30,5 @@ F2=PerformanceTimingResetAllTimers
F3=PerformanceTimingCreateExcelData
Comma=SwapToClassPick
Period=SwapToTeamPick
Enter=PickClass,1
F5=DisconnectFromServer
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Camera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Camera.xsd">
<FOV>59</FOV> <!-- 90 horizontal FOV at 1080p -->
<FOV>45</FOV>
<NearClip>0.01</NearClip>
<FarClip>5000</FarClip>
</Camera>
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DefenderWeapon xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DefenderWeapon.xsd">
<Slot><Primary/></Slot>
<MagazineAmmo>9999</MagazineAmmo>
<MagazineAmmo>8</MagazineAmmo>
<MagazineSize>8</MagazineSize>
<Ammo>64</Ammo>
<MaxAmmo>64</MaxAmmo>
<BaseDamage>90</BaseDamage>
<SpreadAngle>10</SpreadAngle>
<SpreadAngle>0.174533</SpreadAngle> <!-- 0.174533 = 10 degrees -->
<MaxTravelAngle>0.174533</MaxTravelAngle> <!-- 0.174533 = 10 degrees -->
<NumPellets>9</NumPellets>
<NumPellets>10</NumPellets>
<RPM>120</RPM>
<ViewPunch>0.03</ViewPunch>
<ViewReturnSpeed>0.2</ViewReturnSpeed>
@@ -36,7 +36,7 @@
<xs:annotation><xs:documentation>Damage dealt if all shotgun pellets hit</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="SpreadAngle" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>The spread angle radius.</xs:documentation></xs:annotation>
<xs:annotation><xs:documentation>Spread angle in radians</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="MaxTravelAngle" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Maximum vertical aim travel angle in radians</xs:documentation></xs:annotation>
+1 -1
View File
@@ -9,5 +9,5 @@
<SpecularMap>true</SpecularMap>
<GlowMap>true</GlowMap>
<Shadow>true</Shadow>
<GlowIntensity>1.0</GlowIntensity>
<GlowIntensity>3.0</GlowIntensity>
</Model>
-5
View File
@@ -1,14 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Sprite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Sprite.xsd">
<Model>Models/Core/UnitQuad.mesh</Model>
<DiffuseTexture></DiffuseTexture>
<GlowMap></GlowMap>
<Color R="1" G="1" B="1" A="1"/>
<Visible>true</Visible>
<DepthSort>true</DepthSort>
<KeepRatioX>false</KeepRatioX>
<KeepRatioY>false</KeepRatioY>
<KeepRatio>false</KeepRatio>
<Linear>false</Linear>
<BlurBackground>false</BlurBackground>
</Sprite>
+3 -18
View File
@@ -9,17 +9,14 @@
</xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="Model" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>The model the sprite will use.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="DiffuseTexture" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>Diffuse Texture file.</xs:documentation></xs:annotation>
<xs:annotation><xs:documentation>Diffuse Texture file</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="GlowMap" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>GlowMap file.</xs:documentation></xs:annotation>
<xs:annotation><xs:documentation>GlowMap file</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Color" type="t:Color" minOccurs="0">
<xs:annotation><xs:documentation>Color tint.</xs:documentation></xs:annotation>
<xs:annotation><xs:documentation>Color tint</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Visible" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
@@ -27,18 +24,6 @@
<xs:element name="DepthSort" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="KeepRatioX" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the sprite should repeat in x instead of stretch when scaled.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="KeepRatioY" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the sprite should repeat in y instead of stretch when scaled.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="KeepRatio" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Keep a 1:1 ratio between X and Y.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Linear" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>If it should use Linear or Nearest sampling method.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="BlurBackground" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the background should be blurred begind this sprite.</xs:documentation></xs:annotation>
</xs:element>
-94
View File
@@ -1,94 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform/>
</Components>
<Children>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Orientation X="0" Y="0.174532995" Z="0"/>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+23 -79
View File
@@ -1,95 +1,39 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Entity name="Shield" xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Transform>
<Position X="1.70262027" Y="0.261695802" Z="-3.26634645"/>
</c:Transform>
<c:Blend>
<Pose1>Deploy</Pose1>
<Pose2>Idle</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Model>
<Resource>Models/Characters/Defender/DefenderShield.mesh</Resource>
</c:Model>
<c:Transform/>
</Components>
<Children>
<Entity name="Back">
<Entity name="Deploy">
<Components>
<c:Blend>
<Pose1>Deploy</Pose1>
<Pose2>Idle</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Shielded/>
<c:Model>
<Resource>Models/Characters/Defender/DefenderShieldBack.mesh</Resource>
<Color A="0.219607845" B="3.92156863" G="1" R="1"/>
<Shadow>false</Shadow>
<Transparent>true</Transparent>
<NormalMap>false</NormalMap>
<DiffuseTexture>false</DiffuseTexture>
<SpecularMap>false</SpecularMap>
<GlowMap>false</GlowMap>
</c:Model>
<c:Animation>
<AnimationName>ActivateDeactiveShieldF</AnimationName>
<Time>1</Time>
<Speed>1</Speed>
</c:Animation>
<c:Transform/>
</Components>
<Children>
<Entity name="Deploy">
<Components>
<c:Animation>
<AnimationName>ActivateDeactiveShieldF</AnimationName>
<Play>true</Play>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>ShieldFrontF</AnimationName>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
<Children/>
</Entity>
<Entity name="Front">
<Entity name="Idle">
<Components>
<c:Blend>
<Pose1>Deploy</Pose1>
<Pose2>Idle</Pose2>
<Weight>0</Weight>
</c:Blend>
<c:Model>
<Resource>Models/Characters/Defender/DefenderShieldFront.mesh</Resource>
<Color A="0.219607845" B="3.92156863" G="1" R="1"/>
<Shadow>false</Shadow>
<Transparent>true</Transparent>
<NormalMap>false</NormalMap>
<DiffuseTexture>false</DiffuseTexture>
<SpecularMap>false</SpecularMap>
<GlowMap>false</GlowMap>
</c:Model>
<c:Animation>
<AnimationName>ShieldFrontF</AnimationName>
<Speed>1</Speed>
</c:Animation>
<c:Transform/>
</Components>
<Children>
<Entity name="Deploy">
<Components>
<c:Animation>
<AnimationName>ActivateDeactiveShieldF</AnimationName>
<Play>true</Play>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
<Entity name="Idle">
<Components>
<c:Animation>
<AnimationName>ShieldFrontF</AnimationName>
</c:Animation>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
<Children/>
</Entity>
</Children>
-27
View File
@@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Entity xmlns:c="components" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Types/Entity.xsd">
<Components>
<c:Lifetime>
<Lifetime>10</Lifetime>
</c:Lifetime>
<c:ExplosionEffect>
<Velocity X="2" Y="2.30000019" Z="0"/>
<ExplosionDuration>1</ExplosionDuration>
<Randomness>true</Randomness>
<ExponentialAccelaration>true</ExponentialAccelaration>
</c:ExplosionEffect>
<c:Model>
<Resource>Models/Core/UnitSphere.mesh</Resource>
<Color A="1" B="1" G="1" R="3.92156863"/>
<Shadow>false</Shadow>
<Transparent>true</Transparent>
</c:Model>
<c:Transform>
<Scale X="0.0500000007" Y="0.0500000007" Z="0.0500000007"/>
</c:Transform>
</Components>
<Children/>
</Entity>
+4 -96
View File
@@ -103,7 +103,7 @@
<Color A="1" B="1" G="0.254901975" R="0"/>
</c:Model>
<c:Transform>
<Position X="0.800000012" Y="0" Z="0"/>
<Position X="-0.600000024" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
@@ -116,7 +116,7 @@
<Color A="1" B="1" G="0.254901975" R="0"/>
</c:Model>
<c:Transform>
<Position X="-0.600000024" Y="0" Z="0.549540162"/>
<Position X="0.800000012" Y="0" Z="0"/>
</c:Transform>
</Components>
<Children/>
@@ -157,106 +157,14 @@
<Resource>Models/Weapons/Blue/DefenderWeaponBlue.mesh</Resource>
</c:Model>
<c:Transform>
<Orientation X="0" Y="-0" Z="0"/>
<Position X="0.00681143999" Y="-0.204994932" Z="-0.209244296"/>
<Orientation X="-0.581807375" Y="0.562133908" Z="-0.0719003305"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity>
<Components>
<c:Transform>
<Position X="0.870232701" Y="0.640069604" Z="4.07769537"/>
<Orientation X="0" Y="4.71238565" Z="0"/>
</c:Transform>
</Components>
<Children>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Orientation X="0" Y="0.174532995" Z="0"/>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="RayBlue">
<Components>
<c:Transform>
<Scale X="0" Y="1" Z="100"/>
</c:Transform>
</Components>
<Children>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="-1.57099998" Z="0"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
<Entity>
<Components>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Effects/Ray.png</DiffuseTexture>
<Color A="0.419607848" B="3.92156863" G="0.270588249" R="0"/>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="-0.5"/>
<Orientation X="0" Y="4.71218538" Z="3.14199996"/>
<Scale X="1" Y="0.0260000005" Z="0"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
</Children>
</Entity>
+73 -94
View File
@@ -8,7 +8,7 @@
</c:RaptorCopter>
<c:Transform>
<Position X="0" Y="-4" Z="0"/>
<Orientation X="0" Y="58.3794823" Z="0"/>
<Orientation X="0" Y="55.3495064" Z="0"/>
</c:Transform>
</Components>
@@ -34,49 +34,13 @@
</c:Transform>
</Components>
<Children>
<Entity name="AssaultClassPick">
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Icons/Classes/Assault-01.png</DiffuseTexture>
</c:Sprite>
<c:InputCmdButton>
<Command>PickClass</Command>
<PressValue>1</PressValue>
</c:InputCmdButton>
<c:Transform>
<Position X="-0.150000006" Y="-0.0500000007" Z="0"/>
<Scale X="0.0799999982" Y="0.0799999982" Z="1"/>
</c:Transform>
</Components>
<Children>
<Entity name="AssaultText">
<Components>
<c:Text>
<Content>Assault</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="0" G="1" R="0.784313738"/>
</c:Text>
<c:Transform>
<Position X="0" Y="0.800000012" Z="0"/>
<Scale X="0.310000002" Y="0.310000002" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="DefenderClassPick">
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Icons/Classes/Defender-01.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:InputCmdButton>
<Command>PickClass</Command>
@@ -108,10 +72,9 @@
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Icons/Classes/Sniper-01.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:InputCmdButton>
<Command>PickClass</Command>
@@ -139,6 +102,40 @@
</Entity>
</Children>
</Entity>
<Entity name="AssaultClassPick">
<Components>
<c:Button/>
<c:Sprite>
<DiffuseTexture>Textures/Icons/Classes/Assault-01.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:InputCmdButton>
<Command>PickClass</Command>
<PressValue>1</PressValue>
</c:InputCmdButton>
<c:Transform>
<Position X="-0.150000006" Y="-0.0500000007" Z="0"/>
<Scale X="0.0799999982" Y="0.0799999982" Z="1"/>
</c:Transform>
</Components>
<Children>
<Entity name="AssaultText">
<Components>
<c:Text>
<Content>Assault</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="0" G="1" R="0.784313738"/>
</c:Text>
<c:Transform>
<Position X="0" Y="0.800000012" Z="0"/>
<Scale X="0.310000002" Y="0.310000002" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="ClassPickText">
<Components>
<c:Text>
@@ -157,10 +154,9 @@
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite>
<c:InputCmdButton>
@@ -236,10 +232,9 @@
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite>
<c:InputCmdButton>
@@ -271,11 +266,10 @@
<Components>
<c:Button/>
<c:Sprite>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="1" B="0" G="0.294117659" R="0.980392158"/>
<Linear>true</Linear>
</c:Sprite>
<c:InputCmdButton>
<Command>PickTeam</Command>
@@ -306,12 +300,10 @@
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="1" B="0.980392158" G="0.294117659" R="0"/>
<Linear>true</Linear>
</c:Sprite>
<c:InputCmdButton>
<Command>PickTeam</Command>
@@ -342,10 +334,9 @@
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="1" B="0" G="1" R="0.509803951"/>
<Visible>false</Visible>
</c:Sprite>
@@ -431,10 +422,9 @@
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite>
<c:Transform>
@@ -451,10 +441,9 @@
<CapturePointNumber>3</CapturePointNumber>
</c:CapturePointHUD>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
@@ -469,10 +458,9 @@
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.699999988" B="1" G="0.200000003" R="0"/>
</c:Sprite>
<c:Transform>
@@ -489,10 +477,9 @@
<CapturePointNumber>4</CapturePointNumber>
</c:CapturePointHUD>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
@@ -507,10 +494,9 @@
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite>
<c:Transform>
@@ -527,10 +513,9 @@
<CapturePointNumber>2</CapturePointNumber>
</c:CapturePointHUD>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
@@ -545,10 +530,9 @@
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite>
<c:Transform>
@@ -566,10 +550,9 @@
<CapturePointNumber>1</CapturePointNumber>
</c:CapturePointHUD>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
@@ -584,10 +567,9 @@
<Entity name="BackgroundHexagon">
<Components>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="0.699999988" B="0" G="0" R="1"/>
</c:Sprite>
<c:Transform>
@@ -602,10 +584,9 @@
</c:Fill>
<c:CapturePointHUD/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/>
@@ -623,10 +604,9 @@
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite>
<c:InputCmdButton>
@@ -671,10 +651,9 @@
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
<Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite>
<c:InputCmdButton>
+1 -1
View File
@@ -3,7 +3,7 @@
<Components>
<c:Lifetime>
<Lifetime>10</Lifetime>
<Lifetime>0.10000000149011612</Lifetime>
</c:Lifetime>
<c:Transform>
<Scale X="0" Y="1" Z="1"/>
@@ -1,21 +0,0 @@
#version 430
layout (binding = 0) uniform sampler2D Texture;
uniform int MaxMipMap;
in VertexData{
vec2 TextureCoordinate;
}Input;
out vec4 fragmentColor;
void main()
{
vec4 result = vec4(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i < MaxMipMap; i++) {
result += textureLod(Texture, Input.TextureCoordinate, i);
}
fragmentColor = result;
}
@@ -1,13 +0,0 @@
#version 430
layout (location = 0) in vec3 Position;
out VertexData{
vec2 TextureCoordinate;
}Output;
void main()
{
gl_Position = vec4(Position, 1.0);
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
}
+1 -4
View File
@@ -2,7 +2,6 @@
#extension GL_EXT_gpu_shader4 : enable
layout (binding = 0) uniform sampler2D Texture;
uniform int Lod;
in VertexData{
vec2 TextureCoordinate;
@@ -11,14 +10,12 @@ in VertexData{
out vec4 fragmentColor;
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
//uniform float weight[3] = float[](0.265495, 0.226535, 0.140718);
void main()
{
vec2 tex_offset = 1.0 / textureSize(Texture, Lod);
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
vec3 result = center * weight[0];
for(int i = 1; i < 5; ++i) {
vec4 eastFragments = texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0));
vec4 westFragments = texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0));
+1 -4
View File
@@ -2,7 +2,6 @@
#extension GL_EXT_gpu_shader4 : enable
layout (binding = 0) uniform sampler2D Texture;
uniform int Lod;
in VertexData{
vec2 TextureCoordinate;
@@ -11,14 +10,12 @@ in VertexData{
out vec4 fragmentColor;
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
//uniform float weight[3] = float[](0.265495, 0.226535, 0.140718);
void main()
{
vec2 tex_offset = 1.0 / textureSize(Texture, Lod);
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0);
vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
vec3 result = center * weight[0];
for(int i = 1; i < 5; ++i) {
vec4 northFragments = texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i));
vec4 southFragments = texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i));
+5 -8
View File
@@ -3,8 +3,6 @@
uniform vec4 Color;
uniform vec4 FillColor;
uniform float FillPercentage;
uniform float ScaleX;
uniform float ScaleY;
uniform mat4 P;
layout (binding = 1) uniform sampler2D DiffuseTexture;
@@ -23,16 +21,15 @@ out vec4 bloomColor;
void main()
{
vec4 diffuseTexel = texture2D(DiffuseTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
vec4 glowTexel = texture2D(GlowMapTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate);
vec4 color_result = Color * diffuseTexel;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
float fillResult = floor(pos*FillPercentage);
color_result = FillColor*diffuseTexel.a*fillResult + color_result*(1-fillResult);
if(pos <= FillPercentage) {
color_result = FillColor*diffuseTexel.a;
}
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0);
+1 -13
View File
@@ -27,7 +27,7 @@ void EntityWrapper::AttachComponent(const char* componentName)
EntityWrapper EntityWrapper::Parent()
{
if (!Valid()) {
if (this->World == nullptr || this->ID == EntityID_Invalid) {
return EntityWrapper::Invalid;
} else {
return EntityWrapper(this->World, this->World->GetParent(this->ID));
@@ -36,10 +36,6 @@ EntityWrapper EntityWrapper::Parent()
EntityWrapper EntityWrapper::FirstParentByName(const std::string& parentEntityName)
{
if (!Valid()) {
return EntityWrapper::Invalid;
}
EntityWrapper entity = *this;
while (entity.Parent().Valid()) {
entity = entity.Parent();
@@ -52,10 +48,6 @@ EntityWrapper EntityWrapper::FirstParentByName(const std::string& parentEntityNa
EntityWrapper EntityWrapper::FirstChildByName(const std::string& name)
{
if (!Valid()) {
return EntityWrapper::Invalid;
}
return firstChildByNameRecursive(name, this->ID);
}
@@ -86,10 +78,6 @@ EntityWrapper EntityWrapper::FirstLevelChildByName(const std::string& name)
EntityWrapper EntityWrapper::FirstParentWithComponent(const std::string& componentType)
{
if (!Valid()) {
return EntityWrapper::Invalid;
}
EntityWrapper entity = *this;
while (entity.Parent().Valid()) {
entity = entity.Parent();
+1 -1
View File
@@ -86,7 +86,7 @@ bool EditorRenderSystem::OnSetCamera(Events::SetCamera& e)
{
ComponentWrapper cTransform = e.CameraEntity["Transform"];
ComponentWrapper cCamera = e.CameraEntity["Camera"];
m_EditorCamera->SetFOV(glm::radians(static_cast<float>((double)cCamera["FOV"])));
m_EditorCamera->SetFOV(static_cast<float>((double)cCamera["FOV"]));
m_EditorCamera->SetNearClip(static_cast<float>((double)cCamera["NearClip"]));
m_EditorCamera->SetFarClip(static_cast<float>((double)cCamera["FarClip"]));
m_EditorCamera->SetPosition(cTransform["Position"]);
+1
View File
@@ -47,6 +47,7 @@ EditorSystem::EditorSystem(SystemParams params, IRenderer* renderer, RenderFrame
Enable();
} else {
Disable();
m_EventBroker->Publish(Events::UnlockMouse());
}
}
+6 -1
View File
@@ -1,4 +1,5 @@
#include "Network/Client.h"
#include "Network/EPlayerDisconnected.h"
using namespace boost::asio::ip;
Client::Client(World* world, EventBroker* eventBroker)
@@ -224,7 +225,7 @@ void Client::parseServerlist(Packet& packet)
void Client::parseKick()
{
LOG_WARNING("You have been kicked from the server.");
m_IsConnected = false;
disconnect();
}
void Client::parseSpawnEvents()
@@ -464,6 +465,10 @@ void Client::disconnect()
Packet packet(MessageType::Disconnect, m_SendPacketID);
m_Reliable.Send(packet);
m_Reliable.Disconnect();
Events::PlayerDisconnected e;
e.Entity = m_LocalPlayer.ID;
e.PlayerID = -1;
m_EventBroker->Publish(e);
createMainMenu();
}
+3 -7
View File
@@ -97,14 +97,14 @@ void BlurHUD::ClearBuffer()
glClearStencil(0x00);
glStencilMask(~0);
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_GaussianFrameBuffer_horiz.Unbind();
m_GaussianFrameBuffer_vert.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClearStencil(0x00);
glStencilMask(~0);
glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
m_GaussianFrameBuffer_vert.Unbind();
m_CombinedTextureBuffer.Bind();
@@ -211,16 +211,12 @@ void BlurHUD::FillStencil(RenderScene& scene)
RenderState state;
state.BindFramebuffer(m_GaussianFrameBuffer_horiz.GetHandle());
state.Enable(GL_DEPTH_TEST);
state.Disable(GL_DEPTH_TEST);
state.Enable(GL_CULL_FACE);
state.Enable(GL_STENCIL_TEST);
state.StencilFunc(GL_ALWAYS, 1, 0xFF);
state.StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
state.StencilMask(0xFF);
state.AlphaFunc(GL_GEQUAL, 0.95f);
state.Enable(GL_ALPHA_TEST);
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_BlurQuality, m_Renderer->GetViewportSize().Height/m_BlurQuality);
m_FillDepthStencilProgram->Bind();
+48 -119
View File
@@ -12,7 +12,6 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
DrawBloomPass::~DrawBloomPass() {
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
CommonFunctions::DeleteTexture(&m_FinalGaussianTexture);
}
void DrawBloomPass::InitializeTextures()
@@ -31,8 +30,9 @@ void DrawBloomPass::ChangeQuality(int quality)
if (m_Quality == 0) {
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
CommonFunctions::DeleteTexture(&m_FinalGaussianTexture);
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
m_GaussianTexture_horiz = 0;
m_GaussianTexture_vert = 0;
return;
}
InitializeTextures();
@@ -62,50 +62,22 @@ void DrawBloomPass::InitializeShaderPrograms()
m_GaussianProgram_vert->BindFragDataLocation(0, "fragmentColor");
m_GaussianProgram_vert->Link();
}
m_GaussianCombineProgram = ResourceManager::Load<ShaderProgram>("#GaussianCombineProgram");
if (m_GaussianCombineProgram->GetHandle() == 0) {
m_GaussianCombineProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/CombineGaussianTexture.vert.glsl")));
m_GaussianCombineProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/CombineGaussianTexture.frag.glsl")));
m_GaussianCombineProgram->Compile();
m_GaussianCombineProgram->BindFragDataLocation(0, "fragmentColor");
m_GaussianCombineProgram->Link();
}
}
void DrawBloomPass::InitializeBuffers()
{
CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
CommonFunctions::GenerateTexture(&m_FinalGaussianTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
CommonFunctions::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);
if (m_GaussianCombineBuffer.GetHandle() == 0) {
m_GaussianCombineBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_FinalGaussianTexture, GL_COLOR_ATTACHMENT0)));
}
m_GaussianCombineBuffer.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_horiz == nullptr) {
m_GaussianFrameBuffer_horiz = new FrameBuffer[m_BloomLod];
}
if (m_GaussianFrameBuffer_vert == nullptr) {
m_GaussianFrameBuffer_vert = new FrameBuffer[m_BloomLod];
}
for (int i = 0; i < m_BloomLod; i++) {
if(m_GaussianFrameBuffer_horiz[i].GetHandle() == 0) {
m_GaussianFrameBuffer_horiz[i].AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0, i)));
}
m_GaussianFrameBuffer_horiz[i].Generate();
if (m_GaussianFrameBuffer_vert[i].GetHandle() == 0) {
m_GaussianFrameBuffer_vert[i].AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0, i)));
}
m_GaussianFrameBuffer_vert[i].Generate();
}
CommonFunctions::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);
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();
}
@@ -115,75 +87,33 @@ void DrawBloomPass::ClearBuffer()
return;
}
GLERROR("PRE");
for (int i = 0; i < m_BloomLod; i++) {
m_GaussianFrameBuffer_horiz[i].Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_horiz[i].Unbind();
m_GaussianFrameBuffer_vert[i].Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_vert[i].Unbind();
}
m_GaussianCombineBuffer.Bind();
m_GaussianFrameBuffer_horiz.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianCombineBuffer.Unbind();
m_GaussianFrameBuffer_horiz.Unbind();
m_GaussianFrameBuffer_vert.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_vert.Unbind();
GLERROR("END");
}
void DrawBloomPass::Draw(GLuint texture)
{
if (m_Quality == 0) {
return;
}
for (int i = 0; i < m_BloomLod; i++) {
GaussianLodPass(i, texture);
}
CombineGaussianBlur();
}
void DrawBloomPass::OnWindowResize()
{
if (m_Quality == 0) {
return;
}
CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
for (int i = 0; i < m_BloomLod; i++) {
m_GaussianFrameBuffer_vert[i].Generate();
m_GaussianFrameBuffer_horiz[i].Generate();
}
}
void DrawBloomPass::GaussianLodPass(GLuint mipMap, GLuint texture)
{
GLERROR("DrawBloomPass::Draw: Pre");
glViewport(0, 0, m_Renderer->GetViewportSize().Width/(glm::pow(2, mipMap)), m_Renderer->GetViewportSize().Height/(glm::pow(2, mipMap)));
DrawBloomPassState state;
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
m_GaussianProgram_vert->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_vert, "Lod"), mipMap);
m_GaussianProgram_horiz->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_horiz, "Lod"), mipMap);
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
m_GaussianFrameBuffer_horiz[mipMap].Bind();
m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture);
glBindVertexArray(m_ScreenQuad->VAO);
@@ -193,56 +123,55 @@ void DrawBloomPass::GaussianLodPass(GLuint mipMap, GLuint texture)
//Iterate some times to make it more gaussian.
for (int i = 1; i < m_Iterations; i++) {
//Vertical pass
m_GaussianFrameBuffer_vert[mipMap].Bind();
m_GaussianFrameBuffer_vert.Bind();
m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE0);
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_vert[mipMap].Unbind();
m_GaussianFrameBuffer_vert.Unbind();
m_GaussianFrameBuffer_horiz[mipMap].Bind();
m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE0);
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);
m_GaussianFrameBuffer_horiz[mipMap].Unbind();
m_GaussianFrameBuffer_horiz.Unbind();
}
//final vertical gaussian after the iterations are done
m_GaussianFrameBuffer_vert[mipMap].Bind();
m_GaussianFrameBuffer_vert.Bind();
m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
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);
GLERROR("DrawBloomPass::Draw: END");
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
m_GaussianFrameBuffer_vert[mipMap].Unbind();
}
void DrawBloomPass::CombineGaussianBlur()
{
m_GaussianCombineBuffer.Bind();
m_GaussianCombineProgram->Bind();
glUniform1i(glGetUniformLocation(m_GaussianCombineProgram->GetHandle(), "MaxMipMap"), m_BloomLod);
glActiveTexture(GL_TEXTURE0);
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);
GLERROR("DrawBloomPass::Draw: END");
}
void DrawBloomPass::OnWindowResize()
{
if (m_Quality == 0) {
return;
}
CommonFunctions::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();
CommonFunctions::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.Generate();
}
+7 -21
View File
@@ -32,9 +32,9 @@ void DrawFinalPass::InitializeTextures()
void DrawFinalPass::InitializeFrameBuffers()
{
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
CommonFunctions::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);
CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
CommonFunctions::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);
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
@@ -311,8 +311,6 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
GLERROR("TransparentObjects");
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
stateSprite->Enable(GL_DEPTH_TEST);
//stateSprite->AlphaFunc(GL_GEQUAL, 0.05f);
//stateSprite->Enable(GL_ALPHA_TEST);
DrawSprites(scene.Jobs.SpriteJob, scene);
GLERROR("SpriteJobs");
@@ -345,8 +343,8 @@ void DrawFinalPass::OnWindowResize()
//InitializeFrameBuffers();
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
CommonFunctions::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);
CommonFunctions::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);
m_FinalPassFrameBuffer.Generate();
GLERROR("Error changing texture resolutions");
@@ -1232,7 +1230,7 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
} else {
frameBones = modelJob->Skeleton->GetTPose();
}
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else {
if (lastShader != m_FillDepthStencilBufferProgram->GetHandle()) {
@@ -1271,34 +1269,23 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
RenderState* jobState = new RenderState();
for(auto& job : jobs) {
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
RenderState jobState;
if (spriteJob) {
if(spriteJob->Depth == 0) {
jobState->Disable(GL_DEPTH_TEST);
jobState.Disable(GL_DEPTH_TEST);
}
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
glUniform1f(glGetUniformLocation(shaderHandle, "ScaleX"), spriteJob->ScaleX);
glUniform1f(glGetUniformLocation(shaderHandle, "ScaleY"), spriteJob->ScaleY);
glActiveTexture(GL_TEXTURE1);
if (spriteJob->DiffuseTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
if (spriteJob->Linear) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
} else {
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
}
@@ -1316,7 +1303,6 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int)));
}
}
delete jobState;
// m_SpriteProgram->Unbind();
}
+2 -3
View File
@@ -2,12 +2,11 @@
#include "Rendering/FrameBuffer.h"
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod)
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment)
{
m_ResourceHandle = resourceHandle;
m_ResourceType = resourceType;
m_Attachment = attachment;
m_MipMapLod = mipMapLod;
}
Texture2D::~Texture2D()
@@ -59,7 +58,7 @@ void FrameBuffer::Generate()
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
switch ((*it)->m_ResourceType) {
case GL_TEXTURE_2D:
glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, (*it)->m_MipMapLod);
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0);
GLERROR("FrameBuffer generate: glFramebufferTexture2D");
break;
case GL_RENDERBUFFER:
@@ -42,15 +42,6 @@ void LightCullingPass::SetSSBOSizes()
{
m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE);
if (m_Frustums != nullptr) {
delete[] m_Frustums;
}
if (m_LightGrid != nullptr) {
delete[] m_LightGrid;
}
if (m_LightIndex != nullptr) {
delete[] m_LightIndex;
}
m_Frustums = new Frustum[m_NumberOfTiles];
m_LightGrid = new LightGrid[m_NumberOfTiles];
m_LightIndex = new float[m_NumberOfTiles*MAX_LIGHTS_PER_TILE];
+1 -1
View File
@@ -24,7 +24,7 @@ void PickingPass::InitializeTextures()
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
}
void PickingPass::InitializeFrameBuffers()
+2 -10
View File
@@ -9,11 +9,10 @@ RenderSystem::RenderSystem(SystemParams params, const IRenderer* renderer, Rende
, m_Octree(frustumCullOctree)
{
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
EVENT_SUBSCRIBE_MEMBER(m_EResolutionChanged, &RenderSystem::OnResolutionChanged);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned);
m_Camera = new Camera((float)m_Renderer->GetViewportSize().Width / m_Renderer->GetViewportSize().Height, glm::radians(45.f), 0.01f, 5000.f);
m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f);
}
RenderSystem::~RenderSystem()
@@ -21,18 +20,11 @@ RenderSystem::~RenderSystem()
delete m_Camera;
}
bool RenderSystem::OnResolutionChanged(Events::ResolutionChanged& e)
{
// Update camera aspect ration on resolution change
m_Camera->SetAspectRatio((float)e.NewResolution.Width / e.NewResolution.Height);
return true;
}
bool RenderSystem::OnSetCamera(Events::SetCamera& e)
{
ComponentWrapper cTransform = e.CameraEntity["Transform"];
ComponentWrapper cCamera = e.CameraEntity["Camera"];
m_Camera->SetFOV(glm::radians((double)cCamera["FOV"]));
m_Camera->SetFOV((double)cCamera["FOV"]);
m_Camera->SetNearClip((double)cCamera["NearClip"]);
m_Camera->SetFarClip((double)cCamera["FarClip"]);
m_Camera->SetPosition(cTransform["Position"]);
+8 -43
View File
@@ -36,24 +36,16 @@ void Renderer::Initialize()
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
}
void Renderer::glfwWindowSizeCallback(GLFWwindow* window, int width, int height)
{
m_WindowToRenderer[window]->setWindowSize(Rectangle(width, height));
}
void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height)
{
m_WindowToRenderer[window]->updateFramebufferSize();
}
void Renderer::SetResolution(const Rectangle& resolution)
{
m_Resolution = resolution;
if (m_Window != nullptr) {
setWindowSize(resolution);
updateFramebufferSize();
}
glViewport(0, 0, width, height);
Renderer* currentRenderer = m_WindowToRenderer[window];
currentRenderer->m_ViewportSize = Rectangle(width, height);
currentRenderer->m_PickingPass->OnWindowResize();
currentRenderer->m_DrawFinalPass->OnWindowResize();
currentRenderer->m_LightCullingPass->OnWindowResize();
currentRenderer->m_DrawBloomPass->OnWindowResize();
currentRenderer->m_SSAOPass->OnWindowResize();
}
void Renderer::InitializeWindow()
@@ -75,7 +67,6 @@ void Renderer::InitializeWindow()
LOG_ERROR("GLFW: Failed to create window");
exit(EXIT_FAILURE);
}
glfwSetWindowSizeCallback(m_Window, &glfwWindowSizeCallback);
glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback);
glfwMakeContextCurrent(m_Window);
@@ -120,31 +111,6 @@ void Renderer::InputUpdate(double dt)
}
void Renderer::setWindowSize(Rectangle size)
{
m_Resolution = size;
glfwSetWindowSize(m_Window, size.Width, size.Height);
}
void Renderer::updateFramebufferSize()
{
Events::ResolutionChanged e;
e.OldResolution = m_ViewportSize;
int width, height;
glfwGetFramebufferSize(m_Window, &width, &height);
glViewport(0, 0, width, height);
m_ViewportSize = Rectangle(width, height);
m_PickingPass->OnWindowResize();
m_DrawFinalPass->OnWindowResize();
m_LightCullingPass->OnWindowResize();
m_DrawBloomPass->OnWindowResize();
m_SSAOPass->OnWindowResize();
e.NewResolution = m_ViewportSize;
m_EventBroker->Publish(e);
}
void Renderer::Update(double dt)
{
m_EventBroker->Process<Renderer>();
@@ -297,7 +263,6 @@ void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin
GLERROR("Texture initialization failed");
}
void Renderer::InitializeRenderPasses()
{
m_PickingPass = new PickingPass(this, m_EventBroker);
+6 -6
View File
@@ -233,11 +233,6 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
m_GaussianProgram_vert->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_vert, "Lod"), 0);
m_GaussianProgram_horiz->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_horiz, "Lod"), 0);
m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind();
@@ -257,6 +252,8 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_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
@@ -268,6 +265,8 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_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);
m_GaussianFrameBuffer_horiz.Unbind();
@@ -280,7 +279,8 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_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);
+3 -3
View File
@@ -3,9 +3,9 @@
TextureSprite::TextureSprite(std::string path)
:Texture(path)
{
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
GLERROR("Texture load");
}
@@ -25,12 +25,10 @@ void CommonFunctions::GenerateMultiSampleTexture(GLuint* texture, int numSamples
void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps)
{
glDeleteTextures(1, texture);
glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture);
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
//glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, NULL);
GLERROR("MipMap Texture glTexSubImage2D failed");
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture);
glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
@@ -36,6 +36,10 @@ ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer*
unsigned char pdata[3];
glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata);
GLERROR("glReadPixels(pdata) Error");
PickDataBuffer->Unbind();
GLERROR("Unbind Error");
glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer);
GLERROR("glBindFramebuffer(DepthBuffer) Error");
float depthData;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData);
GLERROR("glReadPixels(depthData) Error");
@@ -8,6 +8,7 @@ SpectatorCameraSystem::SpectatorCameraSystem(SystemParams params)
, m_PickedTeam(-1)
{
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &SpectatorCameraSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EDisconnect, &SpectatorCameraSystem::OnDisconnect);
}
void SpectatorCameraSystem::Update(double dt)
@@ -88,3 +89,16 @@ bool SpectatorCameraSystem::OnInputCommand(const Events::InputCommand& e)
return true;
}
bool SpectatorCameraSystem::OnDisconnect(const Events::PlayerDisconnected& e)
{
// If local player gets disconnected, they should be set to
// the spectator camera next time a map loads that has one.
if (e.Entity == LocalPlayer.ID) {
m_CamSetToTeamPick = false;
// They will also be set to menu, so unlock mouse just in case they were in game with locked mouse.
Events::UnlockMouse unlock;
m_EventBroker->Publish(unlock);
}
return true;
}
@@ -190,50 +190,60 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi
magAmmo -= 1;
}
// We can't really do any valuable calculations without a valid camera
if (!m_CurrentCamera.Valid()) {
return;
}
int numPellets = cWeapon["NumPellets"];
float spreadAngle = cWeapon["SpreadAngle"];
std::uniform_real_distribution<float> randomSpreadAngle(-spreadAngle, spreadAngle);
// Create a spread pattern
std::vector<glm::vec2> pattern;
// The first pellet is always centered
pattern.push_back(glm::vec2(0, 0));
// Any additional pellets form circles around the middle
int numOuterPellets = numPellets - 1;
float angleIncrement = glm::two_pi<float>() / numOuterPellets;
for (int i = 0; i < numOuterPellets; ++i) {
float angle = angleIncrement * i;
glm::vec2 pellet = glm::vec2(glm::cos(angle), glm::sin(angle));
pattern.push_back(pellet);
// Calculate pellet angles
// HACK: Random for now?
// TODO: Make distribution even for each quadrant
std::vector<glm::vec2> pelletAngles;
for (int i = 0; i < numPellets; i++) {
pelletAngles.push_back(glm::vec2(randomSpreadAngle(m_RandomEngine), randomSpreadAngle(m_RandomEngine)));
}
// Deal damage (clientside)
dealDamage(cWeapon, wi, pattern);
// Spawn tracers
spawnTracers(cWeapon, wi, pattern);
double pelletDamage = (double)cWeapon["BaseDamage"] / numPellets;
// View punch
//if (IsClient) {
// EntityWrapper camera = wi.Player.FirstChildByName("Camera");
// if (camera.Valid()) {
// glm::vec3& cameraOrientation = camera["Transform"]["Orientation"];
// float viewPunch = cWeapon["ViewPunch"];
// float maxTravelAngle = cWeapon["MaxTravelAngle"];
// float& currentTravel = cWeapon["CurrentTravel"];
// if (currentTravel < maxTravelAngle) {
// float change = viewPunch;
// if (currentTravel + change > maxTravelAngle) {
// change = maxTravelAngle - currentTravel;
// }
// cameraOrientation.x += change;
// currentTravel += change;
// }
// }
//}
if (IsClient) {
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
if (camera.Valid()) {
glm::vec3& cameraOrientation = camera["Transform"]["Orientation"];
float viewPunch = cWeapon["ViewPunch"];
float maxTravelAngle = cWeapon["MaxTravelAngle"];
float& currentTravel = cWeapon["CurrentTravel"];
if (currentTravel < maxTravelAngle) {
float change = viewPunch;
if (currentTravel + change > maxTravelAngle) {
change = maxTravelAngle - currentTravel;
}
cameraOrientation.x += change;
currentTravel += change;
}
}
}
// Tracers
EntityWrapper weaponModelEntity;
if (wi.Player == LocalPlayer) {
weaponModelEntity = wi.FirstPersonEntity;
} else {
weaponModelEntity = wi.ThirdPersonEntity;
}
if (weaponModelEntity.Valid()) {
EntityWrapper spawner = weaponModelEntity.FirstChildByName("WeaponMuzzle");
for (auto& angles : pelletAngles) {
glm::vec3 direction = Transform::AbsoluteOrientation(spawner) * glm::quat(glm::vec3(angles, 0.f)) * glm::vec3(0, 0, -1);
float distance = traceRayDistance(Transform::AbsolutePosition(spawner), direction);
EntityWrapper ray = SpawnerSystem::Spawn(spawner);
((glm::vec3&)ray["Transform"]["Scale"]).z = (distance / 100.f);
glm::vec3& orientation = ray["Transform"]["Orientation"];
orientation.x += angles.x;
orientation.y += angles.y;
glm::vec3 trajectory = direction * distance;
dealDamage(cWeapon, wi, direction, pelletDamage);
}
}
// Play animation
playAnimationAndReturn(wi.FirstPersonEntity, "FinalBlend", "Fire");
@@ -245,35 +255,7 @@ void DefenderWeaponBehaviour::fireShell(ComponentWrapper cWeapon, WeaponInfo& wi
m_EventBroker->Publish(e);
}
void DefenderWeaponBehaviour::spawnTracers(ComponentWrapper cWeapon, WeaponInfo& wi, std::vector<glm::vec2> pattern)
{
EntityWrapper muzzle = getRelevantWeaponEntity(wi).FirstChildByName("WeaponMuzzle");
if (!muzzle.Valid()) {
return;
}
float spreadAngle = glm::radians((float)cWeapon["SpreadAngle"]);
for (auto& pellet : pattern) {
glm::quat pelletRotation = glm::quat(Transform::AbsoluteOrientationEuler(wi.Player.FirstChildByName("Camera"))) * glm::quat(glm::vec3(pellet.y, pellet.x, 0) * spreadAngle);
glm::vec3 origin = Transform::AbsolutePosition(wi.Player.FirstChildByName("Camera"));
glm::vec3 direction = pelletRotation * glm::vec3(0, 0, -1);
float distance = traceRayDistance(origin, direction);
EntityWrapper ray = SpawnerSystem::Spawn(muzzle);
if (ray.Valid()) {
ComponentWrapper cTransform = ray["Transform"];
glm::vec3& position = cTransform["Position"];
glm::vec3& orientation = cTransform["Orientation"];
glm::vec3& scale = cTransform["Scale"];
position = Transform::AbsolutePosition(wi.Player.FirstChildByName("Camera"));
orientation = glm::eulerAngles(pelletRotation);
scale.z = distance;
}
}
}
void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, const std::vector<glm::vec2>& pattern)
void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& wi, glm::vec3 direction, double damage)
{
// Only deal damage client side
if (!IsClient) {
@@ -290,75 +272,46 @@ void DefenderWeaponBehaviour::dealDamage(ComponentWrapper cWeapon, WeaponInfo& w
return;
}
// Convert the spread angle to screen coordinates, taking FOV into account
Rectangle res = m_Renderer->GetViewportSize();
float spreadAngle = glm::radians((float)cWeapon["SpreadAngle"]);
float nearClip = (double)m_CurrentCamera["Camera"]["NearClip"];
float farClip = (double)m_CurrentCamera["Camera"]["FarClip"];
float yFOV = glm::radians((double)m_CurrentCamera["Camera"]["FOV"]);
//float yRefFOV = glm::radians(59.f);
//float yRef = glm::tan(yRefFOV) * nearClip;
//float yRatio = yRef / (glm::tan(yFOV) * nearClip);
//float yMax = (yRatio / 2.f) * spreadAngle * (res.Height / 2.f);
float yRefFOV = glm::radians(59.f);
float yRef = glm::tan(yRefFOV) * nearClip;
float yRatio = yRef / (glm::tan(yFOV) * nearClip);
float yMax = yRatio * (glm::tan(spreadAngle) * farClip);
glm::vec3 maxRange = direction * 2.f;
EntityWrapper camera = wi.Player.FirstChildByName("Camera");
glm::vec3 cameraPosition = Transform::AbsolutePosition(camera);
if (!camera.Valid()) {
return;
}
Rectangle screenResolution = m_Renderer->GetViewportSize();
glm::vec2 centerScreen = glm::vec2(screenResolution.Width / 2, screenResolution.Height / 2);
glm::vec2 screenCoords = cameraFromEntity(m_CurrentCamera).WorldToScreen(cameraPosition + maxRange, m_Renderer->GetViewportSize());
PickData pickData = m_Renderer->Pick(centerScreen + screenCoords);
EntityWrapper victim(m_World, pickData.Entity);
if (!victim.Valid()) {
return;
}
LOG_DEBUG("Ratio: %f", yRatio);
LOG_DEBUG("fatClip: %f", farClip);
LOG_DEBUG("yMax: %f", yMax);
double pelletDamage = (double)cWeapon["BaseDamage"] / pattern.size();
// Don't let us shoot ourselves in the foot somehow
if (victim == LocalPlayer) {
return;
}
// Pick!
std::unordered_map<EntityWrapper, double> damageSum;
glm::vec2 screenCenter(res.Width / 2.f, res.Height / 2.f);
for (auto& pellet : pattern) {
glm::vec2 pickCoord = screenCenter + (pellet * glm::vec2(yMax, yMax));
PickData pick = m_Renderer->Pick(pickCoord);
// Only care about players being hit
if (!victim.HasComponent("Player")) {
victim = victim.FirstParentWithComponent("Player");
}
if (!victim.Valid()) {
return;
}
EntityWrapper victim(m_World, pick.Entity);
if (!victim.Valid()) {
continue;
}
// Temp hit decal
EntityWrapper hit = ResourceManager::Load<EntityFile>("Schema/Entities/HitTest.xml")->MergeInto(m_World);
hit["Transform"]["Position"] = pick.Position;
// Don't let us shoot ourselves in the foot somehow
if (victim == LocalPlayer) {
continue;
}
// Only care about players being hit
if (!victim.HasComponent("Player")) {
victim = victim.FirstParentWithComponent("Player");
if (!victim.Valid()) {
continue;
}
}
// Check for friendly fire
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
// TODO: Ammo sharing
continue;
}
damageSum[victim] += pelletDamage;
((glm::vec3&)hit["Model"]["Color"]).b = 1.f;
// Check for friendly fire
if ((ComponentInfo::EnumType)victim["Team"]["Team"] == (ComponentInfo::EnumType)wi.Player["Team"]["Team"]) {
return;
}
// Deal damage!
for (auto& kv : damageSum) {
// Deal damage!
Events::PlayerDamage ePlayerDamage;
ePlayerDamage.Inflictor = wi.Player;
ePlayerDamage.Victim = kv.first;
ePlayerDamage.Damage = kv.second;
m_EventBroker->Publish(ePlayerDamage);
LOG_DEBUG("Dealt %f damage to #%i", kv.second, kv.first.ID);
}
Events::PlayerDamage ePlayerDamage;
ePlayerDamage.Inflictor = wi.Player;
ePlayerDamage.Victim = victim;
ePlayerDamage.Damage = damage;
m_EventBroker->Publish(ePlayerDamage);
LOG_DEBUG("Damage: %f", damage);
}
bool DefenderWeaponBehaviour::canFire(ComponentWrapper cWeapon, WeaponInfo& wi)