08 Oct 2021

~ Fixed Issue with SM.Intergrations.STPostProcessEffect where it would create wierd artifacts when rendered.
~ Moved the initialization process to the RenderPipeline.InitializationProcess-method.
~ PixelInformation.RGB_HDR now use PixelInternalFormat.R11fG11fB10f
This commit is contained in:
Nineto Nine 2021-10-08 22:09:47 +02:00
parent 8a84182563
commit 687125cc3e
6 changed files with 45 additions and 15 deletions

View file

@ -16,6 +16,7 @@ namespace SM.Intergrations.ShaderTool
public class STPostProcessEffect : PostProcessEffect
{
private STPostProcessShader _shader;
private Framebuffer tempFramebuffer;
public ShaderArguments Arguments;
@ -39,13 +40,29 @@ namespace SM.Intergrations.ShaderTool
}
}
protected override void InitProcess()
{
base.InitProcess();
tempFramebuffer = Pipeline.CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false);
tempFramebuffer.Compile();
}
public override void ScreenSizeChanged(IGenericWindow window)
{
tempFramebuffer.Recompile();
}
protected override void Drawing(ColorAttachment source, DrawContext context)
{
Arguments["_Scene"] = (TextureBase)source;
Arguments["_MVP"] = Mvp;
Arguments["_ViewportSize"] = context.Window.WindowSize;
source.ConnectedFramebuffer.CopyTo(tempFramebuffer);
tempFramebuffer.Activate();
_shader.Draw(Arguments);
tempFramebuffer.CopyTo(source.ConnectedFramebuffer);
}
}
}

View file

@ -188,8 +188,6 @@ namespace SM.Base.PostEffects
{
texSize /= 2;
f = new Framebuffer(texSize);
f.Append("0", new ColorAttachment(0, pixel));
_downsampler.Add(f);

View file

@ -54,16 +54,25 @@ namespace SM.Base.Window
/// <inheritdoc/>
public virtual void Activate()
{ }
/// <inheritdoc/>
public virtual void Initialization()
public void Initialization()
{
if (MainFramebuffer != null) {
InitializationProcess();
InitizePostProcessing();
if (MainFramebuffer != null)
{
Framebuffers.Add(MainFramebuffer);
MainFramebuffer.Name = GetType().Name + ".MainFramebuffer";
}
DefaultShader ??= SMRenderer.DefaultMaterialShader;
}
/// <inheritdoc/>
protected virtual void InitializationProcess()
{
}
internal void Render(ref DrawContext context)
{
RenderProcess(ref context);
@ -132,9 +141,15 @@ namespace SM.Base.Window
/// <summary>
/// This creates a finished setup for a framebuffer.
/// </summary>
public Framebuffer CreateWindowFramebuffer(int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true)
public Framebuffer CreateWindowFramebuffer(int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true) =>
CreateWindowFramebuffer(ConnectedWindow, multisamples, pixelInformation, depth);
/// <summary>
/// This creates a finished setup for a framebuffer.
/// </summary>
public static Framebuffer CreateWindowFramebuffer(IFramebufferWindow window, int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true)
{
Framebuffer framebuffer = new(ConnectedWindow);
Framebuffer framebuffer = new Framebuffer(window);
framebuffer.Append("color", new ColorAttachment(0, pixelInformation.GetValueOrDefault(PixelInformation.RGBA_LDR), multisamples:multisamples));
if (depth)

View file

@ -14,7 +14,7 @@ namespace SM.OGL.Texture
/// <summary>
/// RGB without Alpha channel, High Dynamic Range (0 - n)
/// </summary>
public static PixelInformation RGB_HDR = new PixelInformation(PixelInternalFormat.Rgb16f, PixelFormat.Rgb, PixelType.Float);
public static PixelInformation RGB_HDR = new PixelInformation(PixelInternalFormat.R11fG11fB10f, PixelFormat.Rgb, PixelType.Float);
/// <summary>
/// RGB with Alpha channel, Low Dynamic Range (0 - 1)
/// </summary>

View file

@ -63,7 +63,7 @@ namespace SM_TEST
{
ShowAxisHelper = true
});
//scene.Background.Color = Color4.Red;
scene.Background.Color = Color4.DarkGray;
scene.Camera = new Camera()
{

View file

@ -14,11 +14,13 @@ namespace SM_TEST
private BloomEffect _bloom;
private Framebuffer _postBuffer;
private STPostProcessEffect _vittage;
public override void Initialization()
protected override void InitializationProcess()
{
MainFramebuffer = CreateWindowFramebuffer(8, PixelInformation.RGBA_HDR, true);
_postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false);
Framebuffers.Add(_postBuffer);
_bloom = new BloomEffect(true, true)
{
@ -27,7 +29,7 @@ namespace SM_TEST
};
PostProcessEffects.Add(_bloom);
/*_vittage = new STPostProcessEffect(Program.portal.DrawNodes.Find(a => a.Variables.ContainsKey("_ViewportSize")))
_vittage = new STPostProcessEffect(Program.portal.DrawNodes.Find(a => a.Variables.ContainsKey("_ViewportSize")))
{
Arguments =
{
@ -37,10 +39,7 @@ namespace SM_TEST
{"Move", 3.33f}
}
};
_vittage.Initilize(this);*/
InitizePostProcessing();
base.Initialization();
PostProcessEffects.Add(_vittage);
}
protected override void RenderProcess(ref DrawContext context)
@ -56,6 +55,7 @@ namespace SM_TEST
PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
_bloom.Draw(_postBuffer["color"], context);
_vittage.Draw(_postBuffer["color"], context);
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
PostProcessUtility.FinalizeHDR(_postBuffer["color"], HDRColorCurve.OnlyExposure, .1f);