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:
parent
8a84182563
commit
687125cc3e
6 changed files with 45 additions and 15 deletions
|
|
@ -16,6 +16,7 @@ namespace SM.Intergrations.ShaderTool
|
||||||
public class STPostProcessEffect : PostProcessEffect
|
public class STPostProcessEffect : PostProcessEffect
|
||||||
{
|
{
|
||||||
private STPostProcessShader _shader;
|
private STPostProcessShader _shader;
|
||||||
|
private Framebuffer tempFramebuffer;
|
||||||
|
|
||||||
public ShaderArguments Arguments;
|
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)
|
protected override void Drawing(ColorAttachment source, DrawContext context)
|
||||||
{
|
{
|
||||||
Arguments["_Scene"] = (TextureBase)source;
|
Arguments["_Scene"] = (TextureBase)source;
|
||||||
Arguments["_MVP"] = Mvp;
|
Arguments["_MVP"] = Mvp;
|
||||||
Arguments["_ViewportSize"] = context.Window.WindowSize;
|
Arguments["_ViewportSize"] = context.Window.WindowSize;
|
||||||
|
|
||||||
|
source.ConnectedFramebuffer.CopyTo(tempFramebuffer);
|
||||||
|
tempFramebuffer.Activate();
|
||||||
|
|
||||||
_shader.Draw(Arguments);
|
_shader.Draw(Arguments);
|
||||||
|
tempFramebuffer.CopyTo(source.ConnectedFramebuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -188,8 +188,6 @@ namespace SM.Base.PostEffects
|
||||||
{
|
{
|
||||||
texSize /= 2;
|
texSize /= 2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
f = new Framebuffer(texSize);
|
f = new Framebuffer(texSize);
|
||||||
f.Append("0", new ColorAttachment(0, pixel));
|
f.Append("0", new ColorAttachment(0, pixel));
|
||||||
_downsampler.Add(f);
|
_downsampler.Add(f);
|
||||||
|
|
|
||||||
|
|
@ -54,16 +54,25 @@ namespace SM.Base.Window
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public virtual void Activate()
|
public virtual void Activate()
|
||||||
{ }
|
{ }
|
||||||
/// <inheritdoc/>
|
public void Initialization()
|
||||||
public virtual void Initialization()
|
{
|
||||||
|
InitializationProcess();
|
||||||
|
|
||||||
|
InitizePostProcessing();
|
||||||
|
if (MainFramebuffer != null)
|
||||||
{
|
{
|
||||||
if (MainFramebuffer != null) {
|
|
||||||
Framebuffers.Add(MainFramebuffer);
|
Framebuffers.Add(MainFramebuffer);
|
||||||
MainFramebuffer.Name = GetType().Name + ".MainFramebuffer";
|
MainFramebuffer.Name = GetType().Name + ".MainFramebuffer";
|
||||||
}
|
}
|
||||||
DefaultShader ??= SMRenderer.DefaultMaterialShader;
|
DefaultShader ??= SMRenderer.DefaultMaterialShader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
protected virtual void InitializationProcess()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
internal void Render(ref DrawContext context)
|
internal void Render(ref DrawContext context)
|
||||||
{
|
{
|
||||||
RenderProcess(ref context);
|
RenderProcess(ref context);
|
||||||
|
|
@ -132,9 +141,15 @@ namespace SM.Base.Window
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This creates a finished setup for a framebuffer.
|
/// This creates a finished setup for a framebuffer.
|
||||||
/// </summary>
|
/// </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));
|
framebuffer.Append("color", new ColorAttachment(0, pixelInformation.GetValueOrDefault(PixelInformation.RGBA_LDR), multisamples:multisamples));
|
||||||
|
|
||||||
if (depth)
|
if (depth)
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace SM.OGL.Texture
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// RGB without Alpha channel, High Dynamic Range (0 - n)
|
/// RGB without Alpha channel, High Dynamic Range (0 - n)
|
||||||
/// </summary>
|
/// </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>
|
/// <summary>
|
||||||
/// RGB with Alpha channel, Low Dynamic Range (0 - 1)
|
/// RGB with Alpha channel, Low Dynamic Range (0 - 1)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ namespace SM_TEST
|
||||||
{
|
{
|
||||||
ShowAxisHelper = true
|
ShowAxisHelper = true
|
||||||
});
|
});
|
||||||
//scene.Background.Color = Color4.Red;
|
scene.Background.Color = Color4.DarkGray;
|
||||||
scene.Camera = new Camera()
|
scene.Camera = new Camera()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,11 +14,13 @@ namespace SM_TEST
|
||||||
private BloomEffect _bloom;
|
private BloomEffect _bloom;
|
||||||
|
|
||||||
private Framebuffer _postBuffer;
|
private Framebuffer _postBuffer;
|
||||||
|
private STPostProcessEffect _vittage;
|
||||||
|
|
||||||
public override void Initialization()
|
protected override void InitializationProcess()
|
||||||
{
|
{
|
||||||
MainFramebuffer = CreateWindowFramebuffer(8, PixelInformation.RGBA_HDR, true);
|
MainFramebuffer = CreateWindowFramebuffer(8, PixelInformation.RGBA_HDR, true);
|
||||||
_postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false);
|
_postBuffer = CreateWindowFramebuffer(0, PixelInformation.RGB_HDR, false);
|
||||||
|
Framebuffers.Add(_postBuffer);
|
||||||
|
|
||||||
_bloom = new BloomEffect(true, true)
|
_bloom = new BloomEffect(true, true)
|
||||||
{
|
{
|
||||||
|
|
@ -27,7 +29,7 @@ namespace SM_TEST
|
||||||
};
|
};
|
||||||
PostProcessEffects.Add(_bloom);
|
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 =
|
Arguments =
|
||||||
{
|
{
|
||||||
|
|
@ -37,10 +39,7 @@ namespace SM_TEST
|
||||||
{"Move", 3.33f}
|
{"Move", 3.33f}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
_vittage.Initilize(this);*/
|
PostProcessEffects.Add(_vittage);
|
||||||
InitizePostProcessing();
|
|
||||||
|
|
||||||
base.Initialization();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void RenderProcess(ref DrawContext context)
|
protected override void RenderProcess(ref DrawContext context)
|
||||||
|
|
@ -56,6 +55,7 @@ namespace SM_TEST
|
||||||
PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
|
PostProcessUtility.ResolveMultisampledBuffers(MainFramebuffer, _postBuffer);
|
||||||
|
|
||||||
_bloom.Draw(_postBuffer["color"], context);
|
_bloom.Draw(_postBuffer["color"], context);
|
||||||
|
_vittage.Draw(_postBuffer["color"], context);
|
||||||
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
Framebuffer.Screen.Activate(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||||
|
|
||||||
PostProcessUtility.FinalizeHDR(_postBuffer["color"], HDRColorCurve.OnlyExposure, .1f);
|
PostProcessUtility.FinalizeHDR(_postBuffer["color"], HDRColorCurve.OnlyExposure, .1f);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue