Search Unity

Blend textures based on vertexcolor

Discussion in 'Shaders' started by metervara, Jul 24, 2007.

  1. metervara

    metervara

    Joined:
    Jun 15, 2006
    Posts:
    203
    I'm trying to do something like the Two Layer Terrain shader but instead of mixing based on an alpha texture, I want to mix based on vertex colors (grayscale value or possibly alpha)

    Could that be done using the "combine src1 lerp (src2) src3" and have src2 somehow be vertex color? Or do I need to do a fragment program?

    /P
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Do you also want vertex lighting on that thing, or not? If you don't want the lighting, then you just turn lighting off and use "primary" in the combiner (additionally if you use a vertex program, output something to color).

    If you do vertex lighting, then there's no easy way of doing that (unless you write a fragment program). Because with vertex lighting, the color is the lighting value already, and not the input color.
     
  3. metervara

    metervara

    Joined:
    Jun 15, 2006
    Posts:
    203
    Actually I'm not sure if I want lighting yet, it's for an abstract piece so I'll have to test it. Guess i'll start with the "no light" version and worry about fragment programs later :)

    One thing though - the lerp function always uses the alpha right? So my vertex colors need alpha too?

    thanks - P
     
  4. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Yes. That's just the limitation of fixed function combiners. If you want more arbitrary blends, use fragment programs.