To explain what I’m trying to do I’ll put a GLSL shader here:
void main(void)
{
vec2 offset;
offset = texture2D( unit0, texcoord[0].xy ).rg;
offset += texture2D( unit1, texcoord[1].xy ).rg;
gl_FragColor.a = texture2D( unit2, texcoord[2].xy).a;
gl_FragColor.rgb = texture2D( unit3, texcoord[3].xy + offset).rgb;
}
I’m trying to implement above shader using NV_texture_shader.
I put DSDT_NV textures into unit #0 and #1, and the RGBA texture into units #2 and #3 (the same texture - I’m reading it twice).
Here is my configuration:
unit / format / shader / env
#0 / DSDT_NV / TEXTURE_2D / GL_REPLACE
#1 / DSDT_NV / TEXTURE_2D / GL_ADD
#2 / RGBA / TEXTURE_2D / GL_REPLACE
#3 / RGBA / OFFSET_TEXTURE_2D_NV / GL_COMBINE_ARB
Combine at unit #3:
RGB = REAPLACE / TEXTURE / SRC_COLOR
ALPHA = REPLACE / PREVIOUS / SRC_ALPHA
The problem is that if I use unit #0 as input for OFFSET_TEXTURE_2D_NV then I get what I expect - final image distorted by texture #0, but when I use unit #1 as input then I get my image distorted by unit #1 only. I want it to be distorted by sum of units #0 and #1.