4
\$\begingroup\$

How would I go about creating a river with rushing water? I can do the texture around it but I'm stuck on the actual water part. This is in Unity3D.

\$\endgroup\$
1
  • 4
    \$\begingroup\$ What aspect(s) of a river with rushing water do you want to "create?" A moving semi-transparent texture? Or an actual simulation of water running across terrain? Does it need to dynamically flow? Or is it static and just needs to look convincing? \$\endgroup\$ Commented Jan 17, 2013 at 17:05

2 Answers 2

4
\$\begingroup\$

A) First thing you need is River bed mesh You need to create a river mesh by using 3D editing software, like Blender, Maya. If you want to do this in unity you will not get best tools but there many tools available on unity asset store, that provide creating meshes in Unity for example "Easyroads", Mesh toolkit, Prototype.

B) Second you need to create a flow map. which you can create by using free tool "Flowmap painter", Its free to use. If you are artist you can do it in Photoshop.

The purpose of this flow map is to alter the water normal map.

C) Then you need to write the shader, if you are a artist you always go and buy “Flow” on unity asset store, 20$, this will do all the programming work for you.

For programmers, we need to change water normal map, so we need to take texture coordinates of the current water pixel and offset. it using the flow vector from the flow map based on time offset.

To get real effect you need to create 2 or more waves with half time cycle offset. This will create the flowing water.

    float2 flowmap = tex2D( FlowMapFile, texFirst ).rg * 2.0f - 1.0f;

    float waveFirst = FlowMapOffsetFirst;
    float waveSecond = FlowMapOffsetSecond;
    float3 normalFirst = tex2D(WaveMapFirst, ( texFirst * TexScale ) + flowmap * waveFirst );
    float3 normalSecond = tex2D(WaveMapSecond, ( texSecond * TexScale ) + flowmap * waveSecond );
    float flowDelta = ( abs( HalfCycle - FlowMapOffsetFirst ) / HalfCycle );
    float3 offset = lerp( normalFirst, normalSecond, flowDelta );

Here is the Github source code link for learning flow shaders: https://github.com/TarasOsiris/unity3d-shaders-learning/tree/master/shaders-proj/Assets/MyExperiments/FlowMaps/Shaders

D) Last not the least you will need to add Real time refraction for that you will need Unity Pro.

For water reflection and refraction follow this: https://en.wikibooks.org/wiki/Cg_Programming/Unity/Water_Reflection_and_Refraction

\$\endgroup\$
1
\$\begingroup\$

i dont know unity, but I normally create a model of a river, unwrap it and add a texture then offset its uv coordinates within its shader.

this might help: http://answers.unity3d.com/questions/19848/making-textures-scroll-animate-textures.html

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .