Multisample Texture: Difference between revisions

From OpenGL Wiki
Jump to navigation Jump to search
Stub page for these.
 
mNo edit summary
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''Multisample Textures''' are [[Textures]] that have multiple samples per pixel. This allows them to be used as [[Multisampling|multisample]] render targets, but also as source data for [[Shader|shaders]].
A '''Multisample Texture''' is a [[Texture]] that can have [[Multisampling|multiple samples per pixel]], thereby allowing it to be used in multisampled rendering. As they are textures, their multiple samples can also be fetched from [[Shader|shaders]].


{{stub}}
{{stub}}
There are only two multisampled texture targets: 2D textures, and 2D array textures ({{enum|GL_TEXTURE_2D_MULTISAMPLE}} and {{enum|GL_TEXTURE_2D_ARRAY_MULTISAMPLE}} respectively).
Creating a multisample texture requires using {{apifunc|glTexStorage2DMultisample}}, {{apifunc|glTexStorage3DMultisample}} for 2D array textures (or the {{code|glTexImage*Multisample}} equivalents):
<syntaxhighlight lang="cpp">
GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, w, h, GL_TRUE);
//Attach to an FBO:
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex, 0);
</syntaxhighlight>
Similar functions are provided for using multisample render buffer with your frame buffer: e.g.: {{apifunc|glRenderbufferStorageMultisample}}
You may use {{apifunc|glBlitFramebuffer}} to perform a [[Multisampling#Multisample_Resolve|multisample resolve operation]] by [[Framebuffer#Blitting|copying to a non-multisampled framebuffer object]].


[[Category:Textures]]
[[Category:Textures]]

Latest revision as of 14:01, 28 December 2021

A Multisample Texture is a Texture that can have multiple samples per pixel, thereby allowing it to be used in multisampled rendering. As they are textures, their multiple samples can also be fetched from shaders.

There are only two multisampled texture targets: 2D textures, and 2D array textures (GL_TEXTURE_2D_MULTISAMPLE and GL_TEXTURE_2D_ARRAY_MULTISAMPLE respectively).

Creating a multisample texture requires using glTexStorage2DMultisample, glTexStorage3DMultisample for 2D array textures (or the glTexImage*Multisample equivalents):

GLuint tex;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, tex);
glTexStorage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, w, h, GL_TRUE);

//Attach to an FBO:
glFramebufferTexture(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, tex, 0);

Similar functions are provided for using multisample render buffer with your frame buffer: e.g.: glRenderbufferStorageMultisample

You may use glBlitFramebuffer to perform a multisample resolve operation by copying to a non-multisampled framebuffer object.