Tweaking The Waterfall Visuals

Tweaking Waterfall Visual Aspect Example

What we'll cover on this page?

Waterfall Body Properties

Tweaking Waterfall Body Color And Texture In The Waterfall Material Inspector

Body Color

Waterfall Material Color Properties

We can set the waterfall body color to either a Solid Color or a Gradient Color. If we choose to use a Gradient Color, the Gradient Offset property controls how much to shift the gradient-line midpoint position (where the middle of the color transition should be).

Info

The Gradient Offset property range: -0.5 → 0.5

Body Textures

Waterfall Material Texture Properties

We could apply up to 2 textures (main and secondary) across the waterfall body.

Warning

The texture should have its wrap-mode set to Repeat or Mirror in the texture import settings.

By toggling the Alpha Cutoff property on and tweaking the cutoff value, any pixels with the alpha value below the cutoff threshold will be considered invisible.

Example

Waterfall Material Body Alpha Cutout example

Body Texture Sheet Properties

The main or the secondary texture could be a regular texture, or a texture-sheet (a texture consisting of many frames) by toggling the Is A Texture Sheet property on, and then specifying the number of columns and rows and also setting how many frames to play per second.

Body Texture Opacity

The Opacity property controls the visibility of the texture.

Body Texture Scrolling Speed

We can make the texture scroll vertically by tweaking the Scrolling Speed property.

Body Texture Tiling Mode

Regarding the texture tiling properties, there are two tiling modes:

  • Stretch: The texture stretches when the waterfall object size changes, always keeping the same number of tiles we specify for the X and Y directions.

    Texture Stretch Tiling Mode Properties

  • Repeat: The texture repeats when the waterfall object size changes. In this mode, we specify the scale in units of a single tile.

    Texture Repeat Tiling Mode Properties

Body Texture Offset

We can provide a texture offset regardless of the selected texture Tiling Mode.

Body Texture Distortion Effect

Waterfall Material Distortion Effect

Distortion Scale - Offset

The Mathf.PerlinNoise(x,y) function is used to sample the Perlin noise texture values. The Scale and Offset properties controls the sampled area size and origin, respectively.

Warning

The Scale And Offset properties are used to generate the noise texture (which actually happens only in the editor), and as such they are not animatable.

Distortion Strength

The Strength property, as the name suggests, controls how strong the distortion effect is.

Distortion Speed

The Speed property controls the noise texture scrolling speed.

Distortion Tiling

The Tiling property controls the scale of a texture noise texture tile relative to a waterfall body texture tile.

Example

A value of 0.5, for both the X and Y axis, will apply the noise texture across 4 waterfall body texture tiles.

Distortion Tiling Property Example

Tip

We can use the Tiling property to lower the distortion strength across one axis, and keep the full strength across the other.

Waterfall Left-Right Edges Properties

Waterfall Material Left Right Edges Properties

Left-Right Edges Thickness And Offset

Waterfall Material Left Right Edges Thickness

The thickness and offset of the left and right edges can be set to absolute fixed values (specified in Unity units), or values that are relative to the width of the waterfall object (specified in the 0..1 range).

Left-Right Edges Texture(s)

Waterfall Material Left Right Edges Same Texture Properties

We can use two different textures for the left and right edges, or we can simply use the same texture for both edges by toggling the Use Same Texture property on.

In case we decided to use the same texture, the Flip Texture property controls whether or not we want to flip the texture when it gets applied across the specified edge horizontally.

By toggling the Alpha Cutoff property on and tweaking the cutoff value, any pixels with the alpha value below the cutoff threshold will be considered invisible. This might be useful if we would like to add some irregularities to the left and the right edges.

Example

Waterfall Material Left Right Edges Alpha Cutout example

The description of the left-right edges texture(s) properties is the same as the waterfall body texture properties, as discussed here.

Waterfall Top-Bottom Edges Properties

Waterfall Material Top Bottom Edges Properties

Top-Bottom Edges Thickness And Offset

Waterfall Material Top Bottom Edges Thickness

The thickness and offset of the top and bottom edges can be set to absolute fixed values (specified in Unity units), or values that are relative to the height of the waterfall object (specified in the 0..1 range).

Top-Bottom Edges Texture(s)

Waterfall Material Top Bottom Edges Properties

We can use two different textures for the top and bottom edges, or we can simply use the same texture for both edges by toggling the Use Same Texture property on.

In case we decided to use the same texture, the Flip Texture property controls whether or not we want to flip the texture when it gets applied across the specified edge vertically.

The description of the top-bottom edges texture(s) properties is the same as the waterfall body texture properties, as discussed here.

Waterfall Refraction Effect

Under the Refraction Properties in the waterfall material inspector, we set the refraction effect distortion properties.

Waterfall Material Refraction Effect Properties

The refraction distortion properties description is the same as the waterfall body distortion effect properties, discussed here.

Waterfall Refraction Layers

Under the Refraction Properties in the waterfall component inspector, we use the Objects To Render property to select which layers to include in the refraction rendering.

Waterfall Component Refraction Effect Properties

Script Reference

1
waterfallObject.RenderingModule.Refraction.CullingMask = LayerMask.GetMask("Default", "TransparentFX");

Waterfall Refraction Render-Texture Properties

If the Use Fixed Size property is toggled on, the Size property sets the refraction render-texture width and height.

Use Refraction Render-Texture Fixed Size

Script Reference

1
2
waterfallObject.RenderingModule.Refraction.RenderTextureUseFixedSize = true;
waterfallObject.RenderingModule.Refraction.RenderTextureFixedSize = 512;

But, if the Use Fixed Size property is toggled off, the refraction render-texture will have a dynamic size, and the render-texture width and height are in this case equal to the the waterfall object visible area on screen width and height. We can even downscale this computed size by lowering the Resizing Factor property value.

Use Refraction Render-Texture Dynamic Size

Script Reference

1
2
waterfallObject.RenderingModule.Refraction.RenderTextureUseFixedSize = false;
waterfallObject.RenderingModule.Refraction.RenderTextureResizingFactor = 0.75f;

Lastly, We can set the refraction render-texture Filter Mode property to either Bilinear or Point.

Script Reference

1
waterfallObject.RenderingModule.Refraction.RenderTextureFilterMode = FilterMode.Bilinear;

Rendering Properties

Rendering Properties - Material Inspector

Waterfall Material Rendering Properties

Under the Rendering Options in the waterfall material inspector, the Mask Interaction property controls how the waterfall object behaves when interacting with a Sprite Mask or with the Mesh Mask. We can set the mask interaction to one of the following options:

  • None : No interaction
  • Visible Inside Mask : the waterfall is visible where the Sprite Mask or the Mesh Mask overlays it, but not outside of it.
  • Visible Outside Mask : the waterfall is visible outside the Sprite Mask or the Mesh Mask, but not inside it.

The Apply Tint Color(s) On Top Of Texture(s) property controls in which order the tint colors and textures are applied. If this property is toggled on, the textures are applied first and the tint colors are applied second, otherwise textures are applied last.

Rendering Properties - Component Inspector

Waterfall Component Rendering Properties

Under the Rendering Properties in the waterfall component inspector, the Far Clip Plane property sets the furthest point relative to the waterfall object position that gets included in the refraction rendering.

The Render Pixel Lights property controls whether or not the rendered objects are affected by pixel lights.

Info

The Render Pixel Lights property is ignored when working with the URP/LWRP.

We can also activate/deactivate the High Dynamic Range (HDR) and the Multisample Anti-Aliasing (MSAA) rendering.

Info

The MSAA rendering is activated only if the Antialiasing is enabled in the project quality settings or in the URP/LWRP settings asset.

Script Reference

1
2
3
4
waterfallObject.RenderingModule.FarClipPlane = 10f;
waterfallObject.RenderingModule.RenderPixelLights = true;
waterfallObject.RenderingModule.AllowMSAA = false;
waterfallObject.RenderingModule.AllowHDR = false;

Note

The Sorting Properties and the Mesh Mask Properties are discussed in the Getting Started section of this guide.