zoukankan      html  css  js  c++  java
  • Unity3D Shader水波效果

    水波效果

    Shader "Custom/WaterWave" {
        Properties {
            _MainTex ("Base (RGB)", 2D) = "white" {}
            _WaveStrength("Wave Strength",Float) = 0.01
            _WaveFactor("Wave Factor",Float) = 50
            _TimeScale("Time Scale",Float) = 10
        }
        SubShader {
            
            Pass
            {
                CGPROGRAM
    
                #pragma vertex vert 
                #pragma fragment frag
    
                struct appdata
                {
                    float4 vertex : POSITION;
                    float2 uv : TEXCOORD0;
    
                };
    
                struct v2f {
                    float4 vertex:SV_POSITION;
                    float2 uv:TEXCOORD0;
                };
    
                sampler2D _MainTex;
                float _WaveStrength;
                float _WaveFactor;
                float _TimeScale;
    
                v2f vert (appdata v) 
                {
                    v2f o;
                    o.uv = v.uv;
                    o.vertex = mul(UNITY_MATRIX_MVP,v.vertex);
    
                    return o;
                }
    
                fixed4 frag(v2f IN):COLOR
                {                
                    fixed2 uvDir = normalize(IN.uv-fixed2(0.5,0.5));
                    fixed dis = distance(IN.uv,fixed2(0.5,0.5));
    
                    fixed2 uv = IN.uv+_WaveStrength*uvDir*sin(_Time.y*_TimeScale+dis*_WaveFactor);
                    return tex2D(_MainTex, uv);
                }
    
                ENDCG
            }
    
        } 
        FallBack "Diffuse"
    }
  • 相关阅读:
    MySQL经典面试题--SQL语句
    awk命令
    mysql安装配置
    notepad++使用
    Xshell使用
    说明
    对 MMO 游戏的调研
    对 VR 项目开发流程的调研
    对 Unity 动态加载资源的调研
    对 Unity 太空射击游戏的实践
  • 原文地址:https://www.cnblogs.com/mrblue/p/7651714.html
Copyright © 2011-2022 走看看