Added Ambient-Light
This commit is contained in:
parent
e4e7db8dc0
commit
597a14743b
7 changed files with 40 additions and 10 deletions
|
|
@ -8,13 +8,23 @@ namespace SM2D.Light
|
|||
{
|
||||
public class LightPostEffect : PostProcessEffect
|
||||
{
|
||||
PostProcessShader _shader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile("SM2D.Light.light.frag"));
|
||||
private PostProcessShader _shader = new PostProcessShader(AssemblyUtility.ReadAssemblyFile("SM2D.Light.light.frag"));
|
||||
private LightSceneExtension sceneExtension;
|
||||
|
||||
public override void Draw(Framebuffer main)
|
||||
{
|
||||
base.Draw(main);
|
||||
|
||||
_shader.Draw(main.ColorAttachments["color"], collection =>
|
||||
{
|
||||
collection["Ambient"].SetUniform4(sceneExtension.Ambient);
|
||||
});
|
||||
}
|
||||
|
||||
_shader.Draw(main.ColorAttachments["color"]);
|
||||
public override void SceneChanged(GenericScene scene)
|
||||
{
|
||||
base.SceneChanged(scene);
|
||||
sceneExtension = scene.GetExtension<LightSceneExtension>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -4,6 +4,8 @@ namespace SM2D.Light
|
|||
{
|
||||
public class LightSceneExtension
|
||||
{
|
||||
public Color4 Ambient;
|
||||
public Color4 Ambient = Color4.White;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -39,7 +39,14 @@ namespace SM2D.Pipelines
|
|||
_lightEffect.Draw(_tempWindow);
|
||||
|
||||
scene.DrawHUD(context);
|
||||
scene.DrawDebug(context);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SceneChanged(Scene.Scene scene)
|
||||
{
|
||||
base.SceneChanged(scene);
|
||||
_lightEffect.SceneChanged(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ using SM.Base.Contexts;
|
|||
using SM.Base.Objects.Static;
|
||||
using SM.Base.Scene;
|
||||
using SM2D.Drawing;
|
||||
using SM2D.Light;
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -16,6 +17,7 @@ namespace SM2D.Scene
|
|||
private static DrawObject2D _axisHelper;
|
||||
|
||||
public float AxisHelperSize = 100;
|
||||
public LightSceneExtension LightInformations;
|
||||
static Scene()
|
||||
{
|
||||
_axisHelper = new DrawObject2D();
|
||||
|
|
@ -25,6 +27,8 @@ namespace SM2D.Scene
|
|||
public Scene()
|
||||
{
|
||||
_Background = new DrawBackground(Color4.Black);
|
||||
|
||||
SetExtension(LightInformations = new LightSceneExtension());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue