0

If I use:

void main() {
  gl_FragColor = texture2D ( sampler, uvVarying ) * colorVarying;
}

with colorVarying being (1, 0, 0, 0) in a simple fragment shader, the texture is turned red as I expected.

But I would like to add more red, instead of multiplying with red. But if I sum the texture2D with colorVarying my fragment changes to completely white.

Any ideas why? And how can I accomplish summing colors?

vertti
  • 7,539
  • 4
  • 51
  • 81
  • 1
    Do you have blending enabled and if so, what's the blend mode? Are you doing a color clear at the start of the frame and if so, what's the clear color? One thing that's happening there is that multiplication sets the texture's alpha channel to zero while addition keeps it unchanged, this may not be what you want. – Arttu Peltonen Sep 11 '13 at 18:38
  • I'm not aware of doing any clearing but as it's an engine (MOAI) I'm using I'm not really sure. Multiplying alpha with 0, I was wondering about that too, wouldn't it make the whole texture transparent? – vertti Sep 12 '13 at 04:33
  • Yes, provided you have alpha blending enabled - that's why I thought maybe you're seeing a white clear color from the background. Does the texture display correctly if you remove any additional multiplication or addition? – Arttu Peltonen Sep 12 '13 at 12:38

0 Answers0