Rendering Engine 0.2.17
Modular Graphics Rendering Engine | v0.2.17
Loading...
Searching...
No Matches
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.
 
static glm::vec3 SRGBToLinear (const glm::vec3 &color)
 Converts an sRGB RGB color to linear space.
 
static float LinearToSRGB (float c)
 Converts a single linear channel to sRGB space.
 
static glm::vec3 LinearToSRGB (const glm::vec3 &color)
 Converts a single linear channel to sRGB space.
 

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 32 of file Source/color_space.cpp.

33{
34 return glm::vec3(
35 LinearToSRGB(color.r),
36 LinearToSRGB(color.g),
37 LinearToSRGB(color.b)
38 );
39}
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 24 of file Source/color_space.cpp.

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

◆ 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 15 of file Source/color_space.cpp.

16{
17 return glm::vec3(
18 SRGBToLinear(color.r),
19 SRGBToLinear(color.g),
20 SRGBToLinear(color.b)
21 );
22}
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 7 of file Source/color_space.cpp.

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

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