PDA

View Full Version : Need help implementing a Color Look-Up T able (CLUT) in GLSL


Shree
12-11-2006, 07:35 AM
Following on from my request for help with 2-sided lighting in GLSL I am now implementing a CLUT so that I can modify the colour scheme of the visualization using the shader without needing to relaod the scene geometry from memory.

From Reedbeta's feedback I now realise that I can do this using the fixed-function pipeline (via glMaterialfv). However, I would like to try implementing the same functionality in a shader as an exercise in shader programming.

However, as before, I am unsure exactly how to go about this.

From what I have read, one approach is to use the 8 texture co-ordinates available to vertex shaders to specify a colour code which is used to "look-up" a colour in a fragment shader containing a CLUT.

Is this correct ? Do you know of any examples (online) which use this method ?

Reedbeta
12-11-2006, 09:36 AM
The basic idea is to have a one-dimensional texture, where each pixel contains a different color - then the texture coordinate is the index (scaled into [0, 1] range). In the shader you just do a lookup into the texture with the given coordinate and get your color. The texture coordinates are baked into the scene geometry and don't change, but you can upload a new color table containing different colors in the same index locations, in order to change the color of the output.

Kenneth Gorking
12-12-2006, 07:22 AM
ATI did a chapter in ShaderX3 about rendering a crowd with variation, and one of their tricks seems to what you are trying to do. A link to the paper: http://ati.amd.com/developer/shaderx/ShaderX3_DrawingACrowd.pdf