本shader实现基于世界坐标的贴图置换效果。
效果如下:
设置面板如下:
可在面板上设置切换方向,与切换对象,及其切换速度。
shader实现如下:
Shader "XM/Effect/SwapTexture" {
Properties {
_Color ("Color", Color) = (1,1,1,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_TargetTex ("Target Tex", 2D) = "white" {}//目标贴图
[KeywordEnum(Up, Down, Left, Right, Forward, Back)] _mode ("Mode", Int) = 0//切换方向
_SwapBlend ("Blend", Range(0,1)) = 0//0-1混合值
_SwapMin("Min Value", Float) = 0//最小世界坐标
_SwapMax("Max Value", Float) = 0//最大世界坐标
_Glossiness ("Smoothness", Range(0,1)) = 0.5
_Metallic ("Metallic", Range(0,1)) = 0.0
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
#pragma surface surf Standard fullforwardshadows vertex: