瀑布(流水)效果"/>
简单瀑布(流水)效果
步骤
简单的瀑布效果,简单地分为以下四个步骤
网格
纹理及纹理的设置
shader
Shader "Mobile/流水(Test)" {Properties {_TintColor ("Tint Color", Color) = (0.5,0.5,0.5,0.5)_EmissiveStrength ("Emissive strength", Range (0,1)) = 0.5_Translulency ("Translulency", Range (0,1)) = 1.0_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}}SubShader {Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}LOD 200Cull Off Lighting Off ZWrite OffBlend SrcAlpha OneAlphaTest Greater .01ColorMask RGBCGPROGRAM#pragma surface surf Lambert alphafixed4 _TintColor;half _EmissiveStrength;half _Translulency;sampler2D _MainTex;struct Input {float2 uv_MainTex;};void surf (Input IN, inout SurfaceOutput o) {half4 c = tex2D(_MainTex, IN.uv_MainTex);//o.Albedo = 2*c*_TintColor;o.Emission = 2*c*_TintColor*_EmissiveStrength;o.Alpha = 2*(c.a /* (c.r+c.g+c.b)/3*/)*_Translulency;}ENDCG}Fallback "Transparent/Diffuse"
}
- 脚本(修改瀑布对象的Material的Texture的Offset属性,即纹理的偏移量)
using UnityEngine;
using System.Collections;public class uvAnimation : MonoBehaviour
{public int materialIndex;public string textureName = "_MainTex";public Vector2 uvAnimationRate = new Vector2(1f, 0f);private Vector2 uvOffset = Vector2.zero;private void LateUpdate(){uvOffset += (Vector2) (uvAnimationRate * Time.deltaTime);if (GetComponent<Renderer>().enabled){if(GetComponent<Renderer>().materials.Length > materialIndex){GetComponent<Renderer>().materials[materialIndex].SetTextureOffset(textureName, uvOffset);}}}
}
演示效果
更多推荐
简单瀑布(流水)效果
发布评论