Skip to content

Commit

Permalink
aaa
Browse files Browse the repository at this point in the history
  • Loading branch information
nishinji committed Jul 22, 2023
1 parent 115fdd5 commit b85452e
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 9 deletions.
2 changes: 1 addition & 1 deletion vita3k/renderer/src/gl/screen_render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ bool ScreenRenderer::init(const std::string &base_path) {
const auto builtin_shaders_path = base_path + "shaders-builtin/opengl/";

m_render_shader_nofilter = ::gl::load_shaders(builtin_shaders_path + "render_main.vert", builtin_shaders_path + "render_main.frag");
m_render_shader_fxaa = ::gl::load_shaders(builtin_shaders_path + "render_main.vert", builtin_shaders_path + "render_main_color_inversion.frag");
m_render_shader_fxaa = ::gl::load_shaders(builtin_shaders_path + "render_main.vert", builtin_shaders_path + "render_main_fxaa.frag");
if (!m_render_shader_nofilter || !m_render_shader_fxaa) {
LOG_CRITICAL("Couldn't compile essential shaders for rendering. Exiting");
return false;
Expand Down
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/opengl/render_main_4xhq.frag
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ void main()
w4 = clamp(k*dot(abs(c-i4),dt)/w4+mx,min_w,max_w);

color_frag.rgb = w1*i1 + w2*i2 + w3*i3 + w4*i4 + (1.0-w1-w2-w3-w4)*c;
}
}
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/opengl/render_main_4xhq.vert
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ void main()
v_texcoord6.xy = v_texcoord0.xy + dg1;
v_texcoord5.zw = v_texcoord0.xy - dg2;
v_texcoord6.zw = v_texcoord0.xy + dg2;
}
}
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/opengl/render_main_5xBR.frag
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ void main(){
//}
FragColor.rgb = res;
//FragColor.a = 1.0;
}
}
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/opengl/render_main_gaussian.frag
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ void main() {
vec3 diagonalB = blurDiagonal(fb, uv_frag, tex_offset * vec2(1.0, -1.0)).rgb;
vec3 combination = mix(mix(horizontal, vertical, 0.5f), mix(diagonalA, diagonalB, 0.5f), 0.5f);
color_frag = vec4(combination + base, 1.0f);
}
}
45 changes: 45 additions & 0 deletions vita3k/shaders-builtin/opengl/render_main_scale2x.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Vita3K emulator project
// Shader implementation of Scale2x is adapted from https://gist.github.com/singron/3161079

#version 410 core

in vec2 uv_frag;
uniform sampler2D fb;
uniform vec2 inv_frame_size;

out vec3 color_frag;

void main() {
// o = offset, the width of a pixel
vec2 o = 1.0 / inv_frame_size;

// texel arrangement
// A B C
// D E F
// G H I
vec3 B = texture2D(fb, uv_frag.xy + vec2( 0.0, o.y)).xyz;
vec3 D = texture2D(fb, uv_frag.xy + vec2( -o.x, 0.0)).xyz;
vec3 E = texture2D(fb, uv_frag.xy + vec2( 0.0, 0.0)).xyz;
vec3 F = texture2D(fb, uv_frag.xy + vec2( o.x, 0.0)).xyz;
vec3 H = texture2D(fb, uv_frag.xy + vec2( 0.0, -o.y)).xyz;
vec2 p = uv_frag * inv_frame_size;
// p = the uv_frag within a pixel [0...1]
p = fract(p);
if (p.x > .5) {
if (p.y > .5) {
// Top Right
color_frag.xyz = B == F && B != D && F != H ? F : E;
} else {
// Bottom Right
color_frag.xyz = H == F && D != H && B != F ? F : E;
}
} else {
if (p.y > .5) {
// Top Left
color_frag.xyz = D == B && B != F && D != H ? D : E;
} else {
// Bottom Left
color_frag.xyz = D == H && D != B && H != F ? D : E;
}
}
}
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/vulkan/render_main_4xhq.frag
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ void main()
w4 = clamp(k*dot(abs(c-i4),dt)/w4+mx,min_w,max_w);

color_frag.rgb = w1*i1 + w2*i2 + w3*i3 + w4*i4 + (1.0-w1-w2-w3-w4)*c;
}
}
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/vulkan/render_main_4xhq.vert
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ void main()
v_texcoord6.xy = v_texcoord0.xy + dg1;
v_texcoord5.zw = v_texcoord0.xy - dg2;
v_texcoord6.zw = v_texcoord0.xy + dg2;
}
}
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/vulkan/render_main_5xBR.frag
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ void main(){
//}
color_frag.rgb = res;
//FragColor.a = 1.0;
}
}
2 changes: 1 addition & 1 deletion vita3k/shaders-builtin/vulkan/render_main_gaussian.frag
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ void main() {
vec3 diagonalB = blurDiagonal(fb, uv_frag, tex_offset * vec2(1.0, -1.0)).rgb;
vec3 combination = mix(mix(horizontal, vertical, 0.5f), mix(diagonalA, diagonalB, 0.5f), 0.5f);
color_frag = vec3(combination + base);
}
}

0 comments on commit b85452e

Please sign in to comment.