I have stumbled into a rabbit hole, it seems.
I have been using the FastNoiseLite library within my game in order to generate a voxel world. It’s been working really well on the CPP/Actor side of things, but I quickly realized that materials use a completely different workflow. So I can’t tap into the CPP version of the library.
After double-checking, I found that a part of the repository includes the library fully transposed into one large HLSL file:
How would I even begin to implement this so that I can play around with its features within a Material blueprint? I don’t mind putting in the work to transpose this into whatever variation of syntax that Unreal needs, but I don’t even know where to start.
Specific to my use-case, here is what I am trying to accomplish;
I am generating a 3D block word (think Minecraft), and instead of “Grass” or “Dirt”, I have one singular “Soil” tile which can have a Fertility
value between 0-1.
This Fertility value is computable by the FastNoiseLite library, which is able to take the block’s world position and get some noise value for it. From there, I can use CPP & FColor to set that block’s color.
This has a very blocky effect.
On top of that, the implementation on the above screenshot is not performant in terms of vertex count. Since every Soil block is technically different, I can’t use a greedy algorithm to combine groups of Soil blocks together, otherwise I will get this artifacting:
So ultimately what I would love to do is:
- Use my Greedy Chunk generation logic
- Use a shader that uses the identical Noise algorithm to paint my Soil blocks’ faces at a per-pixel level. (Imagine the first image above, but perfectly smooth instead of blocky)
This is where I imagine a custom shader from the HLSL code comes into play. Does anyone have any pointers on how I could get started with this?