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

BIN
resources/images/crate.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

BIN
resources/images/stone.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
resources/images/wood.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

View File

@@ -0,0 +1,55 @@
# Blender MTL File: 'None'
# Material Count: 4
newmtl AlienHominid
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.533344 0.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Bump normal.png
map_Kd diffuse.png
map_Ns roughness.png
refl specular.png
newmtl Blaster
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Bump blaster_normal.png
map_Kd blaster_diffuse.png
map_Ke blaster_emissive.png
map_Ns blaster_roughness.png
refl blaster_specular.png
newmtl Screenshot_2021-04-19_194508
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd smoke.png
map_d smoke.png
newmtl Untitled-1
Ns 77.904748
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Untitled-1.png
map_d Untitled-1.png

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

View File

@@ -0,0 +1,16 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Scene_-_Root
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.0 0.0 0.0
Ni 1.450000
d 1.000000
illum 2
map_Kd diffuse.jpg
map_Bump normal.png
map_Ks specular.jpg

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 MiB

View File

@@ -0,0 +1,3 @@
Model by Berk Gedik, from: https://sketchfab.com/3d-models/survival-guitar-backpack-low-poly-799f8c4511f84fab8c3f12887f7e6b36
Modified material assignment (Joey de Vries) for easier load in OpenGL model loading chapter, and renamed albedo to diffuse and metallic to specular to match non-PBR lighting setup.

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 MiB

7
resources/models/bird/bird.mtl Executable file
View File

@@ -0,0 +1,7 @@
newmtl material_0
map_bump normal.jpg
norm normal.jpg
map_Kd diffuse.jpg
occlusion occlusion.jpg
Pm 0
Pr 0.793152

80009
resources/models/bird/bird.obj Executable file

File diff suppressed because it is too large Load Diff

BIN
resources/models/bird/diffuse.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 MiB

BIN
resources/models/bird/normal.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

View File

@@ -0,0 +1,12 @@
# Blender v2.82 (sub 7) OBJ File: ''
# www.blender.org
mtllib floor.mtl
o floor
v -1.000000 -0.000000 1.000000
v 1.000000 -0.000000 1.000000
v 1.000000 0.000000 -1.000000
v -1.000000 0.000000 -1.000000
vn 0.0000 1.0000 0.0000
usemtl Default_OBJ
s off
f 1//1 2//1 3//1 4//1

BIN
resources/models/lion/diffuse.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

BIN
resources/models/lion/height.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 KiB

16
resources/models/lion/lion.mtl Executable file
View File

@@ -0,0 +1,16 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Lion
Ns 500.000001
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.800000 0.800000 0.800000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Bump normal.jpg
map_Kd diffuse.jpg
map_Ns roughness.jpg
refl specular.jpg

86063
resources/models/lion/lion.obj Executable file

File diff suppressed because it is too large Load Diff

BIN
resources/models/lion/normal.jpg Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 562 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 KiB

View File

@@ -0,0 +1,8 @@
# WaveFront *.mtl file (generated by CINEMA 4D)
newmtl item/objectcomponents/weapon/staff_2h_artifactdeadwind_d_03.m2_Geoset_000
Ka 0.25 0.25 0.25
Kd 1 1 1
map_Kd diffuse.png
illum 7

5915
resources/models/scythe/scythe.obj Executable file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 885 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 426 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 983 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 484 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 930 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 638 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 844 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 761 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.9 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 MiB

View File

@@ -0,0 +1,104 @@
# Blender MTL File: 'None'
# Material Count: 8
newmtl Spartan_Arms_Mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Spartan_Arms_Mat_BaseColor.png
map_Bump Spartan_Arms_Mat_Normal.png
refl Spartan_Arms_Mat_Specular.png
newmtl Spartan_Chest_Mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Spartan_Chest_Mat_BaseColor.png
map_Bump Spartan_Chest_Mat_Normal.png
refl Spartan_Chest_Mat_Specular.png
newmtl Spartan_Ear_Mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Spartan_Ears_Mat_BaseColor.png
map_Bump Spartan_Ears_Mat_Normal.png
refl Spartan_Ears_Mat_Specular.png
newmtl Spartan_Helmet_Mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Spartan_Helmet_Mat_BaseColor.png
map_Bump Spartan_Helmet_Mat_Normal.png
refl Spartan_Helmet_Mat_Specular.png
newmtl Spartan_Legs_Mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Spartan_Legs_Mat_BaseColor.png
map_Bump Spartan_Legs_Mat_Normal.png
refl Spartan_Legs_Mat_Specular.png
newmtl Spartan_Shoulders_Mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Spartan_Shoulder_Mat_BaseColor.png
map_Bump Spartan_Shoulder_Mat_Normal.png
refl Spartan_Shoulder_Mat_Specular.png
newmtl Spartan_Undersuit_Mat
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 1.000000 1.000000 1.000000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd Spartan_Undersuit_Mat_BaseColor.png
map_Bump Spartan_Undersuit_Mat_Normal.png
refl Spartan_Undersuit_Mat_Specular.png
newmtl lambert1
Ns 179.999996
Ka 1.000000 1.000000 1.000000
Kd 0.500000 0.500000 0.500000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2

File diff suppressed because it is too large Load Diff

1834
resources/models/sphere.obj Normal file

File diff suppressed because it is too large Load Diff

BIN
resources/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 406 KiB

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
}

Some files were not shown because too many files have changed in this diff Show More