Changed shaders to be 430 for the moment.

This commit is contained in:
Antoine Pilote
2023-09-30 14:25:47 -04:00
parent ee008765ac
commit b265665013
27 changed files with 107 additions and 56 deletions

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 aPos;
layout(location = 1) in vec2 aTexCoords;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec2 FragColor;
in vec2 TexCoords;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
layout(location = 0) out vec4 FragColor;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform sampler2D u_Source; // Input texture
uniform float u_Distortion;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform int u_Stage;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec4 FragColor;
in vec2 UV;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform sampler2D u_Source;
uniform sampler2D u_Source2;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform sampler2D u_Source;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -20,7 +20,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec4 FragColor;
@@ -38,6 +38,7 @@ uniform sampler2D m_Material;
uniform sampler2D m_Normal;
uniform sampler2D m_SSAO;
uniform sampler2D m_Emissive;
uniform sampler2D m_UVOffset;
// Lights
const int MaxLight = 32;
@@ -65,6 +66,8 @@ uniform Light Lights[MaxLight];
uniform DirectionalLight u_DirectionalLight;
uniform int u_DisableSSAO = 0;
uniform float u_AmbientTerm;
// Converts depth to World space coords.
vec3 WorldPosFromDepth(float depth) {
float z = depth * 2.0 - 1.0;
@@ -338,7 +341,7 @@ void main()
vec3 kD = 1.0 - kS;
kD *= 1.0 - metallic;
vec3 ambient = (vec3(0.5) * albedo) * ao * ssao;
vec3 ambient = (vec3(0.5) * albedo) * ao * ssao * u_AmbientTerm;
vec3 color = (ambient) + Lo;
// Display CSM splits..

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec4 FragColor;
in vec2 UV;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform vec4 u_Color;
uniform float u_Time;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
/*
DoF with bokeh GLSL shader v2.4

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
@@ -18,7 +18,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform vec4 u_Color;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -11,9 +11,13 @@ uniform mat4 u_Model;
uniform mat4 u_View;
uniform mat4 u_Projection;
out vec3 FragPos;
out vec4 FragPos;
out mat3 TBN;
out vec2 UV;
out mat4 Inv_Proj;
out mat4 Inv_View;
out mat4 view;
out vec3 o_Tangent;
void main()
{
@@ -29,22 +33,30 @@ void main()
TBN = mat3(T, B, N);
UV = UVPosition;
Inv_Proj = u_Projection;
Inv_View = u_View;
o_Tangent = Tangent;
gl_Position = u_Projection * u_View * u_Model * vec4(VertexPosition, 1.0f);
FragPos = gl_Position;
}
#shader fragment
#version 460 core
#version 440 core
layout(location = 0) out vec4 gAlbedo;
layout(location = 1) out vec4 gNormal;
layout(location = 2) out vec4 gMaterial;
layout(location = 3) out int gEntityID;
layout(location = 4) out float gEmissive;
layout(location = 5) out vec4 gTexelOffset;
in vec3 FragPos;
in vec4 FragPos;
in vec2 UV;
in mat3 TBN;
in mat4 Inv_Proj;
in mat4 Inv_View;
// Material
uniform sampler2D m_Albedo;
@@ -71,6 +83,21 @@ layout(std140, binding = 32) uniform u_MaterialUniform
float u_Emissive;
};
vec3 TextureToWorld(vec2 texCoord, mat4 viewMatrix, mat4 invProjectionMatrix)
{
// Combine texture coordinate with depth to obtain clip space position
vec4 clipCoord = vec4(texCoord * 2.0 - 1.0, 0.0, 1.0);
// Transform clip space position to view space
vec4 viewCoord = invProjectionMatrix * clipCoord;
viewCoord /= viewCoord.w;
// Transform view space position to world space
vec4 worldCoord = viewMatrix * viewCoord;
return worldCoord.xyz;
}
void main()
{
// Normal
@@ -118,4 +145,25 @@ void main()
gEntityID = int(u_EntityID);
gEmissive = u_Emissive;
vec3 right = vec3(1.0, 0, 0);
right = TBN * normalize(right);
vec3 up = TBN * normalize(vec3(0, 1, 0));
vec2 textureSize2d = textureSize(m_Albedo, 0);
vec2 pixelPos = UV * textureSize2d;
vec2 centerOfPixel = (vec2(0.5) + floor(pixelPos));
vec2 uvCenter = centerOfPixel;
vec3 uvDiff = vec3(uvCenter.x - pixelPos.x, uvCenter.y - pixelPos.y, 0.0f) / vec3(textureSize2d.x, textureSize2d.y, 1.0f);
uvDiff = uvDiff.x * right;
uvDiff = uvDiff.y * up;
//uvDiff * right;
uvDiff = uvDiff * 100.0f;
vec2 offset = (centerOfPixel - vec2(FragPos.x, FragPos.y)) * 10.0f;
vec3 finalTransformed = normalize(uvDiff);
vec4 conversion = Inv_Proj * Inv_View * vec4(finalTransformed, 1.0f);
gTexelOffset = vec4(conversion.x / 2.0 + 0.5f, conversion.y / 2.0 + 0.5f, 0, 1);
}

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -59,7 +59,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
layout(location = 0) out vec4 gAlbedo;
layout(location = 1) out vec4 gNormal;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 Position;
layout(location = 1) in vec3 Normal;
layout(location = 1) in vec2 UV;
@@ -17,7 +17,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec4 FragColor;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec4 VertexColor;
@@ -17,7 +17,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
in vec4 LineColor;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -40,7 +40,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec4 FragColor;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 Position;
layout(location = 1) in vec2 UV;
@@ -15,7 +15,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec4 FragColor;
in sample vec2 a_UV;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 Position;
@@ -12,6 +12,6 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
void main() { }

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 Position;
layout(location = 1) in vec2 UVPosition;
@@ -40,6 +40,6 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
void main() { }

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 vertexPosition;
@@ -16,7 +16,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
out vec4 FragColor;
in vec3 TexCoords;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -25,7 +25,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform sampler2D u_Depth;
uniform sampler2D u_Normal;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform sampler2D u_Source;
uniform float u_Gamma;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 Position;
layout(location = 1) in vec2 UV;
@@ -15,7 +15,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform vec4 u_BackgroundColor;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -13,7 +13,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
uniform sampler2D u_Source;

View File

@@ -1,5 +1,5 @@
#shader vertex
#version 460 core
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
@@ -20,7 +20,7 @@ void main()
}
#shader fragment
#version 460 core
#version 440 core
float ditherPattern[4][4] = { { 0.0f, 0.5f, 0.125f, 0.625f},
{ 0.75f, 0.22f, 0.875f, 0.375f},