LightsprintSDK 2021.08.08
rr::RRColorSpace Class Referenceabstract

#include <RRBuffer.h>

Inheritance diagram for rr::RRColorSpace:
rr::RRUniformlyAllocated

Public Member Functions

virtual void fromLinear (RRReal &intensity) const =0
 
virtual void fromLinear (RRVec3 &color) const =0
 
virtual void toLinear (RRReal &intensity) const =0
 
virtual void toLinear (RRVec3 &color) const =0
 
virtual RRVec3 getLinear (const unsigned char color[3]) const =0
 
virtual ~RRColorSpace ()
 
- Public Member Functions inherited from rr::RRUniformlyAllocated
void * operator new (std::size_t n)
 
void * operator new[] (std::size_t n)
 
void operator delete (void *p, std::size_t n)
 
void operator delete[] (void *p, std::size_t n)
 

Static Public Member Functions

static RRColorSpacecreate_sRGB (RRReal power=0.45f)
 

Detailed Description

Interface for custom color space.

All data in Lightsprint SDK are flagged to be either in custom color space or in linear colors, where linear colors can be any fixed multiple of physically based units. This class, custom color space, implements conversion to linear colors and back.

If you work with the most common format, sRGB, use create_sRGB().

If your pipeline works with linear colors, just pass nullptr where API asks for color space.

For other color spaces, you can implement your own RRColorSpace. Please make sure that your implementation doesn't generate NaNs or INFs (especially for negative inputs). Custom color spaces are fully supported by realtime solvers, lightmap baking and pathtracer, but not yet by OpenGL renderer, it has sRGB conversion hardcoded in shaders.

Constructor & Destructor Documentation

◆ ~RRColorSpace()

virtual rr::RRColorSpace::~RRColorSpace ( )
inlinevirtual

Member Function Documentation

◆ fromLinear() [1/2]

virtual void rr::RRColorSpace::fromLinear ( RRReal intensity) const
pure virtual

Converts from linear intensity.

◆ fromLinear() [2/2]

virtual void rr::RRColorSpace::fromLinear ( RRVec3 color) const
pure virtual

Converts from linear color.

◆ toLinear() [1/2]

virtual void rr::RRColorSpace::toLinear ( RRReal intensity) const
pure virtual

Converts to linear intensity.

◆ toLinear() [2/2]

virtual void rr::RRColorSpace::toLinear ( RRVec3 color) const
pure virtual

Converts to linear color.

◆ getLinear()

virtual RRVec3 rr::RRColorSpace::getLinear ( const unsigned char  color[3]) const
pure virtual

Converts to linear color.

◆ create_sRGB()

static RRColorSpace * rr::RRColorSpace::create_sRGB ( RRReal  power = 0.45f)
static

Creates and returns sRGB color space - the most common screen colors.

Our implementation approximates sRGB curve by pow() function.

Parameters
powerExponent in formula. Use default value for typical screen colors or tweak it for different contrast.