View Full Version : Seperate texture color channels using GL 1.3
07-10-2007, 11:47 AM
I am working on the fixed-function shading path for our game and I want to convert a shader that treats each color channel of a texture as an intensity value modulated by color constant: clr = txtr_red * c0 + txtr_grn * c1 + txtr_blu * c2. I can use TexEnv Combine and seperate textures, but I was wondering if anybody knows a GL 1.3 way of using the same texture and seperating each color channel. Hope this makes sense :)
07-10-2007, 11:52 AM
Sorry GL 1.3 should be GL 1.4
07-10-2007, 12:18 PM
There is a dot product combine mode GL_DOT3_RGB which you could use with your texture as one input and a constant color as another input. This should be supported by almost every card out there.
this is the extension it is based on:
...and cards that support this:
07-10-2007, 01:08 PM
I don't think that will work, it doesn't let me isolate each color channel of the texture. Using three tev stages with GL_MODULATE, GL_TEXTURE as arg0, and GL_CONSTANT as arg1 is almost what I want, the only addition I require is the ability to isolate each texture color channel at each stage, eg:
tev0: texture.rrr * constant.rgb
tev1: tev0 + texture.ggg * constant.rgb
tev3: tev1 + texture.bbb * constant.rgb
Conceptually the rgb texture is actually three intensity textures.
07-10-2007, 07:40 PM
Your only option is to separate the colors yourself and do that work on the CPU.
The DOT3 mentioned above is the closest thing to what you are looking for in terms of anything pre-GL 2.0
The math is basically
4*((Arg0_r - 0.5)*(Arg1_r - 0.5) +
(Arg0_g - 0.5)*(Arg1_g - 0.5) +
(Arg0_b - 0.5)*(Arg1_b - 0.5))
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.