查看: 2442|回复: 5
打印 上一主题 下一主题

物体添加上明暗变化效果的shader

[复制链接]

5552

主题

2

听众

8万

积分

首席设计师

Rank: 8Rank: 8

纳金币
-1
精华
11

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

跳转到指定楼层
楼主
发表于 2012-3-8 12:13:29 |只看该作者 |倒序浏览




Shader "Hidden/TerrainEngine/BillboardTree" {

Properties {

  _MainTex ("Base (RGB) Alpha (A)", 2D) = "white" {}

}
SubShader {

  Tags { "Queue" = "Transparent-100" "IgnoreProjector"="***e" "RenderType"="TreeBillboard" }

  

  Pass {

   ColorMask rgb

   Blend SrcAlpha OneMinusSrcAlpha

   ZWrite Off Cull Off

   

   CGPROGRAM

   #pragma vertex vert

   #include "UnityCG.cginc"

   #include "TerrainEngine.cginc"

   #pragma fragment frag
   s***ct v2f {

    float4 pos : POSITION;

    fixed4 color : COLOR0;

    float2 uv : TEXCOORD0;

   };
   v2f vert (appdata_tree_billboard v) {

    v2f o;

    TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);

    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);

    o.uv.x = v.texcoord.x;

    o.uv.y = v.texcoord.y > 0;

    o.color = v.color;

    o.color *= o.uv.y;

    return o;

   }
   sampler2D _MainTex;

   fixed4 frag(v2f input) : COLOR

   {

    fixed4 col = tex2D( _MainTex, input.uv);

    col.rgb *= input.color.rgb;

    clip(col.a);

    return col;

   }

   ENDCG   

  }

}
SubShader {

  Tags { "Queue" = "Transparent-100" "IgnoreProjector"="***e" "RenderType"="TreeBillboard" }

  

  Pass {
   CGPROGRAM

   #pragma vertex vert

   #pragma exclude_renderers shaderonly

   #include "UnityCG.cginc"

   #include "TerrainEngine.cginc"
   s***ct v2f {

    float4 pos : POSITION;

    fixed4 color : COLOR0;

    float2 uv : TEXCOORD0;

   };
   v2f vert (appdata_tree_billboard v) {

    v2f o;

    TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);

    o.pos = mul (UNITY_MATRIX_MVP, v.vertex);

    o.uv.x = v.texcoord.x;

    o.uv.y = v.texcoord.y > 0;

    o.color = v.color;

    return o;

   }

   ENDCG  
   ColorMask rgb

   Blend SrcAlpha OneMinusSrcAlpha

   ZWrite Off Cull Off

   

   AlphaTest Greater 0

   SetTexture [_MainTex] { combine texture * primary, texture }

  }

}
Fallback Off

}
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

797

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
5568
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

沙发
发表于 2012-3-8 17:23:31 |只看该作者
这个效果好
回复

使用道具 举报

797

主题

1

听众

1万

积分

资深设计师

Rank: 7Rank: 7Rank: 7

纳金币
5568
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

板凳
发表于 2012-3-8 17:23:40 |只看该作者
一样
回复

使用道具 举报

1274

主题

1

听众

4万

积分

禁止发言

纳金币
43676
精华
4
地板
发表于 2012-3-8 20:31:16 |只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

643

主题

1

听众

9937

积分

高级设计师

Rank: 6Rank: 6

纳金币
9935
精华
1

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

5#
发表于 2012-3-9 17:47:15 |只看该作者
效果不错
回复

使用道具 举报

103

主题

1

听众

7956

积分

高级设计师

Rank: 6Rank: 6

纳金币
7953
精华
0

最佳新人 活跃会员 热心会员 灌水之王 突出贡献

6#
发表于 2012-3-9 20:03:58 |只看该作者
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2025-6-9 17:23 , Processed in 0.102662 second(s), 31 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部