diff --git a/Effects/FXB/ToneMapEffect.fxb b/Effects/FXB/ToneMapEffect.fxb
new file mode 100644
index 0000000..dde4f5f
Binary files /dev/null and b/Effects/FXB/ToneMapEffect.fxb differ
diff --git a/Effects/HLSL/ToneMapEffect.fx b/Effects/HLSL/ToneMapEffect.fx
new file mode 100644
index 0000000..281b714
--- /dev/null
+++ b/Effects/HLSL/ToneMapEffect.fx
@@ -0,0 +1,20 @@
+sampler TextureSampler : register(s0);
+
+float4 main_ps(float2 texCoord : TEXCOORD0) : COLOR0
+{
+ float3 color = tex2D(TextureSampler, texCoord).xyz;
+
+ color = color / (color + float3(1.0, 1.0, 1.0));
+ float exposureConstant = 1.0 / 2.2;
+ color = pow(color, float3(exposureConstant, exposureConstant, exposureConstant));
+
+ return float4(color, 1.0);
+}
+
+Technique DeferredPBR
+{
+ Pass
+ {
+ PixelShader = compile ps_3_0 main_ps();
+ }
+}
diff --git a/Kav.Core.csproj b/Kav.Core.csproj
index c7c437f..327d7bb 100644
--- a/Kav.Core.csproj
+++ b/Kav.Core.csproj
@@ -27,6 +27,9 @@
Kav.Resources.DeferredPBR_GBufferEffect.fxb
+
+ Kav.Resources.ToneMapEffect.fxb
+
Kav.Resources.DeferredPBREffect.fxb
diff --git a/Kav.Framework.csproj b/Kav.Framework.csproj
index a98bb21..2b2dd4f 100644
--- a/Kav.Framework.csproj
+++ b/Kav.Framework.csproj
@@ -27,6 +27,9 @@
Kav.Resources.DeferredPBR_GBufferEffect.fxb
+
+ Kav.Resources.ToneMapEffect.fxb
+
Kav.Resources.DeferredPBREffect.fxb
diff --git a/Renderer.cs b/Renderer.cs
index 0a77713..63b34e5 100644
--- a/Renderer.cs
+++ b/Renderer.cs
@@ -25,6 +25,7 @@ namespace Kav
private DeferredPBR_PointLightEffect DeferredPointLightEffect { get; }
private DeferredPBR_DirectionalLightEffect DeferredDirectionalLightEffect { get; }
private SimpleDepthEffect SimpleDepthEffect { get; }
+ private Effect ToneMapEffect { get; }
private RenderTarget2D gPosition { get; }
private RenderTarget2D gNormal { get; }
@@ -133,8 +134,8 @@ namespace Kav
DeferredAmbientLightEffect = new DeferredPBR_AmbientLightEffect(GraphicsDevice);
DeferredPointLightEffect = new DeferredPBR_PointLightEffect(GraphicsDevice);
DeferredDirectionalLightEffect = new DeferredPBR_DirectionalLightEffect(GraphicsDevice);
-
DeferredDirectionalLightEffect.ShadowMapSize = ShadowMapSize;
+ ToneMapEffect = new Effect(graphicsDevice, Resources.ToneMapEffect);
FullscreenTriangle = new VertexBuffer(GraphicsDevice, typeof(VertexPositionTexture), 3, BufferUsage.WriteOnly);
FullscreenTriangle.SetData(new VertexPositionTexture[3] {
@@ -223,7 +224,7 @@ namespace Kav
GraphicsDevice.SetRenderTarget(null);
GraphicsDevice.Clear(Color.Black);
- SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque);
+ SpriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, null, null, null, ToneMapEffect);
SpriteBatch.Draw(ColorRenderTarget, Vector2.Zero, Color.White);
SpriteBatch.End();
}
diff --git a/Resources.cs b/Resources.cs
index 9ac9358..7791eaa 100644
--- a/Resources.cs
+++ b/Resources.cs
@@ -51,6 +51,18 @@ namespace Kav
}
}
+ public static byte[] ToneMapEffect
+ {
+ get
+ {
+ if (toneMapEffect == null)
+ {
+ toneMapEffect = GetResource("ToneMapEffect");
+ }
+ return toneMapEffect;
+ }
+ }
+
public static byte[] DeferredPBREffect
{
get
@@ -91,6 +103,7 @@ namespace Kav
private static byte[] pointLightEffect;
private static byte[] directionalLightEffect;
private static byte[] gBufferEffect;
+ private static byte[] toneMapEffect;
private static byte[] deferredPBREffect;
private static byte[] pbrEffect;
private static byte[] simpleDepthEffect;