Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes #2620, though I am sure not in the cleanest way. Please provide feedback or feel free to throw this whole PR away.
#2620 shows a sample app for the SDSM filter that also uses multisampling. SDSM was not written with multisampling in mind. This change makes SDSM work with and without it.
As I explained in the issue, the problem is that the depth texture that the SDSM uses becomes multisampled, so
texture2Dbecomestexture2DMS, and the texture cannot be sampled but only fetched. Moreover, the logic in theFilterPostProcessorto handle multisampling mostly deals with materials, which the two compute shaders in SDSM are agnostic of.The change is to have
SdsmFittercheck whether the input depth texture is multisampled and compile the two shaders accordingly. This introduces some CPU overhead but is the simplest solution without having to track and maintain additional state.The crux of the change is in
MultiSample.glsllib. I have added additional overloads there to work with/out multisampled textures.I think there are still three problems not addressed here, though:
getDepth(in sampler2DMS tex, in vec2 texC)is kind of cooked. It callstextureFetch(), which is doing an average of all MS samples. This is rarely what you want for depth. Specifically, at an edge between geometry and background, it'll average values that range between "foreground" and "background" and give something in between. Rather, for depth, you typically want either a max or a min of the samples, depending on the algorithm. Here's a random post about this: https://wickedengine.net/2016/11/how-to-resolve-an-msaa-depthbuffer/ For SDSM in particular, I went with max. I also did not want to change the existinggetDepth()because that might break a whole bunch of other shaders that I have not tested.m_NumDepthSamples. The max should be just as bad as in the no-multisampling case, but not worse. I'm also not entirely familiar with SDSM anyway.SdsmFitterand individual compute shader-based post-filters to deal with multisampling. I think this would ideally be abstracted away, either by having theFilterPostProcessormanage compute shaders better, or by resolving the MS textures before the filters are called. But this would require a larger change and more discussion.Testing
I have tested the sample app in the issue with and without the line
fpp.setNumSamples(2).