14 minutes ago, matt77hias said:
But in case of MSAA what would the purpose of the AA resolve shader be? Temporal AA only?
The MSAA resolve shader is just sampling all your subsamples of the MSAA texture and averaging them. Now, DX11 provides a built in function for this, but you want to avoid it and write your own if you have a HDR pipeline with tonemap - average - inversetonemap.
26 minutes ago, matt77hias said:
So you render all models (opaque and transparent) first and perform a clip in the PS based on the alpha value and some threshold (or just 1.0f?). Then you render only transparent models with alpha blending, and only reading the depth buffer.
I actually perform a similar approach if the user does not select MSAA. Though, I do not have the only reading the depth buffer part, but this is not really an issue I suppose if you don't use the depth buffer anymore (sprites just go on top). The alpha blended geometry looks pretty artificial? If I go up and look at the Crytek Sponza scene from above, the pillar plants look very white since they start blending with each other.
The opaque clipping is like this:
clip(baseColor.a - AlphaTestThreshold);
Where AlphaTestThreshold is 1.0f / 255.0f by default (so that only the completely transparent parts are clipped, but the user can modify it with values between 0 and 1.
The transparent part is depth read not equal because we need to reject samples based on depth test, so every part of the texture gets discarded which was rendered in the opaque pass. Optionally, there could be an additional clip(alpha - 1.0/255.0) to try to early out on the completely transparent parts. The blending equation should be color = ( srcA x srcCol ) + ( invSrcA x destCol ) , so you shouldn't be getting white on the plants as you say. You should be getting something like the attached image. You could notice sorting artifacts where there is a lot of overlap, but that is not so obvious. Instead you get very nice soft edges on distant silhouettes for example, see the part where there is sky at the background. Anyway, this is getting off-topic. ![:) :)](https://uploads.gamedev.net/emoticons/medium.smile.webp)
![grass.png](https://uploads.gamedev.net/monthly_2017_10/grass.png.ea982a0703979956bed9fba1a4732aae.png)