mirror of
https://github.com/luanti-org/luanti.git
synced 2025-09-30 19:22:14 +00:00
Implement support for FSAA in combination with post-processing (#15392)
- Actually it's MSAA I think, or perhaps the terms are equivalent - I've made it fit into the existing Irrlicht architecture, but that has resulted in code duplication compared to my original "hacky" approach - OpenGL 3.2+ and OpenGL ES 3.1+ are supported - EDT_OPENGL3 is not required, EDT_OPENGL works too - Helpful tutorial: https://learnopengl.com/Advanced-OpenGL/Anti-Aliasing, section "Off-screen MSAA" - This may be rough around the edges, but in general it works
This commit is contained in:
parent
a8ea165042
commit
9b6a399011
23 changed files with 290 additions and 42 deletions
|
@ -26,7 +26,7 @@ video::ITexture *TextureBuffer::getTexture(u8 index)
|
|||
}
|
||||
|
||||
|
||||
void TextureBuffer::setTexture(u8 index, core::dimension2du size, const std::string &name, video::ECOLOR_FORMAT format, bool clear)
|
||||
void TextureBuffer::setTexture(u8 index, core::dimension2du size, const std::string &name, video::ECOLOR_FORMAT format, bool clear, u8 msaa)
|
||||
{
|
||||
assert(index != NO_DEPTH_TEXTURE);
|
||||
|
||||
|
@ -41,9 +41,10 @@ void TextureBuffer::setTexture(u8 index, core::dimension2du size, const std::str
|
|||
definition.name = name;
|
||||
definition.format = format;
|
||||
definition.clear = clear;
|
||||
definition.msaa = msaa;
|
||||
}
|
||||
|
||||
void TextureBuffer::setTexture(u8 index, v2f scale_factor, const std::string &name, video::ECOLOR_FORMAT format, bool clear)
|
||||
void TextureBuffer::setTexture(u8 index, v2f scale_factor, const std::string &name, video::ECOLOR_FORMAT format, bool clear, u8 msaa)
|
||||
{
|
||||
assert(index != NO_DEPTH_TEXTURE);
|
||||
|
||||
|
@ -58,6 +59,7 @@ void TextureBuffer::setTexture(u8 index, v2f scale_factor, const std::string &na
|
|||
definition.name = name;
|
||||
definition.format = format;
|
||||
definition.clear = clear;
|
||||
definition.msaa = msaa;
|
||||
}
|
||||
|
||||
void TextureBuffer::reset(PipelineContext &context)
|
||||
|
@ -125,13 +127,19 @@ bool TextureBuffer::ensureTexture(video::ITexture **texture, const TextureDefini
|
|||
|
||||
if (definition.valid) {
|
||||
if (definition.clear) {
|
||||
// We're not able to clear a render target texture
|
||||
// We're not able to create a normal texture with MSAA
|
||||
// (could be solved by more refactoring in Irrlicht, but not needed for now)
|
||||
sanity_check(definition.msaa < 1);
|
||||
|
||||
video::IImage *image = m_driver->createImage(definition.format, size);
|
||||
// Cannot use image->fill because it's not implemented for all formats.
|
||||
std::memset(image->getData(), 0, image->getDataSizeFromFormat(definition.format, size.Width, size.Height));
|
||||
*texture = m_driver->addTexture(definition.name.c_str(), image);
|
||||
image->drop();
|
||||
}
|
||||
else {
|
||||
} else if (definition.msaa > 0) {
|
||||
*texture = m_driver->addRenderTargetTextureMs(size, definition.msaa, definition.name.c_str(), definition.format);
|
||||
} else {
|
||||
*texture = m_driver->addRenderTargetTexture(size, definition.name.c_str(), definition.format);
|
||||
}
|
||||
}
|
||||
|
@ -189,6 +197,12 @@ void TextureBufferOutput::activate(PipelineContext &context)
|
|||
RenderTarget::activate(context);
|
||||
}
|
||||
|
||||
video::IRenderTarget *TextureBufferOutput::getIrrRenderTarget(PipelineContext &context)
|
||||
{
|
||||
activate(context); // Needed to make sure that render_target is set up.
|
||||
return render_target;
|
||||
}
|
||||
|
||||
u8 DynamicSource::getTextureCount()
|
||||
{
|
||||
assert(isConfigured());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue