View Full Version : change texture color

04-05-2010, 03:27 PM

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.


04-05-2010, 04:22 PM

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.

04-07-2010, 03:31 PM
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 :(

04-08-2010, 01:13 PM
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):