Search Unity

Just a simple fog to my simple vertex colour shader?

Discussion in 'Shaders' started by Domarius, Sep 30, 2015.

  1. Domarius

    Domarius

    Joined:
    Jan 5, 2013
    Posts:
    103
    Here's a simple shader I got from the Unity Wiki. It's great because it applies the vertex colour in a way that lets me create my own lighting (which is necessary in a Minecraft game - normal lighting looks dark and ugly because of the angle of the block faces).

    All I want to do is add a fog colour based on distance. What's the simplest way to do it for this shader?

    Code (CSharp):
    1. Shader "Custom/Vertex color unlit" {
    2. Properties {
    3.     _MainTex ("Texture", 2D) = "white" {}
    4. }
    5.  
    6. Category {
    7.     Tags { "Queue"="Geometry" }
    8.     Lighting Off
    9.     BindChannels {
    10.         Bind "Color", color
    11.         Bind "Vertex", vertex
    12.         Bind "TexCoord", texcoord
    13.     }
    14.  
    15.     SubShader {
    16.         Pass {
    17.             SetTexture [_MainTex] {
    18.                 Combine texture * primary DOUBLE
    19.             }
    20.         }
    21.     }
    22. }
    23. }
     
    Last edited: Sep 30, 2015
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Fog On
     
  3. Domarius

    Domarius

    Joined:
    Jan 5, 2013
    Posts:
    103
    Ah thanks - I tried that, it gave a code error, but it turns out the answer is really that I'm an idiot. The fog settings under lighting for the scene work just fine with this shader...