Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions Waves/Assets/Waves.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,11 @@ public float GetHeight(Vector3 position)
+ (max - Vector3.Distance(p3, localPos))
+ (max - Vector3.Distance(p4, localPos) + Mathf.Epsilon);
//weighted sum
var height = Mesh.vertices[index(p1.x, p1.z)].y * (max - Vector3.Distance(p1, localPos))
+ Mesh.vertices[index(p2.x, p2.z)].y * (max - Vector3.Distance(p2, localPos))
+ Mesh.vertices[index(p3.x, p3.z)].y * (max - Vector3.Distance(p3, localPos))
+ Mesh.vertices[index(p4.x, p4.z)].y * (max - Vector3.Distance(p4, localPos));
var vertices = Mesh.vertices;
var height = vertices[index(p1.x, p1.z)].y * (max - Vector3.Distance(p1, localPos))
+ vertices[index(p2.x, p2.z)].y * (max - Vector3.Distance(p2, localPos))
+ vertices[index(p3.x, p3.z)].y * (max - Vector3.Distance(p3, localPos))
+ vertices[index(p4.x, p4.z)].y * (max - Vector3.Distance(p4, localPos));

//scale
return height * transform.lossyScale.y / dist;
Expand Down