Compare commits

..

2 Commits

Author SHA1 Message Date
Teejoon a806f9b1e3 WIP 2016-03-01 12:04:26 +01:00
Teejoon 22748f6594 Merge branch 'master' of https://github.com/teamfisk/TacticalZ into RenderSettings
Conflicts:
	src/Engine/Rendering/CubeMapPass.cpp
2016-02-29 11:46:08 +01:00
34 changed files with 570 additions and 1356 deletions
@@ -17,7 +17,7 @@ public:
void InitializeFrameBuffers(); void InitializeFrameBuffers();
void InitializeShaderPrograms(); 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: private:
const IRenderer* m_Renderer; const IRenderer* m_Renderer;
+22 -21
View File
@@ -15,7 +15,7 @@
class DrawFinalPass class DrawFinalPass
{ {
public: public:
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass); DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer);
~DrawFinalPass() { } ~DrawFinalPass() { }
void InitializeTextures(); void InitializeTextures();
void InitializeFrameBuffers(); void InitializeFrameBuffers();
@@ -26,17 +26,22 @@ public:
//Return the texture that is used in later stages to apply the bloom effect //Return the texture that is used in later stages to apply the bloom effect
GLuint BloomTexture() const { return m_BloomTexture; } GLuint BloomTexture() const { return m_BloomTexture; }
GLuint BloomTextureLowRes() const { return m_BloomTextureLowRes; }
//Return the texture with diffuse and lighting of the scene. //Return the texture with diffuse and lighting of the scene.
GLuint SceneTexture() const { return m_SceneTexture; } GLuint SceneTexture() const { return m_SceneTexture; }
GLuint SceneTextureLowRes() const { return m_SceneTextureLowRes; }
//Return the framebuffer used in the scene rendering stage. //Return the framebuffer used in the scene rendering stage.
FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; } FrameBuffer* FinalPassFrameBuffer() { return &m_FinalPassFrameBuffer; }
FrameBuffer* FinalPassFrameBufferLowRes() { return &m_FinalPassFrameBufferLowRes; }
private: private:
void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene); void DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, RenderScene& scene);
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene); void DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene);
void MergeLayers();
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene); void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene); void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
@@ -50,12 +55,17 @@ private:
Texture* m_GreyTexture; Texture* m_GreyTexture;
Texture* m_ErrorTexture; Texture* m_ErrorTexture;
Model* m_ScreenQuad;
FrameBuffer m_MergeFrameBuffer;
FrameBuffer m_FinalPassFrameBuffer; FrameBuffer m_FinalPassFrameBuffer;
FrameBuffer m_ShieldDepthFrameBuffer; FrameBuffer m_FinalPassFrameBufferLowRes;
GLuint m_BloomTexture; GLuint m_BloomTexture;
GLuint m_SceneTexture; GLuint m_SceneTexture;
GLuint m_DepthBuffer; GLuint m_BloomTextureLowRes;
GLuint m_ShieldBuffer; GLuint m_SceneTextureLowRes;
GLuint* m_DepthBuffer;
GLuint m_DepthBufferLowRes;
GLuint m_CubeMapTexture; GLuint m_CubeMapTexture;
//maqke this component based i guess? //maqke this component based i guess?
@@ -66,32 +76,23 @@ private:
const CubeMapPass* m_CubeMapPass; const CubeMapPass* m_CubeMapPass;
const SSAOPass* m_SSAOPass; const SSAOPass* m_SSAOPass;
ShaderProgram* m_MergeProgram;
ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ForwardPlusProgram;
ShaderProgram* m_ExplosionEffectProgram; ShaderProgram* m_ExplosionEffectProgram;
ShaderProgram* m_ExplosionEffectSplatMapProgram; ShaderProgram* m_ExplosionEffectSplatMapProgram;
ShaderProgram* m_SpriteProgram; ShaderProgram* m_SpriteProgram;
ShaderProgram* m_ForwardPlusSplatMapProgram; ShaderProgram* m_ForwardPlusSplatMapProgram;
ShaderProgram* m_FillDepthStencilBufferProgram; ShaderProgram* m_ShieldToStencilProgram;
ShaderProgram* m_FillDepthBufferProgram;
ShaderProgram* m_ForwardPlusShieldCheckProgram;
ShaderProgram* m_ExplosionEffectShieldCheckProgram;
ShaderProgram* m_ExplosionEffectSplatMapShieldCheckProgram;
ShaderProgram* m_SpriteShieldCheckProgram;
ShaderProgram* m_ForwardPlusSplatMapShieldCheckProgram;
ShaderProgram* m_ForwardPlusSkinnedProgram; ShaderProgram* m_ForwardPlusSkinnedProgram;
ShaderProgram* m_ExplosionEffectSkinnedProgram; ShaderProgram* m_ExplosionEffectSkinnedProgram;
ShaderProgram* m_ExplosionEffectSplatMapSkinnedProgram; ShaderProgram* m_ExplosionEffectSplatMapSkinnedProgram;
ShaderProgram* m_ForwardPlusSplatMapSkinnedProgram; ShaderProgram* m_ForwardPlusSplatMapSkinnedProgram;
ShaderProgram* m_FillDepthStencilBufferSkinnedProgram; ShaderProgram* m_ShieldToStencilSkinnedProgram;
ShaderProgram* m_FillDepthBufferSkinnedProgram;
ShaderProgram* m_ForwardPlusSkinnedShieldCheckProgram;
ShaderProgram* m_ExplosionEffectSkinnedShieldCheckProgram;
ShaderProgram* m_ExplosionEffectSplatMapSkinnedShieldCheckProgram;
ShaderProgram* m_ForwardPlusSplatMapSkinnedShieldCheckProgram;
ShaderProgram* m_FillDepthBufferSkinnedShieldCheckProgram;
}; };
#endif #endif
@@ -15,8 +15,8 @@
struct ExplosionEffectJob : ModelJob struct ExplosionEffectJob : ModelJob
{ {
ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage, bool isShielded) ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage)
: ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage, isShielded) : ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage)
{ {
ExplosionOrigin = (glm::vec3)explosionEffectComponent["ExplosionOrigin"]; ExplosionOrigin = (glm::vec3)explosionEffectComponent["ExplosionOrigin"];
TimeSinceDeath = (double)explosionEffectComponent["TimeSinceDeath"]; TimeSinceDeath = (double)explosionEffectComponent["TimeSinceDeath"];
+3 -3
View File
@@ -18,7 +18,7 @@
struct ModelJob : RenderJob struct ModelJob : RenderJob
{ {
ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matProp, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage, bool isShielded) ModelJob(Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialProperties matProp, ComponentWrapper modelComponent, World* world, glm::vec4 fillColor, float fillPercentage)
: RenderJob() : RenderJob()
{ {
Model = model; Model = model;
@@ -117,7 +117,7 @@ struct ModelJob : RenderJob
FillColor = fillColor; FillColor = fillColor;
FillPercentage = fillPercentage; FillPercentage = fillPercentage;
IsShielded = isShielded;
if (model->IsSkinned()) { if (model->IsSkinned()) {
Skeleton = Model->m_RawModel->m_Skeleton; Skeleton = Model->m_RawModel->m_Skeleton;
@@ -181,7 +181,7 @@ struct ModelJob : RenderJob
glm::vec4 FillColor = glm::vec4(0); glm::vec4 FillColor = glm::vec4(0);
float FillPercentage = 0.0; float FillPercentage = 0.0;
bool IsShielded;
void CalculateHash() override void CalculateHash() override
{ {
Hash = ShaderID << 20 + ModelID << 10 + TextureID; Hash = ShaderID << 20 + ModelID << 10 + TextureID;
+2
View File
@@ -24,6 +24,7 @@ struct RenderScene
std::list<std::shared_ptr<RenderJob>> OpaqueObjects; std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
std::list<std::shared_ptr<RenderJob>> TransparentObjects; std::list<std::shared_ptr<RenderJob>> TransparentObjects;
std::list<std::shared_ptr<RenderJob>> OpaqueShieldedObjects; 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>> ShieldObjects;
std::list<std::shared_ptr<RenderJob>> SpriteJob; std::list<std::shared_ptr<RenderJob>> SpriteJob;
std::list<std::shared_ptr<RenderJob>> PointLight; std::list<std::shared_ptr<RenderJob>> PointLight;
@@ -40,6 +41,7 @@ struct RenderScene
Jobs.OpaqueObjects.clear(); Jobs.OpaqueObjects.clear();
Jobs.TransparentObjects.clear(); Jobs.TransparentObjects.clear();
Jobs.OpaqueShieldedObjects.clear(); Jobs.OpaqueShieldedObjects.clear();
Jobs.TransparentShieldedObjects.clear();
Jobs.ShieldObjects.clear(); Jobs.ShieldObjects.clear();
Jobs.SpriteJob.clear(); Jobs.SpriteJob.clear();
Jobs.DirectionalLight.clear(); Jobs.DirectionalLight.clear();
+4 -2
View File
@@ -14,6 +14,8 @@ public:
virtual void Update(double dt) override; virtual void Update(double dt) override;
static void SetRespawnTime(float respawnTime) { m_RespawnTime = respawnTime; };
private: private:
struct SpawnRequest struct SpawnRequest
{ {
@@ -29,8 +31,8 @@ private:
//EntityWrapper ID -> Player ID. //EntityWrapper ID -> Player ID.
std::map<EntityID, int> m_PlayerIDs; std::map<EntityID, int> m_PlayerIDs;
float m_ForcedRespawnTime; static float m_RespawnTime;
bool m_DbgConfigForceRespawn; float m_Timer;
EventRelay<PlayerSpawnSystem, Events::InputCommand> m_OnInputCommand; EventRelay<PlayerSpawnSystem, Events::InputCommand> m_OnInputCommand;
bool OnInputCommand(Events::InputCommand& e); bool OnInputCommand(Events::InputCommand& e);
+1 -13
View File
@@ -68,17 +68,5 @@ Contrast=1.5
Intensity=1.0 Intensity=1.0
NumSamples=24 NumSamples=24
NumTurns=17 NumTurns=17
NumIterations=9
TextureQuality=0
[GLOW]
Quality=3;
[GLOW1]
NumIterations=5
[GLOW2]
NumIterations=9
[GLOW3]
NumIterations=13 NumIterations=13
TextureQuality=0
-2
View File
@@ -46,8 +46,6 @@
<xs:include schemaLocation="Components/Page.xsd"/> <xs:include schemaLocation="Components/Page.xsd"/>
<xs:include schemaLocation="Components/SpriteIndicator.xsd"/> <xs:include schemaLocation="Components/SpriteIndicator.xsd"/>
<xs:include schemaLocation="Components/Button.xsd"/> <xs:include schemaLocation="Components/Button.xsd"/>
<xs:include schemaLocation="Components/DoubleJump.xsd"/>
<xs:include schemaLocation="Components/WeaponAttachment.xsd"/> <xs:include schemaLocation="Components/WeaponAttachment.xsd"/>
<xs:include schemaLocation="Components/DefenderWeapon.xsd"/> <xs:include schemaLocation="Components/DefenderWeapon.xsd"/>
<xs:include schemaLocation="Components/CapturePointGameMode.xsd"/>
</xs:schema> </xs:schema>
@@ -1,5 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<CapturePointGameMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="CapturePointGameMode.xsd">
<RespawnTime>0.0</RespawnTime>
<MaxRespawnTime>8.0</MaxRespawnTime>
</CapturePointGameMode>
@@ -1,18 +0,0 @@
<?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="CapturePointGameMode">
<xs:complexType>
<xs:all>
<xs:element name="RespawnTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>The time since the last respawn wave. Players will be spawned when this reaches MaxRespawnTime.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="MaxRespawnTime" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Players will be spawned when RespawnTime reaches this.</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
@@ -1,4 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<DoubleJump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="DoubleJump.xsd">
<DoubleJumpSpeed>4.0</DoubleJumpSpeed>
</DoubleJump>
@@ -1,16 +0,0 @@
<?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="DoubleJump">
<xs:annotation><xs:documentation>Enables a Player to double jump.</xs:documentation></xs:annotation>
<xs:complexType>
<xs:all>
<xs:element name="DoubleJumpSpeed" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Vertical velocity set on double jump.</xs:documentation></xs:annotation>
</xs:element>
</xs:all>
</xs:complexType>
</xs:element>
</xs:schema>
-1
View File
@@ -2,7 +2,6 @@
<Player xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Player.xsd"> <Player xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Player.xsd">
<MovementSpeed>3</MovementSpeed> <MovementSpeed>3</MovementSpeed>
<CrouchSpeed>1.5</CrouchSpeed> <CrouchSpeed>1.5</CrouchSpeed>
<JumpSpeed>4.0</JumpSpeed>
<CurrentWishDirection X="0" Y="0" Z="0"/> <CurrentWishDirection X="0" Y="0" Z="0"/>
<CurrentWeapon></CurrentWeapon> <CurrentWeapon></CurrentWeapon>
</Player> </Player>
-3
View File
@@ -11,9 +11,6 @@
<xs:all> <xs:all>
<xs:element name="MovementSpeed" type="t:float" minOccurs="0"/> <xs:element name="MovementSpeed" type="t:float" minOccurs="0"/>
<xs:element name="CrouchSpeed" type="t:float" minOccurs="0"/> <xs:element name="CrouchSpeed" type="t:float" minOccurs="0"/>
<xs:element name="JumpSpeed" type="t:float" minOccurs="0">
<xs:annotation><xs:documentation>Vertical velocity set when jumping.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="CurrentWishDirection" type="t:Vector" minOccurs="0"/> <xs:element name="CurrentWishDirection" type="t:Vector" minOccurs="0"/>
<xs:element name="CurrentWeapon" type="t:string" minOccurs="0"/> <xs:element name="CurrentWeapon" type="t:string" minOccurs="0"/>
</xs:all> </xs:all>
+18 -26
View File
@@ -13,9 +13,8 @@
</c:AssaultWeapon> </c:AssaultWeapon>
<c:Collidable/> <c:Collidable/>
<c:DefenderWeapon> <c:DefenderWeapon>
<TimeSinceLastFire>52.867678870419283</TimeSinceLastFire> <TimeSinceLastFire>1.6944730461160304</TimeSinceLastFire>
</c:DefenderWeapon> </c:DefenderWeapon>
<c:DoubleJump/>
<c:Health/> <c:Health/>
<c:Physics> <c:Physics>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/> <Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
@@ -37,10 +36,7 @@
<Children> <Children>
<Entity name="Camera"> <Entity name="Camera">
<Components> <Components>
<c:Camera> <c:Camera/>
<NearClip>0.10000000149011612</NearClip>
<FarClip>300</FarClip>
</c:Camera>
<c:Transform> <c:Transform>
<Position X="0" Y="1.27700007" Z="0"/> <Position X="0" Y="1.27700007" Z="0"/>
</c:Transform> </c:Transform>
@@ -375,7 +371,7 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>1.9408570429715581</Time1> <Time1>0.67172915251515519</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -389,25 +385,25 @@
<Children> <Children>
<Entity name="PrimaryAttachment"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:WeaponAttachment>
<Weapon>DefenderWeapon</Weapon>
</c:WeaponAttachment>
<c:Spawner> <c:Spawner>
<EntityFile>Schema/Entities/DefenderWeaponView.xml</EntityFile> <EntityFile>Schema/Entities/DefenderWeaponView.xml</EntityFile>
</c:Spawner> </c:Spawner>
<c:Transform/> <c:Transform/>
<c:WeaponAttachment>
<Weapon>DefenderWeapon</Weapon>
</c:WeaponAttachment>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="SecondaryAttachment"> <Entity name="SecondaryAttachment">
<Components> <Components>
<c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon>
</c:WeaponAttachment>
<c:Spawner> <c:Spawner>
<EntityFile>Schema/Entities/AssaultWeaponView.xml</EntityFile> <EntityFile>Schema/Entities/AssaultWeaponView.xml</EntityFile>
</c:Spawner> </c:Spawner>
<c:Transform/> <c:Transform/>
<c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon>
</c:WeaponAttachment>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
@@ -417,10 +413,7 @@
</Entity> </Entity>
<Entity name="ThirdPersonCamera"> <Entity name="ThirdPersonCamera">
<Components> <Components>
<c:Camera> <c:Camera/>
<NearClip>0.10000000149011612</NearClip>
<FarClip>300</FarClip>
</c:Camera>
<c:Model> <c:Model>
<Resource>Models/Widgets/Camera.mesh</Resource> <Resource>Models/Widgets/Camera.mesh</Resource>
<Visible>false</Visible> <Visible>false</Visible>
@@ -436,7 +429,6 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>1.5631122524686134</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -456,31 +448,31 @@
<Children> <Children>
<Entity name="PrimaryAttachment"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:Spawner>
<EntityFile>Schema/Entities/DefenderWeaponWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
<c:WeaponAttachment> <c:WeaponAttachment>
<Weapon>DefenderWeapon</Weapon> <Weapon>DefenderWeapon</Weapon>
<Person> <Person>
<ThirdPerson/> <ThirdPerson/>
</Person> </Person>
</c:WeaponAttachment> </c:WeaponAttachment>
<c:Spawner>
<EntityFile>Schema/Entities/DefenderWeaponWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="SecondaryAttachment"> <Entity name="SecondaryAttachment">
<Components> <Components>
<c:Spawner>
<EntityFile>Schema/Entities/AssaultWeaponWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
<c:WeaponAttachment> <c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon> <Weapon>AssaultWeapon</Weapon>
<Person> <Person>
<ThirdPerson/> <ThirdPerson/>
</Person> </Person>
</c:WeaponAttachment> </c:WeaponAttachment>
<c:Spawner>
<EntityFile>Schema/Entities/AssaultWeaponWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
+18 -26
View File
@@ -13,9 +13,8 @@
</c:AssaultWeapon> </c:AssaultWeapon>
<c:Collidable/> <c:Collidable/>
<c:DefenderWeapon> <c:DefenderWeapon>
<TimeSinceLastFire>22.22055262342397</TimeSinceLastFire> <TimeSinceLastFire>1.6944730461160304</TimeSinceLastFire>
</c:DefenderWeapon> </c:DefenderWeapon>
<c:DoubleJump/>
<c:Health/> <c:Health/>
<c:Physics> <c:Physics>
<Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/> <Velocity X="2.30999646e-23" Y="0" Z="1.05272533e-23"/>
@@ -37,10 +36,7 @@
<Children> <Children>
<Entity name="Camera"> <Entity name="Camera">
<Components> <Components>
<c:Camera> <c:Camera/>
<NearClip>0.10000000149011612</NearClip>
<FarClip>300</FarClip>
</c:Camera>
<c:Transform> <c:Transform>
<Position X="0" Y="1.27700007" Z="0"/> <Position X="0" Y="1.27700007" Z="0"/>
</c:Transform> </c:Transform>
@@ -375,7 +371,7 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>1.1978087298230946</Time1> <Time1>0.67172915251515519</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -389,25 +385,25 @@
<Children> <Children>
<Entity name="PrimaryAttachment"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:WeaponAttachment>
<Weapon>DefenderWeapon</Weapon>
</c:WeaponAttachment>
<c:Spawner> <c:Spawner>
<EntityFile>Schema/Entities/DefenderWeaponViewRed.xml</EntityFile> <EntityFile>Schema/Entities/DefenderWeaponViewRed.xml</EntityFile>
</c:Spawner> </c:Spawner>
<c:Transform/> <c:Transform/>
<c:WeaponAttachment>
<Weapon>DefenderWeapon</Weapon>
</c:WeaponAttachment>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="SecondaryAttachment"> <Entity name="SecondaryAttachment">
<Components> <Components>
<c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon>
</c:WeaponAttachment>
<c:Spawner> <c:Spawner>
<EntityFile>Schema/Entities/AssaultWeaponView.xml</EntityFile> <EntityFile>Schema/Entities/AssaultWeaponView.xml</EntityFile>
</c:Spawner> </c:Spawner>
<c:Transform/> <c:Transform/>
<c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon>
</c:WeaponAttachment>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
@@ -417,10 +413,7 @@
</Entity> </Entity>
<Entity name="ThirdPersonCamera"> <Entity name="ThirdPersonCamera">
<Components> <Components>
<c:Camera> <c:Camera/>
<NearClip>0.10000000149011612</NearClip>
<FarClip>300</FarClip>
</c:Camera>
<c:Model> <c:Model>
<Resource>Models/Widgets/Camera.mesh</Resource> <Resource>Models/Widgets/Camera.mesh</Resource>
<Visible>false</Visible> <Visible>false</Visible>
@@ -436,7 +429,6 @@
<Components> <Components>
<c:Animation> <c:Animation>
<AnimationName1>Idle</AnimationName1> <AnimationName1>Idle</AnimationName1>
<Time1>0.69274608502888668</Time1>
<Speed1>1</Speed1> <Speed1>1</Speed1>
<AnimationName2></AnimationName2> <AnimationName2></AnimationName2>
<AnimationName3></AnimationName3> <AnimationName3></AnimationName3>
@@ -456,31 +448,31 @@
<Children> <Children>
<Entity name="PrimaryAttachment"> <Entity name="PrimaryAttachment">
<Components> <Components>
<c:Spawner>
<EntityFile>Schema/Entities/DefenderWeaponWorldRed.xml</EntityFile>
</c:Spawner>
<c:Transform/>
<c:WeaponAttachment> <c:WeaponAttachment>
<Weapon>DefenderWeapon</Weapon> <Weapon>DefenderWeapon</Weapon>
<Person> <Person>
<ThirdPerson/> <ThirdPerson/>
</Person> </Person>
</c:WeaponAttachment> </c:WeaponAttachment>
<c:Spawner>
<EntityFile>Schema/Entities/DefenderWeaponWorldRed.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
<Entity name="SecondaryAttachment"> <Entity name="SecondaryAttachment">
<Components> <Components>
<c:Spawner>
<EntityFile>Schema/Entities/AssaultWeaponWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
<c:WeaponAttachment> <c:WeaponAttachment>
<Weapon>AssaultWeapon</Weapon> <Weapon>AssaultWeapon</Weapon>
<Person> <Person>
<ThirdPerson/> <ThirdPerson/>
</Person> </Person>
</c:WeaponAttachment> </c:WeaponAttachment>
<c:Spawner>
<EntityFile>Schema/Entities/AssaultWeaponWorld.xml</EntityFile>
</c:Spawner>
<c:Transform/>
</Components> </Components>
<Children/> <Children/>
</Entity> </Entity>
@@ -2,6 +2,8 @@
layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 0) uniform sampler2D SceneTexture;
layout (binding = 1) uniform sampler2D BloomTexture; layout (binding = 1) uniform sampler2D BloomTexture;
layout (binding = 2) uniform sampler2D SceneTextureLowRes;
layout (binding = 3) uniform sampler2D BloomTextureLowRes;
uniform float Exposure; uniform float Exposure;
uniform float Gamma; uniform float Gamma;
@@ -15,12 +17,21 @@ void main()
{ {
vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate); vec4 hdrColor = texture(SceneTexture, Input.TextureCoordinate);
vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate);
vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate);
vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate);
//hdrColor = hdrColor * SSAO; //hdrColor = hdrColor * SSAO;
hdrColor += bloomColor; hdrColor += bloomColor;
hdrColorLowRes;
float hdrColorsum = hdrColorLowRes.r + hdrColorLowRes.g + hdrColorLowRes.b;
//Toon mapping thingy //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 //gamme correction
result = pow(result, vec3(1.0 / Gamma)); result = pow(result, vec3(1.0 / Gamma));
+3 -4
View File
@@ -171,8 +171,7 @@ void main()
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)); color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0; float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0;
vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a; color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2;
color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal;
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
@@ -183,9 +182,9 @@ void main()
} }
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//sceneColor = vec4(reflectionColor.xyz, 1); //sceneColor = vec4(reflectionColor.xyz, 1);
color_result.xyz += glowTexel.xyz*GlowIntensity; color_result += glowTexel*GlowIntensity;
bloomColor = vec4(max(color_result.xyz - 1.0, 0.0), clamp(color_result.a, 0, 1)); bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1));
//Tiled Debug Code //Tiled Debug Code
/* /*
@@ -1,207 +0,0 @@
#version 430
#define MIN_AMBIENT_LIGHT 0.3
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec4 Color;
uniform vec4 DiffuseColor;
uniform vec2 ScreenDimensions;
uniform vec4 FillColor;
uniform vec4 AmbientColor;
uniform float FillPercentage;
uniform float GlowIntensity = 10;
uniform vec3 CameraPosition;
uniform int SSAOQuality;
uniform vec2 DiffuseUVRepeat;
uniform vec2 NormalUVRepeat;
uniform vec2 SpecularUVRepeat;
uniform vec2 GlowUVRepeat;
layout (binding = 0) uniform sampler2D AOTexture;
layout (binding = 1) uniform sampler2D DiffuseTexture;
layout (binding = 2) uniform sampler2D NormalMapTexture;
layout (binding = 3) uniform sampler2D SpecularMapTexture;
layout (binding = 4) uniform sampler2D GlowMapTexture;
layout (binding = 5) uniform samplerCube CubeMap;
layout (binding = 31) uniform sampler2D ShieldBuffer;
#define TILE_SIZE 16
struct LightSource {
vec4 Position;
vec4 Direction;
vec4 Color;
float Radius;
float Intensity;
float Falloff;
int Type;
};
layout (std430, binding = 1) buffer LightBuffer
{
LightSource List[];
} LightSources;
struct LightGrid {
float Start;
float Amount;
vec2 Padding;
};
layout (std430, binding = 2) buffer LightGridBuffer
{
LightGrid Data[];
} LightGrids;
layout (std430, binding = 4) buffer LightIndexBuffer
{
float LightIndex[];
};
in VertexData{
vec3 Position;
vec3 Normal;
vec3 Tangent;
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 ExplosionColor;
float ExplosionPercentageElapsed;
}Input;
out vec4 sceneColor;
out vec4 bloomColor;
struct LightResult {
vec4 Diffuse;
vec4 Specular;
};
float CalcAttenuation(float radius, float dist, float falloff) {
return 1.0 - smoothstep(radius * falloff, radius, dist);
}
vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) {
vec4 R = normalize( reflect(-lightVec, normal));
float RdotV = max( dot(R, viewVec), 0.0);
return lightColor * pow(RdotV, 90.0);
}
vec4 CalcDiffuse(vec4 lightColor, vec4 lightVec, vec4 normal) {
float power = max( dot(normal, lightVec), 0.0);
return lightColor * power;
}
LightResult CalcPointLightSource(vec4 lightPos, float lightRadius, vec4 lightColor, float intensity, vec4 viewVec, vec4 position, vec4 normal, float falloff)
{
vec4 L = lightPos - position;
float dist = length(L);
L = normalize(L);
float attenuation = CalcAttenuation(lightRadius, dist, falloff);
LightResult result;
result.Diffuse = CalcDiffuse(lightColor, L, normal) * attenuation * intensity;
result.Specular = CalcSpecular(lightColor, viewVec, L, normal) * attenuation * intensity;
return result;
}
LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensity, vec4 viewVec, vec4 vertNormal)
{
vec4 L = normalize( -vec4(direction.xyz, 0) );
LightResult result;
result.Diffuse = CalcDiffuse(color, L, vertNormal) * intensity;
result.Specular = CalcSpecular(color, viewVec, L, vertNormal) * intensity;
return result;
}
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
{
mat3 TBN = mat3(tangent, bitangent, normal);
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
return vec4(TBN * normalize(NormalMap), 0.0);
}
void main()
{
float shieldDepthValue = texelFetch(ShieldBuffer, ivec2(gl_FragCoord.xy), 0).r;
if(shieldDepthValue < gl_FragCoord.z){
discard;
}
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
vec4 position = V * M * vec4(Input.Position, 1.0);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-position);
vec3 I = normalize(vec3(M * vec4(Input.Position, 1.0)) - CameraPosition);
vec3 R = reflect(-I, Input.Normal);
//R = vec3(P * vec4(R, 1.0));
vec4 reflectionColor = texture(CubeMap, R);
vec2 tilePos;
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
LightResult totalLighting;
totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0);
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
int start = int(LightGrids.Data[currentTile].Start);
int amount = int(LightGrids.Data[currentTile].Amount);
for(int i = start; i < start + amount; i++) {
int l = int(LightIndex[i]);
LightSource light = LightSources.List[l];
LightResult light_result;
//These if statements should be removed.
if(light.Type == 1) { // point
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
} else if (light.Type == 2) { //Directional
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
}
totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a);
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
}
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
float specularResult = (specularTexel.r + specularTexel.g + specularTexel.b)/3.0;
vec4 reflectionTotal = reflectionColor * (1-specularTexel.a) * color_result.a;
color_result = color_result * clamp(1/specularTexel.a, 0, 1) + reflectionTotal;
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
if(pos <= FillPercentage) {
color_result += FillColor;
}
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//sceneColor = vec4(reflectionColor.xyz, 1);
color_result.xyz += glowTexel.xyz*GlowIntensity;
bloomColor = vec4(max(color_result.xyz - 1.0, 0.0), clamp(color_result.a, 0, 1));
//Tiled Debug Code
/*
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) {
sceneColor += vec4(0.5, 0, 0, 0);
} else {
sceneColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1);
}
*/
}
@@ -1,254 +0,0 @@
#version 430
#define MIN_AMBIENT_LIGHT 0.3
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform vec2 ScreenDimensions;
uniform float FillPercentage;
uniform vec4 DiffuseColor;
uniform vec4 FillColor;
uniform vec4 Color;
uniform vec4 AmbientColor;
uniform int SSAOQuality;
//Get bineded at the same time as the textures
uniform vec2 DiffuseUVRepeat1;
uniform vec2 DiffuseUVRepeat2;
uniform vec2 DiffuseUVRepeat3;
uniform vec2 NormalUVRepeat1;
uniform vec2 NormalUVRepeat2;
uniform vec2 NormalUVRepeat3;
uniform vec2 SpecularUVRepeat1;
uniform vec2 SpecularUVRepeat2;
uniform vec2 SpecularUVRepeat3;
uniform vec2 GlowUVRepeat1;
uniform vec2 GlowUVRepeat2;
uniform vec2 GlowUVRepeat3;
layout (binding = 0) uniform sampler2D AOTexture;
layout (binding = 1) uniform sampler2D SplatMapTexture;
layout (binding = 2) uniform sampler2D DiffuseTexture1;
layout (binding = 3) uniform sampler2D DiffuseTexture2;
layout (binding = 4) uniform sampler2D DiffuseTexture3;
layout (binding = 5) uniform sampler2D NormalMapTexture1;
layout (binding = 6) uniform sampler2D NormalMapTexture2;
layout (binding = 7) uniform sampler2D NormalMapTexture3;
layout (binding = 8) uniform sampler2D SpecularMapTexture1;
layout (binding = 9) uniform sampler2D SpecularMapTexture2;
layout (binding = 10) uniform sampler2D SpecularMapTexture3;
layout (binding = 11) uniform sampler2D GlowMapTexture1;
layout (binding = 12) uniform sampler2D GlowMapTexture2;
layout (binding = 13) uniform sampler2D GlowMapTexture3;
layout (binding = 13) uniform sampler2D GlowMapTexture3;
layout (binding = 31) uniform samplerCube ShieldBuffer;
#define TILE_SIZE 16
struct LightSource {
vec4 Position;
vec4 Direction;
vec4 Color;
float Radius;
float Intensity;
float Falloff;
int Type;
};
layout (std430, binding = 1) buffer LightBuffer
{
LightSource List[];
} LightSources;
struct LightGrid {
float Start;
float Amount;
vec2 Padding;
};
layout (std430, binding = 2) buffer LightGridBuffer
{
LightGrid Data[];
} LightGrids;
layout (std430, binding = 4) buffer LightIndexBuffer
{
float LightIndex[];
};
in VertexData{
vec3 Position;
vec3 Normal;
vec3 Tangent;
vec3 BiTangent;
vec2 TextureCoordinate;
vec4 ExplosionColor;
float ExplosionPercentageElapsed;
}Input;
out vec4 sceneColor;
out vec4 bloomColor;
struct LightResult {
vec4 Diffuse;
vec4 Specular;
};
float CalcAttenuation(float radius, float dist, float falloff) {
return 1.0 - smoothstep(radius * 0.3, radius, dist);
}
vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) {
vec4 R = normalize( reflect(-lightVec, normal));
float RdotV = max( dot(R, viewVec), 0.0);
return lightColor * pow(RdotV, 90.0);
}
vec4 CalcDiffuse(vec4 lightColor, vec4 lightVec, vec4 normal) {
float power = max( dot(normal, lightVec), 0.0);
return lightColor * power;
}
LightResult CalcPointLightSource(vec4 lightPos, float lightRadius, vec4 lightColor, float intensity, vec4 viewVec, vec4 position, vec4 normal, float falloff)
{
vec4 L = lightPos - position;
float dist = length(L);
L = normalize(L);
float attenuation = CalcAttenuation(lightRadius, dist, falloff);
LightResult result;
result.Diffuse = CalcDiffuse(lightColor, L, normal) * attenuation * intensity;
result.Specular = CalcSpecular(lightColor, viewVec, L, normal) * attenuation * intensity;
return result;
}
LightResult CalcDirectionalLightSource(vec4 direction, vec4 color, float intensity, vec4 viewVec, vec4 vertNormal)
{
vec4 L = normalize( -vec4(direction.xyz, 0) );
LightResult result;
result.Diffuse = CalcDiffuse(color, L, vertNormal) * intensity;
result.Specular = CalcSpecular(color, viewVec, L, vertNormal) * intensity;
return result;
}
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
{
mat3 TBN = mat3(tangent, bitangent, normal);
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
return vec4(TBN * normalize(NormalMap), 0.0);
}
vec4 CalcBlendedTexel(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues){
vec4 R_Channel = texture2D(R, Input.TextureCoordinate * R_TileValues);
vec4 G_Channel = texture2D(G, Input.TextureCoordinate * G_TileValues);
vec4 B_Channel = texture2D(B, Input.TextureCoordinate * B_TileValues);
float total = blendValue.r + blendValue.g + blendValue.b;
float totalDiv = 1.0f / total;
blendValue.r = blendValue.r * totalDiv;
blendValue.g = blendValue.g * totalDiv;
blendValue.b = blendValue.b * totalDiv;
return blendValue.r * R_Channel
+ blendValue.g * G_Channel
+ blendValue.b * B_Channel;
}
vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B,
vec2 R_TileValues, vec2 G_TileValues, vec2 B_TileValues){
mat3 TBN = mat3(Input.Tangent, Input.BiTangent, Input.Normal);
vec3 R_Channel = texture(R, Input.TextureCoordinate * R_TileValues).xyz * 2.0 - vec3(1.0);
vec3 G_Channel = texture(G, Input.TextureCoordinate * G_TileValues).xyz * 2.0 - vec3(1.0);
vec3 B_Channel = texture(B, Input.TextureCoordinate * B_TileValues).xyz * 2.0 - vec3(1.0);
float total = blendValue.r + blendValue.g + blendValue.b + blendValue.a;
float totalDiv = 1 / total;
blendValue.r = blendValue.r * totalDiv;
blendValue.g = blendValue.g * totalDiv;
blendValue.b = blendValue.b * totalDiv;
vec3 Normal_result = blendValue.r * R_Channel
+ blendValue.g * G_Channel
+ blendValue.b * B_Channel;
return vec4(TBN * normalize(Normal_result), 0.0);
}
void main()
{
float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy) >> int(SSAOQuality), 0).r;
ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT);
vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate);
vec4 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3,
DiffuseUVRepeat1, DiffuseUVRepeat2, DiffuseUVRepeat3);
vec4 glowTexel = CalcBlendedTexel(splatTexel, GlowMapTexture1, GlowMapTexture2, GlowMapTexture3,
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
vec4 position = V * M * vec4(Input.Position, 1.0);
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
vec4 viewVec = normalize(-position);
vec2 tilePos;
tilePos.x = int(gl_FragCoord.x/TILE_SIZE);
tilePos.y = int(gl_FragCoord.y/TILE_SIZE);
LightResult totalLighting;
totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0);
int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE)));
int start = int(LightGrids.Data[currentTile].Start);
int amount = int(LightGrids.Data[currentTile].Amount);
for(int i = start; i < start + amount; i++) {
int l = int(LightIndex[i]);
LightSource light = LightSources.List[l];
LightResult light_result;
//These if statements should be removed.
if(light.Type == 1) { // point
light_result = CalcPointLightSource(V * light.Position, light.Radius, light.Color, light.Intensity, viewVec, position, normal, light.Falloff);
} else if (light.Type == 2) { //Directional
light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal);
}
totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a);
totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a);
}
vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed);
color_result = color_result * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel));
//vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
if(pos <= FillPercentage) {
color_result += FillColor;
}
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
color_result += glowTexel*3;
bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0);
//Tiled Debug Code
/*
if(int(gl_FragCoord.x)%16 == 0 || int(gl_FragCoord.y)%16 == 0 ) {
sceneColor += vec4(0.5, 0, 0, 0);
} else {
sceneColor += vec4(LightGrids.Data[int(tilePos.x + tilePos.y*80)].Amount/LightSources.List.length(), 0, 0, 1);
}
*/
}
+27
View File
@@ -0,0 +1,27 @@
#version 430
layout (binding = 1) uniform sampler2D DepthStencilTexture;
layout (binding = 2) uniform sampler2D SceneTexture;
layout (binding = 3) uniform sampler2D BloomTexture;
in VertexData{
vec2 TextureCoordinate;
}Input;
out vec4 sceneColor;
out vec4 bloomColor;
void main()
{
float texel = texelFetch(DepthStencilTexture, ivec2(gl_FragCoord.xy / 8.0f), 0).g;
if(texel >= 0.9f)
{
discard;
}
sceneColor = vec4(texture2D(SceneTexture, Input.TextureCoordinate).rgb * texel, 1.0f);
bloomColor = vec4(texture2D(BloomTexture, Input.TextureCoordinate).rgb * texel, 1.0f);
//sceneColor = texel;
//bloomColor = vec4(1,0.5,0.7,1);
}
@@ -1,41 +0,0 @@
#version 430
uniform vec4 Color;
uniform vec4 FillColor;
uniform float FillPercentage;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout (binding = 1) uniform sampler2D DiffuseTexture;
layout (binding = 2) uniform sampler2D GlowMapTexture;
in VertexData{
vec3 Position;
vec3 Normal;
vec2 TextureCoordinate;
}Input;
out vec4 sceneColor;
out vec4 bloomColor;
void main()
{
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;
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);
bloomColor = vec4(1.0, 1.0, 1.0, 0.0);
}
+1 -4
View File
@@ -12,7 +12,6 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
if (!boundingBox) { if (!boundingBox) {
return; return;
} }
ComponentWrapper& cTransform = entity["Transform"]; ComponentWrapper& cTransform = entity["Transform"];
EntityAABB& boxA = *boundingBox; EntityAABB& boxA = *boundingBox;
bool everHitTheGround = false; bool everHitTheGround = false;
@@ -87,12 +86,10 @@ void CollisionSystem::UpdateComponent(EntityWrapper& entity, ComponentWrapper& c
glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity); glm::mat4 modelMatrix = Transform::ModelMatrix(boxB.Entity);
glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"]; glm::vec3 inOutVelocity = (glm::vec3)cPhysics["Velocity"];
bool notMovingxz = glm::all(glm::lessThan(glm::abs(glm::vec2(inOutVelocity.x, inOutVelocity.z)), glm::vec2(0.01f))) && prevPosIt != m_PrevPositions.end();
bool isOnGround = (bool)cPhysics["IsOnGround"]; bool isOnGround = (bool)cPhysics["IsOnGround"];
float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"]; float verticalStepHeight = (float)(double)cPhysics["VerticalStepHeight"];
if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) { if (Collision::AABBvsTriangles(boxA, model->Vertices(), model->m_Indices, modelMatrix, inOutVelocity, verticalStepHeight, isOnGround, resolutionVector)) {
//Move the position to previous position if it is not moving in the xz-plane, else resolve with the resolution vector. (glm::vec3&)cTransform["Position"] += resolutionVector;
(glm::vec3&)cTransform["Position"] += notMovingxz ? prevPosIt->second - boxA.Origin() : resolutionVector;
boxA = *Collision::EntityAbsoluteAABB(entity); boxA = *Collision::EntityAbsoluteAABB(entity);
cPhysics["Velocity"] = inOutVelocity; cPhysics["Velocity"] = inOutVelocity;
if (isOnGround) { if (isOnGround) {
+1 -1
View File
@@ -54,7 +54,7 @@ void EditorRenderSystem::Update(double dt)
EntityWrapper entity(m_World, cModel.EntityID); EntityWrapper entity(m_World, cModel.EntityID);
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World); glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
for (auto matGroup : model->MaterialGroups()) { 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, false); 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"]) { if (cModel["Transparent"]) {
scene.Jobs.TransparentObjects.push_back(modelJob); scene.Jobs.TransparentObjects.push_back(modelJob);
} else { } else {
@@ -18,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms()
m_ColorCorrectionProgram->Link(); 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); //glBindFramebuffer(GL_FRAMEBUFFER, 0);
GLERROR("DrawScreenQuadPass::Draw: Pre"); GLERROR("DrawScreenQuadPass::Draw: Pre");
@@ -33,6 +33,10 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLf
glBindTexture(GL_TEXTURE_2D, sceneTexture); glBindTexture(GL_TEXTURE_2D, sceneTexture);
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, bloomTexture); 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); glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
+246 -487
View File
@@ -1,15 +1,17 @@
#include "Rendering/DrawFinalPass.h" #include "Rendering/DrawFinalPass.h"
DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass) DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass, GLuint* depthBuffer)
: m_Renderer(renderer) : m_Renderer(renderer)
, m_LightCullingPass(lightCullingPass) , m_LightCullingPass(lightCullingPass)
, m_CubeMapPass(cubeMapPass) , m_CubeMapPass(cubeMapPass)
, m_SSAOPass(ssaoPass) , m_SSAOPass(ssaoPass)
, m_DepthBuffer(depthBuffer)
{ {
//TODO: Make sure that uniforms are not sent into shader if not needed. //TODO: Make sure that uniforms are not sent into shader if not needed.
m_ShieldPixelRate = 8; m_ShieldPixelRate = 8;
InitializeTextures(); InitializeTextures();
InitializeShaderPrograms(); InitializeShaderPrograms();
InitializeFrameBuffers(); InitializeFrameBuffers();
m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.mesh");
} }
void DrawFinalPass::InitializeTextures() void DrawFinalPass::InitializeTextures()
@@ -29,20 +31,40 @@ void DrawFinalPass::InitializeFrameBuffers()
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //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); //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);
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&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_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_SceneTexture, GL_COLOR_ATTACHMENT0)));
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
m_FinalPassFrameBuffer.Generate(); m_FinalPassFrameBuffer.Generate();
GLERROR("FBO generation"); GLERROR("FBO generation");
CommonFunctions::GenerateTexture(&m_ShieldBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, /* glGenRenderbuffers(1, &m_DepthBufferLowRes);
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBufferLowRes);
m_ShieldDepthFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_ShieldBuffer, GL_DEPTH_ATTACHMENT))); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width/m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height/m_ShieldPixelRate));
m_ShieldDepthFrameBuffer.Generate(); GLERROR("RenderBufferLowRes generation");*/
CommonFunctions::GenerateTexture(&m_DepthBufferLowRes, GL_CLAMP_TO_EDGE, GL_NEAREST,
glm::vec2((int)(m_Renderer->GetViewportSize().Width / m_ShieldPixelRate), (int)(m_Renderer->GetViewportSize().Height / m_ShieldPixelRate)),
GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
CommonFunctions::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);
CommonFunctions::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 Texture2D(&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");
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT)));
m_MergeFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
m_MergeFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
m_MergeFrameBuffer.Generate();
GLERROR("FBO3 generation");
} }
void DrawFinalPass::InitializeShaderPrograms() void DrawFinalPass::InitializeShaderPrograms()
@@ -74,7 +96,6 @@ void DrawFinalPass::InitializeShaderPrograms()
m_SpriteProgram->BindFragDataLocation(1, "bloomColor"); m_SpriteProgram->BindFragDataLocation(1, "bloomColor");
m_SpriteProgram->Link(); m_SpriteProgram->Link();
GLERROR("Creating sprite program"); GLERROR("Creating sprite program");
m_ForwardPlusSplatMapProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapProgram"); m_ForwardPlusSplatMapProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapProgram");
m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl"))); m_ForwardPlusSplatMapProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGB.frag.glsl")));
@@ -131,183 +152,194 @@ void DrawFinalPass::InitializeShaderPrograms()
m_ForwardPlusSplatMapSkinnedProgram->Link(); m_ForwardPlusSplatMapSkinnedProgram->Link();
GLERROR("Creating Forward SplatMap Skinned program"); GLERROR("Creating Forward SplatMap Skinned program");
m_FillDepthStencilBufferProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgram"); m_ShieldToStencilProgram = ResourceManager::Load<ShaderProgram>("#ShieldToStencilProgram");
m_FillDepthStencilBufferProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBuffer.vert.glsl"))); m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShieldStencil.vert.glsl")));
m_FillDepthStencilBufferProgram->Compile(); m_ShieldToStencilProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ShieldStencil.frag.glsl")));
m_FillDepthStencilBufferProgram->Link(); m_ShieldToStencilProgram->Compile();
m_ShieldToStencilProgram->Link();
GLERROR("Creating Shield program");
m_ShieldToStencilSkinnedProgram = ResourceManager::Load<ShaderProgram>("#ShieldToStencilProgramSkinned");
m_ShieldToStencilSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ShieldStencilSkinned.vert.glsl")));
m_ShieldToStencilSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ShieldStencil.frag.glsl")));
m_ShieldToStencilSkinnedProgram->Compile();
m_ShieldToStencilSkinnedProgram->Link();
GLERROR("Creating Shield Skinned 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"); GLERROR("Creating DepthFill program");
m_FillDepthStencilBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned"); m_FillDepthBufferSkinnedProgram = ResourceManager::Load<ShaderProgram>("#FillDepthBufferProgramSkinned");
m_FillDepthStencilBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl"))); m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/FillDepthBufferSkinned.vert.glsl")));
m_FillDepthStencilBufferSkinnedProgram->Compile(); //m_FillDepthBufferSkinnedProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/FillDepthBuffer.frag.glsl")));
m_FillDepthStencilBufferSkinnedProgram->Link(); m_FillDepthBufferSkinnedProgram->Compile();
m_FillDepthBufferSkinnedProgram->Link();
GLERROR("Creating DepthFill program"); GLERROR("Creating DepthFill program");
m_MergeProgram = ResourceManager::Load<ShaderProgram>("#MergeProgram");
m_MergeProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/DrawScreenQuad.vert.glsl")));
m_MergeProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/MergeProgram.frag.glsl")));
m_MergeProgram->Compile();
m_ForwardPlusShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusShieldCheckProgram"); m_MergeProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl"))); m_MergeProgram->BindFragDataLocation(1, "bloomColor");
m_ForwardPlusShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl"))); m_MergeProgram->Link();
m_ForwardPlusShieldCheckProgram->Compile(); GLERROR("Creating merge program");
m_ForwardPlusShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ForwardPlusShieldCheckProgram->Link();
GLERROR("Creating forward+ program");
m_ExplosionEffectShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectShieldCheckProgram");
m_ExplosionEffectShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
m_ExplosionEffectShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
m_ExplosionEffectShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl")));
m_ExplosionEffectShieldCheckProgram->Compile();
m_ExplosionEffectShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ExplosionEffectShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ExplosionEffectShieldCheckProgram->Link();
GLERROR("Creating explosion program");
m_SpriteShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#SpriteShieldCheckProgram");
m_SpriteShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/Sprite.vert.glsl")));
m_SpriteShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/SpriteShieldCheck.frag.glsl")));
m_SpriteShieldCheckProgram->Compile();
m_SpriteShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_SpriteShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_SpriteShieldCheckProgram->Link();
GLERROR("Creating sprite program");
m_ForwardPlusSplatMapShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapShieldCheckProgram");
m_ForwardPlusSplatMapShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
m_ForwardPlusSplatMapShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl")));
m_ForwardPlusSplatMapShieldCheckProgram->Compile();
m_ForwardPlusSplatMapShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusSplatMapShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ForwardPlusSplatMapShieldCheckProgram->Link();
GLERROR("Creating Forward SplatMap program");
m_ExplosionEffectSplatMapShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectSplatMapShieldCheckProgram");
m_ExplosionEffectSplatMapShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
m_ExplosionEffectSplatMapShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
m_ExplosionEffectSplatMapShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl")));
m_ExplosionEffectSplatMapShieldCheckProgram->Compile();
m_ExplosionEffectSplatMapShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ExplosionEffectSplatMapShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ExplosionEffectSplatMapShieldCheckProgram->Link();
GLERROR("Creating explosion SplatMap program");
m_ForwardPlusSkinnedShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusSkinnedShieldCheckProgram");
m_ForwardPlusSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl")));
m_ForwardPlusSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl")));
m_ForwardPlusSkinnedShieldCheckProgram->Compile();
m_ForwardPlusSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ForwardPlusSkinnedShieldCheckProgram->Link();
GLERROR("Creating forward+ Skinned program");
m_ExplosionEffectSkinnedShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectSkinnedShieldCheckProgram");
m_ExplosionEffectSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl")));
m_ExplosionEffectSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
m_ExplosionEffectSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusShieldCheck.frag.glsl")));
m_ExplosionEffectSkinnedShieldCheckProgram->Compile();
m_ExplosionEffectSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ExplosionEffectSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ExplosionEffectSkinnedShieldCheckProgram->Link();
GLERROR("Creating explosion Skinned program");
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectSplatMapSkinnedShieldCheckProgram");
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl")));
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl")));
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Compile();
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Link();
GLERROR("Creating Forward SplatMap Skinned program");
m_ForwardPlusSplatMapSkinnedShieldCheckProgram = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapSkinnedShieldCheckProgram");
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlusSkinned.vert.glsl")));
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlusSplatMapRGBShieldCheck.frag.glsl")));
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Compile();
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(0, "sceneColor");
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->BindFragDataLocation(1, "bloomColor");
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Link();
GLERROR("Creating Forward SplatMap Skinned program");
} }
void DrawFinalPass::Draw(RenderScene& scene) void DrawFinalPass::Draw(RenderScene& scene)
{ {
GLERROR("Pre"); GLERROR("Pre");
DrawFinalPassState* stateDethp = new DrawFinalPassState(m_ShieldDepthFrameBuffer.GetHandle());
//Draw shields to stencil
DrawToDepthStencilBuffer(scene.Jobs.ShieldObjects, scene);
GLERROR("StencilPass");
delete stateDethp;
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
if (scene.ClearDepth) { if (scene.ClearDepth) {
//glClear(GL_DEPTH_BUFFER_BIT); //glClear(GL_DEPTH_BUFFER_BIT);
state->Disable(GL_DEPTH_TEST); state->Disable(GL_DEPTH_TEST);
state->DepthMask(GL_FALSE);
} }
//TODO: Do we need check for this or will it be per scene always? //TODO: Do we need check for this or will it be per scene always?
state->Enable(GL_STENCIL_TEST);
glClearStencil(0x00); glClearStencil(0x00);
glClear(GL_STENCIL_BUFFER_BIT); glClear(GL_STENCIL_BUFFER_BIT);
//Fill depth buffer //Draw Opaque shielded objects
state->Disable(GL_STENCIL_TEST);
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects");
DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
GLERROR("Shielded Opaque object");
//DrawStencilState* stencilState = new DrawStencilState(m_FinalPassFrameBuffer.GetHandle());
//Draw shields to stencil pass
state->Enable(GL_STENCIL_TEST); state->Enable(GL_STENCIL_TEST);
state->StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); state->StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
state->StencilFunc(GL_ALWAYS, 1, 0xFF); state->StencilFunc(GL_ALWAYS, 1, 0xFF);
state->StencilMask(0xFF); state->StencilMask(0xFF);
state->DepthMask(GL_FALSE); DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
//DrawToDepthStencilBuffer(scene.Jobs.ShieldObjects, scene); GLERROR("StencilPass");
state->DepthMask(GL_TRUE);
//Draw Opaque shielded objects
state->Disable(GL_STENCIL_TEST);
state->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
state->StencilMask(0x00);
DrawModelRenderQueuesWithShieldCheck(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing
GLERROR("Shielded Opaque object");
//Draw Opaque objects
//state->StencilMask(0x00); //state->BlendFunc(GL_ONE, GL_ONE);
//DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
//GLERROR("TransparentObjects");
////Draw Transparen Shielded objects
//DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing
//GLERROR("Shielded Transparent objects");
// state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
// DrawSprites(scene.Jobs.SpriteJob, scene);
// GLERROR("SpriteJobs");
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);
stateLowRes->DepthMask(GL_TRUE);
stateLowRes->Enable(GL_STENCIL_TEST);
stateLowRes->StencilFunc(GL_NOTEQUAL, 1, 0xFF);
stateLowRes->StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
stateLowRes->StencilMask(0xFF);
//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_NOTEQUAL, 1, 0xFF);
stateLowRes->StencilMask(0xFF);
stateLowRes->DepthMask(GL_FALSE);
DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene);
GLERROR("StencilPass");
//glClear(GL_DEPTH_BUFFER_BIT);
stateLowRes->Enable(GL_DEPTH_TEST);
//stateLowRes->DepthMask(GL_TRUE);
stateLowRes->DepthFunc(GL_LEQUAL);
stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF);
stateLowRes->StencilMask(0x00);
DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene);
GLERROR("OpaqueObjects"); 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;
m_FinalPassFrameBuffer.Unbind();
m_FinalPassFrameBufferLowRes.Unbind();
state = new DrawFinalPassState(m_MergeFrameBuffer.GetHandle());
state->Disable(GL_DEPTH_TEST);
state->Enable(GL_STENCIL_TEST);
state->StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
state->StencilFunc(GL_LEQUAL, 1, 0xFF);
state->StencilMask(0x00);
MergeLayers();
delete state;
state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
//Draw Transparancy
state->BlendFunc(GL_ONE, GL_ONE);
DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
GLERROR("TransparentObjects");
//state->Disable(GL_STENCIL_TEST);
//Draw Transparen Shielded objects //Draw Transparen Shielded objects
state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing
DrawModelRenderQueuesWithShieldCheck(scene.Jobs.TransparentObjects, scene); //might need changing
GLERROR("Shielded Transparent objects"); GLERROR("Shielded Transparent objects");
//Draw Transparen objects state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//state->BlendFunc(GL_ONE, GL_ONE);
//state->StencilFunc(GL_EQUAL, 1, 0xFF);
//DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene);
GLERROR("TransparentObjects");
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
DrawSprites(scene.Jobs.SpriteJob, scene); DrawSprites(scene.Jobs.SpriteJob, scene);
GLERROR("SpriteJobs"); GLERROR("SpriteJobs");
delete state;
GLERROR("END"); GLERROR("END");
delete state;
} }
void DrawFinalPass::ClearBuffer() void DrawFinalPass::ClearBuffer()
{ {
GLERROR("PRE"); GLERROR("PRE");
m_ShieldDepthFrameBuffer.Bind(); m_FinalPassFrameBufferLowRes.Bind();
glClear(GL_DEPTH_BUFFER_BIT); GLERROR("Bind LowRes");
m_ShieldDepthFrameBuffer.Unbind();
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);
GLERROR("ViewPort,Scissor LowRes");
glClearColor(0.f, 0.f, 0.f, 0.f);
GLERROR("1");
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
GLERROR("2");
glDisable(GL_SCISSOR_TEST);
GLERROR("3");
m_FinalPassFrameBufferLowRes.Unbind();
GLERROR("prebind HighRes");
m_FinalPassFrameBuffer.Bind(); m_FinalPassFrameBuffer.Bind();
GLERROR("Bind HighRes"); GLERROR("Bind HighRes");
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
GLERROR("ViewPort,Scissor LowRes"); GLERROR("ViewPort,Scissor LowRes");
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
m_FinalPassFrameBuffer.Unbind(); m_FinalPassFrameBuffer.Unbind();
GLERROR("END"); GLERROR("END");
} }
@@ -316,25 +348,39 @@ void DrawFinalPass::ClearBuffer()
void DrawFinalPass::OnWindowResize() void DrawFinalPass::OnWindowResize()
{ {
//InitializeFrameBuffers(); //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_EDGE, 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); 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(); m_FinalPassFrameBuffer.Generate();
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));
CommonFunctions::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);
CommonFunctions::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);
m_FinalPassFrameBufferLowRes.Generate();
GLERROR("Error changing texture resolutions"); GLERROR("Error changing texture resolutions");
} }
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene) void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{ {
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
GLERROR("forwardHandle");
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle(); GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
GLERROR("explosionHandle");
GLuint explosionSplatMapHandle = m_ExplosionEffectSplatMapProgram->GetHandle(); GLuint explosionSplatMapHandle = m_ExplosionEffectSplatMapProgram->GetHandle();
GLuint forwardSplatMapHandle = m_ForwardPlusSplatMapProgram->GetHandle(); GLERROR("explosionSplatMapHandle");
GLuint forwardSplatHandle = m_ForwardPlusSplatMapProgram->GetHandle();
GLERROR("forwardSplatHandle");
GLuint forwardSkinnedHandle = m_ForwardPlusSkinnedProgram->GetHandle(); GLuint forwardSkinnedHandle = m_ForwardPlusSkinnedProgram->GetHandle();
GLERROR("forwardSkinnedHandle");
GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle(); GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle();
GLERROR("explosionSkinnedHandle");
GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle(); GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
GLERROR("explosionSplatMapSkinnedHandle");
GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle(); GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
GLERROR("forwardSplatSkinnedHandle");
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
@@ -365,13 +411,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) { if (explosionEffectJob->AnimationOffset.animation != nullptr) {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
} } else {
else {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
} }
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} } else {
else {
m_ExplosionEffectProgram->Bind(); m_ExplosionEffectProgram->Bind();
GLERROR("Bind ExplosionEffect program"); GLERROR("Bind ExplosionEffect program");
//bind uniforms //bind uniforms
@@ -381,6 +425,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
glActiveTexture(GL_TEXTURE5); glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
} }
break; break;
} }
@@ -397,13 +442,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) { if (explosionEffectJob->AnimationOffset.animation != nullptr) {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
} } else {
else {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations); frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
} }
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else { } else {
m_ExplosionEffectSplatMapProgram->Bind(); m_ExplosionEffectSplatMapProgram->Bind();
GLERROR("Bind ExplosionEffectSplatMap program"); GLERROR("Bind ExplosionEffectSplatMap program");
//bind uniforms //bind uniforms
@@ -447,14 +491,12 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) { if (modelJob->AnimationOffset.animation != nullptr) {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
} } else {
else {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
} }
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} } else {
else {
m_ForwardPlusProgram->Bind(); m_ForwardPlusProgram->Bind();
GLERROR("Bind ForwardPlusProgram"); GLERROR("Bind ForwardPlusProgram");
//bind uniforms //bind uniforms
@@ -480,20 +522,18 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) { if (modelJob->AnimationOffset.animation != nullptr) {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
} } else {
else {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
} }
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} } else {
else {
m_ForwardPlusSplatMapProgram->Bind(); m_ForwardPlusSplatMapProgram->Bind();
GLERROR("Bind SplatMap program"); GLERROR("Bind SplatMap program");
//bind uniforms //bind uniforms
BindModelUniforms(forwardSplatMapHandle, modelJob, scene); BindModelUniforms(forwardSplatHandle, modelJob, scene);
//bind textures //bind textures
BindModelTextures(forwardSplatMapHandle, modelJob); BindModelTextures(forwardSplatHandle, modelJob);
GLERROR("asdasd"); GLERROR("asdasd");
} }
break; break;
@@ -511,341 +551,39 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
} }
} }
void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
void DrawFinalPass::DrawShieldToStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{ {
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
GLuint explosionSplatMapHandle = m_ExplosionEffectSplatMapProgram->GetHandle();
GLuint forwardSplatMapHandle = m_ForwardPlusSplatMapProgram->GetHandle();
GLuint forwardSkinnedHandle = m_ForwardPlusSkinnedProgram->GetHandle();
GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle();
GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
GLuint forwardShieldCheckHandle = m_ForwardPlusShieldCheckProgram->GetHandle();
GLuint explosionShieldCheckHandle = m_ExplosionEffectShieldCheckProgram->GetHandle();
GLuint explosionSplatMapShieldCheckHandle = m_ExplosionEffectSplatMapShieldCheckProgram->GetHandle();
GLuint forwardSplatShieldCheckHandle = m_ForwardPlusSplatMapShieldCheckProgram->GetHandle();
GLuint forwardSkinnedShieldCheckHandle = m_ForwardPlusSkinnedShieldCheckProgram->GetHandle();
GLuint explosionSkinnedShieldCheckHandle = m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle();
GLuint explosionSplatMapSkinnedShieldCheckHandle = m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle();
GLuint forwardSplatMapSkinnedShieldCheckHandle = m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle();
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());
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_SSAOPass->SSAOTexture());
glActiveTexture(GL_TEXTURE31);
glBindTexture(GL_TEXTURE_2D, m_ShieldBuffer);
for (auto &job : jobs) { for (auto &job : jobs) {
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
if (explosionEffectJob) {
if (explosionEffectJob->IsShielded) {
switch (explosionEffectJob->Type) {
case RawModel::MaterialType::Basic:
case RawModel::MaterialType::SingleTextures:
{
if (explosionEffectJob->Model->IsSkinned()) {
m_ExplosionEffectSkinnedShieldCheckProgram->Bind();
GLERROR("Bind ExplosionEffectSkinned program");
//bind uniforms
BindExplosionUniforms(explosionSkinnedShieldCheckHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionSkinnedShieldCheckHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
}
else {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
}
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else {
m_ExplosionEffectShieldCheckProgram->Bind();
GLERROR("Bind ExplosionEffect program");
//bind uniforms
BindExplosionUniforms(explosionShieldCheckHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionShieldCheckHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(explosionShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
}
break;
}
case RawModel::MaterialType::SplatMapping:
{
if (explosionEffectJob->Model->IsSkinned()) {
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind();
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
//bind uniforms
BindExplosionUniforms(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob);
GLERROR("asdasd");
std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
}
else {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
}
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else {
m_ExplosionEffectSplatMapShieldCheckProgram->Bind();
GLERROR("Bind ExplosionEffectSplatMap program");
//bind uniforms
//bind uniforms
BindExplosionUniforms(explosionSplatMapShieldCheckHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionSplatMapShieldCheckHandle, explosionEffectJob);
GLERROR("asdasd");
}
break;
}
}
} else {
switch (explosionEffectJob->Type) {
case RawModel::MaterialType::Basic:
case RawModel::MaterialType::SingleTextures:
{
if (explosionEffectJob->Model->IsSkinned()) {
m_ExplosionEffectSkinnedProgram->Bind();
GLERROR("Bind ExplosionEffectSkinned program");
//bind uniforms
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(explosionSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
}
else {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
}
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else {
m_ExplosionEffectProgram->Bind();
GLERROR("Bind ExplosionEffect program");
//bind uniforms
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionHandle, explosionEffectJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(explosionHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
}
break;
}
case RawModel::MaterialType::SplatMapping:
{
if (explosionEffectJob->Model->IsSkinned()) {
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
//bind uniforms
BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionSplatMapSkinnedHandle, explosionEffectJob);
GLERROR("asdasd");
std::vector<glm::mat4> frameBones;
if (explosionEffectJob->AnimationOffset.animation != nullptr) {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset);
}
else {
frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations);
}
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else {
m_ExplosionEffectSplatMapProgram->Bind();
GLERROR("Bind ExplosionEffectSplatMap program");
//bind uniforms
//bind uniforms
BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene);
//bind textures
BindExplosionTextures(explosionSplatMapHandle, explosionEffectJob);
GLERROR("asdasd");
}
break;
}
}
}
glDisable(GL_CULL_FACE);
//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);
GLERROR("explosion effect end");
} else {
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job); auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if (modelJob) { if (modelJob) {
//bind forward program
//TODO: JOHAN/TOBIAS: Bind shader based on ModelJob->ShaderID;
if (modelJob->IsShielded) {
switch (modelJob->Type) {
case RawModel::MaterialType::Basic:
case RawModel::MaterialType::SingleTextures:
{
if (modelJob->Model->IsSkinned()) {
m_ForwardPlusSkinnedShieldCheckProgram->Bind();
GLERROR("Bind ForwardPlusSkinnedProgram");
//bind uniforms
BindModelUniforms(forwardSkinnedShieldCheckHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardSkinnedShieldCheckHandle, modelJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
if(modelJob->Model->IsSkinned()) {
m_ShieldToStencilSkinnedProgram->Bind();
GLuint shaderHandle = m_ShieldToStencilSkinnedProgram->GetHandle();
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()));
std::vector<glm::mat4> frameBones; std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) { if (modelJob->AnimationOffset.animation != nullptr) {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
}
else {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
}
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else {
m_ForwardPlusShieldCheckProgram->Bind();
GLERROR("Bind ForwardPlusProgram");
//bind uniforms
BindModelUniforms(forwardShieldCheckHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardShieldCheckHandle, modelJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardShieldCheckHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
}
break;
}
case RawModel::MaterialType::SplatMapping:
{
if (modelJob->Model->IsSkinned()) {
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Bind();
GLERROR("Bind SplatMap program");
//bind uniforms
BindModelUniforms(forwardSplatMapSkinnedShieldCheckHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardSplatMapSkinnedShieldCheckHandle, modelJob);
GLERROR("asdasd");
std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
}
else {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
}
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else {
m_ForwardPlusSplatMapShieldCheckProgram->Bind();
GLERROR("Bind SplatMap program");
//bind uniforms
BindModelUniforms(forwardSplatShieldCheckHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardSplatShieldCheckHandle, modelJob);
GLERROR("asdasd");
}
break;
}
}
} else { } else {
switch (modelJob->Type) {
case RawModel::MaterialType::Basic:
case RawModel::MaterialType::SingleTextures:
{
if (modelJob->Model->IsSkinned()) {
m_ForwardPlusSkinnedProgram->Bind();
GLERROR("Bind ForwardPlusSkinnedProgram");
//bind uniforms
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardSkinnedHandle, modelJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardSkinnedHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
}
else {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations); frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
} }
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else {
m_ShieldToStencilProgram->Bind();
GLuint shaderHandle = m_ShieldToStencilProgram->GetHandle();
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()));
} }
else {
m_ForwardPlusProgram->Bind();
GLERROR("Bind ForwardPlusProgram");
//bind uniforms
BindModelUniforms(forwardHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardHandle, modelJob);
glActiveTexture(GL_TEXTURE5);
glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture);
glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position()));
}
break;
}
case RawModel::MaterialType::SplatMapping:
{
if (modelJob->Model->IsSkinned()) {
m_ForwardPlusSplatMapSkinnedProgram->Bind();
GLERROR("Bind SplatMap program");
//bind uniforms
BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardSplatMapSkinnedHandle, modelJob);
GLERROR("asdasd");
std::vector<glm::mat4> frameBones;
if (modelJob->AnimationOffset.animation != nullptr) {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset);
}
else {
frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations);
}
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
}
else {
m_ForwardPlusSplatMapProgram->Bind();
GLERROR("Bind SplatMap program");
//bind uniforms
BindModelUniforms(forwardSplatMapHandle, modelJob, scene);
//bind textures
BindModelTextures(forwardSplatMapHandle, modelJob);
GLERROR("asdasd");
}
break;
}
}
}
//draw
glBindVertexArray(modelJob->Model->VAO); glBindVertexArray(modelJob->Model->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer); 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))); glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
@@ -855,7 +593,6 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
} }
} }
} }
}
void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene) void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{ {
@@ -949,7 +686,7 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<Rende
} }
void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene) void DrawFinalPass::DrawToDepthBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
{ {
@@ -957,8 +694,8 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job); auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
if(modelJob->Model->IsSkinned()) { if(modelJob->Model->IsSkinned()) {
m_FillDepthStencilBufferSkinnedProgram->Bind(); m_FillDepthBufferSkinnedProgram->Bind();
GLuint shaderHandle = m_FillDepthStencilBufferSkinnedProgram->GetHandle(); GLuint shaderHandle = m_FillDepthBufferSkinnedProgram->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); 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())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
@@ -972,8 +709,8 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0])); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
} else { } else {
m_FillDepthStencilBufferProgram->Bind(); m_FillDepthBufferProgram->Bind();
GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle(); GLuint shaderHandle = m_FillDepthBufferProgram->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); 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())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
@@ -1037,6 +774,28 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
// m_SpriteProgram->Unbind(); // m_SpriteProgram->Unbind();
} }
void DrawFinalPass::MergeLayers()
{
GLuint shaderHandle = m_MergeProgram->GetHandle();
m_MergeProgram->Bind();
GLERROR("MergeLayers 1");
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, m_DepthBufferLowRes);
GLERROR("MergeLayers 2");
glActiveTexture(GL_TEXTURE2);
glBindTexture(GL_TEXTURE_2D, m_SceneTextureLowRes);
GLERROR("MergeLayers 3");
glActiveTexture(GL_TEXTURE3);
glBindTexture(GL_TEXTURE_2D, m_BloomTextureLowRes);
GLERROR("MergeLayers 4");
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("MergeLayers 5");
}
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene) void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
{ {
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality()); glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
+6 -3
View File
@@ -8,7 +8,8 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
Enable(GL_BLEND); Enable(GL_BLEND);
BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
Enable(GL_DEPTH_TEST); Enable(GL_DEPTH_TEST);
DepthMask(GL_TRUE); DepthMask(GL_FALSE);
DepthFunc(GL_LEQUAL);
Enable(GL_CULL_FACE); Enable(GL_CULL_FACE);
//Enable(GL_STENCIL_TEST); //Enable(GL_STENCIL_TEST);
//StencilFunc(GL_NOTEQUAL, 1, 0xFF); //StencilFunc(GL_NOTEQUAL, 1, 0xFF);
@@ -25,9 +26,11 @@ DrawFinalPassState::~DrawFinalPassState()
DrawStencilState::DrawStencilState(GLuint frameBuffer) DrawStencilState::DrawStencilState(GLuint frameBuffer)
{ {
BindFramebuffer(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); Enable(GL_DEPTH_TEST);
DepthMask(GL_TRUE);
Enable(GL_CULL_FACE);
ClearColor(glm::vec4(0.f)); ClearColor(glm::vec4(0.f));
} }
+1 -2
View File
@@ -23,12 +23,11 @@ void PickingPass::InitializeTextures()
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); 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, CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
} }
void PickingPass::InitializeFrameBuffers() void PickingPass::InitializeFrameBuffers()
{ {
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0))); m_PickingBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0)));
m_PickingBuffer.Generate(); m_PickingBuffer.Generate();
@@ -9,6 +9,7 @@ PickingPassState::PickingPassState(GLuint frameBuffer)
Enable(GL_DEPTH_TEST); Enable(GL_DEPTH_TEST);
Enable(GL_CULL_FACE); Enable(GL_CULL_FACE);
Disable(GL_BLEND); Disable(GL_BLEND);
glm::vec4 clearColor = glm::vec4(0.f); glm::vec4 clearColor = glm::vec4(0.f);
//ClearColor(clearColor); //ClearColor(clearColor);
//Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+9 -10
View File
@@ -240,8 +240,6 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
fillColor = (glm::vec4)fillComponent["Color"]; fillColor = (glm::vec4)fillComponent["Color"];
} }
bool isShielded = m_World->HasComponent(cModel.EntityID, "Shielded") || m_World->HasComponent(cModel.EntityID, "Player");
glm::mat4 modelMatrix = Transform::ModelMatrix(cModel.EntityID, m_World); glm::mat4 modelMatrix = Transform::ModelMatrix(cModel.EntityID, m_World);
//Loop through all materialgroups of a model //Loop through all materialgroups of a model
for (auto matGroup : model->MaterialGroups()) { for (auto matGroup : model->MaterialGroups()) {
@@ -257,19 +255,20 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
cModel, cModel,
m_World, m_World,
fillColor, fillColor,
fillPercentage, fillPercentage
isShielded
)); ));
if (m_World->HasComponent(cModel.EntityID, "Shield")){ if (m_World->HasComponent(cModel.EntityID, "Shield")){
explosionEffectJob->CalculateHash(); explosionEffectJob->CalculateHash();
Jobs.ShieldObjects.push_back(explosionEffectJob); Jobs.ShieldObjects.push_back(explosionEffectJob);
} else if (isShielded) { } else if (m_World->HasComponent(cModel.EntityID, "Shielded")
|| m_World->HasComponent(cModel.EntityID, "Player")) {
if (explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) { if (explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
cModel["Transparent"] = true; cModel["Transparent"] = true;
} }
if (cModel["Transparent"]) { if (cModel["Transparent"]) {
Jobs.TransparentObjects.push_back(explosionEffectJob); Jobs.TransparentShieldedObjects.push_back(explosionEffectJob);
} else { } else {
explosionEffectJob->CalculateHash(); explosionEffectJob->CalculateHash();
Jobs.OpaqueShieldedObjects.push_back(explosionEffectJob); Jobs.OpaqueShieldedObjects.push_back(explosionEffectJob);
@@ -295,20 +294,20 @@ void RenderSystem::fillModels(RenderScene::Queues &Jobs)
cModel, cModel,
m_World, m_World,
fillColor, fillColor,
fillPercentage, fillPercentage
isShielded
)); ));
if (m_World->HasComponent(cModel.EntityID, "Shield")) { if (m_World->HasComponent(cModel.EntityID, "Shield")) {
modelJob->CalculateHash(); modelJob->CalculateHash();
Jobs.ShieldObjects.push_back(modelJob); Jobs.ShieldObjects.push_back(modelJob);
} else if (isShielded) { } 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) { if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) {
cModel["Transparent"] = true; cModel["Transparent"] = true;
} }
if (cModel["Transparent"]) { if (cModel["Transparent"]) {
Jobs.TransparentObjects.push_back(modelJob); Jobs.TransparentShieldedObjects.push_back(modelJob);
} else { } else {
modelJob->CalculateHash(); modelJob->CalculateHash();
Jobs.OpaqueShieldedObjects.push_back(modelJob); Jobs.OpaqueShieldedObjects.push_back(modelJob);
+11 -5
View File
@@ -110,7 +110,7 @@ void Renderer::Draw(RenderFrame& frame)
{ {
GLERROR("PRE"); GLERROR("PRE");
glBindFramebuffer(GL_FRAMEBUFFER, 0); glBindFramebuffer(GL_FRAMEBUFFER, 0);
ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0Gaussian\0Picking\0Ambient Occlusion"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion");
ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)");
if(m_CubeMapTexture == 0) { if(m_CubeMapTexture == 0) {
m_CubeMapPass->LoadTextures("Nevada"); m_CubeMapPass->LoadTextures("Nevada");
@@ -174,7 +174,7 @@ void Renderer::Draw(RenderFrame& frame)
if (m_DebugTextureToDraw == 0) { if (m_DebugTextureToDraw == 0) {
PerformanceTimer::StartTimer("Renderer-Color Correction Pass"); PerformanceTimer::StartTimer("Renderer-Color Correction Pass");
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);
PerformanceTimer::StopTimer("Renderer-Color Correction Pass"); PerformanceTimer::StopTimer("Renderer-Color Correction Pass");
} }
@@ -186,12 +186,18 @@ void Renderer::Draw(RenderFrame& frame)
m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTexture()); m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTexture());
} }
if (m_DebugTextureToDraw == 3) { if (m_DebugTextureToDraw == 3) {
m_DrawScreenQuadPass->Draw(m_DrawBloomPass->GaussianTexture()); m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTextureLowRes());
} }
if (m_DebugTextureToDraw == 4) { if (m_DebugTextureToDraw == 4) {
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); m_DrawScreenQuadPass->Draw(m_DrawFinalPass->BloomTextureLowRes());
} }
if (m_DebugTextureToDraw == 5) { if (m_DebugTextureToDraw == 5) {
m_DrawScreenQuadPass->Draw(m_DrawBloomPass->GaussianTexture());
}
if (m_DebugTextureToDraw == 6) {
m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture());
}
if (m_DebugTextureToDraw == 7) {
m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture()); m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture());
} }
PerformanceTimer::StopTimer("Renderer-Misc Debug Draws"); PerformanceTimer::StopTimer("Renderer-Misc Debug Draws");
@@ -244,7 +250,7 @@ void Renderer::InitializeRenderPasses()
m_LightCullingPass = new LightCullingPass(this); m_LightCullingPass = new LightCullingPass(this);
m_CubeMapPass = new CubeMapPass(this); m_CubeMapPass = new CubeMapPass(this);
m_SSAOPass = new SSAOPass(this, m_Config); m_SSAOPass = new SSAOPass(this, m_Config);
m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass); m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass, m_SSAOPass, m_PickingPass->DepthBuffer());
m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawScreenQuadPass = new DrawScreenQuadPass(this);
m_DrawBloomPass = new DrawBloomPass(this, m_Config); m_DrawBloomPass = new DrawBloomPass(this, m_Config);
m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this);
+2 -3
View File
@@ -48,6 +48,7 @@ Game::Game(int argc, char* argv[])
ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true); ResourceManager::UseThreading = m_Config->Get<bool>("Multithreading.ResourceLoading", true);
DisableMemoryPool::Value = m_Config->Get<bool>("Debug.DisableMemoryPool", false); DisableMemoryPool::Value = m_Config->Get<bool>("Debug.DisableMemoryPool", false);
LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1)); LOG_LEVEL = static_cast<_LOG_LEVEL>(m_Config->Get<int>("Debug.LogLevel", 1));
PlayerSpawnSystem::SetRespawnTime(m_Config->Get<float>("Debug.RespawnTime", 15.0f));
// Create the core event broker // Create the core event broker
m_EventBroker = new EventBroker(); m_EventBroker = new EventBroker();
@@ -138,6 +139,7 @@ Game::Game(int argc, char* argv[])
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable"); m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeCollision, "Collidable");
m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player"); m_SystemPipeline->AddSystem<FillOctreeSystem>(updateOrderLevel, m_OctreeTrigger, "Player");
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<AnimationSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<UniformScaleSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<UniformScaleSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<HealthHUDSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<HealthHUDSystem>(updateOrderLevel);
@@ -147,9 +149,6 @@ Game::Game(int argc, char* argv[])
m_SystemPipeline->AddSystem<BoneAttachmentSystem>(updateOrderLevel); m_SystemPipeline->AddSystem<BoneAttachmentSystem>(updateOrderLevel);
m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision); m_SystemPipeline->AddSystem<CollisionSystem>(updateOrderLevel, m_OctreeCollision);
m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeTrigger); m_SystemPipeline->AddSystem<TriggerSystem>(updateOrderLevel, m_OctreeTrigger);
// Octree for frustum culling must be updated after collisions, otherwise players frustum may be moved after tree is filled, and wrong things are culled.
++updateOrderLevel;
m_SystemPipeline->AddSystem<FillFrustumOctreeSystem>(updateOrderLevel, m_OctreeFrustrumCulling);
++updateOrderLevel; ++updateOrderLevel;
m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling); m_SystemPipeline->AddSystem<RenderSystem>(updateOrderLevel, m_Renderer, m_RenderFrame, m_OctreeFrustrumCulling);
++updateOrderLevel; ++updateOrderLevel;
+5 -10
View File
@@ -116,18 +116,12 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity)); ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
} }
//you cant jump and dash at the same time - since there is no friction in the air and we would thus dash much further in the air
if (!controller->PlayerIsDashing() && controller->Jumping() && !controller->Crouching() && (isOnGround || !controller->DoubleJumping())) {
(bool)cPhysics["IsOnGround"] = false;
if (isOnGround) { if (isOnGround) {
controller->SetDoubleJumping(false); controller->SetDoubleJumping(false);
} } else {
//If player presses Jump and is not crouching.
if (controller->Jumping() && !controller->Crouching()) {
if (isOnGround) {
(bool)cPhysics["IsOnGround"] = false;
velocity.y = player["Player"]["JumpSpeed"];
} else if (player.HasComponent("DoubleJump") && !controller->DoubleJumping()) {
//Enter here if player can double jump and is doing so.
(bool)cPhysics["IsOnGround"] = false;
velocity.y = player["DoubleJump"]["DoubleJumpSpeed"];
// If IsServer and network is off this will not work // If IsServer and network is off this will not work
if (IsClient) { if (IsClient) {
//put a hexagon at the players feet //put a hexagon at the players feet
@@ -139,6 +133,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
m_EventBroker->Publish(e); m_EventBroker->Publish(e);
} }
} }
velocity.y = 4.f;
} }
if (player.HasComponent("AABB")) { if (player.HasComponent("AABB")) {
+8 -19
View File
@@ -1,38 +1,27 @@
#include "Systems/PlayerSpawnSystem.h" #include "Systems/PlayerSpawnSystem.h"
//This should be set by the config anyway.
float PlayerSpawnSystem::m_RespawnTime = 15.0f;
PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params) PlayerSpawnSystem::PlayerSpawnSystem(SystemParams params)
: System(params) : System(params)
, m_DbgConfigForceRespawn(false) , m_Timer(0.f)
{ {
EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_OnInputCommand, &PlayerSpawnSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_OnPlayerSpawnerd, &PlayerSpawnSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerSpawnerd, &PlayerSpawnSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerSpawnSystem::OnPlayerDeath); EVENT_SUBSCRIBE_MEMBER(m_OnPlayerDeath, &PlayerSpawnSystem::OnPlayerDeath);
ConfigFile* config = ResourceManager::Load<ConfigFile>("Config.ini"); m_NetworkEnabled = ResourceManager::Load<ConfigFile>("Config.ini")->Get("Networking.StartNetwork", false);
m_NetworkEnabled = config->Get("Networking.StartNetwork", false);
m_ForcedRespawnTime = config->Get("Debug.RespawnTime", -1.0f);
m_DbgConfigForceRespawn = m_ForcedRespawnTime > 0;
} }
void PlayerSpawnSystem::Update(double dt) void PlayerSpawnSystem::Update(double dt)
{ {
// If there are no CapturePointGameMode components we will just spawn immediately.
// Should be able to support older maps with this.
// TODO: In the future we might want to return instead, to avoid spawning in the menu for instance.
auto pool = m_World->GetComponents("CapturePointGameMode");
if (pool != nullptr && pool->size() > 0)
{
// Take the first CapturePointGameMode component found.
ComponentWrapper& modeComponent = *pool->begin();
//Increase timer. //Increase timer.
double& timer = (double&)modeComponent["RespawnTime"]; m_Timer += dt;
timer += dt; if (m_Timer < m_RespawnTime) {
double maxRespawnTime = m_DbgConfigForceRespawn ? m_ForcedRespawnTime : (double)modeComponent["MaxRespawnTime"];
if (timer < maxRespawnTime) {
return; return;
} }
//If respawn time has passed, we spawn all players that have requested to be spawned. //If respawn time has passed, we spawn all players that have requested to be spawned.
timer = 0; m_Timer = 0.f;
}
//If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty. //If there are no spawn requests, return immediately, if we are client the SpawnRequests should always be empty.
if (m_SpawnRequests.size() == 0) { if (m_SpawnRequests.size() == 0) {