Fixed MSAA
This commit is contained in:
parent
7ea788534c
commit
ddd2171da2
5 changed files with 21 additions and 9 deletions
|
|
@ -133,7 +133,7 @@ namespace SM.Base.PostEffects
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
protected override void InitProcess()
|
protected override void InitProcess()
|
||||||
{
|
{
|
||||||
_source = Pipeline.MainFramebuffer;
|
_source ??= Pipeline.MainFramebuffer;
|
||||||
|
|
||||||
_source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR;
|
_source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ namespace SM.Base.PostEffects
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This resolves a multisampled framebuffer to a non-multisampled renderbuffer.
|
/// This resolves a multisampled framebuffer to a non-multisampled renderbuffer.
|
||||||
|
/// <para>This removes the depth buffer.</para>
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="multisampledBuffers"></param>
|
/// <param name="multisampledBuffers"></param>
|
||||||
/// <param name="target"></param>
|
/// <param name="target"></param>
|
||||||
|
|
@ -36,7 +37,7 @@ namespace SM.Base.PostEffects
|
||||||
multisampledBuffers.Activate(FramebufferTarget.ReadFramebuffer);
|
multisampledBuffers.Activate(FramebufferTarget.ReadFramebuffer);
|
||||||
target.Activate(FramebufferTarget.DrawFramebuffer);
|
target.Activate(FramebufferTarget.DrawFramebuffer);
|
||||||
GL.BlitFramebuffer(0, 0, (int) multisampledBuffers.Size.X, (int) multisampledBuffers.Size.Y, 0, 0,
|
GL.BlitFramebuffer(0, 0, (int) multisampledBuffers.Size.X, (int) multisampledBuffers.Size.Y, 0, 0,
|
||||||
(int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit,
|
(int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit,
|
||||||
BlitFramebufferFilter.Nearest);
|
BlitFramebufferFilter.Nearest);
|
||||||
|
|
||||||
target.Activate();
|
target.Activate();
|
||||||
|
|
|
||||||
|
|
@ -55,6 +55,8 @@ namespace SM.OGL.Framebuffer
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<RenderbufferAttachment, int> RenderbufferAttachments { get; } = new Dictionary<RenderbufferAttachment, int>();
|
public Dictionary<RenderbufferAttachment, int> RenderbufferAttachments { get; } = new Dictionary<RenderbufferAttachment, int>();
|
||||||
|
|
||||||
|
public ColorAttachment this[string colorName] => ColorAttachments[colorName];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a buffer without any options.
|
/// Creates a buffer without any options.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,14 @@ namespace SM_TEST
|
||||||
|
|
||||||
window.SetScene(scene = new Scene());
|
window.SetScene(scene = new Scene());
|
||||||
scene.Objects.Add(new DrawObject2D());
|
scene.Objects.Add(new DrawObject2D());
|
||||||
|
scene.Objects.Add(new DrawObject2D()
|
||||||
|
{
|
||||||
|
Transform =
|
||||||
|
{
|
||||||
|
Position = new SM.Base.Types.CVector2(20,20),
|
||||||
|
ZIndex = new SM.Base.Types.CVector1(1)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
window.UpdateFrame += WindowOnUpdateFrame;
|
window.UpdateFrame += WindowOnUpdateFrame;
|
||||||
window.Run();
|
window.Run();
|
||||||
|
|
|
||||||
|
|
@ -14,14 +14,13 @@ namespace SM_TEST
|
||||||
public override void Initialization()
|
public override void Initialization()
|
||||||
{
|
{
|
||||||
|
|
||||||
MainFramebuffer = CreateWindowFramebuffer(0);
|
MainFramebuffer = CreateWindowFramebuffer(16, PixelInformation.RGBA_HDR);
|
||||||
|
|
||||||
_postBuffer = CreateWindowFramebuffer(0);
|
_postBuffer = CreateWindowFramebuffer(0, depth: false);
|
||||||
Framebuffers.Add(_postBuffer);
|
Framebuffers.Add(_postBuffer);
|
||||||
_bloom = new BloomEffect(MainFramebuffer, hdr: true, .5f)
|
_bloom = new BloomEffect(_postBuffer, hdr: true, .5f)
|
||||||
{
|
{
|
||||||
Threshold = .5f,
|
Threshold = .5f
|
||||||
Radius = 5
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -36,10 +35,12 @@ namespace SM_TEST
|
||||||
context.Scene.DrawMainObjects(context);
|
context.Scene.DrawMainObjects(context);
|
||||||
context.Scene.DrawHUD(context);
|
context.Scene.DrawHUD(context);
|
||||||
|
|
||||||
|
PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
|
||||||
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
|
||||||
|
|
||||||
_bloom.Draw(context);
|
_bloom.Draw(context);
|
||||||
|
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||||
|
|
||||||
|
PostProcessUtility.FinalizeHDR(_postBuffer["color"], 1);
|
||||||
|
|
||||||
context.Scene.DrawDebug(context);
|
context.Scene.DrawDebug(context);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue