Search Unity

DecalBumpSpecular Shader (not quite working)

Discussion in 'Shaders' started by austinj, Apr 10, 2009.

  1. austinj

    austinj

    Joined:
    Apr 10, 2009
    Posts:
    10
    Hello Everyone,

    I am trying to create a BumpedSpecular shader that also has a Decal layer and I cant seem to figure out how to get one working. I need it so that I can add some details to buildings that share a tiled brick texture.

    Here is what I have so far using the source for the built in shaders...
    //////////////////////////////////////

    Shader "DecalBumpSpec" {
    Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _SpecColor ("Spec Color", Color) = (1,1,1,1)
    _Emission ("Emmisive Color", Color) = (0,0,0,0)
    _Shininess ("Shininess", Range (0.01, 1)) = 0.7
    _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
    _DecalTex ("Decal (RGBA)", 2D) = "black" {}
    _BumpMap ("Bumpmap (RGB)", 2D) = "bump" {}
    }

    SubShader {
    Material {
    Diffuse [_Color]
    Ambient [_Color]
    Shininess [_Shininess]
    Specular [_SpecColor]
    Emission [_Emission]
    }
    Pass {
    Lighting On
    SeparateSpecular On
    SetTexture [_MainTex] {combine texture}
    SetTexture [_DecalTex] {combine texture lerp (texture) previous}
    SetTexture [_MainTex] {combine previous * primary DOUBLE, previous * constant constantColor [_Color]}
    }
    UsePass "Bumped Specular/PPL"
    }

    Fallback "VertexLit", 1

    }
    //////////////////////////////////////////////////

    When I comment out the -UsePass "Bumped Specular/PPL"- the decal works, but when I leave it in it is overriding the Decal texture and just giving me the BumpSpec.

    I have tried several other things but this seems to be the closest I have gotten to achieving the result I am looking for. Funny thing is, this was also the simplest attempt.

    If anyone knows why this is not working, or if you already have a DecalBumpSpec shader, please let me know. I am also very new to this whole shader thing...just so you know.

    Thanks in advance,
    AustinJ