Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Modulated vertex color shader

Discussion in 'Shaders' started by MartinVM, May 10, 2007.

  1. MartinVM

    MartinVM

    Joined:
    Jan 15, 2007
    Posts:
    20
    I think I've come across this earlier but i cant find the post / source again. What I'm looking for a is modulate2x vertex color shader. As to gain both over-brightening and shadows from as single vertex color channel.

    Help please :)
     
  2. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    You want that with actual in-game lights? Or all the lighting is already baked, and there should be no real-time lighting?

    If all lighting is already baked, then something like this shader would be good (that's a stripped down version of BakedVertexColorLighting, with 2x modulation added):
    Code (csharp):
    1.  
    2. Shader "Baked Vertex Lighting/Modulate 2X" {
    3. Properties {
    4.     _MainTex ("Base (RGB)", 2D) = "white" { }
    5. }
    6. SubShader {
    7.     Pass {
    8.         BindChannels {
    9.             Bind "Vertex", vertex
    10.             Bind "TexCoord", texcoord
    11.             Bind "Color", color
    12.         }  
    13.         SetTexture [_MainTex] { Combine primary * texture DOUBLE }
    14.     }
    15. }
    16. }
    It does nothing fancy, just binds in vertex colors, and does a modulate2x (in D3D terms) of texture and vertex color.
     
  3. MartinVM

    MartinVM

    Joined:
    Jan 15, 2007
    Posts:
    20
    Cheers, works great :)
     
  4. Dr-Game

    Dr-Game

    Joined:
    Mar 12, 2015
    Posts:
    161
    Hi~This is surface Shader~
    How can I implement modulate2x in Vertex and Fragment Shader by " + " , " - " ," * " ," / ".
    Is this just simple " *2 " with final color to return??
     
    Last edited: Jul 15, 2019