How is explicit multisampling different from regular multisampling in OpenGL

廉价感情. 提交于 2019-12-10 16:47:15

问题


I was reading this tutorial on MSAA in deferred shading, from 28byteslater.com.

It says that in explicit multisampling we can access a particular sample.

Could not we do the same from a regular texture that was bound to GL_TEXTURE_2D_MULTISAMPLE for instance?

This was the shader code that I used to use earlier for accessing individual samples (without using explict multisampling):

uniform sampler2DMS Diffuse;

ivec2 Texcoord          = ivec2(textureSize(Diffuse) * In.Texcoord);
vec4  colorFirstSample  = texelFetch(Diffuse, Texcoord, 0);
vec4  colorSecondSample = texelFetch(Diffuse, Texcoord, 1);
vec4  colorThirdSample  = texelFetch(Diffuse, Texcoord, 2);

The only thing I see different in explicit multisampling is that they are using texelFetchRenderbuffer() in shader and texture is bound to GL_TEXTURE_RENDERBUFFER_NV. Plus If I remember correctly its not possible to use a RenderBuffer in shader and now we can?


回答1:


I think you are a little confused. Before OpenGL 3.2 / DirectX 10 came along, the only way to do multisample anti-aliasing (MSAA) was to blit a multisample buffer and have it do the "resolve" (the process by which multiple samples are literally resolved into a single sample for normal output). This was about all multisampling was good for, too - it could not be used explicitly in shaders.

GL3.2 / DX10 introduced "explicit" (programmable) multisample resolve, in the form of multisample textures. The way you access the individual samples in a shader is through the use of texelFetch (...). This new functionality allows MSAA to be implemented in deferred shading engines, because now the lighting shader is able to multisample resolve the G-Buffers when they are fetched. This new feature also opened up the possibility of using multisample buffers for things unrelated to anti-aliasing, order-independent transparency through a technique called Stencil Routed A-Buffering comes to mind immediately.

In short, DX10-class hardware allows multisample buffers to function as textures. This means very little had to be done to existing shading languages like HLSL and GLSL in order to expose multisample fetches; you do sacrifice certain things like mipmaps and filtering, but you can actually implement those yourself if you are so inclined. One thing DX10 lacked, however, was support for multisample depth textures - DX10.1 added this.

Prior to OpenGL 3.2, there were vendor specific extensions (e.g. NV_explicit_multisample) that allowed multisample texturing, since the hardware had already supported it since ~2007 (with the release of DX10). On OpenGL 3.2 implementations, ignore the vendor specific stuff and simply use ARB_texture_multisample.



来源:https://stackoverflow.com/questions/19461133/how-is-explicit-multisampling-different-from-regular-multisampling-in-opengl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!