forked from stride3d/stride
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ACES tone mapping operator
- Loading branch information
Showing
3 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
...s/engine/Stride.Rendering/Rendering/Images/ColorTransforms/ToneMap/ToneMapACESOperator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
{ | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
.../Stride.Rendering/Rendering/Images/ColorTransforms/ToneMap/ToneMapACESOperatorShader.sdsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}; | ||
} |
9 changes: 9 additions & 0 deletions
9
...ride.Rendering/Rendering/Images/ColorTransforms/ToneMap/ToneMapACESOperatorShader.sdsl.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |