Some holiday help?

Hi everyone. I need a little help. More than likely this is a super simple solution. I am an artist and not very educated on shaders.

I am attaching an image to show where I need help. I am vertex coloring the entire world, via pre-lighting inside of Maya. Some of the objects need to be double sided, have vertex coloring and a readable alpha channel (i.e. foliage and trees). I have gotten the foliage/trees to be double sided, to use the alpha channel for transparency, but I haven’t gotten them to show the vertex coloring from pre-lighting. The vertex coloring shows up on the much simpler shader called “Baked Vertex Colors”…you can see it in Unity as the darker shaded areas of the terrain. I need the shader for the trees and foliage to show vertex colors as well, yet I have no clue what to add into the shader script to accomplish this or where to add it within the script.

This is kind of greek to me :slight_smile:

Where did you get your double-sided shader to begin with? It’s not very complicated; it should be quite readable to you, if you are able to understand the “multiply” blending mode, in Photoshop. Your problem right now is that you’re never multiplying by the vertex colors, because you don’t use “primary”, in your shader. Instead, you’re multiplying by a constant color, which you haven’t even mentioned as being necessary (though it may be). Try working that in, and I’ll help you understand anything at all you don’t understand in the shader.

Thanks for your help Jessy. I don’t understand the coding aspect of it or the syntax really. I know Photoshop well, but I work in it purely visually, you won’t ever see my working with a lick of script. I do understand the multiply aspect…so if I am correct I want to multiply the vertex colors over the texture somehow in the shader? I got these shaders from the Unity wiki via a Google search…I really haven’t a clue about the constant color thing and if it’s necessary or not. I see it within the script, but I haven’t the first clue what it does. So I just need to figure out how to multiply vertex color over the diffuse texture in this shader… again thank you for your help sir and have a great christmas :slight_smile:

Well, you’ve got two lines, already, that you don’t need: ZWrite On, and Lighting Off, because those are the defaults. You also don’t need to have “texture * constant” written twice. What comes after the comma is the calculation for the alpha channel; if you don’t use the comma, the same calculation happens for all four channels. The _Color property defines a color, that in your current code, will do the same thing as using a “Solid Color” “adjustment layer” in Photoshop, with the multiply blending mode. So that’s a way to “tint” your texture, the exact same as Photoshop (I wasn’t suggesting scripting in Photoshop - I was really just talking about layering and Blend modes.)

You really can think of what you do in Photoshop’s Layers panel as constructing a shader. If you do’t have too many layers, or different blending modes, you can often replicate what you do in Photoshop, in ShaderLab. You just typically don’t need, or want, to do that, because anything static that can be done by Photoshop, before coming into Unity, should. Learn to think of lighting as a multiplied layer, because that’s what is generally going on in other people’s shaders. I don’t know if you already paint like this, but it can be very helpful - I can give you some more tips on this if you need some.

So, here’s what you should do:

  • Decide if you need a solid color tint. Not having it will simplify and improve performance, marginally.
  • Read this page to see how to get better control over your trees. Not having control over the AlphaTest Cutoff tends to suck. (You need what’s in the second code example.)
  • You need to multiply in “primary” somehow. Your shader already binds the vertex colors, with the Bind “color”, color line, so that’s done.

The syntax isn’t important for you to memorize - those brackets can seem a little arbitrary, and although you need them in the right place, for the shader to work, they’re not “artistic intentions”. However, all the actual words and numbers are just things you would use in a “painting app”. It’s important for you to understand what every single one of them means. Again, try editing the shader, yourself. Most of the length of that shader is white space; this can literally be done in less than five seconds if you know what you’re doing, but nobody started off knowing what they were doing, so don’t expect that, with your current understanding. Just make sure, if you don’t completely understand even one thing, you mention it here, so that you can make the art you want to make, and not be limited by not having a clue what’s going on with the shader. :wink:

I finally resolved this on Christmas Eve day lol…and with your help Jessy I was able to find the gumption to go around and find existing shaders that did the different parts I needed and then frankenstein them together. All the features I needed now work with this new shader. It supports texture with alpha channel, alpha test cutoff slider, vertex colors from 3D app, doubled sided rendering. Woo hoo, let the world building commence. This shader will be the foundation for all of my world vegetation. BTW I am doing pre-lighting in Maya, which will basically do all of the static lighting for the world, shadows, highlights, etc…it’s kind of a replacement for a lightmap. I do use shadow stencils from a texture to kind of cast real looking shadows as well.

Everything looks good*, except the Material block, which is doing nothing, and which wouldn’t do anything useful even if you turned the lighting on, because you use colors in that block, not textures. And again, you don’t need Lighting Off, but it doesn’t hurt anything to leave it in.

I’d recommend using this, though. It takes away the ability for you to get unexpected results, if by some chance, your vertex alpha isn’t white:

Combine primary * texture, texture

instead of what you have:

Combine primary * texture
  • The indenting doesn’t look good at all, but it doesn’t affect the functionality, just the readability. :wink: