I am writing a shader that has 3 layered textures. It is ok to interpolate then. But i have a problem with the last one. It is a white number with a black outter shadow (1st image) This last texture shall be multiplied by a color and then alpha blended to the previous result (2nd image with red).
The script should be something like:
Combine constant*texture lerp(texture) previous
But the script language does not accept it. If i do:
Combine constant lerp(texture) previous
I loose the black outter shadow.
Is there anyway to create this aux texture result of the texture * color and the interpolate with the previous texture? Right now, either i loose the shadow or the number has to be white.
Adding a new material with a simple shader to multiply texture*color is not ok due to performance.
You will need an extra combine to get both a multiply and a lerp and even then it may not work depending on how you make your ‘previous’. If you post the full shader, perhaps someone can help out.
I could be wrong (I’m not the best fixed function programmer here by a long shot), but I don’t think it’s possible to do what you want without a fragment shader. The problem is that you really only have one register that survives between texture applications, and there are no combiners that will multiply and lerp in a single operation.
This works fine if you have more than three texture stages (you just have to move the RGB of _Tex2 to its Alpha channel, and vice versa). Use this instead of your third one:
SetTexture[_Tex2] {Combine previous * one - texture}
SetTexture[_Tex2] {
ConstantColor[_Tex2Color]
Combine constant * texture alpha + previous
// Combine texture alpha * constant + previous
// ought to work, but doesn't.
// Someone can report the bug; I honestly don't care much. :-P
// Combine constant Lerp(texture) previous
// also works.
}
Do you really want that at the end, though? I would think that you’d want to multiply lighting in after all that.
Is this not what you were suggesting, tomvds?
fcloss, please use test images that have actual alpha channels in the future. I had to create my own test images because of your baked checkerboards. Not at all a big deal for this, but it’s easier to test with ready-to-go files.
Jessy, sorry for not attaching the alpha images. I’ve attached then now.
I will try to explain why i need this shader. I am creating an image to represent a soccer player. The soccer player is a simple mesh that has a material with 3 textures. The first one is the base jersey color or texture. The second one represents the stripes if the jersey is not plain. The last one is the player number.
The second and third textures are simple alpha images, which i multuply with the team colors to result in the jersey color.
In the image i’ve added in the initial post, it is a team with a verticaly striped jersey with a blue back color, a darken blue color and a red number color. The reason i need the black shadow around the number is because depending on the 1st and 2nd colors the number isn’t visible for the user.
Unfortunately, i couldn’t get the expected result using your modification in the shader. Below is the result (the outter shadow was lost):
The expected would be something like: (if _Tex2Color is yellow)
I can easily separate the outter shadow and the number. This way i could solve it quickly, but i would like to avoid creating a new texture.
You didn’t do what I said. You can’t have _Tex2 structured like it is.
As for what you’re doing with it, that’s what I figured. Doing lighting in the first stage doesn’t make sense (aside from performance), because the stripes and number won’t be lit.
That’s right Jessy. I have created a new texture with the outter shadow to solve it.
About the light, you are correct again. What i can do is create new passes to redefine the material parameters and then combine the primary and the textures, right?