Merge pull request #190 from teamfisk/RendererBugFixes
Renderer bug fixes
This commit is contained in:
@@ -15,7 +15,7 @@ public:
|
|||||||
void GenerateCubeMapTexture();
|
void GenerateCubeMapTexture();
|
||||||
|
|
||||||
//GLuint CubeMapTexture() const { return m_CubeMapTexture; }
|
//GLuint CubeMapTexture() const { return m_CubeMapTexture; }
|
||||||
GLuint m_CubeMapTexture = -1;
|
GLuint m_CubeMapTexture = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IRenderer* m_Renderer;
|
IRenderer* m_Renderer;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class DrawBloomPass
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawBloomPass(IRenderer* renderer, ConfigFile* config);
|
DrawBloomPass(IRenderer* renderer, ConfigFile* config);
|
||||||
~DrawBloomPass() { }
|
~DrawBloomPass();
|
||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class DrawFinalPass
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass);
|
DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCullingPass, CubeMapPass* cubeMapPass, SSAOPass* ssaoPass);
|
||||||
~DrawFinalPass() { }
|
~DrawFinalPass();
|
||||||
void InitializeTextures();
|
void InitializeTextures();
|
||||||
void InitializeFrameBuffers();
|
void InitializeFrameBuffers();
|
||||||
void InitializeShaderPrograms();
|
void InitializeShaderPrograms();
|
||||||
@@ -57,11 +57,11 @@ private:
|
|||||||
|
|
||||||
FrameBuffer m_FinalPassFrameBuffer;
|
FrameBuffer m_FinalPassFrameBuffer;
|
||||||
FrameBuffer m_ShieldDepthFrameBuffer;
|
FrameBuffer m_ShieldDepthFrameBuffer;
|
||||||
GLuint m_BloomTexture;
|
GLuint m_BloomTexture = 0;
|
||||||
GLuint m_SceneTexture;
|
GLuint m_SceneTexture = 0;
|
||||||
GLuint m_DepthBuffer;
|
GLuint m_DepthBuffer = 0;
|
||||||
GLuint m_ShieldBuffer;
|
GLuint m_ShieldBuffer = 0;
|
||||||
GLuint m_CubeMapTexture;
|
GLuint m_CubeMapTexture = 0;
|
||||||
GLuint m_FullBlurredTexture;
|
GLuint m_FullBlurredTexture;
|
||||||
GLuint m_CombinedTexture; //This can be removed for less memory usage, just set m_sceneTexture to the return from m_BlurHUDPass.CombineTextures
|
GLuint m_CombinedTexture; //This can be removed for less memory usage, just set m_sceneTexture to the return from m_BlurHUDPass.CombineTextures
|
||||||
|
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ struct ModelJob : RenderJob
|
|||||||
Color = modelComponent["Color"];
|
Color = modelComponent["Color"];
|
||||||
GlowIntensity = ((double)modelComponent["GlowIntensity"]);
|
GlowIntensity = ((double)modelComponent["GlowIntensity"]);
|
||||||
Entity = modelComponent.EntityID;
|
Entity = modelComponent.EntityID;
|
||||||
glm::vec3 abspos = Transform::AbsolutePosition(world, modelComponent.EntityID);
|
glm::vec3 abspos = glm::vec3(matrix[3][0], matrix[3][1], matrix[3][2]);
|
||||||
glm::vec3 worldpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1));
|
glm::vec3 worldpos = glm::vec3(camera->ViewMatrix() * glm::vec4(abspos, 1));
|
||||||
Depth = worldpos.z;
|
Depth = worldpos.z;
|
||||||
World = world;
|
World = world;
|
||||||
@@ -164,7 +164,9 @@ struct ModelJob : RenderJob
|
|||||||
bool IsShielded;
|
bool IsShielded;
|
||||||
void CalculateHash() override
|
void CalculateHash() override
|
||||||
{
|
{
|
||||||
Hash = ShaderID << 20 + ModelID << 10 + TextureID;
|
Hash = TextureID;
|
||||||
|
Hash += ModelID << 10;
|
||||||
|
Hash += ShaderID << 20;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ private:
|
|||||||
|
|
||||||
std::unordered_map<glm::ivec2, PickingInfo> m_PickingColorsToEntity;
|
std::unordered_map<glm::ivec2, PickingInfo> m_PickingColorsToEntity;
|
||||||
|
|
||||||
GLuint m_PickingTexture;
|
GLuint m_PickingTexture = 0;
|
||||||
GLuint m_DepthBuffer;
|
GLuint m_DepthBuffer = 0;
|
||||||
|
|
||||||
FrameBuffer m_PickingBuffer;
|
FrameBuffer m_PickingBuffer;
|
||||||
|
|
||||||
|
|||||||
@@ -16,16 +16,15 @@ struct RenderJob
|
|||||||
public:
|
public:
|
||||||
float Depth;
|
float Depth;
|
||||||
|
|
||||||
|
bool operator<(const RenderJob& rhs)
|
||||||
|
{
|
||||||
|
return this->Hash < rhs.Hash;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64_t Hash;
|
uint64_t Hash;
|
||||||
|
|
||||||
virtual void CalculateHash() = 0;
|
virtual void CalculateHash() = 0;
|
||||||
|
|
||||||
bool operator<(const RenderJob& rhs)
|
|
||||||
{
|
|
||||||
return this->Hash < rhs.Hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -37,6 +37,7 @@ public:
|
|||||||
: m_EventBroker(eventBroker)
|
: m_EventBroker(eventBroker)
|
||||||
, m_Config(config)
|
, m_Config(config)
|
||||||
{ }
|
{ }
|
||||||
|
~Renderer();
|
||||||
|
|
||||||
virtual void Initialize() override;
|
virtual void Initialize() override;
|
||||||
virtual void Update(double dt) override;
|
virtual void Update(double dt) override;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ class SSAOPass
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SSAOPass(IRenderer* renderer, ConfigFile* config);
|
SSAOPass(IRenderer* renderer, ConfigFile* config);
|
||||||
~SSAOPass() { };
|
~SSAOPass();
|
||||||
|
|
||||||
void ChangeQuality(int quality);
|
void ChangeQuality(int quality);
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public:
|
|||||||
std::string GetFileName() const;
|
std::string GetFileName() const;
|
||||||
GLuint GetHandle() const;
|
GLuint GetHandle() const;
|
||||||
bool IsCompiled() const;
|
bool IsCompiled() const;
|
||||||
|
static std::string ReadFile(std::string fileName);
|
||||||
|
private:
|
||||||
protected:
|
protected:
|
||||||
GLenum m_ShaderType;
|
GLenum m_ShaderType;
|
||||||
std::string m_FileName;
|
std::string m_FileName;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 PVM;
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout(location = 0) in vec3 Position;
|
||||||
layout(location = 5) in vec4 BoneIndices;
|
layout(location = 5) in vec4 BoneIndices;
|
||||||
@@ -15,7 +13,7 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P * V * M * vec4(Position, 1.0);
|
gl_Position = PVM * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 PVM;
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
uniform mat4 Bones[100];
|
uniform mat4 Bones[100];
|
||||||
|
|
||||||
|
|
||||||
@@ -27,7 +25,7 @@ void main()
|
|||||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_Position = P*V*M*boneTransform * vec4(Position, 1.0);
|
gl_Position = PVM*boneTransform * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = vec3(0.0);
|
Output.Position = vec3(0.0);
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
|
|
||||||
|
uniform mat4 VM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -11,7 +12,7 @@ uniform vec2 ScreenDimensions;
|
|||||||
uniform vec4 FillColor;
|
uniform vec4 FillColor;
|
||||||
uniform vec4 AmbientColor;
|
uniform vec4 AmbientColor;
|
||||||
uniform float FillPercentage;
|
uniform float FillPercentage;
|
||||||
uniform float GlowIntensity = 10;
|
uniform float GlowIntensity;
|
||||||
uniform vec3 CameraPosition;
|
uniform vec3 CameraPosition;
|
||||||
uniform int SSAOQuality;
|
uniform int SSAOQuality;
|
||||||
|
|
||||||
@@ -131,7 +132,7 @@ void main()
|
|||||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
||||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
||||||
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
||||||
vec4 position = V * M * vec4(Input.Position, 1.0);
|
vec4 position = VM * vec4(Input.Position, 1.0);
|
||||||
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
|
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
|
||||||
normal = normalize(normal);
|
normal = normalize(normal);
|
||||||
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
||||||
@@ -182,6 +183,7 @@ void main()
|
|||||||
color_result += FillColor;
|
color_result += FillColor;
|
||||||
}
|
}
|
||||||
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
sceneColor = vec4(color_result.xyz, clamp(color_result.a, 0, 1));
|
||||||
|
//sceneColor = CommonUniforms.testColour;
|
||||||
//sceneColor = vec4(reflectionColor.xyz, 1);
|
//sceneColor = vec4(reflectionColor.xyz, 1);
|
||||||
color_result.xyz += glowTexel.xyz*GlowIntensity;
|
color_result.xyz += glowTexel.xyz*GlowIntensity;
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
uniform mat4 PVM;
|
||||||
|
uniform mat4 TIM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -22,8 +23,8 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = PVM * vec4(Position, 1.0);
|
||||||
mat4 TIM = transpose(inverse(M));
|
//mat4 TIM = transpose(inverse(M));
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
Output.Normal = vec3(TIM * vec4(Normal, 0.0));
|
Output.Normal = vec3(TIM * vec4(Normal, 0.0));
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
|
|
||||||
|
uniform mat4 VM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -11,7 +12,7 @@ uniform vec2 ScreenDimensions;
|
|||||||
uniform vec4 FillColor;
|
uniform vec4 FillColor;
|
||||||
uniform vec4 AmbientColor;
|
uniform vec4 AmbientColor;
|
||||||
uniform float FillPercentage;
|
uniform float FillPercentage;
|
||||||
uniform float GlowIntensity = 10;
|
uniform float GlowIntensity;
|
||||||
uniform vec3 CameraPosition;
|
uniform vec3 CameraPosition;
|
||||||
uniform int SSAOQuality;
|
uniform int SSAOQuality;
|
||||||
|
|
||||||
@@ -138,7 +139,7 @@ void main()
|
|||||||
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
|
||||||
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
|
||||||
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
|
||||||
vec4 position = V * M * vec4(Input.Position, 1.0);
|
vec4 position = VM * vec4(Input.Position, 1.0);
|
||||||
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
|
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
|
||||||
normal = normalize(normal);
|
normal = normalize(normal);
|
||||||
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
|
uniform mat4 PVM;
|
||||||
|
uniform mat4 TIM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -34,7 +36,7 @@ void main()
|
|||||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_Position = P*V*M*boneTransform * vec4(Position, 1.0);
|
gl_Position = PVM*boneTransform * vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
|
|
||||||
|
uniform mat4 VM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -189,7 +190,7 @@ void main()
|
|||||||
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
||||||
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
||||||
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
||||||
vec4 position = V * M * vec4(Input.Position, 1.0);
|
vec4 position = VM * vec4(Input.Position, 1.0);
|
||||||
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
||||||
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
||||||
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#define MIN_AMBIENT_LIGHT 0.3
|
#define MIN_AMBIENT_LIGHT 0.3
|
||||||
|
|
||||||
|
uniform mat4 VM;
|
||||||
uniform mat4 M;
|
uniform mat4 M;
|
||||||
uniform mat4 V;
|
uniform mat4 V;
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
@@ -190,7 +191,7 @@ void main()
|
|||||||
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
|
||||||
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
|
||||||
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
SpecularUVRepeat1, SpecularUVRepeat2, SpecularUVRepeat3);
|
||||||
vec4 position = V * M * vec4(Input.Position, 1.0);
|
vec4 position = VM * vec4(Input.Position, 1.0);
|
||||||
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
//vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate, SplatMapTexture);
|
||||||
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
vec4 normal = V * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
|
||||||
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
uniform mat4 PVM;
|
||||||
uniform mat4 M;
|
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout(location = 0) in vec3 Position;
|
||||||
layout(location = 1) in vec3 Normal;
|
layout(location = 1) in vec3 Normal;
|
||||||
@@ -16,6 +13,6 @@ out VertexData{
|
|||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
gl_Position = P*V*M * vec4(Position, 1.0);
|
gl_Position = PVM * vec4(Position, 1.0);
|
||||||
Output.Position = Position, 1.0;
|
Output.Position = Position, 1.0;
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
uniform mat4 PVM;
|
||||||
uniform mat4 M;
|
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
uniform mat4 Bones[100];
|
uniform mat4 Bones[100];
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout(location = 0) in vec3 Position;
|
||||||
@@ -27,6 +24,6 @@ void main()
|
|||||||
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
+ BoneWeights[3] * Bones[int(BoneIndices[3])];
|
||||||
}
|
}
|
||||||
|
|
||||||
gl_Position = P*V*M*boneTransform * vec4(Position, 1.0);
|
gl_Position = PVM*boneTransform * vec4(Position, 1.0);
|
||||||
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
Output.Position = (boneTransform * vec4(Position, 1.0)).xyz;
|
||||||
}
|
}
|
||||||
@@ -3,8 +3,6 @@
|
|||||||
uniform vec4 Color;
|
uniform vec4 Color;
|
||||||
uniform vec4 FillColor;
|
uniform vec4 FillColor;
|
||||||
uniform float FillPercentage;
|
uniform float FillPercentage;
|
||||||
uniform mat4 M;
|
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
uniform mat4 P;
|
||||||
|
|
||||||
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
layout (binding = 1) uniform sampler2D DiffuseTexture;
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#version 430
|
#version 430
|
||||||
|
|
||||||
uniform mat4 M;
|
uniform mat4 PVM;
|
||||||
uniform mat4 V;
|
|
||||||
uniform mat4 P;
|
|
||||||
|
|
||||||
layout(location = 0) in vec3 Position;
|
layout(location = 0) in vec3 Position;
|
||||||
layout(location = 1) in vec3 Normal;
|
layout(location = 1) in vec3 Normal;
|
||||||
@@ -17,7 +15,7 @@ out VertexData{
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
|
|
||||||
gl_Position = P * V * M * vec4(Position, 1.0);
|
gl_Position = PVM* vec4(Position, 1.0);
|
||||||
|
|
||||||
Output.Position = Position;
|
Output.Position = Position;
|
||||||
Output.TextureCoordinate = TextureCoords;
|
Output.TextureCoordinate = TextureCoords;
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
vec4 CalcNormalMappedValue(vec3 normal, vec3 tangent, vec3 bitangent, vec2 textureCoordinate, sampler2D normalMap)
|
||||||
|
{
|
||||||
|
mat3 TBN = mat3(tangent, bitangent, normal);
|
||||||
|
vec3 NormalMap = texture(normalMap, textureCoordinate).xyz * 2.0 - vec3(1.0);
|
||||||
|
return vec4(TBN * normalize(NormalMap), 0.0);
|
||||||
|
}
|
||||||
@@ -9,6 +9,11 @@ DrawBloomPass::DrawBloomPass(IRenderer* renderer, ConfigFile* config)
|
|||||||
ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2));
|
ChangeQuality(m_Config->Get<int>("GLOW.Quality", 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawBloomPass::~DrawBloomPass() {
|
||||||
|
CommonFunctions::DeleteTexture(&m_GaussianTexture_horiz);
|
||||||
|
CommonFunctions::DeleteTexture(&m_GaussianTexture_vert);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawBloomPass::InitializeTextures()
|
void DrawBloomPass::InitializeTextures()
|
||||||
{
|
{
|
||||||
m_BlackTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/Black.png");
|
m_BlackTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/Black.png");
|
||||||
|
|||||||
@@ -12,6 +12,14 @@ DrawFinalPass::DrawFinalPass(IRenderer* renderer, LightCullingPass* lightCulling
|
|||||||
InitializeFrameBuffers();
|
InitializeFrameBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DrawFinalPass::~DrawFinalPass(){
|
||||||
|
CommonFunctions::DeleteTexture(&m_BloomTexture);
|
||||||
|
CommonFunctions::DeleteTexture(&m_SceneTexture);
|
||||||
|
CommonFunctions::DeleteTexture(&m_DepthBuffer);
|
||||||
|
CommonFunctions::DeleteTexture(&m_ShieldBuffer);
|
||||||
|
CommonFunctions::DeleteTexture(&m_CubeMapTexture);
|
||||||
|
}
|
||||||
|
|
||||||
void DrawFinalPass::InitializeTextures()
|
void DrawFinalPass::InitializeTextures()
|
||||||
{
|
{
|
||||||
m_WhiteTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/White.png");
|
m_WhiteTexture = CommonFunctions::TryLoadResource<Texture, false>("Textures/Core/White.png");
|
||||||
@@ -351,6 +359,8 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle();
|
GLuint explosionSkinnedHandle = m_ExplosionEffectSkinnedProgram->GetHandle();
|
||||||
GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
|
GLuint explosionSplatMapSkinnedHandle = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
|
||||||
GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
|
GLuint forwardSplatMapSkinnedHandle = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
|
||||||
|
GLuint lastShader = 0;
|
||||||
|
unsigned int lastModel = 0;
|
||||||
|
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||||
@@ -367,9 +377,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
{
|
{
|
||||||
if (explosionEffectJob->Model->IsSkinned()) {
|
if (explosionEffectJob->Model->IsSkinned()) {
|
||||||
|
if (lastShader != m_ExplosionEffectSkinnedProgram->GetHandle()) {
|
||||||
m_ExplosionEffectSkinnedProgram->Bind();
|
m_ExplosionEffectSkinnedProgram->Bind();
|
||||||
GLERROR("Bind ExplosionEffectSkinned program");
|
lastShader = m_ExplosionEffectSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSkinned program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSkinned Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -389,8 +407,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ExplosionEffectProgram->Bind();
|
if (lastShader != m_ExplosionEffectProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffect program");
|
m_ExplosionEffectProgram->Bind();
|
||||||
|
lastShader = m_ExplosionEffectProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffect program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffect Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -404,8 +431,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
if (explosionEffectJob->Model->IsSkinned()) {
|
if (explosionEffectJob->Model->IsSkinned()) {
|
||||||
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
if (lastShader != m_ExplosionEffectSplatMapSkinnedProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
||||||
|
lastShader = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMapSkinned Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -421,9 +457,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ExplosionEffectSplatMapProgram->Bind();
|
if (lastShader != m_ExplosionEffectSplatMapProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
m_ExplosionEffectSplatMapProgram->Bind();
|
||||||
//bind uniforms
|
lastShader = m_ExplosionEffectSplatMapProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -436,8 +480,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
//draw
|
//draw
|
||||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
if (lastModel != explosionEffectJob->ModelID) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||||
|
lastModel = explosionEffectJob->ModelID;
|
||||||
|
}
|
||||||
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
GLERROR("explosion effect end");
|
GLERROR("explosion effect end");
|
||||||
@@ -451,8 +498,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
{
|
{
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_ForwardPlusSkinnedProgram->Bind();
|
if (lastShader != m_ForwardPlusSkinnedProgram->GetHandle()) {
|
||||||
GLERROR("Bind ForwardPlusSkinnedProgram");
|
m_ForwardPlusSkinnedProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind ForwardPlusSkinnedProgram program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ForwardPlusSkinnedProgram Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -470,8 +526,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ForwardPlusProgram->Bind();
|
if (lastShader != m_ForwardPlusProgram->GetHandle()) {
|
||||||
GLERROR("Bind ForwardPlusProgram");
|
m_ForwardPlusProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusProgram->GetHandle();
|
||||||
|
GLERROR("Bind ForwardPlusProgram program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ForwardPlusProgram Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardHandle, modelJob, scene);
|
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -485,8 +550,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
if (lastShader != m_ForwardPlusSplatMapSkinnedProgram->GetHandle()) {
|
||||||
GLERROR("Bind SplatMap program");
|
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind SkinnedSplatMapProgram program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind SkinnedSplatMapProgram Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene);
|
BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -502,8 +576,17 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ForwardPlusSplatMapProgram->Bind();
|
if (lastShader != m_ForwardPlusSplatMapProgram->GetHandle()) {
|
||||||
GLERROR("Bind SplatMap program");
|
m_ForwardPlusSplatMapProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSplatMapProgram->GetHandle();
|
||||||
|
GLERROR("Bind SplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind SplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSplatMapHandle, modelJob, scene);
|
BindModelUniforms(forwardSplatMapHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -514,8 +597,11 @@ void DrawFinalPass::DrawModelRenderQueues(std::list<std::shared_ptr<RenderJob>>&
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//draw
|
//draw
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
if (lastModel != modelJob->ModelID) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
lastModel = modelJob->ModelID;
|
||||||
|
}
|
||||||
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)));
|
||||||
if (GLERROR("models end")) {
|
if (GLERROR("models end")) {
|
||||||
continue;
|
continue;
|
||||||
@@ -544,6 +630,8 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
GLuint explosionSkinnedShieldCheckHandle = m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle();
|
GLuint explosionSkinnedShieldCheckHandle = m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle();
|
||||||
GLuint explosionSplatMapSkinnedShieldCheckHandle = m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle();
|
GLuint explosionSplatMapSkinnedShieldCheckHandle = m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||||
GLuint forwardSplatMapSkinnedShieldCheckHandle = m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle();
|
GLuint forwardSplatMapSkinnedShieldCheckHandle = m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||||
|
GLuint lastShader = 0;
|
||||||
|
unsigned int lastModel = 0;
|
||||||
|
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, m_LightCullingPass->LightSSBO());
|
||||||
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, m_LightCullingPass->LightGridSSBO());
|
||||||
@@ -564,9 +652,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
{
|
{
|
||||||
if (explosionEffectJob->Model->IsSkinned()) {
|
if (explosionEffectJob->Model->IsSkinned()) {
|
||||||
|
if (lastShader != m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle()) {
|
||||||
m_ExplosionEffectSkinnedShieldCheckProgram->Bind();
|
m_ExplosionEffectSkinnedShieldCheckProgram->Bind();
|
||||||
GLERROR("Bind ExplosionEffectSkinned program");
|
lastShader = m_ExplosionEffectSkinnedShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSkinned program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSkinned Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSkinnedShieldCheckHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSkinnedShieldCheckHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -585,8 +681,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ExplosionEffectShieldCheckProgram->Bind();
|
if (lastShader != m_ExplosionEffectShieldCheckProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffect program");
|
m_ExplosionEffectShieldCheckProgram->Bind();
|
||||||
|
lastShader = m_ExplosionEffectShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffect program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffect Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionShieldCheckHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionShieldCheckHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -601,8 +706,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
if (explosionEffectJob->Model->IsSkinned()) {
|
if (explosionEffectJob->Model->IsSkinned()) {
|
||||||
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind();
|
if (lastShader != m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->Bind();
|
||||||
|
lastShader = m_ExplosionEffectSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSplatMapSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMapSkinned Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSplatMapSkinnedShieldCheckHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -619,9 +733,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ExplosionEffectSplatMapShieldCheckProgram->Bind();
|
if (lastShader != m_ExplosionEffectSplatMapShieldCheckProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
m_ExplosionEffectSplatMapShieldCheckProgram->Bind();
|
||||||
//bind uniforms
|
lastShader = m_ExplosionEffectSplatMapShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSplatMapShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSplatMapShieldCheckHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSplatMapShieldCheckHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -637,9 +759,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
{
|
{
|
||||||
if (explosionEffectJob->Model->IsSkinned()) {
|
if (explosionEffectJob->Model->IsSkinned()) {
|
||||||
|
if (lastShader != m_ExplosionEffectSkinnedProgram->GetHandle()) {
|
||||||
m_ExplosionEffectSkinnedProgram->Bind();
|
m_ExplosionEffectSkinnedProgram->Bind();
|
||||||
GLERROR("Bind ExplosionEffectSkinned program");
|
lastShader = m_ExplosionEffectSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSkinned program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSkinned Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSkinnedHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -657,8 +787,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(explosionSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ExplosionEffectProgram->Bind();
|
if (lastShader != m_ExplosionEffectProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffect program");
|
m_ExplosionEffectProgram->Bind();
|
||||||
|
lastShader = m_ExplosionEffectProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffect program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffect Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -672,8 +811,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
if (explosionEffectJob->Model->IsSkinned()) {
|
if (explosionEffectJob->Model->IsSkinned()) {
|
||||||
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
if (lastShader != m_ExplosionEffectSplatMapSkinnedProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffectSplatMapSkinned program");
|
m_ExplosionEffectSplatMapSkinnedProgram->Bind();
|
||||||
|
lastShader = m_ExplosionEffectSplatMapSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSkinnedSplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSkinnedSplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSplatMapSkinnedHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -689,9 +837,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ExplosionEffectSplatMapProgram->Bind();
|
if (lastShader != m_ExplosionEffectSplatMapProgram->GetHandle()) {
|
||||||
GLERROR("Bind ExplosionEffectSplatMap program");
|
m_ExplosionEffectSplatMapProgram->Bind();
|
||||||
//bind uniforms
|
lastShader = m_ExplosionEffectSplatMapProgram->GetHandle();
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(explosionSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(explosionSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(explosionSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(explosionSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ExplosionEffectSplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene);
|
BindExplosionUniforms(explosionSplatMapHandle, explosionEffectJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -705,8 +861,11 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
//draw
|
//draw
|
||||||
glBindVertexArray(explosionEffectJob->Model->VAO);
|
if (lastModel != explosionEffectJob->ModelID) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
glBindVertexArray(explosionEffectJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, explosionEffectJob->Model->ElementBuffer);
|
||||||
|
lastModel = explosionEffectJob->ModelID;
|
||||||
|
}
|
||||||
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
glDrawElements(GL_TRIANGLES, explosionEffectJob->EndIndex - explosionEffectJob->StartIndex + 1, GL_UNSIGNED_INT, (void*)(explosionEffectJob->StartIndex*sizeof(unsigned int)));
|
||||||
glEnable(GL_CULL_FACE);
|
glEnable(GL_CULL_FACE);
|
||||||
GLERROR("explosion effect end");
|
GLERROR("explosion effect end");
|
||||||
@@ -721,8 +880,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
{
|
{
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_ForwardPlusSkinnedShieldCheckProgram->Bind();
|
if (lastShader != m_ForwardPlusSkinnedShieldCheckProgram->GetHandle()) {
|
||||||
GLERROR("Bind ForwardPlusSkinnedProgram");
|
m_ForwardPlusSkinnedShieldCheckProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSkinnedShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind ForwardPlusSkinnedProgram program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ForwardPlusSkinnedProgram Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSkinnedShieldCheckHandle, modelJob, scene);
|
BindModelUniforms(forwardSkinnedShieldCheckHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -741,8 +909,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ForwardPlusShieldCheckProgram->Bind();
|
if (lastShader != m_ForwardPlusShieldCheckProgram->GetHandle()) {
|
||||||
GLERROR("Bind ForwardPlusProgram");
|
m_ForwardPlusShieldCheckProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind ForwardPlusProgram program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ForwardPlusProgram Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardShieldCheckHandle, modelJob, scene);
|
BindModelUniforms(forwardShieldCheckHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -756,8 +933,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Bind();
|
if (lastShader != m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle()) {
|
||||||
GLERROR("Bind SplatMap program");
|
m_ForwardPlusSplatMapSkinnedShieldCheckProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSplatMapSkinnedShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind ForwardPlusProgramSplatMapSkinned program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ForwardPlusProgramSplatMapSkinned Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSplatMapSkinnedShieldCheckHandle, modelJob, scene);
|
BindModelUniforms(forwardSplatMapSkinnedShieldCheckHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -773,8 +959,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedShieldCheckHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ForwardPlusSplatMapShieldCheckProgram->Bind();
|
if (lastShader != m_ForwardPlusSplatMapShieldCheckProgram->GetHandle()) {
|
||||||
GLERROR("Bind SplatMap program");
|
m_ForwardPlusSplatMapShieldCheckProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSplatMapShieldCheckProgram->GetHandle();
|
||||||
|
GLERROR("Bind SplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSplatShieldCheckHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatShieldCheckHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatShieldCheckHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSplatShieldCheckHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSplatShieldCheckHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind SplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSplatShieldCheckHandle, modelJob, scene);
|
BindModelUniforms(forwardSplatShieldCheckHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -790,8 +985,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SingleTextures:
|
case RawModel::MaterialType::SingleTextures:
|
||||||
{
|
{
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_ForwardPlusSkinnedProgram->Bind();
|
if (lastShader != m_ForwardPlusSkinnedProgram->GetHandle()) {
|
||||||
GLERROR("Bind ForwardPlusSkinnedProgram");
|
m_ForwardPlusSkinnedProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind ForwardPlusSkinnedProgram program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ForwardPlusSkinnedProgram Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
BindModelUniforms(forwardSkinnedHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -810,8 +1014,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ForwardPlusProgram->Bind();
|
if (lastShader != m_ForwardPlusProgram->GetHandle()) {
|
||||||
GLERROR("Bind ForwardPlusProgram");
|
m_ForwardPlusProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusProgram->GetHandle();
|
||||||
|
GLERROR("Bind ForwardPlusProgram program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind ForwardPlusProgram Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardHandle, modelJob, scene);
|
BindModelUniforms(forwardHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -825,8 +1038,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
case RawModel::MaterialType::SplatMapping:
|
case RawModel::MaterialType::SplatMapping:
|
||||||
{
|
{
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
if (lastShader != m_ForwardPlusSplatMapSkinnedProgram->GetHandle()) {
|
||||||
GLERROR("Bind SplatMap program");
|
m_ForwardPlusSplatMapSkinnedProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSplatMapSkinnedProgram->GetHandle();
|
||||||
|
GLERROR("Bind SplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSplatMapSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSplatMapSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSplatMapSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind SplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene);
|
BindModelUniforms(forwardSplatMapSkinnedHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -842,8 +1064,17 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(forwardSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_ForwardPlusSplatMapProgram->Bind();
|
if (lastShader != m_ForwardPlusSplatMapProgram->GetHandle()) {
|
||||||
GLERROR("Bind SplatMap program");
|
m_ForwardPlusSplatMapProgram->Bind();
|
||||||
|
lastShader = m_ForwardPlusSplatMapProgram->GetHandle();
|
||||||
|
GLERROR("Bind SplatMap program");
|
||||||
|
glUniform1i(glGetUniformLocation(forwardSplatMapHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(forwardSplatMapHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(forwardSplatMapHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(forwardSplatMapHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind SplatMap Uniforms");
|
||||||
|
}
|
||||||
//bind uniforms
|
//bind uniforms
|
||||||
BindModelUniforms(forwardSplatMapHandle, modelJob, scene);
|
BindModelUniforms(forwardSplatMapHandle, modelJob, scene);
|
||||||
//bind textures
|
//bind textures
|
||||||
@@ -855,8 +1086,11 @@ void DrawFinalPass::DrawModelRenderQueuesWithShieldCheck(std::list<std::shared_p
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//draw
|
//draw
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
if (lastModel != modelJob->ModelID) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
lastModel = modelJob->ModelID;
|
||||||
|
}
|
||||||
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)));
|
||||||
if (GLERROR("models end")) {
|
if (GLERROR("models end")) {
|
||||||
continue;
|
continue;
|
||||||
@@ -961,17 +1195,26 @@ void DrawFinalPass::DrawShieldedModelRenderQueue(std::list<std::shared_ptr<Rende
|
|||||||
|
|
||||||
void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob>>& jobs, RenderScene& scene)
|
||||||
{
|
{
|
||||||
|
GLuint shaderSkinnedHandle = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
||||||
|
GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle();
|
||||||
|
GLuint lastShader = 0;
|
||||||
for (auto &job : jobs) {
|
for (auto &job : jobs) {
|
||||||
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
auto modelJob = std::dynamic_pointer_cast<ModelJob>(job);
|
||||||
|
|
||||||
if(modelJob->Model->IsSkinned()) {
|
if(modelJob->Model->IsSkinned()) {
|
||||||
m_FillDepthStencilBufferSkinnedProgram->Bind();
|
if (lastShader != m_FillDepthStencilBufferSkinnedProgram->GetHandle()) {
|
||||||
GLuint shaderHandle = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
m_FillDepthStencilBufferSkinnedProgram->Bind();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
lastShader = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniform1i(glGetUniformLocation(shaderSkinnedHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform2f(glGetUniformLocation(shaderSkinnedHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderSkinnedHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind Uniforms 1");
|
||||||
|
}
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||||
|
GLERROR("Bind PVM uniform");
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
if (modelJob->BlendTree != nullptr) {
|
if (modelJob->BlendTree != nullptr) {
|
||||||
@@ -982,11 +1225,19 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_FillDepthStencilBufferProgram->Bind();
|
if (lastShader != m_FillDepthStencilBufferProgram->GetHandle()) {
|
||||||
GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle();
|
m_FillDepthStencilBufferProgram->Bind();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
lastShader = m_FillDepthStencilBufferProgram->GetHandle();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
||||||
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()));
|
||||||
|
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||||
|
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
||||||
|
GLERROR("Bind Uniforms 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||||
|
GLERROR("Bind PVM uniform");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1008,6 +1259,9 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
|
|
||||||
GLuint shaderHandle = m_SpriteProgram->GetHandle();
|
GLuint shaderHandle = m_SpriteProgram->GetHandle();
|
||||||
|
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||||
|
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
|
||||||
|
|
||||||
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;
|
RenderState jobState;
|
||||||
@@ -1016,10 +1270,7 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
if(spriteJob->Depth == 0) {
|
if(spriteJob->Depth == 0) {
|
||||||
jobState.Disable(GL_DEPTH_TEST);
|
jobState.Disable(GL_DEPTH_TEST);
|
||||||
}
|
}
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->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()));
|
|
||||||
glUniform3fv(glGetUniformLocation(shaderHandle, "CameraPos"), 1, glm::value_ptr(scene.Camera->Position()));
|
|
||||||
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);
|
||||||
@@ -1049,17 +1300,14 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
|
|||||||
|
|
||||||
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<ExplosionEffectJob>& job, RenderScene& scene)
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
|
||||||
GLERROR("Bind 1 uniform");
|
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
GLERROR("Bind 2 uniform");
|
GLERROR("Bind 2 uniform");
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * job->Matrix));
|
||||||
GLERROR("Bind 3 uniform");
|
GLERROR("Bind PVM uniform");
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "VM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix() * job->Matrix));
|
||||||
GLERROR("Bind 4 uniform");
|
GLERROR("Bind VM uniform");
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "TIM"), 1, GL_FALSE, glm::value_ptr(glm::transpose(glm::inverse(job->Matrix))));
|
||||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
GLERROR("Bind TIM uniform");
|
||||||
GLERROR("Bind 5 uniform");
|
|
||||||
|
|
||||||
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");
|
||||||
@@ -1090,29 +1338,21 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
|||||||
GLERROR("Bind 18 uniform");
|
GLERROR("Bind 18 uniform");
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
glUniform1f(glGetUniformLocation(shaderHandle, "FillPercentage"), job->FillPercentage);
|
||||||
GLERROR("Bind 19 uniform");
|
GLERROR("Bind 19 uniform");
|
||||||
glUniform4fv(glGetUniformLocation(shaderHandle, "AmbientColor"), 1, glm::value_ptr(scene.AmbientColor));
|
|
||||||
GLERROR("Bind 20 uniform");
|
|
||||||
glUniform1f(glGetUniformLocation(shaderHandle, "GlowIntensity"), job->GlowIntensity);
|
glUniform1f(glGetUniformLocation(shaderHandle, "GlowIntensity"), job->GlowIntensity);
|
||||||
GLERROR("END");
|
GLERROR("END");
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<ModelJob>& job, RenderScene& scene)
|
||||||
{
|
{
|
||||||
glUniform1i(glGetUniformLocation(shaderHandle, "SSAOQuality"), m_SSAOPass->TextureQuality());
|
|
||||||
GLERROR("Bind 1 uniform");
|
|
||||||
GLint Location_M = glGetUniformLocation(shaderHandle, "M");
|
GLint Location_M = glGetUniformLocation(shaderHandle, "M");
|
||||||
glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
glUniformMatrix4fv(Location_M, 1, GL_FALSE, glm::value_ptr(job->Matrix));
|
||||||
GLERROR("Bind 2 uniform");
|
GLERROR("Bind 2 uniform");
|
||||||
GLint Location_V = glGetUniformLocation(shaderHandle, "V");
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * job->Matrix));
|
||||||
glUniformMatrix4fv(Location_V, 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
GLERROR("Bind PVM uniform");
|
||||||
GLERROR("Bind 3 uniform");
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "VM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix() * job->Matrix));
|
||||||
GLint Location_P = glGetUniformLocation(shaderHandle, "P");
|
GLERROR("Bind VM uniform");
|
||||||
glUniformMatrix4fv(Location_P, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "TIM"), 1, GL_FALSE, glm::value_ptr(glm::transpose(glm::inverse(job->Matrix))));
|
||||||
GLERROR("Bind 4 uniform");
|
GLERROR("Bind TIM uniform");
|
||||||
|
|
||||||
GLint Location_ScreenDimensions = glGetUniformLocation(shaderHandle, "ScreenDimensions");
|
|
||||||
glUniform2f(Location_ScreenDimensions, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
|
||||||
GLERROR("Bind 5 uniform");
|
|
||||||
|
|
||||||
GLint Location_FillPercentage = glGetUniformLocation(shaderHandle, "FillPercentage");
|
GLint Location_FillPercentage = glGetUniformLocation(shaderHandle, "FillPercentage");
|
||||||
glUniform1f(Location_FillPercentage, job->FillPercentage);
|
glUniform1f(Location_FillPercentage, job->FillPercentage);
|
||||||
@@ -1125,11 +1365,6 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
|
|||||||
GLERROR("Bind 8 uniform");
|
GLERROR("Bind 8 uniform");
|
||||||
GLint Location_Color = glGetUniformLocation(shaderHandle, "Color");
|
GLint Location_Color = glGetUniformLocation(shaderHandle, "Color");
|
||||||
glUniform4fv(Location_Color, 1, glm::value_ptr(job->Color));
|
glUniform4fv(Location_Color, 1, glm::value_ptr(job->Color));
|
||||||
GLERROR("Bind 9 uniform");
|
|
||||||
GLint Location_AmbientColor = glGetUniformLocation(shaderHandle, "AmbientColor");
|
|
||||||
glUniform4fv(Location_AmbientColor, 1, glm::value_ptr(scene.AmbientColor));
|
|
||||||
|
|
||||||
GLERROR("Bind 10 uniform");
|
|
||||||
GLint Location_GlowIntensity = glGetUniformLocation(shaderHandle, "GlowIntensity");
|
GLint Location_GlowIntensity = glGetUniformLocation(shaderHandle, "GlowIntensity");
|
||||||
|
|
||||||
glUniform1f(Location_GlowIntensity, job->GlowIntensity);
|
glUniform1f(Location_GlowIntensity, job->GlowIntensity);
|
||||||
|
|||||||
@@ -12,7 +12,8 @@ PickingPass::PickingPass(IRenderer* renderer, EventBroker* eb)
|
|||||||
|
|
||||||
PickingPass::~PickingPass()
|
PickingPass::~PickingPass()
|
||||||
{
|
{
|
||||||
|
CommonFunctions::DeleteTexture(&m_PickingTexture);
|
||||||
|
CommonFunctions::DeleteTexture(&m_DepthBuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -61,8 +62,9 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
//TODO: Render: Add code for more jobs than modeljobs.
|
//TODO: Render: Add code for more jobs than modeljobs.
|
||||||
GLuint shaderHandle = m_PickingProgram->GetHandle();
|
GLuint shaderHandle = m_PickingProgram->GetHandle();
|
||||||
GLuint shaderSkinnedHandle = m_PickingSkinnedProgram->GetHandle();
|
GLuint shaderSkinnedHandle = m_PickingSkinnedProgram->GetHandle();
|
||||||
|
GLuint lastShader = 0;
|
||||||
|
unsigned int lastModel = 0;
|
||||||
m_PickingProgram->Bind();
|
m_PickingProgram->Bind();
|
||||||
|
|
||||||
if (scene.ClearDepth) {
|
if (scene.ClearDepth) {
|
||||||
//glClear(GL_DEPTH_BUFFER_BIT);
|
//glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
state->Disable(GL_DEPTH_TEST);
|
state->Disable(GL_DEPTH_TEST);
|
||||||
@@ -98,10 +100,11 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_PickingSkinnedProgram->Bind();
|
if (lastShader != m_PickingSkinnedProgram->GetHandle()) {
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
m_PickingSkinnedProgram->Bind();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
lastShader = m_PickingSkinnedProgram->GetHandle();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
}
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
@@ -114,15 +117,19 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_PickingProgram->Bind();
|
if (lastShader != m_PickingProgram->GetHandle()) {
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
m_PickingProgram->Bind();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
lastShader = m_PickingProgram->GetHandle();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
}
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
if (lastModel != modelJob->ModelID) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
lastModel = modelJob->ModelID;
|
||||||
|
}
|
||||||
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,10 +215,11 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
if (modelJob->Model->IsSkinned()) {
|
if (modelJob->Model->IsSkinned()) {
|
||||||
m_PickingSkinnedProgram->Bind();
|
if (lastShader != m_PickingSkinnedProgram->GetHandle()) {
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
m_PickingSkinnedProgram->Bind();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
lastShader = m_PickingSkinnedProgram->GetHandle();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
}
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||||
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderSkinnedHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
std::vector<glm::mat4> frameBones;
|
std::vector<glm::mat4> frameBones;
|
||||||
@@ -224,19 +232,24 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "Bones"), frameBones.size(), GL_FALSE, glm::value_ptr(frameBones[0]));
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
m_PickingProgram->Bind();
|
if (lastShader != m_PickingProgram->GetHandle()) {
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
|
m_PickingProgram->Bind();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
|
lastShader = m_PickingProgram->GetHandle();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
}
|
||||||
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
|
||||||
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
}
|
}
|
||||||
|
|
||||||
glBindVertexArray(modelJob->Model->VAO);
|
if (lastModel != modelJob->ModelID) {
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
glBindVertexArray(modelJob->Model->VAO);
|
||||||
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, modelJob->Model->ElementBuffer);
|
||||||
|
lastModel = modelJob->ModelID;
|
||||||
|
}
|
||||||
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_PickingProgram->Bind();
|
||||||
for (auto& job : scene.Jobs.SpriteJob) {
|
for (auto& job : scene.Jobs.SpriteJob) {
|
||||||
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
auto spriteJob = std::dynamic_pointer_cast<SpriteJob>(job);
|
||||||
if (!spriteJob->Pickable) {
|
if (!spriteJob->Pickable) {
|
||||||
@@ -271,14 +284,11 @@ void PickingPass::Draw(RenderScene& scene)
|
|||||||
|
|
||||||
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
m_PickingColorsToEntity[glm::ivec2(pickColor[0], pickColor[1])] = pickInfo;
|
||||||
|
|
||||||
m_PickingProgram->Bind();
|
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
|
||||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(spriteJob->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])));
|
glUniform2fv(glGetUniformLocation(shaderHandle, "PickingColor"), 1, glm::value_ptr(glm::vec2(pickColor[0], pickColor[1])));
|
||||||
|
|
||||||
glBindVertexArray(spriteJob->Model->VAO);
|
glBindVertexArray(spriteJob->Model->VAO);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, spriteJob->Model->ElementBuffer);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, spriteJob->Model->ElementBuffer);
|
||||||
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)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -449,7 +449,7 @@ void RenderSystem::Update(double dt)
|
|||||||
fillModels(scene.Jobs);
|
fillModels(scene.Jobs);
|
||||||
fillPointLights(scene.Jobs.PointLight, m_World);
|
fillPointLights(scene.Jobs.PointLight, m_World);
|
||||||
//TODO: Make sure all objects needed are also sorted.
|
//TODO: Make sure all objects needed are also sorted.
|
||||||
scene.Jobs.OpaqueObjects.sort();
|
scene.Jobs.OpaqueObjects.sort([](auto& a, auto& b) {return *a < *b; });
|
||||||
fillSprites(scene.Jobs.SpriteJob, m_World);
|
fillSprites(scene.Jobs.SpriteJob, m_World);
|
||||||
fillDirectionalLights(scene.Jobs.DirectionalLight, m_World);
|
fillDirectionalLights(scene.Jobs.DirectionalLight, m_World);
|
||||||
fillText(scene.Jobs.Text, m_World);
|
fillText(scene.Jobs.Text, m_World);
|
||||||
|
|||||||
@@ -2,6 +2,19 @@
|
|||||||
|
|
||||||
std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
|
std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
|
||||||
|
|
||||||
|
Renderer::~Renderer() {
|
||||||
|
delete m_PickingPass;
|
||||||
|
delete m_LightCullingPass;
|
||||||
|
delete m_ImGuiRenderPass;
|
||||||
|
delete m_DrawFinalPass;
|
||||||
|
delete m_DrawScreenQuadPass;
|
||||||
|
delete m_DrawBloomPass;
|
||||||
|
delete m_DrawColorCorrectionPass;
|
||||||
|
delete m_SSAOPass;
|
||||||
|
delete m_CubeMapPass;
|
||||||
|
delete m_TextPass;
|
||||||
|
}
|
||||||
|
|
||||||
void Renderer::Initialize()
|
void Renderer::Initialize()
|
||||||
{
|
{
|
||||||
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
|
m_SSAO_Quality = m_Config->Get<int>("SSAO.Quality", 0);
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ SSAOPass::SSAOPass(IRenderer* renderer, ConfigFile* config)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SSAOPass::~SSAOPass() {
|
||||||
|
CommonFunctions::DeleteTexture(&m_SSAOTexture);
|
||||||
|
CommonFunctions::DeleteTexture(&m_SSAOViewSpaceZTexture);
|
||||||
|
CommonFunctions::DeleteTexture(&m_Gaussian_horiz);
|
||||||
|
CommonFunctions::DeleteTexture(&m_Gaussian_vert);
|
||||||
|
}
|
||||||
|
|
||||||
void SSAOPass::ChangeQuality(int quality)
|
void SSAOPass::ChangeQuality(int quality)
|
||||||
{
|
{
|
||||||
if (m_Quality == quality) {
|
if (m_Quality == quality) {
|
||||||
|
|||||||
@@ -4,22 +4,32 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
|
|||||||
{
|
{
|
||||||
LOG_INFO("Compiling shader \"%s\"", fileName.c_str());
|
LOG_INFO("Compiling shader \"%s\"", fileName.c_str());
|
||||||
|
|
||||||
std::string shaderFile;
|
std::string shaderFile = ReadFile(fileName);
|
||||||
std::ifstream in(fileName, std::ios::in);
|
|
||||||
if (!in) {
|
|
||||||
LOG_ERROR("Error: Failed to open shader file \"%s\"", fileName.c_str());
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
in.seekg(0, std::ios::end);
|
|
||||||
shaderFile.resize((int)in.tellg());
|
|
||||||
in.seekg(0, std::ios::beg);
|
|
||||||
in.read(&shaderFile[0], shaderFile.size());
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
GLuint shader = glCreateShader(shaderType);
|
GLuint shader = glCreateShader(shaderType);
|
||||||
if (GLERROR("glCreateShader"))
|
if (GLERROR("glCreateShader"))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
std::size_t startPos = 0;
|
||||||
|
std::size_t SEofNewFile[2];
|
||||||
|
std::string key = "#include";
|
||||||
|
while((startPos = shaderFile.find(key, startPos)) != std::string::npos)
|
||||||
|
{
|
||||||
|
SEofNewFile[0] = shaderFile.find('"', startPos+key.length())+1;
|
||||||
|
SEofNewFile[1] = shaderFile.find('"', SEofNewFile[0]);
|
||||||
|
if (SEofNewFile[0] == std::string::npos || SEofNewFile[1] == std::string::npos)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
std::string replacementFileName = shaderFile.substr(SEofNewFile[0], SEofNewFile[1] - SEofNewFile[0]);
|
||||||
|
std::string replacementString = ReadFile(replacementFileName);
|
||||||
|
size_t firstof = replacementString.find_first_of((char)0);
|
||||||
|
replacementString.erase(firstof, replacementString.size() - firstof);
|
||||||
|
if (replacementString.length() <= 0)
|
||||||
|
return 0;
|
||||||
|
shaderFile.replace(startPos, SEofNewFile[1]+2 - startPos, replacementString + "\n");
|
||||||
|
startPos += replacementString.length(); //This might not be wanted.
|
||||||
|
}
|
||||||
|
|
||||||
const GLchar* shaderFiles = shaderFile.c_str();
|
const GLchar* shaderFiles = shaderFile.c_str();
|
||||||
const GLint length = static_cast<GLint>(shaderFile.length());
|
const GLint length = static_cast<GLint>(shaderFile.length());
|
||||||
glShaderSource(shader, 1, &shaderFiles, &length);
|
glShaderSource(shader, 1, &shaderFiles, &length);
|
||||||
@@ -46,6 +56,24 @@ GLuint Shader::CompileShader(GLenum shaderType, std::string fileName)
|
|||||||
return shader;
|
return shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string Shader::ReadFile(std::string fileName)
|
||||||
|
{
|
||||||
|
std::string shaderFile;
|
||||||
|
std::ifstream in(fileName, std::ios::in);
|
||||||
|
if (!in) {
|
||||||
|
LOG_ERROR("Error: Failed to open shader file \"%s\"", fileName.c_str());
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
in.seekg(0, std::ios::end);
|
||||||
|
shaderFile.resize((int)in.tellg());
|
||||||
|
in.seekg(0, std::ios::beg);
|
||||||
|
in.read(&shaderFile[0], shaderFile.size());
|
||||||
|
in.close();
|
||||||
|
return shaderFile;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Shader::Shader(GLenum shaderType, std::string fileName) : m_ShaderType(shaderType), m_FileName(fileName)
|
Shader::Shader(GLenum shaderType, std::string fileName) : m_ShaderType(shaderType), m_FileName(fileName)
|
||||||
{
|
{
|
||||||
m_ShaderHandle = 0;
|
m_ShaderHandle = 0;
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ ScreenCoords::PixelData ScreenCoords::ToPixelData(float x, float y, FrameBuffer*
|
|||||||
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();
|
PickDataBuffer->Unbind();
|
||||||
|
GLERROR("Unbind Error");
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer);
|
glBindFramebuffer(GL_FRAMEBUFFER, DepthBuffer);
|
||||||
GLERROR("glBindFramebuffer(DepthBuffer) Error");
|
GLERROR("glBindFramebuffer(DepthBuffer) Error");
|
||||||
float depthData;
|
float depthData;
|
||||||
|
|||||||
Reference in New Issue
Block a user