Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 8102f3a2ea | |||
| cbb17d22d4 | |||
| eb42217885 | |||
| 7e12d00874 | |||
| 44baa47bba | |||
| 382e00cff4 | |||
| 77e1dacb6f | |||
| 37aa1eaa18 | |||
| 1411964dcf | |||
| 35269315cc | |||
| 8f8b64f99c | |||
| 923589524b | |||
| 00eeed2e20 | |||
| 0630885d92 | |||
| 3467315aef |
@@ -5,6 +5,7 @@
|
|||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "Core/Util/Logging.h"
|
#include "Core/Util/Logging.h"
|
||||||
#include "Core/Util/IfDebug.h"
|
#include "Core/Util/IfDebug.h"
|
||||||
@@ -30,6 +30,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
void GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const;
|
||||||
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
void GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm::vec2 dimensions, GLint format, GLenum type, GLint numMipMaps) const;
|
||||||
|
void DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene);
|
||||||
|
|
||||||
|
void BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene);
|
||||||
|
void BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene);
|
||||||
|
|
||||||
|
void BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& job);
|
||||||
|
void BindModelTextures(std::shared_ptr<ModelJob>& job);
|
||||||
|
|
||||||
Texture* m_WhiteTexture;
|
Texture* m_WhiteTexture;
|
||||||
Texture* m_BlackTexture;
|
Texture* m_BlackTexture;
|
||||||
@@ -43,6 +50,7 @@ private:
|
|||||||
const LightCullingPass* m_LightCullingPass;
|
const LightCullingPass* m_LightCullingPass;
|
||||||
|
|
||||||
ShaderProgram* m_ForwardPlusProgram;
|
ShaderProgram* m_ForwardPlusProgram;
|
||||||
|
ShaderProgram* m_ExplosionEffectProgram;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,106 @@
|
|||||||
|
#ifndef ExplosionEffectJob_h__
|
||||||
|
#define ExplosionEffectJob_h__
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "../Common.h"
|
||||||
|
#include "../GLM.h"
|
||||||
|
#include "../Core/ComponentWrapper.h"
|
||||||
|
#include "Texture.h"
|
||||||
|
#include "Model.h"
|
||||||
|
#include "RenderJob.h"
|
||||||
|
#include "../Core/ResourceManager.h"
|
||||||
|
#include "Camera.h"
|
||||||
|
#include "../Core/World.h"
|
||||||
|
|
||||||
|
struct ExplosionEffectJob : ModelJob
|
||||||
|
{
|
||||||
|
ExplosionEffectJob(ComponentWrapper explosionEffectComponent, ::Model* model, Camera* camera, glm::mat4 matrix, ::RawModel::MaterialGroup matGroup, ComponentWrapper modelComponent, ::World* world, glm::vec4 fillColor, float fillPercentage)
|
||||||
|
: ModelJob(model, camera, matrix, matGroup, modelComponent, world, fillColor, fillPercentage)
|
||||||
|
{
|
||||||
|
ExplosionOrigin = (glm::vec3)explosionEffectComponent["ExplosionOrigin"];
|
||||||
|
TimeSinceDeath = (double)explosionEffectComponent["TimeSinceDeath"];
|
||||||
|
ExplosionDuration = (double)explosionEffectComponent["ExplosionDuration"];
|
||||||
|
EndColor = (glm::vec4)explosionEffectComponent["EndColor"];
|
||||||
|
Randomness = (bool)explosionEffectComponent["Randomness"];
|
||||||
|
RandomnessScalar = (double)explosionEffectComponent["RandomnessScalar"];
|
||||||
|
Velocity = (glm::vec2)explosionEffectComponent["Velocity"];
|
||||||
|
ColorByDistance = (bool)explosionEffectComponent["ColorByDistance"];
|
||||||
|
ExponentialAccelaration = (bool)explosionEffectComponent["ExponentialAccelaration"];
|
||||||
|
};
|
||||||
|
|
||||||
|
glm::vec3 ExplosionOrigin;
|
||||||
|
double TimeSinceDeath = 0.f; //Seconds
|
||||||
|
double ExplosionDuration = 2.f;
|
||||||
|
//bool Gravity = true;
|
||||||
|
//double GravityForce = 1.f; // Speed
|
||||||
|
//double ObjectRadius = 2.f; // TODO: Change this for object radius when it's available
|
||||||
|
glm::vec4 EndColor;
|
||||||
|
bool Randomness = false;
|
||||||
|
|
||||||
|
float RandomnessScalar = 1.f;
|
||||||
|
glm::vec2 Velocity;
|
||||||
|
bool ColorByDistance = false;
|
||||||
|
//bool ReverseAnimation = false;
|
||||||
|
//bool Wireframe = false;
|
||||||
|
bool ExponentialAccelaration = false;
|
||||||
|
|
||||||
|
std::array<float, 50> RandomNumbers = {
|
||||||
|
0.3257552917701f,
|
||||||
|
0.07601508315467f,
|
||||||
|
0.57408909014151f,
|
||||||
|
0.0f,
|
||||||
|
0.8618231368539f,
|
||||||
|
0.074957156588769f,
|
||||||
|
0.39413607511396f,
|
||||||
|
0.54579346698979f,
|
||||||
|
0.83222648353885f,
|
||||||
|
0.83635707285086f,
|
||||||
|
0.34473986148124f,
|
||||||
|
0.98092448710507f,
|
||||||
|
0.46346380070944f,
|
||||||
|
0.7308761201477f,
|
||||||
|
0.70832470371776f,
|
||||||
|
0.28268750909841f,
|
||||||
|
0.26291620883295f,
|
||||||
|
0.07685032816457f,
|
||||||
|
0.30760929515008f,
|
||||||
|
0.2781575388639f ,
|
||||||
|
0.016950582161988f ,
|
||||||
|
0.25787915254844f ,
|
||||||
|
0.76293767279151f ,
|
||||||
|
0.67730279903733f ,
|
||||||
|
0.49042877018937f ,
|
||||||
|
0.13002237823327f ,
|
||||||
|
0.62803373841012f ,
|
||||||
|
0.94525353747665f ,
|
||||||
|
0.32893980076953f ,
|
||||||
|
0.95952951719962f ,
|
||||||
|
0.056386206790985f ,
|
||||||
|
0.012030893476694f ,
|
||||||
|
0.93090049220757f,
|
||||||
|
0.83579883064879f,
|
||||||
|
0.79733513938139f,
|
||||||
|
0.8796381046435f ,
|
||||||
|
0.94160434600972f ,
|
||||||
|
0.76901855588379f ,
|
||||||
|
0.50253688101775f ,
|
||||||
|
0.82457069578793f ,
|
||||||
|
0.80157403359263f ,
|
||||||
|
0.87291810189975f ,
|
||||||
|
0.64679548919517f ,
|
||||||
|
0.42664138899494f ,
|
||||||
|
0.77171308303797f ,
|
||||||
|
0.75567959237643f ,
|
||||||
|
0.45190826265696f ,
|
||||||
|
0.59844922628181f ,
|
||||||
|
0.56534937655802f ,
|
||||||
|
0.195656257307f};
|
||||||
|
|
||||||
|
void CalculateHash() override
|
||||||
|
{
|
||||||
|
Hash = 0;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -39,7 +39,6 @@ struct ModelJob : RenderJob
|
|||||||
Depth = worldpos.z;
|
Depth = worldpos.z;
|
||||||
World = world;
|
World = world;
|
||||||
|
|
||||||
|
|
||||||
FillColor = fillColor;
|
FillColor = fillColor;
|
||||||
FillPercentage = fillPercentage;
|
FillPercentage = fillPercentage;
|
||||||
Skeleton = Model->m_RawModel->m_Skeleton;
|
Skeleton = Model->m_RawModel->m_Skeleton;
|
||||||
|
|||||||
@@ -14,11 +14,13 @@
|
|||||||
#include "TextJob.h"
|
#include "TextJob.h"
|
||||||
#include "PointLightJob.h"
|
#include "PointLightJob.h"
|
||||||
#include "DirectionalLightJob.h"
|
#include "DirectionalLightJob.h"
|
||||||
|
#include "ExplosionEffectJob.h"
|
||||||
|
|
||||||
struct RenderScene
|
struct RenderScene
|
||||||
{
|
{
|
||||||
::Camera* Camera = nullptr;
|
::Camera* Camera = nullptr;
|
||||||
std::list<std::shared_ptr<RenderJob>> ForwardJobs;
|
std::list<std::shared_ptr<RenderJob>> OpaqueObjects;
|
||||||
|
std::list<std::shared_ptr<RenderJob>> TransparentObjects;
|
||||||
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
std::list<std::shared_ptr<RenderJob>> PointLightJobs;
|
||||||
std::list<std::shared_ptr<RenderJob>> TextJobs;
|
std::list<std::shared_ptr<RenderJob>> TextJobs;
|
||||||
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
std::list<std::shared_ptr<RenderJob>> DirectionalLightJobs;
|
||||||
@@ -27,7 +29,8 @@ struct RenderScene
|
|||||||
|
|
||||||
void Clear()
|
void Clear()
|
||||||
{
|
{
|
||||||
ForwardJobs.clear();
|
OpaqueObjects.clear();
|
||||||
|
TransparentObjects.clear();
|
||||||
PointLightJobs.clear();
|
PointLightJobs.clear();
|
||||||
TextJobs.clear();
|
TextJobs.clear();
|
||||||
DirectionalLightJobs.clear();
|
DirectionalLightJobs.clear();
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ private:
|
|||||||
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
EventRelay<RenderSystem, Events::InputCommand> m_EInputCommand;
|
||||||
bool OnInputCommand(const Events::InputCommand& e);
|
bool OnInputCommand(const Events::InputCommand& e);
|
||||||
|
|
||||||
void fillModels(std::list<std::shared_ptr<RenderJob>>& jobs);
|
void fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs);
|
||||||
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
void fillLight(std::list<std::shared_ptr<RenderJob>>& jobs);
|
||||||
|
|
||||||
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<RenderSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
|
|||||||
@@ -73,6 +73,8 @@ private:
|
|||||||
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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
#include "Common.h"
|
||||||
|
#include "Core/System.h"
|
||||||
|
|
||||||
|
class ExplosionEffectSystem : public PureSystem
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ExplosionEffectSystem(World* world, EventBroker* eventBroker)
|
||||||
|
: System(world, eventBroker)
|
||||||
|
, PureSystem("ExplosionEffect")
|
||||||
|
{ }
|
||||||
|
|
||||||
|
virtual void UpdateComponent(EntityWrapper& entity, ComponentWrapper& component, double dt) override
|
||||||
|
{
|
||||||
|
|
||||||
|
if ((double)component["TimeSinceDeath"] > (double)component["ExplosionDuration"]) {
|
||||||
|
(double)component["TimeSinceDeath"] = 0.f;
|
||||||
|
}
|
||||||
|
(double&)component["TimeSinceDeath"] += dt;
|
||||||
|
|
||||||
|
//if ((bool)Component["Gravity"] == true) {
|
||||||
|
// (bool)Component["ExponentialAccelaration"] = false;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -14,6 +14,7 @@
|
|||||||
#include "Core/EKeyDown.h"
|
#include "Core/EKeyDown.h"
|
||||||
#include "Core/EntityFilePreprocessor.h"
|
#include "Core/EntityFilePreprocessor.h"
|
||||||
#include "Core/SystemPipeline.h"
|
#include "Core/SystemPipeline.h"
|
||||||
|
#include "ExplosionEffectSystem.h"
|
||||||
#include "Editor/EditorSystem.h"
|
#include "Editor/EditorSystem.h"
|
||||||
#include "Core/EntityFile.h"
|
#include "Core/EntityFile.h"
|
||||||
#include "Rendering/RenderSystem.h"
|
#include "Rendering/RenderSystem.h"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
<xs:include schemaLocation="Components/PointLight.xsd"/>
|
||||||
<xs:include schemaLocation="Components/DirectionalLight.xsd"/>
|
<xs:include schemaLocation="Components/DirectionalLight.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
<xs:include schemaLocation="Components/Trigger.xsd"/>
|
||||||
|
<xs:include schemaLocation="Components/ExplosionEffect.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Health.xsd"/>
|
<xs:include schemaLocation="Components/Health.xsd"/>
|
||||||
<xs:include schemaLocation="Components/CapturePoint.xsd"/>
|
<xs:include schemaLocation="Components/CapturePoint.xsd"/>
|
||||||
<xs:include schemaLocation="Components/Listener.xsd"/>
|
<xs:include schemaLocation="Components/Listener.xsd"/>
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
|
||||||
|
<ExplosionEffect xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="ExplosionEffect.xsd">
|
||||||
|
<ExplosionOrigin X="0" Y="0" Z="0"/>
|
||||||
|
<TimeSinceDeath>0</TimeSinceDeath>
|
||||||
|
<ExplosionDuration>2</ExplosionDuration>
|
||||||
|
<!--<Gravity>1</Gravity>-->
|
||||||
|
<!--<GravityForce>1</GravityForce>-->
|
||||||
|
<!--<ObjectRadius>2</ObjectRadius>-->
|
||||||
|
<EndColor R="0" G="0" B="0" A="0"/>
|
||||||
|
<Randomness>0</Randomness>
|
||||||
|
<RandomnessScalar>1</RandomnessScalar>
|
||||||
|
<Velocity X="2" Y="2"/>
|
||||||
|
<ColorByDistance>0</ColorByDistance>
|
||||||
|
<!--<ReverseAnimation>0</ReverseAnimation>-->
|
||||||
|
<!--<Wireframe>0</Wireframe>-->
|
||||||
|
<ExponentialAccelaration>0</ExponentialAccelaration>
|
||||||
|
</ExplosionEffect>
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:t="types">
|
||||||
|
<xs:import schemaLocation="../Types.xsd" namespace="types"/>
|
||||||
|
|
||||||
|
<xs:element name="ExplosionEffect">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation>A component that trigger the death effect</xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
<xs:complexType>
|
||||||
|
<xs:all>
|
||||||
|
<xs:element name="ExplosionOrigin" type="t:Vector" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The position in which to spawn the component</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="TimeSinceDeath" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Seconds since death</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="ExplosionDuration" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>How many seconds the death animation should be</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<!--<xs:element name="Gravity" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Enable/disable gravity</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>-->
|
||||||
|
<!--<xs:element name="GravityForce" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The force of the gravity</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>-->
|
||||||
|
<!--<xs:element name="ObjectRadius" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Object radius (TO BE REMOVED AND AUTOMATED)</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>-->
|
||||||
|
<xs:element name="EndColor" type="t:Color" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The tint the polys end with</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="Randomness" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Add some randomness to the explosion</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="RandomnessScalar" type="t:double" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Alter the power of the randomness</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<xs:element name="Velocity" type="t:Vector" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>The velocity factors (start/end)</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
<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: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:annotation><xs:documentation>Enable/disable wireframe</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>-->
|
||||||
|
<xs:element name="ExponentialAccelaration" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Linear/Exponential accelaration</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
|
</xs:all>
|
||||||
|
</xs:complexType>
|
||||||
|
</xs:element>
|
||||||
|
</xs:schema>
|
||||||
@@ -2,5 +2,6 @@
|
|||||||
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Model.xsd">
|
<Model xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Model.xsd">
|
||||||
<Resource></Resource>
|
<Resource></Resource>
|
||||||
<Color R="1" G="1" B="1" A="1"/>
|
<Color R="1" G="1" B="1" A="1"/>
|
||||||
|
<Transparent>false</Transparent>
|
||||||
<Visible>true</Visible>
|
<Visible>true</Visible>
|
||||||
</Model>
|
</Model>
|
||||||
@@ -15,6 +15,9 @@
|
|||||||
<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="Transparent" type="t:bool" minOccurs="0">
|
||||||
|
<xs:annotation><xs:documentation>Wether the model is transparent or not</xs:documentation></xs:annotation>
|
||||||
|
</xs:element>
|
||||||
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
<xs:element name="Visible" type="t:bool" minOccurs="0">
|
||||||
<xs:annotation><xs:documentation>Wether the model is visible or not</xs:documentation></xs:annotation>
|
<xs:annotation><xs:documentation>Wether the model is visible or not</xs:documentation></xs:annotation>
|
||||||
</xs:element>
|
</xs:element>
|
||||||
|
|||||||
@@ -25,10 +25,16 @@
|
|||||||
<Entity>
|
<Entity>
|
||||||
<Components>
|
<Components>
|
||||||
<c:Animation>
|
<c:Animation>
|
||||||
<Name>Crouch Walk</Name>
|
<Name>Run</Name>
|
||||||
<Time>701.10570384634161</Time>
|
<Time>0.56277947897317659</Time>
|
||||||
<Speed>32</Speed>
|
<Speed>1</Speed>
|
||||||
</c:Animation>
|
</c:Animation>
|
||||||
|
<c:ExplosionEffect>
|
||||||
|
<Velocity X="0" Y="1.10000002" Z="3.30000019"/>
|
||||||
|
<ExplosionOrigin X="-0.600000024" Y="1" Z="0"/>
|
||||||
|
<TimeSinceDeath>0.95625903442123672</TimeSinceDeath>
|
||||||
|
<EndColor A="0" B="0.815686285" G="1" R="0"/>
|
||||||
|
</c:ExplosionEffect>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||||
<Color A="1" B="392156.875" G="1" R="1"/>
|
<Color A="1" B="392156.875" G="1" R="1"/>
|
||||||
|
|||||||
@@ -18,6 +18,23 @@
|
|||||||
</c:Transform>
|
</c:Transform>
|
||||||
<c:Camera>
|
<c:Camera>
|
||||||
</c:Camera>
|
</c:Camera>
|
||||||
|
<Orientation X="0.0" Y="0.0" Z="0"/>
|
||||||
|
<c:ExplosionEffect>
|
||||||
|
<ExplosionOrigin X="0" Y="0" Z="0"/>
|
||||||
|
<TimeSinceDeath>0</TimeSinceDeath>
|
||||||
|
<ExplosionDuration>2</ExplosionDuration>
|
||||||
|
<!--<Gravity>1</Gravity>-->
|
||||||
|
<!--<GravityForce>1</GravityForce>-->
|
||||||
|
<!--<ObjectRadius>2</ObjectRadius>-->
|
||||||
|
<EndColor R="0" G="0" B="0" A="0"/>
|
||||||
|
<Randomness>0</Randomness>
|
||||||
|
<RandomnessScalar>1</RandomnessScalar>
|
||||||
|
<Velocity X="2" Y="2"/>
|
||||||
|
<ColorByDistance>0</ColorByDistance>
|
||||||
|
<!--<ReverseAnimation>0</ReverseAnimation>-->
|
||||||
|
<!--<Wireframe>0</Wireframe>-->
|
||||||
|
<ExponentialAccelaration>0</ExponentialAccelaration>
|
||||||
|
</c:ExplosionEffect>
|
||||||
<c:Model>
|
<c:Model>
|
||||||
<Resource>Models/Camera.mesh</Resource>
|
<Resource>Models/Camera.mesh</Resource>
|
||||||
</c:Model>
|
</c:Model>
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<xs:element ref="c:Model" minOccurs="0"/>
|
<xs:element ref="c:Model" minOccurs="0"/>
|
||||||
<xs:element ref="c:RaptorCopter" minOccurs="0"/>
|
<xs:element ref="c:RaptorCopter" minOccurs="0"/>
|
||||||
<xs:element ref="c:Player" minOccurs="0"/>
|
<xs:element ref="c:Player" minOccurs="0"/>
|
||||||
|
<xs:element ref="c:ExplosionEffect" minOccurs="0"/>
|
||||||
<xs:element ref="c:Camera" minOccurs="0"/>
|
<xs:element ref="c:Camera" minOccurs="0"/>
|
||||||
<xs:element ref="c:Text" minOccurs="0"/>
|
<xs:element ref="c:Text" minOccurs="0"/>
|
||||||
<xs:element ref="c:AABB" minOccurs="0"/>
|
<xs:element ref="c:AABB" minOccurs="0"/>
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 M;
|
||||||
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
uniform vec4 Color;
|
||||||
|
|
||||||
|
uniform sampler2D texture0;
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
vec4 DiffuseColor;
|
||||||
|
vec4 ExplosionColor;
|
||||||
|
}Input;
|
||||||
|
|
||||||
|
out vec4 fragmentColor;
|
||||||
|
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
vec4 texel = texture2D(texture0, Input.TextureCoordinate);
|
||||||
|
fragmentColor = texel * Input.DiffuseColor * Color + Input.ExplosionColor;
|
||||||
|
}
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 M;
|
||||||
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
uniform vec3 ExplosionOrigin;
|
||||||
|
uniform float TimeSinceDeath;
|
||||||
|
uniform float ExplosionDuration;
|
||||||
|
uniform vec4 EndColor;
|
||||||
|
uniform bool Randomness;
|
||||||
|
uniform float RandomNumbers[50];
|
||||||
|
uniform float RandomnessScalar;
|
||||||
|
uniform vec2 Velocity;
|
||||||
|
uniform bool ColorByDistance;
|
||||||
|
uniform bool ExponentialAccelaration;
|
||||||
|
|
||||||
|
in VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
vec4 ExplosionColor;
|
||||||
|
}Input[];
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
vec4 ExplosionColor;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
layout(triangles) in;
|
||||||
|
layout(triangle_strip, max_vertices = 3) out;
|
||||||
|
|
||||||
|
// returns a "random" number based on input parameter
|
||||||
|
float GetRandomNumber(int polygon_index)
|
||||||
|
{
|
||||||
|
int randomIndex = int(mod(polygon_index, 50));
|
||||||
|
|
||||||
|
return RandomNumbers[randomIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
float randomNumber = 0.0;
|
||||||
|
float randomDistance = 0.0;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
// calculate middle of vectors
|
||||||
|
vec3 v1 = Input[1].Position - Input[0].Position;
|
||||||
|
vec3 v2 = Input[2].Position - Input[0].Position;
|
||||||
|
vec3 v3 = Input[2].Position - (v1 / 2);
|
||||||
|
vec3 v4 = Input[1].Position - (v2 / 2);
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
mat3 matrisA = mat3(vecA, dir2, vecB);
|
||||||
|
|
||||||
|
float lengthA = length(vecB);
|
||||||
|
lengthA = lengthA * lengthA;
|
||||||
|
|
||||||
|
float s = determinant(matrisA) / lengthA;
|
||||||
|
|
||||||
|
// center position of triangle
|
||||||
|
vec3 centerOfTriangle = Input[1].Position + (s * dir1);
|
||||||
|
|
||||||
|
// center position of triangle to origin vector
|
||||||
|
vec3 origin2TriangleCenterVector = centerOfTriangle - ExplosionOrigin;
|
||||||
|
vec3 normalizedOrigin2TriangleCenterVector = normalize(origin2TriangleCenterVector);
|
||||||
|
|
||||||
|
// time percentage until end of explosion (0.0-1.0)
|
||||||
|
float timePercetage = TimeSinceDeath / ExplosionDuration;
|
||||||
|
|
||||||
|
// get a random number if randomness is enabled, otherwise the random number will be zero and won't affect the other algorithms
|
||||||
|
if (Randomness == true)
|
||||||
|
{
|
||||||
|
randomDistance = GetRandomNumber(gl_PrimitiveIDIn) * RandomnessScalar;
|
||||||
|
}
|
||||||
|
|
||||||
|
vec2 randomVelocity = Velocity * (randomDistance + 1.0);
|
||||||
|
|
||||||
|
// accelaration to use on current frame. is a interpolation between start and end value
|
||||||
|
float currentVelocity = mix(randomVelocity.x, randomVelocity.y, timePercetage);
|
||||||
|
|
||||||
|
if (ExponentialAccelaration == true)
|
||||||
|
{
|
||||||
|
currentVelocity = pow(currentVelocity, 2) / 2.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// distance between origin and the center of the current triangle
|
||||||
|
float origin2TriangleCenterDistance = length(origin2TriangleCenterVector);
|
||||||
|
|
||||||
|
// the distance from origin to the triangle center with eventual randomness added
|
||||||
|
float fullDistanceWithRandomness = origin2TriangleCenterDistance + randomDistance;
|
||||||
|
|
||||||
|
// vector from the triangle center to the explosion's shockwave
|
||||||
|
vec3 triangleCenter2ExplosionRadius = (normalizedOrigin2TriangleCenterVector * (TimeSinceDeath * currentVelocity)) - (normalizedOrigin2TriangleCenterVector * fullDistanceWithRandomness);
|
||||||
|
|
||||||
|
// if the triangle is inside the blast radius...
|
||||||
|
if (fullDistanceWithRandomness <= (TimeSinceDeath * currentVelocity))
|
||||||
|
{
|
||||||
|
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));
|
||||||
|
|
||||||
|
Output.ExplosionColor = EndColor * (length(triangleCenter2ExplosionRadius) / s);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Output.ExplosionColor = EndColor * 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;
|
||||||
|
|
||||||
|
// 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
|
||||||
|
{
|
||||||
|
// if explosion color should be affected by distance instead of time...
|
||||||
|
if (ColorByDistance == true)
|
||||||
|
{
|
||||||
|
Output.ExplosionColor = vec4(0.0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Output.ExplosionColor = EndColor * 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;
|
||||||
|
|
||||||
|
// no change in position, pass through vertex
|
||||||
|
gl_Position = gl_in[i].gl_Position;
|
||||||
|
EmitVertex();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//EndPrimitive();
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 M;
|
||||||
|
uniform mat4 V;
|
||||||
|
uniform mat4 P;
|
||||||
|
|
||||||
|
layout(location = 0) in vec3 Position;
|
||||||
|
layout(location = 1) in vec3 Normal;
|
||||||
|
layout(location = 2) in vec3 Tangent;
|
||||||
|
layout(location = 3) in vec3 BiTangent;
|
||||||
|
layout(location = 4) in vec2 TextureCoords;
|
||||||
|
layout(location = 5) in vec4 DiffuseVertexColor;
|
||||||
|
layout(location = 6) in vec4 SpecularVertexColor;
|
||||||
|
layout(location = 7) in vec4 BoneIndices1;
|
||||||
|
layout(location = 8) in vec4 BoneIndices2;
|
||||||
|
layout(location = 9) in vec4 BoneWeights1;
|
||||||
|
layout(location = 10) in vec4 BoneWeights2;
|
||||||
|
|
||||||
|
out VertexData{
|
||||||
|
vec3 Position;
|
||||||
|
vec3 Normal;
|
||||||
|
vec2 TextureCoordinate;
|
||||||
|
vec4 DiffuseColor;
|
||||||
|
vec4 ExplosionColor;
|
||||||
|
}Output;
|
||||||
|
|
||||||
|
void main()
|
||||||
|
{
|
||||||
|
gl_Position = P*V*M * vec4(Position, 1.0);
|
||||||
|
|
||||||
|
Output.Position = Position;
|
||||||
|
Output.TextureCoordinate = TextureCoords;
|
||||||
|
Output.Normal = Normal;
|
||||||
|
Output.DiffuseColor = DiffuseVertexColor;
|
||||||
|
Output.ExplosionColor = vec4(0.0);
|
||||||
|
}
|
||||||
@@ -50,6 +50,7 @@ in VertexData{
|
|||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
|
vec4 ExplosionColor;
|
||||||
}Input;
|
}Input;
|
||||||
|
|
||||||
out vec4 sceneColor;
|
out vec4 sceneColor;
|
||||||
@@ -137,8 +138,8 @@ void main()
|
|||||||
totalLighting.Specular += light_result.Specular;
|
totalLighting.Specular += light_result.Specular;
|
||||||
}
|
}
|
||||||
|
|
||||||
//sceneColor += Input.DiffuseColor;
|
|
||||||
vec4 color_result = DiffuseColor * (totalLighting.Diffuse + totalLighting.Specular) * diffuseTexel * Color;
|
vec4 color_result = (DiffuseColor + Input.ExplosionColor) * (totalLighting.Diffuse + totalLighting.Specular) * diffuseTexel * Color;
|
||||||
|
|
||||||
|
|
||||||
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
|
float pos = ((P * vec4(Input.Position, 1)).y + 1.0)/2.0;
|
||||||
@@ -161,9 +162,7 @@ void main()
|
|||||||
} else {
|
} else {
|
||||||
bloomColor = vec4(0.0, 0.0, 0.0, 1.0);
|
bloomColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||||
} */
|
} */
|
||||||
|
|
||||||
//sceneColor += Input.DiffuseColor * (totalLighting.Diffuse) * diffuseTexel * Color;
|
|
||||||
//sceneColor += Input.DiffuseColor + vec4(0.0, LightGrids.Data[currentTile].Amount/3, 0, 1);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ out VertexData{
|
|||||||
vec3 Position;
|
vec3 Position;
|
||||||
vec3 Normal;
|
vec3 Normal;
|
||||||
vec2 TextureCoordinate;
|
vec2 TextureCoordinate;
|
||||||
|
vec4 ExplosionColor;
|
||||||
}Output;
|
}Output;
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
@@ -36,4 +37,5 @@ void main()
|
|||||||
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
Output.Normal = vec3(M * vec4(Normal, 0.0));
|
||||||
|
Output.ExplosionColor = vec4(0.0);
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,11 @@ void EditorRenderSystem::Update(double dt)
|
|||||||
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
|
glm::mat4 modelMatrix = Transform::ModelMatrix(entity.ID, entity.World);
|
||||||
for (auto matGroup : model->MaterialGroups()) {
|
for (auto matGroup : model->MaterialGroups()) {
|
||||||
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
std::shared_ptr<ModelJob> modelJob = std::make_shared<ModelJob>(model, scene.Camera, modelMatrix, matGroup, cModel, entity.World, glm::vec4(0), 0.f);
|
||||||
scene.ForwardJobs.push_back(modelJob);
|
if(cModel["Transparent"]) {
|
||||||
|
scene.TransparentObjects.push_back(modelJob);
|
||||||
|
} else {
|
||||||
|
scene.OpaqueObjects.push_back(modelJob);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ void DrawFinalPass::InitializeFrameBuffers()
|
|||||||
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
//GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
GenerateTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, GL_LINEAR, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_RGB, GL_FLOAT);
|
||||||
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_FLOAT, 4);
|
//GenerateMipMapTexture(&m_BloomTexture, GL_CLAMP_TO_EDGE, glm::vec2(m_Renderer->Resolution().Width, m_Renderer->Resolution().Height), GL_RGB16F, GL_FLOAT, 4);
|
||||||
|
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new RenderBuffer(&m_DepthBuffer, GL_DEPTH_ATTACHMENT)));
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_SceneTexture, GL_COLOR_ATTACHMENT0)));
|
||||||
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
m_FinalPassFrameBuffer.AddResource(std::shared_ptr<BufferResource>(new Texture2D(&m_BloomTexture, GL_COLOR_ATTACHMENT1)));
|
||||||
@@ -42,6 +42,15 @@ void DrawFinalPass::InitializeShaderPrograms()
|
|||||||
m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor");
|
m_ForwardPlusProgram->BindFragDataLocation(0, "sceneColor");
|
||||||
m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor");
|
m_ForwardPlusProgram->BindFragDataLocation(1, "bloomColor");
|
||||||
m_ForwardPlusProgram->Link();
|
m_ForwardPlusProgram->Link();
|
||||||
|
|
||||||
|
m_ExplosionEffectProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectProgram");
|
||||||
|
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ForwardPlus.vert.glsl")));
|
||||||
|
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
|
||||||
|
m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ForwardPlus.frag.glsl")));
|
||||||
|
m_ExplosionEffectProgram->Compile();
|
||||||
|
m_ExplosionEffectProgram->BindFragDataLocation(0, "sceneColor");
|
||||||
|
m_ExplosionEffectProgram->BindFragDataLocation(1, "bloomColor");
|
||||||
|
m_ExplosionEffectProgram->Link();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::Draw(RenderScene& scene)
|
void DrawFinalPass::Draw(RenderScene& scene)
|
||||||
@@ -49,69 +58,15 @@ void DrawFinalPass::Draw(RenderScene& scene)
|
|||||||
GLERROR("DrawFinalPass::Draw: Pre");
|
GLERROR("DrawFinalPass::Draw: Pre");
|
||||||
|
|
||||||
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
DrawFinalPassState* state = new DrawFinalPassState(m_FinalPassFrameBuffer.GetHandle());
|
||||||
|
|
||||||
m_ForwardPlusProgram->Bind();
|
|
||||||
GLuint shaderHandle = m_ForwardPlusProgram->GetHandle();
|
|
||||||
|
|
||||||
if (scene.ClearDepth) {
|
if (scene.ClearDepth) {
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
DrawModelRenderQueues(scene.OpaqueObjects, scene);
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
GLERROR("DrawFinalPass::Draw: OpaqueObjects");
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
DrawModelRenderQueues(scene.TransparentObjects, scene);
|
||||||
|
GLERROR("DrawFinalPass::Draw: TransparentObjects");
|
||||||
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
|
||||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
|
||||||
|
|
||||||
|
|
||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
|
||||||
for (auto &job : scene.ForwardJobs) {
|
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
|
||||||
if(modelJob) {
|
|
||||||
//TODO: Kolla upp "header/include/common" shader saken så man slipper skicka in asmycket uniforms
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(modelJob->Color));
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(modelJob->DiffuseColor));
|
|
||||||
|
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(modelJob->FillColor));
|
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), modelJob->FillPercentage);
|
|
||||||
|
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0);
|
|
||||||
if(modelJob->DiffuseTexture != nullptr) {
|
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->DiffuseTexture->m_Texture);
|
|
||||||
} else {
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
|
||||||
}
|
|
||||||
glActiveTexture(GL_TEXTURE1);
|
|
||||||
if (modelJob->IncandescenceTexture != nullptr) {
|
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->IncandescenceTexture->m_Texture);
|
|
||||||
} else {
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*if(modelJob->GlowMap != nullptr) {
|
|
||||||
glBindTexture(GL_TEXTURE_2D, modelJob->GlowMap->m_Texture);
|
|
||||||
} else {
|
|
||||||
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
//TODO: Fixa så att modelsJobs kan spela upp olika animationer och så att den kan få in en tid istället för 1.0f - Hälsningar Johan och Andreas :)
|
|
||||||
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
|
||||||
|
|
||||||
if (modelJob->Animation != nullptr) {
|
|
||||||
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones( *modelJob->Animation, modelJob->AnimationTime);
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
|
||||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GLERROR("DrawFinalPass::Draw: END");
|
GLERROR("DrawFinalPass::Draw: END");
|
||||||
delete state;
|
delete state;
|
||||||
}
|
}
|
||||||
@@ -149,4 +104,137 @@ void DrawFinalPass::GenerateMipMapTexture(GLuint* texture, GLenum wrapping, glm:
|
|||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
||||||
GLERROR("MipMap Texture initialization failed");
|
GLERROR("MipMap Texture initialization failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>& job, RenderScene& scene)
|
||||||
|
{
|
||||||
|
GLuint forwardHandle = m_ForwardPlusProgram->GetHandle();
|
||||||
|
GLuint explosionHandle = m_ExplosionEffectProgram->GetHandle();
|
||||||
|
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 4, m_LightCullingPass->LightIndexSSBO());
|
||||||
|
|
||||||
|
for(auto &job : job)
|
||||||
|
{
|
||||||
|
auto explosionEffectJob = std::dynamic_pointer_cast<ExplosionEffectJob>(job);
|
||||||
|
if(explosionEffectJob) {
|
||||||
|
//Bind program
|
||||||
|
m_ExplosionEffectProgram->Bind();
|
||||||
|
|
||||||
|
//Bind uniforms
|
||||||
|
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||||
|
|
||||||
|
if (explosionEffectJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (explosionEffectJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = explosionEffectJob->Skeleton->GetFrameBones(*explosionEffectJob->Animation, explosionEffectJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//bind textures
|
||||||
|
BindExplosionTextures(explosionEffectJob);
|
||||||
|
//draw
|
||||||
|
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
if (modelJob) {
|
||||||
|
//bind forward program
|
||||||
|
m_ForwardPlusProgram->Bind();
|
||||||
|
|
||||||
|
//bind uniforms
|
||||||
|
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||||
|
|
||||||
|
//bind textures
|
||||||
|
BindModelTextures(modelJob);
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//draw
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex*sizeof(unsigned int)));
|
||||||
|
GLERROR("DrawFinalPass::Model: END");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||||
|
{
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
||||||
|
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
||||||
|
glUniform1f(glGetUniformLocation(shaderHandle, "TimeSinceDeath"), job->TimeSinceDeath);
|
||||||
|
glUniform1f(glGetUniformLocation(shaderHandle, "ExplosionDuration"), job->ExplosionDuration);
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "EndColor"), 1, glm::value_ptr(job->EndColor));
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle, "Randomness"), job->Randomness);
|
||||||
|
glUniform1f(glGetUniformLocation(shaderHandle, "RandomnessScalar"), job->RandomnessScalar);
|
||||||
|
glUniform2fv(glGetUniformLocation(shaderHandle, "Velocity"), 1, glm::value_ptr(job->Velocity));
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle, "ColorByDistance"), job->ColorByDistance);
|
||||||
|
glUniform1i(glGetUniformLocation(shaderHandle, "ExponentialAccelaration"), job->ExponentialAccelaration);
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
|
||||||
|
glUniform1fv(glGetUniformLocation(shaderHandle, "RandomNumbers"), 50, job->RandomNumbers.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
||||||
|
{
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "Color"), 1, glm::value_ptr(job->Color));
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "DiffuseColor"), 1, glm::value_ptr(job->DiffuseColor));
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "FillColor"), 1, glm::value_ptr(job->FillColor));
|
||||||
|
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void DrawFinalPass::BindExplosionTextures(std::shared_ptr<ExplosionEffectJob>& job)
|
||||||
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
if (job->DiffuseTexture != nullptr) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture->m_Texture);
|
||||||
|
} else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||||
|
}
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
if (job->IncandescenceTexture != nullptr) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture);
|
||||||
|
} else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawFinalPass::BindModelTextures(std::shared_ptr<ModelJob>& job)
|
||||||
|
{
|
||||||
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
if (job->DiffuseTexture != nullptr) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, job->DiffuseTexture->m_Texture);
|
||||||
|
} else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_WhiteTexture->m_Texture);
|
||||||
|
}
|
||||||
|
glActiveTexture(GL_TEXTURE1);
|
||||||
|
if (job->IncandescenceTexture != nullptr) {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, job->IncandescenceTexture->m_Texture);
|
||||||
|
} else {
|
||||||
|
glBindTexture(GL_TEXTURE_2D, m_BlackTexture->m_Texture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
}
|
}
|
||||||
m_Camera = scene.Camera;
|
m_Camera = scene.Camera;
|
||||||
|
|
||||||
for (auto &job : scene.ForwardJobs) {
|
for (auto &job : scene.OpaqueObjects) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
if (modelJob) {
|
if (modelJob) {
|
||||||
@@ -101,6 +101,52 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (auto &job : scene.TransparentObjects) {
|
||||||
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
|
if (modelJob) {
|
||||||
|
int pickColor[2] = { m_ColorCounter[0], m_ColorCounter[1] };
|
||||||
|
|
||||||
|
PickingInfo pickInfo;
|
||||||
|
pickInfo.Entity = modelJob->Entity;
|
||||||
|
pickInfo.World = modelJob->World;
|
||||||
|
pickInfo.Camera = scene.Camera;
|
||||||
|
|
||||||
|
auto color = m_EntityColors.find(std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera));
|
||||||
|
if (color != m_EntityColors.end()) {
|
||||||
|
pickColor[0] = color->second[0];
|
||||||
|
pickColor[1] = color->second[1];
|
||||||
|
} else {
|
||||||
|
m_EntityColors[std::make_tuple(pickInfo.Entity, pickInfo.World, pickInfo.Camera)] = glm::ivec2(pickColor[0], pickColor[1]);
|
||||||
|
if (m_ColorCounter[0] > 255) {
|
||||||
|
m_ColorCounter[0] = 0;
|
||||||
|
m_ColorCounter[1] += 5;
|
||||||
|
} else {
|
||||||
|
m_ColorCounter[0] += 50;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
|
if (modelJob->Model->m_RawModel->m_Skeleton != nullptr) {
|
||||||
|
|
||||||
|
if (modelJob->Animation != nullptr) {
|
||||||
|
std::vector<glm::mat4> frameBones = modelJob->Skeleton->GetFrameBones(*modelJob->Animation, modelJob->AnimationTime);
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
glDrawElements(GL_TRIANGLES, modelJob->EndIndex - modelJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(modelJob->StartIndex * sizeof(unsigned int)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
m_PickingBuffer.Unbind();
|
m_PickingBuffer.Unbind();
|
||||||
GLERROR("PickingPass Error");
|
GLERROR("PickingPass Error");
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ bool RenderSystem::OnSetCamera(Events::SetCamera& e)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& opaqueJobs, std::list<std::shared_ptr<RenderJob>>& transparentJobs)
|
||||||
{
|
{
|
||||||
auto models = m_World->GetComponents("Model");
|
auto models = m_World->GetComponents("Model");
|
||||||
if (models == nullptr) {
|
if (models == nullptr) {
|
||||||
@@ -75,22 +75,58 @@ void RenderSystem::fillModels(std::list<std::shared_ptr<RenderJob>>& jobs)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
float fillPercentage = 0.f;
|
float fillPercentage = 0.f;
|
||||||
glm::vec4 fillColor = glm::vec4(0);
|
glm::vec4 fillColor = glm::vec4(0);
|
||||||
|
|
||||||
if(m_World->HasComponent(modelComponent.EntityID, "Fill")) {
|
if(m_World->HasComponent(modelComponent.EntityID, "Fill")) {
|
||||||
auto fillComponent = m_World->GetComponent(modelComponent.EntityID, "Fill");
|
auto fillComponent = m_World->GetComponent(modelComponent.EntityID, "Fill");
|
||||||
fillPercentage = (float)(double)fillComponent["Percentage"];
|
fillPercentage = (float)(double)fillComponent["Percentage"];
|
||||||
fillColor = (glm::vec4)fillComponent["Color"];
|
fillColor = (glm::vec4)fillComponent["Color"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, m_World);
|
glm::mat4 modelMatrix = Transform::ModelMatrix(modelComponent.EntityID, m_World);
|
||||||
for (auto matGroup : model->MaterialGroups()) {
|
for (auto matGroup : model->MaterialGroups()) {
|
||||||
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(model, m_Camera, modelMatrix, matGroup, modelComponent, m_World, fillColor, fillPercentage));
|
if (m_World->HasComponent(modelComponent.EntityID, "ExplosionEffect")) {
|
||||||
jobs.push_back(modelJob);
|
auto explosionEffectComponent = m_World->GetComponent(modelComponent.EntityID, "ExplosionEffect");
|
||||||
|
std::shared_ptr<ExplosionEffectJob> explosionEffectJob = std::shared_ptr<ExplosionEffectJob>(new ExplosionEffectJob(
|
||||||
|
explosionEffectComponent,
|
||||||
|
model,
|
||||||
|
m_Camera,
|
||||||
|
modelMatrix,
|
||||||
|
matGroup,
|
||||||
|
modelComponent,
|
||||||
|
m_World,
|
||||||
|
fillColor,
|
||||||
|
fillPercentage
|
||||||
|
));
|
||||||
|
if(explosionEffectJob->Color.a != 1.f || explosionEffectJob->EndColor.a != 1.f || explosionEffectJob->DiffuseColor.a != 1.f) {
|
||||||
|
modelComponent["Transparent"] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelComponent["Transparent"]) {
|
||||||
|
transparentJobs.push_back(explosionEffectJob);
|
||||||
|
} else {
|
||||||
|
opaqueJobs.push_back(explosionEffectJob);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::shared_ptr<ModelJob> modelJob = std::shared_ptr<ModelJob>(new ModelJob(
|
||||||
|
model,
|
||||||
|
m_Camera,
|
||||||
|
modelMatrix,
|
||||||
|
matGroup,
|
||||||
|
modelComponent,
|
||||||
|
m_World,
|
||||||
|
fillColor,
|
||||||
|
fillPercentage
|
||||||
|
));
|
||||||
|
if (modelJob->Color.a != 1.f || modelJob->DiffuseColor.a != 1.f) {
|
||||||
|
modelComponent["Transparent"] = true;
|
||||||
|
}
|
||||||
|
if (modelComponent["Transparent"]) {
|
||||||
|
transparentJobs.push_back(modelJob);
|
||||||
|
} else {
|
||||||
|
opaqueJobs.push_back(modelJob);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,7 +236,7 @@ void RenderSystem::Update(double dt)
|
|||||||
RenderScene scene;
|
RenderScene scene;
|
||||||
scene.Camera = m_Camera;
|
scene.Camera = m_Camera;
|
||||||
scene.Viewport = Rectangle(1280, 720);
|
scene.Viewport = Rectangle(1280, 720);
|
||||||
fillModels(scene.ForwardJobs);
|
fillModels(scene.OpaqueObjects, scene.TransparentObjects);
|
||||||
fillPointLights(scene.PointLightJobs, m_World);
|
fillPointLights(scene.PointLightJobs, m_World);
|
||||||
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
fillDirectionalLights(scene.DirectionalLightJobs, m_World);
|
||||||
fillText(scene.TextJobs, m_World);
|
fillText(scene.TextJobs, m_World);
|
||||||
|
|||||||
@@ -63,6 +63,15 @@ void Renderer::InitializeWindow()
|
|||||||
void Renderer::InitializeShaders()
|
void Renderer::InitializeShaders()
|
||||||
{
|
{
|
||||||
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
|
m_BasicForwardProgram = ResourceManager::Load<ShaderProgram>("#m_BasicForwardProgram");
|
||||||
|
m_ExplosionEffectProgram = ResourceManager::Load<ShaderProgram>("#ExplosionEffectProgram");
|
||||||
|
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new VertexShader("Shaders/ExplosionEffect.vert.glsl")));
|
||||||
|
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new GeometryShader("Shaders/ExplosionEffect.geom.glsl")));
|
||||||
|
//m_ExplosionEffectProgram->AddShader(std::shared_ptr<Shader>(new FragmentShader("Shaders/ExplosionEffect.frag.glsl")));
|
||||||
|
//m_ExplosionEffectProgram->Compile();
|
||||||
|
//m_ExplosionEffectProgram->Link();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::InputUpdate(double dt)
|
void Renderer::InputUpdate(double dt)
|
||||||
@@ -98,6 +107,7 @@ void Renderer::Draw(RenderFrame& frame)
|
|||||||
m_LightCullingPass->FillLightList(*scene);
|
m_LightCullingPass->FillLightList(*scene);
|
||||||
m_LightCullingPass->CullLights(*scene);
|
m_LightCullingPass->CullLights(*scene);
|
||||||
m_DrawFinalPass->Draw(*scene);
|
m_DrawFinalPass->Draw(*scene);
|
||||||
|
//m_DrawScenePass->Draw(*scene);
|
||||||
|
|
||||||
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
GLERROR("Renderer::Draw m_DrawScenePass->Draw");
|
||||||
|
|
||||||
@@ -140,7 +150,7 @@ void Renderer::InitializeTextures()
|
|||||||
void Renderer::SortRenderJobsByDepth(RenderScene &scene)
|
void Renderer::SortRenderJobsByDepth(RenderScene &scene)
|
||||||
{
|
{
|
||||||
//Sort all forward jobs so transparency is good.
|
//Sort all forward jobs so transparency is good.
|
||||||
scene.ForwardJobs.sort(Renderer::DepthSort);
|
scene.TransparentObjects.sort(Renderer::DepthSort);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
|
void Renderer::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type)
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ Game::Game(int argc, char* argv[])
|
|||||||
// All systems with orderlevel 0 will be updated first.
|
// All systems with orderlevel 0 will be updated first.
|
||||||
unsigned int updateOrderLevel = 0;
|
unsigned int updateOrderLevel = 0;
|
||||||
m_SystemPipeline->AddSystem<RaptorCopterSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<RaptorCopterSystem>(updateOrderLevel);
|
||||||
|
m_SystemPipeline->AddSystem<ExplosionEffectSystem>(updateOrderLevel);
|
||||||
m_SystemPipeline->AddSystem<HealthSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<HealthSystem>(updateOrderLevel);
|
||||||
m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<PlayerMovementSystem>(updateOrderLevel);
|
||||||
m_SystemPipeline->AddSystem<InterpolationSystem>(updateOrderLevel);
|
m_SystemPipeline->AddSystem<InterpolationSystem>(updateOrderLevel);
|
||||||
|
|||||||
Reference in New Issue
Block a user