diff --git a/GPU/GLES/Framebuffer.cpp b/GPU/GLES/Framebuffer.cpp index 3ee793d483..fff549a92f 100644 --- a/GPU/GLES/Framebuffer.cpp +++ b/GPU/GLES/Framebuffer.cpp @@ -835,7 +835,7 @@ void FramebufferManager::CopyDisplayToOutput() { // These are in the output display coordinates DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, true, 480.0f / (float)vfb->width, 272.0f / (float)vfb->height); } else if (usePostShader_ && extraFBOs_.size() == 1 && !postShaderAtOutputResolution_) { - // An additional pass, FXAA to the extra FBO. + // An additional pass, post-processing shader to the extra FBO. fbo_bind_as_render_target(extraFBOs_[0]); int fbo_w, fbo_h; fbo_get_dimensions(extraFBOs_[0], &fbo_w, &fbo_h); @@ -844,7 +844,7 @@ void FramebufferManager::CopyDisplayToOutput() { fbo_unbind(); - // Use the extra FBO, with applied FXAA, as a texture. + // Use the extra FBO, with applied post-processing shader, as a texture. // fbo_bind_color_as_texture(extraFBOs_[0], 0); if (extraFBOs_.size() == 0) { ERROR_LOG(G3D, "WTF?"); diff --git a/GPU/GLES/Framebuffer.h b/GPU/GLES/Framebuffer.h index bf669f2c47..28427e28eb 100644 --- a/GPU/GLES/Framebuffer.h +++ b/GPU/GLES/Framebuffer.h @@ -206,7 +206,7 @@ private: bool usePostShader_; bool postShaderAtOutputResolution_; - // Used by antialiasing + // Used by post-processing shader std::vector extraFBOs_; bool resized_; diff --git a/assets/shaders/bloom.fsh b/assets/shaders/bloom.fsh new file mode 100644 index 0000000000..908545177f --- /dev/null +++ b/assets/shaders/bloom.fsh @@ -0,0 +1,48 @@ +// Simple Bloom shader; created to use in PPSSPP. +// Without excessive samples and complex nested loops +// (to make it compatible with low-end GPUs and to ensure ps_2_0 compatibility). + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +varying vec2 v_texcoord0; + +float amount = 0.75; // suitable range = 0.00 - 1.00 +float power = 0.5; // suitable range = 0.0 - 1.0 + +void main() +{ + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + vec4 sum = vec4(0); + vec3 bloom; + + for(int i= -2 ;i < 2; i++) + { + sum += texture2D(sampler0, v_texcoord0 + vec2(-1, i)*0.004) * amount; + sum += texture2D(sampler0, v_texcoord0 + vec2(0, i)*0.004) * amount; + sum += texture2D(sampler0, v_texcoord0 + vec2(1, i)*0.004) * amount; + } + + if (color.r < 0.3) + { + bloom = sum.xyz*sum.xyz*0.012 + color; + } + else + { + if (color.r < 0.5) + { + bloom = sum.xyz*sum.xyz*0.009 + color; + } + else + { + bloom = sum.xyz*sum.xyz*0.0075 + color; + } + } + + bloom = mix(color, bloom, power); + gl_FragColor.rgb = bloom; + gl_FragColor.a = 1.0; +} diff --git a/assets/shaders/defaultshaders.ini b/assets/shaders/defaultshaders.ini index 1b518b2a8b..1f492860ea 100644 --- a/assets/shaders/defaultshaders.ini +++ b/assets/shaders/defaultshaders.ini @@ -18,6 +18,14 @@ Name=Vignette Author=Henrik Fragment=vignette.fsh Vertex=fxaa.vsh +[Bloom] +Name=Bloom +Fragment=bloom.fsh +Vertex=fxaa.vsh +[Sharpen] +Name=Sharpen +Fragment=sharpen.fsh +Vertex=fxaa.vsh [InverseColors] Name=Inverse Colors Author=Henrik @@ -45,4 +53,4 @@ Name=Spline36 Upscaler Fragment=upscale_spline36.fsh Vertex=upscale_spline36.vsh OutputResolution=True -RequiresIntSupport=True \ No newline at end of file +RequiresIntSupport=True diff --git a/assets/shaders/sharpen.fsh b/assets/shaders/sharpen.fsh new file mode 100644 index 0000000000..d5ad04de54 --- /dev/null +++ b/assets/shaders/sharpen.fsh @@ -0,0 +1,19 @@ +// Simple sharpen shader; created to use in PPSSPP + +#ifdef GL_ES +precision mediump float; +precision mediump int; +#endif + +uniform sampler2D sampler0; +varying vec2 v_texcoord0; + +float amount = 1.5; + +void main() +{ + vec3 color = texture2D(sampler0, v_texcoord0.xy).xyz; + color -= texture2D(sampler0, v_texcoord0.xy+0.0001).xyz*7.0*amount; + color += texture2D(sampler0, v_texcoord0.xy-0.0001).xyz*7.0*amount; + gl_FragColor.rgb = color; +}