[SOLVED] Using a texture to pick colours within a glsl TOP

I’m trying to use a layout TOP with 1x1 pixel constants to create a texture palette to use within a glsl TOP. When I sample the texture within glsl using this line

vec3 color = texture(sTD2DInputs[0], vec2(0.,0.)).rgb;

I get a colour much darker than the input colour, in this case white becomes dark grey.
I’ve uploaded a simple example of what I mean.

ColourInput.toe (4.5 KB)

I’m not sure what is happening here. If anyone could shed some light on this or suggest a different way of doing it I would be very appreciative.


I think you got your mapping wrong so not pointing to right color from your texture.

I would use UV coord to grab the color from the texture. For example :

vec2 uv = vUV.xy;
float position = 1; // position from 1 to 3
uv.x = 0.3 * position;
vec3 color = texture(sTD2DInputs[0], uv).rgb;

you need to sample from the center of each pixel.
So for the leftmost pixel this becomes vec2 uv = (1/6.0, 0.5)

example atached:
sample_from_center_of_pixels.tox (1.4 KB)

1 Like

Perfect. Thanks.