Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
G3D::Texture::Encoding Class Reference


Attaches semantics for reading and writing this texture beyond the OpenGL bitwise description. More...

Public Member Functions

 Encoding (const ImageFormat *fmt=nullptr, FrameName n=FrameName::NONE, const Color4 &readMultiplyFirst=Color4::one(), const Color4 &readAddSecond=Color4::zero())
 
 Encoding (const ImageFormat *fmt, FrameName n, const float readMultiplyFirst=1.0f, const float readAddSecond=0.0f)
 
 Encoding (const Color4 &readMultiplyFirst)
 
 Encoding (const Any &a)
 
size_t hashCode () const
 
bool operator!= (const Encoding &e) const
 
bool operator== (const Encoding &e) const
 
Any toAny () const
 
Color4 writeAddSecond () const
 
Color4 writeMultiplyFirst () const
 

Static Public Member Functions

static Encoding lowPrecisionScreenSpaceMotionVector ()
 Computes a suitable representation for low-precision 2D signed motion vectors on this machine, with an exactly representable zero and range of approximately +/- 64. More...
 

Public Attributes

const ImageFormatformat
 
FrameName frame
 
This is primarily for debugging and visualization. More...
 
Color4 readAddSecond
 This is automatically bound as an optional argument when the texture is passed to a shader. More...
 
Color4 readMultiplyFirst
 This is automatically bound as an optional argument when the texture is passed to a shader. More...
 

Detailed Description


Attaches semantics for reading and writing this texture beyond the OpenGL bitwise description.

This allows G3D to automatically bind texture variables more usefully in shaders, visualize

Read the texture in GLSL as:

vec4 v = texture(t, x) * readMultiplyFirst + readAddSecond;

Note that these encoding values are applied in addition to whatever the underlying ImageFormat specifies. So, sRGB data could be stored in an RGB ImageFormat using an explicit exponent here.

It is common for shaders to assume a limited encoding and their corresponding host code to assert that the encoding is obeyed rather than pass all parameters to the shader.

Any file examples:

t = Texture::Encoding {
frame = CAMERA;
readMultiplyFirst = Color4(1,1,1,0.5);
format = RGBA8;
};
t = Color4(0.5, 1, 0, 1);
t = 0.5;

Constructor & Destructor Documentation

◆ Encoding() [1/4]

G3D::Texture::Encoding::Encoding ( const ImageFormat fmt = nullptr,
FrameName  n = FrameName::NONE,
const Color4 readMultiplyFirst = Color4::one(),
const Color4 readAddSecond = Color4::zero() 
)
inline

◆ Encoding() [2/4]

G3D::Texture::Encoding::Encoding ( const ImageFormat fmt,
FrameName  n,
const float  readMultiplyFirst = 1.0f,
const float  readAddSecond = 0.0f 
)
inline

◆ Encoding() [3/4]

G3D::Texture::Encoding::Encoding ( const Color4 readMultiplyFirst)
inlineexplicit

◆ Encoding() [4/4]

G3D::Texture::Encoding::Encoding ( const Any a)

Member Function Documentation

◆ hashCode()

size_t G3D::Texture::Encoding::hashCode ( ) const
inline

◆ lowPrecisionScreenSpaceMotionVector()

static Encoding G3D::Texture::Encoding::lowPrecisionScreenSpaceMotionVector ( )
static

Computes a suitable representation for low-precision 2D signed motion vectors on this machine, with an exactly representable zero and range of approximately +/- 64.

◆ operator!=()

bool G3D::Texture::Encoding::operator!= ( const Encoding e) const
inline

◆ operator==()

bool G3D::Texture::Encoding::operator== ( const Encoding e) const

◆ toAny()

Any G3D::Texture::Encoding::toAny ( ) const

◆ writeAddSecond()

Color4 G3D::Texture::Encoding::writeAddSecond ( ) const
inline

◆ writeMultiplyFirst()

Color4 G3D::Texture::Encoding::writeMultiplyFirst ( ) const
inline

Member Data Documentation

◆ format

const ImageFormat* G3D::Texture::Encoding::format

◆ frame

FrameName G3D::Texture::Encoding::frame


This is primarily for debugging and visualization.

It is not automatically bound with the texture for shaders. However, programs can explicitly pass information based on it to a shader to allow generalizing over coordinate transformations, for example.

Referenced by hashCode().

◆ readAddSecond

Color4 G3D::Texture::Encoding::readAddSecond

This is automatically bound as an optional argument when the texture is passed to a shader.

Referenced by hashCode(), G3D::Texture::max(), G3D::Texture::mean(), G3D::Texture::min(), and writeAddSecond().

◆ readMultiplyFirst

Color4 G3D::Texture::Encoding::readMultiplyFirst

This is automatically bound as an optional argument when the texture is passed to a shader.

Referenced by hashCode(), G3D::Texture::max(), G3D::Texture::mean(), G3D::Texture::min(), G3D::Texture::opaque(), writeAddSecond(), and writeMultiplyFirst().


documentation generated on Wed Nov 24 2021 08:02:01 using doxygen 1.8.15