Initial commit

This commit is contained in:
2021-09-03 12:56:57 -04:00
parent 76d457bcd7
commit 578fcb2bbd
154 changed files with 617096 additions and 2 deletions

View File

@@ -0,0 +1,11 @@
#version 330 core
out vec4 fColor;
in vec2 vTextureCoord;
uniform sampler2D texture_diffuse1;
void main()
{
fColor = texture(texture_diffuse1, vTextureCoord);
}

View File

@@ -0,0 +1,93 @@
#version 330 core
struct Light {
vec3 position;
// Light colors RGB value
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
// Input from Vertex shader
in VS_OUT {
// Frag position, UV coordinates, normals
vec2 textureCoord;
vec3 position;
vec3 normal;
// Tangent positions
vec3 tangentLight;
vec3 tangentView;
vec3 tangentFrag;
Light light;
} vOut;
// Final fragment fColor
out vec4 fColor;
struct Material {
// Strength ranges 0.0f - 1.0f
float ambientStrength;
float diffuseStrength;
float specularStrength;
// 32, 64, 128, 256
float shine;
// Material color values
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform Material uMaterial;
struct Result {
vec3 ambient;
vec3 diffuse;
vec3 specular;
vec3 sum;
};
void SumResult(inout Result result)
{
result.sum = result.ambient + result.diffuse + result.specular;
}
uniform sampler2D texture_diffuse1;
uniform sampler2D texture_specular1;
uniform sampler2D texture_normal1;
void main()
{
Result result;
// Diffuse texture for ambient and diffuse lighting
vec3 diffuseTexture = vec3(texture(texture_diffuse1, vOut.textureCoord));
// Ambient lighting
vec3 ambientLighting = vOut.light.ambient * uMaterial.ambient;
result.ambient = ambientLighting * diffuseTexture;
result.ambient *= uMaterial.ambientStrength;
// Diffuse lighting
vec3 normalTexture = texture(texture_normal1, vOut.textureCoord).rgb;
normalTexture = normalize(normalTexture * 2.0f - 1.0f);
vec3 lightDir = normalize(vOut.tangentLight - vOut.tangentFrag);
float diff = max(dot(lightDir, normalTexture), 0.0f);
vec3 diffuseLighting = vOut.light.diffuse * diff * uMaterial.diffuse;
result.diffuse = diffuseLighting * diffuseTexture;
result.diffuse *= uMaterial.diffuseStrength;
// Specular lighting
vec3 specularTexture = vec3(texture(texture_specular1, vOut.textureCoord));
vec3 viewDir = normalize(vOut.tangentView - vOut.tangentFrag);
vec3 reflectDir = reflect(-lightDir, normalTexture);
vec3 halfDir = normalize(lightDir + viewDir);
float angleAlpha = max(dot(normalTexture, halfDir), 0.0f);
float spec = pow(angleAlpha, uMaterial.shine);
vec3 specLighting = vOut.light.specular * spec;
result.specular = specLighting * specularTexture;
result.specular *= uMaterial.specularStrength;
SumResult(result);
fColor = vec4(result.sum, 1.0f);
}

View File

@@ -0,0 +1,85 @@
#version 330 core
// Input from Vertex shader
in vec2 vTextureCoord;
in vec3 vNormal;
in vec3 vPosition;
// Final fragment fColor
out vec4 fColor;
// Light object and camera position vectors
uniform vec3 uCameraPosition;
struct Light {
vec3 position;
// Light colors RGB value
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform Light uLight;
struct Material {
// Strength ranges 0.0f - 1.0f
float ambientStrength;
float diffuseStrength;
float specularStrength;
// 32, 64, 128, 256
float shine;
// Material color values
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform Material uMaterial;
struct Result {
vec3 ambient;
vec3 diffuse;
vec3 specular;
vec3 sum;
};
void SumResult(inout Result result)
{
result.sum = result.ambient + result.diffuse + result.specular;
}
uniform sampler2D texture_diffuse1;
uniform sampler2D texture_specular1;
void main()
{
Result result;
// Diffuse texture for ambient and diffuse lighting
vec3 diffuseTexture = vec3(texture(texture_diffuse1, vTextureCoord));
// Ambient lighting
vec3 ambientLighting = uLight.ambient * uMaterial.ambient;
result.ambient = ambientLighting * diffuseTexture;
result.ambient *= uMaterial.ambientStrength;
// Diffuse lighting
vec3 norm = normalize(vNormal);
vec3 lightDir = normalize(uLight.position - vPosition);
float diff = max(dot(norm, lightDir), 0.0f);
vec3 diffuseLighting = uLight.diffuse * diff * uMaterial.diffuse;
result.diffuse = diffuseLighting * diffuseTexture;
result.diffuse *= uMaterial.diffuseStrength;
// Specular lighting
vec3 specularTexture = vec3(texture(texture_specular1, vTextureCoord));
vec3 viewDir = normalize(uCameraPosition - vPosition);
vec3 reflectDir = reflect(-lightDir, norm);
float angleAlpha = max(dot(viewDir, reflectDir), 0.0f);
float spec = pow(angleAlpha, uMaterial.shine);
vec3 specLighting = uLight.specular * spec;
result.specular = specLighting * specularTexture;
result.specular *= uMaterial.specularStrength;
SumResult(result);
fColor = vec4(result.sum, 1.0f);
}

View File

@@ -0,0 +1,93 @@
#version 330 core
struct Light {
vec3 position;
// Light colors RGB value
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
// Input from Vertex shader
in VS_OUT {
// Frag position, UV coordinates, normals
vec2 textureCoord;
vec3 position;
vec3 normal;
// Tangent positions
vec3 tangentLight;
vec3 tangentView;
vec3 tangentFrag;
Light light;
} vOut;
// Final fragment fColor
out vec4 fColor;
struct Material {
// Strength ranges 0.0f - 1.0f
float ambientStrength;
float diffuseStrength;
float specularStrength;
// 32, 64, 128, 256
float shine;
// Material color values
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform Material uMaterial;
struct Result {
vec3 ambient;
vec3 diffuse;
vec3 specular;
vec3 sum;
};
void SumResult(inout Result result)
{
result.sum = result.ambient + result.diffuse + result.specular;
}
uniform sampler2D texture_diffuse1;
uniform sampler2D texture_specular1;
uniform sampler2D texture_normal1;
void main()
{
Result result;
// Diffuse texture for ambient and diffuse lighting
vec3 diffuseTexture = vec3(texture(texture_diffuse1, vOut.textureCoord));
// Ambient lighting
vec3 ambientLighting = vOut.light.ambient * uMaterial.ambient;
result.ambient = ambientLighting * diffuseTexture;
result.ambient *= uMaterial.ambientStrength;
// Diffuse lighting
vec3 normalTexture = texture(texture_normal1, vOut.textureCoord).rgb;
normalTexture = normalize(normalTexture * 2.0f - 1.0f);
vec3 lightDir = normalize(vOut.tangentLight - vOut.tangentFrag);
float diff = max(dot(lightDir, normalTexture), 0.0f);
vec3 diffuseLighting = vOut.light.diffuse * diff * uMaterial.diffuse;
result.diffuse = diffuseLighting * diffuseTexture;
result.diffuse *= uMaterial.diffuseStrength;
// Specular lighting
vec3 specularTexture = vec3(texture(texture_specular1, vOut.textureCoord));
vec3 viewDir = normalize(vOut.tangentView - vOut.tangentFrag);
vec3 reflectDir = reflect(-lightDir, normalTexture);
vec3 halfDir = normalize(lightDir + viewDir);
float angleAlpha = max(dot(normalTexture, halfDir), 0.0f);
float spec = pow(angleAlpha, uMaterial.shine);
vec3 specLighting = vOut.light.specular * spec;
result.specular = specLighting * specularTexture;
result.specular *= uMaterial.specularStrength;
SumResult(result);
fColor = vec4(result.sum, 1.0f);
}

View File

@@ -0,0 +1,9 @@
#version 330
in vec4 vColor;
out vec4 fColor;
void main()
{
fColor = vColor;
}

View File

@@ -0,0 +1,94 @@
#version 330
// Color input from Vertex shader
in vec3 vNormal;
in vec3 vPosition;
// Final fragment fColor
out vec4 fColor;
// Light object and camera position vectors
uniform vec3 uCameraPosition;
struct Light {
vec3 position;
// Light colors RGB value
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform Light uLight;
struct Material {
// Strength ranges 0.0f - 1.0f
float ambientStrength;
float diffuseStrength;
float specularStrength;
// 32, 64, 128, 256
float shine;
// Material color values
vec3 ambient;
vec3 diffuse;
vec3 specular;
};
uniform Material uMaterial;
struct Result {
vec3 ambient;
vec3 diffuse;
vec3 specular;
vec3 sum;
};
void SumResult(inout Result result)
{
result.sum = result.ambient + result.diffuse + result.specular;
}
void main()
{
// A struct to store lighting results as we finish calculating them
// Valuse stored here will be applied to the final output of our shader
Result result;
// Ambient lighting
result.ambient = (uLight.ambient * uMaterial.ambient) * uMaterial.ambientStrength;
//
// Diffuse lighting
// Normalize the provided normal vector
// + Creates a vector with length of 1 in the same direction as vNormal
vec3 norm = normalize(vNormal);
// Get a vector from this frag to the lightSoruce
vec3 lightDir = normalize(uLight.position - vPosition);
// As the normal vector approaches an angle looking at lightDir vector
// + If this is negative, the frag is on a surface opposite of the lightSource
float diff = max(dot(norm, lightDir), 0.0f);
result.diffuse = (uLight.diffuse * diff * uMaterial.diffuse) * uMaterial.diffuseStrength;
//
// Specular lighting
// Get a vector from the camera to the fragment as our viewDir
vec3 viewDir = normalize(uCameraPosition - vPosition);
// Since lightDir is already a vector from this frag to the light source
// reflectionDir is the opposite; A vector from the light to the frag
vec3 reflectDir = reflect(-lightDir, norm);
// Use dot product to check if viewDir and reflectDir angles are intersecting
// -1.0f if they are opposite; 1.0 if they are looking at each other directly
// + If this is negative, the lightSource is behind the player; Ignore it
float angleAlpha = max(dot(viewDir, reflectDir), 0.0f);
// As the angleAlpha approaches 1, raise to the power of uMaterial.shine
float spec = pow(angleAlpha, uMaterial.shine);
// Apply specular result to the
result.specular = (uLight.specular * uMaterial.specular * spec) * uMaterial.specularStrength;
//
// Final calculation
SumResult(result);
// Final output
fColor = vec4(result.sum, 1.0f); // Reapply alpha for opacity
}

View File

@@ -0,0 +1,11 @@
#version 330
// Color input from Vertex shader
in vec3 vNormal;
// Final fragment color
out vec4 fColor;
void main()
{
fColor = vec4(abs(vNormal), 1.0f); // Reapply alpha
}

View File

@@ -0,0 +1,19 @@
#version 330
// Color input from Vertex shader
in vec4 vColor;
// Final fragment color
out vec4 fColor;
// Light color RGB value
uniform vec3 uLightColor;
// Strength ranges 0.0f - 1.0f
uniform float uAmbientStrength; // 0.2f
void main()
{
vec3 ambient = uAmbientStrength * uLightColor;
vec3 result = ambient * vec3(vColor); // Strip aColor to vec3 to drop alpha
fColor = vec4(result, 1.0f); // Reapply alpha
}

View File

@@ -0,0 +1,35 @@
#version 330
// Color input from Vertex shader
in vec4 vColor;
in vec3 vNormal;
in vec3 vPosition;
// Final fragment color
out vec4 fColor;
// Light color RGB value
uniform vec3 uLightColor;
// Light object position vector
uniform vec3 uLightPosition;
// Strength ranges 0.0f - 1.0f
uniform float uAmbientStrength; // 0.2f
void main()
{
// Ambient lighting
vec3 ambient = uAmbientStrength * uLightColor;
// Diffuse lighting
vec3 norm = normalize(vNormal);
vec3 lightDir = normalize(uLightPosition - vPosition);
float diff = max(dot(norm, lightDir), 0.0f);
vec3 diffuse = diff * uLightColor;
// Strip vColor to vec3 to drop alpha
vec3 result = (ambient + diffuse) * vec3(vColor);
// Final output
fColor = vec4(result, 1.0f); // Reapply alpha
}

View File

@@ -0,0 +1,9 @@
#version 330
in vec4 vColor;
out vec4 fColor;
void main()
{
fColor = vColor;
}

View File

@@ -0,0 +1,49 @@
#version 330
// Color input from Vertex shader
in vec4 vColor;
in vec3 vNormal;
in vec3 vPosition;
// Final fragment fColor
out vec4 fColor;
// Light color RGB value
uniform vec3 uLightColor;
// Light object and camera position vectors
uniform vec3 uLightPosition;
uniform vec3 uCameraPosition;
// Strength ranges 0.0f - 1.0f
uniform float uAmbientStrength; // 0.2f
uniform float uSpecularStrength; // 0.25f
// 32, 64, 128, 256
uniform int uSpecularShine; // 64
void main()
{
// Ambient lighting
vec3 ambient = uAmbientStrength * uLightColor;
// Diffuse lighting
vec3 norm = normalize(vNormal);
vec3 lightDir = normalize(uLightPosition - vPosition);
float diff = max(dot(norm, lightDir), 0.0f);
vec3 diffuse = diff * uLightColor;
// Specular lighting
vec3 viewDir = normalize(uCameraPosition - vPosition);
vec3 reflectDir = reflect(-lightDir, norm);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), uSpecularShine);
vec3 specular = uSpecularStrength * spec * uLightColor;
//
// Final calculation
// Strip vColor to vec3 to drop alpha
vec3 result = (ambient + diffuse + specular) * vec3(vColor);
// Final output
fColor = vec4(result, 1.0f); // Reapply alpha
}

View File

@@ -0,0 +1,49 @@
#version 330
// Color input from Vertex shader
in vec4 vColor;
in vec3 vNormal;
in vec3 vPosition;
// Final fragment fColor
out vec4 fColor;
// Light color RGB value
uniform vec3 uLightColor;
// Light object and camera position vectors
uniform vec3 uLightPosition;
uniform vec3 uCameraPosition;
// Strength ranges 0.0f - 1.0f
uniform float uAmbientStrength; // 0.2f
uniform float uSpecularStrength; // 0.25f
// 32, 64, 128, 256
uniform int uSpecularShine; // 64
void main()
{
// Ambient lighting
vec3 ambient = uAmbientStrength * uLightColor;
// Diffuse lighting
vec3 norm = normalize(vNormal);
vec3 lightDir = normalize(uLightPosition - vPosition);
float diff = max(dot(norm, lightDir), 0.0f);
vec3 diffuse = diff * uLightColor;
// Specular lighting
vec3 viewDir = normalize(uCameraPosition - vPosition);
vec3 reflectDir = reflect(-lightDir, norm);
float spec = pow(max(dot(viewDir, reflectDir), 0.0), uSpecularShine);
vec3 specular = uSpecularStrength * spec * uLightColor;
//
// Final calculation
// Strip vColor to vec3 to drop alpha
vec3 result = (ambient + specular) * vec3(vColor);
// Final output
fColor = vec4(result, 1.0f); // Reapply alpha
}

View File

@@ -0,0 +1,9 @@
#version 330
in vec4 vColor;
out vec4 fColor;
void main()
{
fColor = vColor;
}

View File

@@ -0,0 +1,12 @@
#version 330
in vec3 vPosition;
uniform samplerCube uTexture;
out vec4 fColor;
void main()
{
vec4 texCol = texture(uTexture, vPosition);
fColor = texCol;
}

View File

@@ -0,0 +1,12 @@
#version 330
in vec2 vTextureCoord;
uniform sampler2D uTexture;
out vec4 fColor;
void main()
{
vec4 texCol = texture(uTexture, vTextureCoord);
fColor = texCol;
}