Game Development Community

Partial blending

by Argiris Bendilas · in Torque Game Builder · 04/23/2007 (1:05 am) · 5 replies

Hello,

Is there anyway to blend only a desired color instead of overall image blending?

#1
04/23/2007 (5:25 am)
I am not really sure why you would need that. Are you trying to get a part of your image (The part without the hue) to be jagged and the other to be smooth(with the hue you want to blend)?
#2
04/24/2007 (2:36 am)
I have a cloth and i want to paint only a specified by color area of it. The blend paints let say all the cloth, how can i get partial blending, or blending with a specific color?
#3
04/24/2007 (9:02 am)
Argiris, you'd have to write a custom C++ method in the SceneObject class, and expose it as a ConsoleMethod ... it's possible, but not through TorqueScript at the current moment ...
#4
04/24/2007 (11:59 pm)
David, do you know how to do it? I don't have a problem to write C++ code, but do you know how to implement this?
I am not so good with opengl.
#5
04/25/2007 (9:38 am)
Argiris, no ... I don't know ... I do know that with the C++ you can obtain a reference to the raw bitmap for a sprite ... and if you wanted to alpha blend some of the pixels ... you could easily make a copy of that sprite ... create a new sprite from it, then modify the raw pixel data with your alpha blend settings ... for a single player game, I can't see this being too harmful ... for a networked game with lots of players who use an alpha-blending system to change there characters hair color however ... this could be troublesome ... since you could have an almost limitless number of hair styles, each of which potentially having it's own bitmap in memory ... which is where limiting the options, and possibly removing alpha-blending and replacing it with pre-rendered images is a good idea ... but I don't think your doing that ... so modifying the raw pixel data shouldn't be too harmful ...

but yeah ... I would look at the ImageMapDatablock code in the C++ ... I believe thats where the raw pixel data is stored ... so basically, you'd find the imagemap datablock storing the image you want ... then duplicate it ... and modify the copies raw pixel data (once you found the data)

don't think you'd need to touch OpenGL code ... as the pixel data should just be a byte buffer or some sort, where ... knowing which bytes were what ... you could easily change a byte with a value of 128 to 256 and go from 50% to 100% on the RGBA scale ... I'm not familiar with the way it's stored in memory ... but I'm guessing your going to be tweaking 4 bytes ... how you find them, I'm not sure ... but they'd be RGBA values ... most likely, in that order ...