Unity Sharder墙面应用

来源:互联网 发布:淘宝上衣服没有吊牌吗 编辑:程序博客网 时间:2024/06/11 17:49

如果有看不懂的参数,请参看http://blog.csdn.net/u011244737/article/details/49819751

实现效果:远看有一个整体颜色,近看有细节。



Shader "Custom/TilingShader"
{
Properties
{
_Color("Base Color", Color) = (1,1,1,1)
_MainTex("Base(RGB)", 2D) = "white" {}
        //通过检视面板调整  整体颜色的UV值 ,也就是XY重复值
_ColorU("ColorU", float) = 1.0
_ColorV("ColorV", float) = 1.0
_DetailTex("DetailTex", 2D) = "white" {}
        //通过检视面板调整 调整细节的UV值
_DetailU("DetailU", float) = 1.0
_DetailV("DetailV", float) = 1.0
}

SubShader
{
tags{"Queue" = "Transparent" "RenderType" = "Transparent" "IgnoreProjector" = "True"}
Blend SrcAlpha OneMinusSrcAlpha

Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"

float4 _Color;
sampler2D _MainTex;
float _ColorU;
float _ColorV;
sampler2D _DetailTex;
float _DetailU;
float _DetailV;

struct v2f
{
float4 pos:POSITION;
float4 uv:TEXCOORD0;
};


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

half4 frag(v2f i):COLOR
{  
half4 c = tex2D(_MainTex , i.uv * float2(_ColorU, _ColorV)) * _Color;
half4 d = tex2D(_DetailTex, i.uv * float2(_DetailU, _DetailV));
return c * d;
}

ENDCG
}
}
}



0 0