Why is this oversaturating my textures?

Consider the following function:

// returns a color that is blended with larger samples of itself. used to
// reduce the appearance of tiling
fixed4 tex2DTiled(sampler2D tex, float2 uv) {           
    return tex2D(tex, uv) * tex2D(tex, uv * -0.1) * tex2D(tex, uv * -0.01) * 4;
}

This is causing an over saturation of textures. I never noticed it until now, but I wrote this a long while ago and am having trouble understanding why it is happening.

Open gimp/photoshop duplicate a layer 2-3 times and set layers to multiply.

Hmm, I see what you are trying to say. This appears to be the correct way to do this:

float4 tex2DTiled(sampler2D tex, float2 uv) {               
    return (tex2D(tex, uv) + tex2D(tex, uv * -0.1) + tex2D(tex, uv * -0.01)) / 3;   
}
1 Like