Merge branch 'master' of https://github.com/IedSoftworks/SMRendererV3
This commit is contained in:
commit
3bc90dd83b
14 changed files with 190 additions and 49 deletions
|
|
@ -15,6 +15,11 @@ namespace SM.Base.Drawing
|
|||
/// </summary>
|
||||
public abstract class DrawingBasis : IShowItem, IModelItem
|
||||
{
|
||||
/// <summary>
|
||||
/// The camera, that was used last time the object was rendered.
|
||||
/// </summary>
|
||||
public GenericCamera LastDrawingCamera;
|
||||
|
||||
/// <summary>
|
||||
/// The material it should use.
|
||||
/// </summary>
|
||||
|
|
@ -86,6 +91,8 @@ namespace SM.Base.Drawing
|
|||
context.ForcedType = ForcedMeshType;
|
||||
context.TextureMatrix *= TextureTransform.GetMatrix();
|
||||
context.LastObject = this;
|
||||
|
||||
LastDrawingCamera = context.UseCamera;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,12 @@ namespace SM.Base.PostEffects
|
|||
/// </summary>
|
||||
public float Power = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Radius of the effect
|
||||
/// <para>Default: 2</para>
|
||||
/// </summary>
|
||||
public float Radius = 1;
|
||||
|
||||
/// <summary>
|
||||
/// This can disable the bloom calculation.
|
||||
/// <para>Default: true</para>
|
||||
|
|
@ -127,7 +133,7 @@ namespace SM.Base.PostEffects
|
|||
/// <inheritdoc/>
|
||||
protected override void InitProcess()
|
||||
{
|
||||
_source = Pipeline.MainFramebuffer;
|
||||
_source ??= Pipeline.MainFramebuffer;
|
||||
|
||||
_source.ColorAttachments["color"].PixelInformation = PixelInformation.RGBA_HDR;
|
||||
|
||||
|
|
@ -175,6 +181,8 @@ namespace SM.Base.PostEffects
|
|||
collection["Weights"].SetUniform1(_weights);
|
||||
collection["WeightCount"].SetUniform1(WeightCurvePickAmount);
|
||||
collection["Power"].SetUniform1(Power);
|
||||
|
||||
collection["Radius"].SetUniform1(_textureScale * Radius);
|
||||
});
|
||||
|
||||
hoz = !hoz;
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ namespace SM.Base.PostEffects
|
|||
|
||||
/// <summary>
|
||||
/// This resolves a multisampled framebuffer to a non-multisampled renderbuffer.
|
||||
/// <para>This removes the depth buffer.</para>
|
||||
/// </summary>
|
||||
/// <param name="multisampledBuffers"></param>
|
||||
/// <param name="target"></param>
|
||||
|
|
@ -36,7 +37,7 @@ namespace SM.Base.PostEffects
|
|||
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 | ClearBufferMask.DepthBufferBit,
|
||||
(int) target.Size.X, (int) target.Size.Y, ClearBufferMask.ColorBufferBit,
|
||||
BlitFramebufferFilter.Nearest);
|
||||
|
||||
target.Activate();
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@ uniform float[32] Weights;
|
|||
uniform int WeightCount;
|
||||
uniform float Power;
|
||||
|
||||
uniform float Radius;
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
vec4 GetRenderColorOffset(vec2 offset);
|
||||
|
|
@ -33,12 +35,13 @@ void main() {
|
|||
|
||||
vec2 tex_offset = 1.0 / textureSize(renderedTexture, 0) * vec2(Horizontal ? 1 : 0, Horizontal ? 0 : 1);
|
||||
|
||||
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * (First ? Power : 1);
|
||||
result *= GetWeight(0);
|
||||
vec3 result = max(GetRenderColorOffset(vec2(0)).rgb - thres, 0) * (First ? Power : 1) * GetWeight(0);
|
||||
|
||||
float radi = Radius + (length(result));
|
||||
|
||||
for(int i = 1; i < WeightCount; i++) {
|
||||
result += max(GetRenderColorOffset(tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
result += max(GetRenderColorOffset(-tex_offset * i).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
result += max(GetRenderColorOffset(tex_offset * i * radi).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
result += max(GetRenderColorOffset(-tex_offset * i * radi).rgb - thres, 0) * (First ? Power : 1) * GetWeight(i);
|
||||
}
|
||||
|
||||
color = vec4(result, 1);
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@
|
|||
<Name>SM.OGL</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup />
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="PostProcess\DefaultFiles\vertexWithExt.vert" />
|
||||
</ItemGroup>
|
||||
|
|
|
|||
|
|
@ -75,29 +75,57 @@ namespace SM.Base.Window
|
|||
/// </summary>
|
||||
public virtual void Resize()
|
||||
{
|
||||
if (Framebuffers == null) return;
|
||||
foreach (var framebuffer in Framebuffers)
|
||||
framebuffer.Dispose();
|
||||
Recompile();
|
||||
}
|
||||
|
||||
Thread.Sleep(50);
|
||||
|
||||
/// <summary>
|
||||
/// Compiles the framebuffers.
|
||||
/// </summary>
|
||||
public void Compile()
|
||||
{
|
||||
foreach (var framebuffer in Framebuffers)
|
||||
framebuffer.Compile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recompiles the pipeline.
|
||||
/// </summary>
|
||||
public void Recompile()
|
||||
{
|
||||
if (Framebuffers == null) return;
|
||||
Dispose();
|
||||
|
||||
Thread.Sleep(100);
|
||||
|
||||
Compile();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes unmanaged resources like Framebuffers.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var framebuffer in Framebuffers)
|
||||
framebuffer.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This creates a finished setup for a framebuffer.
|
||||
/// </summary>
|
||||
/// <param name="multisamples"></param>
|
||||
/// <returns></returns>
|
||||
public Framebuffer CreateWindowFramebuffer(int multisamples = 0)
|
||||
public Framebuffer CreateWindowFramebuffer(int multisamples = 0, PixelInformation? pixelInformation = null, bool depth = true)
|
||||
{
|
||||
Framebuffer framebuffer = new Framebuffer(ConnectedWindow);
|
||||
framebuffer.Append("color", new ColorAttachment(0, PixelInformation.RGBA_LDR, multisamples));
|
||||
|
||||
RenderbufferAttachment depthAttach = RenderbufferAttachment.Depth;
|
||||
depthAttach.Multisample = multisamples;
|
||||
framebuffer.AppendRenderbuffer(depthAttach);
|
||||
framebuffer.Append("color", new ColorAttachment(0, pixelInformation.GetValueOrDefault(PixelInformation.RGBA_LDR), multisamples));
|
||||
|
||||
if (depth)
|
||||
{
|
||||
RenderbufferAttachment depthAttach = RenderbufferAttachment.Depth;
|
||||
depthAttach.Multisample = multisamples;
|
||||
framebuffer.AppendRenderbuffer(depthAttach);
|
||||
}
|
||||
|
||||
return framebuffer;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using SM.Base.Shaders.Extensions;
|
|||
using SM.Base.Time;
|
||||
using SM.Base.Utility;
|
||||
using SM.OGL;
|
||||
using SM.OGL.Framebuffer;
|
||||
using Keyboard = SM.Base.Controls.Keyboard;
|
||||
using Mouse = SM.Base.Controls.Mouse;
|
||||
|
||||
|
|
@ -26,6 +27,7 @@ namespace SM.Base.Window
|
|||
{
|
||||
GLSystem.INIT_SYSTEM();
|
||||
GLSettings.ShaderPreProcessing = true;
|
||||
Framebuffer.ScreenWindow = window;
|
||||
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
if (args.Contains("--advDebugging"))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue