tone mapping
parent
a341d3ba93
commit
3389897d08
Binary file not shown.
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -27,6 +27,9 @@
|
|||
<EmbeddedResource Include="Effects\FXB\DeferredPBR_GBufferEffect.fxb">
|
||||
<LogicalName>Kav.Resources.DeferredPBR_GBufferEffect.fxb</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Effects\FXB\ToneMapEffect.fxb">
|
||||
<LogicalName>Kav.Resources.ToneMapEffect.fxb</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Effects\FXB\DeferredPBREffect.fxb">
|
||||
<LogicalName>Kav.Resources.DeferredPBREffect.fxb</LogicalName>
|
||||
</EmbeddedResource>
|
||||
|
|
|
@ -27,6 +27,9 @@
|
|||
<EmbeddedResource Include="Effects\FXB\DeferredPBR_GBufferEffect.fxb">
|
||||
<LogicalName>Kav.Resources.DeferredPBR_GBufferEffect.fxb</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Effects\FXB\ToneMapEffect.fxb">
|
||||
<LogicalName>Kav.Resources.ToneMapEffect.fxb</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Effects\FXB\DeferredPBREffect.fxb">
|
||||
<LogicalName>Kav.Resources.DeferredPBREffect.fxb</LogicalName>
|
||||
</EmbeddedResource>
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
13
Resources.cs
13
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;
|
||||
|
|
Loading…
Reference in New Issue