纳金网
标题:
室外玻璃幕墙shader
[打印本页]
作者:
晃晃
时间:
2011-8-26 08:45
标题:
室外玻璃幕墙shader
老外分享的一个shader,做建筑虚拟可以用下!
Shader "Building/Glass" {
Properties {
_Lightmap ("Lightmap (RGB) Reflectiveness (A)", 2D) = "black" {}
_Color ("Main Color", Color) = (1,1,1,1)
_Cube ("Reflection Cubemap", Cube) = "" { TexGen CubeReflect }
}
Category {
Tags { "Queue" = "Transparent-110" }
Blend SrcAlpha OneMinusSrcAlpha
Lighting Off
Colormask RGB
// ---- fragment program cards
SubShader {
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_fog_exp2
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
struct v2f {
V2F_POS_FOG;
float3 normal;
float3 viewDir;
float3 rotNormal;
float2 uv;
};
uniform float4x4 _RotMatrix;
uniform float4 _Lightmap_ST;
v2f vert (appdata_tan v)
{
v2f o;
PositionFog( v.vertex, o.pos, o.fog );
o.normal = mul( (float3x3)_Object2World, v.normal );
o.rotNormal = mul( (float3x3)_RotMatrix, o.normal );
o.viewDir = mul( (float3x3)_Object2World, ObjSpaceViewDir(v.vertex) );
o.uv = TRANSFORM_TEX(v.texcoord, _Lightmap);
return o;
}
uniform samplerCUBE _Cube;
uniform float4 _Color;
uniform sampler2D _Lightmap;
float4 frag (v2f i) : COLOR
{
float3 normal = i.normal;
i.viewDir = normalize(i.viewDir);
half nsv = saturate(dot( normal, i.viewDir ));
// calculate reflection vector in world space
half3 r = reflect(-i.viewDir, i.rotNormal);
half4 lightmapColor = tex2D(_Lightmap, i.uv);
half4 reflcolor = texCUBE(_Cube, r);
half fresnel = 1 - nsv*0.5;
half fresnelAlpha = 1 - nsv * (1 - _Color.a);
half4 c = half4( lerp( _Color.rgb, reflcolor.rgb, fresnel * lightmapColor.a ), fresnelAlpha );
c.rgb *= lightmapColor.rgb;
return c;
}
ENDCG
}
}
// ---- cards that can do cube maps
SubShader {
Pass {
SetTexture [_Cube] { matrix[_RotMatrix] constantColor(1,1,1,0.5) combine texture, constant }
}
}
// ---- cards that can't do anything
SubShader {
Pass {
Color (1,1,1,0.3)
}
}
}
}
作者:
Asen
时间:
2011-9-9 09:37
作者:
菜刀吻电线
时间:
2011-12-30 18:25
楼主收集的可真全哦
作者:
C.R.CAN
时间:
2012-1-26 23:21
送你一件外套,前面是平安,后面是幸福,吉祥是领子,如意是袖子,快乐是扣子,口袋里满是温暖,穿上吧,让它相伴你的每一天!新年快乐!
作者:
奇
时间:
2012-5-15 23:18
精典,学习了!
作者:
晃晃
时间:
2012-10-25 23:26
已阵亡的 蝶 随 风 舞 说过 偶尔按一下 CTRL A 会发现 世界还有另一面
作者:
奇
时间:
2012-11-12 23:22
好可爱的字,学习了
作者:
菜刀吻电线
时间:
2013-2-5 23:40
响应天帅号召,顶
作者:
晃晃
时间:
2013-3-12 23:18
既来之,则看之!
欢迎光临 纳金网 (http://go.narkii.com/club/)
Powered by Discuz! X2.5