简单瀑布(流水)效果

编程入门 行业动态 更新时间:2024-10-09 19:23:46

简单<a href=https://www.elefans.com/category/jswz/34/1762263.html style=瀑布(流水)效果"/>

简单瀑布(流水)效果

步骤

简单的瀑布效果,简单地分为以下四个步骤

  • 网格

  • 纹理及纹理的设置


  • 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);}}}
}

演示效果

更多推荐

简单瀑布(流水)效果

本文发布于:2024-02-06 15:47:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1749758.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:瀑布   流水   效果   简单

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!