纳金网

标题: 云效果shader [打印本页]

作者: 会飞的鱼    时间: 2012-2-24 14:23
标题: 云效果shader
一个云效果shader,具体未经测试,可能会有些问题,下面是原作者发的一个效果截图:







Shader "Cloud/Lightning Cloud 02" {
Properties {
_MainTex ("article Texture", 2D) = "white" {}
}
Category {
Tags {
"Queue"="Transparent"
"IgnoreProjector"="***e"
"RenderType"="Transparent"
}

Alphatest Greater 0
ColorMask RGB
Cull Off
ZWrite Off
Fog {Mode Off}

SubShader {
Pass {
Tags {
"LightMode"="ForwardBase"
}

Lighting Off
Blend SrcAlpha OneMinusSrcAlpha

BindChannels {
Bind "Vertex", vertex
Bind "Texcoord", texcoord
Bind "Color", color
}

SetTexture [_MainTex] {
combine primary * texture
}
}

Pass {
Tags {
"LightMode"="ForwardAdd"
}

Lighting On
Blend One One

CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fwdadd
#pragma fragmentoption ARB_precision_hint_fastest

#include "UnityCG.cginc"
#include "AutoLight.cginc"

s***ct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD1;
LIGHTING_COORDS(3,4)
};

v2f vert (appdata_tan v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord.xy;
TRANSFER_VERTEX_TO_FRAGMENT(o);
return o;
}

sampler2D _MainTex;

float4 _LightColor0;

float4 frag(v2f i) : COLOR
{
float4 result;
float atten = LIGHT_ATTENUATION(i);
float4 textureColor = tex2D(_MainTex, i.uv);
result.rgb = _LightColor0.rgb * atten;
result.a = 0.5 * textureColor.a;

return result;
}
ENDCG
}
}
}

Fallback "Cloud/Cloud"
}
作者: 彬彬    时间: 2012-3-8 17:08
再加点文字说明比较好
作者: 浩劫    时间: 2012-3-9 20:02





欢迎光临 纳金网 (http://old.narkii.com/club/) Powered by Discuz! X2.5