SLProject 4.0.000
SLTexColorLUT Class Reference

SLTexColorLUT defines a lookup table as an 1D texture of (256) RGBA values. More...

#include <SLTexColorLUT.h>

Inheritance diagram for SLTexColorLUT:
[legend]

Public Member Functions

 SLTexColorLUT (SLAssetManager *assetMgr, SLColorLUTType lutType, SLuint length=256)
 Default ctor color LUT of a specific SLColorLUTType. More...
 
 SLTexColorLUT (SLAssetManager *assetMgr, SLVAlphaLUTPoint alphaVec, SLColorLUTType lutType=CLUT_RYGCB, SLuint length=256)
 ctor with vector of alpha values and a predefined color LUT scheme More...
 
 SLTexColorLUT (SLAssetManager *assetMgr, SLVAlphaLUTPoint alphaValues, SLVColorLUTPoint colorValues, SLuint length=256)
 ctor with vector of alpha and color values More...
 
virtual ~SLTexColorLUT ()
 
void generateTexture ()
 Generates the full 256 value LUT as 1x256 RGBA texture. More...
 
void colors (SLColorLUTType lut)
 Colors setter function by predefined color LUT. More...
 
SLuint length ()
 
SLVColorLUTPointcolors ()
 
SLVAlphaLUTPointalphas ()
 
SLVfloat allAlphas ()
 Returns all alpha values of the transfer function as a float vector. More...
 
- Public Member Functions inherited from SLGLTexture
 SLGLTexture ()
 Default ctor for all stack instances (not created with new) More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLVCol4f &colors, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLint wrapS=GL_REPEAT, const SLstring &name="2D-Texture")
 ctor for 1D texture with internal image allocation More...
 
 SLGLTexture (SLAssetManager *assetMgr, SLint min_filter, SLint mag_filter, SLint wrapS, SLint wrapT, SLenum target=GL_TEXTURE_2D)
 ctor for empty 2D textures More...
 
 SLGLTexture (SLAssetManager *assetMgr, unsigned char *data, int width, int height, int cvtype, SLint min_filter, SLint mag_filter, SLTextureType type, SLint wrapS, SLint wrapT)
 ctor for 2D textures from byte pointer More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLstring &imageFilename, SLint min_filter=GL_LINEAR_MIPMAP_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT)
 ctor for 2D textures with internal image allocation More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLVstring &imageFilenames, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT, const SLstring &name="3D-Texture", SLbool loadGrayscaleIntoAlpha=false)
 ctor for 3D texture with internal image allocation More...
 
 SLGLTexture (SLAssetManager *assetMgr, SLint depth, const SLstring &imageFilename, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLint wrapS=GL_REPEAT, SLint wrapT=GL_REPEAT, const SLstring &name="3D-Texture", SLbool loadGrayscaleIntoAlpha=false)
 ctor for 3D texture from a single file with depth as 3rd dimension More...
 
 SLGLTexture (SLAssetManager *assetMgr, const SLstring &imageFilenameXPos, const SLstring &imageFilenameXNeg, const SLstring &imageFilenameYPos, const SLstring &imageFilenameYNeg, const SLstring &imageFilenameZPos, const SLstring &imageFilenameZNeg, SLint min_filter=GL_LINEAR, SLint mag_filter=GL_LINEAR, SLTextureType type=TT_unknown)
 ctor for cube mapping with internal image allocation More...
 
 ~SLGLTexture () override
 
virtual void build (SLint texUnit)
 
void deleteData ()
 Delete all data (CVImages and GPU textures) More...
 
void deleteDataGpu ()
 Deletes the OpenGL texture objects and releases the memory on the GPU. More...
 
void deleteImages ()
 Deletes the CVImages in _images. No more texture mapping in ray tracing. More...
 
void bindActive (SLuint texUnit=0)
 
void fullUpdate ()
 
void drawSprite (SLbool doUpdate, SLfloat x, SLfloat y, SLfloat w, SLfloat h)
 Draws the texture as 2D sprite with OpenGL buffers. More...
 
void cubeUV2XYZ (SLint index, SLfloat u, SLfloat v, SLfloat &x, SLfloat &y, SLfloat &z)
 Computes the unnormalised vector x,y,z from tex. coords. uv with cubemap index. More...
 
void cubeXYZ2UV (SLfloat x, SLfloat y, SLfloat z, SLint &index, SLfloat &u, SLfloat &v)
 Computes the uv and cubemap image index from a unnormalised vector x,y,z. More...
 
SLstring filterString (SLint glFilter)
 Returns OpenGL texture filter as string. More...
 
void texType (SLTextureType bt)
 
void uvIndex (SLbyte i)
 
void bumpScale (SLfloat bs)
 
void minFiler (SLint minF)
 
void magFiler (SLint magF)
 
void needsUpdate (SLbool update)
 
void textureSize (int width, int height)
 
void deleteImageAfterBuild (SLbool delImg)
 If deleteImageAfterBuild is set to true you won't be able to ray trace the scene. More...
 
SLuint width ()
 
SLuint height ()
 
SLuint depth ()
 
SLbyte uvIndex ()
 
SLint bytesPerPixel ()
 
SLint bytesOnGPU ()
 
SLint bytesInFile ()
 
CVVImage & images ()
 
SLenum target () const
 
SLuint texID () const
 
SLTextureType texType ()
 
SLfloat bumpScale () const
 
SLCol4f getTexelf (SLfloat u, SLfloat v, SLuint imgIndex=0)
 SLGLTexture::getTexelf returns a pixel color from u & v texture coordinates. More...
 
SLCol4f getTexelf (const SLVec3f &cubemapDir)
 SLGLTexture::getTexelf returns a pixel color at the specified cubemap direction. More...
 
SLbool hasAlpha ()
 
SLMat4f tm ()
 
SLbool autoCalcTM3D () const
 
SLbool needsUpdate ()
 
SLstring typeName ()
 Returns the texture type as string. More...
 
SLstring typeShortName ()
 Returns the texture type short. More...
 
bool isTexture ()
 
SLstring minificationFilterName ()
 
SLstring magnificationFilterName ()
 
void build2DMipmaps (SLint target, SLuint index)
 
SLbool copyVideoImage (SLint camWidth, SLint camHeight, CVPixelFormatGL glFormat, SLuchar *data, SLbool isContinuous, SLbool isTopLeft)
 Copies the image data from a video camera into the current video image. More...
 
SLbool copyVideoImage (SLint camWidth, SLint camHeight, CVPixelFormatGL srcFormat, CVPixelFormatGL dstFormat, SLuchar *data, SLbool isContinuous, SLbool isTopLeft)
 
void calc3DGradients (SLint sampleRadius, const function< void(int)> &onUpdateProgress)
 
void smooth3DGradients (SLint smoothRadius, function< void(int)> onUpdateProgress)
 
SLVec2f dudv (SLfloat u, SLfloat v)
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 
- Public Member Functions inherited from SLEventHandler
 SLEventHandler ()
 
virtual ~SLEventHandler ()
 
virtual SLbool onMouseDown (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseUp (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseMove (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onDoubleClick (const SLMouseButton button, const SLint x, const SLint y, const SLKey mod)
 
virtual SLbool onMouseWheel (const SLint delta, const SLKey mod)
 
virtual SLbool onTouch2Down (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch2Move (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch2Up (const SLint x1, const SLint y1, const SLint x2, const SLint y2)
 
virtual SLbool onTouch3Down (const SLint x1, const SLint y1)
 
virtual SLbool onTouch3Move (const SLint x1, const SLint y1)
 
virtual SLbool onTouch3Up (const SLint x1, const SLint y1)
 
virtual SLbool onKeyPress (const SLKey key, const SLKey mod)
 
virtual SLbool onKeyRelease (const SLKey key, const SLKey mod)
 
virtual SLbool onRotationPYR (const SLfloat pitchRAD, const SLfloat yawRAD, const SLfloat rollRAD)
 
void mouseRotationFactor (SLfloat rf)
 
SLfloat mouseRotationFactor ()
 

Protected Attributes

SLuint _length
 
SLColorLUTType _colorLUT
 Length of transfer function (default 256) More...
 
SLVColorLUTPoint _colors
 Color LUT identifier. More...
 
SLVAlphaLUTPoint _alphas
 vector of colors in TF More...
 
- Protected Attributes inherited from SLGLTexture
CVVImage _images
 Vector of CVImage pointers. More...
 
SLuint _texID
 OpenGL texture ID. More...
 
SLTextureType _texType
 See SLTextureType. More...
 
SLint _width
 Texture image width in pixels (images exist either in _images or on the GPU or on both) More...
 
SLint _height
 Texture image height in pixels (images exist either in _images or on the GPU or on both) More...
 
SLint _depth
 3D Texture image depth (images exist either in _images or on the GPU or on both) More...
 
SLbyte _uvIndex
 Texture coordinate index in SLMesh (0 = default) More...
 
SLint _internalFormat
 Internal OpenGL format. More...
 
SLint _bytesPerPixel
 Bytes per texture image pixel (images exist either in _images or on the GPU or on both) More...
 
SLint _min_filter
 Minification filter. More...
 
SLint _mag_filter
 Magnification filter. More...
 
SLint _wrap_s
 Wrapping in s direction. More...
 
SLint _wrap_t
 Wrapping in t direction. More...
 
SLenum _target
 texture target More...
 
SLMat4f _tm
 texture matrix More...
 
SLuint _bytesOnGPU
 NO. of bytes on GPU. More...
 
SLuint _bytesInFile
 NO. of bytes in file. More...
 
SLbool _autoCalcTM3D
 Flag if texture matrix should be calculated from AABB for 3D mapping. More...
 
SLfloat _bumpScale
 Bump mapping scale factor. More...
 
SLbool _resizeToPow2
 Flag if image should be resized to n^2. More...
 
SLGLVertexArray _vaoSprite
 Vertex array object for sprite rendering. More...
 
std::atomic< bool > _needsUpdate {}
 Flag if image needs an single update. More...
 
std::mutex _mutex
 Mutex to protect parallel access (used in ray tracing) More...
 
SLbool _deleteImageAfterBuild
 Flag if images should be deleted after build on GPU. More...
 
SLbool _compressedTexture = false
 True for compressed texture format on GPU. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 
- Protected Attributes inherited from SLEventHandler
SLfloat _mouseRotationFactor
 Mouse rotation sensibility. More...
 
SLfloat _keyboardDeltaPos
 Delta dist. for keyboard translation. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SLGLTexture
static SLTextureType detectType (const SLstring &filename)
 Detects the texture type from the filename appendix (See SLTexType def.) More...
 
static string internalFormatStr (int internalFormat)
 Returns the internal pixel format from OpenGL. More...
 
- Static Public Attributes inherited from SLGLTexture
static SLfloat maxAnisotropy = -1.0f
 Returns the derivation as [s,t]. More...
 
static SLuint totalNumBytesOnGPU = 0
 Total NO. of bytes used for textures on GPU. More...
 
- Protected Member Functions inherited from SLGLTexture
void load (const SLstring &filename, SLbool flipVertical=true, SLbool loadGrayscaleIntoAlpha=false)
 Loads the texture, converts color depth & applies vertical mirroring. More...
 
void load (const SLVCol4f &colors)
 Loads the 1D color data into an image of height 1. More...
 

Detailed Description

SLTexColorLUT defines a lookup table as an 1D texture of (256) RGBA values.

SLTexColorLUT defines an RGBA color lookup table (LUT). It can be used to define a transfer function that are generated from a set of color and alpha points where all in-between points are linearly interpolated. Such a color/alpha lookup table is used as a transfer function e.g. in volume rendering (see the shader VolumeRenderingRayCast). All values (RGB color, alpha and position) are values between 0-1 and are mapped to 0-255 when the texture image of size 1x256 is generated.

Constructor & Destructor Documentation

◆ SLTexColorLUT() [1/3]

SLTexColorLUT::SLTexColorLUT ( SLAssetManager assetMgr,
SLColorLUTType  lutType,
SLuint  length = 256 
)

Default ctor color LUT of a specific SLColorLUTType.

◆ SLTexColorLUT() [2/3]

SLTexColorLUT::SLTexColorLUT ( SLAssetManager assetMgr,
SLVAlphaLUTPoint  alphaVec,
SLColorLUTType  lutType = CLUT_RYGCB,
SLuint  length = 256 
)

ctor with vector of alpha values and a predefined color LUT scheme

◆ SLTexColorLUT() [3/3]

SLTexColorLUT::SLTexColorLUT ( SLAssetManager assetMgr,
SLVAlphaLUTPoint  alphaValues,
SLVColorLUTPoint  colorValues,
SLuint  length = 256 
)

ctor with vector of alpha and color values

◆ ~SLTexColorLUT()

SLTexColorLUT::~SLTexColorLUT ( )
virtual

Member Function Documentation

◆ allAlphas()

SLVfloat SLTexColorLUT::allAlphas ( )

Returns all alpha values of the transfer function as a float vector.

◆ alphas()

SLVAlphaLUTPoint & SLTexColorLUT::alphas ( )
inline

◆ colors() [1/2]

SLVColorLUTPoint & SLTexColorLUT::colors ( )
inline

◆ colors() [2/2]

void SLTexColorLUT::colors ( SLColorLUTType  lut)

Colors setter function by predefined color LUT.

◆ generateTexture()

void SLTexColorLUT::generateTexture ( )

Generates the full 256 value LUT as 1x256 RGBA texture.

◆ length()

SLuint SLTexColorLUT::length ( )
inline

Member Data Documentation

◆ _alphas

SLVAlphaLUTPoint SLTexColorLUT::_alphas
protected

vector of colors in TF

◆ _colorLUT

SLColorLUTType SLTexColorLUT::_colorLUT
protected

Length of transfer function (default 256)

◆ _colors

SLVColorLUTPoint SLTexColorLUT::_colors
protected

Color LUT identifier.

◆ _length

SLuint SLTexColorLUT::_length
protected

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