Volumes Of Fun

My first Unreal Engine game (Work In Progress)
Page 1 of 1

Author:  mgumley [ Sun Oct 30, 2016 5:38 pm ]
Post subject:  My first Unreal Engine game (Work In Progress)

My first Unreal Engine game. Currently a work in progress. The terrain is generated randomly at runtime, and is almost endless, like Minecraft. I'm going to work on blending the transition between grass, dirt and stone.


Here's a list of software that I used to make it.

Unreal Engine 4.13


OceanProject (cascade256 4.13 fork)

https://bitbucket.org/volumesoffun/poly ... ch/develop

Vegetation Pack
https://forums.unrealengine.com/showthr ... tarter-Kit

Runtime Mesh Component
https://forums.unrealengine.com/showthr ... ted-meshes!

UE4 Tools Addon (for blender)

Author:  David Williams [ Mon Oct 31, 2016 8:29 pm ]
Post subject:  Re: My first Unreal Engine game (Work In Progress)

Looks very nice, and fast quick mesh updates :-) Material blending is quite challenging but I look forward to seeing how it works out!

Author:  petersvp [ Wed Mar 01, 2017 1:17 am ]
Post subject:  Re: My first Unreal Engine game (Work In Progress)

For Material Blending I already have a solution. I think I described it once in the Crafterria thread.

You know you can mix up to 4 materials per vertex.
What if we can, however, have different set of materials per triangle?
This is what I am doing in my projects. 4 Materials per triangle.

Each triangle need to have its own ID. The ID must be same for all vertices by the triangle.
This ID is used to lookup actual Material Indices from a lookup texture that is using integer format!

I've ended doing this because if Unity's limitations, however, you can basically encode 4 ids in a UV4 4-vector channel, however a Vertex Id and a lookup texture gives you basically A LOT of vertex attributes.

Triangle 1:
v1: pos, normal, tangent, color(blend factors RGBA), whatnot, uv2(1,2,5,6)
v2: pos, normal, tangent, color(blend factors RGBA), whatnot, uv2(1,2,5,6)
v3: pos, normal, tangent, color(blend factors RGBA), whatnot, uv2(1,2,5,6)

Then, in the pixel shader, you do your usual texture splatting and triplanar texturing,
but use the IDs that will NOT be interpolated to select what texture to use.

For best looking results like these in Crafterria, you should use Texture Array (sometimes they call them Array Samplers) - You load all your texture into a texture array with mipmaps, an you are ready to go. Just don't mistake a Texture Array with 3D Texture - with Textuyre Arrays you get correct mipmaps, they are basically wad of images but with third dimension to access the specific image.

Of course such algorithm requires some preparations, and you will need to calculate your splatting ids on the CPU. And in case more than 5 materials want to contribute to single vertex.... Ignore the least contributor completely and use just the top 4 ranked contributing materials. Trilinear interpolation code is needed for this.

This screenshot shows the idea. Notice that most of triangles have contributions set to (1,0,0,0) and only the Red channel contribution is used, however, the per-triangle-id table points to different texture id.

In places where blending is needed, Red, Green and even Blue and Alpha channels are used to implement the splatting as and if needed.
idea.jpg [ 202.85 KiB | Viewed 7359 times ]

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group