Skip to content

Commit

Permalink
Split the Uncharted 2 tonemap into two options, one with parameter va…
Browse files Browse the repository at this point in the history
…lues from Hable's GDC talk and another for his BLog post.

Updated plugin documentation.
Updated README.md
  • Loading branch information
Zackin5 committed Sep 7, 2017
1 parent 3bf6153 commit 3fb66e2
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 19 deletions.
51 changes: 33 additions & 18 deletions FilmicTonemapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@
// Submenu:
// Author: Jace Regenbrecht
// Title: Filmic Tonemapping Operators
// Version: 1.0
// Version: 1.1
// Desc:
// Keywords:
// URL:
// URL: https://github.com/Zackin5/Filmic-Tonemapping-Plugin
// Help:
#region UICode
CheckboxControl Amount1 = true; // [0,1] Gamma Correction
DoubleSliderControl Amount2 = 2.2; // [0,5] Pre Gamma
DoubleSliderControl Amount3 = 2.2; // [0,5] Post Gamma
ListBoxControl Amount4 = 0; // Tonemapping Model|Reinhard RGB Simple|Reinhard RGB Full|Reinhard Luminance Simple|Reinhard Luminance Full|Haarm-Peter Duiker Simple|Uncharted 2
ListBoxControl Amount4 = 0; // Tonemapping Model|Reinhard RGB Simple|Reinhard RGB Full|Reinhard Luminance Simple|Reinhard Luminance Full|Haarm-Peter Duiker Simple|Uncharted 2 GDC|Uncharted 2 Blog
DoubleSliderControl Amount5 = 5; // [1,20] White Value
DoubleSliderControl Amount6 = 1; // [1,20] Pre Exposure
#endregion
Expand All @@ -36,26 +36,19 @@ private double TonemapHPD(double color)
return (x*(6.2*x+.5))/(x*(6.2*x+1.7)+0.06);
}

private double TonemapUncharted2(double color, double W)
private double TonemapUncharted2(double color, double W, double ShoulderStr, double LinStr, double LinAng, double ToeStr, double ToeNum, double ToeDenom)
{
double ExposureBias = 2.0;

double curr = TonemapUncharted2_(ExposureBias*color);
double curr = TonemapUncharted2_(ExposureBias*color, ShoulderStr, LinStr, LinAng, ToeStr, ToeNum, ToeDenom);

double whiteScale = 1.0f/TonemapUncharted2_(W);
double whiteScale = 1.0f/TonemapUncharted2_(W, ShoulderStr, LinStr, LinAng, ToeStr, ToeNum, ToeDenom);

return curr*whiteScale;
}

private double TonemapUncharted2_(double x)
private double TonemapUncharted2_(double x, double A, double B, double C, double D, double E, double F)
{
double A = 0.15; // Shoulder strength
double B = 0.50; // Linear strength
double C = 0.10; // Linear angle
double D = 0.20; // Toe strength
double E = 0.02; // Toe numerator
double F = 0.30; // Toe denominator

return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;
}

Expand Down Expand Up @@ -141,11 +134,33 @@ void Render(Surface dst, Surface src, Rectangle rect)
G = TonemapHPD(G);
B = TonemapHPD(B);
break;
// Uncharted 2
// Uncharted 2 GDC Values
case 5:
R = TonemapUncharted2(R, Amount5);
G = TonemapUncharted2(G, Amount5);
B = TonemapUncharted2(B, Amount5);
{
double uA = 0.22; // Shoulder strength
double uB = 0.30; // Linear strength
double uC = 0.10; // Linear angle
double uD = 0.20; // Toe strength
double uE = 0.01; // Toe numerator
double uF = 0.30; // Toe denominator
R = TonemapUncharted2(R, Amount5, uA, uB, uC, uD, uE, uF);
G = TonemapUncharted2(G, Amount5, uA, uB, uC, uD, uE, uF);
B = TonemapUncharted2(B, Amount5, uA, uB, uC, uD, uE, uF);
}
break;
// Uncharted 2 Blog Values
case 6:
{
double uA = 0.15; // Shoulder strength
double uB = 0.50; // Linear strength
double uC = 0.10; // Linear angle
double uD = 0.20; // Toe strength
double uE = 0.02; // Toe numerator
double uF = 0.30; // Toe denominator
R = TonemapUncharted2(R, Amount5, uA, uB, uC, uD, uE, uF);
G = TonemapUncharted2(G, Amount5, uA, uB, uC, uD, uE, uF);
B = TonemapUncharted2(B, Amount5, uA, uB, uC, uD, uE, uF);
}
break;
default:
break;
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ This plugin offers the following usage parameters:
* **Reinhard Luminance Simple** - simple Reinhard model applied to Luminance values
* **Reinhard Luminance Full** - full Reinhard model applied to Luminance values with support for white values
* **Haarm-Peter Duiker Simple** - simple Haarm-Pieter Duiker curve
* **Uncharted 2** - Uncharted 2 model using default values, supports white values
* **Uncharted 2 GDC** - Uncharted 2 model using parameter values from Hable's GDC talk, supports white values
* **Uncharted 2 Blog** - Uncharted 2 model using parameter values from Hable's blod post, supports white values
* **White Value** - color value which will be mapped to full white in final results
* **Pre Exposure** - Amount of image exposure to apply before tonemapping

Expand Down

0 comments on commit 3fb66e2

Please sign in to comment.