diff --git a/src/graphic/Fast3D/gfx_direct3d_common.cpp b/src/graphic/Fast3D/gfx_direct3d_common.cpp index 25947561e..73dd31c1e 100644 --- a/src/graphic/Fast3D/gfx_direct3d_common.cpp +++ b/src/graphic/Fast3D/gfx_direct3d_common.cpp @@ -350,6 +350,19 @@ void gfx_direct3d_common_build_shader(char buf[8192], size_t& len, size_t& num_f } len += sprintf(buf + len, " } else {\r\n"); len += sprintf(buf + len, " texVal%d = g_texture%d.Sample(g_sampler%d, tc%d);\r\n", i, i, i, i); + if (cc_features.used_masks[i]) { + if (cc_features.used_blend[i]) { + len += sprintf(buf + len, + " float4 blendVal%d = g_textureBlend%d.Sample(g_sampler%d, tc%d);\r\n", i, + i, i, i); + } else { + len += sprintf(buf + len, " float4 blendVal%d = float4(0, 0, 0, 0);\r\n", i); + } + len += sprintf(buf + len, + " texVal%d = lerp(texVal%d, blendVal%d, " + "g_textureMask%d.Sample(g_sampler%d, tc%d).a);\r\n", + i, i, i, i, i, i); + } len += sprintf(buf + len, " }\r\n"); } else { len += diff --git a/src/graphic/Fast3D/gfx_metal_shader.cpp b/src/graphic/Fast3D/gfx_metal_shader.cpp index 881fc7337..3bc54df98 100644 --- a/src/graphic/Fast3D/gfx_metal_shader.cpp +++ b/src/graphic/Fast3D/gfx_metal_shader.cpp @@ -125,7 +125,7 @@ static void append_formula(char* buf, size_t* len, const uint8_t c[2][4], bool d // MARK: - Public Methods -MTL::VertexDescriptor* gfx_metal_build_shader(char buf[4096], size_t& num_floats, const CCFeatures& cc_features, +MTL::VertexDescriptor* gfx_metal_build_shader(char buf[8192], size_t& num_floats, const CCFeatures& cc_features, bool three_point_filtering) { size_t len = 0; diff --git a/src/graphic/Fast3D/gfx_metal_shader.h b/src/graphic/Fast3D/gfx_metal_shader.h index 917909bfa..6394d58fd 100644 --- a/src/graphic/Fast3D/gfx_metal_shader.h +++ b/src/graphic/Fast3D/gfx_metal_shader.h @@ -13,7 +13,7 @@ #include #include "gfx_cc.h" -MTL::VertexDescriptor* gfx_metal_build_shader(char buf[4096], size_t& num_floats, const CCFeatures& cc_features, +MTL::VertexDescriptor* gfx_metal_build_shader(char buf[8192], size_t& num_floats, const CCFeatures& cc_features, bool three_point_filtering); #endif /* GFX_METAL_SHADER_H */ diff --git a/src/graphic/Fast3D/gfx_pc.cpp b/src/graphic/Fast3D/gfx_pc.cpp index 537f5923d..f86bff532 100644 --- a/src/graphic/Fast3D/gfx_pc.cpp +++ b/src/graphic/Fast3D/gfx_pc.cpp @@ -901,10 +901,10 @@ static void import_texture_raw(int tile, bool importReplacement) { // if texture type is CI4 or CI8 we need to apply tlut to it switch (type) { case LUS::TextureType::Palette4bpp: - import_texture_ci4(tile, false); + import_texture_ci4(tile, importReplacement); return; case LUS::TextureType::Palette8bpp: - import_texture_ci8(tile, false); + import_texture_ci8(tile, importReplacement); return; default: break; @@ -1565,6 +1565,12 @@ static void gfx_sp_tri1(uint8_t vtx1_idx, uint8_t vtx2_idx, uint8_t vtx3_idx, bo if (linear_filter != rendering_state.textures[i]->second.linear_filter || cms != rendering_state.textures[i]->second.cms || cmt != rendering_state.textures[i]->second.cmt) { gfx_flush(); + + // Set the same sampler params on the blended texture. Needed for opengl. + if (rdp.loaded_texture[i].blended) { + gfx_rapi->set_sampler_parameters(SHADER_FIRST_REPLACEMENT_TEXTURE + i, linear_filter, cms, cmt); + } + gfx_rapi->set_sampler_parameters(i, linear_filter, cms, cmt); rendering_state.textures[i]->second.linear_filter = linear_filter; rendering_state.textures[i]->second.cms = cms;