Loads and loads of small improvements I added while developing on my game
This commit is contained in:
parent
41421b1df9
commit
a7c71e7ea1
107 changed files with 2278 additions and 1023 deletions
46
SMCode/SM.Base/PostEffects/PostProcessFinals.cs
Normal file
46
SMCode/SM.Base/PostEffects/PostProcessFinals.cs
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
using System.Windows.Controls;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using SM.Base.PostProcess;
|
||||
using SM.Base.Windows;
|
||||
using SM.OGL.Framebuffer;
|
||||
using SM.Utility;
|
||||
|
||||
namespace SM.Base.PostEffects
|
||||
{
|
||||
public class PostProcessFinals
|
||||
{
|
||||
static PostProcessShader _hdrExposureShader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath+".finalize_hdr.glsl"));
|
||||
static PostProcessShader _gammaShader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile(SMRenderer.PostProcessPath + ".finalize_gamma.glsl"));
|
||||
|
||||
public static float Gamma = 2.2f;
|
||||
|
||||
public static void ResolveMultisampledBuffers(Framebuffer multisampledBuffers, Framebuffer target)
|
||||
{
|
||||
multisampledBuffers.Activate(FramebufferTarget.ReadFramebuffer);
|
||||
target.Activate(FramebufferTarget.DrawFramebuffer);
|
||||
GL.BlitFramebuffer(0, 0, (int)multisampledBuffers.Size.X, (int)multisampledBuffers.Size.Y, 0, 0, (int)target.Size.X, (int)target.Size.Y, ClearBufferMask.ColorBufferBit, BlitFramebufferFilter.Nearest);
|
||||
|
||||
target.Activate();
|
||||
}
|
||||
|
||||
public static void FinalizeHDR(ColorAttachment attachment, float exposure)
|
||||
{
|
||||
|
||||
_hdrExposureShader.Draw(u =>
|
||||
{
|
||||
u["Gamma"].SetUniform1(Gamma);
|
||||
u["Exposure"].SetUniform1(exposure);
|
||||
u["Scene"].SetTexture(attachment);
|
||||
});
|
||||
}
|
||||
|
||||
public static void FinalizeGamma(ColorAttachment attachment)
|
||||
{
|
||||
_gammaShader.Draw(u =>
|
||||
{
|
||||
u["Gamma"].SetUniform1(Gamma);
|
||||
u["Scene"].SetTexture(attachment);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue