Multisample Texture: Difference between revisions
No edit summary |
Added linking, formatting, and improved descriptions. |
||
| Line 1: | Line 1: | ||
A '''Multisample Texture''' is a [[Texture]] that can have multiple samples per pixel | 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}} | |||
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: | |||
You may use | <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]] | ||
Revision as of 18:25, 14 May 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.
| This article is a stub. You can help the OpenGL Wiki by expanding it. |
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.