mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-28 23:13:02 +00:00
Make linear/tripoint filters switchable without restart
This commit is contained in:
parent
95d0977df5
commit
2f69079e8e
3 changed files with 30 additions and 32 deletions
|
@ -128,8 +128,8 @@ FAST = "Fast"
|
|||
ACCURATE = "Accurate"
|
||||
INTERPOLATION = "Interpolation"
|
||||
NEAREST = "Nearest"
|
||||
LINEAR = "Linear"
|
||||
TRIPOINT = "Tripoint"
|
||||
LINEAR = "Bilinear"
|
||||
TRIPOINT = "Trilinear"
|
||||
FILTERING = "Filtering"
|
||||
D0P5X = "0.5x"
|
||||
D1X = "1x"
|
||||
|
@ -201,8 +201,8 @@ BOUNCY_BOUNDS_ON_CAP = "ON (Capped)"
|
|||
BOUNCY_BOUNDS_ON = "ON"
|
||||
BOUNCY_BOUNDS_OFF = "OFF"
|
||||
BOUNCY_LEVEL_BOUNDS = "Bouncy Level Bounds"
|
||||
AMOUNT_OF_PLAYERS = "Amount of players"
|
||||
PAUSE_ANYWHERE = "Pause anywhere"
|
||||
AMOUNT_OF_PLAYERS = "Amount Of Players"
|
||||
PAUSE_ANYWHERE = "Pause Anywhere"
|
||||
|
||||
[HOST]
|
||||
SERVER_TITLE = "SERVER"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
-- name: Arena
|
||||
-- description: A arena-shooter inspired game mode with custom weapons and levels.\nSeven gamemodes in one, three custom stages, five weapons.
|
||||
-- incompatible: gamemode arena light
|
||||
-- incompatible: gamemode arena
|
||||
-- deluxe: true
|
||||
|
||||
if SM64COOPDX_VERSION == nil then return end
|
||||
|
|
|
@ -50,7 +50,7 @@ struct ShaderProgram {
|
|||
bool used_textures[2];
|
||||
uint8_t num_floats;
|
||||
GLint attrib_locations[7];
|
||||
GLint uniform_locations[6];
|
||||
GLint uniform_locations[7];
|
||||
uint8_t attrib_sizes[7];
|
||||
uint8_t num_attribs;
|
||||
bool used_noise;
|
||||
|
@ -96,6 +96,7 @@ static void gfx_opengl_vertex_array_set_attribs(struct ShaderProgram *prg) {
|
|||
static inline void gfx_opengl_set_shader_uniforms(struct ShaderProgram *prg) {
|
||||
if (prg->used_noise) { glUniform1f(prg->uniform_locations[4], (float)frame_count); }
|
||||
if (prg->used_lightmap) { glUniform3f(prg->uniform_locations[5], gVertexColor[0] / 255.0f, gVertexColor[1] / 255.0f, gVertexColor[2] / 255.0f); }
|
||||
glUniform1i(prg->uniform_locations[6], configFiltering);
|
||||
}
|
||||
|
||||
static inline void gfx_opengl_set_texture_uniforms(struct ShaderProgram *prg, const int tile) {
|
||||
|
@ -341,10 +342,8 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC
|
|||
|
||||
// 3 point texture filtering
|
||||
// Original author: ArthurCarvalho
|
||||
// Slightly modified GLSL implementation by twinaphex, mupen64plus-libretro project.
|
||||
|
||||
// Modified GLSL implementation by twinaphex, mupen64plus-libretro project.
|
||||
if (ccf.used_textures[0] || ccf.used_textures[1]) {
|
||||
if (configFiltering == 2) {
|
||||
append_line(fs_buf, &fs_len, "#define TEX_OFFSET(off) texture2D(tex, texCoord - (off)/texSize)");
|
||||
append_line(fs_buf, &fs_len, "vec4 filter3point(in sampler2D tex, in vec2 texCoord, in vec2 texSize) {");
|
||||
append_line(fs_buf, &fs_len, " vec2 offset = fract(texCoord*texSize - vec2(0.5));");
|
||||
|
@ -354,17 +353,12 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC
|
|||
append_line(fs_buf, &fs_len, " vec4 c2 = TEX_OFFSET(vec2(offset.x, offset.y - sign(offset.y)));");
|
||||
append_line(fs_buf, &fs_len, " return c0 + abs(offset.x)*(c1-c0) + abs(offset.y)*(c2-c0);");
|
||||
append_line(fs_buf, &fs_len, "}");
|
||||
append_line(fs_buf, &fs_len, "vec4 sampleTex(in sampler2D tex, in vec2 uv, in vec2 texSize, in bool dofilter) {");
|
||||
append_line(fs_buf, &fs_len, "if (dofilter)");
|
||||
append_line(fs_buf, &fs_len, "vec4 sampleTex(in sampler2D tex, in vec2 uv, in vec2 texSize, in bool dofilter, in int filter) {");
|
||||
append_line(fs_buf, &fs_len, " if (dofilter && filter == 2)");
|
||||
append_line(fs_buf, &fs_len, " return filter3point(tex, uv, texSize);");
|
||||
append_line(fs_buf, &fs_len, " else");
|
||||
append_line(fs_buf, &fs_len, " return texture2D(tex, uv);");
|
||||
append_line(fs_buf, &fs_len, "}");
|
||||
} else {
|
||||
append_line(fs_buf, &fs_len, "vec4 sampleTex(in sampler2D tex, in vec2 uv, in vec2 texSize, in bool dofilter) {");
|
||||
append_line(fs_buf, &fs_len, "return texture2D(tex, uv);");
|
||||
append_line(fs_buf, &fs_len, "}");
|
||||
}
|
||||
}
|
||||
|
||||
if ((opt_alpha && opt_dither) || ccf.do_noise) {
|
||||
|
@ -380,6 +374,8 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC
|
|||
append_line(fs_buf, &fs_len, "uniform vec3 uLightmapColor;");
|
||||
}
|
||||
|
||||
append_line(fs_buf, &fs_len, "uniform int uFilter;");
|
||||
|
||||
append_line(fs_buf, &fs_len, "void main() {");
|
||||
|
||||
if ((opt_alpha && opt_dither) || ccf.do_noise) {
|
||||
|
@ -387,15 +383,15 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC
|
|||
}
|
||||
|
||||
if (ccf.used_textures[0]) {
|
||||
append_line(fs_buf, &fs_len, "vec4 texVal0 = sampleTex(uTex0, vTexCoord, uTex0Size, uTex0Filter);");
|
||||
append_line(fs_buf, &fs_len, "vec4 texVal0 = sampleTex(uTex0, vTexCoord, uTex0Size, uTex0Filter, uFilter);");
|
||||
}
|
||||
if (ccf.used_textures[1]) {
|
||||
if (opt_light_map) {
|
||||
append_line(fs_buf, &fs_len, "vec4 texVal1 = sampleTex(uTex1, vLightMap, uTex1Size, uTex1Filter);");
|
||||
append_line(fs_buf, &fs_len, "vec4 texVal1 = sampleTex(uTex1, vLightMap, uTex1Size, uTex1Filter, uFilter);");
|
||||
append_line(fs_buf, &fs_len, "texVal0.rgb *= uLightmapColor.rgb;");
|
||||
append_line(fs_buf, &fs_len, "texVal1.rgb = texVal1.rgb * texVal1.rgb + texVal1.rgb;");
|
||||
} else {
|
||||
append_line(fs_buf, &fs_len, "vec4 texVal1 = sampleTex(uTex1, vTexCoord, uTex1Size, uTex1Filter);");
|
||||
append_line(fs_buf, &fs_len, "vec4 texVal1 = sampleTex(uTex1, vTexCoord, uTex1Size, uTex1Filter, uFilter);");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,6 +558,8 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(struct ColorC
|
|||
prg->used_lightmap = false;
|
||||
}
|
||||
|
||||
prg->uniform_locations[6] = glGetUniformLocation(shader_program, "uFilter");
|
||||
|
||||
return prg;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue