View Full Version : Texture combiners
02-05-2009, 08:21 AM
Supposing to have two textures bound on, respectively, texture unit 0 and texture unit 1.
Modulating them (t0 * t1), is there a way to obtain:
t0.r * t1.r
t0.g * t1.r
t0.b * t1.r
t0.a * t1.r
What I need is to consider all the t1 channels equal to t1 red channel.
Is there an operand that realizes this?
Thanks in advance.
02-05-2009, 12:25 PM
Not directly, but if you have at least 3 texture stages available, I guess you could feed in <1,0,0> in as the constant color and dot t1 with that.
It's unfortunate that there is no unsigned dot product, so you would indeed need three stages:
First you would need a lerp to remap t1 to [0.5, 1], perform a dot3 with <1, 0.5, 0.5>, then modulate with t0.
However you might run into precision issues with this since you lose a bit in the remap step, and 0.5 might not have an accurate representation in the numerical format used in the fragment pipeline. And the biggest issue of course, you can't expect ES 1.x implementations to have three texenv stages.
I am of course assuming that t1 is a rendertarget texture, otherwise the problem should be easily solvable at the texture upload stage.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.