您的位置:首页 > 移动开发 > Unity3D

Unity 不受光照影响shader 仿Unlit/Texture

2016-05-10 15:35 1491 查看
Unity 不受光照影响 shader ,类似 “Unlit/Texture” shader

一:

Shader "Custom/MyShader" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)//Tint Color
_MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader {
Tags {  "RenderType"="Opaque" }
LOD 100

Pass {
cull front
Lighting Off
SetTexture [_MainTex] { combine texture }
SetTexture [_MainTex]
{
ConstantColor [_Color]
Combine Previous * Constant
}
}
}
}


下面是我用surf shader 实现的

二 :

Shader "Custom/SurfTexture" {
Properties {
_Color ("Main Color", Color) = (1,1,1,1)
_MainTex ("Base (RGB)", 2D) = "white" {}

}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200

CGPROGRAM
#pragma surface surf myLightModel

//命名规则:Lighting接#pragma suface之后起的名字
//lightDir :点到光源的单位向量   viewDir:点到摄像机的单位向量   atten:衰减系数
float4 LightingmyLightModel(SurfaceOutput s, float3 lightDir,half3 viewDir, half atten)
{
float4 c ;
c.rgb =  s.Albedo;
c.a = s.Alpha;
return c;
}

sampler2D _MainTex;
float4 _Color;

struct Input {
float2 uv_MainTex;
float4 _Color;
};

void surf (Input IN, inout SurfaceOutput o) {
half4 c = tex2D (_MainTex, IN.uv_MainTex)*_Color;
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}


相关链接:http://ykxingquan.blog.163.com/blog/static/13428052013052420979/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: