Unity Sharder墙面应用

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

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

Unity Sharder墙面应用_第1张图片

Unity Sharder墙面应用_第2张图片

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
}
}
}



你可能感兴趣的:(unity,sharder)