After wrapping up the first formative hand-in I decided to dedicate the second project to learning Houdini, or well, getting started learning it. Fortunately since I am familiar with node-based tools working with it is quite intuitive, as well as using Houdini's scripting language VEX, since it is really close to C/C++, which I have used in the past.Topic of my second brief will be destruction.
1 - Crate Generator 1.0 and 2.0
As my first destructible object I wanted to have some crates and started building a procedural generator in Houdini and created Version 1.0, which was mainly for getting used to Houdini's workflow. The only difference to Version 2.0 is, that I added the option to bevel the edges and fixed the Normals afterwards. I discarded that feature to reduce the tri-count. It also lacks the variation I added to Version 2.0, since I used "Copy" instead of "Copy Stamp".
Crate Generator 1.0
Well,I wasn't too happy with the result, as again the elements lacked variation (scale, rotation etc). So I decided to get more familiar with the "Copy Stamp" which in my case uses Points to determine copy locations. I ended up generating the point locations for the planks and posts via Code in "Attribute Wrangle" nodes and since I wanted to learn VEX I put everything into algorithms instead of manually defining locations. Once I know more about VEX I'll probably go back and optimise the code.
Corner Posts:
VEX Corner Locations
With this you can also change whether those corner posts are supposed to be on the inside of the corners or not.
Changing Corner Location
I also ended up procedurally selecting the top faces so I could add some Variation to their width.
Grouping Top Faces
Corner Post Nodes
Plank Locations:
I divided the Planks into Front and Side Planks, but I might combine once I have figured out transformation matrices.
Otherwise the code is almost identical. Basically the number of planks gets calculated based on plank width, distance between planks and crate height. Then by using the for-each metadata I can add random rotation to the planks.
Front Plank Locations VEX
Side Plank Locations VEX
Planks Node Setup
And here the code in action:
Planks Location
Small Support Posts:
I also wanted the option to have some smaller posts on the inside of the crate. Here I created the positions in one go, because orientation wasn't an issue. In this case you can change the amount of posts and based on that the gaps in between them gets calculated.
Small Post Location VEX
Small Post Location
Now throwing all those elements together results in the following crate generator.
Also for creating a destructible version I made a fractured version of the crate, Fracture Amount is tied to a Parameter.
Fracture
The node network itself is fairly simple and looks like this.
And that's it for now
Of course I then moved on to bringing those boxes into Unreal to see how they'd work as destructible Meshes. One problem I ran into is, that we currently do not have the Houdini Engine Version an Uni, so Houdini files can't be imported into Unreal, which gets rid of the whole procedural Factor, but apparently that is in work, so I might be able to do this towards the end of this project.
Also Unreal 4.21 seems to have a bug in the Destructible Meshes and the inside of the generated Chunks doesn't get a second Material ID assigned. I tried doing it manually to the fractured mesh, but on importing it Unreal doesn't consider the IDs.
Nevertheless, here is a video of how it currently looks.
Since the first hand-in date is this Friday, I am currenty wrapping up the project for now. There are still changes and improvements I want to make, but I will focus on that, when I have time for polishing.
1 - Shore interaction
Since I still had some time left, I decided to add water interaction to my object master material. The rocks and also the landscape now have a waterline and/or foam on it, depending on the water height.
I made another version of the Water Master Material, where I exchanged the Gerstner Wave Parameters for a parameter collection, so I can use the same parameters across multiple Materials. In the Material it ended up looking like this:
Overview Opaque Master Material
Waterline/Foam Logic
It works by calculating the water height compared to the object in Worldspace and then masking out the area underwater or for the foam a "band".
This is how the effect ended up looking in the level:
Shore Interaction
Of course this solution is far from perfect, however now the water doesn't feel quite as cut off from the environment anymore.
Also a nice effect, even though it was actually accidental: as the shore/object surface angle to the water is getting steeper it looks like the foam is running down the surface quicker.
2 - Water Material Changes
After putting the water in the level I noticed, that the normals started looking very weird in the distance, so I added some extra logic in the material to blend to flat Normals in the Distance. I used the same for specularity, so now the water reflects the sky more in the distance.
2 - Environment
I ended up not using the sand and cliff texture I made in week 2, as I got better results just layering the rocks I sculpted. Instead of the sand I made a very quick and simple gravel texture, resolution is 512 by 512.
Gravel Texture
As for the environment here is an overview of the general setup.
And here are a few views from the playable area.
3 - Reflection and future improvements
Overall I am very happy with the outcome of this project and I feel like I learned a great deal whilst working on it. For example it was the first time using render targets and I now feel like I got a better understanding of how they can be used to create dynamic effects.
1) INTERACTIVE WATER:I would like to change the interactive water part to essentially follow the player, so that it works no matter where the player is with the same Scene Capture. At the moment it only covers a 20 by 20 meter area. I actually build a version, where the scene capture followed the player, however it affected the ripples produced by other objects in a weird way, changing their direction.
Also objects moving slowly produce very quick ripples, which is unrealistic. Since the ripple logic was not made by me and I spend most of my time on this project creating the water shader and environment I would like to see if I can change the math behind the ripples to improve the effect.
Additionally I would like to maybe add buoyancy to objects and slow them down, when they enter the water.
2) DAY/NIGHT CYCLE
Since ended up linking the sun position for the reflections in my water material to the directional light, I would like to add a day night cycle to the environment, to better show of the effect and also extend it to also add moon reflections.
4 - Resources used
To create the water effect I used some textures included in Unreal Engine's Starter and Engine Content. These are the following:
T_Detail_Rocky_N
T_Ground_Grass_N
water_d
I reduced the texture size of those to 512 to fit the texture budget constraints.
Just as a notice to myself, I will update this post at a later day, since it is way to late right now, but I want to get this out of the way.
1 - All Water Things
I spent the beginning of the week finishing and organizing my water master material. This is, how it looks overall.
Water Master Material
I added quite a few features to improve the overall looks of it, as well as some more interactive things. For example I added the option to add foam both on the wave peaks, as well as based on distance fields. I'll go more into detail about those at a later point.
I also tied the Sun Reflections to the Directional Light Source in the Level by approximating a sun location based on the inverted forward vector, so when updating it's rotation and updating the default sky, the reflections on the water match the sun position. So now a day/night cycle would be possible.
Sun Position Approximation
Sunset/ Sunrise
Midday Sun
Additionally I made a Caustics Material Function. I simply used an inverted Voronoi Noise Texture and then offset them slightly to create a chromatic abberation effect. I also found out, that Blend_Darken gives a really nice effect, compared to just adding the panner outputs.
MF_Caustics
To further add to the interactive part I now also added a particle effect, by checking vertical velocity, when objects overlap with the water surface and then creating the particle system at the point of impact, also offsetting it slightly based on the object's horizontal velocity. I created the water droplet textures in Substance Designer.
Particle_Material
Water Surface Blueprint
Here is an overview of some of the interactive features, including particle splash and caustics.
2 - Grass Originally I had planned to have a look at Pivot Painter to create some better foliage interaction and visuals. Due to time constraints I ended up not doing it and postponing it to a later project. I kept the grass shader fairly simple, however I decided to create my own wind material functions since I didn't really like the look of Unreal's SimpleGrassWind. I am still not a hundred percent happy with the outcome and might tweek it later, but I believe I achieved a more organic feel.
Wind Function Overview
I ended up layering multiple sine curves moving across world space, which is very similar to how the Gerstner Waves work, but simplified, and used a panning noise texture to further break it up. That way however, I can define multiple wind directions, rotate them and add a bit of variation to the foliage instances.
Sine Waves
I furthermore also included Player and Object interaction in the function, just for convenience. For Objects I simply use distance field gradients and for the player the distance between Player and World Position multiplied by a sphere mask.
Interaction
So this is how it ended up looking:
Custom Grass Wind Function
Grass Distance Field Interaction
3 - Random Things Aside from these things, I build a quick master material for any other objects, trying to keep it quite flexible to reduce the amount of individual materials I need. It includes features, like Vertex Painting, individual UVs or adding moss/snow.
Master Material
I also made some textures in Substance Designer, but now I am not quite sure anymore, if I need to use all of them, if I like the look of them or if they work for my environment in general.
Moss, Rock Cliff, Sand Materials
I also did some quick sculpts of rocks and textured them in Substance Painter.
Rocks
Both the material textures, as well as the rock textures ( 1 for 2 rocks ) are 512 by 512 px.
4 - Environment After avoiding to start the environment I finally went ahead with it and started working on it. I decided to go for a rocky beach/bay. Since there is not much yet, here an overview of the current progress.
As my first project for Year 3 I chose to work on the Water VFX Brief. My goal is to create an interactive water shader for a small stylized Environment. I spend my first week mainly on creating the water shader and made relatively good progress, but I still need to add some more features, like depth-based changes and distance field interaction.
I initially struggled a bit with implementing the normals, but after figuring out, that I forgot to add World Position to the x and y Offset, it ended up working.
Gerstner Wave Normals
Since I knew, that I had to layer quite a few of those Gerstner Waves, to create a believable, and not too obviously tiling water surface, I made a quick function to combine 4 Waves.
Combined Gerstner Waves
Lastly, I did not particularely like the look of the water, when just using UE4's specular Reflections and wanted to get a strong sun glitter on the water.
Water with standard UE4 specular reflections
I did some research into computing specular reflection and settled on a simplified Phong model to achieve that, since it was relatively easy to understand and implement and delivered good results for my purposes. At the moment it works by defining a sun position, but I want to change it to approximating a sun position based on the directional light source, then it could also be easily used for a day/night cycle, etc. The output goes into the Emissive input of the Material.
Sunlight Reflection
I was really happy with the outcome, since just adding this simple function added a lot of believability to the water shader. Here are the results for a low and a high sun position:
Low Sun Position
High Sun Position
An additional Benefit of calculating specular reflections was, that I could use the Reflection Vector to add some fake Subsurface Scattering to the water. Of course the SSS is not accurate, since it doesn't account for refraction or similar things, but it adds a bit of variation to the water.
Faked Subsurface Scatter
2 - Water Master Material
Whilst working on all those Material Functions I also started working on the Water Master Material. It is essentially a combination of the Material Functions and some additional other features. Basically everything is parametrized, so anything like water color, wave height, speed, direction, etc can be changed. Here is an overview of what I got so far, I still want to change it quite a bit and add more features, like foam, depth based changes, etc.
Water Master Material
2 - Interactive Ripples
The last thing I worked on this week, was adding interactive ripples to the water. A while ago I found an interesting video by Coding Train about creating interactive ripples and he linked the following website: https://web.archive.org/web/20160418004149/http://freespace.virgin.net/hugo.elias/graphics/x_water.htm . This is where I learned about using multiple render targets to create effects like this. One problem however was, that the resulting ripples had no Normals. After some research I found a tutorial in the Unreal Documentation called "Creating a fluid surface with Blueprints and Render Targets" (https://docs.unrealengine.com/en-US/Engine/Rendering/RenderTargets/BlueprintRenderTargets/HowTo/FluidSurface/index.html) and since their setup was very similar I could use their material for creating the normals. Something they added, which I hadn't considered, was making the effect framerate independent, which I thought was really interesting, so I added that to by blueprint. The big problem with both was, that they receive location input through mouse interaction to apply force at a specific location. So essentially it only works for one actor at a time. After some thinking I decided to use a Scene Capture Component to render the objects, I want the water to interact with, to Custom Depth and then put it through a Spiral Blur Node to get soft edges. This way I also get different ripples depending on the object shape. One problem however was, that those objects then get always drawn to the Render Target and always produce ripples, even if they are not moving. My solution to this was checking for components overlapping the water surface and depending on their velocity enable or disable "Render to Custom Depth". The Ripple creation works in World Space.
This still needs some tweeking, especially figuring out a good offset for the Custom Depth, and there are a few things I want to change, but overall I am really happy with the result.
Write to persistant
Custom Depth Post Process for Scene Capture
Modified Blueprint to create Ripples
Here is, what the Ripples look like in action at the moment:
Next week I will start working on the environment, so I can also implement the shore interaction for the water material and translucency. I want to tackle creating larger scale water surfaces, as that will be necessary for an ocean and also add some particle effects, like splashes, etc.