Hello!
I have made a blending tool, capable of blending a large
amount of materials together using texture arrays and utilizing the
height maps for better transitions. It also features shaders to blend
objects with the terrain created with that blending tool, designed to
hide the intersection seams !
The runtime shaders are not super
expensive, they mostly do texture array samples and lerps (around 10 of
each) as most of the data required for
the effect is baked inside vertex channels and a control map at editor time.
The
"contact blending" tool bakes the normal, UVs, tangent and height to
the terrain into the various vertex channels of the object, which are
then used for the blending.
Right now it is a naive raycast up and
down for the distance to the surface, no fancy signed distance fields
but I hope to be able to improve that !
The blending shader uses a
control map, which stores inside it's RGB channels the texture index as
the int part and the weight of that texture as the floating part
(clamped between 0.05 and 0.95 to prevent artefacts). The A channel is
used for a bonus wetness overlay, but could be reworked to be anything
(burn, frost...). That control texture needs to use point filtering of
course, but even at low resolutions it give pretty convincing results,
thanks to the blending being modulated by the different height maps.
Here are a couple of ideas I've considered already:
-Figuring
out a way to use distance fields or another method for better distance
detection (right now it only works for mostly "flat" surfaces)
-Adding a way to mask areas where the blending should or should not happen (Quickly running out of vertex channels though)
I'd love to hear what you think !
Thanks!
Replies
is there any other way I can get it?
I could add world-aligned UVs, but wouldn't that suffer from the same problem unless I did tri-planar mapping ?
how's the performance on this ?
Terrain blending :
Simple contact blending (Between an object's material and another single material) :
Advanced contact blending (Between an object and a terrain blending shader) :
Now, I don't have much experience with shader performance yet, so you are going to have to help me make sense of this
EDIT: I did compiled Unity's default Standard shader for comparison :