Initial commit
This commit is contained in:
16
resources/shaders/vertex/model-basic.vert
Normal file
16
resources/shaders/vertex/model-basic.vert
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPosition;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 2) in vec2 aTextureCoord;
|
||||
|
||||
out vec2 vTextureCoord;
|
||||
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
vTextureCoord = aTextureCoord;
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
}
|
||||
68
resources/shaders/vertex/model-normals.vert
Normal file
68
resources/shaders/vertex/model-normals.vert
Normal file
@@ -0,0 +1,68 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPosition;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 2) in vec2 aTextureCoord;
|
||||
layout (location = 3) in vec3 aTangent;
|
||||
layout (location = 4) in vec3 aBitangent;
|
||||
|
||||
struct Light {
|
||||
vec3 position;
|
||||
|
||||
// Light colors RGB value
|
||||
vec3 ambient;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
};
|
||||
uniform Light uLight;
|
||||
|
||||
out VS_OUT {
|
||||
vec2 textureCoord;
|
||||
vec3 position;
|
||||
vec3 normal;
|
||||
vec3 tangentLight;
|
||||
vec3 tangentView;
|
||||
vec3 tangentFrag;
|
||||
Light light;
|
||||
} vOut;
|
||||
|
||||
// Model View Projection matrix found by P * V * M
|
||||
struct MVP {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
// Additional uniform to allow CPU to provide mat3(transpose(inverse(uModel)))
|
||||
// + Makes a big difference in quality of diffuse shading
|
||||
// + QMatrix4x4.normalMatrix() returns a mat3 that can be used as a uniform
|
||||
mat3 normalMatrix;
|
||||
};
|
||||
uniform MVP uMVP;
|
||||
|
||||
vec4 VertexPosition(in MVP mvp, in vec3 position)
|
||||
{
|
||||
return mvp.projection * mvp.view * mvp.model * vec4(position, 1.0f);
|
||||
}
|
||||
|
||||
// Light object and camera position vectors
|
||||
uniform vec3 uCameraPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Finx TBN 3x3 matrix values for normals
|
||||
vec3 T = normalize(vec3(uMVP.model * vec4(aTangent, 0.0)));
|
||||
vec3 B = normalize(vec3(uMVP.model * vec4(aBitangent, 0.0)));
|
||||
vec3 N = normalize(vec3(uMVP.model * vec4(aNormal, 0.0)));
|
||||
mat3 TBN = transpose(mat3(T, B, N));
|
||||
|
||||
// Set tangent postiions for fragment shader
|
||||
vOut.tangentLight = TBN * uLight.position;
|
||||
vOut.tangentView = TBN * uCameraPosition;
|
||||
vOut.tangentFrag = TBN * vec3(uMVP.model * vec4(aPosition, 1.0f));
|
||||
|
||||
// Set normal, position, and texture coordinate for frag shader
|
||||
vOut.textureCoord = aTextureCoord;
|
||||
vOut.normal = uMVP.normalMatrix * aNormal;
|
||||
vOut.position = vec3(uMVP.model * vec4(aPosition, 1.0f));
|
||||
vOut.light = uLight;
|
||||
|
||||
gl_Position = VertexPosition(uMVP, aPosition);
|
||||
}
|
||||
34
resources/shaders/vertex/model-specular.vert
Normal file
34
resources/shaders/vertex/model-specular.vert
Normal file
@@ -0,0 +1,34 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPosition;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 2) in vec2 aTextureCoord;
|
||||
|
||||
out vec2 vTextureCoord;
|
||||
out vec3 vPosition;
|
||||
out vec3 vNormal;
|
||||
|
||||
// Model View Projection matrix found by P * V * M
|
||||
struct MVP {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
// Additional uniform to allow CPU to provide mat3(transpose(inverse(uModel)))
|
||||
// + Makes a big difference in quality of diffuse shading
|
||||
// + QMatrix4x4.normalMatrix() returns a mat3 that can be used as a uniform
|
||||
mat3 normalMatrix;
|
||||
};
|
||||
|
||||
vec4 VertexPosition(in MVP mvp, in vec3 position)
|
||||
{
|
||||
return mvp.projection * mvp.view * mvp.model * vec4(position, 1.0f);
|
||||
}
|
||||
|
||||
uniform MVP uMVP;
|
||||
|
||||
void main()
|
||||
{
|
||||
vTextureCoord = aTextureCoord;
|
||||
vNormal = uMVP.normalMatrix * aNormal;
|
||||
vPosition = vec3(uMVP.model * vec4(aPosition, 1.0f));
|
||||
gl_Position = VertexPosition(uMVP, aPosition);
|
||||
}
|
||||
68
resources/shaders/vertex/model.vert
Normal file
68
resources/shaders/vertex/model.vert
Normal file
@@ -0,0 +1,68 @@
|
||||
#version 330 core
|
||||
layout (location = 0) in vec3 aPosition;
|
||||
layout (location = 1) in vec3 aNormal;
|
||||
layout (location = 2) in vec2 aTextureCoord;
|
||||
layout (location = 3) in vec3 aTangent;
|
||||
layout (location = 4) in vec3 aBitangent;
|
||||
|
||||
struct Light {
|
||||
vec3 position;
|
||||
|
||||
// Light colors RGB value
|
||||
vec3 ambient;
|
||||
vec3 diffuse;
|
||||
vec3 specular;
|
||||
};
|
||||
uniform Light uLight;
|
||||
|
||||
out VS_OUT {
|
||||
vec2 textureCoord;
|
||||
vec3 position;
|
||||
vec3 normal;
|
||||
vec3 tangentLight;
|
||||
vec3 tangentView;
|
||||
vec3 tangentFrag;
|
||||
Light light;
|
||||
} vOut;
|
||||
|
||||
// Model View Projection matrix found by P * V * M
|
||||
struct MVP {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
// Additional uniform to allow CPU to provide mat3(transpose(inverse(uModel)))
|
||||
// + Makes a big difference in quality of diffuse shading
|
||||
// + QMatrix4x4.normalMatrix() returns a mat3 that can be used as a uniform
|
||||
mat3 normalMatrix;
|
||||
};
|
||||
uniform MVP uMVP;
|
||||
|
||||
vec4 VertexPosition(in MVP mvp, in vec3 position)
|
||||
{
|
||||
return mvp.projection * mvp.view * mvp.model * vec4(position, 1.0f);
|
||||
}
|
||||
|
||||
// Light object and camera position vectors
|
||||
uniform vec3 uCameraPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
// Finx TBN 3x3 matrix values for normals
|
||||
vec3 T = normalize(vec3(uMVP.model * vec4(aTangent, 0.0)));
|
||||
vec3 B = normalize(vec3(uMVP.model * vec4(aBitangent, 0.0)));
|
||||
vec3 N = normalize(vec3(uMVP.model * vec4(aNormal, 0.0)));
|
||||
mat3 TBN = transpose(mat3(T, B, N));
|
||||
|
||||
// Set tangent postiions for fragment shader
|
||||
vOut.tangentLight = TBN * uLight.position;
|
||||
vOut.tangentView = TBN * uCameraPosition;
|
||||
vOut.tangentFrag = TBN * vec3(uMVP.model * vec4(aPosition, 1.0f));
|
||||
|
||||
// Set normal, position, and texture coordinate for frag shader
|
||||
vOut.textureCoord = aTextureCoord;
|
||||
vOut.normal = uMVP.normalMatrix * aNormal;
|
||||
vOut.position = vec3(uMVP.model * vec4(aPosition, 1.0f));
|
||||
vOut.light = uLight;
|
||||
|
||||
gl_Position = VertexPosition(uMVP, aPosition);
|
||||
}
|
||||
16
resources/shaders/vertex/multi-color.vert
Normal file
16
resources/shaders/vertex/multi-color.vert
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aColor;
|
||||
|
||||
out vec4 vColor;
|
||||
|
||||
uniform mat4 uModel; // Model
|
||||
uniform mat4 uView; // View
|
||||
uniform mat4 uProjection; // Projection
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
|
||||
vColor = vec4(aColor, 1.0f);
|
||||
}
|
||||
38
resources/shaders/vertex/phong.vert
Normal file
38
resources/shaders/vertex/phong.vert
Normal file
@@ -0,0 +1,38 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
|
||||
out vec3 vPosition;
|
||||
out vec3 vNormal;
|
||||
|
||||
// Model View Projection matrix found by P * V * M
|
||||
struct MVP {
|
||||
mat4 model;
|
||||
mat4 view;
|
||||
mat4 projection;
|
||||
// Additional uniform to allow CPU to provide mat3(transpose(inverse(uModel)))
|
||||
// + Makes a big difference in quality of diffuse shading
|
||||
// + QMatrix4x4.normalMatrix() returns a mat3 that can be used as a uniform
|
||||
mat3 normalMatrix;
|
||||
};
|
||||
uniform MVP uMVP;
|
||||
|
||||
vec4 VertexPosition(in MVP mvp, in vec3 position)
|
||||
{
|
||||
return mvp.projection * mvp.view * mvp.model * vec4(position, 1.0f);
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
// Find normals, pass to fragment shader
|
||||
vNormal = uMVP.normalMatrix * aNormal;
|
||||
// vNormal = aNormal; // This is possible without the additional uniform
|
||||
// Or you could find this on the GPU using the uModel matrix
|
||||
// vNormal = mat3(transpose(inverse(uModel))) * aNormal;
|
||||
|
||||
// Set the vertex position to pass to fragment shader using only model matrix
|
||||
vPosition = vec3(uMVP.model * vec4(aPosition, 1.0f));
|
||||
|
||||
// Set vertex gl_Position using MVP matrix
|
||||
gl_Position = VertexPosition(uMVP, aPosition);
|
||||
}
|
||||
26
resources/shaders/vertex/rgb-normals.vert
Normal file
26
resources/shaders/vertex/rgb-normals.vert
Normal file
@@ -0,0 +1,26 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
|
||||
// Solid color input from application
|
||||
|
||||
// Color to output to fragment shader
|
||||
out vec3 vNormal;
|
||||
|
||||
// Model View Projection matrix found by P * V * M
|
||||
//uniform mat3 uModelInverseTransposed;
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
|
||||
// This isn't a shader we plan to use heavily, it's useful for testing normals
|
||||
// + We can see what the value of normals are on the object based on color
|
||||
vNormal = mat3(transpose(inverse(uModel))) * aNormal;
|
||||
// vNormal = uModelInverseTransposed * aNormal;
|
||||
// vNormal = aNormal; // This is possible without the additional uniform
|
||||
// Or you could find this on the GPU using the uModel matrix
|
||||
}
|
||||
20
resources/shaders/vertex/solid-ambient.vert
Normal file
20
resources/shaders/vertex/solid-ambient.vert
Normal file
@@ -0,0 +1,20 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
//layout(location = 1) in vec3 vNormal;
|
||||
|
||||
// Solid color input from application
|
||||
uniform vec3 uColor;
|
||||
|
||||
// Color to output to fragment shader
|
||||
out vec4 vColor;
|
||||
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
|
||||
vColor = vec4(uColor, 1.0f);
|
||||
}
|
||||
30
resources/shaders/vertex/solid-diffuse.vert
Normal file
30
resources/shaders/vertex/solid-diffuse.vert
Normal file
@@ -0,0 +1,30 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
|
||||
// Solid color input from application
|
||||
uniform vec3 uColor;
|
||||
|
||||
// Color to output to fragment shader
|
||||
out vec4 vColor;
|
||||
out vec3 vPosition;
|
||||
out vec3 vNormal;
|
||||
|
||||
// Model View Projection matrix found by P * V * M
|
||||
uniform mat3 uModelInverseTransposed;
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
|
||||
vPosition = vec3(uModel * vec4(aPosition, 1.0f));
|
||||
vColor = vec4(uColor, 1.0f);
|
||||
|
||||
vNormal = uModelInverseTransposed * aNormal;
|
||||
// vNormal = aNormal; // This is possible without the additional uniform
|
||||
// Or you could find this on the GPU using the uModel matrix
|
||||
// vNormal = mat3(transpose(inverse(uModel))) * aNormal;
|
||||
}
|
||||
17
resources/shaders/vertex/solid-perspective.vert
Normal file
17
resources/shaders/vertex/solid-perspective.vert
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
|
||||
out vec4 vColor;
|
||||
|
||||
uniform vec3 uColor;
|
||||
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
|
||||
vColor = vec4(uColor, 1.0f);
|
||||
}
|
||||
35
resources/shaders/vertex/solid-phong.vert
Normal file
35
resources/shaders/vertex/solid-phong.vert
Normal file
@@ -0,0 +1,35 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
|
||||
// Solid color input from application
|
||||
uniform vec3 uColor;
|
||||
|
||||
// Color to output to fragment shader
|
||||
out vec4 vColor;
|
||||
out vec3 vPosition;
|
||||
out vec3 vNormal;
|
||||
|
||||
// Additional uniform to allow CPU to provide mat3(transpose(inverse(uModel)))
|
||||
// + Makes a big difference in quality of diffuse shading
|
||||
// + QMatrix4x4.normalMatrix() returns a mat3 that can be used as a uniform
|
||||
uniform mat3 uModelInverseTransposed;
|
||||
// Model View Projection matrix found by P * V * M
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 mvp = uProjection * uView * uModel;
|
||||
|
||||
gl_Position = mvp * vec4(aPosition, 1.0);
|
||||
|
||||
vPosition = vec3(uModel * vec4(aPosition, 1.0f));
|
||||
vColor = vec4(uColor, 1.0f);
|
||||
|
||||
vNormal = uModelInverseTransposed * aNormal;
|
||||
// vNormal = aNormal; // This is possible without the additional uniform
|
||||
// Or you could find this on the GPU using the uModel matrix
|
||||
// vNormal = mat3(transpose(inverse(uModel))) * aNormal;
|
||||
}
|
||||
33
resources/shaders/vertex/solid-specular.vert
Normal file
33
resources/shaders/vertex/solid-specular.vert
Normal file
@@ -0,0 +1,33 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec3 aNormal;
|
||||
// Solid color input from application
|
||||
uniform vec3 uColor;
|
||||
|
||||
// Color to output to fragment shader
|
||||
out vec4 vColor;
|
||||
out vec3 vPosition;
|
||||
out vec3 vNormal;
|
||||
|
||||
// Additional uniform to allow CPU to provide mat3(transpose(inverse(uModel)))
|
||||
// + Makes a big difference in quality of diffuse shading
|
||||
// + QMatrix4x4.normalMatrix() returns a mat3 that can be used as a uniform
|
||||
uniform mat3 uModelInverseTransposed;
|
||||
|
||||
// Model View Projection matrix found by P * V * M
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
|
||||
vPosition = vec3(uModel * vec4(aPosition, 1.0f));
|
||||
vColor = vec4(uColor, 1.0f);
|
||||
|
||||
vNormal = uModelInverseTransposed * aNormal;
|
||||
// vNormal = aNormal; // This is possible without the additional uniform
|
||||
// Or you could find this on the GPU using the uModel matrix
|
||||
// vNormal = mat3(transpose(inverse(uModel))) * aNormal;
|
||||
}
|
||||
13
resources/shaders/vertex/solid.vert
Normal file
13
resources/shaders/vertex/solid.vert
Normal file
@@ -0,0 +1,13 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
|
||||
out vec4 vColor;
|
||||
|
||||
uniform vec3 uColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = vec4(aPosition, 1.0);
|
||||
|
||||
vColor = vec4(uColor, 1.0f);
|
||||
}
|
||||
15
resources/shaders/vertex/texture-cubemap.vert
Normal file
15
resources/shaders/vertex/texture-cubemap.vert
Normal file
@@ -0,0 +1,15 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
out vec3 vPosition;
|
||||
|
||||
void main()
|
||||
{
|
||||
vPosition = aPosition;
|
||||
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
}
|
||||
16
resources/shaders/vertex/texture2d.vert
Normal file
16
resources/shaders/vertex/texture2d.vert
Normal file
@@ -0,0 +1,16 @@
|
||||
#version 330
|
||||
layout(location = 0) in vec3 aPosition;
|
||||
layout(location = 1) in vec2 aTexture;
|
||||
|
||||
uniform mat4 uModel;
|
||||
uniform mat4 uView;
|
||||
uniform mat4 uProjection;
|
||||
|
||||
out vec2 vTextureCoord;
|
||||
|
||||
void main()
|
||||
{
|
||||
vTextureCoord = aTexture;
|
||||
|
||||
gl_Position = uProjection * uView * uModel * vec4(aPosition, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user