Skip to content

Commit

Permalink
Add ACES (stride3d#1037)
Browse files Browse the repository at this point in the history
Add ACES tone mapping operator
  • Loading branch information
D3ZAX authored Mar 28, 2021
1 parent 34ed6fa commit 0b3fc81
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) Stride contributors (https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System.ComponentModel;
using Stride.Core;

namespace Stride.Rendering.Images
{
/// <summary>
/// The Tone mapping ACES operator.
/// </summary>
[DataContract("ToneMapACESOperator")]
[Display("ACES")]
public class ToneMapACESOperator : ToneMapCommonOperator
{
/// <summary>
/// Initializes a new instance of the <see cref="ToneMapReinhardOperator"/> class.
/// </summary>
public ToneMapACESOperator()
: base("ToneMapACESOperatorShader")
{
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// Copyright (c) Stride contributors (https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.

namespace Stride.Rendering.Images
{
/// <summary>
/// The ACES tonemap operator.
/// </summary>
internal shader ToneMapACESOperatorShader : ToneMapCommonOperatorShader
{
// ACES filmic tonemapper with highlight desaturation ("crosstalk").
// Based on the curve fit by Krzysztof Narkowicz.
// https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/

override float4 Compute(float4 color)
{
float pixelLuminance = LuminanceUtils.Luma(color);

// ACES Tonemapper
const float a = 2.51f;
const float b = 0.03f;
const float c = 2.43f;
const float d = 0.59f;
const float e = 0.14f;

float toneMappedLuminance = (pixelLuminance * (a * pixelLuminance + b)) / (pixelLuminance * (c * pixelLuminance + d) + e);
float whiteLuminance = (WhiteLevel * (a * WhiteLevel + b)) / (WhiteLevel * (c * WhiteLevel + d) + e);
return toneMappedLuminance / whiteLuminance * pow(color / pixelLuminance, LuminanceSaturation);
}
};
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// <auto-generated>
// Do not edit this file yourself!
//
// This code was generated by Stride Shader Mixin Code Generator.
// To generate it yourself, please install Stride.VisualStudio.Package .vsix
// and re-save the associated .sdfx.
// </auto-generated>

// Nothing to generate

0 comments on commit 0b3fc81

Please sign in to comment.