Jump to content


Need help implementing a Color Look-Up T able (CLUT) in GLSL


2 replies to this topic

#1 Shree

    Member

  • Members
  • PipPip
  • 31 posts

Posted 11 December 2006 - 03:35 PM

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 ?

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4782 posts
  • LocationBellevue, WA

Posted 11 December 2006 - 05:36 PM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 Kenneth Gorking

    Senior Member

  • Members
  • PipPipPipPip
  • 907 posts

Posted 12 December 2006 - 03:22 PM

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/d...awingACrowd.pdf
"Stupid bug! You go squish now!!" - Homer Simpson





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users