the Earth was without form and void. Then we started messing around in the UDK Editor, and there was light, terrain, rivers, smoke and cottages.

This is the first actual development post of our awesome  blog. So where to start? What are we doing? Starting out from scratch in this huge system is quite an undertaking, but the will is strong and the results are starting to appear. As indicated, we’ve messed around with terrain, light, materials (river), particles (smoke) and importing content from 3d Studio Max(cottages). This post will tell the epic tale of how we conquered the material editor.

To familiarize ourselves with UDKs material editor we could have started out by creating a boring brick material or something equally unchallenging. However, since we are fearless on the battlefield of game development (and sandwich making) we started out the hard way; by creating a dynamically reflected smooth-moving river with “realistic” physical properties. So..how to create a flowing river? The first challenge was to create the actual geometry for the river surface. UDK features a toolset for creating geometry using CSG. When used to polygonal modeling this approach is a little bit weird, and the results were therefore accordingly weird. The problem here was that we wanted the flow of the river to move along a path, and not in a single direction in world-space (which would look stupid).  To do this we created a so-called BSP “brush” which consisted of several surface all together resembling a river surface. Each of these surfaces should be somewhat square and together create a curved river geometry, and have perfectly  squared out UV-coordinates (0.0, 0.1, 1.0, 1.1). Such a scheme allows a texture map placed on the river geometry to  be seamlessly moving along the U-axis, and creating a “flowing” illusion. The problem we encountered was that we didn’t manage to force the UV-coordinates to be square on a non-square surface. Things were looking grim, but in the horizon shone a beacon of hope and justice (apart from their legal team): 3d Studio Max.

Our unmatched 3d Studio Max powers™ prevailed, and a river mesh was created in minutes, leading to massive guitar wailings, boner raging and democracy in several small African countries. With  geometry in hand we went on to conquer the material editor. Having a little experience with water materials we knew what we were looking for, but many hours were spent praying to the unholy UDK before our prayers were heard. The screenshot below outlines the basic river material.

The material graph for the river

As the node count indicates, the final material is quite complex. Luckily UDK provides these nice grouping tools making it pretty easy to stay in control of the overall result. The final material has four major groups: Normal, Distortion, Opacity and Reflections. Real-time reflection in water has become ubiquitous in recent games, and UDK makes it really easy to create this effect. Simply place a “SceneCaptureReflectActor” in the world to indicate the plane of the reflected surface, hook this up to a TextureRenderTarget, and BAM!…instant reflections. Some of the other groups are pretty trivial: The normal group samples a couple of  normal maps, and combine them. When sampling the normals we create directed flow in the river by panning them along the U-axis. The distortion group simply desaturates the sampled normal and scales it up a little bit.  The opacity group was the most challenging. We wanted the river to appear a little transparent along the edges, as well as having increased transparency when the angle between the camera and the river geometry’s normal is small. To summarize many hours of frustration, we did a dot product between the camera angle and a fixed normal pointing straight up and combined this with a fresnel operation.

As seen in the screenshot below, our efforts were rewarded with a nice looking river. The keen eye may spot a terrain, some cottages, a little smoke and a…uh robot thingy. More on this later.

I like river

Keep on wailing!