I have been working on creating rivers and lakes in code and run into a problem. Lakes work great but whenever i flag something as a River with the .lake bool, the water texture looks really bad. I am sure there is a setting in either the MeshBase or the Water Mesh or Water Mtrl that i am just not setting but i have looked everywhere and cant find it.
If you could just let me know what i am not setting, that would help. Here is a video showing the problem.
Hi!
I haven't seen the video, but:
For Rivers (unlike Lakes) you need to manually set the texture coordinates for the vertexes.
Something like x=0 for left side, x=1 for right side, and continuously increase Y along the river direction, should do the trick.
I knew it would be something like that. Unfortunately, i have no idea what that means. I checked Meshbase and the water classes but don't see anything that mentions setting texture coordinates. Any extra hint would be much appreciated.
Ahh, i see what you are saying now, the Tutorial helped me put the pieces together.
I would love to see the code you use to assign the texture coords when a user is creating a river in the editor. Same kind of goes for how you determine the best mix of Triangles and Quads for Rivers and Lakes. Even pseudo code would help.
Either way, thanks for the help, i understand it much better now.
So i got this to work for rivers (thanks for the tip about the text coords). I would love to give the user the ability to add additional points to a river or lake but i can't figure out a way to do that without implementing a full on Delaunay Triangulation algorithm. Since you do it in the editor so easily, i have to assume it is something the engine already has in it. Is that process exposed in any way in the engine? If not, i understand, but just thought i would ask. I feel like building they from scratch would be overkill.
// convert mesh 2D to 3D
REP(Min(8, smooth))mesh.subdivideEdge();
mesh.inflateEdges(true, false);
mesh.quadToTri (0.9993 ); // convert quads to tris because not flat rivers can have quads built of 2 non-coplanar tris
mesh.texScale (tex_scale );
REPA(mesh.vtx)Swap(mesh.vtx.pos(i).y, mesh.vtx.pos(i).z);