Add reverse_interlaced uniform flag

This commit is contained in:
OneUp03 2020-10-21 12:27:02 -05:00
parent a4f57e6910
commit 33d233fffa

View file

@ -302,28 +302,11 @@ uniform vec4 o_resolution;
uniform sampler2D color_texture; uniform sampler2D color_texture;
uniform sampler2D color_texture_r; uniform sampler2D color_texture_r;
void main() { uniform int reverse_interlaced;
float screen_row = o_resolution.x * frag_tex_coord.x;
if (int(screen_row) % 2 == 0)
color = texture(color_texture, frag_tex_coord);
else
color = texture(color_texture_r, frag_tex_coord);
}
)";
static const char fragment_shader_reverse_interlaced[] = R"(
in vec2 frag_tex_coord;
out vec4 color;
uniform vec4 o_resolution;
uniform sampler2D color_texture;
uniform sampler2D color_texture_r;
void main() { void main() {
float screen_row = o_resolution.x * frag_tex_coord.x; float screen_row = o_resolution.x * frag_tex_coord.x;
if (int(screen_row) % 2 == 1) if (int(screen_row) % 2 == reverse_interlaced)
color = texture(color_texture, frag_tex_coord); color = texture(color_texture, frag_tex_coord);
else else
color = texture(color_texture_r, frag_tex_coord); color = texture(color_texture_r, frag_tex_coord);
@ -711,7 +694,8 @@ void RendererOpenGL::ReloadShader() {
shader_data += shader_text; shader_data += shader_text;
} }
} }
} else if (Settings::values.render_3d == Settings::StereoRenderOption::Interlaced) { } else if (Settings::values.render_3d == Settings::StereoRenderOption::Interlaced ||
Settings::values.render_3d == Settings::StereoRenderOption::ReverseInterlaced) {
if (Settings::values.pp_shader_name == "horizontal (builtin)") { if (Settings::values.pp_shader_name == "horizontal (builtin)") {
shader_data += fragment_shader_interlaced; shader_data += fragment_shader_interlaced;
} else { } else {
@ -724,19 +708,6 @@ void RendererOpenGL::ReloadShader() {
shader_data += shader_text; shader_data += shader_text;
} }
} }
} else if (Settings::values.render_3d == Settings::StereoRenderOption::ReverseInterlaced) {
if (Settings::values.pp_shader_name == "horizontal (builtin)") {
shader_data += fragment_shader_reverse_interlaced;
} else {
std::string shader_text =
OpenGL::GetPostProcessingShaderCode(true, Settings::values.pp_shader_name);
if (shader_text.empty()) {
// Should probably provide some information that the shader couldn't load
shader_data += fragment_shader_reverse_interlaced;
} else {
shader_data += shader_text;
}
}
} else { } else {
if (Settings::values.pp_shader_name == "none (builtin)") { if (Settings::values.pp_shader_name == "none (builtin)") {
shader_data += fragment_shader; shader_data += fragment_shader;
@ -761,6 +732,15 @@ void RendererOpenGL::ReloadShader() {
Settings::values.render_3d == Settings::StereoRenderOption::ReverseInterlaced) { Settings::values.render_3d == Settings::StereoRenderOption::ReverseInterlaced) {
uniform_color_texture_r = glGetUniformLocation(shader.handle, "color_texture_r"); uniform_color_texture_r = glGetUniformLocation(shader.handle, "color_texture_r");
} }
if (Settings::values.render_3d == Settings::StereoRenderOption::Interlaced ||
Settings::values.render_3d == Settings::StereoRenderOption::ReverseInterlaced) {
GLuint uniform_reverse_interlaced =
glGetUniformLocation(shader.handle, "reverse_interlaced");
if (Settings::values.render_3d == Settings::StereoRenderOption::ReverseInterlaced)
glUniform1i(uniform_reverse_interlaced, 1);
else
glUniform1i(uniform_reverse_interlaced, 0);
}
uniform_i_resolution = glGetUniformLocation(shader.handle, "i_resolution"); uniform_i_resolution = glGetUniformLocation(shader.handle, "i_resolution");
uniform_o_resolution = glGetUniformLocation(shader.handle, "o_resolution"); uniform_o_resolution = glGetUniformLocation(shader.handle, "o_resolution");
uniform_layer = glGetUniformLocation(shader.handle, "layer"); uniform_layer = glGetUniformLocation(shader.handle, "layer");