Pages

Tuesday, 19 November 2013

Creating water in UDK - BA7



Studio Research
(River in UDK) This river uses something similar to what I wish to create however the river is too clean looking for my design. The ambient sounds at the beginning are somewhat similar or close to what I want to put into my video render for the final scene.
UDK: Getting started with UDK

  • Whilst reading the ‘Getting Started: Unreal Engine 3’ document I read this and found it of interest; Planning and Preproduction
  • Before production begins, in fact before you even decide Unreal Engine is the right fit for your game, there are some important aspects to go over and sort out in order to avoid any gotchas down the line.
  • What features required by your game are supported by Unreal Engine 3?
  • Do Unreal Engine 3's minimum specifications fit your target market?
  •  Do you have enough and sufficiently skilled workers to meet your release schedule?
  • Does the content pipeline for Unreal Engine 3 suit your needs?
  •   What legal guidelines will need to be followed?
  • What support outlets does Epic provide for Unreal Engine 3?


Although some of these outline don’t necessarily fit to my needs or requirements they’re still quite important to know.
(Another extract from ‘Getting started’ documents)
A standard workflow for developing a level might go something like:

  •  Block out and path a level
  • Playtest flow and gameplay
  •  Modify layout and repeat testing
  •   Initial meshing pass
  •  Initial lighting pass
  •  Playtest for collision and performance issues
  •  Polish pass

Whilst looking on Google at various water flow systems I stumbled upon a very kind user on the  ‘Epic Games’ forums that has created a water flow tutorial document for UDK. Although it explains a various amount in detail I didn’t find it sufficient enough to create a water system.

 
Creating a simple water plane



Chatting with a friend of mine he helped me get to a basic plane water texture into UDK. I first made a plane in Maya, exported it as an FBX and then imported it into UDK. From here I scaled it to a decent size and searched for a water texture in the UDK content browser: M_UN_Liquid_BSPInsert. This is the result of doing so. It’s not at the current level or fine customisation I want it but it’s a start.


Added rocks pre-build in the content browser


Test of a few water materials

Although it’s a simple process it doesn’t possess the quality that I desire for my scene.


Finding the right tutorial
Speaking to my tutor Lothar Zhou he found a tutorial on how to create a water material in UDK. Looking at the tutorial seemed like it was the right way to go and if honest the node network seemed very confusing but still I wanted to follow it and learn.
First off was make a 1024x1024 plane in Maya sub-divided into 10x10, from here I then exported it as an FBX file.
After doing this I opened up UDK, created a new package, called it Water_test and added the files from the tutorial as well as creating a new material.

After doing this I then did the most vital step and saved.


Now, in the content browser I selected ‘Actor Classes’. Under the heading ‘Uncategorised’ I dragged into the scene ‘SceneCaptureCubeMapActor’. One dragged across it will look something like this:

I then changed the view mode of the sphere to SceneCapView_Lit as well changing the far plane to a greater number and enabling Post Process as well as Enabling Fog.


Next step is to right click in the content browser in an empty space and add ‘TextureRenderTargetCube’.



After this I then plugged the ‘TextureRenderTargetCube to the ‘SceneCaptureCubeMapActor’.
Now I right clicked on ‘TextureRenderTargetCube’ and click on ‘Create new static texture’.


After this process was finish I was left with reflection maps


Next step is main final step; creating the node network for the water material.
There won’t be a step by step of all the nodes but rather a screenshot of each section that is needed for the water material, at the end of this tutorial there will be a list of nodes used and a brief explanation of what each one does.



Diffuse


Normal





Specular

Bubbles


World displacement

Next step was to press the green button for the network to be applied to the material, doing so I then dragged and dropped the FBX plane file into UDK and then the water material on top of it, this is the result:


Then to demonstrate how the bubble node system looks when in contact with other objects I dragged in a rock that is pre-built within the engine:



The world displacement node works from a pattern and in turn creates waves, here’s a screenshot to show this:

Video


After fiddling with some of the settings and diffuse texture I made the texture to more of a murky green to better match the river near my university and took the displacement network off. I also repeated the water several times to try and make the ripples smaller, overall the water needs more tweaking to get the desired look for my river. 




This entire project wasn't without it's faults and errors. Through out most of the progress I ran into errors such as UDK constantly crashing or missing the right nodes in order to complete the network. All of these errors made it difficult for me to proceed but with perseverance and determination I managed to get it to work. The one thing that I got out of it crashing constantly or putting out errors is that I learned why these errors happened and learned the nodes that were needed to create the water material.

The nodes used in the network for the water system

Multiply – this simply put multiplies two nodes together, input1 x input2.

Constant – this is the more commonly used node and can be connected to any of the options with a material, it sets a constant colour to what it’s connected to, for instance you could connect it to a multiply and therefore multiplying a single colour with another node

Constant3Vector – in a nutshell this enables the RGB channel to be constant. You input a colour for Red, a colour for Blue and finally a colour for Green and you’ll get a mix of all three, this then can be connected to say an ‘Add’ node. 

Texture Sample – this is the texture that is normally in the content browser either in your custom package or with the engines library. This can then be linked to different options with the materiel, normally you would connect to the ‘Diffuse’ option on the material.

Rotator – this node outputs UV texture coordinates, this then can allow the texture to have a more natural flow.

Texture Coordinate – this node allows a way of outputting UV coordinates for what you want the texture to be, for example if you wanted a section of the texture to show through on an object in game then you could plug in coordinates for the texture to show only a section you want.

Panner – this node gives the option for UV texture coordinates for panning or moving textures.
Time – this is what it sounds like except it gives the option for the UV texture coordinates to move 
over time.

DepthBiasedAlpha – this more specifically to my project helped to cut down the sharpness of the edges around the bubble texture and other textures used. This node is also most commonly used on sprite particles removing the sharp edges.

Lerp – this node is short for LinearInterpolate, the node can perform a blend between textures

ScalarParameter– this will show up as a Param ‘BubbleTiles’ (10), (10) being the constant colour. The ScalarParameter expression outputs a single float value (Constant) that can be accessed and changed in an instance of the material or on the fly by code

ComponentMask – for my project I used a ‘Mask (r)’ node to make sure that the red input value was passed through the output. This node allows either or all 4 of the Red, Green, Blue or Alpha channels to be passed through the output of the node. So if you have a texture sample with stripes that are Red, Green and Blue you could set it so the Red channel with only pass through.

Subtract – the subtract node has two inputs, from here it will take away the second input away from the first allowing you two use two textures and subtract different parts accordingly.

Add – this node has two inputs, for example if you take to different ‘Texture Samples’ and input them into the ‘Add’ node you can then combine the two together and add them to the ‘Diffuse’ option on the material.

Clamp – the clamp node constrains to a value set by the user. If the ‘min’ input was 0.0 and the ‘max’ input was 1.0 then it would never go below 0.0 and never above 1.0

Constant Clamp – this has the same function as the ‘Clamp’ node but has the properties for the ‘min’ and ‘max’ values within the node itself

Camera World Position – this is as it sounds, this species the cameras position in the world space

Reflection Vector – this uses similar traits to the ‘CameraVector’ node in which is represents the 
direction of the camera with respect to the surface, which in this case is the reflected surface across the normal.

Fresnel - The Fresnel expression calculates a falloff based on the dot product of the surface normal and the direction to the camera

No comments:

Post a Comment