-
Notifications
You must be signed in to change notification settings - Fork 134
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
4 changed files
with
98 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#version 410 core | ||
|
||
out vec4 color; | ||
|
||
in vec4 fragment_color; | ||
in vec2 tex_coord; | ||
in float fogginess; | ||
uniform sampler2D tex_T0; | ||
uniform vec4 fog_color; | ||
|
||
uniform int gfx_hack_no_tex; | ||
|
||
|
||
void main() { | ||
if (gfx_hack_no_tex == 0) { | ||
vec4 T0 = texture(tex_T0, tex_coord); | ||
color = fragment_color * T0 * 2; | ||
} else { | ||
color = fragment_color; | ||
} | ||
|
||
color.rgb = mix(color.rgb, fog_color.rgb, clamp(fogginess * fog_color.a, 0, 1)); | ||
} |
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,56 @@ | ||
#version 410 core | ||
|
||
layout (location = 0) in float position_in; | ||
layout (location = 1) in int time_of_day_index; | ||
layout (location = 2) in ivec2 uv; | ||
layout (location = 3) in int vi; | ||
|
||
uniform vec4 hvdf_offset; | ||
uniform mat4 camera; | ||
uniform float fog_constant; | ||
uniform float fog_min; | ||
uniform float fog_max; | ||
uniform sampler1D tex_T10; // note, sampled in the vertex shader on purpose. | ||
// uniform int decal; | ||
uniform float fog_hack_threshold; | ||
|
||
out vec4 fragment_color; | ||
out vec2 tex_coord; | ||
out float fogginess; | ||
|
||
void main() { | ||
int vx = vi % 512; | ||
int vz = vi / 512; | ||
|
||
tex_coord.x = (uv.x == 1) ? 1.f : 0.f; | ||
tex_coord.y = (uv.y == 1) ? 1.f : 0.f; | ||
|
||
vec4 transformed = -camera[3]; | ||
transformed -= camera[0] * 32768.f * vx; | ||
transformed -= camera[1] * position_in; | ||
transformed -= camera[2] * 32768.f * vz; | ||
|
||
float Q = fog_constant / transformed.w; | ||
|
||
fogginess = 255 - clamp(-transformed.w + hvdf_offset.w, fog_min, fog_max); | ||
|
||
transformed.xyz *= Q; | ||
// offset | ||
transformed.xyz += hvdf_offset.xyz; | ||
// correct xy offset | ||
transformed.xy -= (2048.); | ||
// correct z scale | ||
transformed.z /= (8388608); | ||
transformed.z -= 1; | ||
// correct xy scale | ||
transformed.x /= (256); | ||
transformed.y /= -(128); | ||
transformed.xyz *= transformed.w; | ||
// scissoring area adjust | ||
transformed.y *= SCISSOR_ADJUST * HEIGHT_SCALE; | ||
gl_Position = transformed; | ||
|
||
// time of day lookup | ||
fragment_color = texelFetch(tex_T10, time_of_day_index, 0); | ||
fragment_color.a = 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,8 @@ | ||
#version 410 core | ||
out vec4 color; | ||
in vec2 uv; | ||
uniform sampler2D tex_T0; | ||
void main() { | ||
color = texture(tex_T0, uv); | ||
color.a = 1; | ||
} |
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,11 @@ | ||
#version 410 core | ||
|
||
layout (location = 0) in vec2 pos; | ||
layout (location = 1) in vec2 tex_coord; | ||
|
||
out vec2 uv; | ||
|
||
void main() { | ||
gl_Position = vec4(pos.x * 2 - 1, pos.y * 2 - 1, 0, 1); | ||
uv = tex_coord; | ||
} |