slog update
[OpenColorIO-Configs.git] / aces / luts / slogf65_to_aces_3200.ctl
1 ////////////////////////////////////////////////////////////////////////////////////// 
2 // License Terms for Academy Color Encoding System Components                       //
3 //                                                                                  //
4 // Academy Color Encoding System (ACES) software and tools are provided by the      //
5 // Academy under the following terms and conditions: A worldwide, royalty-free,     //
6 // non-exclusive right to copy, modify, create derivatives, and use, in source and  //
7 // binary forms, is hereby granted, subject to acceptance of this license.          //
8 // Performance of any of the aforementioned acts indicates acceptance to be bound   //
9 // by the following terms and conditions:                                           //
10 //                                                                                  //
11 // Copies of source code, in whole or in part, must retain the above copyright      //
12 // notice, this list of conditions and the Disclaimer of Warranty.                  //
13 //                                                                                  //
14 // Use in binary form must retain the copyright notice (below), this list of        //
15 // conditions and the Disclaimer of Warranty in the documentation and/or other      //
16 // materials provided with the distribution.                                        //
17 //                                                                                  //
18 // * Nothing in this license shall be deemed to grant any rights to trademarks,     //
19 // copyrights, patents, trade secrets or any other intellectual property of         //
20 // A.M.P.A.S. or any contributors, except as expressly stated herein.               //
21 //                                                                                  //
22 // * Neither the name "A.M.P.A.S." nor the name of any other contributors to this   //
23 // software may be used to endorse or promote products derivative of or based on    //
24 // this software without express prior written permission of A.M.P.A.S. or the      //
25 // contributors, as appropriate.                                                    //
26 //                                                                                  //
27 // * This license shall be construed pursuant to the laws of the State of           //
28 // California, and any disputes related thereto shall be subject to the             //
29 // jurisdiction of the courts therein.                                              //
30 //                                                                                  //
31 // Copyright © 2012 Academy of Motion Picture Arts and Sciences (A.M.P.A.S.).       //
32 // Portions contributed by others as indicated. All rights reserved.                //
33 //                                                                                  //
34 // Disclaimer of Warranty: THIS SOFTWARE IS PROVIDED BY A.M.P.A.S. AND CONTRIBUTORS //
35 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,    //
36 // THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND //
37 // NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL A.M.P.A.S., OR ANY            //
38 // CONTRIBUTORS OR DISTRIBUTORS, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,    //
39 // SPECIAL, EXEMPLARY, RESITUTIONARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT  //
40 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR   //
41 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF           //
42 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE  //
43 // OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF        //
44 // ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                       //
45 //                                                                                  //
46 // WITHOUT LIMITING THE GENERALITY OF THE FOREGOING, THE ACADEMY SPECIFICALLY       //
47 // DISCLAIMS ANY REPRESENTATIONS OR WARRANTIES WHATSOEVER RELATED TO PATENT OR      //
48 // OTHER INTELLECTUAL PROPERTY RIGHTS IN THE ACADEMY COLOR ENCODING SYSTEM, OR      //
49 // APPLICATIONS THEREOF, HELD BY PARTIES OTHER THAN A.M.P.A.S.,WHETHER DISCLOSED OR //
50 // UNDISCLOSED.                                                                     //
51 ////////////////////////////////////////////////////////////////////////////////////// 
52
53 //
54 // IDT for S-Log/S-Gamut F65 cameras
55 // Prototype: Jeremy Selan
56 //
57
58
59
60 /* ============ SUBFUNCTIONS ============ */
61 float SLog10_to_lin (
62     float SLog
63 )
64 {
65     return (pow(10,((((SLog/4-16)/219)-0.616596-0.03)/0.432699))-0.037584)*0.9;
66 }
67
68
69
70
71
72 /* ============ Main Algorithm ============ */
73 void
74 main
75 (   input varying float rIn,
76     input varying float gIn,
77     input varying float bIn,
78     input varying float aIn,
79     output varying float rOut,
80     output varying float gOut,
81     output varying float bOut,
82     output varying float aOut
83 )
84 {
85     // Prepare input values based on application bit depth handling
86     float SLog[3];
87     SLog[0] = rIn * 1023.0;
88     SLog[1] = gIn * 1023.0;
89     SLog[2] = bIn * 1023.0;
90
91     // 10-bit Sony S-log to linear S-gamut
92     float lin[3];
93     lin[0] = SLog10_to_lin( SLog[0]);
94     lin[1] = SLog10_to_lin( SLog[1]);
95     lin[2] = SLog10_to_lin( SLog[2]);
96
97     // S-Gamut to ACES matrix
98     rOut = lin[0] * 1.0110238740 + lin[1] * -0.1362526051 + lin[2] * 0.1252287310;
99     gOut = lin[0] * 0.1011994504 + lin[1] * 0.9562196265 + lin[2] * -0.0574190769;
100     bOut = lin[0] * 0.0600766530 + lin[1] * -0.1010185315 + lin[2] * 1.0409418785;
101     aOut = aIn;
102 }