Merge remote-tracking branch 'origin/master' into Sound
This commit is contained in:
@@ -78,6 +78,8 @@ bool AABBVsAABB(const AABB& a, const AABB& b);
|
||||
//Also outputs the minimum translation that box [a] would need in order to resolve collision.
|
||||
bool AABBVsAABB(const AABB& a, const AABB& b, glm::vec3& minimumTranslation);
|
||||
|
||||
//Attaches an AABB which contains all vertices in the entitys Model.
|
||||
bool AttachAABBComponentFromModel(EntityWrapper entity);
|
||||
// Calculates an absolute AABB from an entity AABB component
|
||||
boost::optional<EntityAABB> EntityAbsoluteAABB(EntityWrapper& entity);
|
||||
|
||||
|
||||
+3
-3
@@ -6,12 +6,12 @@
|
||||
#include "Collision.h"
|
||||
#include "EntityAABB.h"
|
||||
|
||||
class CollidableOctreeSystem : public ImpureSystem, public PureSystem
|
||||
class FillOctreeSystem : public ImpureSystem, public PureSystem
|
||||
{
|
||||
public:
|
||||
CollidableOctreeSystem(World* world, EventBroker* eventBroker, Octree<EntityAABB>* octree, const std::string& componentType)
|
||||
FillOctreeSystem(World* world, EventBroker* eventBroker, Octree<EntityAABB>* octree, const std::string& fillComponentType)
|
||||
: System(world, eventBroker)
|
||||
, PureSystem(componentType)
|
||||
, PureSystem(fillComponentType)
|
||||
, m_Octree(octree)
|
||||
{ }
|
||||
|
||||
@@ -25,6 +25,7 @@ struct EntityWrapper
|
||||
|
||||
const std::string Name();
|
||||
bool HasComponent(const std::string& componentType);
|
||||
void AttachComponent(const char* componentName);
|
||||
EntityWrapper Parent();
|
||||
EntityWrapper FirstChildByName(const std::string& name);
|
||||
EntityWrapper FirstParentWithComponent(const std::string& componentType);
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
void InitializeFrameBuffers();
|
||||
void InitializeShaderPrograms();
|
||||
|
||||
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure);
|
||||
void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure);
|
||||
private:
|
||||
const IRenderer* m_Renderer;
|
||||
|
||||
|
||||
@@ -22,15 +22,23 @@ public:
|
||||
|
||||
//Return the texture that is used in later stages to apply the bloom effect
|
||||
GLuint BloomTexture() const { return m_BloomTexture; }
|
||||
GLuint BloomTextureLowRes() const { return m_BloomTextureLowRes; }
|
||||
//Return the texture with diffuse and lighting of the scene.
|
||||
GLuint SceneTexture() const { return m_SceneTexture; }
|
||||
GLuint SceneTextureLowRes() const { return m_SceneTextureLowRes; }
|
||||
//Return the framebuffer used in the scene rendering stage.
|
||||
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
|
||||
FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; }
|
||||
|
||||
|
||||
private:
|
||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
||||
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene);
|
||||
|
||||
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);
|
||||
|
||||
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
|
||||
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
|
||||
@@ -44,15 +52,24 @@ private:
|
||||
Texture* m_GreyTexture;
|
||||
|
||||
FrameBuffer m_FinalPassFrameBuffer;
|
||||
FrameBuffer m_FinalPassFrameBufferLowRes;
|
||||
GLuint m_BloomTexture;
|
||||
GLuint m_SceneTexture;
|
||||
GLuint m_BloomTextureLowRes;
|
||||
GLuint m_SceneTextureLowRes;
|
||||
GLuint m_DepthBuffer;
|
||||
GLuint m_DepthBufferLowRes;
|
||||
|
||||
//maqke this component based i guess?
|
||||
GLuint m_ShieldPixelRate = 16;
|
||||
|
||||
const IRenderer* m_Renderer;
|
||||
const LightCullingPass* m_LightCullingPass;
|
||||
|
||||
ShaderProgram* m_ForwardPlusProgram;
|
||||
ShaderProgram* m_ExplosionEffectProgram;
|
||||
ShaderProgram* m_ShieldToStencilProgram;
|
||||
ShaderProgram* m_FillDepthBufferProgram;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -12,4 +12,11 @@ private:
|
||||
|
||||
};
|
||||
|
||||
class DrawStencilState : public RenderState
|
||||
{
|
||||
public:
|
||||
DrawStencilState(GLuint frameBuffer);
|
||||
~DrawStencilState();
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -19,22 +19,30 @@
|
||||
struct RenderScene
|
||||
{
|
||||
::Camera* Camera = nullptr;
|
||||
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
||||
std::list<std::shared_ptr<RenderJob>> TextJobs;
|
||||
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
||||
struct Queues {
|
||||
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> TransparentShieldedObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> ShieldObjects;
|
||||
std::list<std::shared_ptr<RenderJob>> PointLight;
|
||||
std::list<std::shared_ptr<RenderJob>> Text;
|
||||
std::list<std::shared_ptr<RenderJob>> DirectionalLight;
|
||||
} Jobs;
|
||||
|
||||
Rectangle Viewport;
|
||||
bool ClearDepth = false;
|
||||
glm::vec4 AmbientColor;
|
||||
|
||||
void Clear()
|
||||
{
|
||||
OpaqueObjects.clear();
|
||||
TransparentObjects.clear();
|
||||
PointLightJobs.clear();
|
||||
TextJobs.clear();
|
||||
DirectionalLightJobs.clear();
|
||||
Jobs.OpaqueObjects.clear();
|
||||
Jobs.TransparentObjects.clear();
|
||||
Jobs.OpaqueShieldedObjects.clear();
|
||||
Jobs.TransparentShieldedObjects.clear();
|
||||
Jobs.ShieldObjects.clear();
|
||||
Jobs.Text.clear();
|
||||
Jobs.DirectionalLight.clear();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define RenderState_h__
|
||||
|
||||
#include <functional>
|
||||
#include <boost/range/adaptor/reversed.hpp>
|
||||
#include "../Common.h"
|
||||
#include "../OpenGL.h"
|
||||
#include "../GLM.h"
|
||||
@@ -19,6 +20,9 @@ public:
|
||||
bool BindFramebuffer(GLint framebuffer);
|
||||
bool BlendEquation(GLenum mode);
|
||||
bool BlendFunc(GLenum sfactor, GLenum dfactor);
|
||||
bool StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass);
|
||||
bool StencilFunc(GLenum func, GLint ref, GLuint mask);
|
||||
bool StencilMask(GLuint mask);
|
||||
bool DepthMask(GLboolean flag);
|
||||
|
||||
private:
|
||||
|
||||
@@ -40,7 +40,7 @@ private:
|
||||
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||
|
||||
void fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs);
|
||||
void fillModels(RenderScene::Queues &jobs);
|
||||
void fillText(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||
void fillPointLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||
void fillDirectionalLights(std::list<std::shared_ptr<RenderJob>>& jobs, World* world);
|
||||
|
||||
@@ -32,4 +32,6 @@
|
||||
<xs:include schemaLocation="Components/HiddenForLocalPlayer.xsd"/>
|
||||
<xs:include schemaLocation="Components/HealthPickup.xsd"/>
|
||||
<xs:include schemaLocation="Components/DashAbility.xsd"/>
|
||||
<xs:include schemaLocation="Components/Shield.xsd"/>
|
||||
<xs:include schemaLocation="Components/Shielded.xsd"/>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Shield xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Shield.xsd">
|
||||
</Shield>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
|
||||
<xs:element name="Shield">
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -0,0 +1,3 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||
<Shielded xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Shielded.xsd">
|
||||
</Shielded>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||
|
||||
<xs:element name="Shielded">
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -9,7 +9,8 @@
|
||||
<Entity name="Scenemesh">
|
||||
<Components>
|
||||
<c:AABB>
|
||||
<Size X="150" Y="64" Z="180"/>
|
||||
<Origin X="0.195705414" Y="26.0382366" Z="-0.010017395"/>
|
||||
<Size X="135.414337" Y="68.3848572" Z="180.020035"/>
|
||||
</c:AABB>
|
||||
<c:Collidable/>
|
||||
<c:Model>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="7364.7876" Z="0"/>
|
||||
<Orientation X="0" Y="9161.41992" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -105,7 +105,7 @@
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Position X="2.1529963" Y="6.59221172" Z="0.169116676"/>
|
||||
<Orientation X="4.16300011" Y="15381.7266" Z="0"/>
|
||||
<Orientation X="4.16300011" Y="17199.7988" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
@@ -122,7 +122,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Run</Name>
|
||||
<Time>0.28223692849998105</Time>
|
||||
<Time>0.79292191744688711</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
@@ -138,7 +138,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Walk</Name>
|
||||
<Time>0.44951638260048998</Time>
|
||||
<Time>0.96020137154739604</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
@@ -188,7 +188,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="2019.28503" Z="0"/>
|
||||
<Orientation X="0" Y="2918.14136" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -196,7 +196,7 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Run</Name>
|
||||
<Time>0.021047045591223501</Time>
|
||||
<Time>0.53173203453812956</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
@@ -237,7 +237,7 @@
|
||||
<Axis X="1" Y="1" Z="1"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="13996.3721" Y="13996.3721" Z="13996.3721"/>
|
||||
<Orientation X="15792.2051" Y="15792.2051" Z="15792.2051"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -301,7 +301,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="13793.4053" Z="0"/>
|
||||
<Orientation X="0" Y="15589.2383" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -333,7 +333,7 @@
|
||||
<Axis X="0.699999988" Y="1" Z="0.300000012"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="10188.9443" Y="14517.8643" Z="4350.31738"/>
|
||||
<Orientation X="11456.2695" Y="16313.6973" Z="4881.66504"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -586,7 +586,7 @@
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-0.258742422" Y="0.5" Z="-1.8603574"/>
|
||||
<Position X="-0.236842498" Y="0.5" Z="-1.83845747"/>
|
||||
<Orientation X="2.03600001" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
@@ -683,7 +683,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="316.504456" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -730,7 +730,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="316.504456" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -790,7 +790,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="316.504456" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -837,7 +837,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="316.504456" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -883,7 +883,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="316.504456" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -930,7 +930,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="316.504456" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -977,7 +977,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="316.504456" Z="0"/>
|
||||
<Orientation X="0" Y="1217.61243" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1038,7 +1038,7 @@
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="1" B="0" G="0.200000003" R="1"/>
|
||||
<Color A="0.300000012" B="0" G="0.200000003" R="1"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Team>
|
||||
@@ -1088,7 +1088,8 @@
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="1" B="0" G="1" R="1"/>
|
||||
<Color A="0.300000012" B="0" G="1" R="1"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Team/>
|
||||
<c:Transform>
|
||||
@@ -1131,6 +1132,7 @@
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="0.300000012" B="1" G="1" R="1"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Team/>
|
||||
@@ -1177,7 +1179,8 @@
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="1" B="1" G="1" R="0"/>
|
||||
<Color A="0.300000012" B="1" G="1" R="0"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Team/>
|
||||
<c:Transform>
|
||||
@@ -1225,7 +1228,7 @@
|
||||
</c:CapturePoint>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="1" B="1" G="0.200000003" R="0"/>
|
||||
<Color A="0.300000012" B="1" G="0.200000003" R="0"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Team>
|
||||
@@ -1347,6 +1350,19 @@
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Text">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>ExplosionEffect Test</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="3.80000019" Z="0"/>
|
||||
<Orientation X="0" Y="1.5710001" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="AssetBase">
|
||||
<Components>
|
||||
<c:Model>
|
||||
@@ -1374,7 +1390,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="850.206848" Z="0"/>
|
||||
<Orientation X="0" Y="1750.85376" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1383,7 +1399,7 @@
|
||||
<c:ExplosionEffect>
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0.800000012" Y="0.0379999988" Z="0"/>
|
||||
<TimeSinceDeath>0.75008034908941568</TimeSinceDeath>
|
||||
<TimeSinceDeath>1.3671759474185377</TimeSinceDeath>
|
||||
<ExplosionDuration>3.7999999523162842</ExplosionDuration>
|
||||
<EndColor A="0" B="23.5294113" G="11.7647057" R="0"/>
|
||||
<Randomness>true</Randomness>
|
||||
@@ -1430,7 +1446,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="850.206848" Z="0"/>
|
||||
<Orientation X="0" Y="1750.85376" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1439,7 +1455,7 @@
|
||||
<c:ExplosionEffect>
|
||||
<Velocity X="0.5" Y="1" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="0.900000036" Z="0"/>
|
||||
<TimeSinceDeath>1.1999860997035228</TimeSinceDeath>
|
||||
<TimeSinceDeath>0.31711568080172703</TimeSinceDeath>
|
||||
</c:ExplosionEffect>
|
||||
<c:Model>
|
||||
<Resource>Models/Assault.mesh</Resource>
|
||||
@@ -1482,7 +1498,7 @@
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="850.206848" Z="0"/>
|
||||
<Orientation X="0" Y="1750.85376" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
@@ -1490,14 +1506,14 @@
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Walk</Name>
|
||||
<Time>0.23053304095120097</Time>
|
||||
<Time>0.74121802989810703</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:ExplosionEffect>
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0.300000012" Y="2" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="1.30000007" Z="-0.200000003"/>
|
||||
<TimeSinceDeath>0.68343188336345406</TimeSinceDeath>
|
||||
<TimeSinceDeath>0.31711568080172703</TimeSinceDeath>
|
||||
<EndColor A="0" B="0.333333343" G="0.933333337" R="3.92156863"/>
|
||||
<Randomness>true</Randomness>
|
||||
</c:ExplosionEffect>
|
||||
@@ -1515,18 +1531,120 @@
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="Text">
|
||||
<Entity name="AssetBase">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>ExplosionEffect Test</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||
<Color A="1" B="1.56862748" G="1.56862748" R="1.56862748"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="3.80000019" Z="0"/>
|
||||
<Orientation X="0" Y="1.5710001" Z="0"/>
|
||||
<Position X="0" Y="-0.231354833" Z="-2.92637157"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
<Children>
|
||||
<Entity name="Light">
|
||||
<Components>
|
||||
<c:PointLight/>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.663784981" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="RotationOrigin">
|
||||
<Components>
|
||||
<c:RaptorCopter>
|
||||
<Speed>0.5</Speed>
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="857.983765" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Asset">
|
||||
<Components>
|
||||
<c:ExplosionEffect>
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0" Y="0.699999988" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="-1.10000002" Z="0"/>
|
||||
<TimeSinceDeath>0.95047462600732735</TimeSinceDeath>
|
||||
<ExplosionDuration>10</ExplosionDuration>
|
||||
<EndColor A="1" B="0" G="0" R="1"/>
|
||||
<RandomnessScalar>3</RandomnessScalar>
|
||||
<Randomness>true</Randomness>
|
||||
</c:ExplosionEffect>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitSphere.mesh</Resource>
|
||||
<Color A="0" B="1" G="0" R="0"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.5" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="AssetBase">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCylinder.mesh</Resource>
|
||||
<Color A="1" B="1.56862748" G="1.56862748" R="1.56862748"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="-0.231354833" Z="-4.48872519"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Light">
|
||||
<Components>
|
||||
<c:PointLight/>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.663784981" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="RotationOrigin">
|
||||
<Components>
|
||||
<c:RaptorCopter>
|
||||
<Speed>0.5</Speed>
|
||||
<Axis X="0" Y="1" Z="0"/>
|
||||
</c:RaptorCopter>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="456.13559" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Asset">
|
||||
<Components>
|
||||
<c:ExplosionEffect>
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="6" Y="0.100000001" Z="0"/>
|
||||
<ExplosionOrigin X="0" Y="-10" Z="0"/>
|
||||
<TimeSinceDeath>1.350502887383392</TimeSinceDeath>
|
||||
<ExponentialAccelaration>true</ExponentialAccelaration>
|
||||
<ExplosionDuration>5</ExplosionDuration>
|
||||
<Randomness>true</Randomness>
|
||||
</c:ExplosionEffect>
|
||||
<c:Model>
|
||||
<Resource>Models/Assault.mesh</Resource>
|
||||
<Color A="1" B="1" G="0.392156869" R="0"/>
|
||||
<Transparent>true</Transparent>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.5" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
@@ -1553,6 +1671,278 @@
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="DefenderShieldTestOrigin">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="-11.0375881" Y="0" Z="20.9209175"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Shield">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitHexagon.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Shield/>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="1.47765553" Z="0"/>
|
||||
<Orientation X="0" Y="2.15300012" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="ShieldedCube">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Shielded/>
|
||||
<c:Transform>
|
||||
<Position X="-3.34650159" Y="1.19966424" Z="3.09996605"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="ShieldedPlayer">
|
||||
<Components>
|
||||
<c:AABB>
|
||||
<Origin X="0" Y="0.772000015" Z="0"/>
|
||||
<Size X="1" Y="1.60000002" Z="1"/>
|
||||
</c:AABB>
|
||||
<c:Collidable/>
|
||||
<c:Health/>
|
||||
<c:Physics>
|
||||
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
|
||||
<Gravity>false</Gravity>
|
||||
</c:Physics>
|
||||
<c:Player>
|
||||
<MovementSpeed>5</MovementSpeed>
|
||||
</c:Player>
|
||||
<c:Team>
|
||||
<Team>
|
||||
<Red/>
|
||||
</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-1.56735241" Y="0.527999997" Z="0.929739475"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Camera">
|
||||
<Components>
|
||||
<c:Camera/>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="1.37700009" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="PlayerName">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Resource>Fonts/DroidSans.ttf,100</Resource>
|
||||
<Color A="1" B="0" G="1" R="0"/>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0.100000001" Y="0.248000011" Z="-0.248000011"/>
|
||||
<Scale X="0.100000001" Y="0.113000005" Z="0.5"/>
|
||||
<Orientation X="0" Y="3.14199996" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="CameraModel">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Camera.mesh</Resource>
|
||||
<Visible>false</Visible>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.0331346765" Z="-0.0792061687"/>
|
||||
<Scale X="1.30000007" Y="1.50000012" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="HUD">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="-0.5"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="HealthBar">
|
||||
<Components>
|
||||
<c:Fill>
|
||||
<Percentage>1</Percentage>
|
||||
<Color A="0" B="1" G="0" R="0"/>
|
||||
</c:Fill>
|
||||
<c:HealthHUD/>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitHexagon.mesh</Resource>
|
||||
<Color A="1" B="0.70588237" G="0.70588237" R="0.70588237"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-0.383000016" Y="-0.185000002" Z="0"/>
|
||||
<Scale X="0.150000006" Y="0.150000006" Z="0.150000006"/>
|
||||
<Orientation X="0" Y="0.594000041" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Crosshair">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/CrosshairQuad.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0" Z="0.200000003"/>
|
||||
<Scale X="0.00600000005" Y="1" Z="0.00600000005"/>
|
||||
<Orientation X="1.57000005" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Weapon">
|
||||
<Components>
|
||||
<c:ExplosionEffect>
|
||||
<ColorByDistance>true</ColorByDistance>
|
||||
<Velocity X="0.800000012" Y="0.0379999988" Z="0"/>
|
||||
<TimeSinceDeath>1.3671759474185377</TimeSinceDeath>
|
||||
<ExplosionDuration>3.7999999523162842</ExplosionDuration>
|
||||
<EndColor A="0" B="23.5294113" G="11.7647057" R="0"/>
|
||||
<Randomness>true</Randomness>
|
||||
</c:ExplosionEffect>
|
||||
<c:Model>
|
||||
<Resource>Models/AssaultWeaponRed.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0.180000007" Y="-0.183000013" Z="0"/>
|
||||
<Orientation X="0" Y="3.08300018" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="WeaponMuzzle">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="0.215000004" Y="-0.153000012" Z="-0.266000003"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="ThirdPersonCamera">
|
||||
<Components>
|
||||
<c:Camera/>
|
||||
<c:Model>
|
||||
<Resource>Models/Camera.mesh</Resource>
|
||||
<Visible>false</Visible>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-0.284000009" Y="1.83800006" Z="1.18900001"/>
|
||||
<Orientation X="5.95600033" Y="0" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="PlayerModel">
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Hold Pos</Name>
|
||||
<Time>0.39573681725672838</Time>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:HiddenForLocalPlayer/>
|
||||
<c:Model>
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
<Color A="1" B="0" G="0" R="1"/>
|
||||
</c:Model>
|
||||
<c:Shielded/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="AABBStanding">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="0.427450985" B="1" G="1" R="1"/>
|
||||
<Visible>false</Visible>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.772000015" Z="0"/>
|
||||
<Scale X="1" Y="1.60000002" Z="1"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="AABBCrouching">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/UnitCube.mesh</Resource>
|
||||
<Color A="0.745098054" B="1" G="0" R="1"/>
|
||||
<Visible>false</Visible>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.772000015" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="BackgroundItemsOrigin">
|
||||
<Components>
|
||||
<c:Transform>
|
||||
<Position X="-7.17760038" Y="0" Z="5.57545042"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children>
|
||||
<Entity name="Log">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Log.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-0.09513513" Y="0.53153497" Z="-0.127776429"/>
|
||||
<Orientation X="5.9920001" Y="0.640000045" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="Bush">
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/BushAlive.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="-4.95900011" Y="0" Z="1.29897511"/>
|
||||
<Scale X="5" Y="5" Z="5"/>
|
||||
<Orientation X="0.407000005" Y="1.68700004" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
<Entity name="Text">
|
||||
<Components>
|
||||
<c:Text>
|
||||
<Content>Defender Shield Test</Content>
|
||||
<Resource>Fonts/DroidSans.ttf,64</Resource>
|
||||
</c:Text>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="4.20000029" Z="0"/>
|
||||
<Orientation X="0" Y="2.15300012" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
|
||||
@@ -0,0 +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">
|
||||
|
||||
<Components>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
|
||||
<Children>
|
||||
<Entity>
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Core/Unithexagon.mesh</Resource>
|
||||
</c:Model>
|
||||
<c:Shield/>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="dl">
|
||||
<Components>
|
||||
<c:DirectionalLight/>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="2.61800003" Z="0.756000042"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
<Entity name="sl">
|
||||
<Components>
|
||||
<c:SceneLight>
|
||||
<Gamma>2.2000000476837158</Gamma>
|
||||
</c:SceneLight>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
</Children>
|
||||
|
||||
</Entity>
|
||||
@@ -38,6 +38,8 @@
|
||||
<xs:element ref="c:HiddenForLocalPlayer" minOccurs="0"/>
|
||||
<xs:element ref="c:Fill" minOccurs="0"/>
|
||||
<xs:element ref="c:Animation" minOccurs="0"/>
|
||||
<xs:element ref="c:Shield" minOccurs="0"/>
|
||||
<xs:element ref="c:Shielded" minOccurs="0"/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
layout (binding = 0) uniform sampler2D SceneTexture;
|
||||
layout (binding = 1) uniform sampler2D BloomTexture;
|
||||
layout (binding = 2) uniform sampler2D SceneTextureLowRes;
|
||||
layout (binding = 3) uniform sampler2D BloomTextureLowRes;
|
||||
uniform float Exposure;
|
||||
uniform float Gamma;
|
||||
|
||||
@@ -15,10 +17,19 @@ void main()
|
||||
{
|
||||
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
|
||||
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
|
||||
vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate);
|
||||
vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate);
|
||||
hdrColor += bloomColor;
|
||||
hdrColorLowRes;
|
||||
|
||||
float hdrColorsum = hdrColorLowRes.r + hdrColorLowRes.g + hdrColorLowRes.b;
|
||||
//Toon mapping thingy
|
||||
vec3 result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
|
||||
vec3 result;
|
||||
if(hdrColorsum > 0.0) {
|
||||
result = vec3(1.0) - exp(-hdrColorLowRes.rgb * Exposure);
|
||||
} else {
|
||||
result = vec3(1.0) - exp(-hdrColor.rgb * Exposure);
|
||||
}
|
||||
|
||||
//gamme correction
|
||||
result = pow(result, vec3(1.0 / Gamma));
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#version 430
|
||||
|
||||
in VertexData{
|
||||
vec3 Position;
|
||||
}Input;
|
||||
|
||||
void main()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#version 430
|
||||
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
|
||||
layout(location = 0) in vec3 Position;
|
||||
layout(location = 5) in vec4 BoneIndices;
|
||||
layout(location = 6) in vec4 BoneWeights;
|
||||
|
||||
|
||||
out VertexData{
|
||||
vec3 Position;
|
||||
}Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = P * V * M * vec4(Position, 1.0);
|
||||
|
||||
Output.Position = Position;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#version 430
|
||||
|
||||
in VertexData{
|
||||
vec3 Position;
|
||||
}Input;
|
||||
|
||||
|
||||
out vec4 fragmentColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
fragmentColor = vec4(0.5, 0.0, 0.0, 0.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
#version 430
|
||||
|
||||
uniform mat4 M;
|
||||
uniform mat4 V;
|
||||
uniform mat4 P;
|
||||
|
||||
layout(location = 0) in vec3 Position;
|
||||
|
||||
|
||||
out VertexData{
|
||||
vec3 Position;
|
||||
}Output;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = P * V * M * vec4(Position, 1.0);
|
||||
|
||||
Output.Position = Position;
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "Collision/CollidableOctreeSystem.h"
|
||||
|
||||
void CollidableOctreeSystem::Update(double dt)
|
||||
{
|
||||
m_Octree->ClearDynamicObjects();
|
||||
}
|
||||
|
||||
void CollidableOctreeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
{
|
||||
if (entity.HasComponent("AABB")) {
|
||||
boost::optional<EntityAABB> absoluteAABB = Collision::EntityAbsoluteAABB(entity);
|
||||
if (absoluteAABB) {
|
||||
m_Octree->AddDynamicObject(*absoluteAABB);
|
||||
}
|
||||
} else if (entity.HasComponent("Model")) {
|
||||
// TODO: Derive AABB from model
|
||||
}
|
||||
}
|
||||
@@ -564,33 +564,29 @@ bool AABBvsTriangles(const AABB& box,
|
||||
return hit;
|
||||
}
|
||||
|
||||
bool attachAABBComponentFromModel(World* world, EntityID id)
|
||||
bool AttachAABBComponentFromModel(EntityWrapper entity)
|
||||
{
|
||||
if (!world->HasComponent(id, "Model")) {
|
||||
if (!entity.HasComponent("Model")) {
|
||||
return false;
|
||||
}
|
||||
ComponentWrapper model = world->GetComponent(id, "Model");
|
||||
ComponentWrapper collision = world->AttachComponent(id, "AABB");
|
||||
Model* modelRes = ResourceManager::Load<Model>(model["Resource"]);
|
||||
if (modelRes == nullptr) {
|
||||
//Derive AABB from model
|
||||
RawModel* model;
|
||||
try {
|
||||
model = ResourceManager::Load<RawModel, true>(entity["Model"]["Resource"]);
|
||||
} catch (const std::exception&) {
|
||||
return false;
|
||||
}
|
||||
|
||||
glm::mat4 modelMatrix = modelRes->Matrix();
|
||||
|
||||
glm::vec3 mini = glm::vec3(INFINITY, INFINITY, INFINITY);
|
||||
glm::vec3 maxi = glm::vec3(-INFINITY, -INFINITY, -INFINITY);
|
||||
for (const auto& v : modelRes->Vertices()) {
|
||||
const auto& wPos = modelMatrix * glm::vec4(v.Position.x, v.Position.y, v.Position.z, 1);
|
||||
maxi.x = std::max(wPos.x, maxi.x);
|
||||
maxi.y = std::max(wPos.y, maxi.y);
|
||||
maxi.z = std::max(wPos.z, maxi.z);
|
||||
mini.x = std::min(wPos.x, mini.x);
|
||||
mini.y = std::min(wPos.y, mini.y);
|
||||
mini.z = std::min(wPos.z, mini.z);
|
||||
glm::vec3 mini(INFINITY);
|
||||
glm::vec3 maxi(-INFINITY);
|
||||
for (const auto& v : model->m_Vertices) {
|
||||
mini = glm::min(mini, v.Position);
|
||||
maxi = glm::max(maxi, v.Position);
|
||||
}
|
||||
collision["Origin"] = 0.5f * (maxi + mini);
|
||||
collision["Size"] = maxi - mini;
|
||||
|
||||
entity.AttachComponent("AABB");
|
||||
entity["AABB"]["Origin"] = 0.5f * (maxi + mini);
|
||||
entity["AABB"]["Size"] = maxi - mini;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
// Collide against octree items
|
||||
m_OctreeResult.clear();
|
||||
m_Octree->ObjectsInSameRegion(*boundingBox, m_OctreeResult);
|
||||
bool everHitTheGround = false;
|
||||
for (auto& boxB : m_OctreeResult) {
|
||||
glm::vec3 resolutionVector;
|
||||
if (boxA.Entity == boxB.Entity) {
|
||||
@@ -43,17 +44,24 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
|
||||
if (Collision::AABBvsTriangles(boxA, model->m_Vertices, model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
|
||||
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
||||
cPhysics["Velocity"] = inOutVelocity;
|
||||
(bool)cPhysics["IsOnGround"] = isOnGround;
|
||||
} else {
|
||||
(bool)cPhysics["IsOnGround"] = false;
|
||||
if (isOnGround) {
|
||||
everHitTheGround = true;
|
||||
(bool)cPhysics["IsOnGround"] = true;
|
||||
}
|
||||
}
|
||||
} else if (Collision::AABBVsAABB(boxA, boxB, resolutionVector)) {
|
||||
//Enter here if boxB has no Model.
|
||||
(glm::vec3&)cTransform["Position"] += resolutionVector;
|
||||
(bool)cPhysics["IsOnGround"] = resolutionVector.y > 0;
|
||||
if ((bool)cPhysics["IsOnGround"]){
|
||||
if (resolutionVector.y > 0) {
|
||||
everHitTheGround = true;
|
||||
(bool)cPhysics["IsOnGround"] = true;
|
||||
((glm::vec3&)cPhysics["Velocity"]).y = 0.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//This should apply air friction and such, iff zero models were hit.
|
||||
if (!everHitTheGround) {
|
||||
(bool)cPhysics["IsOnGround"] = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
#include "Collision/FillOctreeSystem.h"
|
||||
|
||||
void FillOctreeSystem::Update(double dt)
|
||||
{
|
||||
m_Octree->ClearDynamicObjects();
|
||||
}
|
||||
|
||||
void FillOctreeSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt)
|
||||
{
|
||||
if (!entity.HasComponent("AABB")) {
|
||||
//Derive AABB from model.
|
||||
if (!Collision::AttachAABBComponentFromModel(entity)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
boost::optional<EntityAABB> absoluteAABB = Collision::EntityAbsoluteAABB(entity);
|
||||
if (absoluteAABB) {
|
||||
m_Octree->AddDynamicObject(*absoluteAABB);
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@
|
||||
void TriggerSystem::UpdateComponent(EntityWrapper& triggerEntity, ComponentWrapper& cTrigger, double dt)
|
||||
{
|
||||
// The trigger *should* have a bounding box, or something, to test against so it can be triggered.
|
||||
// If it doesn't, add one as big as the model for now, then size can be modified in editor if necessary.
|
||||
if (!triggerEntity.HasComponent("AABB")) {
|
||||
Collision::AttachAABBComponentFromModel(triggerEntity);
|
||||
}
|
||||
boost::optional<EntityAABB> triggerBox = Collision::EntityAbsoluteAABB(triggerEntity);
|
||||
if (!triggerBox) {
|
||||
return;
|
||||
|
||||
@@ -16,6 +16,15 @@ bool EntityWrapper::HasComponent(const std::string& componentName)
|
||||
return World->HasComponent(ID, componentName);
|
||||
}
|
||||
|
||||
void EntityWrapper::AttachComponent(const char* componentName)
|
||||
{
|
||||
if (!Valid()) {
|
||||
LOG_WARNING("Could not attach \"%s\" component to #%i, entity is not valid.", componentName, ID);
|
||||
return;
|
||||
}
|
||||
World->AttachComponent(ID, componentName);
|
||||
}
|
||||
|
||||
EntityWrapper EntityWrapper::Parent()
|
||||
{
|
||||
if (this->World == nullptr || this->ID == EntityID_Invalid) {
|
||||
|
||||
@@ -56,9 +56,9 @@ void EditorRenderSystem::Update(double dt)
|
||||
for (auto matGroup : model->MaterialGroups()) {
|
||||
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
||||
if (cModel["Transparent"]) {
|
||||
scene.TransparentObjects.push_back(modelJob);
|
||||
scene.Jobs.TransparentObjects.push_back(modelJob);
|
||||
} else {
|
||||
scene.OpaqueObjects.push_back(modelJob);
|
||||
scene.Jobs.OpaqueObjects.push_back(modelJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,7 +75,7 @@ void EditorRenderSystem::Update(double dt)
|
||||
EntityWrapper entity(m_World, cPointLight.EntityID);
|
||||
ComponentWrapper& cTransform = entity["Transform"];
|
||||
std::shared_ptr<PointLightJob> pointLightJob = std::make_shared<PointLightJob>(cTransform, cPointLight, entity.World);
|
||||
scene.PointLightJobs.push_back(pointLightJob);
|
||||
scene.Jobs.PointLight.push_back(pointLightJob);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,8 +6,6 @@ DrawColorCorrectionPass::DrawColorCorrectionPass(IRenderer* renderer)
|
||||
|
||||
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
|
||||
|
||||
//m_Exposure = 0.4; //TODO: Renderer: Fixa så att denna går att ändra på genom komponent eller setting.
|
||||
|
||||
InitializeShaderPrograms();
|
||||
}
|
||||
|
||||
@@ -20,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms()
|
||||
m_ColorCorrectionProgram->Link();
|
||||
}
|
||||
|
||||
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLfloat gamma, GLfloat exposure)
|
||||
void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure)
|
||||
{
|
||||
//glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
GLERROR("DrawScreenQuadPass::Draw: Pre");
|
||||
@@ -35,6 +33,10 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLf
|
||||
glBindTexture(GL_TEXTURE_2D, sceneTexture);
|
||||
glActiveTexture(GL_TEXTURE1);
|
||||
glBindTexture(GL_TEXTURE_2D, bloomTexture);
|
||||
glActiveTexture(GL_TEXTURE2);
|
||||
glBindTexture(GL_TEXTURE_2D, sceneTextureLowRes);
|
||||
glActiveTexture(GL_TEXTURE3);
|
||||
glBindTexture(GL_TEXTURE_2D, bloomTextureLowRes);
|
||||
|
||||
glBindVertexArray(m_ScreenQuad->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
|
||||
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass)
|
||||
{
|
||||
//TODO: Make sure that uniforms are not sent into shader if not needed.
|
||||
m_Renderer = renderer;
|
||||
m_LightCullingPass = lightCullingPass;
|
||||
m_ShieldPixelRate = 8;
|
||||
InitializeTextures();
|
||||
InitializeShaderPrograms();
|
||||
InitializeFrameBuffers();
|
||||
@@ -21,18 +23,39 @@ void DrawFinalPass::InitializeFrameBuffers()
|
||||
{
|
||||
glGenRenderbuffers(1, &m_DepthBuffer);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
GLERROR("RenderBuffer generation");
|
||||
|
||||
GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
//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);
|
||||
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||
//m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
||||
m_FinalPassFrameBuffer.Generate();
|
||||
GLERROR("FBO generation");
|
||||
|
||||
glGenRenderbuffers(1, &m_DepthBufferLowRes);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate));
|
||||
GLERROR("RenderBufferLowRes generation");
|
||||
|
||||
GenerateTexture(&m_SceneTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||
GenerateTexture(&m_BloomTextureLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST, glm::vec2((int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate)), 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);
|
||||
|
||||
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBufferLowRes, GL_DEPTH_STENCIL_ATTACHMENT)));
|
||||
//m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT)));
|
||||
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTextureLowRes, GL_COLOR_ATTACHMENT0)));
|
||||
m_FinalPassFrameBufferLowRes.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTextureLowRes, GL_COLOR_ATTACHMENT1)));
|
||||
m_FinalPassFrameBufferLowRes.Generate();
|
||||
GLERROR("FBO2 generation");
|
||||
}
|
||||
|
||||
void DrawFinalPass::InitializeShaderPrograms()
|
||||
@@ -55,6 +78,20 @@ void DrawFinalPass::InitializeShaderPrograms()
|
||||
m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor");
|
||||
m_ExplosionEffectProgram->Link();
|
||||
GLERROR("Creating explosion program");
|
||||
|
||||
m_ShieldToStencilProgram = ResourceManager::Load<ShaderProgram>("#ShieldToStencilProgram");
|
||||
m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShieldStencil.vert.glsl")));
|
||||
m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ShieldStencil.frag.glsl")));
|
||||
m_ShieldToStencilProgram->Compile();
|
||||
m_ShieldToStencilProgram->Link();
|
||||
GLERROR("Creating Shield program");
|
||||
|
||||
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->Compile();
|
||||
m_FillDepthBufferProgram->Link();
|
||||
GLERROR("Creating DepthFill program");
|
||||
}
|
||||
|
||||
void DrawFinalPass::Draw(RenderScene& scene)
|
||||
@@ -65,20 +102,92 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
||||
if (scene.ClearDepth) {
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
//TODO: Do we need check for this or will it be per scene always?
|
||||
glClearStencil(0x00);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
DrawModelRenderQueues(scene.OpaqueObjects, scene);
|
||||
//Fill depth buffer
|
||||
|
||||
|
||||
state->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
GLERROR("OpaqueObjects");
|
||||
DrawModelRenderQueues(scene.TransparentObjects, scene);
|
||||
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
|
||||
GLERROR("TransparentObjects");
|
||||
|
||||
delete state;
|
||||
//DrawStencilState* stencilState = new DrawStencilState(m_FinalPassFrameBuffer.GetHandle());
|
||||
//Draw shields to stencil pass
|
||||
state->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||
state->StencilMask(0xFF);
|
||||
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||
GLERROR("StencilPass");
|
||||
|
||||
//Draw Opaque shielded objects
|
||||
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||
state->StencilMask(0x00);
|
||||
DrawShieldedModelRenderQueue(scene.Jobs.OpaqueShieldedObjects, scene);
|
||||
GLERROR("Shielded Opaque object");
|
||||
|
||||
//Draw Transparen Shielded objects
|
||||
DrawShieldedModelRenderQueue(scene.Jobs.TransparentShieldedObjects, scene);
|
||||
GLERROR("Shielded Transparent objects");
|
||||
|
||||
GLERROR("END");
|
||||
delete state;
|
||||
|
||||
|
||||
DrawFinalPassState* stateLowRes = new DrawFinalPassState(m_FinalPassFrameBufferLowRes.GetHandle());
|
||||
//Draw the lowres texture that will be shown behind the shield.
|
||||
stateLowRes->Enable(GL_SCISSOR_TEST);
|
||||
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||
//TODO: Viewports and scissor should be in state
|
||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
|
||||
glClearStencil(0x00);
|
||||
glClear(GL_STENCIL_BUFFER_BIT);
|
||||
|
||||
//TODO: This should not be here...
|
||||
stateLowRes->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||
stateLowRes->StencilMask(0x00);
|
||||
DrawToDepthBuffer(scene.Jobs.OpaqueObjects, scene);
|
||||
DrawToDepthBuffer(scene.Jobs.TransparentObjects, scene);
|
||||
|
||||
//Draw shields to stencil pass
|
||||
stateLowRes->StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||
stateLowRes->StencilMask(0xFF);
|
||||
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
|
||||
GLERROR("StencilPass");
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
stateLowRes->Enable(GL_DEPTH_TEST);
|
||||
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
|
||||
stateLowRes->StencilMask(0x00);
|
||||
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
|
||||
GLERROR("OpaqueObjects");
|
||||
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);
|
||||
delete stateLowRes;
|
||||
}
|
||||
|
||||
|
||||
void DrawFinalPass::ClearBuffer()
|
||||
{
|
||||
m_FinalPassFrameBufferLowRes.Bind();
|
||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_ShieldPixelRate, m_Renderer->GetViewportSize().Height/m_ShieldPixelRate);
|
||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
m_FinalPassFrameBufferLowRes.Unbind();
|
||||
|
||||
m_FinalPassFrameBuffer.Bind();
|
||||
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
m_FinalPassFrameBuffer.Unbind();
|
||||
@@ -110,7 +219,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
|
||||
GLERROR("MipMap Texture initialization failed");
|
||||
}
|
||||
|
||||
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene)
|
||||
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||
{
|
||||
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||
GLERROR("forwardHandle");
|
||||
@@ -121,7 +230,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||
|
||||
for(auto &job : job)
|
||||
for(auto &job : jobs)
|
||||
{
|
||||
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||
if(explosionEffectJob) {
|
||||
@@ -201,6 +310,153 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
||||
|
||||
}
|
||||
|
||||
|
||||
void DrawFinalPass::DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||
{
|
||||
m_ShieldToStencilProgram->Bind();
|
||||
GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle();
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
|
||||
for (auto &job : jobs) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
if (modelJob) {
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
|
||||
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||
if (GLERROR("models end")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||
{
|
||||
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||
GLERROR("forwardHandle");
|
||||
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
|
||||
GLERROR("explosionHandle");
|
||||
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||
|
||||
for (auto &job : jobs) {
|
||||
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||
if (explosionEffectJob) {
|
||||
//Bind program
|
||||
if (GLERROR("Prebind")) {
|
||||
continue;
|
||||
}
|
||||
m_ExplosionEffectProgram->Bind();
|
||||
if (GLERROR("BindProgram")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
glDisable(GL_CULL_FACE);
|
||||
|
||||
//Bind uniforms
|
||||
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||
if (GLERROR("BindExplosionUniforms")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
if (explosionEffectJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = explosionEffectJob->Skeleton->GetFrameBones(*explosionEffectJob->Animation, explosionEffectJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
}
|
||||
if (GLERROR("Animation")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//bind textures
|
||||
BindExplosionTextures(explosionEffectJob);
|
||||
if (GLERROR("BindExplosionTextures")) {
|
||||
continue;
|
||||
}
|
||||
//draw
|
||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||
glEnable(GL_CULL_FACE);
|
||||
if (GLERROR("explosion effect end")) {
|
||||
continue;
|
||||
}
|
||||
|
||||
} else {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
if (modelJob) {
|
||||
//bind forward program
|
||||
m_ForwardPlusProgram->Bind();
|
||||
glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
|
||||
//bind uniforms
|
||||
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||
|
||||
//bind textures
|
||||
BindModelTextures(modelJob);
|
||||
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
if (modelJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
}
|
||||
|
||||
//draw
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||
if (GLERROR("models end")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DrawFinalPass::DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||
{
|
||||
m_FillDepthBufferProgram->Bind();
|
||||
GLuint shaderHandle = m_FillDepthBufferProgram->GetHandle();
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
|
||||
for (auto &job : jobs) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
|
||||
//bind uniforms
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
if (modelJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
}
|
||||
|
||||
//draw
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||
if (GLERROR("models end")) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||
{
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "Rendering/DrawFinalPassState.h"
|
||||
|
||||
|
||||
|
||||
DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
||||
{
|
||||
BindFramebuffer(frameBuffer);
|
||||
@@ -8,6 +9,10 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
|
||||
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
Enable(GL_DEPTH_TEST);
|
||||
Enable(GL_CULL_FACE);
|
||||
Enable(GL_STENCIL_TEST);
|
||||
StencilFunc(GL_NOTEQUAL, 1, 0xFF);
|
||||
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
StencilMask(0xFF);
|
||||
ClearColor(glm::vec4(0.f, 0.f, 0.f, 0.f));
|
||||
}
|
||||
|
||||
@@ -15,3 +20,20 @@ DrawFinalPassState::~DrawFinalPassState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DrawStencilState::DrawStencilState(GLuint frameBuffer)
|
||||
{
|
||||
BindFramebuffer(frameBuffer);
|
||||
Enable(GL_STENCIL_TEST);
|
||||
StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
|
||||
StencilFunc(GL_ALWAYS, 1, 0xFF);
|
||||
StencilMask(0xFF);
|
||||
Enable(GL_DEPTH_TEST);
|
||||
ClearColor(glm::vec4(0.f));
|
||||
}
|
||||
|
||||
DrawStencilState::~DrawStencilState()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -39,10 +39,13 @@ void FrameBuffer::AddResource(std::shared_ptr<BufferResource> resource)
|
||||
|
||||
void FrameBuffer::Generate()
|
||||
{
|
||||
GLERROR("PRE");
|
||||
|
||||
std::vector<GLenum> attachments;
|
||||
|
||||
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) {
|
||||
@@ -56,20 +59,30 @@ void FrameBuffer::Generate()
|
||||
GLERROR("FrameBuffer generate: glFramebufferRenderbuffer");
|
||||
break;
|
||||
}
|
||||
|
||||
GLERROR("2");
|
||||
|
||||
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT) {
|
||||
if ((*it)->m_Attachment != GL_DEPTH_ATTACHMENT && (*it)->m_Attachment != GL_STENCIL_ATTACHMENT && (*it)->m_Attachment != GL_DEPTH_STENCIL_ATTACHMENT) {
|
||||
attachments.push_back((*it)->m_Attachment);
|
||||
}
|
||||
GLERROR("Attachment");
|
||||
|
||||
}
|
||||
|
||||
GLERROR("3");
|
||||
|
||||
|
||||
GLenum* bufferTextures = &attachments[0];
|
||||
glDrawBuffers(attachments.size(), bufferTextures);
|
||||
if(GLERROR("4")) {
|
||||
printf("hello");
|
||||
}
|
||||
|
||||
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
||||
GLERROR("Framebuffer incomplete");
|
||||
//LOG_ERROR("FrameBuffer incomplete: 0x%x\n", frameBufferStatus);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
GLERROR("END");
|
||||
|
||||
}
|
||||
|
||||
void FrameBuffer::Bind()
|
||||
|
||||
@@ -16,7 +16,7 @@ LightCullingPass::~LightCullingPass()
|
||||
|
||||
void LightCullingPass::GenerateNewFrustum(RenderScene& scene)
|
||||
{
|
||||
if (scene.PointLightJobs.size() == 0)
|
||||
if (scene.Jobs.PointLight.size() == 0)
|
||||
return;
|
||||
|
||||
GLERROR("CalculateFrustum Error: Pre");
|
||||
@@ -83,7 +83,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
||||
{
|
||||
m_LightSources.clear();
|
||||
|
||||
for(auto &job : scene.PointLightJobs) {
|
||||
for(auto &job : scene.Jobs.PointLight) {
|
||||
auto pointLightjob = std::dynamic_pointer_cast<PointLightJob>(job);
|
||||
if (pointLightjob) {
|
||||
LightSource p;
|
||||
@@ -97,7 +97,7 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
||||
m_LightSources.push_back(p);
|
||||
}
|
||||
}
|
||||
for(auto &job : scene.DirectionalLightJobs) {
|
||||
for(auto &job : scene.Jobs.DirectionalLight) {
|
||||
auto directionalLightJob = std::dynamic_pointer_cast<DirectionalLightJob>(job);
|
||||
if(directionalLightJob) {
|
||||
LightSource p;
|
||||
|
||||
@@ -56,7 +56,7 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
}
|
||||
m_Camera = scene.Camera;
|
||||
|
||||
for (auto &job : scene.OpaqueObjects) {
|
||||
for (auto &job : scene.Jobs.OpaqueObjects) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
|
||||
if (modelJob) {
|
||||
@@ -102,7 +102,99 @@ void PickingPass::Draw(RenderScene& scene)
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &job : scene.TransparentObjects) {
|
||||
for (auto &job : scene.Jobs.TransparentObjects) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
|
||||
if (modelJob) {
|
||||
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
||||
|
||||
PickingInfo pickInfo;
|
||||
pickInfo.Entity = modelJob->Entity;
|
||||
pickInfo.World = modelJob->World;
|
||||
pickInfo.Camera = scene.Camera;
|
||||
|
||||
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
||||
if (color != m_EntityColors.end()) {
|
||||
pickColor[0] = color->second[0];
|
||||
pickColor[1] = color->second[1];
|
||||
} else {
|
||||
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||
if (m_ColorCounter[0] > 255) {
|
||||
m_ColorCounter[0] = 0;
|
||||
m_ColorCounter[1] += 1;
|
||||
} else {
|
||||
m_ColorCounter[0] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
if (modelJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
}
|
||||
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &job : scene.Jobs.OpaqueShieldedObjects) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
|
||||
if (modelJob) {
|
||||
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
||||
|
||||
PickingInfo pickInfo;
|
||||
pickInfo.Entity = modelJob->Entity;
|
||||
pickInfo.World = modelJob->World;
|
||||
pickInfo.Camera = scene.Camera;
|
||||
|
||||
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
||||
if (color != m_EntityColors.end()) {
|
||||
pickColor[0] = color->second[0];
|
||||
pickColor[1] = color->second[1];
|
||||
} else {
|
||||
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||
if (m_ColorCounter[0] > 255) {
|
||||
m_ColorCounter[0] = 0;
|
||||
m_ColorCounter[1] += 1;
|
||||
} else {
|
||||
m_ColorCounter[0] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||
|
||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||
|
||||
if (modelJob->Animation != nullptr) {
|
||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||
}
|
||||
}
|
||||
|
||||
glBindVertexArray(modelJob->Model->VAO);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||
}
|
||||
}
|
||||
|
||||
for (auto &job : scene.Jobs.TransparentShieldedObjects) {
|
||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||
|
||||
if (modelJob) {
|
||||
|
||||
@@ -6,9 +6,10 @@ bool RenderState::Enable(GLenum cap)
|
||||
//LOG_WARNING("Trying to enable somthing that is already enabled.");
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ResetFunctions.push_back(std::bind(glDisable, cap));
|
||||
glEnable(cap);
|
||||
return !GLERROR("RenderState::Enable");
|
||||
return !GLERROR("Enable");
|
||||
}
|
||||
|
||||
bool RenderState::Disable(GLenum cap)
|
||||
@@ -16,9 +17,10 @@ bool RenderState::Disable(GLenum cap)
|
||||
if (!glIsEnabled(cap)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
m_ResetFunctions.push_back(std::bind(glEnable, cap));
|
||||
glDisable(cap);
|
||||
return !GLERROR("RenderState::Disable");
|
||||
return !GLERROR("Disable");
|
||||
}
|
||||
|
||||
bool RenderState::CullFace(GLenum mode)
|
||||
@@ -32,7 +34,7 @@ bool RenderState::CullFace(GLenum mode)
|
||||
glGetIntegerv(GL_CULL_FACE_MODE, &original);
|
||||
m_ResetFunctions.push_back(std::bind(glCullFace, original));
|
||||
glCullFace(mode);
|
||||
return !GLERROR("RenderState::CullFace");
|
||||
return !GLERROR("CullFace");
|
||||
}
|
||||
|
||||
bool RenderState::ClearColor(glm::vec4 color)
|
||||
@@ -41,7 +43,7 @@ bool RenderState::ClearColor(glm::vec4 color)
|
||||
glGetFloatv(GL_COLOR_CLEAR_VALUE, &original[0]);
|
||||
m_ResetFunctions.push_back(std::bind(glClearColor, original[0], original[1], original[2], original[3]));
|
||||
glClearColor(color.r, color.g, color.b, color.a);
|
||||
return !GLERROR("RenderState::ClearColor");
|
||||
return !GLERROR("ClearColor");
|
||||
}
|
||||
|
||||
bool RenderState::BindFramebuffer(GLint framebuffer)
|
||||
@@ -55,7 +57,7 @@ bool RenderState::BindFramebuffer(GLint framebuffer)
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, originalDraw);
|
||||
});
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);
|
||||
return !GLERROR("RenderState::BindBuffer");
|
||||
return !GLERROR("BindBuffer");
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +69,7 @@ bool RenderState::BlendEquation(GLenum mode)
|
||||
glGetIntegerv(GL_BLEND_EQUATION_ALPHA, &originalAlpha);
|
||||
m_ResetFunctions.push_back(std::bind(glBlendEquationSeparate, originalRGB, originalAlpha));
|
||||
glBlendEquation(mode);
|
||||
return !GLERROR("RenderState::BlendEquation");
|
||||
return !GLERROR("BlendEquation");
|
||||
}
|
||||
|
||||
bool RenderState::BlendFunc(GLenum sfactor, GLenum dfactor)
|
||||
@@ -82,7 +84,46 @@ bool RenderState::BlendFunc(GLenum sfactor, GLenum dfactor)
|
||||
glGetIntegerv(GL_BLEND_DST_ALPHA, &originalDestAlpha);
|
||||
m_ResetFunctions.push_back(std::bind(glBlendFuncSeparate, originalSrcRGB, originalSrcAlpha, originalDestRGB, originalDestAlpha));
|
||||
glBlendFunc(sfactor, dfactor);
|
||||
return !GLERROR("RenderState::BlendFunc");
|
||||
return !GLERROR("BlendFunc");
|
||||
}
|
||||
|
||||
|
||||
bool RenderState::StencilOp(GLenum sfail, GLenum dpfail, GLenum dppass)
|
||||
{
|
||||
GLint originalSFail;
|
||||
glGetIntegerv(GL_STENCIL_FAIL, &originalSFail);
|
||||
GLint originalDPFail;
|
||||
glGetIntegerv(GL_STENCIL_PASS_DEPTH_FAIL, &originalDPFail);
|
||||
GLint originalDPPass;
|
||||
glGetIntegerv(GL_STENCIL_PASS_DEPTH_PASS, &originalDPPass);
|
||||
m_ResetFunctions.push_back(std::bind(glStencilOp, originalSFail, originalDPFail, originalDPPass));
|
||||
glStencilOp(sfail, dpfail, dppass);
|
||||
return !GLERROR("StencilOp");
|
||||
}
|
||||
|
||||
|
||||
bool RenderState::StencilFunc(GLenum func, GLint ref, GLuint mask)
|
||||
{
|
||||
GLint originalFunc;
|
||||
glGetIntegerv(GL_STENCIL_FUNC, &originalFunc);
|
||||
GLint originalRef;
|
||||
glGetIntegerv(GL_STENCIL_REF, &originalRef);
|
||||
GLint originalMask;
|
||||
glGetIntegerv(GL_STENCIL_VALUE_MASK, &originalMask);
|
||||
m_ResetFunctions.push_back(std::bind(glStencilFunc, originalFunc, originalRef, originalMask));
|
||||
glStencilFunc(func, ref, mask);
|
||||
return !GLERROR("StencilFunc");
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool RenderState::StencilMask(GLuint mask)
|
||||
{
|
||||
GLint originalMask;
|
||||
glGetIntegerv(GL_STENCIL_WRITEMASK, &originalMask);
|
||||
m_ResetFunctions.push_back(std::bind(glStencilMask, mask));
|
||||
glStencilMask(mask);
|
||||
return !GLERROR("StencilMask");
|
||||
}
|
||||
|
||||
bool RenderState::DepthMask(GLboolean flag)
|
||||
@@ -91,12 +132,12 @@ bool RenderState::DepthMask(GLboolean flag)
|
||||
glGetBooleanv(GL_DEPTH_WRITEMASK, &original);
|
||||
m_ResetFunctions.push_back(std::bind(glDepthMask, original));
|
||||
glDepthMask(flag);
|
||||
return !GLERROR("RenderState::DepthMask");
|
||||
return !GLERROR("DepthMask");
|
||||
}
|
||||
|
||||
RenderState::~RenderState()
|
||||
{
|
||||
for (auto& f : m_ResetFunctions) {
|
||||
for (auto& f : boost::adaptors::reverse(m_ResetFunctions)) {
|
||||
f();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ bool RenderSystem::isChildOfCurrentCamera(EntityWrapper entity)
|
||||
return entity == m_CurrentCamera || entity.IsChildOf(m_CurrentCamera);
|
||||
}
|
||||
|
||||
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs)
|
||||
void RenderSystem::fillModels(RenderScene::Queues &Jobs)
|
||||
{
|
||||
auto models = m_World->GetComponents("Model");
|
||||
if (models == nullptr) {
|
||||
@@ -92,7 +92,9 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs,
|
||||
}
|
||||
|
||||
glm::mat4 modelMatrix = Transform::ModelMatrix(cModel.EntityID, m_World);
|
||||
//Loop through all materialgroups of a model
|
||||
for (auto matGroup : model->MaterialGroups()) {
|
||||
//If the model has an explosioneffect component, we will add an explosioneffectjob
|
||||
if (m_World->HasComponent(cModel.EntityID, "ExplosionEffect")) {
|
||||
auto explosionEffectComponent = m_World->GetComponent(cModel.EntityID, "ExplosionEffect");
|
||||
std::shared_ptr<ExplosionEffectJob> explosionEffectJob = std::shared_ptr<ExplosionEffectJob>(new ExplosionEffectJob(
|
||||
@@ -106,14 +108,30 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs,
|
||||
fillColor,
|
||||
fillPercentage
|
||||
));
|
||||
if(explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
|
||||
cModel["Transparent"] = true;
|
||||
}
|
||||
if (m_World->HasComponent(cModel.EntityID, "Shield")){
|
||||
Jobs.ShieldObjects.push_back(explosionEffectJob);
|
||||
} else if (m_World->HasComponent(cModel.EntityID, "Shielded")
|
||||
|| m_World->HasComponent(cModel.EntityID, "Player")) {
|
||||
|
||||
if (cModel["Transparent"]) {
|
||||
transparentJobs.push_back(explosionEffectJob);
|
||||
if (explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
|
||||
cModel["Transparent"] = true;
|
||||
}
|
||||
|
||||
if (cModel["Transparent"]) {
|
||||
Jobs.TransparentShieldedObjects.push_back(explosionEffectJob);
|
||||
} else {
|
||||
Jobs.OpaqueShieldedObjects.push_back(explosionEffectJob);
|
||||
}
|
||||
} else {
|
||||
opaqueJobs.push_back(explosionEffectJob);
|
||||
if (explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
|
||||
cModel["Transparent"] = true;
|
||||
}
|
||||
|
||||
if (cModel["Transparent"]) {
|
||||
Jobs.TransparentObjects.push_back(explosionEffectJob);
|
||||
} else {
|
||||
Jobs.OpaqueObjects.push_back(explosionEffectJob);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(
|
||||
@@ -126,13 +144,30 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs,
|
||||
fillColor,
|
||||
fillPercentage
|
||||
));
|
||||
if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) {
|
||||
cModel["Transparent"] = true;
|
||||
}
|
||||
if (cModel["Transparent"]) {
|
||||
transparentJobs.push_back(modelJob);
|
||||
if (m_World->HasComponent(cModel.EntityID, "Shield")) {
|
||||
Jobs.ShieldObjects.push_back(modelJob);
|
||||
} else if (m_World->HasComponent(cModel.EntityID, "Shielded")
|
||||
|| m_World->HasComponent(cModel.EntityID, "Player")) {
|
||||
|
||||
if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) {
|
||||
cModel["Transparent"] = true;
|
||||
}
|
||||
|
||||
if (cModel["Transparent"]) {
|
||||
Jobs.TransparentShieldedObjects.push_back(modelJob);
|
||||
} else {
|
||||
Jobs.OpaqueShieldedObjects.push_back(modelJob);
|
||||
}
|
||||
} else {
|
||||
opaqueJobs.push_back(modelJob);
|
||||
if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) {
|
||||
cModel["Transparent"] = true;
|
||||
}
|
||||
|
||||
if (cModel["Transparent"]) {
|
||||
Jobs.TransparentObjects.push_back(modelJob);
|
||||
} else {
|
||||
Jobs.OpaqueObjects.push_back(modelJob);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,10 +286,10 @@ void RenderSystem::Update(double dt)
|
||||
scene.AmbientColor = (glm::vec4)(*cSceneLight->begin())["AmbientColor"];
|
||||
}
|
||||
|
||||
fillModels(scene.OpaqueObjects, scene.TransparentObjects);
|
||||
fillPointLights(scene.PointLightJobs, m_World);
|
||||
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
||||
fillText(scene.TextJobs, m_World);
|
||||
fillModels(scene.Jobs);
|
||||
fillPointLights(scene.Jobs.PointLight, m_World);
|
||||
fillDirectionalLights(scene.Jobs.DirectionalLight, m_World);
|
||||
fillText(scene.Jobs.Text, m_World);
|
||||
m_RenderFrame->Add(scene);
|
||||
|
||||
}
|
||||
@@ -93,7 +93,7 @@ void Renderer::Update(double dt)
|
||||
|
||||
void Renderer::Draw(RenderFrame& frame)
|
||||
{
|
||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking");
|
||||
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking");
|
||||
//clear buffer 0
|
||||
glClearColor(0.f, 0.f, 0.f, 0.f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
@@ -120,7 +120,7 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
}
|
||||
m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture());
|
||||
if (m_DebugTextureToDraw == 0) {
|
||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), frame.Gamma, frame.Exposure);
|
||||
m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure);
|
||||
}
|
||||
if (m_DebugTextureToDraw == 1) {
|
||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture());
|
||||
@@ -129,9 +129,15 @@ void Renderer::Draw(RenderFrame& frame)
|
||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTexture());
|
||||
}
|
||||
if (m_DebugTextureToDraw == 3) {
|
||||
m_DrawScreenQuadPass->Draw(m_DrawBloomPass->GaussianTexture());
|
||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTextureLowRes());
|
||||
}
|
||||
if (m_DebugTextureToDraw == 4) {
|
||||
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTextureLowRes());
|
||||
}
|
||||
if (m_DebugTextureToDraw == 5) {
|
||||
m_DrawScreenQuadPass->Draw(m_DrawBloomPass->GaussianTexture());
|
||||
}
|
||||
if (m_DebugTextureToDraw == 6) {
|
||||
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
|
||||
}
|
||||
|
||||
@@ -154,7 +160,7 @@ void Renderer::InitializeTextures()
|
||||
void Renderer::SortRenderJobsByDepth(RenderScene &scene)
|
||||
{
|
||||
//Sort all forward jobs so transparency is good.
|
||||
scene.TransparentObjects.sort(Renderer::DepthSort);
|
||||
scene.Jobs.TransparentObjects.sort(Renderer::DepthSort);
|
||||
}
|
||||
|
||||
void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
|
||||
|
||||
@@ -35,7 +35,7 @@ void TextPass::Draw(RenderScene& scene, FrameBuffer& frameBuffer)
|
||||
{
|
||||
GLERROR("Derp1");
|
||||
TextPassState* state = new TextPassState(frameBuffer.GetHandle());
|
||||
for (auto &job : scene.TextJobs) {
|
||||
for (auto &job : scene.Jobs.Text) {
|
||||
auto textJob = std::dynamic_pointer_cast<TextJob>(job);
|
||||
if (textJob) {
|
||||
|
||||
|
||||
+3
-3
@@ -1,5 +1,5 @@
|
||||
#include "Game.h"
|
||||
#include "Collision/CollidableOctreeSystem.h"
|
||||
#include "Collision/FillOctreeSystem.h"
|
||||
#include "Collision/EntityAABB.h"
|
||||
#include "Collision/TriggerSystem.h"
|
||||
#include "Collision/CollisionSystem.h"
|
||||
@@ -100,8 +100,8 @@ Game::Game(int argc, char* argv[])
|
||||
m_SystemPipeline->AddSystem<PickupSpawnSystem>(updateOrderLevel);
|
||||
// Populate Octree with collidables
|
||||
++updateOrderLevel;
|
||||
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||
m_SystemPipeline->AddSystem<CollidableOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
|
||||
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
|
||||
m_SystemPipeline->AddSystem<PlayerHUD>(updateOrderLevel);
|
||||
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
int blueTeamPlayersStandingInside = 0;
|
||||
if (capturePointEntity.HasComponent("Model")) {
|
||||
//Now sets team color to the capturepoint, or white if it is uncaptured.
|
||||
capturePointEntity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.2f, 1, 1) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 1) : glm::vec4(1, 1, 1, 1);
|
||||
capturePointEntity["Model"]["Color"] = ownedBy == blueTeam ? glm::vec4(0, 0.2f, 1, 0.3) : ownedBy == redTeam ? glm::vec4(1, 0.2f, 0, 0.3) : glm::vec4(1, 1, 1, 0.3);
|
||||
}
|
||||
|
||||
//calculate next possible capturePoint for both teams
|
||||
@@ -106,10 +106,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
|
||||
|
||||
//colorize next possible capturepoint
|
||||
if (nextPossibleCapturePoint["Red"] == capturePointNumber) {
|
||||
capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 1);
|
||||
capturePointEntity["Model"]["Color"] = glm::vec4(1, 1, 0, 0.3);
|
||||
}
|
||||
if (nextPossibleCapturePoint["Blue"] == capturePointNumber) {
|
||||
capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 1);
|
||||
capturePointEntity["Model"]["Color"] = glm::vec4(0, 1, 1, 0.3);
|
||||
}
|
||||
|
||||
//check how many players are standing inside and are healthy
|
||||
|
||||
@@ -103,7 +103,7 @@ void PlayerMovementSystem::Update(double dt)
|
||||
Events::DoubleJump e;
|
||||
m_EventBroker->Publish(e);
|
||||
}
|
||||
velocity.y += 4.f;
|
||||
velocity.y = 4.f;
|
||||
}
|
||||
|
||||
if (player.HasComponent("AABB")) {
|
||||
|
||||
Reference in New Issue
Block a user