Shader "Unlit/GerstnerWave"
{
Properties
{
_MainTex ("Texture", 2D) = "black" {}
// example 1(1个波的高度y)
/*
_GAmplitude ("Wave Amplitude", float) = 0.3
_GFrequency ("Wave Frequency", float) = 1.3
_GSteepness ("Wave Steepness", float) = 1.0
_GSpeed ("Wave Speed", float) = 1.2
_GDirection ("Wave Direction", Vector) = (0.3 ,0.85, 0.85, 0.25)
*/
// example 2 (4个波合成的高度y)
/*
_GAmplitude ("Wave Amplitude", Vector) = (0.3 ,0.35, 0.25, 0.25)
_GFrequency ("Wave Frequency", Vector) = (1.3, 1.35, 1.25, 1.25)
_GSteepness ("Wave Steepness", Vector) = (1.0, 1.0, 1.0, 1.0)
_GSpeed ("Wave Speed", Vector) = (1.2, 1.375, 1.1, 1.5)
_GDirectionAB ("Wave Direction", Vector) = (0.3 ,0.85, 0.85, 0.25)
_GDirectionCD ("Wave Direction", Vector) = (0.1 ,0.9, 0.5, 0.5)
*/
_GAmplitude ("Wave Amplitude", Vector) = (0.3 ,0.35, 0.25, 0.25)
_GFrequency ("Wave Frequency", Vector) = (1.3, 1.35, 1.25, 1.25)
_GSteepness ("Wave Steepness", Vector) = (1.0, 1.0, 1.0, 1.0)
_GSpeed ("Wave Speed", Vector) = (1.2, 1.375, 1.1, 1.5)
_GDirectionAB ("Wave Direction", Vector) = (0.3 ,0.85, 0.85, 0.25)
_GDirectionCD ("Wave Direction", Vector) = (0.1 ,0.9, 0.5, 0.5)
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
sampler2D _MainTex;
float4 _MainTex_ST;
// example 1 (1个波的高度y)
/*
float _GAmplitude;
float _GFrequency;
float _GSteepness;
float _GSpeed;
Vector _GDirection;
*/
// example 2 (4个波合成的高度y)
/*
floa
Unity Shader Example 15 (Gerstner Wave)
最新推荐文章于 2024-08-26 08:23:58 发布
本文介绍了使用Unity进行3D水波模拟的Gerstner波方法,详细解析了公式和代码实现,包括波浪方向、振幅、陡峭度等因素对水面效果的影响,并提到了批处理静态设置对游戏运行的影响。
摘要由CSDN通过智能技术生成