~hikiko/nux/arb-srgba-shader

« back to all changes in this revision

Viewing changes to NuxCore/ColorFunctions.cpp

  • Committer: Neil Jagdish Patel
  • Date: 2010-09-01 19:25:37 UTC
  • Revision ID: neil.patel@canonical.com-20100901192537-mfz7rm6q262pewg6
Import and build NuxCore

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "NKernel.h"
 
2
#include "NSystemTypes.h"
 
3
#include "ColorFunctions.h"
 
4
 
 
5
 
 
6
NAMESPACE_BEGIN
 
7
// Converts from Gamma2.2 space to Gamma1.0 space
 
8
t_float Undo_Gamma_Correction(t_float c)
 
9
{
 
10
    if(c <= 0.03928f)     
 
11
    {                      
 
12
      return (c / 12.92f);     
 
13
    }                      
 
14
    else                   
 
15
    {                      
 
16
      return (float)pow((c + 0.055f) / 1.055f, 2.4f);
 
17
    }                                            
 
18
}
 
19
  
 
20
t_float Do_Gamma_Correction(t_float c)
 
21
{
 
22
    if(c <= 0.00304f)     
 
23
    {                      
 
24
      return (c * 12.92f);     
 
25
    }                      
 
26
    else                   
 
27
    {                      
 
28
      return (float)pow(c, 1.0f/2.4f) * 1.055f - 0.055f;
 
29
    }                                            
 
30
}
 
31
 
 
32
NAMESPACE_END
 
 
b'\\ No newline at end of file'