Modifying each pixel in a Texture

Hi all,

I am happy to announce that I have a solid base for transient effects. Yay. Tint is going to be part of the "transient" group.

So far, i have a FadeInOut and a FadeInOutController, with these you can basically fade in and out two scenes.

My problem lies in modifying a texture. I need to alter the alpha value of each pixel in a texture rendered by the drawToTexture thing.

Is there a FloatBuffer or something I can get because GL11.getPixel stuff that is used in the takeScreenshot thing gives me screen dimensions and textures need to be in powers of 2.

Any Ideas?

Sorry, can you explain a bit more what you need here? Are you looking to use pixel operations on the Pbuffer?

hmm, ://, lets see

I am passing a Texture as an argument to my effects which has been rendered using the textureRenderer. I was wondering on a way to modify it, that is, the image on the texture, the pixels of the image itself.

Not quite sure if this is what you are looking for… but.

Texture contains an Image class (getImage()).

Image tells you the width height and data as well as type. So you can get the data from the data (byte buffer) and alter it, you just need to know the format and size so you know what index to use.

If you are looking to alter something generated by render to texture though, the Image value will not be set on the Texture. Are you trying to apply changes to the texture itself?

i would like to alter the actual texture itself.


heres what id like to do:

  1. Obtain a textured rendered by the textureRenderer
  2. Stick that renderer to my transient effect.
  3. Apply changes to that texture (different alpha…etc).
  4. When alpha (e.g.) is 0, renderer next scene to a texture and ulter the new texture.
  5. When alpha == 1, dont render anymore

    currently, i have two methods to determine the current stage of processing of the effect. getCurrentStage() and getNumberOfStages().

    basically, for FadeInOut it has two stages, 1 decrease alpha, 2, change texture (which happens in the SimpleGame child) and increase alpha.

    for my render i have added a simple method:

    draw(Transient t) {

    //setup ortho mode

    // draw a quad with a size of the screen with texture coordinates

    //remove ortho


    thats the plan anyway. All thats stopping me is the applying the changes to the alpha.

    Mojomonkey said to getImage() and alter that, but renderToTexture doesn’t set the image. So how will I be able to do it??

    Should I upload my current code so you can understand it better?


I stumbled upon this post while trying to let the shields of my starships fade away - and I found a solution: one can alter the ‘colors’ array of the mesh with the rendered texture to have a lower alpha!

Though you may not be interested in a solution anymore, DP :wink: