Color swapping on OGL ES 2

Started by
3 comments, last by Atrix256 14 years, 11 months ago
Hi all. I am creating a 2D game on OGL ES for iPhone. I want the player to be able to customize his character's color (For example, his character is a dog. He could change his main color to brown, white, etc). Now, lets suppose this is the image of my dog (thanks google images): http://dogs.thefuntimesguide.com/images/free/puppy-dog-face.jpg As you can see, he has different shades of brown, and some parts of the image which will not be colored/tinted (tongue, eyes, teeth, black outline). What is the best way to do this coloring? Is there a way could define a grayscale image (texture?) and add color to this? Ive searched on google, and found this: http://stackoverflow.com/questions/662440/palette-animation-in-opengl "Currently I am doing it with 2 textures: white texture under the other texture, translated the specific pixel color into transparent, then I change white texture color with glColor3f() function to what ever I want, and I see the "palet animation" on that specific color." This seems to be kinda what i want, but will the glColor color the gray's accordingly? I dont have too much experience with OGL, so any help or guidance will be greatly appreciated! :)
Advertisement
well... you could create a mask in photoshop and then multiply the color by sampling the mask.

Not sure of any other way to do it.

------------------------------

redwoodpixel.com

I think your best approach there would be to use a second image that holds information about which areas are colored. Then you can use a fragment shader to set each fragment's color depending on whether it lies withing the colorable area or not.
A fragment shader would be cool, but i think iPhone does not support shaders at the moment :S

AverageJoe, do u mean that i create a mask in photoshop and then render this map with some kind of blending function on ogl? What do u mean?
How i generally color things in opengl/directx is have a white (or greyscale) image, and then just set the diffuse color to the color i want.

This works because white is all colors put together so you can easily subtract colors out to get the color you want.

So if you have a grescale dog face, if you set the diffuse color to brown, it will be in shades of brown. If you set it to green, it will be in shades of green, etc.

That technique doesn't work for all situations, but it works nicely for some (:

This topic is closed to new replies.

Advertisement