This commit is contained in:
Teejoon
2016-03-08 16:19:56 +01:00
parent 82a7ff2ec3
commit 155d700a44
15 changed files with 104 additions and 49 deletions
+2 -4
View File
@@ -1,8 +1,6 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat4 PVM;
layout(location = 0) in vec3 Position;
layout(location = 5) in vec4 BoneIndices;
@@ -15,7 +13,7 @@ out VertexData{
void main()
{
gl_Position = P * V * M * vec4(Position, 1.0);
gl_Position = PVM * vec4(Position, 1.0);
Output.Position = Position;
}
@@ -1,8 +1,6 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat4 PVM;
uniform mat4 Bones[100];
@@ -27,7 +25,7 @@ void main()
+ 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);
}
+3 -2
View File
@@ -2,6 +2,7 @@
#define MIN_AMBIENT_LIGHT 0.3
uniform mat4 VM;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
@@ -11,7 +12,7 @@ uniform vec2 ScreenDimensions;
uniform vec4 FillColor;
uniform vec4 AmbientColor;
uniform float FillPercentage;
uniform float GlowIntensity = 10;
uniform float GlowIntensity;
uniform vec3 CameraPosition;
uniform int SSAOQuality;
@@ -131,7 +132,7 @@ void main()
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
vec4 position = V * M * vec4(Input.Position, 1.0);
vec4 position = VM * vec4(Input.Position, 1.0);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
+4 -3
View File
@@ -1,5 +1,6 @@
#version 430
uniform mat4 PVM;
uniform mat4 TIM;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
@@ -22,8 +23,8 @@ out VertexData{
void main()
{
gl_Position = P*V*M * vec4(Position, 1.0);
mat4 TIM = transpose(inverse(M));
gl_Position = PVM * vec4(Position, 1.0);
//mat4 TIM = transpose(inverse(M));
Output.Position = Position;
Output.TextureCoordinate = TextureCoords;
Output.Normal = vec3(TIM * vec4(Normal, 0.0));
@@ -2,6 +2,7 @@
#define MIN_AMBIENT_LIGHT 0.3
uniform mat4 VM;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
@@ -11,7 +12,7 @@ uniform vec2 ScreenDimensions;
uniform vec4 FillColor;
uniform vec4 AmbientColor;
uniform float FillPercentage;
uniform float GlowIntensity = 10;
uniform float GlowIntensity;
uniform vec3 CameraPosition;
uniform int SSAOQuality;
@@ -138,7 +139,7 @@ void main()
vec4 diffuseTexel = texture2D(DiffuseTexture, Input.TextureCoordinate * DiffuseUVRepeat);
vec4 glowTexel = texture2D(GlowMapTexture, Input.TextureCoordinate * GlowUVRepeat);
vec4 specularTexel = texture2D(SpecularMapTexture, Input.TextureCoordinate * SpecularUVRepeat);
vec4 position = V * M * vec4(Input.Position, 1.0);
vec4 position = VM * vec4(Input.Position, 1.0);
vec4 normal = V * CalcNormalMappedValue(Input.Normal, Input.Tangent, Input.BiTangent, Input.TextureCoordinate * NormalUVRepeat, NormalMapTexture);
normal = normalize(normal);
//vec4 normal = normalize(V * vec4(Input.Normal, 0.0));
@@ -1,5 +1,7 @@
#version 430
uniform mat4 PVM;
uniform mat4 TIM;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
@@ -34,7 +36,7 @@ void main()
+ 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.TextureCoordinate = TextureCoords;
@@ -2,6 +2,7 @@
#define MIN_AMBIENT_LIGHT 0.3
uniform mat4 VM;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
@@ -189,7 +190,7 @@ void main()
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
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 * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
@@ -2,6 +2,7 @@
#define MIN_AMBIENT_LIGHT 0.3
uniform mat4 VM;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
@@ -190,7 +191,7 @@ void main()
GlowUVRepeat1, GlowUVRepeat2, GlowUVRepeat3);
vec4 specularTexel = CalcBlendedTexel(splatTexel, SpecularMapTexture1, SpecularMapTexture2, SpecularMapTexture3,
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 * CalcBlendedNormal(splatTexel, NormalMapTexture1, NormalMapTexture2, NormalMapTexture3,
NormalUVRepeat1, NormalUVRepeat2, NormalUVRepeat3);
+3 -5
View File
@@ -1,8 +1,6 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
#include "StandarUniform.glsl"
layout(location = PVM_UNIFORM_LOCATION) uniform mat4 PVM;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
@@ -16,6 +14,6 @@ out VertexData{
void main()
{
gl_Position = P*V*M * vec4(Position, 1.0);
gl_Position = PVM * vec4(Position, 1.0);
Output.Position = Position, 1.0;
}
+3 -5
View File
@@ -1,8 +1,6 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
#include "StandarUniform.glsl"
layout(location = PVM_UNIFORM_LOCATION) uniform mat4 PVM;
uniform mat4 Bones[100];
layout(location = 0) in vec3 Position;
@@ -27,6 +25,6 @@ void main()
+ 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;
}
-2
View File
@@ -3,8 +3,6 @@
uniform vec4 Color;
uniform vec4 FillColor;
uniform float FillPercentage;
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
layout (binding = 1) uniform sampler2D DiffuseTexture;
+2 -4
View File
@@ -1,8 +1,6 @@
#version 430
uniform mat4 M;
uniform mat4 V;
uniform mat4 P;
uniform mat4 PVM;
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
@@ -17,7 +15,7 @@ out VertexData{
void main()
{
gl_Position = P * V * M * vec4(Position, 1.0);
gl_Position = PVM* vec4(Position, 1.0);
Output.Position = Position;
Output.TextureCoordinate = TextureCoords;
+55
View File
@@ -0,0 +1,55 @@
//----- SHADER DEFINES -----
#define MAX_BONES 100
#define MIN_AMBIENT_LIGHT 0.3
//----- UNIFORM LOCATION -----
#define PVM_UNIFORM_LOCATION 100
#define VM_UNIFORM_LOCATION 101
#define VP_UNIFORM_LOCATION 102
#define TIM_UNIFORM_LOCATION 103
#define M_UNIFORM_LOCATION 104
#define V_UNIFORM_LOCATION 105
#define P_UNIFORM_LOCATION 106
#define BONES_LOCATION 200
#define AMBIENT_COLOR_UNIFORM_LOCATION 300
#define COLOR_UNIFORM_LOCATION 301
#define DIFFUSE_COLOR_UNIFORM_LOCATION 302
#define SCREEN_DIMENSIONS_UNIFORM_LOCATION 303
#define FILL_COLOR_UNIFORM_LOCATION 304
#define FILL_PERCENTAGE_UNIFORM_LOCATION 305
#define GLOW_INTENSITY_UNIFORM_LOCATION 306
#define CAMERA_POSITION_UNIFORM_LOCATION 306
#define SSAO_QUALITY_UNIFORM_LOCATION 308
#define LOCAL_UNIFORM_LOCATION1;
//----- TEXTURE LOCATION -----
#define SSAO_TEXTURE_LOCATION 0
#define SHADOW_TEXTURE_LOCATION 1
#define LOCAL_TEXTURE_LOCATION1 2
#define LOCAL_TEXTURE_LOCATION2 3
#define LOCAL_TEXTURE_LOCATION3 4
#define LOCAL_TEXTURE_LOCATION4 5
#define LOCAL_TEXTURE_LOCATION5 6
#define LOCAL_TEXTURE_LOCATION6 7
#define LOCAL_TEXTURE_LOCATION7 8
#define LOCAL_TEXTURE_LOCATION8 9
#define LOCAL_TEXTURE_LOCATION9 10
#define LOCAL_TEXTURE_LOCATION10 11
#define LOCAL_TEXTURE_LOCATION11 12
#define LOCAL_TEXTURE_LOCATION12 13
#define LOCAL_TEXTURE_LOCATION13 14
#define LOCAL_TEXTURE_LOCATION14 15
#define LOCAL_TEXTURE_LOCATION15 16
#define LOCAL_TEXTURE_LOCATION16 17
#define LOCAL_TEXTURE_LOCATION17 18
#define LOCAL_TEXTURE_LOCATION18 19
#define LOCAL_TEXTURE_LOCATION19 20
#define LOCAL_TEXTURE_LOCATION20 21
#define LOCAL_TEXTURE_LOCATION21 22
#define LOCAL_TEXTURE_LOCATION22 23
#define LOCAL_TEXTURE_LOCATION23 24
#define LOCAL_TEXTURE_LOCATION24 25
#define LOCAL_TEXTURE_LOCATION25 26
+18 -8
View File
@@ -961,9 +961,8 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
if(modelJob->Model->IsSkinned()) {
m_FillDepthStencilBufferSkinnedProgram->Bind();
GLuint shaderHandle = m_FillDepthStencilBufferSkinnedProgram->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
GLERROR("Bind PVM uniform");
std::vector<glm::mat4> frameBones;
if (modelJob->BlendTree != nullptr) {
@@ -976,9 +975,8 @@ void DrawFinalPass::DrawToDepthStencilBuffer(std::list<std::shared_ptr<RenderJob
} else {
m_FillDepthStencilBufferProgram->Bind();
GLuint shaderHandle = m_FillDepthStencilBufferProgram->GetHandle();
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "V"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "M"), 1, GL_FALSE, glm::value_ptr(modelJob->Matrix));
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * modelJob->Matrix));
GLERROR("Bind PVM uniform");
}
@@ -1008,8 +1006,8 @@ void DrawFinalPass::DrawSprites(std::list<std::shared_ptr<RenderJob>>&jobs, Rend
if(spriteJob->Depth == 0) {
jobState.Disable(GL_DEPTH_TEST);
}
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, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * spriteJob->Matrix));
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));
@@ -1049,6 +1047,12 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
GLERROR("Bind 3 uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
GLERROR("Bind 4 uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * job->Matrix));
GLERROR("Bind PVM uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "VM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix() * job->Matrix));
GLERROR("Bind VM uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "TIM"), 1, GL_FALSE, glm::value_ptr(glm::transpose(glm::inverse(job->Matrix))));
GLERROR("Bind TIM uniform");
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
GLERROR("Bind 5 uniform");
@@ -1101,6 +1105,12 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
GLint Location_P = glGetUniformLocation(shaderHandle, "P");
glUniformMatrix4fv(Location_P, 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
GLERROR("Bind 4 uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "PVM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix() * scene.Camera->ViewMatrix() * job->Matrix));
GLERROR("Bind PVM uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "VM"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ViewMatrix() * job->Matrix));
GLERROR("Bind VM uniform");
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "TIM"), 1, GL_FALSE, glm::value_ptr(glm::transpose(glm::inverse(job->Matrix))));
GLERROR("Bind TIM uniform");
GLint Location_ScreenDimensions = glGetUniformLocation(shaderHandle, "ScreenDimensions");
glUniform2f(Location_ScreenDimensions, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
+2 -7
View File
@@ -63,7 +63,6 @@ void PickingPass::Draw(RenderScene& scene)
GLuint shaderHandle = m_PickingProgram->GetHandle();
GLuint shaderSkinnedHandle = m_PickingSkinnedProgram->GetHandle();
m_PickingProgram->Bind();
if (scene.ClearDepth) {
//glClear(GL_DEPTH_BUFFER_BIT);
state->Disable(GL_DEPTH_TEST);
@@ -100,9 +99,7 @@ void PickingPass::Draw(RenderScene& scene)
if (modelJob->Model->IsSkinned()) {
m_PickingSkinnedProgram->Bind();
glUniformMatrix4fv(glGetUniformLocation(shaderSkinnedHandle, "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()));
glUniformMatrix4fv(100, 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])));
std::vector<glm::mat4> frameBones;
@@ -116,9 +113,7 @@ void PickingPass::Draw(RenderScene& scene)
} else {
m_PickingProgram->Bind();
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()));
glUniformMatrix4fv(100, 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])));
}