change texture color


I have a texture for the grass and I would like to make it change slowly in time, for example decreasing the grey level of green one by one.

I wonder if it is possible to do the change in an opengl texture, instead of changing my picture and then loading it in a texture every time.



Create uniform variable in your fragment shader (I assume You are doing texture stuff there), and change it’s value every frame.
In the shader do something like this:

vec4 lookup = texture2D(...) <- your texture
lookup.r *=, +=, -= ...etc.  yourUniformVariable;
(the same for other components )

I don’t know if this is the best way to do that, but it works.
ps. sorry for my bad English.

If I use a shader, I will have to implement evething that is treated in this part of the pipeline, doesn’t I?

Like the light and so on. It may be a lot of work :frowning:

In fixed pipeline there is thing called pixel transfer
I never used it (jumped straight into shaders), but that may be what You are looking for.

ps. Implementing light (simple diffuse + ambient + specular) is not that hard in shaders (< 100 lines of code)

good tutorial on GLSL (especially lights):