您的位置:首页 > 其它

Shader学习笔记(六)_Time的使用,会动的纹理

2016-10-11 12:37 393 查看
_Time的使用

会动的纹理

Shader "Custom/River" {
Properties {
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_XSpeed("X Speed",Range(0,10))=2
_YSpeed("Y Speed",Range(0,10))=2
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200

CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Lambert

// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0

sampler2D _MainTex;

struct Input {
float2 uv_MainTex;
};

float _XSpeed;
float _YSpeed;

void surf (Input IN, inout SurfaceOutput o) {

float2 scrolledUV=IN.uv_MainTex;
float xScrollValue=_XSpeed*_Time.y;
float yScrollValue=_YSpeed*_Time.y;

scrolledUV+=fixed2(xScrollValue,yScrollValue);
fixed4 c=tex2D(_MainTex,scrolledUV);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}


_Time内置变量与Time.time类似

float4 _Time:Time(t/20,t,t*2,t*3)用于shader中可动画的地方

根据需要选择某个分量
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: