From 17da9a8036ca6d23512aabcadb4c18106f5bb69e Mon Sep 17 00:00:00 2001 From: Teejoon Date: Tue, 16 Feb 2016 15:56:58 +0100 Subject: [PATCH 01/28] WIP --- include/Engine/Rendering/ModelJob.h | 2 +- include/Engine/Rendering/SpriteJob.h | 8 +- resources/Schema/Components.xsd | 1 + resources/Schema/Components/Indicator.xml | 3 + resources/Schema/Components/Indicator.xsd | 11 + resources/Schema/Entities/JohansTestMap.xml | 5379 +++++++++++++++++ resources/Schema/Entities/TestPlayerIndicator | 590 ++ .../Schema/Entities/TestPlayerIndicator.xml | 590 ++ src/Engine/Rendering/RenderSystem.cpp | 35 +- 9 files changed, 6612 insertions(+), 7 deletions(-) create mode 100644 resources/Schema/Components/Indicator.xml create mode 100644 resources/Schema/Components/Indicator.xsd create mode 100644 resources/Schema/Entities/JohansTestMap.xml create mode 100644 resources/Schema/Entities/TestPlayerIndicator create mode 100644 resources/Schema/Entities/TestPlayerIndicator.xml diff --git a/include/Engine/Rendering/ModelJob.h b/include/Engine/Rendering/ModelJob.h index ba801f60..41b0b8dd 100644 --- a/include/Engine/Rendering/ModelJob.h +++ b/include/Engine/Rendering/ModelJob.h @@ -183,7 +183,7 @@ struct ModelJob : RenderJob void CalculateHash() override { - Hash = TextureID + ModelID << 10 + ShaderID << 20; + Hash = ShaderID << 20 + ModelID << 10 + TextureID; } }; diff --git a/include/Engine/Rendering/SpriteJob.h b/include/Engine/Rendering/SpriteJob.h index 3bb43a1c..07636a97 100644 --- a/include/Engine/Rendering/SpriteJob.h +++ b/include/Engine/Rendering/SpriteJob.h @@ -17,7 +17,7 @@ struct SpriteJob : RenderJob { - SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted) + SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator) : RenderJob() { Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh"); @@ -30,7 +30,7 @@ struct SpriteJob : RenderJob StartIndex = matProp.material->StartIndex; EndIndex = matProp.material->EndIndex; - Matrix = matrix; + Matrix = matrix; Color = cSprite["Color"]; Entity = cSprite.EntityID; Position = Transform::AbsolutePosition(world, cSprite.EntityID); @@ -40,7 +40,7 @@ struct SpriteJob : RenderJob Depth = viewpos.z; } World = world; - + IsIndicator = isIndicator; FillColor = fillColor; FillPercentage = fillPercentage; }; @@ -61,6 +61,8 @@ struct SpriteJob : RenderJob unsigned int EndIndex = 0; World* World; + bool IsIndicator = false; + glm::vec4 FillColor = glm::vec4(0); float FillPercentage = 0.0; diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index 61e49ae3..8a5f51f3 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -42,4 +42,5 @@ + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml new file mode 100644 index 00000000..cd4e3f46 --- /dev/null +++ b/resources/Schema/Components/Indicator.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/Indicator.xsd new file mode 100644 index 00000000..54a6bfe5 --- /dev/null +++ b/resources/Schema/Components/Indicator.xsd @@ -0,0 +1,11 @@ + + + + + + + + Billbord and makes a Model or Sprite too always appare on players screen + + + \ No newline at end of file diff --git a/resources/Schema/Entities/JohansTestMap.xml b/resources/Schema/Entities/JohansTestMap.xml new file mode 100644 index 00000000..06e97bdc --- /dev/null +++ b/resources/Schema/Entities/JohansTestMap.xml @@ -0,0 +1,5379 @@ + + + + + + + + + + + + + + + + + + Models/Props/Ground.mesh + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + Models/Props/Highground1.mesh + + + + + + + + + + + + Models/Props/Highground2.mesh + + + + + + + + + + + + Models/Props/Highground3.mesh + + + + + + + + + + Models/Props/Highground4.mesh + + + + + + + + + + Models/Props/Highground5.mesh + + + + + + + + + + + Models/Props/Highground6.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallTop.mesh + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall1.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall2.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallBig.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallMedium.mesh + + + + + + + + + + + + Models/Props/Walls/SciFiWallSmall3.mesh + + + + + + + + + + Models/Props/Walls/SciFiWallSmall4.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar1Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar3Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + Models/Props/Pillars/StonePillar.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiPillar2Red.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallBlue.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/BigWallRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall2.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SmallWall3.mesh + + + + + + + + + + + + Models/Props/Walls/SmallWall4.mesh + + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/SpecialWall1.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + Models/Props/Bridges/SciFiBridgeDefense.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Blue.mesh + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/SciFiBridge1Red.mesh + + + + + + + + + + + + + Models/Props/Bridges/WoodenBridge.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall2.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall3.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + Models/Core/UnitPlane.mesh + + true + + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + Models/Props/Pillars/SciFiBridgePillar1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/TreeLog.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/AliveBush.mesh + true + + + + + + + + + + + + + + Models/Props/Flora/SpecialRoot.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Walls/MediumWall1.mesh + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone1.mesh + + + + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone1.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + Models/Props/Stones/BigStone.mesh + + + + + + + + + + + + + Models/Props/Stones/SmallStone2.mesh + + + + + + + + + + + + + + Models/Props/Stones/MediumStone2.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + Models/Props/PickUps/PickUpHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + Models/Props/Stones/AssaultHolder.mesh + + + + + + + + + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + Models/Props/SciFiHolder1.mesh + + + + + + + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalBlue.mesh + + + + + + + + + + + + + + Models/Props/Stones/ShinyStoneCrystalRed.mesh + + + + + + + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointBlue.mesh + + + + + + + + + + + + + 4 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + false + + + + + + + + + + + + Textures/Test/SmallDiff.png + false + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 3 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 2 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointNeutral.mesh + + + + + + + + + + 1.5498908015879351 + 1 + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + Models/Props/CapturePoint/CapturePointRed.mesh + + + + + + + + + + + + + + + Models/Core/UnitCylinder.mesh + + true + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + false + + + + + + + + + + Textures/Test/SmallDiff.png + false + + + + + + + + + + + + + + + + + + + + + + + + 1 + + + + + + + + + 10 + + + + + + + + + + 10 + + + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 10 + + + + + + + + + + + 1 + + + + + + + + + + + + + + Schema/Entities/PlayerRed.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + Schema/Entities/Player.xml + + + + + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + Models/Characters/Assault/AssaultTPose.mesh + false + + + + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/HealthPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + Models/Props/PickUps/AmmoPickUp.mesh + + + 0.10000000149011612 + + + + + + + + + + + + + + + + diff --git a/resources/Schema/Entities/TestPlayerIndicator b/resources/Schema/Entities/TestPlayerIndicator new file mode 100644 index 00000000..504fa0db --- /dev/null +++ b/resources/Schema/Entities/TestPlayerIndicator @@ -0,0 +1,590 @@ + + + + + + + + + + 600 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1 + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 1 + + + 0.10332605343919568 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + Idle + 1.0214894690177836 + 1 + + + Models/Characters/Assault/FirstPerson.mesh + + true + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + true + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + Idle + 0.33673680560517383 + 1 + + + AimRifle + + + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + + + + + + + diff --git a/resources/Schema/Entities/TestPlayerIndicator.xml b/resources/Schema/Entities/TestPlayerIndicator.xml new file mode 100644 index 00000000..56390bcb --- /dev/null +++ b/resources/Schema/Entities/TestPlayerIndicator.xml @@ -0,0 +1,590 @@ + + + + + + + + + + 600 + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + + + + + + + + Textures/Weapons/Crosshair/SmallThickHoleDot.png + false + + + + + + + + + + + + Schema/Entities/HitMarker.xml + + + + + + + + + + + + + + 1 + + + + + 100/100 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + 1 + + + + Textures/HealthHUD3.png + + + + + + + + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 2 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 3 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 4 + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + 1 + + + 0.10332605343919568 + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + Textures/Core/UnitHexagon_Rotated.png + + + + + + + + + + + + + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + Idle + 0.71065405191594166 + 1 + + + Models/Characters/Assault/FirstPerson.mesh + + true + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + true + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectView.xml + + + + + + + + + + + + + + + + + + Textures/Core/UnitHexagon.png + + + + + + + + + + + + + + + + + + 32 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + 360 + Fonts/DroidSans.ttf,64 + + + + + + + + + + + + + + + + + + + + + + + + Models/Widgets/Camera.mesh + false + + + + + + + + + + + + Idle + 1.0759003871452997 + 1 + + + AimRifle + + + + + Models/Characters/Assault/AssaultAnimations.mesh + + + + + + + + + R_Arm_Weapon_Joint + + + Models/Weapons/Blue/AssaultWeaponBlue.mesh + + + + + + + + + + + Schema/Entities/RayBlue.xml + + + + + + + + + + + Schema/Entities/ReloadEffectWorld.xml + + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + + Models/Core/UnitCube.mesh + + false + + + + + + + + + + + Insert name here + Fonts/DroidSans.ttf,100 + + + + + + + + + + + + + + Textures/Test/aM4ME4GR.png + + + + + + + + + + diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index 665c4027..cd604b8c 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -67,11 +67,16 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl fillColor = (glm::vec4)fillComponent["Color"]; } - glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world); - //modelMatrix *= m_Camera->BillboardMatrix(); + glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world); + bool isIndicator = false; + if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) + { + isIndicator = true; + modelMatrix = modelMatrix * m_Camera->BillboardMatrix(); + } - std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted)); + std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted, isIndicator)); jobs.push_back(spriteJob); } @@ -94,6 +99,30 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) return false; } + // If a sprite is an Indicator, it's not local on player and object is in the same team, then dispaly it + if ( + (entity.HasComponent("Indicator")) + && (entity != m_LocalPlayer || !entity.IsChildOf(m_LocalPlayer)) + && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) + && entity.HasComponent("Sprite") + && m_LocalPlayer.World != nullptr + ) { + EntityWrapper entityTeam; + if (!entity.HasComponent("Team")) { + entityTeam = entity.FirstParentWithComponent("Team"); + } + else { + entityTeam = entity; + } + ComponentWrapper& entityTeamComponent = entityTeam["Team"]; + ComponentWrapper& localComponent = m_LocalPlayer["Team"]; + int entityTeamInt = entityTeamComponent["Team"]; + int localComponentInt = localComponent["Team"]; + int SpectatorInt = localComponent["Team"].Enum("Spectator"); + if (entityTeamInt != localComponentInt && localComponentInt != SpectatorInt) { + return false; + } + } return true; } From 4fd0108443e04cfe04d918f445cd3763fd8f54d6 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 17 Feb 2016 16:50:24 +0100 Subject: [PATCH 02/28] Working billbording --- resources/Schema/Components/Indicator.xml | 4 + resources/Schema/Components/Indicator.xsd | 14 +- resources/Schema/Entities/JohansTestMap.xml | 90 +-- resources/Schema/Entities/Player.xml | 30 +- resources/Schema/Entities/PlayerRed.xml | 29 +- resources/Schema/Entities/TestPlayerIndicator | 590 ------------------ .../Schema/Entities/TestPlayerIndicator.xml | 590 ------------------ src/Engine/Rendering/RenderSystem.cpp | 53 +- 8 files changed, 121 insertions(+), 1279 deletions(-) delete mode 100644 resources/Schema/Entities/TestPlayerIndicator delete mode 100644 resources/Schema/Entities/TestPlayerIndicator.xml diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml index cd4e3f46..3aab2d1b 100644 --- a/resources/Schema/Components/Indicator.xml +++ b/resources/Schema/Components/Indicator.xml @@ -1,3 +1,7 @@ + 10 + 10 + 1 + 1 \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/Indicator.xsd index 54a6bfe5..69e47821 100644 --- a/resources/Schema/Components/Indicator.xsd +++ b/resources/Schema/Components/Indicator.xsd @@ -5,7 +5,19 @@ - Billbord and makes a Model or Sprite too always appare on players screen + Billbord a Sprite around global Y axis + + + + After this distance between the camera and the sprite, the sprite will not get any smaller on the screen + + + Smaller distance between the camera and the sprite, the sprite will not get any bigger on the screen + + + + + \ No newline at end of file diff --git a/resources/Schema/Entities/JohansTestMap.xml b/resources/Schema/Entities/JohansTestMap.xml index 06e97bdc..c60ea350 100644 --- a/resources/Schema/Entities/JohansTestMap.xml +++ b/resources/Schema/Entities/JohansTestMap.xml @@ -4783,41 +4783,7 @@ - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - false - - - - - - - - - - - - Textures/Test/SmallDiff.png - false - - - - - - - - + @@ -4952,41 +4918,7 @@ - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - false - - - - - - - - - - Textures/Test/SmallDiff.png - false - - - - - - - - - - + @@ -5149,7 +5081,7 @@ - Schema/Entities/Player.xml + Schema/Entities/TestPlayerIndicator.xml @@ -5233,7 +5165,7 @@ - + @@ -5252,7 +5184,7 @@ - + @@ -5271,7 +5203,7 @@ - + @@ -5290,7 +5222,7 @@ - + @@ -5309,7 +5241,7 @@ - + @@ -5328,7 +5260,7 @@ - + @@ -5347,7 +5279,7 @@ - + @@ -5366,7 +5298,7 @@ - + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index be6009ba..64ebbf54 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -349,7 +349,7 @@ Idle - 1.6050530664521858 + 0.30516549779527224 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 1.620305457513453 + 1.9204144556290004 1 @@ -501,8 +501,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -572,6 +572,24 @@ + + + + 30 + + + Textures/Icons/Arrow.png + false + + + + + + + + + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index d9839e9f..a6c6d077 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -349,7 +349,7 @@ Idle - 1.6050530664521858 + 0.73262309029003347 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 1.620305457513453 + 0.031207590802594609 1 @@ -501,8 +501,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -572,6 +572,23 @@ + + + + 30 + + + Textures/Icons/Arrow.png + + + + + + + + + + diff --git a/resources/Schema/Entities/TestPlayerIndicator b/resources/Schema/Entities/TestPlayerIndicator deleted file mode 100644 index 504fa0db..00000000 --- a/resources/Schema/Entities/TestPlayerIndicator +++ /dev/null @@ -1,590 +0,0 @@ - - - - - - - - - - 600 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - - - - - - - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - false - - - - - - - - - - - - Schema/Entities/HitMarker.xml - - - - - - - - - - - - - - 1 - - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - 1 - - - - Textures/HealthHUD3.png - - - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 2 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 3 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 4 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - 0.10332605343919568 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - Idle - 1.0214894690177836 - 1 - - - Models/Characters/Assault/FirstPerson.mesh - - true - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - true - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - Idle - 0.33673680560517383 - 1 - - - AimRifle - - - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - Insert name here - Fonts/DroidSans.ttf,100 - - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - - - - - - - - - - diff --git a/resources/Schema/Entities/TestPlayerIndicator.xml b/resources/Schema/Entities/TestPlayerIndicator.xml deleted file mode 100644 index 56390bcb..00000000 --- a/resources/Schema/Entities/TestPlayerIndicator.xml +++ /dev/null @@ -1,590 +0,0 @@ - - - - - - - - - - 600 - - - - - - - - - 5 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - - - - - - - - Textures/Weapons/Crosshair/SmallThickHoleDot.png - false - - - - - - - - - - - - Schema/Entities/HitMarker.xml - - - - - - - - - - - - - - 1 - - - - - 100/100 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - 1 - - - - Textures/HealthHUD3.png - - - - - - - - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 2 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 3 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 4 - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - 1 - - - 0.10332605343919568 - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - Textures/Core/UnitHexagon_Rotated.png - - - - - - - - - - - - - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - Idle - 0.71065405191594166 - 1 - - - Models/Characters/Assault/FirstPerson.mesh - - true - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - true - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectView.xml - - - - - - - - - - - - - - - - - - Textures/Core/UnitHexagon.png - - - - - - - - - - - - - - - - - - 32 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - 360 - Fonts/DroidSans.ttf,64 - - - - - - - - - - - - - - - - - - - - - - - - Models/Widgets/Camera.mesh - false - - - - - - - - - - - - Idle - 1.0759003871452997 - 1 - - - AimRifle - - - - - Models/Characters/Assault/AssaultAnimations.mesh - - - - - - - - - R_Arm_Weapon_Joint - - - Models/Weapons/Blue/AssaultWeaponBlue.mesh - - - - - - - - - - - Schema/Entities/RayBlue.xml - - - - - - - - - - - Schema/Entities/ReloadEffectWorld.xml - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - - Models/Core/UnitCube.mesh - - false - - - - - - - - - - - Insert name here - Fonts/DroidSans.ttf,100 - - - - - - - - - - - - - - Textures/Test/aM4ME4GR.png - - - - - - - - - - diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index cd604b8c..c05b3681 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -67,13 +67,53 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl fillColor = (glm::vec4)fillComponent["Color"]; } - glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, world); - + glm::mat4 modelMatrix = glm::mat4(1); + bool isIndicator = false; if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) { isIndicator = true; - modelMatrix = modelMatrix * m_Camera->BillboardMatrix(); + glm::vec3 pos = Transform::AbsolutePosition(entity); + + + // Code for shcneking if sprite is inside or outside of screen + //glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f); + //projectedPos /= projectedPos.w; + //// Check if inside of outside of screen. + //if (projectedPos.x < -1.0f || projectedPos.x > 1.0f || projectedPos.y < -1.0f || projectedPos.y > 1.0f) { + // // is outside of screen + //} else { + // // is inside of screen + //} + + + glm::vec3 zAxis = glm::vec3(0.0f, 1.0f, 0.0f); + glm::vec3 normal = pos - m_Camera->Position(); + normal.y = 0; + normal = glm::normalize(normal); + glm::vec3 right = glm::cross(normal, zAxis); + glm::vec3 up = glm::cross(right, normal); + + modelMatrix[0][0] = right.x; + modelMatrix[0][1] = right.y; + modelMatrix[0][2] = right.z; + + modelMatrix[1][0] = zAxis.x; + modelMatrix[1][1] = zAxis.y; + modelMatrix[1][2] = zAxis.z; + + modelMatrix[2][0] = normal.x; + modelMatrix[2][1] = normal.y; + modelMatrix[2][2] = normal.z; + + modelMatrix[3][0] = pos.x; + modelMatrix[3][1] = pos.y; + modelMatrix[3][2] = pos.z; + + modelMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity)); + + } else { + modelMatrix = Transform::ModelMatrix(entity.ID, world); } std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted, isIndicator)); @@ -101,8 +141,8 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) // If a sprite is an Indicator, it's not local on player and object is in the same team, then dispaly it if ( - (entity.HasComponent("Indicator")) - && (entity != m_LocalPlayer || !entity.IsChildOf(m_LocalPlayer)) + entity.HasComponent("Indicator") + && !entity.IsChildOf(m_LocalPlayer) && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) && entity.HasComponent("Sprite") && m_LocalPlayer.World != nullptr @@ -110,8 +150,7 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) EntityWrapper entityTeam; if (!entity.HasComponent("Team")) { entityTeam = entity.FirstParentWithComponent("Team"); - } - else { + } else { entityTeam = entity; } ComponentWrapper& entityTeamComponent = entityTeam["Team"]; From 5e3af7ac5d6eb1ca0883ff5bf891bdb9b0688aee Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 17 Feb 2016 17:58:01 +0100 Subject: [PATCH 03/28] Player Indicator now working OK. Scaling depending on how far away you are makes the Indicator to hide players head behind it. Shields are making indicators to disappear. --- resources/Schema/Components/Indicator.xml | 5 +-- resources/Schema/Components/Indicator.xsd | 7 ----- resources/Schema/Entities/Player.xml | 16 +++++----- resources/Schema/Entities/PlayerRed.xml | 16 +++++----- src/Engine/Rendering/RenderSystem.cpp | 38 ++++++++++++++++++++--- 5 files changed, 51 insertions(+), 31 deletions(-) diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml index 3aab2d1b..1dfc0077 100644 --- a/resources/Schema/Components/Indicator.xml +++ b/resources/Schema/Components/Indicator.xml @@ -1,7 +1,4 @@ - 10 - 10 - 1 - 1 + 10 \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/Indicator.xsd index 69e47821..5015b13c 100644 --- a/resources/Schema/Components/Indicator.xsd +++ b/resources/Schema/Components/Indicator.xsd @@ -9,14 +9,7 @@ - - After this distance between the camera and the sprite, the sprite will not get any smaller on the screen - - - Smaller distance between the camera and the sprite, the sprite will not get any bigger on the screen - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index 64ebbf54..dfc8855c 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -349,7 +349,7 @@ Idle - 0.30516549779527224 + 1.9902125899398158 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 1.9204144556290004 + 1.7887947062665859 1 @@ -501,8 +501,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -575,7 +575,7 @@ - 30 + 80 Textures/Icons/Arrow.png @@ -585,7 +585,7 @@ - + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index a6c6d077..fc8dea66 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -349,7 +349,7 @@ Idle - 0.73262309029003347 + 1.5972608217572741 1 @@ -370,8 +370,8 @@ true - - + + @@ -477,7 +477,7 @@ Idle - 0.031207590802594609 + 1.0291785284465931 1 @@ -501,8 +501,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -575,7 +575,7 @@ - 30 + 80 Textures/Icons/Arrow.png @@ -584,7 +584,7 @@ - + diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index c05b3681..a0534fed 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -67,16 +67,26 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl fillColor = (glm::vec4)fillComponent["Color"]; } - glm::mat4 modelMatrix = glm::mat4(1); + glm::mat4 modelMatrix; bool isIndicator = false; if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) { + EntityWrapper EntityWithIndicator; + if (world->HasComponent(entity.ID, "Indicator")) { + EntityWithIndicator = entity; + } + else { + EntityWithIndicator = entity.FirstParentWithComponent("Indicator"); + } + auto indicator = EntityWithIndicator["Indicator"]; + + float minScale = (float)(double)indicator["MinScale"]; isIndicator = true; glm::vec3 pos = Transform::AbsolutePosition(entity); - // Code for shcneking if sprite is inside or outside of screen + // Code for check if sprite is inside or outside of screen //glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f); //projectedPos /= projectedPos.w; //// Check if inside of outside of screen. @@ -89,6 +99,13 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl glm::vec3 zAxis = glm::vec3(0.0f, 1.0f, 0.0f); glm::vec3 normal = pos - m_Camera->Position(); + + //float distance = glm::length(normal); + //if (distance < minDistance) { + // pos = pos - glm::normalize(normal) * (distance - minDistance); + //} else if (distance > maxDistance) { + // pos = pos - glm::normalize(normal) * (distance - maxDistance); + //} normal.y = 0; normal = glm::normalize(normal); glm::vec3 right = glm::cross(normal, zAxis); @@ -97,21 +114,34 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl modelMatrix[0][0] = right.x; modelMatrix[0][1] = right.y; modelMatrix[0][2] = right.z; + modelMatrix[0][3] = 0.0f; modelMatrix[1][0] = zAxis.x; modelMatrix[1][1] = zAxis.y; modelMatrix[1][2] = zAxis.z; + modelMatrix[1][3] = 0.0f; modelMatrix[2][0] = normal.x; modelMatrix[2][1] = normal.y; modelMatrix[2][2] = normal.z; + modelMatrix[2][3] = 0.0f; modelMatrix[3][0] = pos.x; modelMatrix[3][1] = pos.y; modelMatrix[3][2] = pos.z; + modelMatrix[3][3] = 1.0f; - modelMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity)); - + glm::mat4 tranformationMatrix = modelMatrix * glm::scale(Transform::AbsoluteScale(entity)); + glm::vec4 tmp = tranformationMatrix * glm::vec4(glm::vec3(0.5, 0.5, 0), 1.0f); + glm::vec2 projectedTopRight = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize()); + tmp = tranformationMatrix * glm::vec4(glm::vec3(-0.5, -0.5, 0), 1.0f); + glm::vec2 projectedBottomLeft = m_Camera->WorldToScreen(glm::vec3(tmp), m_Renderer->GetViewportSize()); + + float diag = glm::length(projectedBottomLeft - projectedTopRight); + if (diag < minScale) { + tranformationMatrix = tranformationMatrix * glm::scale(glm::vec3(minScale / diag, minScale / diag, minScale / diag)); + } + modelMatrix = tranformationMatrix; } else { modelMatrix = Transform::ModelMatrix(entity.ID, world); } From c4d3c515e4f77d1120b05c833f384cea7724e699 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 17 Feb 2016 18:04:49 +0100 Subject: [PATCH 04/28] Marge with Master --- resources/Schema/Entities/JohansTestMap.xml | 5311 ------------------- resources/Schema/Entities/Player.xml | 2 +- resources/Schema/Entities/PlayerRed.xml | 2 +- 3 files changed, 2 insertions(+), 5313 deletions(-) delete mode 100644 resources/Schema/Entities/JohansTestMap.xml diff --git a/resources/Schema/Entities/JohansTestMap.xml b/resources/Schema/Entities/JohansTestMap.xml deleted file mode 100644 index c60ea350..00000000 --- a/resources/Schema/Entities/JohansTestMap.xml +++ /dev/null @@ -1,5311 +0,0 @@ - - - - - - - - - - - - - - - - - - Models/Props/Ground.mesh - - - - - - - - - Models/Props/Highground1.mesh - - - - - - - - - - Models/Props/Highground2.mesh - - - - - - - - - - Models/Props/Highground1.mesh - - - - - - - - - - - - Models/Props/Highground2.mesh - - - - - - - - - - - - Models/Props/Highground3.mesh - - - - - - - - - - Models/Props/Highground4.mesh - - - - - - - - - - Models/Props/Highground5.mesh - - - - - - - - - - - Models/Props/Highground6.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallTop.mesh - - - - - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallMedium.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallSmall1.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallSmall2.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallBig.mesh - - - - - - - - - - - - Models/Props/Walls/SciFiWallMedium.mesh - - - - - - - - - - - - Models/Props/Walls/SciFiWallSmall3.mesh - - - - - - - - - - Models/Props/Walls/SciFiWallSmall4.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar3Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar1Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar3Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - Models/Props/Pillars/StonePillar.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiPillar2Red.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallBlue.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - Models/Props/Walls/BigWallRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall2.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SmallWall3.mesh - - - - - - - - - - - - Models/Props/Walls/SmallWall4.mesh - - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/SpecialWall1.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Red.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - Models/Props/Bridges/SciFiBridgeDefense.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Blue.mesh - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Red.mesh - - - - - - - - - - - - - Models/Props/Bridges/SciFiBridge1Red.mesh - - - - - - - - - - - - - Models/Props/Bridges/WoodenBridge.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall2.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall3.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - - - - - Models/Core/UnitPlane.mesh - - true - - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - Models/Core/UnitCube.mesh - - - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - Models/Props/Pillars/SciFiBridgePillar1.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - - Models/Props/Flora/TreeLog.mesh - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/AliveBush.mesh - true - - - - - - - - - - - - - - Models/Props/Flora/SpecialRoot.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Walls/MediumWall1.mesh - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone1.mesh - - - - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone1.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - Models/Props/Stones/BigStone.mesh - - - - - - - - - - - - - Models/Props/Stones/SmallStone2.mesh - - - - - - - - - - - - - - Models/Props/Stones/MediumStone2.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - Models/Props/PickUps/PickUpHolder.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - Models/Props/Stones/AssaultHolder.mesh - - - - - - - - - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - Models/Props/SciFiHolder1.mesh - - - - - - - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalBlue.mesh - - - - - - - - - - - - - - Models/Props/Stones/ShinyStoneCrystalRed.mesh - - - - - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointBlue.mesh - - - - - - - - - - - - - 4 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 3 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 2 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointNeutral.mesh - - - - - - - - - - 1.5498908015879351 - 1 - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - Models/Props/CapturePoint/CapturePointRed.mesh - - - - - - - - - - - - - - - Models/Core/UnitCylinder.mesh - - true - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - 10 - - - - - - - - - - 10 - - - - - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - 10 - - - - - - - - - - - 1 - - - - - - - - - - - - - - Schema/Entities/PlayerRed.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - - - Schema/Entities/TestPlayerIndicator.xml - - - - - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - Models/Characters/Assault/AssaultTPose.mesh - false - - - - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/HealthPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - Models/Props/PickUps/AmmoPickUp.mesh - - - 0.10000000149011612 - - - - - - - - - - - - - - - - diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index dfc8855c..4fd70af1 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -575,7 +575,7 @@ - 80 + 60 Textures/Icons/Arrow.png diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index fc8dea66..c9ac246d 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -575,7 +575,7 @@ - 80 + 60 Textures/Icons/Arrow.png From 949ee76f553cea745d575349d83fc2e3a39be950 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 19 Feb 2016 13:52:16 +0100 Subject: [PATCH 05/28] Fallow and name fix --- resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Rendering/DrawBloomPass.cpp | 2 +- src/Engine/Rendering/Renderer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index d757ff36..8e248aad 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -73,7 +73,7 @@ struct LightResult { }; float CalcAttenuation(float radius, float dist, float falloff) { - return 1.0 - smoothstep(radius * 0.3, radius, dist); + return 1.0 - smoothstep(radius * falloff, radius, dist); } vec4 CalcSpecular(vec4 lightColor, vec4 viewVec, vec4 lightVec, vec4 normal) { diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 23080a52..1855a653 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -122,7 +122,7 @@ void DrawBloomPass::Draw(GLuint texture) } -void DrawBloomPass::OnWindowRezise() +void DrawBloomPass::OnWindowResize() { GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); m_GaussianFrameBuffer_vert.Generate(); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index d0c06ea0..b8665fce 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -29,7 +29,7 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height currentRenderer->m_DrawFinalPass->OnWindowResize(); currentRenderer->m_LightCullingPass->OnWindowResize(); currentRenderer->m_PickingPass->OnWindowResize(); - currentRenderer->m_DrawBloomPass->OnWindowRezise(); + currentRenderer->m_DrawBloomPass->OnWindowResize(); } void Renderer::InitializeWindow() From 97fcdb342d5fcd51758b3eea3c3ae99debfd2604 Mon Sep 17 00:00:00 2001 From: Tleety Date: Fri, 19 Feb 2016 14:23:40 +0100 Subject: [PATCH 06/28] Bloom should now show behind transparent objects. --- resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Rendering/DrawFinalPass.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 8e248aad..2db0295c 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -169,7 +169,7 @@ void main() sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); color_result += glowTexel*GlowIntensity; - bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), 1.0); + bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); //Tiled Debug Code /* diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index d46f9591..1b99955a 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -191,8 +191,10 @@ void DrawFinalPass::Draw(RenderScene& scene) state->StencilMask(0x00); DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); GLERROR("OpaqueObjects"); + state->BlendFunc(GL_ONE, GL_ONE); DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); GLERROR("TransparentObjects"); + state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs"); From 201480b17f6d72b0ee082916e577cea34defa9f2 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Fri, 19 Feb 2016 16:50:04 +0100 Subject: [PATCH 07/28] SSAO is working, but is kinda crappy. You can change shade variables in the debug window. --- .../Rendering/DrawColorCorrectionPass.h | 2 +- include/Engine/Rendering/DrawFinalPass.h | 4 + include/Engine/Rendering/Renderer.h | 5 + include/Engine/Rendering/SSAOPass.h | 58 ++++++++ include/Engine/Rendering/SSAOPassState.h | 15 ++ .../Shaders/DrawColorCorrection.frag.glsl | 7 +- resources/Shaders/SSAO.frag.glsl | 106 ++++++++++++++ resources/Shaders/SSAO.vert.glsl | 8 ++ resources/Shaders/SSAOViewSpaceZ.frag.glsl | 14 ++ src/Engine/Rendering/DrawBloomPass.cpp | 34 +++-- .../Rendering/DrawColorCorrectionPass.cpp | 4 +- src/Engine/Rendering/DrawFinalPass.cpp | 56 +++++--- src/Engine/Rendering/Renderer.cpp | 15 +- src/Engine/Rendering/SSAOPass.cpp | 135 ++++++++++++++++++ src/Engine/Rendering/SSAOPassState.cpp | 16 +++ src/Engine/Rendering/ShaderProgram.cpp | 3 +- 16 files changed, 444 insertions(+), 38 deletions(-) create mode 100644 include/Engine/Rendering/SSAOPass.h create mode 100644 include/Engine/Rendering/SSAOPassState.h create mode 100644 resources/Shaders/SSAO.frag.glsl create mode 100644 resources/Shaders/SSAO.vert.glsl create mode 100644 resources/Shaders/SSAOViewSpaceZ.frag.glsl create mode 100644 src/Engine/Rendering/SSAOPass.cpp create mode 100644 src/Engine/Rendering/SSAOPassState.cpp diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index 231e2d33..db16cf98 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -17,7 +17,7 @@ public: void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure); + void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLuint SSAOTexture, GLfloat gamma, GLfloat exposure); private: const IRenderer* m_Renderer; diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index bf8d4d76..f1cf66c8 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -21,6 +21,9 @@ public: void Draw(RenderScene& scene); void ClearBuffer(); + //Return the texture that is used in later stages to apply the bloom effect + GLuint DepthBuffer() const { return m_DepthBuffer; } + Camera* DepthBufferCamera() const { return RenderCamera; } //Return the texture that is used in later stages to apply the bloom effect GLuint BloomTexture() const { return m_BloomTexture; } GLuint BloomTextureLowRes() const { return m_BloomTextureLowRes; } @@ -62,6 +65,7 @@ private: GLuint m_SceneTextureLowRes; GLuint m_DepthBuffer; GLuint m_DepthBufferLowRes; + Camera* RenderCamera; //maqke this component based i guess? GLuint m_ShieldPixelRate = 16; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 04754514..b613ba4f 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -16,6 +16,7 @@ #include "DrawScreenQuadPass.h" #include "DrawBloomPass.h" #include "DrawColorCorrectionPass.h" +#include "SSAOPass.h" #include "../Core/EventBroker.h" #include "ImGuiRenderPass.h" #include "Camera.h" @@ -50,6 +51,9 @@ private: Model* m_UnitSphere; int m_DebugTextureToDraw = 0; + float m_SSAO_Radius = 0.2f; + float m_SSAO_Bias = 0.012f; + float m_SSAO_Intensity = 1.0f; PickingPass* m_PickingPass; LightCullingPass* m_LightCullingPass; @@ -58,6 +62,7 @@ private: DrawScreenQuadPass* m_DrawScreenQuadPass; DrawBloomPass* m_DrawBloomPass; DrawColorCorrectionPass* m_DrawColorCorrectionPass; + SSAOPass* m_SSAOPass; //----------------------Functions----------------------// void InitializeWindow(); diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h new file mode 100644 index 00000000..22f53ded --- /dev/null +++ b/include/Engine/Rendering/SSAOPass.h @@ -0,0 +1,58 @@ +#ifndef SSAOPass_h__ +#define SSAOPass_h__ + +#include "IRenderer.h" +#include "SSAOPassState.h" +//#include "LightCullingPass.h" Finalpass om den skall skickas in +#include "FrameBuffer.h" +#include "ShaderProgram.h" +#include "DrawBloomPass.h" +//#include "Util/UnorderedMapVec2.h" +#include "Texture.h" + +class SSAOPass +{ +public: + SSAOPass(IRenderer* rendere); + ~SSAOPass() { }; + + void Draw(GLuint depthBuffer, Camera* camera); + void Setting(float radius, float bias, float intensity); + void ClearBuffer(); + + //Return the SSAO of the texture sent to Draw + GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); } + +private: + void InitializeTexture(); + void InitializeFrameBuffer(); + void InitializeShaderProgram(); + void InitializeBuffer(); + + void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; + + void ComputeAO(GLuint depthBuffer, Camera* camera); + //void blurHorizontal(GLuint depthBuffer); + //void blurVertical(GLuint depthBuffer); + + Model* m_ScreenQuad; + + const IRenderer* m_Renderer; + + float m_Radius; + float m_Bias; + float m_Intensity; + + GLuint m_SSAOTexture; + FrameBuffer m_SSAOFramBuffer; + + GLuint m_SSAOViewSpaceZTexture; + FrameBuffer m_SSAOViewSpaceZFramBuffer; + + ShaderProgram* m_SSAOProgram; + ShaderProgram* m_SSAOViewSpaceZProgram; + + DrawBloomPass* m_DrawBloomPass; +}; + +#endif \ No newline at end of file diff --git a/include/Engine/Rendering/SSAOPassState.h b/include/Engine/Rendering/SSAOPassState.h new file mode 100644 index 00000000..115fdcf7 --- /dev/null +++ b/include/Engine/Rendering/SSAOPassState.h @@ -0,0 +1,15 @@ +#ifndef SSAOPassState_h__ +#define SSAOPassState_h__ + +#include "Rendering/RenderState.h" + +class SSAOPassState : public RenderState +{ +public: + SSAOPassState(); + ~SSAOPassState(); +private: + +}; + +#endif \ No newline at end of file diff --git a/resources/Shaders/DrawColorCorrection.frag.glsl b/resources/Shaders/DrawColorCorrection.frag.glsl index 76db3e82..838a78f6 100644 --- a/resources/Shaders/DrawColorCorrection.frag.glsl +++ b/resources/Shaders/DrawColorCorrection.frag.glsl @@ -4,6 +4,7 @@ layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 1) uniform sampler2D BloomTexture; layout (binding = 2) uniform sampler2D SceneTextureLowRes; layout (binding = 3) uniform sampler2D BloomTextureLowRes; +layout (binding = 4) uniform sampler2D SSAOTexture; uniform float Exposure; uniform float Gamma; @@ -19,6 +20,10 @@ void main() vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate); vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate); + vec4 SSAO = texture(SSAOTexture, Input.TextureCoordinate); + + //hdrColor = hdrColor * SSAO; + SSAO = clamp(SSAO, 0.1f, 1.0f); hdrColor += bloomColor; hdrColorLowRes; @@ -33,7 +38,7 @@ void main() //gamme correction result = pow(result, vec3(1.0 / Gamma)); - + result = result * SSAO.rgb; fragmentColor = vec4(result, 1.0); //fragmentColor = hdrColor; //fragmentColor = bloomColor; diff --git a/resources/Shaders/SSAO.frag.glsl b/resources/Shaders/SSAO.frag.glsl new file mode 100644 index 00000000..b9ba58ce --- /dev/null +++ b/resources/Shaders/SSAO.frag.glsl @@ -0,0 +1,106 @@ +#version 430 + +//Number of samples per pixel +#define NUM_SAMPLES (24) + +//Number of turns around the cirle +#define NUM_TURNS (7) + +uniform sampler2D ViewSpaceZ; + +uniform vec4 ProjInfo; + +uniform float ProjScale; +//#define ProjScale 500 + +uniform float Radius; +//#define Radius 1.0f + +uniform float Bias; +//#define Bias 0.012f + +uniform float IntensityDivR6; +//#define IntensityDivR6 1 + +out vec4 fragmentColor; + +vec3 reconstructVSPosition(vec2 ScreenSpaceCoord, float z){ + return vec3((ScreenSpaceCoord * ProjInfo.xy + ProjInfo.zw) * z, z); +} + +vec3 getPosition(ivec2 ScreenSpaceCoord) { + vec3 P; + P.z = texelFetch(ViewSpaceZ, ScreenSpaceCoord, 0).r; + //Get the xy view space coordinates and add the z value from ViewSpaceZ buffer. + return reconstructVSPosition(vec2(ScreenSpaceCoord) + vec2(0.5), P.z); +} + +vec3 getVSFaceNormal(vec3 ViewSpacePosition) { + // Get tangets vector for the plane and ViewSpacePositin... don't ask how this functions works. It's pure magic. + // They do this and it just works... I would guess that they approximate the function of a plane from pixels close to the pixel were on now. + return normalize(cross(dFdx(ViewSpacePosition), dFdy(ViewSpacePosition))); +} + + +vec3 getSampleViewSpacePos(ivec2 ScreenSpaceCoord, int SampleIndex, float RotationAngle, float ScreenSpaceSampleRadius){ + // Pure Magic... + float alpha = float(SampleIndex + 0.5) * (1.0 / NUM_SAMPLES); + + // Angle to where to sample + float angle = alpha * (NUM_TURNS * 6.28) + RotationAngle; + + //Lenght to were to sample + ScreenSpaceSampleRadius = ScreenSpaceSampleRadius * alpha; + + vec2 screenSpaceSampleOffsetVecor = vec2(cos(angle), sin(angle)); + + // Get texel coordinate on where to sample by going screenSpaceSampleOffsetVecor direction in ScreenSpaceSampleRadius units from ScreenSpaceCoord (the point being shaded); + ivec2 screenSpaceSampleTexel = ivec2(ScreenSpaceSampleRadius * screenSpaceSampleOffsetVecor) + ScreenSpaceCoord; + + return getPosition(screenSpaceSampleTexel); +} + +float Radius2 = Radius * Radius; + +float sampleAO(ivec2 ScreenSpaceCoord, vec3 ShadedViewSpacePosition, vec3 ViewSpaceNormal, float ScreenSpaceSampleRadius, int SampleIndex, float RotationAngle) { + vec3 sampleViewSpacePosition = getSampleViewSpacePos(ScreenSpaceCoord, SampleIndex, RotationAngle, ScreenSpaceSampleRadius); + + vec3 sampleVector = ShadedViewSpacePosition - sampleViewSpacePosition; + + // vv = sampleVectorLenght ^ 2 + float vv = dot(sampleVector, sampleVector); + // vn = angle between sampleVector and Normal + float vn = dot(sampleVector, ViewSpaceNormal); + + const float epsilon = 0.01f; + + // vv < radius2 if the vector is shorter then the radius; + // vn - bias, offset the angle to reduse self occlusion. + // epsilon is here to make divison by 0 impossible. + return float(vv < Radius2) * max((vn - Bias) / (epsilon + vv), 0.0); + //float f = max(Radius2 - vv, 0.0); + //return f * f * f * max((vn - Bias) / (epsilon + vv), 0.0); +} + + +void main() { + ivec2 originScreenCoord = ivec2(gl_FragCoord.xy); + + vec3 origin = getPosition(originScreenCoord); + + vec3 viewSpaceNormal = getVSFaceNormal(origin); + + float screenSpaceSampleRadius = ProjScale * Radius / origin.z; + + //Offset on what angle to start on so that not evry pixel start sampling in the same direction, AlchemyAO + float rotationAngleOffset = (3 * originScreenCoord.x ^ originScreenCoord.y + originScreenCoord.x * originScreenCoord.y) * 10; + + float sum = 0.0; + for (int i = 0; i < NUM_SAMPLES; i++) { + sum += sampleAO(originScreenCoord, origin, viewSpaceNormal, screenSpaceSampleRadius, i, rotationAngleOffset); + } + + float A = max(0.0, 1.0 - sum * (2.0f / NUM_SAMPLES)); + //fragmentColor= vec4(viewSpaceNormal, 1.0f); + fragmentColor = vec4(A, A, A, 1.0f); +} diff --git a/resources/Shaders/SSAO.vert.glsl b/resources/Shaders/SSAO.vert.glsl new file mode 100644 index 00000000..a019c5ef --- /dev/null +++ b/resources/Shaders/SSAO.vert.glsl @@ -0,0 +1,8 @@ +#version 430 + +layout (location = 0) in vec3 Position; + +void main() +{ + gl_Position = vec4(Position, 1.0); +} \ No newline at end of file diff --git a/resources/Shaders/SSAOViewSpaceZ.frag.glsl b/resources/Shaders/SSAOViewSpaceZ.frag.glsl new file mode 100644 index 00000000..e4ec491b --- /dev/null +++ b/resources/Shaders/SSAOViewSpaceZ.frag.glsl @@ -0,0 +1,14 @@ +#version 430 + +uniform sampler2D DepthBuffer; +uniform vec3 ClipInfo; + +//out float depthLinear; +//Just for Debug, should be depthLinear +out vec4 fragmentColor; +void main() { + float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r; + float depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]); + //float depthLinear = (NearClip) / ( -depthSample + 1.0f); + fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f); +} \ No newline at end of file diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 46612d5e..e12ebd91 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -19,16 +19,20 @@ void DrawBloomPass::InitializeTextures() void DrawBloomPass::InitializeShaderPrograms() { m_GaussianProgram_horiz = ResourceManager::Load("##GaussianProgramHoriz"); - m_GaussianProgram_horiz->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_horiz.vert.glsl"))); - m_GaussianProgram_horiz->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl"))); - m_GaussianProgram_horiz->Compile(); - m_GaussianProgram_horiz->Link(); + if (m_GaussianProgram_horiz->GetHandle() == 0) { + m_GaussianProgram_horiz->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_horiz.vert.glsl"))); + m_GaussianProgram_horiz->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_horiz.frag.glsl"))); + m_GaussianProgram_horiz->Compile(); + m_GaussianProgram_horiz->Link(); + } - m_GaussianProgram_vert = ResourceManager::Load("##GaussianProgramVert"); - m_GaussianProgram_vert->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_vert.vert.glsl"))); - m_GaussianProgram_vert->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_vert.frag.glsl"))); - m_GaussianProgram_vert->Compile(); - m_GaussianProgram_vert->Link(); + m_GaussianProgram_vert = ResourceManager::Load("##GaussianProgramVert"); + if (m_GaussianProgram_vert->GetHandle() == 0) { + m_GaussianProgram_vert->AddShader(std::shared_ptr(new VertexShader("Shaders/Gaussian_vert.vert.glsl"))); + m_GaussianProgram_vert->AddShader(std::shared_ptr(new FragmentShader("Shaders/Gaussian_vert.frag.glsl"))); + m_GaussianProgram_vert->Compile(); + m_GaussianProgram_vert->Link(); + } } @@ -70,16 +74,18 @@ void DrawBloomPass::Draw(GLuint texture) //Horizontal pass, first use the given texture then save it to the horizontal framebuffer. m_GaussianFrameBuffer_horiz.Bind(); + GLERROR("m_GaussianFrameBuffer_horiz.Bind()"); m_GaussianProgram_horiz->Bind(); - + GLERROR("m_GaussianProgram_horiz->Bind()"); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); - + GLERROR("glBindTexture"); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); + GLERROR("GL_ELEMENT_ARRAY_BUFFER"); 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("HEJ"); //Iterate some times to make it more gaussian. for (int i = 1; i < m_iterations; i++) { //Vertical pass @@ -92,7 +98,7 @@ void DrawBloomPass::Draw(GLuint texture) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); - + GLERROR("HEJ LOOP"); //horizontal pass m_GaussianFrameBuffer_horiz.Bind(); @@ -112,7 +118,7 @@ void DrawBloomPass::Draw(GLuint texture) m_GaussianProgram_vert->Bind(); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); - + GLERROR("GL_TEXTURE_2D"); 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 diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index c82d614f..620bd896 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -18,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() m_ColorCorrectionProgram->Link(); } -void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure) +void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLuint SSAOTexture, GLfloat gamma, GLfloat exposure) { //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); @@ -37,6 +37,8 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLu glBindTexture(GL_TEXTURE_2D, sceneTextureLowRes); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, bloomTextureLowRes); + glActiveTexture(GL_TEXTURE4); + glBindTexture(GL_TEXTURE_2D, SSAOTexture); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 11db71f0..a2681c65 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -22,10 +22,21 @@ void DrawFinalPass::InitializeTextures() void DrawFinalPass::InitializeFrameBuffers() { - glGenRenderbuffers(1, &m_DepthBuffer); + + glGenTextures(1, &m_DepthBuffer); + + glBindTexture(GL_TEXTURE_2D, m_DepthBuffer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width), (int)(m_Renderer->GetViewportSize().Height), 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + + /*glGenRenderbuffers(1, &m_DepthBuffer); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - GLERROR("RenderBuffer generation"); + GLERROR("RenderBuffer generation");*/ + GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); @@ -33,7 +44,7 @@ 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); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); - m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); + m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); //m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1))); @@ -176,10 +187,12 @@ void DrawFinalPass::InitializeShaderPrograms() void DrawFinalPass::Draw(RenderScene& scene) { GLERROR("Pre"); - + RenderCamera = scene.Camera; DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); if (scene.ClearDepth) { - glClear(GL_DEPTH_BUFFER_BIT); + //glClear(GL_DEPTH_BUFFER_BIT); + state->Disable(GL_DEPTH_TEST); + state->DepthMask(GL_FALSE); } //TODO: Do we need check for this or will it be per scene always? glClearStencil(0x00); @@ -241,7 +254,7 @@ void DrawFinalPass::Draw(RenderScene& scene) DrawShieldToStencilBuffer(scene.Jobs.ShieldObjects, scene); GLERROR("StencilPass"); - glClear(GL_DEPTH_BUFFER_BIT); + //glClear(GL_DEPTH_BUFFER_BIT); stateLowRes->Enable(GL_DEPTH_TEST); stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF); @@ -743,17 +756,26 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { - GLERROR("Bind 1 uniform"); - GLint Location_M = glGetUniformLocation(shaderHandle, "M"); - glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); - GLERROR("Bind 2 uniform"); - GLint Location_V = glGetUniformLocation(shaderHandle, "V"); - glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); - GLERROR("Bind 3 uniform"); - GLint Location_P = glGetUniformLocation(shaderHandle, "P"); - glUniformMatrix4fv(Location_P, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - GLERROR("Bind 4 uniform"); - + if (1/*job->Model->IsSkinned()*/) { + GLERROR("Bind 1 uniform"); + GLint Location_M = glGetUniformLocation(shaderHandle, "M"); + glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); + GLERROR("Bind 2 uniform"); + GLint Location_V = glGetUniformLocation(shaderHandle, "V"); + glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); + GLERROR("Bind 3 uniform"); + GLint Location_P = glGetUniformLocation(shaderHandle, "P"); + glUniformMatrix4fv(Location_P, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + GLERROR("Bind 4 uniform"); + } else { + GLERROR("Bind 1 uniform"); + GLint Location_M = glGetUniformLocation(shaderHandle, "M"); + glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); + GLERROR("Bind 2 uniform"); + GLint Location_V = glGetUniformLocation(shaderHandle, "PV"); + glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix())); + GLERROR("Bind 3 uniform"); + } GLint Location_ScreenDimensions = glGetUniformLocation(shaderHandle, "ScreenDimensions"); glUniform2f(Location_ScreenDimensions, m_Renderer->Resolution().Width, m_Renderer->Resolution().Height); GLERROR("Bind 5 uniform"); diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index be84160c..79c935a5 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -93,7 +93,12 @@ void Renderer::Update(double dt) void Renderer::Draw(RenderFrame& frame) { - ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking"); + ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0SSAO"); + + ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.0001f, 1.0f); + ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 1.0f); + ImGui::SliderFloat("SSAO intensity", &m_SSAO_Intensity, 0.0f, 1.0f); + m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Intensity); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -124,8 +129,10 @@ void Renderer::Draw(RenderFrame& frame) } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); + m_SSAOPass->Draw(m_DrawFinalPass->DepthBuffer(), m_DrawFinalPass->DepthBufferCamera()); + if (m_DebugTextureToDraw == 0) { - m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure); + m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), m_SSAOPass->SSAOTexture(), frame.Gamma, frame.Exposure); } if (m_DebugTextureToDraw == 1) { m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture()); @@ -145,6 +152,9 @@ void Renderer::Draw(RenderFrame& frame) if (m_DebugTextureToDraw == 6) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); } + if (m_DebugTextureToDraw == 7) { + m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture()); + } m_ImGuiRenderPass->Draw(); GLERROR("Imgui draw"); @@ -191,4 +201,5 @@ void Renderer::InitializeRenderPasses() m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); + m_SSAOPass = new SSAOPass(this); } diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp new file mode 100644 index 00000000..67b5cf33 --- /dev/null +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -0,0 +1,135 @@ +#include "Rendering/SSAOPass.h" + +SSAOPass::SSAOPass(IRenderer* renderer) +{ + m_Renderer = renderer; + + m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); + + InitializeBuffer(); + InitializeShaderProgram(); + Setting(0.1f, 0.012f, 1.0f); + + m_DrawBloomPass = new DrawBloomPass(renderer); +} + +void SSAOPass::InitializeShaderProgram() +{ + m_SSAOProgram = ResourceManager::Load("##SSAOProgram"); + m_SSAOProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); + m_SSAOProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAO.frag.glsl"))); + m_SSAOProgram->Compile(); + m_SSAOProgram->Link(); + + m_SSAOViewSpaceZProgram = ResourceManager::Load("##SSAOViewSpaceZProgram"); + m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new VertexShader("Shaders/SSAO.vert.glsl"))); + m_SSAOViewSpaceZProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/SSAOViewSpaceZ.frag.glsl"))); + m_SSAOViewSpaceZProgram->Compile(); + m_SSAOViewSpaceZProgram->Link(); +} + + +void SSAOPass::InitializeBuffer() +{ + GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + + m_SSAOFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); + m_SSAOFramBuffer.Generate(); + + GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB32F, GL_RGB, GL_FLOAT); + + m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0))); + m_SSAOViewSpaceZFramBuffer.Generate(); +} + +void SSAOPass::ClearBuffer() +{ + m_SSAOFramBuffer.Bind(); + glClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_SSAOFramBuffer.Unbind(); + + m_SSAOViewSpaceZFramBuffer.Bind(); + glClearColor(0.f, 0.f, 0.f, 0.f); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + m_SSAOViewSpaceZFramBuffer.Unbind(); +} + +void SSAOPass::Setting(float radius, float bias, float intensity) { + m_Radius = radius; + m_Bias = bias; + m_Intensity = intensity; +} + +void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const +{ + glGenTextures(1, texture); + glBindTexture(GL_TEXTURE_2D, *texture); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering); + glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, dimensions.x, dimensions.y, 0, format, type, nullptr); + GLERROR("Texture initialization failed"); +} + +void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) +{ + SSAOPassState state; + GLuint viewSpaceZPShaderHandle = m_SSAOViewSpaceZProgram->GetHandle(); + GLuint SSAOShaderHandle = m_SSAOProgram->GetHandle(); + + m_SSAOViewSpaceZFramBuffer.Bind(); + m_SSAOViewSpaceZProgram->Bind(); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, depthBuffer); + glm::vec3 clipInfo = glm::vec3( + (camera->NearClip() * camera->FarClip()), + (camera->NearClip() - camera->FarClip()), + (camera->FarClip()) + ); + /*glm::vec3 clipInfo = glm::vec3( + (camera->NearClip()), + (-1.0f), + (+1.0f) + );*/ + glUniform3fv(glGetUniformLocation(viewSpaceZPShaderHandle, "ClipInfo"), 1, glm::value_ptr(clipInfo)); + + glBindVertexArray(m_ScreenQuad->VAO); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); + glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 + , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + + glm::vec4 projInfo = glm::vec4( + (-2.0f / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])), + (-2.0f / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1])), + ((1.0f - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]), + ((1.0f - camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]) + ); + + + m_SSAOFramBuffer.Bind(); + m_SSAOProgram->Bind(); + + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture); + + // How many pixel there are in a 1m long object 1m away from the camera + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "ProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f))); + + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "Radius"), m_Radius); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "Bias"), m_Bias); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "IntensityDivR6"), m_Intensity / glm::pow(m_Radius, 6)); + + glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "ProjInfo"), 1, glm::value_ptr(projInfo)); + glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 + , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); + + m_DrawBloomPass->ClearBuffer(); + m_DrawBloomPass->Draw(m_SSAOTexture); +} + +void ComputeAO(GLuint depthBuffer, Camera* camera) { + +} \ No newline at end of file diff --git a/src/Engine/Rendering/SSAOPassState.cpp b/src/Engine/Rendering/SSAOPassState.cpp new file mode 100644 index 00000000..7dd49841 --- /dev/null +++ b/src/Engine/Rendering/SSAOPassState.cpp @@ -0,0 +1,16 @@ +#include "Rendering/SSAOPassState.h" + + +SSAOPassState::SSAOPassState() +{ + //BindFramebuffer(0); + Disable(GL_BLEND); + Disable(GL_DEPTH_TEST); + Disable(GL_CULL_FACE); +} + +SSAOPassState::~SSAOPassState() +{ + +} + diff --git a/src/Engine/Rendering/ShaderProgram.cpp b/src/Engine/Rendering/ShaderProgram.cpp index 9c26c15c..ae536bc0 100644 --- a/src/Engine/Rendering/ShaderProgram.cpp +++ b/src/Engine/Rendering/ShaderProgram.cpp @@ -98,8 +98,7 @@ void ShaderProgram::AddShader(std::shared_ptr shader) void ShaderProgram::Compile() { - if (m_ShaderProgramHandle == 0) - { + if (m_ShaderProgramHandle == 0) { m_ShaderProgramHandle = glCreateProgram(); } From adceccf4029f23fcf3be52983766583dcc6fb58c Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 22 Feb 2016 14:48:20 +0100 Subject: [PATCH 08/28] SSAO now working. Changed in DrawFinalePass so that th AOTexture is on texture position 0 and only get binded once. Changed so that the picking pass get drawn once in the beginning so that the AO shatde could calculate AO from the depthbuffer generated during pthe pickingpass. In the ImGUI debugg window there is now sliders to change the behavior of the AO shader. Only the minimum ambient lightning is HardCoded in to the frowardPlus fragmentshaders with a define in the begining. --- .../Rendering/DrawColorCorrectionPass.h | 2 +- include/Engine/Rendering/DrawFinalPass.h | 4 +- include/Engine/Rendering/Renderer.h | 9 +- include/Engine/Rendering/SSAOPass.h | 7 +- resources/Schema/Entities/Player.xml | 14 ++-- resources/Schema/Entities/PlayerRed.xml | 14 ++-- .../Shaders/DrawColorCorrection.frag.glsl | 4 - resources/Shaders/ForwardPlus.frag.glsl | 19 +++-- .../Shaders/ForwardPlusSplatMapRGB.frag.glsl | 38 +++++---- resources/Shaders/SSAO.frag.glsl | 82 ++++++++++--------- resources/Shaders/SSAOViewSpaceZ.frag.glsl | 10 +-- resources/Shaders/Sprite.frag.glsl | 4 +- src/Engine/Rendering/DrawBloomPass.cpp | 7 -- .../Rendering/DrawColorCorrectionPass.cpp | 4 +- src/Engine/Rendering/DrawFinalPass.cpp | 64 +++++++-------- src/Engine/Rendering/PickingPass.cpp | 19 ++++- src/Engine/Rendering/Renderer.cpp | 27 +++--- src/Engine/Rendering/SSAOPass.cpp | 34 ++++---- 18 files changed, 192 insertions(+), 170 deletions(-) diff --git a/include/Engine/Rendering/DrawColorCorrectionPass.h b/include/Engine/Rendering/DrawColorCorrectionPass.h index db16cf98..231e2d33 100644 --- a/include/Engine/Rendering/DrawColorCorrectionPass.h +++ b/include/Engine/Rendering/DrawColorCorrectionPass.h @@ -17,7 +17,7 @@ public: void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLuint SSAOTexture, GLfloat gamma, GLfloat exposure); + void Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure); private: const IRenderer* m_Renderer; diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index f1cf66c8..54f9407f 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -18,7 +18,7 @@ public: void InitializeTextures(); void InitializeFrameBuffers(); void InitializeShaderPrograms(); - void Draw(RenderScene& scene); + void Draw(RenderScene& scene, GLuint SSAOTexture); void ClearBuffer(); //Return the texture that is used in later stages to apply the bloom effect @@ -40,7 +40,7 @@ private: void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const; void DrawSprites(std::list>&jobs, RenderScene& scene); - void DrawModelRenderQueues(std::list>& jobs, RenderScene& scene); + void DrawModelRenderQueues(std::list>& jobs, RenderScene& scene, GLuint SSAOTexture); void DrawShieldToStencilBuffer(std::list>& jobs, RenderScene& scene); void DrawShieldedModelRenderQueue(std::list>& jobs, RenderScene& scene); void DrawToDepthBuffer(std::list>& jobs, RenderScene& scene); diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index b613ba4f..d8c60cd8 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -51,9 +51,12 @@ private: Model* m_UnitSphere; int m_DebugTextureToDraw = 0; - float m_SSAO_Radius = 0.2f; - float m_SSAO_Bias = 0.012f; - float m_SSAO_Intensity = 1.0f; + float m_SSAO_Radius = 1.0f; + float m_SSAO_Bias = 0.05f; + float m_SSAO_Contrast = 1.5f; + float m_SSAO_IntensityScale = 1.0f; + int m_SSAO_NumOfSamples = 24; + int m_SSAO_NumOfTurns = 7; PickingPass* m_PickingPass; LightCullingPass* m_LightCullingPass; diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h index 22f53ded..f15e20d3 100644 --- a/include/Engine/Rendering/SSAOPass.h +++ b/include/Engine/Rendering/SSAOPass.h @@ -17,7 +17,7 @@ public: ~SSAOPass() { }; void Draw(GLuint depthBuffer, Camera* camera); - void Setting(float radius, float bias, float intensity); + void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns); void ClearBuffer(); //Return the SSAO of the texture sent to Draw @@ -41,7 +41,10 @@ private: float m_Radius; float m_Bias; - float m_Intensity; + float m_Contrast; + float m_IntensityScale; + int m_NumOfSamples; + int m_NumOfTurns; GLuint m_SSAOTexture; FrameBuffer m_SSAOFramBuffer; diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index be6009ba..d4485112 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -349,13 +349,12 @@ Idle - 1.6050530664521858 + 1.8314163732853146 1 Models/Characters/Assault/FirstPerson.mesh - true @@ -367,11 +366,10 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - true - - + + @@ -477,7 +475,7 @@ Idle - 1.620305457513453 + 0.16333512901638159 1 @@ -501,8 +499,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index d9839e9f..4be8fc26 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -349,13 +349,12 @@ Idle - 1.6050530664521858 + 0.018170670865885086 1 Models/Characters/Assault/FirstPerson.mesh - true @@ -367,11 +366,10 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - true - - + + @@ -477,7 +475,7 @@ Idle - 1.620305457513453 + 0.11675631578762591 1 @@ -501,8 +499,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + diff --git a/resources/Shaders/DrawColorCorrection.frag.glsl b/resources/Shaders/DrawColorCorrection.frag.glsl index 838a78f6..bae50887 100644 --- a/resources/Shaders/DrawColorCorrection.frag.glsl +++ b/resources/Shaders/DrawColorCorrection.frag.glsl @@ -4,7 +4,6 @@ layout (binding = 0) uniform sampler2D SceneTexture; layout (binding = 1) uniform sampler2D BloomTexture; layout (binding = 2) uniform sampler2D SceneTextureLowRes; layout (binding = 3) uniform sampler2D BloomTextureLowRes; -layout (binding = 4) uniform sampler2D SSAOTexture; uniform float Exposure; uniform float Gamma; @@ -20,10 +19,8 @@ void main() vec4 bloomColor = texture(BloomTexture, Input.TextureCoordinate); vec4 hdrColorLowRes = texture(SceneTextureLowRes, Input.TextureCoordinate); vec4 bloomColorLowRes = texture(BloomTextureLowRes, Input.TextureCoordinate); - vec4 SSAO = texture(SSAOTexture, Input.TextureCoordinate); //hdrColor = hdrColor * SSAO; - SSAO = clamp(SSAO, 0.1f, 1.0f); hdrColor += bloomColor; hdrColorLowRes; @@ -38,7 +35,6 @@ void main() //gamme correction result = pow(result, vec3(1.0 / Gamma)); - result = result * SSAO.rgb; fragmentColor = vec4(result, 1.0); //fragmentColor = hdrColor; //fragmentColor = bloomColor; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 471ee20b..b4e0022b 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -1,5 +1,7 @@ #version 430 +#define MIN_AMBIENT_LIGHT 0.3 + uniform mat4 M; uniform mat4 V; uniform mat4 P; @@ -14,10 +16,11 @@ uniform vec2 DiffuseUVRepeat; uniform vec2 NormalUVRepeat; uniform vec2 SpecularUVRepeat; uniform vec2 GlowUVRepeat; -layout (binding = 0) uniform sampler2D DiffuseTexture; -layout (binding = 1) uniform sampler2D NormalMapTexture; -layout (binding = 2) uniform sampler2D SpecularMapTexture; -layout (binding = 3) uniform sampler2D GlowMapTexture; +layout (binding = 0) uniform sampler2D AOTexture; +layout (binding = 1) uniform sampler2D DiffuseTexture; +layout (binding = 2) uniform sampler2D NormalMapTexture; +layout (binding = 3) uniform sampler2D SpecularMapTexture; +layout (binding = 4) uniform sampler2D GlowMapTexture; #define TILE_SIZE 16 @@ -119,6 +122,8 @@ vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textu void main() { + float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; + ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat); vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat); vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat); @@ -133,7 +138,7 @@ void main() tilePos.y = int(gl_FragCoord.y/TILE_SIZE); LightResult totalLighting; - totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0); + totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0); int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE))); int start = int(LightGrids.Data[currentTile].Start); @@ -151,8 +156,8 @@ void main() } else if (light.Type == 2) { //Directional light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); } - totalLighting.Diffuse += light_result.Diffuse; - totalLighting.Specular += light_result.Specular; + totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a); + totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a); } vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); diff --git a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl index e862d926..cf358b96 100644 --- a/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl +++ b/resources/Shaders/ForwardPlusSplatMapRGB.frag.glsl @@ -1,5 +1,7 @@ #version 430 +#define MIN_AMBIENT_LIGHT 0.3 + uniform mat4 M; uniform mat4 V; uniform mat4 P; @@ -23,19 +25,20 @@ uniform vec2 SpecularUVRepeat3; uniform vec2 GlowUVRepeat1; uniform vec2 GlowUVRepeat2; uniform vec2 GlowUVRepeat3; -layout (binding = 0) uniform sampler2D SplatMapTexture; -layout (binding = 1) uniform sampler2D DiffuseTexture1; -layout (binding = 2) uniform sampler2D DiffuseTexture2; -layout (binding = 3) uniform sampler2D DiffuseTexture3; -layout (binding = 4) uniform sampler2D NormalMapTexture1; -layout (binding = 5) uniform sampler2D NormalMapTexture2; -layout (binding = 6) uniform sampler2D NormalMapTexture3; -layout (binding = 7) uniform sampler2D SpecularMapTexture1; -layout (binding = 8) uniform sampler2D SpecularMapTexture2; -layout (binding = 9) uniform sampler2D SpecularMapTexture3; -layout (binding = 10) uniform sampler2D GlowMapTexture1; -layout (binding = 11) uniform sampler2D GlowMapTexture2; -layout (binding = 12) uniform sampler2D GlowMapTexture3; +layout (binding = 0) uniform sampler2D AOTexture; +layout (binding = 1) uniform sampler2D SplatMapTexture; +layout (binding = 2) uniform sampler2D DiffuseTexture1; +layout (binding = 3) uniform sampler2D DiffuseTexture2; +layout (binding = 4) uniform sampler2D DiffuseTexture3; +layout (binding = 5) uniform sampler2D NormalMapTexture1; +layout (binding = 6) uniform sampler2D NormalMapTexture2; +layout (binding = 7) uniform sampler2D NormalMapTexture3; +layout (binding = 8) uniform sampler2D SpecularMapTexture1; +layout (binding = 9) uniform sampler2D SpecularMapTexture2; +layout (binding = 10) uniform sampler2D SpecularMapTexture3; +layout (binding = 11) uniform sampler2D GlowMapTexture1; +layout (binding = 12) uniform sampler2D GlowMapTexture2; +layout (binding = 13) uniform sampler2D GlowMapTexture3; #define TILE_SIZE 16 @@ -174,6 +177,9 @@ vec4 CalcBlendedNormal(vec4 blendValue, sampler2D R, sampler2D G, sampler2D B, void main() { + float ao = texelFetch(AOTexture, ivec2(gl_FragCoord.xy), 0).r; + ao = (clamp(1.0 - (1.0 - ao), 0.0, 1.0) + MIN_AMBIENT_LIGHT) / (1.0 + MIN_AMBIENT_LIGHT); + vec4 splatTexel = texture2D(SplatMapTexture, Input.TextureCoordinate); vec4 diffuseTexel = CalcBlendedTexel(splatTexel, DiffuseTexture1, DiffuseTexture2, DiffuseTexture3, @@ -195,7 +201,7 @@ void main() tilePos.y = int(gl_FragCoord.y/TILE_SIZE); LightResult totalLighting; - totalLighting.Diffuse = vec4(AmbientColor.rgb, 1.0); + totalLighting.Diffuse = vec4(AmbientColor.rgb * ao, 1.0); int currentTile = int(floor(gl_FragCoord.x/TILE_SIZE) + (floor(gl_FragCoord.y/TILE_SIZE) * int(ScreenDimensions.x/TILE_SIZE))); int start = int(LightGrids.Data[currentTile].Start); @@ -213,8 +219,8 @@ void main() } else if (light.Type == 2) { //Directional light_result = CalcDirectionalLightSource(V * light.Direction, light.Color, light.Intensity, viewVec, normal); } - totalLighting.Diffuse += light_result.Diffuse; - totalLighting.Specular += light_result.Specular; + totalLighting.Diffuse += vec4(light_result.Diffuse.rgb * ao, light_result.Diffuse.a); + totalLighting.Specular += vec4(light_result.Specular.rgb * ao, light_result.Specular.a); } vec4 color_result = mix((Color * diffuseTexel * DiffuseColor), Input.ExplosionColor, Input.ExplosionPercentageElapsed); diff --git a/resources/Shaders/SSAO.frag.glsl b/resources/Shaders/SSAO.frag.glsl index b9ba58ce..68c830f8 100644 --- a/resources/Shaders/SSAO.frag.glsl +++ b/resources/Shaders/SSAO.frag.glsl @@ -1,38 +1,37 @@ #version 430 //Number of samples per pixel -#define NUM_SAMPLES (24) +uniform int uNumOfSamples; +//#define NUM_SAMPLES (11) //Number of turns around the cirle -#define NUM_TURNS (7) +uniform int uNumOfTurns; +//#define NUM_TURNS (7) -uniform sampler2D ViewSpaceZ; +layout (binding = 0) uniform sampler2D ViewSpaceZ; -uniform vec4 ProjInfo; +uniform vec4 uProjInfo; -uniform float ProjScale; +uniform float uProjScale; //#define ProjScale 500 -uniform float Radius; +uniform float uRadius; //#define Radius 1.0f -uniform float Bias; +uniform float uBias; //#define Bias 0.012f -uniform float IntensityDivR6; +uniform float uContrast; //#define IntensityDivR6 1 -out vec4 fragmentColor; +uniform float uIntensityScale; -vec3 reconstructVSPosition(vec2 ScreenSpaceCoord, float z){ - return vec3((ScreenSpaceCoord * ProjInfo.xy + ProjInfo.zw) * z, z); -} +out float AO; -vec3 getPosition(ivec2 ScreenSpaceCoord) { - vec3 P; - P.z = texelFetch(ViewSpaceZ, ScreenSpaceCoord, 0).r; +vec3 getVSPosition(ivec2 ScreenSpaceCoord) { + float z = texelFetch(ViewSpaceZ, ScreenSpaceCoord, 0).r; //Get the xy view space coordinates and add the z value from ViewSpaceZ buffer. - return reconstructVSPosition(vec2(ScreenSpaceCoord) + vec2(0.5), P.z); + return vec3((uProjInfo[0] + (ScreenSpaceCoord.x * uProjInfo[1])) * z, (uProjInfo[2] + (ScreenSpaceCoord.y * uProjInfo[3])) * z, z); } vec3 getVSFaceNormal(vec3 ViewSpacePosition) { @@ -44,10 +43,10 @@ vec3 getVSFaceNormal(vec3 ViewSpacePosition) { vec3 getSampleViewSpacePos(ivec2 ScreenSpaceCoord, int SampleIndex, float RotationAngle, float ScreenSpaceSampleRadius){ // Pure Magic... - float alpha = float(SampleIndex + 0.5) * (1.0 / NUM_SAMPLES); + float alpha = float(SampleIndex) * (1.0 / uNumOfSamples); // Angle to where to sample - float angle = alpha * (NUM_TURNS * 6.28) + RotationAngle; + float angle = alpha * (uNumOfTurns * 6.28) + RotationAngle; //Lenght to were to sample ScreenSpaceSampleRadius = ScreenSpaceSampleRadius * alpha; @@ -57,50 +56,59 @@ vec3 getSampleViewSpacePos(ivec2 ScreenSpaceCoord, int SampleIndex, float Rotati // Get texel coordinate on where to sample by going screenSpaceSampleOffsetVecor direction in ScreenSpaceSampleRadius units from ScreenSpaceCoord (the point being shaded); ivec2 screenSpaceSampleTexel = ivec2(ScreenSpaceSampleRadius * screenSpaceSampleOffsetVecor) + ScreenSpaceCoord; - return getPosition(screenSpaceSampleTexel); + return getVSPosition(screenSpaceSampleTexel); } -float Radius2 = Radius * Radius; -float sampleAO(ivec2 ScreenSpaceCoord, vec3 ShadedViewSpacePosition, vec3 ViewSpaceNormal, float ScreenSpaceSampleRadius, int SampleIndex, float RotationAngle) { + +float sampleAO(ivec2 ScreenSpaceCoord, vec3 Origin, vec3 OriginNormal, float ScreenSpaceSampleRadius, int SampleIndex, float RotationAngle, float Radius) { + float radius2 = Radius * Radius; vec3 sampleViewSpacePosition = getSampleViewSpacePos(ScreenSpaceCoord, SampleIndex, RotationAngle, ScreenSpaceSampleRadius); - vec3 sampleVector = ShadedViewSpacePosition - sampleViewSpacePosition; + vec3 sampleVector = Origin - sampleViewSpacePosition; // vv = sampleVectorLenght ^ 2 float vv = dot(sampleVector, sampleVector); // vn = angle between sampleVector and Normal - float vn = dot(sampleVector, ViewSpaceNormal); + float vn = dot(sampleVector, OriginNormal); - const float epsilon = 0.01f; + const float epsilon = 0.0001f; // vv < radius2 if the vector is shorter then the radius; // vn - bias, offset the angle to reduse self occlusion. // epsilon is here to make divison by 0 impossible. - return float(vv < Radius2) * max((vn - Bias) / (epsilon + vv), 0.0); - //float f = max(Radius2 - vv, 0.0); - //return f * f * f * max((vn - Bias) / (epsilon + vv), 0.0); + return float(vv < radius2) * max((vn - uBias) / (epsilon + vv), 0.0); + //float f = max(radius2 - vv, 0.0); + //return f * f * f * max((vn - uBias) / (epsilon + vv), 0.0); } void main() { ivec2 originScreenCoord = ivec2(gl_FragCoord.xy); - vec3 origin = getPosition(originScreenCoord); + vec3 origin = getVSPosition(originScreenCoord); - vec3 viewSpaceNormal = getVSFaceNormal(origin); + float radius; + if(origin.z < uRadius){ + radius = origin.z; + } else { + radius = uRadius; + } - float screenSpaceSampleRadius = ProjScale * Radius / origin.z; - //Offset on what angle to start on so that not evry pixel start sampling in the same direction, AlchemyAO - float rotationAngleOffset = (3 * originScreenCoord.x ^ originScreenCoord.y + originScreenCoord.x * originScreenCoord.y) * 10; + vec3 originNormal = getVSFaceNormal(origin); + + float screenSpaceSampleRadius = -uProjScale * radius / origin.z; + + float rotationAngleOffset = 30 * originScreenCoord.x ^ originScreenCoord.y + 10 * originScreenCoord.x * originScreenCoord.y; float sum = 0.0; - for (int i = 0; i < NUM_SAMPLES; i++) { - sum += sampleAO(originScreenCoord, origin, viewSpaceNormal, screenSpaceSampleRadius, i, rotationAngleOffset); + for (int i = 0; i < uNumOfSamples; i++) { + sum += sampleAO(originScreenCoord, origin, originNormal, screenSpaceSampleRadius, i, rotationAngleOffset, radius); } - float A = max(0.0, 1.0 - sum * (2.0f / NUM_SAMPLES)); - //fragmentColor= vec4(viewSpaceNormal, 1.0f); - fragmentColor = vec4(A, A, A, 1.0f); + //float A = max(0.0, 1.0 - sum * (2.0f / uNumOfSamples)); + float A = 1.0 - sum * (2.0f * uIntensityScale / float(uNumOfSamples)); + AO = clamp(pow(A, uContrast), 0.0f, 1.0f); + //AO = vec4(originNormal, 1.0f); } diff --git a/resources/Shaders/SSAOViewSpaceZ.frag.glsl b/resources/Shaders/SSAOViewSpaceZ.frag.glsl index e4ec491b..dbcfd899 100644 --- a/resources/Shaders/SSAOViewSpaceZ.frag.glsl +++ b/resources/Shaders/SSAOViewSpaceZ.frag.glsl @@ -1,14 +1,14 @@ #version 430 -uniform sampler2D DepthBuffer; +layout (binding = 0) uniform sampler2D DepthBuffer; uniform vec3 ClipInfo; -//out float depthLinear; +out float depthLinear; //Just for Debug, should be depthLinear -out vec4 fragmentColor; +//out vec4 fragmentColor; void main() { float depthSample = texelFetch(DepthBuffer, ivec2(gl_FragCoord.xy), 0).r; - float depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]); + depthLinear = ClipInfo[0] / (ClipInfo[1] * depthSample + ClipInfo[2]); //float depthLinear = (NearClip) / ( -depthSample + 1.0f); - fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f); + //fragmentColor = vec4(depthLinear, depthLinear, depthLinear, 1.0f); } \ No newline at end of file diff --git a/resources/Shaders/Sprite.frag.glsl b/resources/Shaders/Sprite.frag.glsl index 9ce2bbdf..754be6ac 100644 --- a/resources/Shaders/Sprite.frag.glsl +++ b/resources/Shaders/Sprite.frag.glsl @@ -7,8 +7,8 @@ uniform mat4 M; uniform mat4 V; uniform mat4 P; -layout (binding = 0) uniform sampler2D DiffuseTexture; -layout (binding = 1) uniform sampler2D GlowMapTexture; +layout (binding = 1) uniform sampler2D DiffuseTexture; +layout (binding = 2) uniform sampler2D GlowMapTexture; in VertexData{ diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index e12ebd91..7479962e 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -74,18 +74,13 @@ void DrawBloomPass::Draw(GLuint texture) //Horizontal pass, first use the given texture then save it to the horizontal framebuffer. m_GaussianFrameBuffer_horiz.Bind(); - GLERROR("m_GaussianFrameBuffer_horiz.Bind()"); m_GaussianProgram_horiz->Bind(); - GLERROR("m_GaussianProgram_horiz->Bind()"); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, texture); - GLERROR("glBindTexture"); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); - GLERROR("GL_ELEMENT_ARRAY_BUFFER"); 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("HEJ"); //Iterate some times to make it more gaussian. for (int i = 1; i < m_iterations; i++) { //Vertical pass @@ -98,7 +93,6 @@ void DrawBloomPass::Draw(GLuint texture) glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); - GLERROR("HEJ LOOP"); //horizontal pass m_GaussianFrameBuffer_horiz.Bind(); @@ -118,7 +112,6 @@ void DrawBloomPass::Draw(GLuint texture) m_GaussianProgram_vert->Bind(); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); - GLERROR("GL_TEXTURE_2D"); 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 diff --git a/src/Engine/Rendering/DrawColorCorrectionPass.cpp b/src/Engine/Rendering/DrawColorCorrectionPass.cpp index 620bd896..c82d614f 100644 --- a/src/Engine/Rendering/DrawColorCorrectionPass.cpp +++ b/src/Engine/Rendering/DrawColorCorrectionPass.cpp @@ -18,7 +18,7 @@ void DrawColorCorrectionPass::InitializeShaderPrograms() m_ColorCorrectionProgram->Link(); } -void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLuint SSAOTexture, GLfloat gamma, GLfloat exposure) +void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLuint sceneTextureLowRes, GLuint bloomTextureLowRes, GLfloat gamma, GLfloat exposure) { //glBindFramebuffer(GL_FRAMEBUFFER, 0); GLERROR("DrawScreenQuadPass::Draw: Pre"); @@ -37,8 +37,6 @@ void DrawColorCorrectionPass::Draw(GLuint sceneTexture, GLuint bloomTexture, GLu glBindTexture(GL_TEXTURE_2D, sceneTextureLowRes); glActiveTexture(GL_TEXTURE3); glBindTexture(GL_TEXTURE_2D, bloomTextureLowRes); - glActiveTexture(GL_TEXTURE4); - glBindTexture(GL_TEXTURE_2D, SSAOTexture); glBindVertexArray(m_ScreenQuad->VAO); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index a2681c65..9f2113d7 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -22,20 +22,10 @@ void DrawFinalPass::InitializeTextures() void DrawFinalPass::InitializeFrameBuffers() { - - glGenTextures(1, &m_DepthBuffer); - - glBindTexture(GL_TEXTURE_2D, m_DepthBuffer); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width), (int)(m_Renderer->GetViewportSize().Height), 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - - /*glGenRenderbuffers(1, &m_DepthBuffer); + glGenRenderbuffers(1, &m_DepthBuffer); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); - GLERROR("RenderBuffer generation");*/ + GLERROR("RenderBuffer generation"); GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); @@ -44,7 +34,7 @@ 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); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); - m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); + m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_STENCIL_ATTACHMENT))); //m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_StencilTexture, GL_STENCIL_ATTACHMENT))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0))); m_FinalPassFrameBuffer.AddResource(std::shared_ptr(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1))); @@ -184,7 +174,7 @@ void DrawFinalPass::InitializeShaderPrograms() GLERROR("Creating DepthFill program"); } -void DrawFinalPass::Draw(RenderScene& scene) +void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) { GLERROR("Pre"); RenderCamera = scene.Camera; @@ -199,12 +189,11 @@ void DrawFinalPass::Draw(RenderScene& scene) glClear(GL_STENCIL_BUFFER_BIT); //Fill depth buffer - - + state->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); + DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); GLERROR("OpaqueObjects"); - DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); + DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); GLERROR("TransparentObjects"); DrawSprites(scene.Jobs.SpriteJob, scene); GLERROR("SpriteJobs"); @@ -219,11 +208,11 @@ void DrawFinalPass::Draw(RenderScene& scene) //Draw Opaque shielded objects state->StencilFunc(GL_NOTEQUAL, 1, 0xFF); state->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene); //might need changing + DrawModelRenderQueues(scene.Jobs.OpaqueShieldedObjects, scene, SSAOTexture); //might need changing GLERROR("Shielded Opaque object"); //Draw Transparen Shielded objects - DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene); //might need changing + DrawModelRenderQueues(scene.Jobs.TransparentShieldedObjects, scene, SSAOTexture); //might need changing GLERROR("Shielded Transparent objects"); GLERROR("END"); @@ -259,9 +248,9 @@ void DrawFinalPass::Draw(RenderScene& scene) stateLowRes->Enable(GL_DEPTH_TEST); stateLowRes->StencilFunc(GL_LEQUAL, 1, 0xFF); stateLowRes->StencilMask(0x00); - DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene); + DrawModelRenderQueues(scene.Jobs.OpaqueObjects, scene, SSAOTexture); GLERROR("OpaqueObjects"); - DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene); + DrawModelRenderQueues(scene.Jobs.TransparentObjects, scene, SSAOTexture); GLERROR("TransparentObjects"); glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); glScissor(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); @@ -313,7 +302,7 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm: GLERROR("MipMap Texture initialization failed"); } -void DrawFinalPass::DrawModelRenderQueues(std::list>& jobs, RenderScene& scene) +void DrawFinalPass::DrawModelRenderQueues(std::list>& jobs, RenderScene& scene, GLuint SSAOTexture) { GLuint forwardHandle = m_ForwardPlusProgram->GetHandle(); GLERROR("forwardHandle"); @@ -336,6 +325,9 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO()); glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO()); + glActiveTexture(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, SSAOTexture); + for (auto &job : jobs) { auto explosionEffectJob = std::dynamic_pointer_cast(job); if (explosionEffectJob) { @@ -682,14 +674,14 @@ void DrawFinalPass::DrawSprites(std::list>&jobs, Rend glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor)); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage); - glActiveTexture(GL_TEXTURE0); + glActiveTexture(GL_TEXTURE1); if (spriteJob->DiffuseTexture != nullptr) { glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture); } else { glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture); } - glActiveTexture(GL_TEXTURE1); + glActiveTexture(GL_TEXTURE2); if (spriteJob->IncandescenceTexture != nullptr) { glBindTexture(GL_TEXTURE_2D, spriteJob->IncandescenceTexture->m_Texture); } else { @@ -804,7 +796,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptrDiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat)); @@ -814,7 +806,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptrNormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat)); @@ -824,7 +816,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptrSpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat)); @@ -834,7 +826,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptrIncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat)); @@ -847,7 +839,7 @@ void DrawFinalPass::BindExplosionTextures(GLuint shaderHandle, std::shared_ptrSplatMap->Texture->m_Texture); int texturePosition = GL_TEXTURE1; @@ -922,7 +914,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrDiffuseTexture.size() > 0 && job->DiffuseTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "DiffuseUVRepeat"), 1, glm::value_ptr(job->DiffuseTexture[0]->UVRepeat)); @@ -932,7 +924,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrNormalTexture.size() > 0 && job->NormalTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->NormalTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "NormalUVRepeat"), 1, glm::value_ptr(job->NormalTexture[0]->UVRepeat)); @@ -942,7 +934,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrSpecularTexture.size() > 0 && job->SpecularTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->SpecularTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "SpecularUVRepeat"), 1, glm::value_ptr(job->SpecularTexture[0]->UVRepeat)); @@ -952,7 +944,7 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrIncandescenceTexture.size() > 0 && job->IncandescenceTexture[0]->Texture != nullptr) { glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture[0]->Texture->m_Texture); glUniform2fv(glGetUniformLocation(shaderHandle, "GlowUVRepeat"), 1, glm::value_ptr(job->IncandescenceTexture[0]->UVRepeat)); @@ -965,10 +957,10 @@ void DrawFinalPass::BindModelTextures(GLuint shaderHandle, std::shared_ptrSplatMap->Texture->m_Texture); - int texturePosition = GL_TEXTURE1; + int texturePosition = GL_TEXTURE2; //Bind 5 diffuse textures std::string UniformName = "DiffuseUVRepeat"; diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index ecd0a4b8..73679a68 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -23,11 +23,20 @@ void PickingPass::InitializeTextures() void PickingPass::InitializeFrameBuffers() { - glGenRenderbuffers(1, &m_DepthBuffer); + /* glGenRenderbuffers(1, &m_DepthBuffer); glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); + glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);*/ - m_PickingBuffer.AddResource(std::shared_ptr(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); + glGenTextures(1, &m_DepthBuffer); + + glBindTexture(GL_TEXTURE_2D, m_DepthBuffer); + glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width), (int)(m_Renderer->GetViewportSize().Height), 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); + + m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0))); m_PickingBuffer.Generate(); } @@ -61,7 +70,9 @@ void PickingPass::Draw(RenderScene& scene) m_PickingProgram->Bind(); if (scene.ClearDepth) { - glClear(GL_DEPTH_BUFFER_BIT); + //glClear(GL_DEPTH_BUFFER_BIT); + state->Disable(GL_DEPTH_TEST); + state->DepthMask(GL_FALSE); } m_Camera = scene.Camera; diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 79c935a5..2336ff99 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -93,12 +93,15 @@ void Renderer::Update(double dt) void Renderer::Draw(RenderFrame& frame) { - ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0SSAO"); + ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); - ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.0001f, 1.0f); - ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 1.0f); - ImGui::SliderFloat("SSAO intensity", &m_SSAO_Intensity, 0.0f, 1.0f); - m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Intensity); + ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); + ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f); + ImGui::SliderFloat("SSAO contrast", &m_SSAO_Contrast, 0.0f, 10.0f); + ImGui::SliderFloat("SSAO IntensityScale", &m_SSAO_IntensityScale, 0.0f, 10.0f); + ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100); + ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50); + m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -107,20 +110,23 @@ void Renderer::Draw(RenderFrame& frame) m_PickingPass->ClearPicking(); m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); - + for (auto scene : frame.RenderScenes) { + m_PickingPass->Draw(*scene); + GLERROR("Drawing pickingpass"); + } + m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); + GLuint ao = m_SSAOPass->SSAOTexture(); for (auto scene : frame.RenderScenes){ SortRenderJobsByDepth(*scene); GLERROR("SortByDepth"); - m_PickingPass->Draw(*scene); - GLERROR("Drawing pickingpass"); m_LightCullingPass->GenerateNewFrustum(*scene); GLERROR("Generate frustums"); m_LightCullingPass->FillLightList(*scene); GLERROR("Filling light list"); m_LightCullingPass->CullLights(*scene); GLERROR("LightCulling"); - m_DrawFinalPass->Draw(*scene); + m_DrawFinalPass->Draw(*scene, ao); GLERROR("Draw Geometry+Light"); //m_DrawScenePass->Draw(*scene); @@ -129,10 +135,9 @@ void Renderer::Draw(RenderFrame& frame) } m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); - m_SSAOPass->Draw(m_DrawFinalPass->DepthBuffer(), m_DrawFinalPass->DepthBufferCamera()); if (m_DebugTextureToDraw == 0) { - m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), m_SSAOPass->SSAOTexture(), frame.Gamma, frame.Exposure); + m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure); } if (m_DebugTextureToDraw == 1) { m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture()); diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 67b5cf33..331e040f 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -8,7 +8,7 @@ SSAOPass::SSAOPass(IRenderer* renderer) InitializeBuffer(); InitializeShaderProgram(); - Setting(0.1f, 0.012f, 1.0f); + Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7); m_DrawBloomPass = new DrawBloomPass(renderer); } @@ -31,12 +31,12 @@ void SSAOPass::InitializeShaderProgram() void SSAOPass::InitializeBuffer() { - GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); + GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); m_SSAOFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); m_SSAOFramBuffer.Generate(); - GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB32F, GL_RGB, GL_FLOAT); + GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0))); m_SSAOViewSpaceZFramBuffer.Generate(); @@ -55,10 +55,13 @@ void SSAOPass::ClearBuffer() m_SSAOViewSpaceZFramBuffer.Unbind(); } -void SSAOPass::Setting(float radius, float bias, float intensity) { +void SSAOPass::Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns) { m_Radius = radius; m_Bias = bias; - m_Intensity = intensity; + m_Contrast = contrast; + m_IntensityScale = intensityScale; + m_NumOfSamples = numOfSamples; + m_NumOfTurns = NumOfTurns; } void SSAOPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const @@ -102,10 +105,10 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); glm::vec4 projInfo = glm::vec4( - (-2.0f / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])), - (-2.0f / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1])), - ((1.0f - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]), - ((1.0f - camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]) + ((1.0 - camera->ProjectionMatrix()[0][2]) / camera->ProjectionMatrix()[0][0]), + (-2.0 / (m_Renderer->GetViewportSize().Width * camera->ProjectionMatrix()[0][0])), + ((1.0 + camera->ProjectionMatrix()[1][2]) / camera->ProjectionMatrix()[1][1]), + (-2.0 / (m_Renderer->GetViewportSize().Height * camera->ProjectionMatrix()[1][1])) ); @@ -116,13 +119,16 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) glBindTexture(GL_TEXTURE_2D, m_SSAOViewSpaceZTexture); // How many pixel there are in a 1m long object 1m away from the camera - glUniform1f(glGetUniformLocation(SSAOShaderHandle, "ProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f))); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uProjScale"), m_Renderer->GetViewportSize().Height / (-2.0f * glm::tan(camera->FOV() * 0.5f))); - glUniform1f(glGetUniformLocation(SSAOShaderHandle, "Radius"), m_Radius); - glUniform1f(glGetUniformLocation(SSAOShaderHandle, "Bias"), m_Bias); - glUniform1f(glGetUniformLocation(SSAOShaderHandle, "IntensityDivR6"), m_Intensity / glm::pow(m_Radius, 6)); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uRadius"), m_Radius); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uBias"), m_Bias); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uContrast"), m_Contrast); + glUniform1f(glGetUniformLocation(SSAOShaderHandle, "uIntensityScale"), m_IntensityScale); + glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfSamples"), m_NumOfSamples); + glUniform1i(glGetUniformLocation(SSAOShaderHandle, "uNumOfTurns"), m_NumOfTurns);; - glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "ProjInfo"), 1, glm::value_ptr(projInfo)); + glUniform4fv(glGetUniformLocation(SSAOShaderHandle, "uProjInfo"), 1, glm::value_ptr(projInfo)); glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex); From 4cf8c3d8d7dacbb6d5ab9fd74deb1377e367a038 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 22 Feb 2016 15:02:20 +0100 Subject: [PATCH 09/28] Fixed PerformanceTimer start and stop in Renderer.cpp since I have changed a little code there --- src/Engine/Rendering/Renderer.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 3ab05514..0c668cad 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -128,17 +128,20 @@ void Renderer::Draw(RenderFrame& frame) m_DrawBloomPass->ClearBuffer(); PerformanceTimer::StopTimer("Renderer-ClearBuffers"); for (auto scene : frame.RenderScenes) { + PerformanceTimer::StartTimer("Renderer-Depth"); m_PickingPass->Draw(*scene); GLERROR("Drawing pickingpass"); + PerformanceTimer::StopTimer("Renderer-Depth"); } + PerformanceTimer::StartTimer("AO generation"); m_SSAOPass->Draw(m_PickingPass->DepthBuffer(), frame.RenderScenes.front()->Camera); GLuint ao = m_SSAOPass->SSAOTexture(); + PerformanceTimer::StopTimer("AO generation"); for (auto scene : frame.RenderScenes){ - PerformanceTimer::StartTimer("Renderer-Depth"); + PerformanceTimer::StartTimer("Renderer-Drawing PickingPass"); SortRenderJobsByDepth(*scene); GLERROR("SortByDepth"); - PerformanceTimer::StartTimerAndStopPrevious("Renderer-Drawing PickingPass"); PerformanceTimer::StartTimerAndStopPrevious("Renderer-Generate Frustrums"); m_LightCullingPass->GenerateNewFrustum(*scene); GLERROR("Generate frustums"); @@ -158,14 +161,17 @@ void Renderer::Draw(RenderFrame& frame) GLERROR("Draw Text"); PerformanceTimer::StopTimer("Renderer-Draw Text"); } + PerformanceTimer::StartTimer("Renderer-Draw Bloom"); m_DrawBloomPass->Draw(m_DrawFinalPass->BloomTexture()); PerformanceTimer::StopTimer("Renderer-Draw Bloom"); + if (m_DebugTextureToDraw == 0) { PerformanceTimer::StartTimer("Renderer-Color Correction Pass"); m_DrawColorCorrectionPass->Draw(m_DrawFinalPass->SceneTexture(), m_DrawBloomPass->GaussianTexture(), m_DrawFinalPass->SceneTextureLowRes(), m_DrawFinalPass->BloomTextureLowRes(), frame.Gamma, frame.Exposure); PerformanceTimer::StopTimer("Renderer-Color Correction Pass"); } + PerformanceTimer::StartTimer("Renderer-Misc Debug Draws"); if (m_DebugTextureToDraw == 1) { m_DrawScreenQuadPass->Draw(m_DrawFinalPass->SceneTexture()); @@ -185,10 +191,10 @@ void Renderer::Draw(RenderFrame& frame) if (m_DebugTextureToDraw == 6) { m_DrawScreenQuadPass->Draw(m_PickingPass->PickingTexture()); } - PerformanceTimer::StopTimer("Renderer-Misc Debug Draws"); if (m_DebugTextureToDraw == 7) { m_DrawScreenQuadPass->Draw(m_SSAOPass->SSAOTexture()); } + PerformanceTimer::StopTimer("Renderer-Misc Debug Draws"); PerformanceTimer::StartTimer("Renderer-ImGuiRenderPass"); m_ImGuiRenderPass->Draw(); From 09aec08d0e210ee045e72821d73aeec60b79e9dd Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 22 Feb 2016 16:38:20 +0100 Subject: [PATCH 10/28] Pull request fixes --- include/Engine/Rendering/DrawFinalPass.h | 4 --- src/Engine/Rendering/DrawFinalPass.cpp | 32 ++++++++---------------- 2 files changed, 11 insertions(+), 25 deletions(-) diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index 0be65caf..e3389471 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -22,9 +22,6 @@ public: void ClearBuffer(); void OnWindowResize(); - //Return the texture that is used in later stages to apply the bloom effect - GLuint DepthBuffer() const { return m_DepthBuffer; } - Camera* DepthBufferCamera() const { return RenderCamera; } //Return the texture that is used in later stages to apply the bloom effect GLuint BloomTexture() const { return m_BloomTexture; } GLuint BloomTextureLowRes() const { return m_BloomTextureLowRes; } @@ -65,7 +62,6 @@ private: GLuint m_SceneTextureLowRes; GLuint m_DepthBuffer; GLuint m_DepthBufferLowRes; - Camera* RenderCamera; //maqke this component based i guess? GLuint m_ShieldPixelRate = 16; diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index 97482b3b..a12c52b1 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -177,7 +177,6 @@ void DrawFinalPass::InitializeShaderPrograms() void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) { GLERROR("Pre"); - RenderCamera = scene.Camera; DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle()); if (scene.ClearDepth) { //glClear(GL_DEPTH_BUFFER_BIT); @@ -768,26 +767,17 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr& job, RenderScene& scene) { - if (1/*job->Model->IsSkinned()*/) { - GLERROR("Bind 1 uniform"); - GLint Location_M = glGetUniformLocation(shaderHandle, "M"); - glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); - GLERROR("Bind 2 uniform"); - GLint Location_V = glGetUniformLocation(shaderHandle, "V"); - glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); - GLERROR("Bind 3 uniform"); - GLint Location_P = glGetUniformLocation(shaderHandle, "P"); - glUniformMatrix4fv(Location_P, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); - GLERROR("Bind 4 uniform"); - } else { - GLERROR("Bind 1 uniform"); - GLint Location_M = glGetUniformLocation(shaderHandle, "M"); - glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); - GLERROR("Bind 2 uniform"); - GLint Location_V = glGetUniformLocation(shaderHandle, "PV"); - glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix())); - GLERROR("Bind 3 uniform"); - } + GLERROR("Bind 1 uniform"); + GLint Location_M = glGetUniformLocation(shaderHandle, "M"); + glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix)); + GLERROR("Bind 2 uniform"); + GLint Location_V = glGetUniformLocation(shaderHandle, "V"); + glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix())); + GLERROR("Bind 3 uniform"); + GLint Location_P = glGetUniformLocation(shaderHandle, "P"); + glUniformMatrix4fv(Location_P, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); + GLERROR("Bind 4 uniform"); + GLint Location_ScreenDimensions = glGetUniformLocation(shaderHandle, "ScreenDimensions"); glUniform2f(Location_ScreenDimensions, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); GLERROR("Bind 5 uniform"); From fa4f007604745c8cdf9722d25b7486e4835e0007 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 22 Feb 2016 18:35:00 +0100 Subject: [PATCH 11/28] Changed name from Indicator to SpriteIndicator. Can now be an indicator for a single team or every one --- resources/Schema/Components.xsd | 2 +- resources/Schema/Components/Indicator.xml | 4 - .../Schema/Components/SpriteIndicator.xml | 5 + .../{Indicator.xsd => SpriteIndicator.xsd} | 5 +- resources/Schema/Entities/Player.xml | 52 +++++++++-- resources/Schema/Entities/PlayerRed.xml | 59 ++++++++++-- src/Engine/Rendering/RenderSystem.cpp | 92 +++++++++---------- 7 files changed, 151 insertions(+), 68 deletions(-) delete mode 100644 resources/Schema/Components/Indicator.xml create mode 100644 resources/Schema/Components/SpriteIndicator.xml rename resources/Schema/Components/{Indicator.xsd => SpriteIndicator.xsd} (59%) diff --git a/resources/Schema/Components.xsd b/resources/Schema/Components.xsd index c97f2a06..42abed82 100644 --- a/resources/Schema/Components.xsd +++ b/resources/Schema/Components.xsd @@ -44,6 +44,6 @@ - + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xml b/resources/Schema/Components/Indicator.xml deleted file mode 100644 index 1dfc0077..00000000 --- a/resources/Schema/Components/Indicator.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - 10 - \ No newline at end of file diff --git a/resources/Schema/Components/SpriteIndicator.xml b/resources/Schema/Components/SpriteIndicator.xml new file mode 100644 index 00000000..cbed22f0 --- /dev/null +++ b/resources/Schema/Components/SpriteIndicator.xml @@ -0,0 +1,5 @@ + + + 10 + false + \ No newline at end of file diff --git a/resources/Schema/Components/Indicator.xsd b/resources/Schema/Components/SpriteIndicator.xsd similarity index 59% rename from resources/Schema/Components/Indicator.xsd rename to resources/Schema/Components/SpriteIndicator.xsd index 5015b13c..bd8c1038 100644 --- a/resources/Schema/Components/Indicator.xsd +++ b/resources/Schema/Components/SpriteIndicator.xsd @@ -3,13 +3,16 @@ - + Billbord a Sprite around global Y axis + + Add a Team component to this Entity or Parent to make it visible only for that team + diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index d4485112..e68c0dd8 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -13,6 +13,7 @@ + @@ -60,6 +61,7 @@ Textures/Weapons/Crosshair/SmallThickHoleDot.png false + @@ -110,6 +112,7 @@ Textures/HealthHUD3.png + @@ -135,6 +138,7 @@ Textures/Core/UnitHexagon.png + @@ -152,6 +156,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -167,6 +172,7 @@ Textures/Core/UnitHexagon.png + @@ -185,6 +191,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -200,6 +207,7 @@ Textures/Core/UnitHexagon.png + @@ -217,6 +225,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -232,6 +241,7 @@ Textures/Core/UnitHexagon.png + @@ -249,6 +259,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -264,6 +275,7 @@ Textures/Core/UnitHexagon.png + @@ -279,6 +291,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -304,6 +317,7 @@ + Fonts/DroidSans.ttf,64 @@ -316,6 +330,7 @@ + Fonts/DroidSans.ttf,64 @@ -330,6 +345,7 @@ + Fonts/DroidSans.ttf,64 @@ -349,8 +365,10 @@ Idle - 1.8314163732853146 + 1.1964538350402378 1 + + Models/Characters/Assault/FirstPerson.mesh @@ -368,8 +386,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -406,6 +424,7 @@ Textures/Core/UnitHexagon.png + @@ -475,8 +494,10 @@ Idle - 0.16333512901638159 + 0.59503633283673452 1 + + AimRifle @@ -499,8 +520,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -570,6 +591,25 @@ + + + + Textures/Icons/Arrow.png + false + + + + + + 30 + true + + + + + + + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index 4be8fc26..c45f9280 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -13,6 +13,7 @@ + @@ -60,6 +61,7 @@ Textures/Weapons/Crosshair/SmallThickHoleDot.png false + @@ -110,6 +112,7 @@ Textures/HealthHUD3.png + @@ -135,6 +138,7 @@ Textures/Core/UnitHexagon.png + @@ -152,6 +156,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -167,6 +172,7 @@ Textures/Core/UnitHexagon.png + @@ -185,6 +191,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -200,6 +207,7 @@ Textures/Core/UnitHexagon.png + @@ -217,6 +225,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -232,6 +241,7 @@ Textures/Core/UnitHexagon.png + @@ -249,6 +259,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -264,6 +275,7 @@ Textures/Core/UnitHexagon.png + @@ -279,6 +291,7 @@ Textures/Core/UnitHexagon_Rotated.png + @@ -304,6 +317,7 @@ + Fonts/DroidSans.ttf,64 @@ -316,6 +330,7 @@ + Fonts/DroidSans.ttf,64 @@ -330,6 +345,7 @@ + Fonts/DroidSans.ttf,64 @@ -349,8 +365,10 @@ Idle - 0.018170670865885086 + 1.9065361003781902 1 + + Models/Characters/Assault/FirstPerson.mesh @@ -368,8 +386,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -406,6 +424,7 @@ Textures/Core/UnitHexagon.png + @@ -475,8 +494,10 @@ Idle - 0.11675631578762591 + 0.62178782386743592 1 + + AimRifle @@ -499,8 +520,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -570,6 +591,32 @@ + + + + + + + + + + + Textures/Icons/Arrow.png + false + + + + + + 30 + true + + + + + + + diff --git a/src/Engine/Rendering/RenderSystem.cpp b/src/Engine/Rendering/RenderSystem.cpp index a0534fed..7b0ea84f 100644 --- a/src/Engine/Rendering/RenderSystem.cpp +++ b/src/Engine/Rendering/RenderSystem.cpp @@ -52,40 +52,39 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl continue; } - std::string diffuseResource = cSprite["DiffuseTexture"]; - std::string glowResource = cSprite["GlowMap"]; - bool depthSorted = cSprite["DepthSort"]; - if (diffuseResource.empty() && glowResource.empty()) { - continue; - } - - float fillPercentage = 0.f; - glm::vec4 fillColor = glm::vec4(0); - if (world->HasComponent(entity.ID, "Fill")) { - auto fillComponent = world->GetComponent(entity.ID, "Fill"); - fillPercentage = (float)(double)fillComponent["Percentage"]; - fillColor = (glm::vec4)fillComponent["Color"]; - } - glm::mat4 modelMatrix; - + + // See a sprite is an SpriteIndicator bool isIndicator = false; - if (world->HasComponent(entity.ID, "Indicator") || entity.FirstParentWithComponent("Indicator").Valid()) + if (world->HasComponent(entity.ID, "SpriteIndicator")) { - EntityWrapper EntityWithIndicator; - if (world->HasComponent(entity.ID, "Indicator")) { - EntityWithIndicator = entity; - } - else { - EntityWithIndicator = entity.FirstParentWithComponent("Indicator"); - } - auto indicator = EntityWithIndicator["Indicator"]; + auto indicator = entity["SpriteIndicator"]; float minScale = (float)(double)indicator["MinScale"]; + bool hasTeam = indicator["VisibleForSingleTeamOnly"]; isIndicator = true; glm::vec3 pos = Transform::AbsolutePosition(entity); + EntityWrapper entityTeam; + if (hasTeam && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) && m_LocalPlayer.World != nullptr) { + if (!entity.HasComponent("Team")) { + entityTeam = entity.FirstParentWithComponent("Team"); + } + else { + entityTeam = entity; + } + + ComponentWrapper& entityTeamComponent = entityTeam["Team"]; + ComponentWrapper& localComponent = m_LocalPlayer["Team"]; + int entityTeamInt = entityTeamComponent["Team"]; + int localComponentInt = localComponent["Team"]; + int SpectatorInt = localComponent["Team"].Enum("Spectator"); + if (entityTeamInt != localComponentInt && localComponentInt != SpectatorInt) { + continue; + } + } + // Code for check if sprite is inside or outside of screen //glm::vec4 projectedPos = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix() * glm::vec4(pos, 1.0f); //projectedPos /= projectedPos.w; @@ -142,10 +141,27 @@ void RenderSystem::fillSprites(std::list>& jobs, Worl tranformationMatrix = tranformationMatrix * glm::scale(glm::vec3(minScale / diag, minScale / diag, minScale / diag)); } modelMatrix = tranformationMatrix; - } else { + } + else { modelMatrix = Transform::ModelMatrix(entity.ID, world); } + + std::string diffuseResource = cSprite["DiffuseTexture"]; + std::string glowResource = cSprite["GlowMap"]; + bool depthSorted = cSprite["DepthSort"]; + if (diffuseResource.empty() && glowResource.empty()) { + continue; + } + + float fillPercentage = 0.f; + glm::vec4 fillColor = glm::vec4(0); + if (world->HasComponent(entity.ID, "Fill")) { + auto fillComponent = world->GetComponent(entity.ID, "Fill"); + fillPercentage = (float)(double)fillComponent["Percentage"]; + fillColor = (glm::vec4)fillComponent["Color"]; + } + std::shared_ptr spriteJob = std::shared_ptr(new SpriteJob(cSprite, m_Camera, modelMatrix, world, fillColor, fillPercentage, depthSorted, isIndicator)); jobs.push_back(spriteJob); @@ -168,30 +184,6 @@ bool RenderSystem::isEntityVisible(EntityWrapper& entity) ) { return false; } - - // If a sprite is an Indicator, it's not local on player and object is in the same team, then dispaly it - if ( - entity.HasComponent("Indicator") - && !entity.IsChildOf(m_LocalPlayer) - && (entity.HasComponent("Team") || entity.FirstParentWithComponent("Team").Valid()) - && entity.HasComponent("Sprite") - && m_LocalPlayer.World != nullptr - ) { - EntityWrapper entityTeam; - if (!entity.HasComponent("Team")) { - entityTeam = entity.FirstParentWithComponent("Team"); - } else { - entityTeam = entity; - } - ComponentWrapper& entityTeamComponent = entityTeam["Team"]; - ComponentWrapper& localComponent = m_LocalPlayer["Team"]; - int entityTeamInt = entityTeamComponent["Team"]; - int localComponentInt = localComponent["Team"]; - int SpectatorInt = localComponent["Team"].Enum("Spectator"); - if (entityTeamInt != localComponentInt && localComponentInt != SpectatorInt) { - return false; - } - } return true; } From fe3e0bac5bf86d54a374c3622b520d063e634a0b Mon Sep 17 00:00:00 2001 From: Teejoon Date: Mon, 22 Feb 2016 18:45:02 +0100 Subject: [PATCH 12/28] Changed SpritIndicator values on player --- resources/Schema/Entities/Player.xml | 15 ++++---- resources/Schema/Entities/PlayerRed.xml | 46 +++++++++++-------------- 2 files changed, 28 insertions(+), 33 deletions(-) diff --git a/resources/Schema/Entities/Player.xml b/resources/Schema/Entities/Player.xml index e68c0dd8..48adffac 100644 --- a/resources/Schema/Entities/Player.xml +++ b/resources/Schema/Entities/Player.xml @@ -365,7 +365,7 @@ Idle - 1.1964538350402378 + 0.97725610639912475 1 @@ -386,8 +386,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -494,7 +494,7 @@ Idle - 0.59503633283673452 + 0.87583812735846323 1 @@ -520,8 +520,8 @@ Models/Weapons/Blue/AssaultWeaponBlue.mesh - - + + @@ -601,11 +601,12 @@ - 30 + 50 true + diff --git a/resources/Schema/Entities/PlayerRed.xml b/resources/Schema/Entities/PlayerRed.xml index c45f9280..cd01632e 100644 --- a/resources/Schema/Entities/PlayerRed.xml +++ b/resources/Schema/Entities/PlayerRed.xml @@ -365,7 +365,7 @@ Idle - 1.9065361003781902 + 1.2667383999985162 1 @@ -386,8 +386,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -494,7 +494,7 @@ Idle - 0.62178782386743592 + 0.26532318661337229 1 @@ -520,8 +520,8 @@ Models/Weapons/Red/AssaultWeaponRed.mesh - - + + @@ -591,31 +591,25 @@ - + + + Textures/Icons/Arrow.png + false + + + + + + 50 + true + + - - - - - Textures/Icons/Arrow.png - false - - - - - - 30 - true - - - - - - + From fe9dbf0b0f34306a1842a96f9374be7c7711bbaf Mon Sep 17 00:00:00 2001 From: stiffly Date: Tue, 23 Feb 2016 10:33:20 +0100 Subject: [PATCH 13/28] Serverlist fix. --- src/Engine/Network/Client.cpp | 2 ++ src/Engine/Network/Server.cpp | 2 +- src/Engine/Network/UDPClient.cpp | 1 + src/Engine/Network/UDPServer.cpp | 4 ++++ 4 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index ccca0d67..fc5b68e1 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -203,6 +203,8 @@ void Client::parseServerlist(Packet& packet) std::string serverName = packet.ReadString(); int playersConnected = packet.ReadPrimitive(); //TODO: This should not happen when a client is connected to a server + LOG_INFO("Parsing a server list!"); + m_Serverlist.push_back({ address, port, serverName, playersConnected }); } diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 4b83967e..157f74dd 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -401,7 +401,7 @@ void Server::parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint) packet.WritePrimitive(m_ConnectedPlayers.size()); //PlayerDefinition pDef; //pDef.Endpoint = boost::asio::ip::udp::endpoint(endpoint.address(), 13); - + LOG_INFO("Parsing a server list request!"); m_ServerlistRequest.Send(packet/*, endpoint*/); } diff --git a/src/Engine/Network/UDPClient.cpp b/src/Engine/Network/UDPClient.cpp index f31d5a17..37b9b1a0 100644 --- a/src/Engine/Network/UDPClient.cpp +++ b/src/Engine/Network/UDPClient.cpp @@ -91,6 +91,7 @@ void UDPClient::Send(Packet& packet) void UDPClient::Broadcast(Packet& packet, int port) { + packet.UpdateSize(); m_Socket->set_option(boost::asio::socket_base::broadcast(true)); m_Socket->send_to(boost::asio::buffer( packet.Data(), diff --git a/src/Engine/Network/UDPServer.cpp b/src/Engine/Network/UDPServer.cpp index fcf26aec..2f941b04 100644 --- a/src/Engine/Network/UDPServer.cpp +++ b/src/Engine/Network/UDPServer.cpp @@ -41,6 +41,7 @@ void UDPServer::Send(Packet & packet) // Broadcasting respond specific logic void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint) { + packet.UpdateSize(); m_Socket->send_to( boost::asio::buffer( packet.Data(), @@ -52,6 +53,7 @@ void UDPServer::Send(Packet & packet, boost::asio::ip::udp::endpoint endpoint) // Broadcasting void UDPServer::Broadcast(Packet & packet, int port) { + packet.UpdateSize(); m_Socket->set_option(boost::asio::socket_base::broadcast(true)); m_Socket->send_to( boost::asio::buffer( @@ -68,6 +70,7 @@ void UDPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition) if (bytesRead > 0) { packet.ReconstructFromData(m_ReadBuffer, bytesRead); } + LOG_INFO("Received server list msg"); playerDefinition.Endpoint = m_ReceiverEndpoint; } @@ -90,6 +93,7 @@ int UDPServer::readBuffer() if (!m_Socket) { return 0; } + int addasdasd = m_Socket->available(); boost::system::error_code error; // Read size of packet m_Socket->receive_from(boost From c42e1e09672a172ca9877f815fcb0f448d88b72b Mon Sep 17 00:00:00 2001 From: stiffly Date: Tue, 23 Feb 2016 11:07:41 +0100 Subject: [PATCH 14/28] SoundSystem Fix. Now subscribes to an event that was thought to be listened to. --- src/Game/Systems/SoundSystem.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Game/Systems/SoundSystem.cpp b/src/Game/Systems/SoundSystem.cpp index 56c1f018..b4a37ad0 100644 --- a/src/Game/Systems/SoundSystem.cpp +++ b/src/Game/Systems/SoundSystem.cpp @@ -14,6 +14,7 @@ SoundSystem::SoundSystem(SystemParams params) EVENT_SUBSCRIBE_MEMBER(m_EPlayerDamage, &SoundSystem::OnPlayerDamage); EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &SoundSystem::OnCaptured); EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &SoundSystem::OnTriggerTouch); + EVENT_SUBSCRIBE_MEMBER(m_EPlayerDeath, &SoundSystem::OnPlayerDeath); } } @@ -111,7 +112,12 @@ bool SoundSystem::OnCaptured(const Events::Captured & e) // Testing purposes atm... bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e) { - // Should check for only local players here... + if (!IsClient) { // Only play for clients + return false; + } + if (LocalPlayer.ID = e.Victim.ID) { // You're local player was the one who took dmg + return false; + } std::uniform_int_distribution dist(1, 12); int rand = dist(generator); std::vector paths; @@ -131,8 +137,16 @@ bool SoundSystem::OnPlayerDamage(const Events::PlayerDamage & e) bool SoundSystem::OnPlayerDeath(const Events::PlayerDeath & e) { - Events::PlaySoundOnEntity ev; - ev.EmitterID = LocalPlayer.ID; + if (e.Player.ID != LocalPlayer.ID) { + return false; + } + if (!IsClient) { + return false; + } + // The local player is dead. The local player might be invalid? + // Play the sound from the listener. + // TODO: We might want to hear other players die. + Events::PlayBackgroundMusic ev; ev.FilePath = "Audio/die/die2.wav"; m_EventBroker->Publish(ev); return false; From fc7d62a5ad11655bfdd763477ce22fddaf15466b Mon Sep 17 00:00:00 2001 From: stiffly Date: Tue, 23 Feb 2016 11:07:56 +0100 Subject: [PATCH 15/28] Various clean ups. --- include/Engine/Network/HybridClient.h | 13 ----------- include/Engine/Network/HybridServer.h | 12 ---------- src/Engine/Network/Client.cpp | 1 - src/Engine/Network/HybridClient.cpp | 10 --------- src/Engine/Network/HybridServer.cpp | 9 -------- src/Engine/Network/Server.cpp | 5 +---- src/Engine/Network/TCPClient.cpp | 20 ----------------- src/Engine/Network/TCPServer.cpp | 32 --------------------------- src/Engine/Network/UDPClient.cpp | 12 ---------- src/Engine/Network/UDPServer.cpp | 10 --------- 10 files changed, 1 insertion(+), 123 deletions(-) delete mode 100644 include/Engine/Network/HybridClient.h delete mode 100644 include/Engine/Network/HybridServer.h delete mode 100644 src/Engine/Network/HybridClient.cpp delete mode 100644 src/Engine/Network/HybridServer.cpp diff --git a/include/Engine/Network/HybridClient.h b/include/Engine/Network/HybridClient.h deleted file mode 100644 index 8d96bf6e..00000000 --- a/include/Engine/Network/HybridClient.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef HybridClient_h__ -#define HybridClient_h__ - -class HybridClient -{ -public: - HybridClient(); - ~HybridClient(); -private: - -}; - -#endif \ No newline at end of file diff --git a/include/Engine/Network/HybridServer.h b/include/Engine/Network/HybridServer.h deleted file mode 100644 index 48d6fe63..00000000 --- a/include/Engine/Network/HybridServer.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef HybridServer_h__ -#define HybridServer_h__ - -class HybridServer -{ -public: - HybridServer(); - ~HybridServer(); -private: -}; - -#endif \ No newline at end of file diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index fc5b68e1..213e1815 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -203,7 +203,6 @@ void Client::parseServerlist(Packet& packet) std::string serverName = packet.ReadString(); int playersConnected = packet.ReadPrimitive(); //TODO: This should not happen when a client is connected to a server - LOG_INFO("Parsing a server list!"); m_Serverlist.push_back({ address, port, serverName, playersConnected }); } diff --git a/src/Engine/Network/HybridClient.cpp b/src/Engine/Network/HybridClient.cpp deleted file mode 100644 index 4200e8e3..00000000 --- a/src/Engine/Network/HybridClient.cpp +++ /dev/null @@ -1,10 +0,0 @@ -#include "Network/HybridClient.h" - - -HybridClient::HybridClient() -{ -} - -HybridClient::~HybridClient() -{ -} \ No newline at end of file diff --git a/src/Engine/Network/HybridServer.cpp b/src/Engine/Network/HybridServer.cpp deleted file mode 100644 index bfcdaee0..00000000 --- a/src/Engine/Network/HybridServer.cpp +++ /dev/null @@ -1,9 +0,0 @@ -#include "Network/HybridServer.h" - -HybridServer::HybridServer() -{ -} - -HybridServer::~HybridServer() -{ -} \ No newline at end of file diff --git a/src/Engine/Network/Server.cpp b/src/Engine/Network/Server.cpp index 157f74dd..8783a7b0 100644 --- a/src/Engine/Network/Server.cpp +++ b/src/Engine/Network/Server.cpp @@ -399,10 +399,7 @@ void Server::parseServerlistRequest(boost::asio::ip::udp::endpoint endpoint) packet.WritePrimitive(m_Reliable.Port()); packet.WriteString("SERVERNAME"); packet.WritePrimitive(m_ConnectedPlayers.size()); - //PlayerDefinition pDef; - //pDef.Endpoint = boost::asio::ip::udp::endpoint(endpoint.address(), 13); - LOG_INFO("Parsing a server list request!"); - m_ServerlistRequest.Send(packet/*, endpoint*/); + m_ServerlistRequest.Send(packet); } void Server::disconnect(PlayerID playerID) diff --git a/src/Engine/Network/TCPClient.cpp b/src/Engine/Network/TCPClient.cpp index f2920ae5..f3394d3d 100644 --- a/src/Engine/Network/TCPClient.cpp +++ b/src/Engine/Network/TCPClient.cpp @@ -64,26 +64,6 @@ void TCPClient::Receive(Packet& packet) size_t TCPClient::readBuffer() { - //if (!m_Socket) { - // return 0; - //} - //boost::system::error_code error; - //// Read size of packet - //size_t bytesReceived = m_Socket->read_some(boost - // ::asio::buffer((void*)data, sizeof(int)), - // error); - //int sizeOfPacket = 0; - //memcpy(&sizeOfPacket, data, sizeof(int)); - - //// Read the rest of the message - //bytesReceived += m_Socket->read_some(boost - // ::asio::buffer((void*)(data + bytesReceived), sizeOfPacket - bytesReceived), - // error); - //if (error) { - // //LOG_ERROR("receive: %s", error.message().c_str()); - //} - //return bytesReceived; - if (!m_Socket) { return 0; } diff --git a/src/Engine/Network/TCPServer.cpp b/src/Engine/Network/TCPServer.cpp index ac2ba655..24a0b2c1 100644 --- a/src/Engine/Network/TCPServer.cpp +++ b/src/Engine/Network/TCPServer.cpp @@ -91,38 +91,6 @@ std::string TCPServer::GetAddress() return endpoint.address().to_string().c_str(); } -//void TCPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition) -//{ -// int bytesRead = readBuffer(m_ReadBuffer, playerDefinition); -// if (bytesRead > 0) { -// packet.ReconstructFromData(m_ReadBuffer, bytesRead); -// } -// lastReceivedSocket = playerDefinition.TCPSocket; -//} -// -//int TCPServer::readBuffer(char* data, PlayerDefinition & playerDefinition) -//{ -// if (!playerDefinition.TCPSocket) { -// return 0; -// } -// boost::system::error_code error; -// // Read size of packet -// size_t bytesReceived = playerDefinition.TCPSocket->read_some(boost -// ::asio::buffer((void*)data, sizeof(int)), -// error); -// int sizeOfPacket = 0; -// memcpy(&sizeOfPacket, data, sizeof(int)); -// -// // Read the rest of the message -// bytesReceived += playerDefinition.TCPSocket->read_some(boost -// ::asio::buffer((void*)(data + bytesReceived), sizeOfPacket - bytesReceived), -// error); -// if (error) { -// //LOG_ERROR("receive: %s", error.message().c_str()); -// } -// return bytesReceived; -//} - void TCPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition) { int bytesRead = readBuffer(playerDefinition); diff --git a/src/Engine/Network/UDPClient.cpp b/src/Engine/Network/UDPClient.cpp index 37b9b1a0..51c29920 100644 --- a/src/Engine/Network/UDPClient.cpp +++ b/src/Engine/Network/UDPClient.cpp @@ -35,18 +35,6 @@ void UDPClient::Receive(Packet& packet) int UDPClient::readBuffer() { - //if (!m_Socket) { - // return 0; - //} - //boost::system::error_code error; - //int bytesReceived = m_Socket->receive_from(boost - // ::asio::buffer((void*)data, BUFFERSIZE), - // m_ReceiverEndpoint, - // 0, error); - //if (error) { - // //LOG_ERROR("receive: %s", error.message().c_str()); - //} - //return bytesReceived; if (!m_Socket) { return 0; } diff --git a/src/Engine/Network/UDPServer.cpp b/src/Engine/Network/UDPServer.cpp index 2f941b04..635ebd4d 100644 --- a/src/Engine/Network/UDPServer.cpp +++ b/src/Engine/Network/UDPServer.cpp @@ -70,7 +70,6 @@ void UDPServer::Receive(Packet & packet, PlayerDefinition & playerDefinition) if (bytesRead > 0) { packet.ReconstructFromData(m_ReadBuffer, bytesRead); } - LOG_INFO("Received server list msg"); playerDefinition.Endpoint = m_ReceiverEndpoint; } @@ -81,15 +80,6 @@ bool UDPServer::IsSocketAvailable() int UDPServer::readBuffer() { - //boost::system::error_code error = boost::asio::error::host_not_found; - //unsigned int length = m_Socket->receive_from( - // boost::asio::buffer((void*)data - // , BUFFERSIZE) - // , m_ReceiverEndpoint, 0, error); - //if (error) { - // LOG_WARNING(error.message().c_str()); - //} - //return length; if (!m_Socket) { return 0; } From d77119bb2dfcf020abb33bab49043a1bc0e39257 Mon Sep 17 00:00:00 2001 From: stiffly Date: Tue, 23 Feb 2016 11:47:44 +0100 Subject: [PATCH 16/28] Fixed print for serverlist. --- src/Engine/Network/Client.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Engine/Network/Client.cpp b/src/Engine/Network/Client.cpp index 213e1815..903cd929 100644 --- a/src/Engine/Network/Client.cpp +++ b/src/Engine/Network/Client.cpp @@ -599,7 +599,7 @@ void Client::displayServerlist() LOG_INFO("This is a serverlist:\n"); for (int i = 0; i < m_Serverlist.size(); i++) { ServerInfo si = m_Serverlist[i]; - LOG_INFO("%s:%i\t%s\t%i\n", si.Address, si.Port, si.Name, si.PlayersConnected); + LOG_INFO("%s:%i\t%s\t%i\n", si.Address.c_str(), si.Port, si.Name.c_str(), si.PlayersConnected); } } From 91b0ac5fbde7fc731be49eda31b1c668ca8d0c6e Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 23 Feb 2016 16:00:43 +0100 Subject: [PATCH 17/28] Some groundwork for cubemaps. --- assets | 2 +- include/Engine/Rendering/CubeMapPass.h | 26 +++++++++++++++ include/Engine/Rendering/DrawFinalPass.h | 5 ++- include/Engine/Rendering/Renderer.h | 2 ++ include/Engine/Rendering/Texture.h | 1 + resources/Shaders/ForwardPlus.frag.glsl | 8 +++-- src/Engine/Rendering/CubeMapPass.cpp | 39 +++++++++++++++++++++++ src/Engine/Rendering/DrawBloomPass.cpp | 2 ++ src/Engine/Rendering/DrawFinalPass.cpp | 33 +++++++++++++++++-- src/Engine/Rendering/PickingPass.cpp | 3 ++ src/Engine/Rendering/PickingPassState.cpp | 5 +-- src/Engine/Rendering/Renderer.cpp | 12 ++++--- src/Engine/Rendering/Texture.cpp | 2 ++ 13 files changed, 126 insertions(+), 14 deletions(-) create mode 100644 include/Engine/Rendering/CubeMapPass.h create mode 100644 src/Engine/Rendering/CubeMapPass.cpp diff --git a/assets b/assets index 1e7adc74..ba8e04f1 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 1e7adc749e02144615a20a82c847d3c8df46ee3d +Subproject commit ba8e04f12be11034464b8446331286196953bb84 diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h new file mode 100644 index 00000000..564329e2 --- /dev/null +++ b/include/Engine/Rendering/CubeMapPass.h @@ -0,0 +1,26 @@ +#ifndef CubeMapPass_h__ +#define CubeMapPass_h__ + +#include "IRenderer.h" +#include "ShaderProgram.h" + +class CubeMapPass +{ +public: + CubeMapPass(IRenderer* renderer); + ~CubeMapPass() { } + + void LoadTextures(); + void FillCubeMap(glm::vec3 originPosition); + void GenerateCubeMapTexture(); + + //GLuint CubeMapTexture() const { return m_CubeMapTexture; } + GLuint m_CubeMapTexture; + +private: + IRenderer* m_Renderer; + + std::vector m_CubeMapTestTextures; +}; + +#endif \ No newline at end of file diff --git a/include/Engine/Rendering/DrawFinalPass.h b/include/Engine/Rendering/DrawFinalPass.h index e3389471..1800c90e 100644 --- a/include/Engine/Rendering/DrawFinalPass.h +++ b/include/Engine/Rendering/DrawFinalPass.h @@ -4,6 +4,7 @@ #include "IRenderer.h" #include "DrawFinalPassState.h" #include "LightCullingPass.h" +#include "CubeMapPass.h" #include "FrameBuffer.h" #include "ShaderProgram.h" #include "Util/UnorderedMapVec2.h" @@ -13,7 +14,7 @@ class DrawFinalPass { public: - DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass); + DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass); ~DrawFinalPass() { } void InitializeTextures(); void InitializeFrameBuffers(); @@ -62,12 +63,14 @@ private: GLuint m_SceneTextureLowRes; GLuint m_DepthBuffer; GLuint m_DepthBufferLowRes; + GLuint m_CubeMapTexture; //maqke this component based i guess? GLuint m_ShieldPixelRate = 16; const IRenderer* m_Renderer; const LightCullingPass* m_LightCullingPass; + const CubeMapPass* m_CubeMapPass; ShaderProgram* m_ForwardPlusProgram; ShaderProgram* m_ExplosionEffectProgram; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index aa87536b..720336aa 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -17,6 +17,7 @@ #include "DrawBloomPass.h" #include "DrawColorCorrectionPass.h" #include "SSAOPass.h" +#include "CubeMapPass.h" #include "../Core/EventBroker.h" #include "ImGuiRenderPass.h" #include "Camera.h" @@ -74,6 +75,7 @@ private: DrawBloomPass* m_DrawBloomPass; DrawColorCorrectionPass* m_DrawColorCorrectionPass; SSAOPass* m_SSAOPass; + CubeMapPass* m_CubeMapPass; //----------------------Functions----------------------// void InitializeWindow(); diff --git a/include/Engine/Rendering/Texture.h b/include/Engine/Rendering/Texture.h index 0fe650b3..d159e636 100644 --- a/include/Engine/Rendering/Texture.h +++ b/include/Engine/Rendering/Texture.h @@ -18,6 +18,7 @@ public: void Bind(GLenum textureUnit = GL_TEXTURE0); GLuint m_Texture = 0; + unsigned char* Data = nullptr; }; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index f9b93091..78f2106f 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -22,6 +22,7 @@ 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; #define TILE_SIZE 16 @@ -132,7 +133,9 @@ void main() 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); + vec4 viewVec = normalize(-position); + vec3 R = reflect(-viewVec.xyz, normal.xyz); + vec4 reflectionColor = texture(CubeMap, R); vec2 tilePos; tilePos.x = int(gl_FragCoord.x/TILE_SIZE); @@ -171,7 +174,8 @@ void main() if(pos <= FillPercentage) { color_result += FillColor; } - 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); color_result += glowTexel*GlowIntensity; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp new file mode 100644 index 00000000..153d8eb8 --- /dev/null +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -0,0 +1,39 @@ +#include "Rendering/CubeMapPass.h" + +CubeMapPass::CubeMapPass(IRenderer* renderer) + :m_Renderer(renderer) +{ + LoadTextures(); + GenerateCubeMapTexture(); +} + +/* + +*/ + +void CubeMapPass::LoadTextures() +{ + for (int i = 0; i < 6; i++){ + std::string str; + str = "Textures/Test/CubeMap/CubeMapTest0" + std::to_string(i) + ".png"; + Texture* img = ResourceManager::Load(str); + m_CubeMapTestTextures.push_back(img); + } +} + +void CubeMapPass::GenerateCubeMapTexture() +{ + glGenTextures(1, &m_CubeMapTexture); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); + + for (int i = 0; i < 6; i++) { + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); + } + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + GLERROR("Generate Cubemap"); +} + diff --git a/src/Engine/Rendering/DrawBloomPass.cpp b/src/Engine/Rendering/DrawBloomPass.cpp index 6bfb58eb..e8ad4cd5 100644 --- a/src/Engine/Rendering/DrawBloomPass.cpp +++ b/src/Engine/Rendering/DrawBloomPass.cpp @@ -52,6 +52,7 @@ void DrawBloomPass::InitializeBuffers() void DrawBloomPass::ClearBuffer() { + GLERROR("PRE"); m_GaussianFrameBuffer_horiz.Bind(); glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -60,6 +61,7 @@ void DrawBloomPass::ClearBuffer() glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_GaussianFrameBuffer_vert.Unbind(); + GLERROR("END"); } void DrawBloomPass::Draw(GLuint texture) diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index c16caa24..e7982a3d 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -1,10 +1,11 @@ #include "Rendering/DrawFinalPass.h" -DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass) +DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass) + : m_Renderer(renderer) + , m_LightCullingPass(lightCullingPass) + , m_CubeMapPass(cubeMapPass) { //TODO: Make sure that uniforms are not sent into shader if not needed. - m_Renderer = renderer; - m_LightCullingPass = lightCullingPass; m_ShieldPixelRate = 8; InitializeTextures(); InitializeShaderPrograms(); @@ -261,20 +262,35 @@ void DrawFinalPass::Draw(RenderScene& scene, GLuint SSAOTexture) void DrawFinalPass::ClearBuffer() { + GLERROR("PRE"); m_FinalPassFrameBufferLowRes.Bind(); + GLERROR("Bind LowRes"); + 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); + GLERROR("2"); + glDisable(GL_SCISSOR_TEST); + GLERROR("3"); + m_FinalPassFrameBufferLowRes.Unbind(); + GLERROR("prebind HighRes"); m_FinalPassFrameBuffer.Bind(); + GLERROR("Bind HighRes"); glViewport(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"); glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_FinalPassFrameBuffer.Unbind(); + GLERROR("END"); } @@ -358,12 +374,15 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& 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); std::vector frameBones; if (explosionEffectJob->AnimationOffset.animation != nullptr) { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); @@ -378,6 +397,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionUniforms(explosionHandle, explosionEffectJob, scene); //bind textures BindExplosionTextures(explosionHandle, explosionEffectJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); } break; } @@ -436,6 +457,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelUniforms(forwardSkinnedHandle, modelJob, scene); //bind textures BindModelTextures(forwardSkinnedHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); std::vector frameBones; if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); @@ -451,6 +474,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelUniforms(forwardHandle, modelJob, scene); //bind textures BindModelTextures(forwardHandle, modelJob); + glActiveTexture(GL_TEXTURE5); + glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); } break; } @@ -809,6 +834,8 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr& job) { + + switch (job->Type) { case RawModel::MaterialType::SingleTextures: case RawModel::MaterialType::Basic: diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index d1ed73dd..e0288348 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -64,6 +64,7 @@ void PickingPass::InitializeShaderPrograms() void PickingPass::Draw(RenderScene& scene) { + GLERROR("PRE"); PickingPassState* state = new PickingPassState(m_PickingBuffer.GetHandle()); //TODO: Render: Add code for more jobs than modeljobs. @@ -367,6 +368,7 @@ void PickingPass::Draw(RenderScene& scene) void PickingPass::ClearPicking() { + GLERROR("PRE"); m_PickingColorsToEntity.clear(); m_EntityColors.clear(); m_ColorCounter[0] = 0; @@ -376,6 +378,7 @@ void PickingPass::ClearPicking() glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_PickingBuffer.Unbind(); + GLERROR("END"); } diff --git a/src/Engine/Rendering/PickingPassState.cpp b/src/Engine/Rendering/PickingPassState.cpp index 0c4f4aca..f2d42bff 100644 --- a/src/Engine/Rendering/PickingPassState.cpp +++ b/src/Engine/Rendering/PickingPassState.cpp @@ -3,9 +3,9 @@ PickingPassState::PickingPassState(GLuint frameBuffer) { - GLERROR("---2"); + GLERROR("PRE"); BindFramebuffer(frameBuffer); - GLERROR("---3"); + GLERROR("Bind Framebuffer"); Enable(GL_DEPTH_TEST); Enable(GL_CULL_FACE); Disable(GL_BLEND); @@ -13,6 +13,7 @@ PickingPassState::PickingPassState(GLuint frameBuffer) glm::vec4 clearColor = glm::vec4(0.f); //ClearColor(clearColor); //Clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + GLERROR("END"); } PickingPassState::~PickingPassState() diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 0c668cad..8391599c 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -30,6 +30,7 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height currentRenderer->m_LightCullingPass->OnWindowResize(); currentRenderer->m_PickingPass->OnWindowResize(); currentRenderer->m_DrawBloomPass->OnWindowResize(); + //TODO: CubeMapPass->OnWindowResize //If needed } void Renderer::InitializeWindow() @@ -88,9 +89,6 @@ void Renderer::InitializeShaders() //m_ExplosionEffectProgram->AddShader(std::shared_ptr(new FragmentShader("Shaders/ExplosionEffect.frag.glsl"))); //m_ExplosionEffectProgram->Compile(); //m_ExplosionEffectProgram->Link(); - - - } void Renderer::InputUpdate(double dt) @@ -108,6 +106,7 @@ void Renderer::Update(double dt) void Renderer::Draw(RenderFrame& frame) { + GLERROR("PRE"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); @@ -117,6 +116,7 @@ void Renderer::Draw(RenderFrame& frame) ImGui::SliderInt("SSAO Number of Samples", &m_SSAO_NumOfSamples, 2, 100); ImGui::SliderInt("SSAO Number of Turns", &m_SSAO_NumOfTurns, 0, 50); m_SSAOPass->Setting(m_SSAO_Radius, m_SSAO_Bias, m_SSAO_Contrast, m_SSAO_IntensityScale, m_SSAO_NumOfSamples, m_SSAO_NumOfTurns); + GLERROR("SSAO Settings"); //clear buffer 0 glClearColor(0.f, 0.f, 0.f, 0.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -127,6 +127,7 @@ void Renderer::Draw(RenderFrame& frame) m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); PerformanceTimer::StopTimer("Renderer-ClearBuffers"); + GLERROR("ClearBuffers"); for (auto scene : frame.RenderScenes) { PerformanceTimer::StartTimer("Renderer-Depth"); m_PickingPass->Draw(*scene); @@ -239,9 +240,10 @@ void Renderer::InitializeRenderPasses() { m_PickingPass = new PickingPass(this, m_EventBroker); m_LightCullingPass = new LightCullingPass(this); - m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass); + m_CubeMapPass = new CubeMapPass(this); + m_DrawFinalPass = new DrawFinalPass(this, m_LightCullingPass, m_CubeMapPass); m_DrawScreenQuadPass = new DrawScreenQuadPass(this); m_DrawBloomPass = new DrawBloomPass(this); m_DrawColorCorrectionPass = new DrawColorCorrectionPass(this); - m_SSAOPass = new SSAOPass(this); + m_SSAOPass = new SSAOPass(this); } diff --git a/src/Engine/Rendering/Texture.cpp b/src/Engine/Rendering/Texture.cpp index 256246a9..03347044 100644 --- a/src/Engine/Rendering/Texture.cpp +++ b/src/Engine/Rendering/Texture.cpp @@ -18,6 +18,7 @@ Texture::Texture(std::string path) this->Width = img->Width; this->Height = img->Height; + this->Data = img->Data; GLint format; switch (img->Format) { @@ -28,6 +29,7 @@ Texture::Texture(std::string path) format = GL_RGBA; break; } + // Construct the OpenGL texture glGenTextures(1, &m_Texture); From 8d23c531afc08de9dd39584d84f8016e6498e2ef Mon Sep 17 00:00:00 2001 From: Tleety Date: Tue, 23 Feb 2016 17:17:50 +0100 Subject: [PATCH 18/28] Cubemaps kinda functioning, still somthing wierd with the vectors. --- assets | 2 +- resources/Shaders/ForwardPlus.frag.glsl | 9 ++++++--- src/Engine/Rendering/CubeMapPass.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/assets b/assets index ba8e04f1..89b40707 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit ba8e04f12be11034464b8446331286196953bb84 +Subproject commit 89b4070731584056402eac071845e9b1a0d156fb diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 78f2106f..1b4d8c1e 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -134,7 +134,8 @@ void main() normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); - vec3 R = reflect(-viewVec.xyz, normal.xyz); + vec3 R = reflect(viewVec.xyz, normal.xyz); + R = vec3(P * vec4(R, 1.0)); vec4 reflectionColor = texture(CubeMap, R); vec2 tilePos; @@ -166,6 +167,8 @@ void main() 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; + color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; @@ -174,8 +177,8 @@ void main() if(pos <= FillPercentage) { color_result += FillColor; } - //sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); - sceneColor = vec4(reflectionColor.xyz, 1); + sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); + //sceneColor = vec4(reflectionColor.xyz, 1); color_result += glowTexel*GlowIntensity; bloomColor = vec4(clamp(color_result.xyz - 1.0, 0, 100), clamp(color_result.a, 0, 1)); diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index 153d8eb8..cdfc704e 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -27,7 +27,7 @@ void CubeMapPass::GenerateCubeMapTexture() glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); From e2831c5593604047cdca3eeb11e0046851176c72 Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Tue, 23 Feb 2016 17:29:33 +0100 Subject: [PATCH 19/28] CapturePointSystem fix, DamageIndicatorSystem fix --- include/Game/Systems/DamageIndicatorSystem.h | 16 ++- src/Game/Systems/CapturePointSystem.cpp | 53 ++++---- src/Game/Systems/DamageIndicatorSystem.cpp | 133 ++++++++++++++----- src/Game/Systems/PlayerDeathSystem.cpp | 5 +- src/Tests/HealthSystemTest.h | 1 - 5 files changed, 144 insertions(+), 64 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 053b196b..49ae249c 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -15,10 +15,11 @@ #include "Rendering/Util/CommonFunctions.h" -class DamageIndicatorSystem : public System +class DamageIndicatorSystem : public ImpureSystem { public: DamageIndicatorSystem(SystemParams params); + virtual void Update(double dt) override; private: EventRelay m_EPlayerDamage; @@ -28,6 +29,19 @@ private: bool OnSetCamera(const Events::SetCamera& e); EntityID m_CurrentCamera = -1; + struct DamageIndicatorStruct { + EntityWrapper spriteEntity; + glm::vec3 enemyPosition; + DamageIndicatorStruct(EntityWrapper sprite, glm::vec3 pos) + : spriteEntity(sprite) + , enemyPosition(pos) {} + }; + std::vector updateDamageIndicatorVector; + float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos); + //for tests + int m_TestVar = 0; + bool m_Testing = false; + glm::vec3 DamageIndicatorTest(EntityWrapper player); }; #endif diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 5fdd74cd..e4df9740 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -1,32 +1,37 @@ #include "Systems/CapturePointSystem.h" #include -CapturePointSystem::CapturePointSystem(SystemParams params) +CapturePointSystem::CapturePointSystem(SystemParams params) : System(params) , PureSystem("CapturePoint") { //subscribe/listenTo playerdamage,healthpickup events (using the eventBroker) - if (IsClient) { - EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); - EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); - EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); - } + EVENT_SUBSCRIBE_MEMBER(m_ETriggerTouch, &CapturePointSystem::OnTriggerTouch); + EVENT_SUBSCRIBE_MEMBER(m_ETriggerLeave, &CapturePointSystem::OnTriggerLeave); + EVENT_SUBSCRIBE_MEMBER(m_ECaptured, &CapturePointSystem::OnCaptured); + } //here all capturepoints will update their component //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { - if (!IsClient) { - return; - } - + //if (!IsClient) { + // return; + //} if (m_WinnerWasFound) { return; } const int capturePointNumber = cCapturePoint["CapturePointNumber"]; const bool hasTeamComponent = capturePointEntity.HasComponent("Team"); + if (m_NumberOfCapturePoints != 0) { + if (!m_CapturePointNumberToEntityMap[0].HasComponent("CapturePoint")) { + //if map has changed, the capturepoints has changed, now have to redo them + m_NumberOfCapturePoints = 0; + m_CapturePointNumberToEntityMap.clear(); + } + } //if point doesnt have a teamComponent yet, add one. since: //what if capture point has no team -> we cant get/use the team enum from it... if (!hasTeamComponent) { @@ -71,8 +76,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp std::map nextPossibleCapturePoint; nextPossibleCapturePoint["Red"] = -1; nextPossibleCapturePoint["Blue"] = -1; - for (int i = 0; i < m_NumberOfCapturePoints; i++) - { + for (int i = 0; i < m_NumberOfCapturePoints; i++) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; } @@ -84,8 +88,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp nextPossibleCapturePoint["Blue"] = i + 1; } } - for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) - { + for (int i = m_NumberOfCapturePoints - 1; i >= 0; i--) { if (!m_CapturePointNumberToEntityMap[i].HasComponent("Team")) { continue; } @@ -100,8 +103,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp //reset timers and reset the bool that triggers this if (m_ResetTimers) { - for (int i = 0; i < m_NumberOfCapturePoints; i++) - { + for (int i = 0; i < m_NumberOfCapturePoints; i++) { ComponentWrapper& capturePoint = m_CapturePointNumberToEntityMap[i]["CapturePoint"]; if ((int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Red"] && (int)capturePoint["CapturePointNumber"] != nextPossibleCapturePoint["Blue"]) { @@ -116,8 +118,7 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp } //check how many players are standing inside and are healthy - for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) - { + for (size_t i = m_ETriggerTouchVector.size(); i > 0; i--) { auto triggerTouched = m_ETriggerTouchVector[i - 1]; if (std::get<1>(triggerTouched) == capturePointEntity) { //some player has touched this - lets figure out: what team, health @@ -176,8 +177,8 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; } //if capturePoint is owned by the team, and the other team has been trying to take it, then increase/decrease the timer towards 0.0 - if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < 0.0) || - (ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > 0.0)) { + if ((ownedBy == currentTeam && currentTeam == redTeam && (double)cCapturePoint["CaptureTimer"] < captureTimeToTakeOver) || + (ownedBy == currentTeam && currentTeam == blueTeam && (double)cCapturePoint["CaptureTimer"] > -captureTimeToTakeOver)) { cCapturePoint["CaptureTimer"] = (double)cCapturePoint["CaptureTimer"] + timerDeltaChange; } //check if captureTimer > captureTimeToTakeOver and if so change owner and publish the eCaptured event @@ -195,17 +196,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp //check for possible winCondition = check if the homebase is owned by the other team bool checkForWinner = false; - if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) - { + if (capturePointNumber == m_RedTeamHomeCapturePoint && ownedBy != redTeam) { checkForWinner = true; } - if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) - { + if (capturePointNumber == m_BlueTeamHomeCapturePoint && ownedBy != blueTeam) { checkForWinner = true; } - if (checkForWinner && !m_WinnerWasFound) - { + if (checkForWinner && !m_WinnerWasFound) { //publish Win event Events::Win e; e.TeamThatWon = ownedBy; @@ -224,8 +222,7 @@ bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e) { - for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++) - { + for (size_t i = 0; i < m_ETriggerTouchVector.size(); i++) { auto triggerTouched = m_ETriggerTouchVector[i]; if (std::get<0>(triggerTouched) == e.Entity && std::get<1>(triggerTouched) == e.Trigger) { m_ETriggerTouchVector.erase(m_ETriggerTouchVector.begin() + i); diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 235eced0..65e1caf0 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -12,52 +12,42 @@ DamageIndicatorSystem::DamageIndicatorSystem(SystemParams params) auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); } +void DamageIndicatorSystem::Update(double dt) { + if (!IsServer) { + for (auto& iter = updateDamageIndicatorVector.begin(); iter != updateDamageIndicatorVector.end(); iter++) { + if (!iter->spriteEntity.Valid()) { + updateDamageIndicatorVector.erase(iter); + break; + } + auto angleBetweenVectors = CalculateAngle(LocalPlayer, iter->enemyPosition); + //simply set the rotation z-wise to the angleBetweenVectors + iter->spriteEntity["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); + } + } +} + bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) { if (m_CurrentCamera == EntityID_Invalid) { return false; } - //if (e.Victim != LocalPlayer) { - // return false; - //} if (e.Victim.Valid() && e.Victim != LocalPlayer && !e.Victim.IsChildOf(LocalPlayer)) { return false; } if (!e.Inflictor.Valid() || !e.Victim.Valid()) { - return false; + return false; } - //grab players direction - auto playerOrientation = glm::quat((glm::vec3)e.Victim["Transform"]["Orientation"]); - - //get the position vectors, but ignore the y-height - auto enemyPosition = (glm::vec3)e.Inflictor["Transform"]["Position"]; - auto playerPosition = (glm::vec3)e.Victim["Transform"]["Position"]; - enemyPosition.y = 0.0f; - playerPosition.y = 0.0f; - - //calculate the enemy to player vector - auto enemyPlayerVector = glm::normalize(playerPosition - enemyPosition); - - //get angle from players current rotation, this angle is how much you rotate around the y-axis - auto playerAngle = glm::angle(playerOrientation); - auto playerRotationVector = glm::normalize(glm::rotateY(glm::vec3(0, 0, 1), playerAngle)); - - //dot product of players direction-vector and enemys-to-playervector will give the cos of the angle between the vectors - auto playerRotationDot = glm::dot(playerRotationVector, enemyPlayerVector); - //to get the angle between the vectors just do cos-inverse - auto angleBetweenVectors = glm::acos(playerRotationDot); - - //rotate the direction-vector 90 degrees to get the players side-vector - auto playerSideVector = glm::normalize(glm::rotateY(glm::vec3(0, 0, 1), playerAngle + 1.57f)); - //dot of sidevector positive = enemy is on the right side, dot sidevector negative = left side - auto playerSideVectorDot = glm::dot(playerSideVector, enemyPlayerVector); - if (playerSideVectorDot < 0) { - angleBetweenVectors = -angleBetweenVectors; + glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"]; + //if testing + if (m_Testing) { + inflictorPos = DamageIndicatorTest(e.Victim); } + float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos); + //load & set the "2d" sprite auto entityFile = ResourceManager::Load("Schema/Entities/DamageIndicator.xml"); EntityFileParser parser(entityFile); @@ -67,6 +57,10 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) //simply set the rotation z-wise to the angleBetweenVectors spriteWrapper["Transform"]["Orientation"] = glm::vec3(0, 0, angleBetweenVectors); + if (!IsServer) { + updateDamageIndicatorVector.emplace_back(spriteWrapper, inflictorPos); + } + return true; } @@ -74,3 +68,80 @@ bool DamageIndicatorSystem::OnSetCamera(const Events::SetCamera& e) { m_CurrentCamera = e.CameraEntity.ID; return true; } + +float DamageIndicatorSystem::CalculateAngle(EntityWrapper player, glm::vec3 enemyPos) { + //grab players direction + auto playerOrientation = glm::quat((glm::vec3)player["Transform"]["Orientation"]); + + //get the position vectors, but ignore the y-height + auto enemyPosition = enemyPos; + auto playerPosition = (glm::vec3)player["Transform"]["Position"]; + enemyPosition.y = 0.0f; + playerPosition.y = 0.0f; + + //calculate the enemy to player vector + auto enemyPlayerVector = glm::normalize(playerPosition - enemyPosition); + + //get the rotationvector relative to the z-axis + auto rotationVectorVec3 = glm::vec3(glm::toMat4(Transform::AbsoluteOrientation(player))*glm::vec4(0, 0, 1, 0)); + //rotate the direction-vector 90 degrees to get the players side-vector + auto playerSideVector = glm::vec3(glm::rotateY(rotationVectorVec3, 1.57f)); + + //dot product of players direction-vector and enemys-to-playervector will give the cos of the angle between the vectors + auto playerRotationDot = glm::dot(rotationVectorVec3, enemyPlayerVector); + //to get the angle between the vectors just do cos-inverse + auto angleBetweenVectors = glm::acos(playerRotationDot); + + //dot of sidevector positive = enemy is on the right side, dot sidevector negative = left side + auto playerSideVectorDot = glm::dot(playerSideVector, enemyPlayerVector); + if (playerSideVectorDot < 0) { + angleBetweenVectors = -angleBetweenVectors; + } + + return angleBetweenVectors; +} +glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) { + auto currentPos = (glm::vec3)player["Transform"]["Position"]; + + auto testVar = 1; + auto testVar2 = 1; + if (m_TestVar % 4 == 0) { + testVar = -1; + testVar2 = 1; + } + if (m_TestVar % 4 == 1) { + testVar = 1; + testVar2 = 1; + } + if (m_TestVar % 4 == 2) { + testVar *= -1; + testVar2 = -1; + } + if (m_TestVar % 4 == 3) { + testVar = 1; + testVar2 = -1; + } + m_TestVar++; + + auto inflictorPos = glm::vec3(currentPos.x + testVar*6.0f, currentPos.y, currentPos.z + testVar2*6.0f); + + //load the explosioneffect XML + auto deathEffect = ResourceManager::Load("Schema/Entities/PlayerDeathExplosionWithCamera.xml"); + EntityFileParser parser(deathEffect); + EntityID deathEffectID = parser.MergeEntities(m_World); + EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID); + + //components that we need from player + auto playerModel = player.FirstChildByName("PlayerModel"); + auto playerEntityModel = playerModel["Model"]; + auto playerEntityAnimation = playerModel["Animation"]; + + //copy the data from player to explosioneffectmodel + playerEntityModel.Copy(deathEffectEW["Model"]); + playerEntityAnimation.Copy(deathEffectEW["Animation"]); + + //copy the models position,orientation + deathEffectEW["Transform"]["Position"] = inflictorPos; + deathEffectEW["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; + return inflictorPos; +} diff --git a/src/Game/Systems/PlayerDeathSystem.cpp b/src/Game/Systems/PlayerDeathSystem.cpp index 40a98278..844d2ed1 100644 --- a/src/Game/Systems/PlayerDeathSystem.cpp +++ b/src/Game/Systems/PlayerDeathSystem.cpp @@ -33,9 +33,8 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) EntityWrapper deathEffectEW = EntityWrapper(m_World, deathEffectID); //components that we need from player - auto playerCamera = player.FirstChildByName("Camera"); auto playerModel = player.FirstChildByName("PlayerModel"); - if (!playerCamera.Valid() || !playerModel.Valid()) { + if (!playerModel.Valid()) { return; } if (!playerModel.HasComponent("Model") || !playerModel.HasComponent("Animation")) { @@ -44,7 +43,7 @@ void PlayerDeathSystem::createDeathEffect(EntityWrapper player) auto playerEntityModel = playerModel["Model"]; auto playerEntityAnimation = playerModel["Animation"]; - //copy the data from player to explisioneffectmodel + //copy the data from player to explosioneffectmodel playerEntityModel.Copy(deathEffectEW["Model"]); playerEntityAnimation.Copy(deathEffectEW["Animation"]); //freeze the animation diff --git a/src/Tests/HealthSystemTest.h b/src/Tests/HealthSystemTest.h index 685a06dd..275558d2 100644 --- a/src/Tests/HealthSystemTest.h +++ b/src/Tests/HealthSystemTest.h @@ -6,7 +6,6 @@ #include "Core/EventBroker.h" #include "Rendering/Renderer.h" #include "Core/InputManager.h" -#include "GUI/Frame.h" #include "Core/World.h" #include "Input/InputProxy.h" #include "Input/KeyboardInputHandler.h" From 6465fe6ed68fd242d85a3411e46bf3a12cdbe6a2 Mon Sep 17 00:00:00 2001 From: Teejoon Date: Wed, 24 Feb 2016 13:22:41 +0100 Subject: [PATCH 20/28] Have fix the resizing errors --- include/Engine/Rendering/SSAOPass.h | 6 ++++-- src/Engine/Rendering/PickingPass.cpp | 18 +++--------------- src/Engine/Rendering/Renderer.cpp | 2 ++ src/Engine/Rendering/SSAOPass.cpp | 20 ++++++++++++-------- 4 files changed, 21 insertions(+), 25 deletions(-) diff --git a/include/Engine/Rendering/SSAOPass.h b/include/Engine/Rendering/SSAOPass.h index f15e20d3..792d1d82 100644 --- a/include/Engine/Rendering/SSAOPass.h +++ b/include/Engine/Rendering/SSAOPass.h @@ -14,11 +14,14 @@ class SSAOPass { public: SSAOPass(IRenderer* rendere); - ~SSAOPass() { }; + ~SSAOPass() { + delete m_DrawBloomPass; + }; void Draw(GLuint depthBuffer, Camera* camera); void Setting(float radius, float bias, float contrast, float intensityScale, int numOfSamples, int NumOfTurns); void ClearBuffer(); + void OnWindowResize(); //Return the SSAO of the texture sent to Draw GLuint SSAOTexture() const { return m_DrawBloomPass->GaussianTexture(); } @@ -31,7 +34,6 @@ private: void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const; - void ComputeAO(GLuint depthBuffer, Camera* camera); //void blurHorizontal(GLuint depthBuffer); //void blurVertical(GLuint depthBuffer); diff --git a/src/Engine/Rendering/PickingPass.cpp b/src/Engine/Rendering/PickingPass.cpp index d1ed73dd..4b4cd193 100644 --- a/src/Engine/Rendering/PickingPass.cpp +++ b/src/Engine/Rendering/PickingPass.cpp @@ -21,23 +21,13 @@ void PickingPass::InitializeTextures() { GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); + + 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); } void PickingPass::InitializeFrameBuffers() { - /* glGenRenderbuffers(1, &m_DepthBuffer); - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);*/ - - glGenTextures(1, &m_DepthBuffer); - - glBindTexture(GL_TEXTURE_2D, m_DepthBuffer); - glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, (int)(m_Renderer->GetViewportSize().Width), (int)(m_Renderer->GetViewportSize().Height), 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); - m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_DepthBuffer, GL_DEPTH_ATTACHMENT))); m_PickingBuffer.AddResource(std::shared_ptr(new Texture2D(&m_PickingTexture, GL_COLOR_ATTACHMENT0))); m_PickingBuffer.Generate(); @@ -382,8 +372,6 @@ void PickingPass::ClearPicking() void PickingPass::OnWindowResize() { InitializeTextures(); - glBindRenderbuffer(GL_RENDERBUFFER, m_DepthBuffer); - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height); m_PickingBuffer.Generate(); } diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 0c668cad..5b3348c3 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -30,6 +30,7 @@ void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height currentRenderer->m_LightCullingPass->OnWindowResize(); currentRenderer->m_PickingPass->OnWindowResize(); currentRenderer->m_DrawBloomPass->OnWindowResize(); + currentRenderer->m_SSAOPass->OnWindowResize(); } void Renderer::InitializeWindow() @@ -126,6 +127,7 @@ void Renderer::Draw(RenderFrame& frame) m_PickingPass->ClearPicking(); m_DrawFinalPass->ClearBuffer(); m_DrawBloomPass->ClearBuffer(); + m_SSAOPass->ClearBuffer(); PerformanceTimer::StopTimer("Renderer-ClearBuffers"); for (auto scene : frame.RenderScenes) { PerformanceTimer::StartTimer("Renderer-Depth"); diff --git a/src/Engine/Rendering/SSAOPass.cpp b/src/Engine/Rendering/SSAOPass.cpp index 331e040f..d4cdcb19 100644 --- a/src/Engine/Rendering/SSAOPass.cpp +++ b/src/Engine/Rendering/SSAOPass.cpp @@ -6,6 +6,7 @@ SSAOPass::SSAOPass(IRenderer* renderer) m_ScreenQuad = ResourceManager::Load("Models/Core/ScreenQuad.mesh"); + InitializeTexture(); InitializeBuffer(); InitializeShaderProgram(); Setting(0.1f, 0.012f, 1.0f, 1.0f, 13, 7); @@ -28,16 +29,16 @@ void SSAOPass::InitializeShaderProgram() m_SSAOViewSpaceZProgram->Link(); } +void SSAOPass::InitializeTexture() { + GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); + GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); +} void SSAOPass::InitializeBuffer() { - GenerateTexture(&m_SSAOTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R8, GL_RED, GL_FLOAT); - m_SSAOFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOTexture, GL_COLOR_ATTACHMENT0))); m_SSAOFramBuffer.Generate(); - GenerateTexture(&m_SSAOViewSpaceZTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_R32F, GL_RED, GL_FLOAT); - m_SSAOViewSpaceZFramBuffer.AddResource(std::shared_ptr(new Texture2D(&m_SSAOViewSpaceZTexture, GL_COLOR_ATTACHMENT0))); m_SSAOViewSpaceZFramBuffer.Generate(); } @@ -45,12 +46,12 @@ void SSAOPass::InitializeBuffer() void SSAOPass::ClearBuffer() { m_SSAOFramBuffer.Bind(); - glClearColor(0.f, 0.f, 0.f, 0.f); + glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_SSAOFramBuffer.Unbind(); m_SSAOViewSpaceZFramBuffer.Bind(); - glClearColor(0.f, 0.f, 0.f, 0.f); + glClearColor(1.f, 1.f, 1.f, 1.f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); m_SSAOViewSpaceZFramBuffer.Unbind(); } @@ -136,6 +137,9 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera) m_DrawBloomPass->Draw(m_SSAOTexture); } -void ComputeAO(GLuint depthBuffer, Camera* camera) { - +void SSAOPass::OnWindowResize() { + m_DrawBloomPass->OnWindowResize(); + InitializeTexture(); + m_SSAOFramBuffer.Generate(); + m_SSAOViewSpaceZFramBuffer.Generate(); } \ No newline at end of file From 6f9ce8a0c16d1c65d05318e585857a3b02243468 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 13:57:54 +0100 Subject: [PATCH 21/28] WIP --- include/Engine/Rendering/CubeMapPass.h | 5 +++-- resources/Shaders/ForwardPlus.frag.glsl | 8 +++++--- resources/Shaders/ForwardPlus.vert.glsl | 8 ++++---- src/Engine/Rendering/CubeMapPass.cpp | 23 +++++++++++------------ src/Engine/Rendering/DrawFinalPass.cpp | 7 +++++++ 5 files changed, 30 insertions(+), 21 deletions(-) diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h index 564329e2..0840e2c8 100644 --- a/include/Engine/Rendering/CubeMapPass.h +++ b/include/Engine/Rendering/CubeMapPass.h @@ -10,7 +10,7 @@ public: CubeMapPass(IRenderer* renderer); ~CubeMapPass() { } - void LoadTextures(); + void LoadTextures(std::string input); void FillCubeMap(glm::vec3 originPosition); void GenerateCubeMapTexture(); @@ -19,8 +19,9 @@ public: private: IRenderer* m_Renderer; + std::string m_PreviusCubeMapTexture; - std::vector m_CubeMapTestTextures; + std::vector m_CubeMapTextures; }; #endif \ No newline at end of file diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 1b4d8c1e..8b7a4824 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -12,6 +12,7 @@ uniform vec4 FillColor; uniform vec4 AmbientColor; uniform float FillPercentage; uniform float GlowIntensity = 10; +uniform vec3 CameraPosition; uniform vec2 DiffuseUVRepeat; uniform vec2 NormalUVRepeat; @@ -134,8 +135,9 @@ void main() normal = normalize(normal); //vec4 normal = normalize(V * vec4(Input.Normal, 0.0)); vec4 viewVec = normalize(-position); - vec3 R = reflect(viewVec.xyz, normal.xyz); - R = vec3(P * vec4(R, 1.0)); + 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; @@ -168,7 +170,7 @@ void main() 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; - color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); + //color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index d475d825..32daf240 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -23,12 +23,12 @@ out VertexData{ void main() { gl_Position = P*V*M * vec4(Position, 1.0); - + mat4 TIM = transpose(inverse(M)); Output.Position = Position; Output.TextureCoordinate = TextureCoords; - Output.Normal = vec3(M * vec4(Normal, 0.0)); - Output.Tangent = vec3(M * vec4(Tangent, 0.0)); - Output.BiTangent = vec3(M * vec4(BiTangent, 0.0)); + Output.Normal = vec3(TIM) * Normal; + Output.Tangent = vec3(TIM) * Tangent; + Output.BiTangent = vec3(TIM) * BiTangent; Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; } \ No newline at end of file diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index cdfc704e..b64b77f1 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -3,21 +3,20 @@ CubeMapPass::CubeMapPass(IRenderer* renderer) :m_Renderer(renderer) { - LoadTextures(); + LoadTextures("Nevada"); GenerateCubeMapTexture(); } -/* - -*/ - -void CubeMapPass::LoadTextures() +void CubeMapPass::LoadTextures(std::string input) { - for (int i = 0; i < 6; i++){ - std::string str; - str = "Textures/Test/CubeMap/CubeMapTest0" + std::to_string(i) + ".png"; - Texture* img = ResourceManager::Load(str); - m_CubeMapTestTextures.push_back(img); + if (m_PreviusCubeMapTexture != input) { + m_CubeMapTextures.clear(); + for (int i = 0; i < 6; i++) { + std::string str; + str = "Textures/Test/CubeMap/" + input + "/CubeMapTest0" + std::to_string(i) + ".png"; + Texture* img = ResourceManager::Load(str); + m_CubeMapTextures.push_back(img); + } } } @@ -27,7 +26,7 @@ void CubeMapPass::GenerateCubeMapTexture() glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { - glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, 1024, 1024, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTestTextures[i]->Data); + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, GL_RGBA32F, m_CubeMapTextures[0]->Width, m_CubeMapTextures[0]->Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, m_CubeMapTextures[i]->Data); } glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); diff --git a/src/Engine/Rendering/DrawFinalPass.cpp b/src/Engine/Rendering/DrawFinalPass.cpp index e7982a3d..6cd2c1f1 100644 --- a/src/Engine/Rendering/DrawFinalPass.cpp +++ b/src/Engine/Rendering/DrawFinalPass.cpp @@ -383,6 +383,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionSkinnedHandle, explosionEffectJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (explosionEffectJob->AnimationOffset.animation != nullptr) { frameBones = explosionEffectJob->Skeleton->GetFrameBones(explosionEffectJob->Animations, explosionEffectJob->AnimationOffset); @@ -399,6 +401,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindExplosionTextures(explosionHandle, explosionEffectJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + } break; } @@ -459,6 +463,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& BindModelTextures(forwardSkinnedHandle, modelJob); glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapPass->m_CubeMapTexture); + glUniform3fv(glGetUniformLocation(forwardHandle, "CameraPosition"), 1, glm::value_ptr(scene.Camera->Position())); + std::vector frameBones; if (modelJob->AnimationOffset.animation != nullptr) { frameBones = modelJob->Skeleton->GetFrameBones(modelJob->Animations, modelJob->AnimationOffset); @@ -476,6 +482,7 @@ void DrawFinalPass::DrawModelRenderQueues(std::list>& 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; } From af68236e7186774ba25111523a5cbacb4860eaab Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 24 Feb 2016 13:58:05 +0100 Subject: [PATCH 22/28] now using a define INDICATOR_TEST to activate the DamageIndicatorSystem test. --- include/Game/Systems/DamageIndicatorSystem.h | 6 ++++-- src/Game/Systems/DamageIndicatorSystem.cpp | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/Game/Systems/DamageIndicatorSystem.h b/include/Game/Systems/DamageIndicatorSystem.h index 49ae249c..ae9ba195 100644 --- a/include/Game/Systems/DamageIndicatorSystem.h +++ b/include/Game/Systems/DamageIndicatorSystem.h @@ -14,6 +14,7 @@ #include #include "Rendering/Util/CommonFunctions.h" +//#define INDICATOR_TEST class DamageIndicatorSystem : public ImpureSystem { @@ -40,8 +41,9 @@ private: float CalculateAngle(EntityWrapper player, glm::vec3 enemyPos); //for tests - int m_TestVar = 0; - bool m_Testing = false; +#ifdef INDICATOR_TEST glm::vec3 DamageIndicatorTest(EntityWrapper player); + int m_TestVar = 0; +#endif }; #endif diff --git a/src/Game/Systems/DamageIndicatorSystem.cpp b/src/Game/Systems/DamageIndicatorSystem.cpp index 65e1caf0..92fbe607 100644 --- a/src/Game/Systems/DamageIndicatorSystem.cpp +++ b/src/Game/Systems/DamageIndicatorSystem.cpp @@ -42,9 +42,9 @@ bool DamageIndicatorSystem::OnPlayerDamage(Events::PlayerDamage& e) glm::vec3 inflictorPos = e.Inflictor["Transform"]["Position"]; //if testing - if (m_Testing) { +#ifdef INDICATOR_TEST inflictorPos = DamageIndicatorTest(e.Victim); - } +#endif float angleBetweenVectors = CalculateAngle(e.Victim, inflictorPos); @@ -100,6 +100,7 @@ float DamageIndicatorSystem::CalculateAngle(EntityWrapper player, glm::vec3 enem return angleBetweenVectors; } +#ifdef INDICATOR_TEST glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) { auto currentPos = (glm::vec3)player["Transform"]["Position"]; @@ -145,3 +146,4 @@ glm::vec3 DamageIndicatorSystem::DamageIndicatorTest(EntityWrapper player) { deathEffectEW["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"]; return inflictorPos; } +#endif \ No newline at end of file From 5af4f9d8e72795e4345cdc00623801d0c08bf51c Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 24 Feb 2016 14:06:41 +0100 Subject: [PATCH 23/28] Removed a comment originating from HUDDesynch branch --- src/Game/Systems/CapturePointSystem.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index e4df9740..b45f6ced 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -16,9 +16,6 @@ CapturePointSystem::CapturePointSystem(SystemParams params) //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { - //if (!IsClient) { - // return; - //} if (m_WinnerWasFound) { return; } From 607e83134df77faae4a276189494a8cf5bd64ef7 Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 14:16:49 +0100 Subject: [PATCH 24/28] Cubemaps working --- resources/Shaders/ForwardPlus.frag.glsl | 4 ++-- resources/Shaders/ForwardPlus.vert.glsl | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index 8b7a4824..cddd6d6b 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -136,7 +136,7 @@ void main() //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); + vec3 R = reflect(-I, Input.Normal); //R = vec3(P * vec4(R, 1.0)); vec4 reflectionColor = texture(CubeMap, R); @@ -170,7 +170,7 @@ void main() 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; - //color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); + color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/resources/Shaders/ForwardPlus.vert.glsl b/resources/Shaders/ForwardPlus.vert.glsl index 32daf240..26686222 100644 --- a/resources/Shaders/ForwardPlus.vert.glsl +++ b/resources/Shaders/ForwardPlus.vert.glsl @@ -26,9 +26,9 @@ void main() mat4 TIM = transpose(inverse(M)); Output.Position = Position; Output.TextureCoordinate = TextureCoords; - Output.Normal = vec3(TIM) * Normal; - Output.Tangent = vec3(TIM) * Tangent; - Output.BiTangent = vec3(TIM) * BiTangent; + Output.Normal = vec3(TIM * vec4(Normal, 0.0)); + Output.Tangent = vec3(TIM * vec4(Tangent, 0.0)); + Output.BiTangent = vec3(TIM * vec4(BiTangent, 0.0)); Output.ExplosionColor = vec4(1.0); Output.ExplosionPercentageElapsed = 0.0; } \ No newline at end of file From f41e0b29be13badc2ba84aef79611a0734da8aee Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 14:21:48 +0100 Subject: [PATCH 25/28] assets --- assets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets b/assets index 89b40707..10a61165 160000 --- a/assets +++ b/assets @@ -1 +1 @@ -Subproject commit 89b4070731584056402eac071845e9b1a0d156fb +Subproject commit 10a611659ddaadfea6a560e707d395834855a979 From 7394436e7a0f811e8e536595bd6b791c3b28ca45 Mon Sep 17 00:00:00 2001 From: stiffly Date: Wed, 24 Feb 2016 14:23:54 +0100 Subject: [PATCH 26/28] Removed unnecessary comment. --- src/Game/Systems/CapturePointSystem.cpp | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Game/Systems/CapturePointSystem.cpp b/src/Game/Systems/CapturePointSystem.cpp index 598a1a8e..f5e37429 100644 --- a/src/Game/Systems/CapturePointSystem.cpp +++ b/src/Game/Systems/CapturePointSystem.cpp @@ -16,9 +16,6 @@ CapturePointSystem::CapturePointSystem(SystemParams params) //NOTE: needs to run each frame, since we're possibly modifying the captureTimer for the capturePoints by dt void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, ComponentWrapper& cCapturePoint, double dt) { - //if (!IsClient) { - // return; - //} if (m_WinnerWasFound) { return; } From feeff5b164a86f88346046b2d84ac45af15b867b Mon Sep 17 00:00:00 2001 From: Tleety Date: Wed, 24 Feb 2016 14:47:47 +0100 Subject: [PATCH 27/28] Debug tool for different CubeMap changed cubemap influence. --- include/Engine/Rendering/CubeMapPass.h | 2 +- include/Engine/Rendering/Renderer.h | 1 + resources/Shaders/ForwardPlus.frag.glsl | 2 +- src/Engine/Rendering/CubeMapPass.cpp | 6 ++++-- src/Engine/Rendering/Renderer.cpp | 6 ++++++ 5 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/Engine/Rendering/CubeMapPass.h b/include/Engine/Rendering/CubeMapPass.h index 0840e2c8..3cda8cad 100644 --- a/include/Engine/Rendering/CubeMapPass.h +++ b/include/Engine/Rendering/CubeMapPass.h @@ -15,7 +15,7 @@ public: void GenerateCubeMapTexture(); //GLuint CubeMapTexture() const { return m_CubeMapTexture; } - GLuint m_CubeMapTexture; + GLuint m_CubeMapTexture = -1; private: IRenderer* m_Renderer; diff --git a/include/Engine/Rendering/Renderer.h b/include/Engine/Rendering/Renderer.h index 720336aa..f3a6bf31 100644 --- a/include/Engine/Rendering/Renderer.h +++ b/include/Engine/Rendering/Renderer.h @@ -59,6 +59,7 @@ private: Model* m_UnitSphere; int m_DebugTextureToDraw = 0; + int m_CubeMapTexture = 0; bool m_ResizeWindow = false; float m_SSAO_Radius = 1.0f; float m_SSAO_Bias = 0.05f; diff --git a/resources/Shaders/ForwardPlus.frag.glsl b/resources/Shaders/ForwardPlus.frag.glsl index cddd6d6b..6fbc9c27 100644 --- a/resources/Shaders/ForwardPlus.frag.glsl +++ b/resources/Shaders/ForwardPlus.frag.glsl @@ -170,7 +170,7 @@ void main() 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; - color_result = color_result * clamp(1/specularTexel, 0, 1) + reflectionColor * clamp(specularTexel, 0, 1); + color_result = color_result * clamp(1/specularTexel, 0, 1)*2 + reflectionColor * clamp(specularTexel, 0, 1)/2; //vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + (totalLighting.Specular * specularTexel)) * diffuseTexel * Color; diff --git a/src/Engine/Rendering/CubeMapPass.cpp b/src/Engine/Rendering/CubeMapPass.cpp index b64b77f1..75f5e1c9 100644 --- a/src/Engine/Rendering/CubeMapPass.cpp +++ b/src/Engine/Rendering/CubeMapPass.cpp @@ -4,7 +4,6 @@ CubeMapPass::CubeMapPass(IRenderer* renderer) :m_Renderer(renderer) { LoadTextures("Nevada"); - GenerateCubeMapTexture(); } void CubeMapPass::LoadTextures(std::string input) @@ -17,12 +16,15 @@ void CubeMapPass::LoadTextures(std::string input) Texture* img = ResourceManager::Load(str); m_CubeMapTextures.push_back(img); } + GenerateCubeMapTexture(); } } void CubeMapPass::GenerateCubeMapTexture() { - glGenTextures(1, &m_CubeMapTexture); + if (m_CubeMapTexture == -1) { + glGenTextures(1, &m_CubeMapTexture); + } glBindTexture(GL_TEXTURE_CUBE_MAP, m_CubeMapTexture); for (int i = 0; i < 6; i++) { diff --git a/src/Engine/Rendering/Renderer.cpp b/src/Engine/Rendering/Renderer.cpp index 8391599c..a3a53591 100644 --- a/src/Engine/Rendering/Renderer.cpp +++ b/src/Engine/Rendering/Renderer.cpp @@ -108,6 +108,12 @@ void Renderer::Draw(RenderFrame& frame) { GLERROR("PRE"); ImGui::Combo("Draw textures", &m_DebugTextureToDraw, "Final\0Scene\0Bloom\0SceneLowRes\0BloomLowRes\0Gaussian\0Picking\0Ambient Occlusion"); + ImGui::Combo("CubeMap", &m_CubeMapTexture, "Nevada(512)\0Sky(1024)"); + if(m_CubeMapTexture == 0) { + m_CubeMapPass->LoadTextures("Nevada"); + } else if (m_CubeMapTexture == 1) { + m_CubeMapPass->LoadTextures("Sky"); + } ImGui::SliderFloat("SSAO sample radius", &m_SSAO_Radius, 0.01f, 5.0f); ImGui::SliderFloat("SSAO bias", &m_SSAO_Bias, 0.0f, 0.1f); From ef87102d1f141810c2ebb3b2bc966f76d2849abc Mon Sep 17 00:00:00 2001 From: verysecrethero Date: Wed, 24 Feb 2016 17:53:37 +0100 Subject: [PATCH 28/28] Ammo,HealthPickup now takes in account for possible parenting/childing of the pickup. Also saved the xml files with the new scaling --- include/Game/Systems/AmmoPickupSystem.h | 1 + include/Game/Systems/PickupSpawnSystem.h | 1 + resources/Schema/Entities/AmmoPickup.xml | 10 +++++----- resources/Schema/Entities/HealthPickup.xml | 10 +++++----- src/Game/Systems/AmmoPickupSystem.cpp | 5 +++-- src/Game/Systems/PickupSpawnSystem.cpp | 3 ++- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/include/Game/Systems/AmmoPickupSystem.h b/include/Game/Systems/AmmoPickupSystem.h index a54b8495..0fbd9e08 100644 --- a/include/Game/Systems/AmmoPickupSystem.h +++ b/include/Game/Systems/AmmoPickupSystem.h @@ -26,6 +26,7 @@ private: double AmmoGain; double RespawnTimer; double DecreaseThisRespawnTimer; + EntityID parentID; }; std::vector m_ETriggerTouchVector; }; diff --git a/include/Game/Systems/PickupSpawnSystem.h b/include/Game/Systems/PickupSpawnSystem.h index f912e8ff..66c5f630 100644 --- a/include/Game/Systems/PickupSpawnSystem.h +++ b/include/Game/Systems/PickupSpawnSystem.h @@ -27,6 +27,7 @@ private: double HealthGain; double RespawnTimer; double DecreaseThisRespawnTimer; + EntityID parentID; }; std::vector m_ETriggerTouchVector; }; diff --git a/resources/Schema/Entities/AmmoPickup.xml b/resources/Schema/Entities/AmmoPickup.xml index 1d1435f7..bebde467 100644 --- a/resources/Schema/Entities/AmmoPickup.xml +++ b/resources/Schema/Entities/AmmoPickup.xml @@ -2,18 +2,18 @@ - Models/Props/PickUps/AmmoPickUp.mesh - 0.1 - + 8 + - - + + + diff --git a/resources/Schema/Entities/HealthPickup.xml b/resources/Schema/Entities/HealthPickup.xml index c6fbc4f4..b4b83392 100644 --- a/resources/Schema/Entities/HealthPickup.xml +++ b/resources/Schema/Entities/HealthPickup.xml @@ -2,18 +2,18 @@ - Models/Props/PickUps/HealthPickUp.mesh - 0.1 - + 8 + - - + + + diff --git a/src/Game/Systems/AmmoPickupSystem.cpp b/src/Game/Systems/AmmoPickupSystem.cpp index f6778fe4..250fa494 100644 --- a/src/Game/Systems/AmmoPickupSystem.cpp +++ b/src/Game/Systems/AmmoPickupSystem.cpp @@ -29,6 +29,7 @@ void AmmoPickupSystem::Update(double dt) newAmmoPickupEntity["Transform"]["Position"] = ammoPickupPosition.Pos; newAmmoPickupEntity["AmmoPickup"]["AmmoGain"] = ammoPickupPosition.AmmoGain; newAmmoPickupEntity["AmmoPickup"]["RespawnTimer"] = ammoPickupPosition.RespawnTimer; + m_World->SetParent(newAmmoPickupEntity.ID, ammoPickupPosition.parentID); //erase the current element (AmmoPickupPosition) m_ETriggerTouchVector.erase(it); @@ -69,8 +70,8 @@ bool AmmoPickupSystem::OnTriggerTouch(Events::TriggerTouch& e) //copy position, ammogain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each ammoPickup - m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["AmmoPickup"]["AmmoGain"], - e.Trigger["AmmoPickup"]["RespawnTimer"],e.Trigger["AmmoPickup"]["RespawnTimer"] }); + m_ETriggerTouchVector.push_back({ e.Trigger["Transform"]["Position"], e.Trigger["AmmoPickup"]["AmmoGain"], + e.Trigger["AmmoPickup"]["RespawnTimer"], e.Trigger["AmmoPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); //delete the ammopickup m_World->DeleteEntity(e.Trigger.ID); diff --git a/src/Game/Systems/PickupSpawnSystem.cpp b/src/Game/Systems/PickupSpawnSystem.cpp index 159f716b..abf59007 100644 --- a/src/Game/Systems/PickupSpawnSystem.cpp +++ b/src/Game/Systems/PickupSpawnSystem.cpp @@ -29,6 +29,7 @@ void PickupSpawnSystem::Update(double dt) newHealthPickupEntity["Transform"]["Position"] = healthPickupPosition.Pos; newHealthPickupEntity["HealthPickup"]["HealthGain"] = healthPickupPosition.HealthGain; newHealthPickupEntity["HealthPickup"]["RespawnTimer"] = healthPickupPosition.RespawnTimer; + m_World->SetParent(newHealthPickupEntity.ID, healthPickupPosition.parentID); //erase the current element (healthPickupPosition) m_ETriggerTouchVector.erase(it); @@ -58,7 +59,7 @@ bool PickupSpawnSystem::OnTriggerTouch(Events::TriggerTouch& e) //copy position, healthgain, respawntimer (twice since one of the values will be counted down to 0, the other will be set in the new object) //we need to copy all values since each value can be different for each healthPickup m_ETriggerTouchVector.push_back({ (glm::vec3)e.Trigger["Transform"]["Position"] ,e.Trigger["HealthPickup"]["HealthGain"], - e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"] }); + e.Trigger["HealthPickup"]["RespawnTimer"],e.Trigger["HealthPickup"]["RespawnTimer"], m_World->GetParent(e.Trigger.ID) }); //delete the healthpickup m_World->DeleteEntity(e.Trigger.ID);