Rendering Engine 0.2.9
Modular Graphics Rendering Engine | v0.2.9
rendering_engine::ColorSpace Class Reference

Color space conversion utilities (sRGB <-> linear). More...

#include <color_space.hpp>

Static Public Member Functions

static float SRGBToLinear (float c)
 Converts a single sRGB channel to linear space. More...
 
static glm::vec3 SRGBToLinear (const glm::vec3 &color)
 Converts an sRGB RGB color to linear space. More...
 
static float LinearToSRGB (float c)
 Converts a single linear channel to sRGB space. More...
 
static glm::vec3 LinearToSRGB (const glm::vec3 &color)
 Converts a single linear channel to sRGB space. More...
 

Detailed Description

Color space conversion utilities (sRGB <-> linear).

The rendering engine operates internally in linear color space. Use these helpers when converting colors from UI/design tools (typically sRGB) to linear space before rendering.

Definition at line 21 of file color_space.hpp.

Member Function Documentation

◆ LinearToSRGB() [1/2]

glm::vec3 rendering_engine::ColorSpace::LinearToSRGB ( const glm::vec3 &  color)
static

Converts a single linear channel to sRGB space.

Definition at line 31 of file Source/color_space.cpp.

32{
33 return glm::vec3(
34 LinearToSRGB(color.r),
35 LinearToSRGB(color.g),
36 LinearToSRGB(color.b)
37 );
38}
static float LinearToSRGB(float c)
Converts a single linear channel to sRGB space.

◆ LinearToSRGB() [2/2]

float rendering_engine::ColorSpace::LinearToSRGB ( float  c)
static

Converts a single linear channel to sRGB space.

Definition at line 23 of file Source/color_space.cpp.

24{
25 if (c <= 0.0031308f)
26 return 12.92f * c;
27 else
28 return 1.055f * std::pow(c, 1.0f / 2.4f) - 0.055f;
29}

◆ SRGBToLinear() [1/2]

glm::vec3 rendering_engine::ColorSpace::SRGBToLinear ( const glm::vec3 &  color)
static

Converts an sRGB RGB color to linear space.

Definition at line 14 of file Source/color_space.cpp.

15{
16 return glm::vec3(
17 SRGBToLinear(color.r),
18 SRGBToLinear(color.g),
19 SRGBToLinear(color.b)
20 );
21}
static float SRGBToLinear(float c)
Converts a single sRGB channel to linear space.

◆ SRGBToLinear() [2/2]

float rendering_engine::ColorSpace::SRGBToLinear ( float  c)
static

Converts a single sRGB channel to linear space.

Definition at line 6 of file Source/color_space.cpp.

7{
8 if (c <= 0.04045f)
9 return c / 12.92f;
10 else
11 return pow((c + 0.055f) / 1.055f, 2.4f);
12}

The documentation for this class was generated from the following files: