Game Development Community

Tinting

by Patrick Jeeves · in Torque Game Engine · 03/23/2007 (3:58 pm) · 4 replies

Where do i call the glBlendFunc function from in order to tint meshes/textures? do i have to make the engine call it in order to tint an object, or can i make the object itself call the function?

#1
03/23/2007 (8:44 pm)
Oh man, ummm, explain exactly what you want to do and with which object. The reason is this question is very broad.

My first response is to use the ability of a shapebase object to use different textures rather than some "tinting" method. You can set a shapebase object to different textures at runtime through script. Search for skin or setskinname in the forums. Or go to page 161 in "The Game Programmer's Guide to Torque". BTW, I recommend getting that book if you do not already have it.

Good luck,
Frank
#2
03/23/2007 (9:03 pm)
I want to color greyscale textures on a model in real time, and call different textures and colors with a random number generator, so it looks different every time the constructor is called.

the object in question is based off of this, with a modified constructor:

http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=5516

also i already knew i could do that with shapebase objects; i would need an absurd number of textures for all the things i want to use this for though.
#3
03/25/2007 (2:33 pm)
Hey, I need to do this myself for my project, so I looked into it a little bit.

It's not supported, and it's not a trivial thing to add. Here's how I'm planning to do it:

- Add a Tinting Flag to TSMaterialList, change the exporter to set this on some materials.
- Add a tint color to TSShapeInstance
- Use these in tsMesh.cc (probably pass the current color through smRenderData -- not entirely sure).
- Add scripting hooks to set the tint color for everything

There are a lot of different cases in the render modes, so you'd have to apply the tinting to each one. I tried hard-coding some color values (just for debugging, doing that tints EVERY mesh the same color) and it worked.

For more complicated, texture-based tinting, there is an article in "Game Programming Gems IV", that goes over how to do this with either multitexture or multipass, see Greg Seegert "Techniques to Apply Team Colors to 3D Models", Chapter 5.8

Anyways, whenever I get around to adding this I will try and make a resource out of it, but this will probably be a few months away.

Joel
#4
03/25/2007 (4:20 pm)
You could just grab the actual texture pixels and change them?