Skip to content

Commit

Permalink
fix holes in color clamped effects (#390) (#394)
Browse files Browse the repository at this point in the history
Co-authored-by: Qlonever <42286723+Qlonever@users.noreply.github.com>
  • Loading branch information
briaguya-ai and Qlonever committed Dec 14, 2023
1 parent 02a0c9a commit b4abd7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/graphic/Fast3D/gfx_direct3d_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,16 +402,16 @@ void gfx_direct3d_common_build_shader(char buf[8192], size_t& len, size_t& num_f
append_line(buf, &len, ";");

if (c == 0) {
append_str(buf, &len, "texel = WRAP(texel, -1.01, 1.01);");
append_str(buf, &len, "texel.rgb = WRAP(texel.rgb, -1.01, 1.01);");
}
}

if (cc_features.opt_texture_edge && cc_features.opt_alpha) {
append_line(buf, &len, " if (texel.a > 0.19) texel.a = 1.0; else discard;");
}

append_str(buf, &len, "texel = WRAP(texel, -0.51, 1.51);");
append_str(buf, &len, "texel = clamp(texel, 0.0, 1.0);");
append_str(buf, &len, "texel.rgb = WRAP(texel.rgb, -0.51, 1.51);");
append_str(buf, &len, "texel.rgb = clamp(texel.rgb, 0.0, 1.0);");
// TODO discard if alpha is 0?
if (cc_features.opt_fog) {
if (cc_features.opt_alpha) {
Expand Down
6 changes: 3 additions & 3 deletions src/graphic/Fast3D/gfx_opengl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,12 +519,12 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
append_line(fs_buf, &fs_len, ";");

if (c == 0) {
append_str(fs_buf, &fs_len, "texel = WRAP(texel, -1.01, 1.01);");
append_str(fs_buf, &fs_len, "texel.rgb = WRAP(texel.rgb, -1.01, 1.01);");
}
}

append_str(fs_buf, &fs_len, "texel = WRAP(texel, -0.51, 1.51);");
append_str(fs_buf, &fs_len, "texel = clamp(texel, 0.0, 1.0);");
append_str(fs_buf, &fs_len, "texel.rgb = WRAP(texel.rgb, -0.51, 1.51);");
append_str(fs_buf, &fs_len, "texel.rgb = clamp(texel.rgb, 0.0, 1.0);");
// TODO discard if alpha is 0?
if (cc_features.opt_fog) {
if (cc_features.opt_alpha) {
Expand Down

0 comments on commit b4abd7c

Please sign in to comment.