Skip to content

Commit

Permalink
Add files (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
Zedb0T authored May 18, 2024
1 parent 77db0d2 commit 95fb7e3
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
23 changes: 23 additions & 0 deletions hfrag/hfrag.frag
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));
}
56 changes: 56 additions & 0 deletions hfrag/hfrag.vert
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;
}
8 changes: 8 additions & 0 deletions hfrag/hfrag_montage.frag
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;
}
11 changes: 11 additions & 0 deletions hfrag/hfrag_montage.vert
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;
}

0 comments on commit 95fb7e3

Please sign in to comment.