Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Perfect Dark frame buffer effects do not work when FSAA is on. #244

Closed
gonetz opened this issue Feb 19, 2015 · 13 comments
Closed

Perfect Dark frame buffer effects do not work when FSAA is on. #244

gonetz opened this issue Feb 19, 2015 · 13 comments

Comments

@gonetz
Copy link
Owner

gonetz commented Feb 19, 2015

Cap Spy, Night Vision and other full-screen effects does not work with FSAA on

@gonetz
Copy link
Owner Author

gonetz commented Feb 19, 2015

Technical issue. Hard to resolve.

@gonetz
Copy link
Owner Author

gonetz commented Apr 3, 2015

Paper Mario, same issue

@ghost
Copy link

ghost commented Apr 16, 2015

I thought with shaders you can resolve from multisampled render targets/FBOs. :/

Not sure how you are doing it on a technical level but:
http://www.learnopengl.com/#!Advanced-OpenGL/Anti-Aliasing

is interesting at least. For my graphics stuff, I am using a FXAA shader as a postprocess for edge reduction.

@gonetz
Copy link
Owner Author

gonetz commented Apr 16, 2015

Yes, it is possible. In fact you have to manually blend samples from multisampling texture in your shader. Sounds creepy, so I left it for better times.

@purplemarshmallow
Copy link
Contributor

AA breaks the rocket launcher in Conker's BFD and possibly other framebuffer effects in this game

@ghost
Copy link

ghost commented May 4, 2015

Would it be possible to add a bruteforce method of supersampling as an alternative to combat this?

I know you can set custom resolutions for the glide plugin, eg 960x720. Add two radio buttons above the anti aliasing slider, one that says "Multisampling (default)" and the other that says "Supersampling" (that way people use the original method by default but if they run into problems they can try the alternative).

As for the feature, if Supersampling is selected it takes the multiple and then multiplies the resolution you've selected by this number. If your resolution is 960x720 and your anti aliasing value 4x it'd render at 3840x2800. Then, add a resize (like Lanczos) to that to resize back down to the initial resolution, so 960x720. That way the plugin is just rendering at a larger resolution, then resizing the output down back to the selected resolution and displaying at what the user selected.

It'd be performance intensive and I know a lot of systems could struggle with it, but high end systems could handle it and as hardware evolves it'd definitely become a standard.

I'm not sure how the current method works, nor am I sure how complicated it'd be on a programming level to do this. But would a method like that fix or help the issue?

@ghost
Copy link

ghost commented May 5, 2015

No.
Solution is to resolve MSAA'd FBOs properly.

An example pixel shader of how to resolve MSAA'ed FBOs is as follows:

uniform sampler2DMS u_framebufferTexture;
uniform int u_msaaSamples;
in vec2 v_texCoord;

vec4 sampleMS(sampler2DMS texture, ivec2 ipos)
{
vec4 texel = vec4(0.0);
for (int i = 0; i < u_msaaSamples; i++)
{
texel += texelFetch(texture, ipos, i);
}
texel /= float(u_msaaSamples);
return texel;
}

void main(void)
{
// MSAA sampling.
vec2 framebufferTextureSize = vec2(textureSize(u_framebufferTexture));
ivec2 itexCoord = ivec2(framebufferTextureSize * v_texCoord);
vec3 Color = sampleMS(u_framebufferTexture, itexCoord).rgb;
//do shit with Color
.........................
}

Removes the need for a intermediate FBO to resolve to, since MSAA resolving is done in the pixel shader.

@gonetz
Copy link
Owner Author

gonetz commented May 5, 2015

Thanks mudlord!
Yes, MSAA must be resolved in shaders and I planned to do that.
Current solution with resolve to texture is temporal. Shaders code was in rework when I implemented AA, I did not want to add new level of complexity into it.
I think, now it should be not hard to do.

@degasus
Copy link

degasus commented May 5, 2015

Custom sampling is possible, but it will kill performance a bit, at least if you want to support either linear filtering or mipmaps.
@mudlord Don't use "texel /= float(u_msaaSamples);", plese just generate "1/u_msaaSamples" on the CPU.

If you need any filter settings, it's likely worth to do a glBlitFramebuffer call first. Also the common MSAA resolving hardware uses better method than just averaging the samples.

@gonetz
Copy link
Owner Author

gonetz commented May 6, 2015

Plugin does not use multisampled mip-mapped textures. The problem arises when frame buffer emulation requires to use multisampled FBO texture as input in shader program. There are cases, where resolving with glBlitFramebuffer is not enough. So the choice is between "imperfect custom sampling" and "no MSAA".

@Mushman
Copy link
Contributor

Mushman commented May 6, 2015

Good work figuring it out and thanks to @mudlord for their contribution!

@purplemarshmallow
Copy link
Contributor

this is fixed
but #249 is not fixed

gonetz added a commit that referenced this issue May 13, 2015
Thanks mudlord for the idea.

Fixed Perfect Dark frame buffer effects do not work when FSAA is on. #244
@AmbientMalice
Copy link
Contributor

This issue is fixed, I believe, so it can be closed.

@gonetz gonetz closed this as completed Jun 25, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants