Velvet

From Unify Community Wiki
Revision as of 11:11, 24 April 2007 by Metervara (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Author: Patrik Svensson

Description

Velvet or Rim Light shader

Usage

  • Create a base texture with an alpha channel. The alpha channel should be a horizontal ramp, light to the left and dark to the right.
  • Assign it to the texture property of any material using this shader.
  • Tweak alpha channel to achieve desired effect

ShaderLab - Velvet Shader

<shaderlab>Shader "Velvet" {

    Properties { 
         _Color ("Main Color", Color) = (1,1,1,0.5) 
         _MainTex ("Base (RGB) Rim-Light Ramp (A)", 2D) = "white" {} 
    } 
    SubShader { 
         //For Velvet look, Make Self-Illumination Depend on Facig Ration 
         Pass { 
              Tags {"LightMode" = "PixelOrNone"} 
              Color [_PPLAmbient] 
         
              CGPROGRAM 
              // profiles arbfp1 
              // vertex vert 
              #include "UnityCG.cginc" 
              sampler2D _MainTex : register(s0); 
              struct v2f { 
                   V2F_POS_FOG; 
                   float2  uv : TEXCOORD0; 
                   float2  uv1 : TEXCOORD1; 
              }; 
              v2f vert (appdata_base v) 
              { 
                   v2f o; 
                   PositionFog( v.vertex, o.pos, o.fog ); 
                   o.uv = TRANSFORM_UV(0); 
            
                   float3 viewDir = normalize(ObjSpaceViewDir(v.vertex)); 
               
                   o.uv1.x = dot(viewDir,v.normal); 
                   o.uv1.y = 0.5; 
               
                   return o; 
              } 
         
              ENDCG 
         
              SetTexture [_MainTex] { 
                   constantColor [_Color] 
                   combine constant * texture 
              } 
              SetTexture [_MainTex] { 
                   constantColor (0,0,0,1) 
                   combine previous lerp(texture) constant 
              } 
         
         } 
      
         UsePass " Diffuse/PPL" 
    } 
   
    FallBack "Normal-Diffuse", 1 

}</shaderlab>

Personal tools
Namespaces

Variants
Actions
Navigation
Extras
Toolbox