vk/gl: add more anaglyph 3D modes

This commit is contained in:
Megamouse 2024-01-29 22:55:15 +01:00
parent 3dac7d16e7
commit 651f8512eb
8 changed files with 61 additions and 13 deletions

View File

@ -179,7 +179,7 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
if (!buffer_pitch)
buffer_pitch = buffer_width * avconfig.get_bpp();
const u32 video_frame_height = (avconfig.stereo_mode == stereo_render_mode_options::disabled? avconfig.resolution_y : ((avconfig.resolution_y - 30) / 2));
const u32 video_frame_height = (avconfig.stereo_mode == stereo_render_mode_options::disabled ? avconfig.resolution_y : ((avconfig.resolution_y - 30) / 2));
buffer_width = std::min(buffer_width, avconfig.resolution_x);
buffer_height = std::min(buffer_height, video_frame_height);
}

View File

@ -13,9 +13,13 @@ layout(location=0) in vec2 tc0;
layout(location=0) out vec4 ocol;
#define STEREO_MODE_DISABLED 0
#define STEREO_MODE_ANAGLYPH 1
#define STEREO_MODE_SIDE_BY_SIDE 2
#define STEREO_MODE_OVER_UNDER 3
#define STEREO_MODE_SIDE_BY_SIDE 1
#define STEREO_MODE_OVER_UNDER 2
#define STEREO_MODE_ANAGLYPH_RED_GREEN 3
#define STEREO_MODE_ANAGLYPH_RED_BLUE 4
#define STEREO_MODE_ANAGLYPH_RED_CYAN 5
#define STEREO_MODE_ANAGLYPH_MAGENTA_CYAN 6
#define STEREO_MODE_ANAGLYPH_TRIOSCOPIC 7
vec2 sbs_single_matrix = vec2(2.0,0.4898f);
vec2 sbs_multi_matrix = vec2(2.0,1.0);
@ -46,10 +50,26 @@ vec4 read_source()
{
switch (stereo_display_mode)
{
case STEREO_MODE_ANAGLYPH:
case STEREO_MODE_ANAGLYPH_RED_GREEN:
left = texture(fs0, tc0 * vec2(1.f, 0.4898f));
right = texture(fs0, (tc0 * vec2(1.f, 0.4898f)) + vec2(0.f, 0.510204f));
return vec4(left.r, right.g, 0.f, 1.f);
case STEREO_MODE_ANAGLYPH_RED_BLUE:
left = texture(fs0, tc0 * vec2(1.f, 0.4898f));
right = texture(fs0, (tc0 * vec2(1.f, 0.4898f)) + vec2(0.f, 0.510204f));
return vec4(left.r, 0.f, right.b, 1.f);
case STEREO_MODE_ANAGLYPH_RED_CYAN:
left = texture(fs0, tc0 * vec2(1.f, 0.4898f));
right = texture(fs0, (tc0 * vec2(1.f, 0.4898f)) + vec2(0.f, 0.510204f));
return vec4(left.r, right.g, right.b, 1.f);
case STEREO_MODE_ANAGLYPH_MAGENTA_CYAN:
left = texture(fs0, tc0 * vec2(1.f, 0.4898f));
right = texture(fs0, (tc0 * vec2(1.f, 0.4898f)) + vec2(0.f, 0.510204f));
return vec4(left.r, right.g, (left.b + right.b) / 2.f, 1.f);
case STEREO_MODE_ANAGLYPH_TRIOSCOPIC:
left = texture(fs0, tc0 * vec2(1.f, 0.4898f));
right = texture(fs0, (tc0 * vec2(1.f, 0.4898f)) + vec2(0.f, 0.510204f));
return vec4(right.r, left.g, right.b, 1.f);
case STEREO_MODE_SIDE_BY_SIDE:
if (tc0.x < 0.5) return texture(fs0, tc0* sbs_single_matrix);
else return texture(fs0, (tc0* sbs_single_matrix) + vec2(-1.f, 0.510204f));
@ -64,10 +84,26 @@ vec4 read_source()
{
switch (stereo_display_mode)
{
case STEREO_MODE_ANAGLYPH:
case STEREO_MODE_ANAGLYPH_RED_GREEN:
left = texture(fs0, tc0);
right = texture(fs1, tc0);
return vec4(left.r, right.g, 0.f, 1.f);
case STEREO_MODE_ANAGLYPH_RED_BLUE:
left = texture(fs0, tc0);
right = texture(fs1, tc0);
return vec4(left.r, 0.f, right.b, 1.f);
case STEREO_MODE_ANAGLYPH_RED_CYAN:
left = texture(fs0, tc0);
right = texture(fs1, tc0);
return vec4(left.r, right.g, right.b, 1.f);
case STEREO_MODE_ANAGLYPH_MAGENTA_CYAN:
left = texture(fs0, tc0);
right = texture(fs1, tc0);
return vec4(left.r, right.g, (left.b + right.b) / 2.f, 1.f);
case STEREO_MODE_ANAGLYPH_TRIOSCOPIC:
left = texture(fs0, tc0);
right = texture(fs1, tc0);
return vec4(right.r, left.g, right.b, 1.f);
case STEREO_MODE_SIDE_BY_SIDE:
if (tc0.x < 0.5) return texture(fs0,(tc0 * sbs_multi_matrix));
else return texture(fs1,(tc0 * sbs_multi_matrix) + vec2(-1.f,0.f));

View File

@ -137,7 +137,7 @@ namespace vk
bool m_pulse_glow = false;
bool m_clip_enabled = false;
bool m_disable_vertex_snap = false;
rsx::overlays::texture_sampling_mode m_texture_type = rsx::overlays::texture_sampling_mode::none;
rsx::overlays::texture_sampling_mode m_texture_type;
areaf m_clip_region;
coordf m_viewport;

View File

@ -494,7 +494,7 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
if (!buffer_pitch)
buffer_pitch = buffer_width * avconfig.get_bpp();
const u32 video_frame_height = (avconfig.stereo_mode == stereo_render_mode_options::disabled? avconfig.resolution_y : ((avconfig.resolution_y - 30) / 2));
const u32 video_frame_height = (avconfig.stereo_mode == stereo_render_mode_options::disabled ? avconfig.resolution_y : ((avconfig.resolution_y - 30) / 2));
buffer_width = std::min(buffer_width, avconfig.resolution_x);
buffer_height = std::min(buffer_height, video_frame_height);
}

View File

@ -640,9 +640,13 @@ void fmt_class_string<stereo_render_mode_options>::format(std::string& out, u64
switch (value)
{
case stereo_render_mode_options::disabled: return "Disabled";
case stereo_render_mode_options::anaglyph: return "Anaglyph";
case stereo_render_mode_options::side_by_side: return "Side-by-Side";
case stereo_render_mode_options::over_under: return "Over-Under";
case stereo_render_mode_options::anaglyph_red_green: return "Anaglyph Red-Green";
case stereo_render_mode_options::anaglyph_red_blue: return "Anaglyph Red-Blue";
case stereo_render_mode_options::anaglyph_red_cyan: return "Anaglyph Red-Cyan";
case stereo_render_mode_options::anaglyph_magenta_cyan: return "Anaglyph Magenta-Cyan";
case stereo_render_mode_options::anaglyph_trioscopic: return "Anaglyph Trioscopic";
}
return unknown;

View File

@ -316,9 +316,13 @@ enum class output_scaling_mode
enum class stereo_render_mode_options
{
disabled,
anaglyph,
side_by_side,
over_under
over_under,
anaglyph_red_green,
anaglyph_red_blue,
anaglyph_red_cyan,
anaglyph_magenta_cyan,
anaglyph_trioscopic,
};
enum class xfloat_accuracy

View File

@ -1286,9 +1286,13 @@ QString emu_settings::GetLocalizedSetting(const QString& original, emu_settings_
switch (static_cast<stereo_render_mode_options>(index))
{
case stereo_render_mode_options::disabled: return tr("Disabled", "3D Display Mode");
case stereo_render_mode_options::anaglyph: return tr("Anaglyph", "3D Display Mode");
case stereo_render_mode_options::side_by_side: return tr("Side-by-side", "3D Display Mode");
case stereo_render_mode_options::over_under: return tr("Over-under", "3D Display Mode");
case stereo_render_mode_options::anaglyph_red_green: return tr("Anaglyph Red-Green", "3D Display Mode");
case stereo_render_mode_options::anaglyph_red_blue: return tr("Anaglyph Red-Blue", "3D Display Mode");
case stereo_render_mode_options::anaglyph_red_cyan: return tr("Anaglyph Red-Cyan", "3D Display Mode");
case stereo_render_mode_options::anaglyph_magenta_cyan: return tr("Anaglyph Magenta-Cyan", "3D Display Mode");
case stereo_render_mode_options::anaglyph_trioscopic: return tr("Anaglyph Green-Magenta (Trioscopic)", "3D Display Mode");
}
break;
case emu_settings_type::MidiDevices:

View File

@ -117,7 +117,7 @@ public:
const QString disable_fifo_reordering = tr("Disables RSX FIFO optimizations completely. Draws are processed as they are received by the DMA puller.");
const QString gpu_texture_scaling = tr("Force all texture transfer, scaling and conversion operations on the GPU.\nMay cause texture corruption in some cases.");
const QString strict_texture_flushing = tr("Forces texture flushing even in situations where it is not necessary/correct. Known to cause visual artifacts, but useful for debugging certain texture cache issues.");
const QString stereo_render_mode = tr("Sets the 3D stereo rendering mode.\nAnaglyph is traditional blue-red.\nSide-by-Side is more commonly supported by VR viewer apps.\nOver-Under is closer to the native stereo output, but less commonly supported.");
const QString stereo_render_mode = tr("Sets the 3D stereo rendering mode.\nAnaglyph uses different colors for each eye, which can then be filtered with certain glasses.\nSide-by-Side is more commonly supported by VR viewer apps.\nOver-Under is closer to the native stereo output, but less commonly supported.");
const QString accurate_ppu_128_loop = tr("When enabled, PPU atomic operations will operate on entire cache line data, as opposed to a single 64bit block of memory when disabled.\nNumerical values control whether or not to enable the accurate version based on the atomic operation's length.");
const QString enable_performance_report = tr("Measure certain events and print a chart after the emulator is stopped. Don't enable if not asked to.");
const QString num_ppu_threads = tr("Affects maximum amount of PPU threads running concurrently, the value of 1 has very low compatibility with games.\n2 is the default, if unsure do not modify this setting.");