-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,016 additions
and
307 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#version 330 core | ||
|
||
in vec2 TexCoord; | ||
|
||
out vec4 FragColor; | ||
|
||
uniform sampler2D tex; | ||
|
||
const vec3 ambient = vec3(.5); | ||
const vec3 lightDirection = vec3(0.8, 1, 0.7); | ||
|
||
const vec3 normal = vec3( 0, -1, 0); | ||
|
||
void main() | ||
{ | ||
vec3 lightDir = normalize(-lightDirection); | ||
|
||
float diff = max(dot(normal, lightDir), 0.0); | ||
vec3 diffuse = diff * vec3(1); | ||
|
||
vec4 result = vec4(ambient + diffuse, 1.0); | ||
|
||
vec4 texResult = texture(tex, TexCoord); | ||
if (texResult.a == 0) | ||
discard; | ||
FragColor = texResult * result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) in vec3 aPos; | ||
layout (location = 1) in vec2 aTexCoord; | ||
|
||
out vec2 TexCoord; | ||
out vec3 Normal; | ||
|
||
uniform float texMultiplier; | ||
|
||
uniform mat4 model; | ||
uniform mat4 view; | ||
uniform mat4 projection; | ||
|
||
void main() | ||
{ | ||
gl_Position = projection * view * model * vec4(aPos, 1.0); | ||
TexCoord = aTexCoord * texMultiplier; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#version 330 core | ||
|
||
out vec4 FragColor; | ||
in vec2 TexCoords; | ||
|
||
uniform sampler2D screenTexture; | ||
uniform sampler2D depthTexture; | ||
|
||
uniform bool underwater; | ||
|
||
const vec3 fogColor = vec3(0, 0, 0.25); | ||
const float fogNear = 0.9; | ||
const float fogFar = 1.0; | ||
|
||
void main() | ||
{ | ||
vec3 color = texture(screenTexture, TexCoords).rgb; | ||
float depth = texture(depthTexture, TexCoords).r; | ||
|
||
vec3 finalColor = color; | ||
|
||
// Calculate fog | ||
if (underwater) | ||
{ | ||
float fogFactor = (fogFar - depth) / (fogFar - fogNear); | ||
fogFactor = clamp(fogFactor, 0.0, 1.0); | ||
|
||
finalColor = mix(fogColor, color, fogFactor); | ||
} | ||
|
||
FragColor = vec4(vec3(finalColor), 1.0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) in vec2 inPos; | ||
layout (location = 1) in vec2 inTexCoords; | ||
|
||
out vec2 TexCoords; | ||
|
||
void main() | ||
{ | ||
gl_Position = vec4(inPos.x, inPos.y, 0.0, 1.0); | ||
TexCoords = inTexCoords; | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#version 330 core | ||
|
||
in vec2 TexCoord; | ||
in vec3 Normal; | ||
|
||
out vec4 FragColor; | ||
|
||
uniform sampler2D tex; | ||
|
||
vec3 ambient = vec3(.5); | ||
vec3 lightDirection = vec3(0.8, 1, 0.7); | ||
|
||
void main() | ||
{ | ||
vec3 lightDir = normalize(-lightDirection); | ||
|
||
float diff = max(dot(Normal, lightDir), 0.0); | ||
vec3 diffuse = diff * vec3(1); | ||
|
||
vec4 result = vec4(ambient + diffuse, 1.0); | ||
|
||
vec4 texResult = texture(tex, TexCoord); | ||
if (texResult.a == 0) | ||
discard; | ||
FragColor = texResult * result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#version 330 core | ||
|
||
layout (location = 0) in vec3 aPos; | ||
layout (location = 1) in vec2 aTexCoord; | ||
layout (location = 2) in int aDirection; | ||
layout (location = 3) in int aTop; | ||
|
||
out vec2 TexCoord; | ||
out vec3 Normal; | ||
|
||
uniform float texMultiplier; | ||
|
||
uniform mat4 model; | ||
uniform mat4 view; | ||
uniform mat4 projection; | ||
uniform float time; | ||
|
||
// Array of possible normals based on direction | ||
const vec3 normals[] = vec3[]( | ||
vec3( 0, 0, 1), // 0 | ||
vec3( 0, 0, -1), // 1 | ||
vec3( 1, 0, 0), // 2 | ||
vec3(-1, 0, 0), // 3 | ||
vec3( 0, 1, 0), // 4 | ||
vec3( 0, -1, 0), // 5 | ||
vec3( 0, -1, 0) // 6 | ||
); | ||
|
||
const int aFrames = 32; | ||
const float animationTime = 5; | ||
const int texNum = 16; | ||
void main() | ||
{ | ||
vec3 pos = aPos; | ||
if (aTop == 1) | ||
{ | ||
pos.y -= .1; | ||
pos.y += (sin(pos.x * 3.1415926535 / 2 + time) + sin(pos.z * 3.1415926535 / 2 + time * 1.5)) * .05; | ||
} | ||
gl_Position = projection * view * model * vec4(pos, 1.0); | ||
vec2 currentTex = aTexCoord; | ||
currentTex.x += mod(floor(mod(time / animationTime, 1) * aFrames), texNum); | ||
currentTex.y += floor(floor(mod(time / animationTime, 1) * aFrames) / texNum); | ||
TexCoord = currentTex * texMultiplier; | ||
|
||
Normal = normals[aDirection]; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Oops, something went wrong.