Hi!

I'm working on a flowing river shader for my game Fortifend, but I can't quite figure out how to get it working the way I'd like. Maybe someone here has some shader insights/techniques that can help me!

The water flow shader is applied to a procedurally generated triangular mesh. Vertex color is used to pass flow vector and foam (water turbulence) into the shader. The vertices of each tri all have the same flow vector, but they have independent foam values.

The shader rotates the texture UV into alignment with the flow direction, and scrolls the waves in that direction. Naturally, this means that there is a visible seam between any two adjacent tris that don't have the same flow vector. Doesn't look half bad when zoomed out, but noticeably distracting close up.

I'm looking for possible solutions to this.

Is there a solution that involves setting each vertex within a tri to its own independent flow vector? For example, if I set each vertex within a tri to its own independent flow vector (for the purpose of blending the 3 flows), is there some way to pass all 3 vertex flow vectors from the vertex shader to the fragment shader? (Plus how much "influence" each vertex should have over the blend.)

Megalomaniak

I'm aware of that technique, that's essentially what I was trying to do. I initially wanted to rely on the color channels of the mesh vertices instead of sampling from a flow texture for (possibly silly) technical reasons specific to my project.

In the end, it turned out to be easier to just sample the flow vector from a texture:

    steelyglint In the end, it turned out to be easier to just sample the flow vector from a texture

    Yes, vertex colors would have worked if you didn't need to split the mesh for hard edges or UV islands. What I can't tell from the image in OP is if you needed to do one, the other or both.

      That looks like a super pretty game! Love the style. Are you sure you don't need to just blend the cells together?

        Megalomaniak
        I could make it look good using vertex colors, but not when the waves were in motion. I needed the ability to phase out the influence of a particular vertex as the pixel being rendered got father away (within the context of the fragment shader), and I still don't know how to do that. Here's what it looks like in motion using flow fields sampled from a texture:

        Erich_L
        Thanks! I wanted to blend the cells, but I couldn't figure out how to do it with just the mesh vertex colors. (So I went down a different path).