A lot of us have probably read the Vavle Dota 2 character and texture art guides by now. If you haven't, then GET ON IT!
http://media.steampowered.com/apps/dota2/workshop/Dota2CharacterArtGuide.pdfhttp://media.steampowered.com/apps/dota2/workshop/Dota2CharacterTextureGuide.pdf
One of the techniques they talk about in the guides is creating a gradient from light to dark - light at the character's head, dark at their feet. It always bothered me that I couldn't figure out a way to bake out some sort of texture or mask that would do this work for me. So I finally got fed up and worked out a solution.
What I did, essentially, is bake lighting onto my low poly model with a light above my character's head. The nice thing about this technique is that you don't need to explode your geometry, or bake objects out separately, and it gives you a lot of flexibility.
THIS GUIDE IS FOR MAYA, BUT THE SAME TECHNIQUES ARE ALMOST CERTAINLY POSSIBLE IN ANY SOFTWARE.
Step One - Set up your UV's
This goes for any kind of baking, but don't bake onto mirrored uv's! An easy way to get mirrored uv's out of the way is to simply offset them one full unit in the UV editor (so 0 to 1 becomes -1 to 0). When you bake, the software will ignore any uv's outside the 0 to 1 area.
Step Two - Normals
The crux of this technique is that we are getting what we want by baking lighting from a single source, above the character's head. But if our light source is above the character then the bottom of their chin, under their arms, etc, will be completely in shadow, wont they? Yes they will - unless we change their normals to point straight upward.
Quick crash course on normals - a polygon's "normal" is what direction that polygon is "facing". So regardless of what shape or orientation a polygon is, if it's normal is pointing upward, then it will act like it's facing upward. Light from above will illuminate that polygon, while light from below will not affect it.
Usually the normals of your model will point outward, in a way that makes sense (top of your model gets lit from above, bottom gets lit from below.
But since we want all parts of our model to get lit from above, we want all our normals facing upward. To do this, select all of your geometry, go to the Normals Tab under the Polygons Shelf and select Set Vertex Normals. Hit the box next to it, actually, since we need to adjust the settings. Make sure your settings look like this.
X and Z values at 0, Y at 1 (pointing upward). Click Set Normal, and as you can see, the normals are all pointing upward now.
Step Three - Light
We are going to bake lighting, so we need a light. Create a point light and place it above your character's head. Make sure you are previewing lighting, so that you can see the actual effect it will have (lighting > use all lights).
Okay, our problem here is that light has no fall-off, so all parts of the character are equally well lit. To fix that, go to the light properties and give it a linear falloff, then mess around with the brightness till the gradient looks like something you want. Don't worry if the contrast isn't intense enough, we can deal with that in photoshop. Here I set my intensity to 35. If your scene size is smaller, you will probably need a smaller intensity, and vice versa.
Step Four - Baking Lighting
To bake lighting in Maya, you need to make sure the mental ray plugin is loaded (Window > settings/prefs > plugin manager > mayatomr.mll). Then go to the Rendering menu, and go to Lighting/Shading > Batch Bake (mental ray) and click on the options. Go to edit > reset settings.
-Use bake set override ON
-Color Mode to ONLY LIGHT
-Set your bake resolution, file type, anti-alisasing, and edge padding to whatever you want.
Hit Convert, and mental ray will bake out your texture. (check the script editor if you aren't sure where it saved it).
There you go, your very own mask texture!
Just play with the levels in photoshop to get the correct amount of contrast.
Hope you find it useful!
A subtle gradient from top to bottom:
Replies
Hah, now I feel dumb for not thinking of that. Thanks for the alternate method!
I put it in single file if you dont mind .
You can have a lot of control with this setut. Change the intensity of the gradient, modify the hues and so on. You can even combine it with noise to create all kinds of cool effects.
It also bakes nicely with RTT
edit:
These PDF docs are fucking awesome
- assign a new set of UVs to channel 2, mapped as planar from front view
- apply a gradient texture to the model
- render to texture from channel 2 to channel 1
- done!
I don't mind at all! Good on you!
@captSwing
@teaandcigarettes
@pior
Lol, I feel like I've been going about this in the most complicated manner. I'm pretty sure there are shaders for maya that would let me do this easier, but I don't remember maya's shader tools nearly well enough to get them to work.
cryrid thanks for your reply...going to try zapplink
i use 3dcoat to do it.
use the paintbucket tool
1.click on "lines mode"
2.click "pick point 1" and choose the top of your model.
3.click "pick point 2" and choose the bottom of your model.
4.click the "layer" button and it will fill your current layer with a gradient using you foreground and background colors
Baking down a gradient plugged into the diffuse slot in max didn't work for me, unfortunately (some sides stay black, probably due to the front-view-planar mapping?) ..
i usually do this, also textools transfer button makes this process very fast
on a technical sidenote this entire process could be scripted so youd only have to press one button
Ravenslayer, I googled TexTools and then cried silently because it's only for 3dsmax... just like everything else
Here's the link for anyone else who's interested:
http://www.renderhjs.net/textools/
i tired the zaplink one but didn't work as i hope, it have some work to do with... oh well, i thinki will do the old methode : painting directly...
at the moment, i'm trying the maya one but in 3Ds max, not very good and it's not enough fffff....
i wish pixologic add the feature "gradient fill" that could work like 3dcoat.
Zbrush has lightbox, which can work the same way, I think.
If anyone would try it then I'd be very grateful for some feedback, especially if you find any problems/bugs.
I'll try to record a showcase video for this script soon enough.
Ill try it out Kodde and let you know. Looks like you were doing what I was.
[ame="http://www.youtube.com/watch?v=R52kclEBa8E"]Creating a gradient texture in Maya with MEL script - YouTube[/ame]
That said, I almost always put a 'ground plane' in my scene when I bake my AO which gives a very similar effect.