Compare commits

..

30 Commits

Author SHA1 Message Date
Teejoon e000408593 Getting ShaderID one time per material in total instead of one time every frame 2016-03-11 11:03:09 +01:00
FakeShemp 937bf823f3 Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-10 21:59:23 +01:00
FakeShemp e35b09cc68 Add alpha clipping
Tobbe sa att jag fick pusha direkt
2016-03-10 21:59:01 +01:00
William Moberg b172526e62 Merge pull request #199 from teamfisk/CapturePointTake
The children of the CapturePointModels now also get their visibility changed
2016-03-10 16:37:53 +01:00
verysecrethero 551745b0a6 Merge remote-tracking branch 'origin/master' into CapturePointTake 2016-03-10 16:14:18 +01:00
verysecrethero 8b89df0095 Changed to a better validator 2016-03-10 16:09:54 +01:00
Jace 777f382772 Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-10 15:48:05 +01:00
Jace 78129cf432 Fixed picking depth values after depth buffer was changed to a texture. 2016-03-10 15:47:47 +01:00
Jace e734d0c953 Oops. 2016-03-10 15:47:32 +01:00
William Moberg c9fef65c4f Merge pull request #198 from teamfisk/Menu
Menu
2016-03-10 15:38:06 +01:00
Tleety 7e6288c597 Some merge fixes and some sprite fixes. 2016-03-10 15:36:33 +01:00
Tleety 4322a5d8da Some fixes for sprites 2016-03-10 15:21:11 +01:00
FakeShemp b094b9feca Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-10 15:01:27 +01:00
verysecrethero 0a94373f3f The children of the CapturePointModels now also get their visibility on/off. This is done since a capturepoint is actually 2 models and not just 1 2016-03-10 14:38:20 +01:00
Tleety 79d0ef4529 Changed default value of glow intensity 2016-03-10 14:01:45 +01:00
Jace dd63f4a1b4 Fixed FOV being used to calculate projection matrix being degrees when it should be radians, AGAIN. FOV angles are now correct! 2016-03-10 13:51:18 +01:00
Tleety 50dbbb4ed4 SSAO now send in 0 as Lod level and some optimizations in SSAO and Blur pass. 2016-03-10 13:47:16 +01:00
Tleety 329a15e08b Bloom bad edge clamp fixed 2016-03-10 13:42:33 +01:00
stiffly 28de31d84d FIX #196: Some variables had not been properly initialized and would cause the game to crash. 2016-03-10 13:28:38 +01:00
Jace e9ef0e7060 Disabled GLERROR macro for release builds 2016-03-10 13:19:26 +01:00
Jace 416f55b6ce Merge pull request #196 from teamfisk/RendererBugFixes
Fixed on window resize memory leak
2016-03-10 13:11:23 +01:00
Jace 0346f81234 Renderer resizing updated to send EResolutionChanged when the resolution is updated so cameras can update their aspect ratio and have a correct FOV. Renderer::SetResolution actually changes the resolution now too. 2016-03-10 13:09:34 +01:00
Tleety c3255519bf Blur is now looking like real blur 2016-03-10 13:07:41 +01:00
Teejoon a6ef026db5 Fixed on window resize memory leak 2016-03-10 12:27:25 +01:00
Tleety a2244e87ad WIP, trying to get blur to work with mipmaps 2016-03-10 12:18:06 +01:00
Tleety 592edf7dba Sprites can now be rendered with the texture ratio in mind 2016-03-09 23:31:54 +01:00
Tleety 087facc22e Textures are now able to keep their scale even though the sprite is scaled. 2016-03-09 22:22:32 +01:00
Tleety f9935cad42 Merge branch 'master' into Menu 2016-03-09 21:07:40 +01:00
Tleety 90b2c70215 Some sprite fixes 2016-03-09 19:12:06 +01:00
FakeShemp 7ced9e6767 Merge branch 'master' of github.com:teamfisk/TacticalZ 2016-03-08 17:25:03 +01:00
45 changed files with 666 additions and 350 deletions
+1 -1
Submodule assets updated: 3af64d8b1f...007b54bd67
+9 -3
View File
@@ -33,12 +33,14 @@ public:
if (m_Quality == 0) { if (m_Quality == 0) {
return m_BlackTexture->m_Texture; return m_BlackTexture->m_Texture;
} else { } else {
return m_GaussianTexture_vert; return m_FinalGaussianTexture;
} }
} }
private: private:
void GaussianLodPass(GLuint mipMap, GLuint texture);
void CombineGaussianBlur();
Texture* m_BlackTexture; Texture* m_BlackTexture;
Model* m_ScreenQuad; Model* m_ScreenQuad;
@@ -47,15 +49,19 @@ private:
//const LightCullingPass* m_LightCullingPass //const LightCullingPass* m_LightCullingPass
int m_Iterations; int m_Iterations;
int m_Quality = 0; int m_Quality = 0;
int m_BloomLod = 5;
GLuint m_GaussianTexture_horiz = 0; GLuint m_GaussianTexture_horiz = 0;
GLuint m_GaussianTexture_vert = 0; GLuint m_GaussianTexture_vert = 0;
GLuint m_FinalGaussianTexture = 0;
FrameBuffer m_GaussianFrameBuffer_horiz; FrameBuffer* m_GaussianFrameBuffer_horiz = nullptr;
FrameBuffer m_GaussianFrameBuffer_vert; FrameBuffer* m_GaussianFrameBuffer_vert = nullptr;
FrameBuffer m_GaussianCombineBuffer;
ShaderProgram* m_GaussianProgram_horiz; ShaderProgram* m_GaussianProgram_horiz;
ShaderProgram* m_GaussianProgram_vert; ShaderProgram* m_GaussianProgram_vert;
ShaderProgram* m_GaussianCombineProgram;
}; };
@@ -0,0 +1,19 @@
#ifndef EResolutionChanged_h__
#define EResolutionChanged_h__
#include "../Core/Event.h"
#include "../Core/Util/Rectangle.h"
namespace Events
{
// Fired when the framebuffer size changes
struct ResolutionChanged : Event
{
Rectangle OldResolution;
Rectangle NewResolution;
};
}
#endif
@@ -27,8 +27,6 @@ struct ExplosionEffectJob : ModelJob
Velocity = (glm::vec2)explosionEffectComponent["Velocity"]; Velocity = (glm::vec2)explosionEffectComponent["Velocity"];
ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"]; ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"];
ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"]; ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"];
Reverse = (bool)explosionEffectComponent["Reverse"];
ColorDistanceScalar = (double)explosionEffectComponent["ColorDistanceScalar"];
}; };
glm::vec3 ExplosionOrigin; glm::vec3 ExplosionOrigin;
@@ -40,14 +38,12 @@ struct ExplosionEffectJob : ModelJob
glm::vec4 EndColor; glm::vec4 EndColor;
bool Randomness = false; bool Randomness = false;
double RandomnessScalar = 1.f; float RandomnessScalar = 1.f;
glm::vec2 Velocity; glm::vec2 Velocity;
bool ColorByDistance = false; bool ColorByDistance = false;
//bool ReverseAnimation = false; //bool ReverseAnimation = false;
//bool Wireframe = false; //bool Wireframe = false;
bool ExponentialAccelaration = false; bool ExponentialAccelaration = false;
bool Reverse = false;
double ColorDistanceScalar = 1.f;
std::array<float, 50> RandomNumbers = { std::array<float, 50> RandomNumbers = {
0.3257552917701f, 0.3257552917701f,
+8 -7
View File
@@ -7,11 +7,12 @@
class BufferResource class BufferResource
{ {
public: public:
BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment); BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod);
GLuint* m_ResourceHandle; GLuint* m_ResourceHandle;
GLenum m_ResourceType; GLenum m_ResourceType;
GLenum m_Attachment; GLenum m_Attachment;
GLuint m_MipMapLod = 0;
private: private:
}; };
@@ -20,15 +21,15 @@ template <GLenum RESOURCETYPE>
class ResourceType : public BufferResource class ResourceType : public BufferResource
{ {
public: public:
ResourceType(GLuint* resourceHandle, GLenum attachment) ResourceType(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod)
: BufferResource(resourceHandle, RESOURCETYPE, attachment) { } : BufferResource(resourceHandle, RESOURCETYPE, attachment, mipMapLod) { }
}; };
class Texture2D : public ResourceType<GL_TEXTURE_2D> class Texture2D : public ResourceType<GL_TEXTURE_2D>
{ {
public: public:
Texture2D(GLuint* resourceHandle, GLenum attachment) Texture2D(GLuint* resourceHandle, GLenum attachment, GLuint mipMapLod = 0)
: ResourceType(resourceHandle, attachment) { }; : ResourceType(resourceHandle, attachment, mipMapLod) { };
~Texture2D(); ~Texture2D();
}; };
@@ -37,7 +38,7 @@ class RenderBuffer : public ResourceType<GL_RENDERBUFFER>
{ {
public: public:
RenderBuffer(GLuint* resourceHandle, GLenum attachment) RenderBuffer(GLuint* resourceHandle, GLenum attachment)
: ResourceType(resourceHandle, attachment) : ResourceType(resourceHandle, attachment, 0)
{ }; { };
~RenderBuffer(); ~RenderBuffer();
@@ -47,7 +48,7 @@ class Texture2DArray : public ResourceType<GL_TEXTURE_2D_ARRAY>
{ {
public: public:
Texture2DArray(GLuint* resourceHandle, GLenum attachment) Texture2DArray(GLuint* resourceHandle, GLenum attachment)
: ResourceType(resourceHandle, attachment) : ResourceType(resourceHandle, attachment, 0)
{ }; { };
~Texture2DArray(); ~Texture2DArray();
+3 -3
View File
@@ -54,7 +54,7 @@ private:
struct Frustum { struct Frustum {
Plane Planes[4]; Plane Planes[4];
}; };
Frustum* m_Frustums; Frustum* m_Frustums = nullptr;
//This should be a component //This should be a component
struct LightSource { struct LightSource {
@@ -74,11 +74,11 @@ private:
glm::vec2 Padding = glm::vec2(1.f, 2.f); glm::vec2 Padding = glm::vec2(1.f, 2.f);
}; };
LightGrid* m_LightGrid; LightGrid* m_LightGrid = nullptr;
int m_LightOffset = 0; int m_LightOffset = 0;
float* m_LightIndex; float* m_LightIndex = nullptr;
}; };
+1 -18
View File
@@ -26,24 +26,13 @@ struct ModelJob : RenderJob
ModelID = model->ResourceID; ModelID = model->ResourceID;
Type = matProp.type; Type = matProp.type;
::RawModel::MaterialBasic* matGroup = matProp.material; ::RawModel::MaterialBasic* matGroup = matProp.material;
ShaderID = matProp.ShaderID;
switch(matProp.type){ switch(matProp.type){
case ::RawModel::MaterialType::Basic: case ::RawModel::MaterialType::Basic:
if (Model->IsSkinned()) {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSkinnedProgram")->ResourceID;
}
else {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
}
TextureID = 0; TextureID = 0;
break; break;
case ::RawModel::MaterialType::SingleTextures: case ::RawModel::MaterialType::SingleTextures:
{ {
if (Model->IsSkinned()) {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSkinnedProgram")->ResourceID;
}
else {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
}
::RawModel::MaterialSingleTextures* singleTextures = static_cast<::RawModel::MaterialSingleTextures*>(matProp.material); ::RawModel::MaterialSingleTextures* singleTextures = static_cast<::RawModel::MaterialSingleTextures*>(matProp.material);
TextureID = (singleTextures->ColorMap.Texture) ? singleTextures->ColorMap.Texture->ResourceID : 0; TextureID = (singleTextures->ColorMap.Texture) ? singleTextures->ColorMap.Texture->ResourceID : 0;
if (modelComponent["DiffuseTexture"]) { if (modelComponent["DiffuseTexture"]) {
@@ -65,12 +54,6 @@ struct ModelJob : RenderJob
break; break;
case ::RawModel::MaterialType::SplatMapping: case ::RawModel::MaterialType::SplatMapping:
{ {
if (Model->IsSkinned()) {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapSkinnedProgram")->ResourceID;
}
else {
ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapProgram")->ResourceID;
}
::RawModel::MaterialSplatMapping* SplatTextures = static_cast<::RawModel::MaterialSplatMapping*>(matProp.material); ::RawModel::MaterialSplatMapping* SplatTextures = static_cast<::RawModel::MaterialSplatMapping*>(matProp.material);
SplatMap = &SplatTextures->SplatMap; SplatMap = &SplatTextures->SplatMap;
@@ -18,6 +18,7 @@
#include "../Core/ResourceManager.h" #include "../Core/ResourceManager.h"
#include "Texture.h" #include "Texture.h"
#include "Skeleton.h" #include "Skeleton.h"
#include "ShaderProgram.h"
#include "boost\endian\buffers.hpp" #include "boost\endian\buffers.hpp"
@@ -87,6 +88,7 @@ public:
struct MaterialProperties { struct MaterialProperties {
MaterialType type; MaterialType type;
MaterialBasic* material; MaterialBasic* material;
unsigned int ShaderID = 0;
}; };
const Vertex* Vertices() const { const Vertex* Vertices() const {
+3
View File
@@ -19,6 +19,7 @@
#include "../Core/Octree.h" #include "../Core/Octree.h"
#include "../Collision/EntityAABB.h" #include "../Collision/EntityAABB.h"
#include "../Core/ConfigFile.h" #include "../Core/ConfigFile.h"
#include "EResolutionChanged.h"
class RenderSystem : public ImpureSystem class RenderSystem : public ImpureSystem
{ {
@@ -36,6 +37,8 @@ private:
EntityWrapper m_LocalPlayer = EntityWrapper::Invalid; EntityWrapper m_LocalPlayer = EntityWrapper::Invalid;
Octree<EntityAABB>* m_Octree; Octree<EntityAABB>* m_Octree;
EventRelay<RenderSystem, Events::ResolutionChanged> m_EResolutionChanged;
bool OnResolutionChanged(Events::ResolutionChanged &event);
EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera; EventRelay<RenderSystem, Events::SetCamera> m_ESetCamera;
bool OnSetCamera(Events::SetCamera &event); bool OnSetCamera(Events::SetCamera &event);
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand; EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
+8 -2
View File
@@ -28,10 +28,12 @@
#include "Util/CommonFunctions.h" #include "Util/CommonFunctions.h"
#include "Core/PerformanceTimer.h" #include "Core/PerformanceTimer.h"
#include "ShadowPass.h" #include "ShadowPass.h"
#include "EResolutionChanged.h"
class Renderer : public IRenderer class Renderer : public IRenderer
{ {
static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height); static void glfwFrameBufferCallback(GLFWwindow* window, int width, int height);
static void glfwWindowSizeCallback(GLFWwindow* window, int width, int height);
public: public:
Renderer(EventBroker* eventBroker, ConfigFile* config) Renderer(EventBroker* eventBroker, ConfigFile* config)
@@ -40,13 +42,14 @@ public:
{ } { }
~Renderer(); ~Renderer();
virtual void SetResolution(const Rectangle& resolution) override;
virtual void Initialize() override; virtual void Initialize() override;
virtual void Update(double dt) override; virtual void Update(double dt) override;
virtual void Draw(RenderFrame& frame) override; virtual void Draw(RenderFrame& frame) override;
virtual PickData Pick(glm::vec2 screenCoord) override; virtual PickData Pick(glm::vec2 screenCoord) override;
private: private:
//----------------------Variables----------------------// //----------------------Variables----------------------//
@@ -90,11 +93,14 @@ private:
void InputUpdate(double dt); void InputUpdate(double dt);
//void PickingPass(RenderQueueCollection& rq); //void PickingPass(RenderQueueCollection& rq);
//void DrawScreenQuad(GLuint textureToDraw); //void DrawScreenQuad(GLuint textureToDraw);
void setWindowSize(Rectangle size);
void updateFramebufferSize();
static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); } static bool DepthSort(const std::shared_ptr<RenderJob> &i, const std::shared_ptr<RenderJob> &j) { return (i->Depth < j->Depth); }
void SortRenderJobsByDepth(RenderScene &scene); void SortRenderJobsByDepth(RenderScene &scene);
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type); void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type);
//--------------------ShaderPrograms-------------------//
//--------------------ShaderPrograms-------------------//
ShaderProgram* m_BasicForwardProgram; ShaderProgram* m_BasicForwardProgram;
ShaderProgram* m_ExplosionEffectProgram; ShaderProgram* m_ExplosionEffectProgram;
+26 -2
View File
@@ -21,14 +21,15 @@ struct SpriteJob : RenderJob
SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator) SpriteJob(ComponentWrapper cSprite, Camera* camera, glm::mat4 matrix, World* world, glm::vec4 fillColor, float fillPercentage, bool depthSorted, bool isIndicator)
: RenderJob() : RenderJob()
{ {
Model = ResourceManager::Load<::Model>("Models/Core/UnitQuad.mesh"); Model = ResourceManager::Load<::Model>((std::string)cSprite["Model"]);
::RawModel::MaterialProperties matProp = Model->MaterialGroups().front(); ::RawModel::MaterialProperties matProp = Model->MaterialGroups().front();
TextureID = 0; TextureID = 0;
DiffuseTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["DiffuseTexture"]); DiffuseTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["DiffuseTexture"]);
IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]); IncandescenceTexture = CommonFunctions::TryLoadResource<TextureSprite, true>(cSprite["GlowMap"]);
Linear = (bool)cSprite["Linear"];
StartIndex = matProp.material->StartIndex; StartIndex = matProp.material->StartIndex;
EndIndex = matProp.material->EndIndex; EndIndex = matProp.material->EndIndex;
Matrix = matrix; Matrix = matrix;
@@ -48,6 +49,26 @@ struct SpriteJob : RenderJob
FillColor = fillColor; FillColor = fillColor;
FillPercentage = fillPercentage; FillPercentage = fillPercentage;
glm::vec3 scale = Transform::AbsoluteScale(world, cSprite.EntityID);
if((bool)cSprite["KeepRatio"] == true) {
if(scale.y >= scale.x) {
ScaleY = (scale.x)/(scale.y);
ScaleX = 1.f;
} else {
ScaleY = 1.f;
ScaleX = (scale.x)/(scale.y);
}
} else {
if ((bool)cSprite["KeepRatioX"] == true) {
ScaleX = scale.x;
}
if ((bool)cSprite["KeepRatioY"] == true) {
ScaleY = scale.y;
}
}
}; };
unsigned int TextureID; unsigned int TextureID;
@@ -69,6 +90,9 @@ struct SpriteJob : RenderJob
bool Pickable; bool Pickable;
bool IsIndicator = false; bool IsIndicator = false;
bool BlurBackground = false; bool BlurBackground = false;
float ScaleX = 1;
float ScaleY = 1;
bool Linear = false;
glm::vec4 FillColor = glm::vec4(0); glm::vec4 FillColor = glm::vec4(0);
float FillPercentage = 0.0; float FillPercentage = 0.0;
+4
View File
@@ -16,7 +16,11 @@ inline bool _GLERROR(const char* info, const char* file, const char* func, unsig
return false; return false;
} }
#ifdef DEBUG
#define GLERROR(function) \ #define GLERROR(function) \
_GLERROR(function, __BASE_FILE__, __func__, __LINE__) _GLERROR(function, __BASE_FILE__, __func__, __LINE__)
#else
#define GLERROR(function) false
#endif
#endif #endif
@@ -30,6 +30,7 @@ private:
bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e); bool CapturePointSystem::OnTriggerLeave(const Events::TriggerLeave& e);
EventRelay<CapturePointSystem, Events::Captured> m_ECaptured; EventRelay<CapturePointSystem, Events::Captured> m_ECaptured;
bool CapturePointSystem::OnCaptured(const Events::Captured& e); bool CapturePointSystem::OnCaptured(const Events::Captured& e);
void ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner);
bool m_WinnerWasFound = false; bool m_WinnerWasFound = false;
//need to track these variables for the captureSystem to work as per design! //need to track these variables for the captureSystem to work as per design!
@@ -3,7 +3,6 @@
#include "Common.h" #include "Common.h"
#include "Core/System.h" #include "Core/System.h"
#include "Engine/GLM.h"
class ExplosionEffectSystem : public PureSystem class ExplosionEffectSystem : public PureSystem
{ {
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Camera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Camera.xsd"> <Camera xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Camera.xsd">
<FOV>45</FOV> <FOV>59</FOV> <!-- 90 horizontal FOV at 1080p -->
<NearClip>0.01</NearClip> <NearClip>0.01</NearClip>
<FarClip>5000</FarClip> <FarClip>5000</FarClip>
</Camera> </Camera>
@@ -1,21 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<ExplosionEffect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ExplosionEffect.xsd"> <ExplosionEffect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ExplosionEffect.xsd">
<ExplosionOrigin X="0" Y="0" Z="0"/> <ExplosionOrigin X="0" Y="0" Z="0"/>
<TimeSinceDeath>0.0</TimeSinceDeath> <TimeSinceDeath>0</TimeSinceDeath>
<ExplosionDuration>2.0</ExplosionDuration> <ExplosionDuration>2</ExplosionDuration>
<Speed>1</Speed> <Speed>1</Speed>
<Delay>0</Delay> <Delay>0</Delay>
<!--<Gravity>1</Gravity>--> <!--<Gravity>1</Gravity>-->
<!--<GravityForce>1</GravityForce>--> <!--<GravityForce>1</GravityForce>-->
<!--<ObjectRadius>2</ObjectRadius>--> <!--<ObjectRadius>2</ObjectRadius>-->
<EndColor R="0" G="0" B="0" A="0"/> <EndColor R="0" G="0" B="0" A="0"/>
<Randomness>false</Randomness> <Randomness>0</Randomness>
<RandomnessScalar>1.0</RandomnessScalar> <RandomnessScalar>1</RandomnessScalar>
<Velocity X="2" Y="2"/> <Velocity X="2" Y="2"/>
<ColorByDistance>false</ColorByDistance> <ColorByDistance>0</ColorByDistance>
<!--<ReverseAnimation>0</ReverseAnimation>-->
<!--<Wireframe>0</Wireframe>--> <!--<Wireframe>0</Wireframe>-->
<ExponentialAccelaration>false</ExponentialAccelaration> <ExponentialAccelaration>0</ExponentialAccelaration>
<Pulsate>false</Pulsate>
<Reverse>false</Reverse>
<ColorDistanceScalar>1.0</ColorDistanceScalar>
</ExplosionEffect> </ExplosionEffect>
@@ -44,21 +44,15 @@
<xs:element name="ColorByDistance" type="t:bool" minOccurs="0"> <xs:element name="ColorByDistance" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Change the color by its moved distance instead of by its time</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<!--<xs:element name="ReverseAnimation" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Implosions are cooler</xs:documentation></xs:annotation>
</xs:element>-->
<!--<xs:element name="Wireframe" type="t:bool" minOccurs="0"> <!--<xs:element name="Wireframe" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
</xs:element>--> </xs:element>-->
<xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0"> <xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="Pulsate" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Pulsate the effect</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Reverse" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Reverse the effect</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="ColorDistanceScalar" type="t:double" minOccurs="0">
<xs:annotation><xs:documentation>Scale the distance of the color change</xs:documentation></xs:annotation>
</xs:element>
</xs:all> </xs:all>
</xs:complexType> </xs:complexType>
</xs:element> </xs:element>
+1 -1
View File
@@ -9,5 +9,5 @@
<SpecularMap>true</SpecularMap> <SpecularMap>true</SpecularMap>
<GlowMap>true</GlowMap> <GlowMap>true</GlowMap>
<Shadow>true</Shadow> <Shadow>true</Shadow>
<GlowIntensity>3.0</GlowIntensity> <GlowIntensity>1.0</GlowIntensity>
</Model> </Model>
+5
View File
@@ -1,9 +1,14 @@
<?xml version="1.0" encoding="UTF-8" standalone="no" ?> <?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<Sprite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Sprite.xsd"> <Sprite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Sprite.xsd">
<Model>Models/Core/UnitQuad.mesh</Model>
<DiffuseTexture></DiffuseTexture> <DiffuseTexture></DiffuseTexture>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<Color R="1" G="1" B="1" A="1"/> <Color R="1" G="1" B="1" A="1"/>
<Visible>true</Visible> <Visible>true</Visible>
<DepthSort>true</DepthSort> <DepthSort>true</DepthSort>
<KeepRatioX>false</KeepRatioX>
<KeepRatioY>false</KeepRatioY>
<KeepRatio>false</KeepRatio>
<Linear>false</Linear>
<BlurBackground>false</BlurBackground> <BlurBackground>false</BlurBackground>
</Sprite> </Sprite>
+18 -3
View File
@@ -9,14 +9,17 @@
</xs:annotation> </xs:annotation>
<xs:complexType> <xs:complexType>
<xs:all> <xs:all>
<xs:element name="Model" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>The model the sprite will use.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="DiffuseTexture" type="t:string" minOccurs="0"> <xs:element name="DiffuseTexture" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>Diffuse Texture file</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Diffuse Texture file.</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="GlowMap" type="t:string" minOccurs="0"> <xs:element name="GlowMap" type="t:string" minOccurs="0">
<xs:annotation><xs:documentation>GlowMap file</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>GlowMap file.</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="Color" type="t:Color" minOccurs="0"> <xs:element name="Color" type="t:Color" minOccurs="0">
<xs:annotation><xs:documentation>Color tint</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Color tint.</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="Visible" type="t:bool" minOccurs="0"> <xs:element name="Visible" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Whether the model is visible or not</xs:documentation></xs:annotation>
@@ -24,6 +27,18 @@
<xs:element name="DepthSort" type="t:bool" minOccurs="0"> <xs:element name="DepthSort" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Whether the sprite should be sorted with depth or not. Only use false for textures that are on HUD</xs:documentation></xs:annotation>
</xs:element> </xs:element>
<xs:element name="KeepRatioX" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the sprite should repeat in x instead of stretch when scaled.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="KeepRatioY" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the sprite should repeat in y instead of stretch when scaled.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="KeepRatio" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Keep a 1:1 ratio between X and Y.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="Linear" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>If it should use Linear or Nearest sampling method.</xs:documentation></xs:annotation>
</xs:element>
<xs:element name="BlurBackground" type="t:bool" minOccurs="0"> <xs:element name="BlurBackground" type="t:bool" minOccurs="0">
<xs:annotation><xs:documentation>Wether the background should be blurred begind this sprite.</xs:documentation></xs:annotation> <xs:annotation><xs:documentation>Wether the background should be blurred begind this sprite.</xs:documentation></xs:annotation>
</xs:element> </xs:element>
+94 -73
View File
@@ -8,7 +8,7 @@
</c:RaptorCopter> </c:RaptorCopter>
<c:Transform> <c:Transform>
<Position X="0" Y="-4" Z="0"/> <Position X="0" Y="-4" Z="0"/>
<Orientation X="0" Y="55.3495064" Z="0"/> <Orientation X="0" Y="58.3794823" Z="0"/>
</c:Transform> </c:Transform>
</Components> </Components>
@@ -34,13 +34,49 @@
</c:Transform> </c:Transform>
</Components> </Components>
<Children> <Children>
<Entity name="AssaultClassPick">
<Components>
<c:Button/>
<c:Sprite>
<DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Icons/Classes/Assault-01.png</DiffuseTexture>
</c:Sprite>
<c:InputCmdButton>
<Command>PickClass</Command>
<PressValue>1</PressValue>
</c:InputCmdButton>
<c:Transform>
<Position X="-0.150000006" Y="-0.0500000007" Z="0"/>
<Scale X="0.0799999982" Y="0.0799999982" Z="1"/>
</c:Transform>
</Components>
<Children>
<Entity name="AssaultText">
<Components>
<c:Text>
<Content>Assault</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="0" G="1" R="0.784313738"/>
</c:Text>
<c:Transform>
<Position X="0" Y="0.800000012" Z="0"/>
<Scale X="0.310000002" Y="0.310000002" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="DefenderClassPick"> <Entity name="DefenderClassPick">
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Icons/Classes/Defender-01.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Icons/Classes/Defender-01.png</DiffuseTexture>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
<Command>PickClass</Command> <Command>PickClass</Command>
@@ -72,9 +108,10 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Icons/Classes/Sniper-01.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Icons/Classes/Sniper-01.png</DiffuseTexture>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
<Command>PickClass</Command> <Command>PickClass</Command>
@@ -102,40 +139,6 @@
</Entity> </Entity>
</Children> </Children>
</Entity> </Entity>
<Entity name="AssaultClassPick">
<Components>
<c:Button/>
<c:Sprite>
<DiffuseTexture>Textures/Icons/Classes/Assault-01.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort>
</c:Sprite>
<c:InputCmdButton>
<Command>PickClass</Command>
<PressValue>1</PressValue>
</c:InputCmdButton>
<c:Transform>
<Position X="-0.150000006" Y="-0.0500000007" Z="0"/>
<Scale X="0.0799999982" Y="0.0799999982" Z="1"/>
</c:Transform>
</Components>
<Children>
<Entity name="AssaultText">
<Components>
<c:Text>
<Content>Assault</Content>
<Resource>Fonts/DroidSans.ttf,64</Resource>
<Color A="1" B="0" G="1" R="0.784313738"/>
</c:Text>
<c:Transform>
<Position X="0" Y="0.800000012" Z="0"/>
<Scale X="0.310000002" Y="0.310000002" Z="1"/>
</c:Transform>
</Components>
<Children/>
</Entity>
</Children>
</Entity>
<Entity name="ClassPickText"> <Entity name="ClassPickText">
<Components> <Components>
<c:Text> <c:Text>
@@ -154,9 +157,10 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="1" B="0" G="1" R="0.509803951"/> <Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
@@ -232,9 +236,10 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="1" B="0" G="1" R="0.509803951"/> <Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
@@ -266,10 +271,11 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture> <Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap> <GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="1" B="0" G="0.294117659" R="0.980392158"/> <Color A="1" B="0" G="0.294117659" R="0.980392158"/>
<Linear>true</Linear>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
<Command>PickTeam</Command> <Command>PickTeam</Command>
@@ -300,10 +306,12 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="1" B="0.980392158" G="0.294117659" R="0"/> <Color A="1" B="0.980392158" G="0.294117659" R="0"/>
<Linear>true</Linear>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
<Command>PickTeam</Command> <Command>PickTeam</Command>
@@ -334,9 +342,10 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="1" B="0" G="1" R="0.509803951"/> <Color A="1" B="0" G="1" R="0.509803951"/>
<Visible>false</Visible> <Visible>false</Visible>
</c:Sprite> </c:Sprite>
@@ -422,9 +431,10 @@
<Entity name="BackgroundHexagon"> <Entity name="BackgroundHexagon">
<Components> <Components>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="0.300000012" B="1" G="1" R="1"/> <Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
@@ -441,9 +451,10 @@
<CapturePointNumber>3</CapturePointNumber> <CapturePointNumber>3</CapturePointNumber>
</c:CapturePointHUD> </c:CapturePointHUD>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/> <Position X="0" Y="0" Z="0.00999999978"/>
@@ -458,9 +469,10 @@
<Entity name="BackgroundHexagon"> <Entity name="BackgroundHexagon">
<Components> <Components>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="0.699999988" B="1" G="0.200000003" R="0"/> <Color A="0.699999988" B="1" G="0.200000003" R="0"/>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
@@ -477,9 +489,10 @@
<CapturePointNumber>4</CapturePointNumber> <CapturePointNumber>4</CapturePointNumber>
</c:CapturePointHUD> </c:CapturePointHUD>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/> <Position X="0" Y="0" Z="0.00999999978"/>
@@ -494,9 +507,10 @@
<Entity name="BackgroundHexagon"> <Entity name="BackgroundHexagon">
<Components> <Components>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="0.300000012" B="1" G="1" R="1"/> <Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
@@ -513,9 +527,10 @@
<CapturePointNumber>2</CapturePointNumber> <CapturePointNumber>2</CapturePointNumber>
</c:CapturePointHUD> </c:CapturePointHUD>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/> <Position X="0" Y="0" Z="0.00999999978"/>
@@ -530,9 +545,10 @@
<Entity name="BackgroundHexagon"> <Entity name="BackgroundHexagon">
<Components> <Components>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="0.300000012" B="1" G="1" R="1"/> <Color A="0.300000012" B="1" G="1" R="1"/>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
@@ -550,9 +566,10 @@
<CapturePointNumber>1</CapturePointNumber> <CapturePointNumber>1</CapturePointNumber>
</c:CapturePointHUD> </c:CapturePointHUD>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/> <Position X="0" Y="0" Z="0.00999999978"/>
@@ -567,9 +584,10 @@
<Entity name="BackgroundHexagon"> <Entity name="BackgroundHexagon">
<Components> <Components>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="0.699999988" B="0" G="0" R="1"/> <Color A="0.699999988" B="0" G="0" R="1"/>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
@@ -584,9 +602,10 @@
</c:Fill> </c:Fill>
<c:CapturePointHUD/> <c:CapturePointHUD/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon_Rotated.png</DiffuseTexture>
</c:Sprite> </c:Sprite>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="0.00999999978"/> <Position X="0" Y="0" Z="0.00999999978"/>
@@ -604,9 +623,10 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="1" B="0" G="1" R="0.509803951"/> <Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
@@ -651,9 +671,10 @@
<Components> <Components>
<c:Button/> <c:Button/>
<c:Sprite> <c:Sprite>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<GlowMap></GlowMap>
<DepthSort>false</DepthSort> <DepthSort>false</DepthSort>
<Model>Models/Core/UnitQuad.mesh</Model>
<GlowMap></GlowMap>
<DiffuseTexture>Textures/Core/UnitHexagon.png</DiffuseTexture>
<Color A="1" B="0" G="1" R="0.509803951"/> <Color A="1" B="0" G="1" R="0.509803951"/>
</c:Sprite> </c:Sprite>
<c:InputCmdButton> <c:InputCmdButton>
@@ -99,7 +99,7 @@
</c:Team> </c:Team>
<c:PlayerSpawn/> <c:PlayerSpawn/>
<c:Spawner> <c:Spawner>
<EntityFile>Schema/Entities/Player.xml</EntityFile> <EntityFile>Schema/Entities/PlayerRed.xml</EntityFile>
</c:Spawner> </c:Spawner>
<c:Transform/> <c:Transform/>
</Components> </Components>
@@ -225,6 +225,11 @@
</Team> </Team>
</c:Team> </c:Team>
<c:Trigger/> <c:Trigger/>
<c:Model>
<Resource></Resource>
<Color A="0.300000012" B="0" G="0" R="1"/>
<Visible>false</Visible>
</c:Model>
<c:Transform> <c:Transform>
<Position X="0" Y="0" Z="-4.10000038"/> <Position X="0" Y="0" Z="-4.10000038"/>
</c:Transform> </c:Transform>
@@ -239,7 +244,17 @@
<Scale X="2.70000005" Y="3.4000001" Z="4.60000038"/> <Scale X="2.70000005" Y="3.4000001" Z="4.60000038"/>
</c:Transform> </c:Transform>
</Components> </Components>
<Children/> <Children>
<Entity>
<Components>
<c:Model>
<Resource></Resource>
</c:Model>
<c:Transform/>
</Components>
<Children/>
</Entity>
</Children>
</Entity> </Entity>
<Entity name="Blue"> <Entity name="Blue">
<Components> <Components>
@@ -0,0 +1,21 @@
#version 430
layout (binding = 0) uniform sampler2D Texture;
uniform int MaxMipMap;
in VertexData{
vec2 TextureCoordinate;
}Input;
out vec4 fragmentColor;
void main()
{
vec4 result = vec4(0.0, 0.0, 0.0, 0.0);
for(int i = 0; i < MaxMipMap; i++) {
result += textureLod(Texture, Input.TextureCoordinate, i);
}
fragmentColor = result;
}
@@ -0,0 +1,13 @@
#version 430
layout (location = 0) in vec3 Position;
out VertexData{
vec2 TextureCoordinate;
}Output;
void main()
{
gl_Position = vec4(Position, 1.0);
Output.TextureCoordinate = (vec2(Position) + 1) / 2;
}
+125 -97
View File
@@ -15,11 +15,6 @@ uniform float RandomnessScalar;
uniform vec2 Velocity; uniform vec2 Velocity;
uniform bool ColorByDistance; uniform bool ColorByDistance;
uniform bool ExponentialAccelaration; uniform bool ExponentialAccelaration;
uniform bool Reverse;
uniform float ColorDistanceScalar;
//uniform bool Gravity;
//uniform bool Rotation;
//uniform bool MaxRadius;
in VertexData{ in VertexData{
vec3 Position; vec3 Position;
@@ -46,136 +41,169 @@ out VertexData{
layout(triangles) in; layout(triangles) in;
layout(triangle_strip, max_vertices = 3) out; layout(triangle_strip, max_vertices = 3) out;
float EqualTo(float x, float y) {
return 1.0 - abs(sign(x - y));
}
float NotEqualTo(float x, float y) {
return abs(sign(x - y));
}
float GreaterThan(float x, float y) {
return max(sign(x - y), 0.0);
}
float LessThan(float x, float y) {
return max(sign(y - x), 0.0);
}
float GreaterEqualTo(float x, float y) {
return 1.0 - LessThan(x, y);
}
float LessEqualTo(float x, float y) {
return 1.0 - GreaterThan(x, y);
}
// returns a "random" number based on input parameter // returns a "random" number based on input parameter
float GetRandomNumber(int polygon_index) float GetRandomNumber(int polygon_index)
{ {
return RandomNumbers[int(mod(polygon_index, 50))]; int randomIndex = int(mod(polygon_index, 50));
return RandomNumbers[randomIndex];
} }
vec3 CalcCenterOfTriangle(vec3 vertex0, vec3 vertex1, vec3 vertex2) float randomNumber = 0.0;
float randomDistance = 0.0;
void main()
{ {
// calculate middle of vectors // calculate middle of vectors
vec3 dir1 = normalize(vertex1 - vertex0); vec3 v1 = Input[1].Position - Input[0].Position;
vec3 dir2 = normalize(vertex2 - vertex0); vec3 v2 = Input[2].Position - Input[0].Position;
vec3 v3 = Input[2].Position - (v1 / 2);
vec3 v4 = Input[1].Position - (v2 / 2);
vec3 vecA = vertex2 - vertex1; //o2 - o1 // calculate intersection
// normalize direction
vec3 dir1 = normalize(v1);
vec3 dir2 = normalize(v2);
vec3 vecA = Input[2].Position - Input[1].Position; //o2 - o1
vec3 vecB = cross(dir1, dir2); vec3 vecB = cross(dir1, dir2);
mat3 matrisA = mat3(vecA, dir2, vecB); mat3 matrisA = mat3(vecA, dir2, vecB);
float lengthA = length(vecB); float lengthA = length(vecB);
lengthA = lengthA * lengthA; lengthA = lengthA * lengthA;
float s = determinant(matrisA) / lengthA; float s = determinant(matrisA) / lengthA;
// center position of triangle // center position of triangle
return vertex1 + (s * dir1); vec3 centerOfTriangle = Input[1].Position + (s * dir1);
}
void PassThingsThrough(int index)
{
// pass through vertex data
Output.Normal = Input[index].Normal;
Output.Position = Input[index].Position;
Output.TextureCoordinate = Input[index].TextureCoordinate;
Output.Tangent = Input[index].Tangent;
Output.BiTangent = Input[index].BiTangent;
Output.ExplosionColor = EndColor;
}
void main()
{
vec3 centerOfTriangle = CalcCenterOfTriangle(Input[0].Position, Input[1].Position, Input[2].Position);
// center position of triangle to origin vector // center position of triangle to origin vector
vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin; vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin;
vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector); vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector);
// distance between origin and the center of the current triangle
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
// time percentage until end of explosion (0.0-1.0) // time percentage until end of explosion (0.0-1.0)
float timePercetage = TimeSinceDeath / ExplosionDuration; float timePercetage = TimeSinceDeath / ExplosionDuration;
// get a random number if randomness is enabled, otherwise the random distance will be zero and won't affect the other algorithms // get a random number if randomness is enabled, otherwise the random number will be zero and won't affect the other algorithms
float randomDistance = float(Randomness) * GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar; if (Randomness == true)
{
randomDistance = GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
}
vec2 randomVelocity = Velocity * (randomDistance + 1.0); vec2 randomVelocity = Velocity * (randomDistance + 1.0);
// accelaration to use on current frame. is a interpolation between start and end value // accelaration to use on current frame. is a interpolation between start and end value
float currentVelocity = mix(randomVelocity.x, randomVelocity.y, timePercetage); float currentVelocity = mix(randomVelocity.x, randomVelocity.y, timePercetage);
// if the accelaration should be exponential if (ExponentialAccelaration == true)
currentVelocity = currentVelocity * max(currentVelocity * float(ExponentialAccelaration), 1.0); {
currentVelocity = pow(currentVelocity, 2) / 2.0;
}
// the distance the blast has moved since the beginning, i.e. its radius // distance between origin and the center of the current triangle
float blastWave = TimeSinceDeath * currentVelocity; float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
// the distance from origin to the triangle center with eventual randomness added // the distance from origin to the triangle center with eventual randomness added
float origin2TriangleCenterDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance; float fullDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * blastWave) - (normalizedOrigin2TriangleCenterVector * origin2TriangleCenterDistanceWithRandomness);
// if the triangle is inside the blast's radius... // vector from the triangle center to the explosion's shockwave
float isInsideBlastRadius = LessEqualTo(origin2TriangleCenterDistanceWithRandomness, blastWave); vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * (TimeSinceDeath * currentVelocity)) - (normalizedOrigin2TriangleCenterVector * fullDistanceWithRandomness);
// calculate the max distance (s) the triangle will move // if the triangle is inside the blast radius...
float accelaration = (randomVelocity.y - randomVelocity.x) / ExplosionDuration; if (fullDistanceWithRandomness <= (TimeSinceDeath * currentVelocity))
float maxDistance = (randomVelocity.x * ExplosionDuration) + (0.5 * accelaration * ExplosionDuration * ExplosionDuration);
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{ {
Output.ExplosionPercentageElapsed = (length(triangleCenter2ExplosionRadius) / maxDistance) * isInsideBlastRadius * ColorDistanceScalar; float maxRadius = max(TimeSinceDeath * currentVelocity, (ExplosionDuration * currentVelocity));
float a = (randomVelocity.y - randomVelocity.x) / ExplosionDuration;
//float t = sqrt((2 * origin2TriangleCenterDistance) / a);
// if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{
// calculate the max distance (s) the triangle will move
float s = (randomVelocity.x * ExplosionDuration) + (0.5 * a * pow(ExplosionDuration, 2));
float te = (length(triangleCenter2ExplosionRadius) / s);
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = te;
}
else
{
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = timePercetage;
}
// for every vertex on the triangle...
for (int i = 0; i < gl_in.length(); i++)
{
// move the triangle to the blast radius
vec3 ExplodedPosition = Input[i].Position + triangleCenter2ExplosionRadius;
// pass through vertex data
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
Output.Tangent = Input[i].Tangent;
Output.BiTangent = Input[i].BiTangent;
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
// convert to model space for the gravity to always be in -y
vec4 ExplodedPositionInModelSpace = M * vec4(ExplodedPosition, 1.0);
// if there is gravity, apply it
//if (Gravity == true)
//{
// // ---DO THIS----> //ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - TimeSinceHit;
//
// ExplodedPositionInModelSpace.y = ExplodedPositionInModelSpace.y - pow(TimeSinceDeath, 2);
//}
// convert to screen space
gl_Position = P*V * ExplodedPositionInModelSpace;
EmitVertex();
}
} }
else else
{ {
Output.ExplosionPercentageElapsed = timePercetage; // if explosion color should be affected by distance instead of time...
if (ColorByDistance == true)
{
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = 0.0;
}
else
{
Output.ExplosionColor = EndColor;
Output.ExplosionPercentageElapsed = timePercetage;
}
// for every vertex on the triangle...
for(int i = 0; i < gl_in.length(); i++)
{
// pass through vertex data
Output.Normal = Input[i].Normal;
Output.Position = Input[i].Position;
Output.TextureCoordinate = Input[i].TextureCoordinate;
Output.Tangent = Input[i].Tangent;
Output.BiTangent = Input[i].BiTangent;
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
// no change in position, pass through vertex
gl_Position = gl_in[i].gl_Position;
EmitVertex();
}
} }
vec3 ExplodedPosition; //EndPrimitive();
for (int i = 0; i < gl_in.length(); i++) }
{
// move the triangle to the blast radius
ExplodedPosition = Input[i].Position + (triangleCenter2ExplosionRadius * isInsideBlastRadius);
// pass through vertex data
PassThingsThrough(i);
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
for (int j = 0; j < MAX_SPLITS; j++)
{
Output.PositionLightSpace[j] = Input[i].PositionLightSpace[j];
}
// convert to window space
gl_Position = P * V * M * vec4(ExplodedPosition, 1.0);
EmitVertex();
}
}
+4 -1
View File
@@ -2,6 +2,7 @@
#extension GL_EXT_gpu_shader4 : enable #extension GL_EXT_gpu_shader4 : enable
layout (binding = 0) uniform sampler2D Texture; layout (binding = 0) uniform sampler2D Texture;
uniform int Lod;
in VertexData{ in VertexData{
vec2 TextureCoordinate; vec2 TextureCoordinate;
@@ -10,12 +11,14 @@ in VertexData{
out vec4 fragmentColor; out vec4 fragmentColor;
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216); uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
//uniform float weight[3] = float[](0.265495, 0.226535, 0.140718);
void main() void main()
{ {
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0); vec2 tex_offset = 1.0 / textureSize(Texture, Lod);
vec3 center = texture(Texture, Input.TextureCoordinate).rgb; vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
vec3 result = center * weight[0]; vec3 result = center * weight[0];
for(int i = 1; i < 5; ++i) { for(int i = 1; i < 5; ++i) {
vec4 eastFragments = texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0)); vec4 eastFragments = texture(Texture, Input.TextureCoordinate + vec2(tex_offset.x * i, 0.0));
vec4 westFragments = texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0)); vec4 westFragments = texture(Texture, Input.TextureCoordinate - vec2(tex_offset.x * i, 0.0));
+4 -1
View File
@@ -2,6 +2,7 @@
#extension GL_EXT_gpu_shader4 : enable #extension GL_EXT_gpu_shader4 : enable
layout (binding = 0) uniform sampler2D Texture; layout (binding = 0) uniform sampler2D Texture;
uniform int Lod;
in VertexData{ in VertexData{
vec2 TextureCoordinate; vec2 TextureCoordinate;
@@ -10,12 +11,14 @@ in VertexData{
out vec4 fragmentColor; out vec4 fragmentColor;
uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216); uniform float weight[5] = float[](0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216);
//uniform float weight[3] = float[](0.265495, 0.226535, 0.140718);
void main() void main()
{ {
vec2 tex_offset = 1.0 / textureSize2D(Texture, 0); vec2 tex_offset = 1.0 / textureSize(Texture, Lod);
vec3 center = texture(Texture, Input.TextureCoordinate).rgb; vec3 center = texture(Texture, Input.TextureCoordinate).rgb;
vec3 result = center * weight[0]; vec3 result = center * weight[0];
for(int i = 1; i < 5; ++i) { for(int i = 1; i < 5; ++i) {
vec4 northFragments = texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i)); vec4 northFragments = texture(Texture, Input.TextureCoordinate + vec2(0.0, tex_offset.y * i));
vec4 southFragments = texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i)); vec4 southFragments = texture(Texture, Input.TextureCoordinate - vec2(0.0, tex_offset.y * i));
+8 -5
View File
@@ -3,6 +3,8 @@
uniform vec4 Color; uniform vec4 Color;
uniform vec4 FillColor; uniform vec4 FillColor;
uniform float FillPercentage; uniform float FillPercentage;
uniform float ScaleX;
uniform float ScaleY;
uniform mat4 P; uniform mat4 P;
layout (binding = 1) uniform sampler2D DiffuseTexture; layout (binding = 1) uniform sampler2D DiffuseTexture;
@@ -21,15 +23,16 @@ out vec4 bloomColor;
void main() void main()
{ {
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate); vec4 diffuseTexel = texture2D(DiffuseTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate); vec4 glowTexel = texture2D(GlowMapTexture, vec2(Input.TextureCoordinate.x*ScaleX, Input.TextureCoordinate.y*ScaleY));
vec4 color_result = Color * diffuseTexel; vec4 color_result = Color * diffuseTexel;
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0; float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
if(pos <= FillPercentage) { float fillResult = floor(pos*FillPercentage);
color_result = FillColor*diffuseTexel.a;
} color_result = FillColor*diffuseTexel.a*fillResult + color_result*(1-fillResult);
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1)); sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
//bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0); //bloomColor = vec4(clamp((glowTexel.xyz*3) - 1.0, 0, 100), 1.0);
+1 -1
View File
@@ -86,7 +86,7 @@ bool EditorRenderSystem::OnSetCamera(Events::SetCamera& e)
{ {
ComponentWrapper cTransform = e.CameraEntity["Transform"]; ComponentWrapper cTransform = e.CameraEntity["Transform"];
ComponentWrapper cCamera = e.CameraEntity["Camera"]; ComponentWrapper cCamera = e.CameraEntity["Camera"];
m_EditorCamera->SetFOV(static_cast<float>((double)cCamera["FOV"])); m_EditorCamera->SetFOV(glm::radians(static_cast<float>((double)cCamera["FOV"])));
m_EditorCamera->SetNearClip(static_cast<float>((double)cCamera["NearClip"])); m_EditorCamera->SetNearClip(static_cast<float>((double)cCamera["NearClip"]));
m_EditorCamera->SetFarClip(static_cast<float>((double)cCamera["FarClip"])); m_EditorCamera->SetFarClip(static_cast<float>((double)cCamera["FarClip"]));
m_EditorCamera->SetPosition(cTransform["Position"]); m_EditorCamera->SetPosition(cTransform["Position"]);
+7 -3
View File
@@ -97,14 +97,14 @@ void BlurHUD::ClearBuffer()
glClearStencil(0x00); glClearStencil(0x00);
glStencilMask(~0); glStencilMask(~0);
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_GaussianFrameBuffer_horiz.Unbind(); m_GaussianFrameBuffer_horiz.Unbind();
m_GaussianFrameBuffer_vert.Bind(); m_GaussianFrameBuffer_vert.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClearStencil(0x00); glClearStencil(0x00);
glStencilMask(~0); glStencilMask(~0);
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
m_GaussianFrameBuffer_vert.Unbind(); m_GaussianFrameBuffer_vert.Unbind();
m_CombinedTextureBuffer.Bind(); m_CombinedTextureBuffer.Bind();
@@ -211,12 +211,16 @@ void BlurHUD::FillStencil(RenderScene& scene)
RenderState state; RenderState state;
state.BindFramebuffer(m_GaussianFrameBuffer_horiz.GetHandle()); state.BindFramebuffer(m_GaussianFrameBuffer_horiz.GetHandle());
state.Disable(GL_DEPTH_TEST); state.Enable(GL_DEPTH_TEST);
state.Enable(GL_CULL_FACE); state.Enable(GL_CULL_FACE);
state.Enable(GL_STENCIL_TEST); state.Enable(GL_STENCIL_TEST);
state.StencilFunc(GL_ALWAYS, 1, 0xFF); state.StencilFunc(GL_ALWAYS, 1, 0xFF);
state.StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); state.StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
state.StencilMask(0xFF); state.StencilMask(0xFF);
state.AlphaFunc(GL_GEQUAL, 0.95f);
state.Enable(GL_ALPHA_TEST);
glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_BlurQuality, m_Renderer->GetViewportSize().Height/m_BlurQuality); glViewport(0, 0, m_Renderer->GetViewportSize().Width/m_BlurQuality, m_Renderer->GetViewportSize().Height/m_BlurQuality);
m_FillDepthStencilProgram->Bind(); m_FillDepthStencilProgram->Bind();
+116 -45
View File
@@ -12,6 +12,7 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
DrawBloomPass::~DrawBloomPass() { DrawBloomPass::~DrawBloomPass() {
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz); CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert); CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
CommonFunctions::DeleteTexture(&m_FinalGaussianTexture);
} }
void DrawBloomPass::InitializeTextures() void DrawBloomPass::InitializeTextures()
@@ -30,9 +31,8 @@ void DrawBloomPass::ChangeQuality(int quality)
if (m_Quality == 0) { if (m_Quality == 0) {
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz); CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert); CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
m_GaussianTexture_horiz = 0; CommonFunctions::DeleteTexture(&m_FinalGaussianTexture);
m_GaussianTexture_vert = 0;
return; return;
} }
InitializeTextures(); InitializeTextures();
@@ -62,22 +62,50 @@ void DrawBloomPass::InitializeShaderPrograms()
m_GaussianProgram_vert->BindFragDataLocation(0, "fragmentColor"); m_GaussianProgram_vert->BindFragDataLocation(0, "fragmentColor");
m_GaussianProgram_vert->Link(); m_GaussianProgram_vert->Link();
} }
m_GaussianCombineProgram = ResourceManager::Load<ShaderProgram>("#GaussianCombineProgram");
if (m_GaussianCombineProgram->GetHandle() == 0) {
m_GaussianCombineProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/CombineGaussianTexture.vert.glsl")));
m_GaussianCombineProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/CombineGaussianTexture.frag.glsl")));
m_GaussianCombineProgram->Compile();
m_GaussianCombineProgram->BindFragDataLocation(0, "fragmentColor");
m_GaussianCombineProgram->Link();
}
} }
void DrawBloomPass::InitializeBuffers() void DrawBloomPass::InitializeBuffers()
{ {
CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
CommonFunctions::GenerateTexture(&m_FinalGaussianTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
if (m_GaussianFrameBuffer_horiz.GetHandle() == 0) { if (m_GaussianCombineBuffer.GetHandle() == 0) {
m_GaussianFrameBuffer_horiz.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0))); m_GaussianCombineBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_FinalGaussianTexture, GL_COLOR_ATTACHMENT0)));
} }
m_GaussianFrameBuffer_horiz.Generate(); m_GaussianCombineBuffer.Generate();
CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); if(m_GaussianFrameBuffer_horiz == nullptr) {
if (m_GaussianFrameBuffer_vert.GetHandle() == 0) { m_GaussianFrameBuffer_horiz = new FrameBuffer[m_BloomLod];
m_GaussianFrameBuffer_vert.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0))); }
} if (m_GaussianFrameBuffer_vert == nullptr) {
m_GaussianFrameBuffer_vert.Generate(); m_GaussianFrameBuffer_vert = new FrameBuffer[m_BloomLod];
}
for (int i = 0; i < m_BloomLod; i++) {
if(m_GaussianFrameBuffer_horiz[i].GetHandle() == 0) {
m_GaussianFrameBuffer_horiz[i].AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_horiz, GL_COLOR_ATTACHMENT0, i)));
}
m_GaussianFrameBuffer_horiz[i].Generate();
if (m_GaussianFrameBuffer_vert[i].GetHandle() == 0) {
m_GaussianFrameBuffer_vert[i].AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_GaussianTexture_vert, GL_COLOR_ATTACHMENT0, i)));
}
m_GaussianFrameBuffer_vert[i].Generate();
}
} }
@@ -87,33 +115,75 @@ void DrawBloomPass::ClearBuffer()
return; return;
} }
GLERROR("PRE"); GLERROR("PRE");
m_GaussianFrameBuffer_horiz.Bind(); for (int i = 0; i < m_BloomLod; i++) {
m_GaussianFrameBuffer_horiz[i].Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_horiz[i].Unbind();
m_GaussianFrameBuffer_vert[i].Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_vert[i].Unbind();
}
m_GaussianCombineBuffer.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f); glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT); glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_horiz.Unbind(); m_GaussianCombineBuffer.Unbind();
m_GaussianFrameBuffer_vert.Bind();
glClearColor(0.f, 0.f, 0.f, 0.f);
glClear(GL_COLOR_BUFFER_BIT);
m_GaussianFrameBuffer_vert.Unbind();
GLERROR("END"); GLERROR("END");
} }
void DrawBloomPass::Draw(GLuint texture) void DrawBloomPass::Draw(GLuint texture)
{
if (m_Quality == 0) {
return;
}
for (int i = 0; i < m_BloomLod; i++) {
GaussianLodPass(i, texture);
}
CombineGaussianBlur();
}
void DrawBloomPass::OnWindowResize()
{ {
if (m_Quality == 0) { if (m_Quality == 0) {
return; return;
} }
GLERROR("DrawBloomPass::Draw: Pre"); CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_vert, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
CommonFunctions::GenerateMipMapTexture(
&m_GaussianTexture_horiz, GL_CLAMP_TO_BORDER, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height)
, GL_RGB, GL_FLOAT, m_BloomLod);
for (int i = 0; i < m_BloomLod; i++) {
m_GaussianFrameBuffer_vert[i].Generate();
m_GaussianFrameBuffer_horiz[i].Generate();
}
}
void DrawBloomPass::GaussianLodPass(GLuint mipMap, GLuint texture)
{
GLERROR("DrawBloomPass::Draw: Pre");
glViewport(0, 0, m_Renderer->GetViewportSize().Width/(glm::pow(2, mipMap)), m_Renderer->GetViewportSize().Height/(glm::pow(2, mipMap)));
DrawBloomPassState state; DrawBloomPassState state;
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle(); GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle(); GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
m_GaussianProgram_vert->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_vert, "Lod"), mipMap);
m_GaussianProgram_horiz->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_horiz, "Lod"), mipMap);
//Horizontal pass, first use the given texture then save it to the horizontal framebuffer. //Horizontal pass, first use the given texture then save it to the horizontal framebuffer.
m_GaussianFrameBuffer_horiz.Bind(); m_GaussianFrameBuffer_horiz[mipMap].Bind();
m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
glBindVertexArray(m_ScreenQuad->VAO); glBindVertexArray(m_ScreenQuad->VAO);
@@ -123,55 +193,56 @@ void DrawBloomPass::Draw(GLuint texture)
//Iterate some times to make it more gaussian. //Iterate some times to make it more gaussian.
for (int i = 1; i < m_Iterations; i++) { for (int i = 1; i < m_Iterations; i++) {
//Vertical pass //Vertical pass
m_GaussianFrameBuffer_vert.Bind(); m_GaussianFrameBuffer_vert[mipMap].Bind();
m_GaussianProgram_vert->Bind(); m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 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); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
//horizontal pass //horizontal pass
m_GaussianFrameBuffer_vert.Unbind(); m_GaussianFrameBuffer_vert[mipMap].Unbind();
m_GaussianFrameBuffer_horiz.Bind(); m_GaussianFrameBuffer_horiz[mipMap].Bind();
m_GaussianProgram_horiz->Bind(); m_GaussianProgram_horiz->Bind();
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 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); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
m_GaussianFrameBuffer_horiz.Unbind(); m_GaussianFrameBuffer_horiz[mipMap].Unbind();
} }
//final vertical gaussian after the iterations are done //final vertical gaussian after the iterations are done
m_GaussianFrameBuffer_vert.Bind(); m_GaussianFrameBuffer_vert[mipMap].Bind();
m_GaussianProgram_vert->Bind(); m_GaussianProgram_vert->Bind();
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_horiz);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex +1 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); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
GLERROR("DrawBloomPass::Draw: END"); GLERROR("DrawBloomPass::Draw: END");
glViewport(0, 0, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
m_GaussianFrameBuffer_vert[mipMap].Unbind();
} }
void DrawBloomPass::CombineGaussianBlur()
void DrawBloomPass::OnWindowResize()
{ {
if (m_Quality == 0) { m_GaussianCombineBuffer.Bind();
return; m_GaussianCombineProgram->Bind();
} glUniform1i(glGetUniformLocation(m_GaussianCombineProgram->GetHandle(), "MaxMipMap"), m_BloomLod);
CommonFunctions::GenerateTexture(&m_GaussianTexture_vert, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_GaussianFrameBuffer_vert.Generate(); glActiveTexture(GL_TEXTURE0);
CommonFunctions::GenerateTexture(&m_GaussianTexture_horiz, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); glBindTexture(GL_TEXTURE_2D, m_GaussianTexture_vert);
m_GaussianFrameBuffer_horiz.Generate(); 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);
} }
+21 -16
View File
@@ -32,9 +32,9 @@ void DrawFinalPass::InitializeTextures()
void DrawFinalPass::InitializeFrameBuffers() void DrawFinalPass::InitializeFrameBuffers()
{ {
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); //GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4); //GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->GetViewPortSize().Width, m_Renderer->GetViewPortSize().Height), GL_RGB16F, GL_FLOAT, 4);
//GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT); //GenerateTexture(&m_StencilTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_STENCIL, GL_STENCIL_INDEX8, GL_INT);
@@ -311,6 +311,8 @@ void DrawFinalPass::Draw(RenderScene& scene, BlurHUD* blurHUDPass)
GLERROR("TransparentObjects"); GLERROR("TransparentObjects");
//state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //state->BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
stateSprite->Enable(GL_DEPTH_TEST); stateSprite->Enable(GL_DEPTH_TEST);
//stateSprite->AlphaFunc(GL_GEQUAL, 0.05f);
//stateSprite->Enable(GL_ALPHA_TEST);
DrawSprites(scene.Jobs.SpriteJob, scene); DrawSprites(scene.Jobs.SpriteJob, scene);
GLERROR("SpriteJobs"); GLERROR("SpriteJobs");
@@ -343,8 +345,8 @@ void DrawFinalPass::OnWindowResize()
//InitializeFrameBuffers(); //InitializeFrameBuffers();
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8); glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH24_STENCIL8, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8);
CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_SceneTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT); CommonFunctions::GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_BORDER, GL_LINEAR, glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
m_FinalPassFrameBuffer.Generate(); m_FinalPassFrameBuffer.Generate();
GLERROR("Error changing texture resolutions"); GLERROR("Error changing texture resolutions");
@@ -1269,23 +1271,34 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix())); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position())); glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
RenderState* jobState = new RenderState();
for(auto& job : jobs) { for(auto& job : jobs) {
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job); auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
RenderState jobState;
if (spriteJob) { if (spriteJob) {
if(spriteJob->Depth == 0) { if(spriteJob->Depth == 0) {
jobState.Disable(GL_DEPTH_TEST); jobState->Disable(GL_DEPTH_TEST);
} }
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix)); glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(spriteJob->Color));
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor)); glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(spriteJob->FillColor));
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage); glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), spriteJob->FillPercentage);
glUniform1f(glGetUniformLocation(shaderHandle, "ScaleX"), spriteJob->ScaleX);
glUniform1f(glGetUniformLocation(shaderHandle, "ScaleY"), spriteJob->ScaleY);
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
if (spriteJob->DiffuseTexture != nullptr) { if (spriteJob->DiffuseTexture != nullptr) {
glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture); glBindTexture(GL_TEXTURE_2D, spriteJob->DiffuseTexture->m_Texture);
if (spriteJob->Linear) {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
} else {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
}
} else { } else {
glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture); glBindTexture(GL_TEXTURE_2D, m_ErrorTexture->m_Texture);
} }
@@ -1303,6 +1316,7 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int))); glDrawElements(GL_TRIANGLES, spriteJob->EndIndex - spriteJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(spriteJob->StartIndex*sizeof(unsigned int)));
} }
} }
delete jobState;
// m_SpriteProgram->Unbind(); // m_SpriteProgram->Unbind();
} }
@@ -1319,12 +1333,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin)); glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
GLERROR("Bind 6 uniform"); GLERROR("Bind 6 uniform");
if (job->Reverse == false) { glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
}
else {
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), (job->ExplosionDuration - job->TimeSinceDeath));
}
GLERROR("Bind 7 uniform"); GLERROR("Bind 7 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration); glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
GLERROR("Bind 8 uniform"); GLERROR("Bind 8 uniform");
@@ -1342,10 +1351,6 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
GLERROR("Bind 14 uniform"); GLERROR("Bind 14 uniform");
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration); glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
GLERROR("Bind 15 uniform"); GLERROR("Bind 15 uniform");
glUniform1i(glGetUniformLocation(shaderHandle, "Reverse"), job->Reverse);
GLERROR("Bind 15-2 uniform");
glUniform1f(glGetUniformLocation(shaderHandle, "ColorDistanceScalar"), job->ColorDistanceScalar);
GLERROR("Bind 15-3 uniform");
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color)); glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
GLERROR("Bind 16 uniform"); GLERROR("Bind 16 uniform");
@@ -10,6 +10,8 @@ DrawFinalPassState::DrawFinalPassState(GLuint frameBuffer)
Enable(GL_DEPTH_TEST); Enable(GL_DEPTH_TEST);
DepthMask(GL_TRUE); DepthMask(GL_TRUE);
Enable(GL_CULL_FACE); Enable(GL_CULL_FACE);
Enable(GL_ALPHA_TEST);
AlphaFunc(GL_GEQUAL, 0.05f);
// Enable(GL_STENCIL_TEST); // Enable(GL_STENCIL_TEST);
// StencilFunc(GL_NOTEQUAL, 1, 0xFF); // StencilFunc(GL_NOTEQUAL, 1, 0xFF);
// StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE); // StencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
+3 -2
View File
@@ -2,11 +2,12 @@
#include "Rendering/FrameBuffer.h" #include "Rendering/FrameBuffer.h"
BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment) BufferResource::BufferResource(GLuint* resourceHandle, GLenum resourceType, GLenum attachment, GLuint mipMapLod)
{ {
m_ResourceHandle = resourceHandle; m_ResourceHandle = resourceHandle;
m_ResourceType = resourceType; m_ResourceType = resourceType;
m_Attachment = attachment; m_Attachment = attachment;
m_MipMapLod = mipMapLod;
} }
Texture2D::~Texture2D() Texture2D::~Texture2D()
@@ -58,7 +59,7 @@ void FrameBuffer::Generate()
for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) { for (auto it = m_Resources.begin(); it != m_Resources.end(); it++) {
switch ((*it)->m_ResourceType) { switch ((*it)->m_ResourceType) {
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
glFramebufferTexture2D(GL_FRAMEBUFFER, (*it)->m_Attachment, (*it)->m_ResourceType, *(*it)->m_ResourceHandle, 0); glFramebufferTexture(GL_FRAMEBUFFER, (*it)->m_Attachment, *(*it)->m_ResourceHandle, (*it)->m_MipMapLod);
GLERROR("FrameBuffer generate: glFramebufferTexture2D"); GLERROR("FrameBuffer generate: glFramebufferTexture2D");
break; break;
case GL_RENDERBUFFER: case GL_RENDERBUFFER:
@@ -42,6 +42,15 @@ void LightCullingPass::SetSSBOSizes()
{ {
m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE); m_NumberOfTiles = (int)(m_Renderer->GetViewportSize().Width/TILE_SIZE) * (int)(m_Renderer->GetViewportSize().Height/TILE_SIZE);
if (m_Frustums != nullptr) {
delete[] m_Frustums;
}
if (m_LightGrid != nullptr) {
delete[] m_LightGrid;
}
if (m_LightIndex != nullptr) {
delete[] m_LightIndex;
}
m_Frustums = new Frustum[m_NumberOfTiles]; m_Frustums = new Frustum[m_NumberOfTiles];
m_LightGrid = new LightGrid[m_NumberOfTiles]; m_LightGrid = new LightGrid[m_NumberOfTiles];
m_LightIndex = new float[m_NumberOfTiles*MAX_LIGHTS_PER_TILE]; m_LightIndex = new float[m_NumberOfTiles*MAX_LIGHTS_PER_TILE];
+1 -1
View File
@@ -24,7 +24,7 @@ void PickingPass::InitializeTextures()
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE); glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_RG8, GL_RG, GL_UNSIGNED_BYTE);
CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST, CommonFunctions::GenerateTexture(&m_DepthBuffer, GL_CLAMP_TO_BORDER, GL_NEAREST,
glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT); glm::vec2(m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height), GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT);
} }
void PickingPass::InitializeFrameBuffers() void PickingPass::InitializeFrameBuffers()
+15
View File
@@ -148,14 +148,29 @@ void RawModelCustom::ReadMaterialSingle(std::size_t& offset, char* fileData, con
case MaterialType::Basic: case MaterialType::Basic:
newMaterialProperty.material = new MaterialBasic(); newMaterialProperty.material = new MaterialBasic();
ReadMaterialBasic(newMaterialProperty.material, offset, fileData, fileByteSize); ReadMaterialBasic(newMaterialProperty.material, offset, fileData, fileByteSize);
if(hasSkin){
newMaterialProperty.ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSkinnedProgram")->ResourceID;
} else {
newMaterialProperty.ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
}
break; break;
case MaterialType::SplatMapping: case MaterialType::SplatMapping:
newMaterialProperty.material = new MaterialSplatMapping(); newMaterialProperty.material = new MaterialSplatMapping();
ReadMaterialSplatMapping(static_cast<MaterialSplatMapping*>(newMaterialProperty.material), offset, fileData, fileByteSize); ReadMaterialSplatMapping(static_cast<MaterialSplatMapping*>(newMaterialProperty.material), offset, fileData, fileByteSize);
if (hasSkin){
newMaterialProperty.ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapSkinnedProgram")->ResourceID;
} else {
newMaterialProperty.ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSplatMapProgram")->ResourceID;
}
break; break;
case MaterialType::SingleTextures: case MaterialType::SingleTextures:
newMaterialProperty.material = new MaterialSingleTextures(); newMaterialProperty.material = new MaterialSingleTextures();
ReadMaterialSingleTexture(static_cast<MaterialSingleTextures*>(newMaterialProperty.material), offset, fileData, fileByteSize); ReadMaterialSingleTexture(static_cast<MaterialSingleTextures*>(newMaterialProperty.material), offset, fileData, fileByteSize);
if (hasSkin){
newMaterialProperty.ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusSkinnedProgram")->ResourceID;
} else {
newMaterialProperty.ShaderID = ResourceManager::Load<ShaderProgram>("#ForwardPlusProgram")->ResourceID;
}
break; break;
default: default:
throw Resource::FailedLoadingException("Material contains an unknown MaterialType"); throw Resource::FailedLoadingException("Material contains an unknown MaterialType");
+10 -2
View File
@@ -9,10 +9,11 @@ RenderSystem::RenderSystem(SystemParams params, const IRenderer* renderer, Rende
, m_Octree(frustumCullOctree) , m_Octree(frustumCullOctree)
{ {
EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera); EVENT_SUBSCRIBE_MEMBER(m_ESetCamera, &RenderSystem::OnSetCamera);
EVENT_SUBSCRIBE_MEMBER(m_EResolutionChanged, &RenderSystem::OnResolutionChanged);
EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand); EVENT_SUBSCRIBE_MEMBER(m_EInputCommand, &RenderSystem::OnInputCommand);
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned); EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &RenderSystem::OnPlayerSpawned);
m_Camera = new Camera((float)m_Renderer->Resolution().Width / m_Renderer->Resolution().Height, glm::radians(45.f), 0.01f, 5000.f); m_Camera = new Camera((float)m_Renderer->GetViewportSize().Width / m_Renderer->GetViewportSize().Height, glm::radians(45.f), 0.01f, 5000.f);
} }
RenderSystem::~RenderSystem() RenderSystem::~RenderSystem()
@@ -20,11 +21,18 @@ RenderSystem::~RenderSystem()
delete m_Camera; delete m_Camera;
} }
bool RenderSystem::OnResolutionChanged(Events::ResolutionChanged& e)
{
// Update camera aspect ration on resolution change
m_Camera->SetAspectRatio((float)e.NewResolution.Width / e.NewResolution.Height);
return true;
}
bool RenderSystem::OnSetCamera(Events::SetCamera& e) bool RenderSystem::OnSetCamera(Events::SetCamera& e)
{ {
ComponentWrapper cTransform = e.CameraEntity["Transform"]; ComponentWrapper cTransform = e.CameraEntity["Transform"];
ComponentWrapper cCamera = e.CameraEntity["Camera"]; ComponentWrapper cCamera = e.CameraEntity["Camera"];
m_Camera->SetFOV((double)cCamera["FOV"]); m_Camera->SetFOV(glm::radians((double)cCamera["FOV"]));
m_Camera->SetNearClip((double)cCamera["NearClip"]); m_Camera->SetNearClip((double)cCamera["NearClip"]);
m_Camera->SetFarClip((double)cCamera["FarClip"]); m_Camera->SetFarClip((double)cCamera["FarClip"]);
m_Camera->SetPosition(cTransform["Position"]); m_Camera->SetPosition(cTransform["Position"]);
+43 -8
View File
@@ -36,16 +36,24 @@ void Renderer::Initialize()
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker); m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
} }
void Renderer::glfwWindowSizeCallback(GLFWwindow* window, int width, int height)
{
m_WindowToRenderer[window]->setWindowSize(Rectangle(width, height));
}
void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height) void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height)
{ {
glViewport(0, 0, width, height); m_WindowToRenderer[window]->updateFramebufferSize();
Renderer* currentRenderer = m_WindowToRenderer[window]; }
currentRenderer->m_ViewportSize = Rectangle(width, height);
currentRenderer->m_PickingPass->OnWindowResize(); void Renderer::SetResolution(const Rectangle& resolution)
currentRenderer->m_DrawFinalPass->OnWindowResize(); {
currentRenderer->m_LightCullingPass->OnWindowResize(); m_Resolution = resolution;
currentRenderer->m_DrawBloomPass->OnWindowResize();
currentRenderer->m_SSAOPass->OnWindowResize(); if (m_Window != nullptr) {
setWindowSize(resolution);
updateFramebufferSize();
}
} }
void Renderer::InitializeWindow() void Renderer::InitializeWindow()
@@ -67,6 +75,7 @@ void Renderer::InitializeWindow()
LOG_ERROR("GLFW: Failed to create window"); LOG_ERROR("GLFW: Failed to create window");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
glfwSetWindowSizeCallback(m_Window, &glfwWindowSizeCallback);
glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback); glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback);
glfwMakeContextCurrent(m_Window); glfwMakeContextCurrent(m_Window);
@@ -111,6 +120,31 @@ void Renderer::InputUpdate(double dt)
} }
void Renderer::setWindowSize(Rectangle size)
{
m_Resolution = size;
glfwSetWindowSize(m_Window, size.Width, size.Height);
}
void Renderer::updateFramebufferSize()
{
Events::ResolutionChanged e;
e.OldResolution = m_ViewportSize;
int width, height;
glfwGetFramebufferSize(m_Window, &width, &height);
glViewport(0, 0, width, height);
m_ViewportSize = Rectangle(width, height);
m_PickingPass->OnWindowResize();
m_DrawFinalPass->OnWindowResize();
m_LightCullingPass->OnWindowResize();
m_DrawBloomPass->OnWindowResize();
m_SSAOPass->OnWindowResize();
e.NewResolution = m_ViewportSize;
m_EventBroker->Publish(e);
}
void Renderer::Update(double dt) void Renderer::Update(double dt)
{ {
m_EventBroker->Process<Renderer>(); m_EventBroker->Process<Renderer>();
@@ -263,6 +297,7 @@ void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filterin
GLERROR("Texture initialization failed"); GLERROR("Texture initialization failed");
} }
void Renderer::InitializeRenderPasses() void Renderer::InitializeRenderPasses()
{ {
m_PickingPass = new PickingPass(this, m_EventBroker); m_PickingPass = new PickingPass(this, m_EventBroker);
+6 -6
View File
@@ -233,6 +233,11 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle(); GLuint shaderHandle_horiz = m_GaussianProgram_horiz->GetHandle();
GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle(); GLuint shaderHandle_vert = m_GaussianProgram_vert->GetHandle();
m_GaussianProgram_vert->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_vert, "Lod"), 0);
m_GaussianProgram_horiz->Bind();
glUniform1i(glGetUniformLocation(shaderHandle_horiz, "Lod"), 0);
m_GaussianFrameBuffer_horiz.Bind(); m_GaussianFrameBuffer_horiz.Bind();
m_GaussianProgram_horiz->Bind(); m_GaussianProgram_horiz->Bind();
@@ -252,8 +257,6 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz); glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 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); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
//horizontal pass //horizontal pass
@@ -265,8 +268,6 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_vert); glBindTexture(GL_TEXTURE_2D, m_Gaussian_vert);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 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); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
m_GaussianFrameBuffer_horiz.Unbind(); m_GaussianFrameBuffer_horiz.Unbind();
@@ -279,8 +280,7 @@ void SSAOPass::Draw(GLuint depthBuffer, Camera* camera)
glActiveTexture(GL_TEXTURE0); glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz); glBindTexture(GL_TEXTURE_2D, m_Gaussian_horiz);
glBindVertexArray(m_ScreenQuad->VAO);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_ScreenQuad->ElementBuffer);
glDrawElementsBaseVertex(GL_TRIANGLES, m_ScreenQuad->MaterialGroups()[0].material->EndIndex - m_ScreenQuad->MaterialGroups()[0].material->StartIndex + 1 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); , GL_UNSIGNED_INT, 0, m_ScreenQuad->MaterialGroups()[0].material->StartIndex);
+3 -3
View File
@@ -3,9 +3,9 @@
TextureSprite::TextureSprite(std::string path) TextureSprite::TextureSprite(std::string path)
:Texture(path) :Texture(path)
{ {
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST); glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
GLERROR("Texture load"); GLERROR("Texture load");
} }
@@ -25,10 +25,12 @@ void CommonFunctions::GenerateMultiSampleTexture(GLuint* texture, int numSamples
void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) void CommonFunctions::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps)
{ {
glDeleteTextures(1, texture);
glGenTextures(1, texture); glGenTextures(1, texture);
glBindTexture(GL_TEXTURE_2D, *texture); glBindTexture(GL_TEXTURE_2D, *texture);
glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y); glTexStorage2D(GL_TEXTURE_2D, numMipMaps, GL_RGBA8, dimensions.x, dimensions.y);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, texture); //glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, dimensions.x, dimensions.y, format, type, NULL);
GLERROR("MipMap Texture glTexSubImage2D failed");
glGenerateMipmap(GL_TEXTURE_2D); glGenerateMipmap(GL_TEXTURE_2D);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapping);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapping);
@@ -36,10 +36,6 @@ ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer*
unsigned char pdata[3]; unsigned char pdata[3];
glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata); glReadPixels(x, y, 1, 1, GL_RGB, GL_UNSIGNED_BYTE, &pdata);
GLERROR("glReadPixels(pdata) Error"); GLERROR("glReadPixels(pdata) Error");
PickDataBuffer->Unbind();
GLERROR("Unbind Error");
glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer);
GLERROR("glBindFramebuffer(DepthBuffer) Error");
float depthData; float depthData;
glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData); glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &depthData);
GLERROR("glReadPixels(depthData) Error"); GLERROR("glReadPixels(depthData) Error");
+12 -4
View File
@@ -108,10 +108,10 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
//change what model is displaying (change all in case 2 capturepoints has been captured on the same frame) //change what model is displaying (change all in case 2 capturepoints has been captured on the same frame)
for (int i = 0; i < m_NumberOfCapturePoints; i++) { for (int i = 0; i < m_NumberOfCapturePoints; i++) {
auto owner = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"]; auto owner = (int)m_CapturePointNumberToEntityMap[i]["Team"]["Team"];
if (m_CapturePointNumberToEntityMap[i].FirstChildByName("Red").ID != EntityID_Invalid) { if (m_CapturePointNumberToEntityMap[i].FirstChildByName("Red").Valid()) {
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Red")["Model"]["Visible"] = owner == redTeam ? true : false; ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Red"), owner == redTeam);
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Blue")["Model"]["Visible"] = owner == blueTeam ? true : false; ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Blue"), owner == blueTeam);
(bool&)m_CapturePointNumberToEntityMap[i].FirstChildByName("Spectator")["Model"]["Visible"] = owner == spectatorTeam ? true : false; ChangeCapturePointModelsVisibility(m_CapturePointNumberToEntityMap[i].FirstChildByName("Spectator"), owner == spectatorTeam);
} }
} }
//save the next cap points and publish the captured event //save the next cap points and publish the captured event
@@ -232,6 +232,14 @@ void CapturePointSystem::UpdateComponent(EntityWrapper& capturePointEntity, Comp
} }
void CapturePointSystem::ChangeCapturePointModelsVisibility(EntityWrapper &capturePointModels, bool isOwner) {
(bool&)capturePointModels["Model"]["Visible"] = isOwner;
for (auto& capModel : capturePointModels.ChildrenWithComponent("Model"))
{
(bool&)capModel["Model"]["Visible"] = isOwner;
}
}
bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e) bool CapturePointSystem::OnTriggerTouch(const Events::TriggerTouch& e)
{ {
//personEntered = e.Entity, thingEntered = e.Trigger //personEntered = e.Entity, thingEntered = e.Trigger
+7 -10
View File
@@ -7,15 +7,12 @@ void ExplosionEffectSystem::UpdateComponent(EntityWrapper& entity, ComponentWrap
delay = std::max(0.0, delay - dt); delay = std::max(0.0, delay - dt);
} }
if (delay <= 0) { if (delay <= 0) {
double& timeSinceDeath = component["TimeSinceDeath"]; double& timeSinceDeath = component["TimeSinceDeath"];
timeSinceDeath += (double)component["Speed"] * dt; timeSinceDeath += (double)component["Speed"] * dt;
if (timeSinceDeath < 0) { if (timeSinceDeath < 0 || timeSinceDeath > (double)component["ExplosionDuration"]) {
timeSinceDeath = 0.0; timeSinceDeath = 0.0;
} }
else if (timeSinceDeath >(double)component["ExplosionDuration"]) { }
timeSinceDeath = (double)component["ExplosionDuration"];
}
}
} }