I am utilizing HillHeightMap
to generate a heightmap. I discovered a approach to generate an alphamap primarily based on a heightmap.
That is how I create the fabric
/** Add texture into the purple layer */
val purple: Texture = assetManager.loadTexture(redTexturePath)
purple.setWrap(WrapMode.Repeat)
materials.setTexture("AlbedoMap_0", purple)
materials.setTexture(
"NormalMap_0",
assetManager.loadTexture(redTextureNormalPath)
)
materials.setFloat("AlbedoMap_0_scale", 64f)
/** Add texture into the inexperienced layer */
val inexperienced: Texture = assetManager.loadTexture(greenTexturePath)
inexperienced.setWrap(WrapMode.Repeat)
materials.setTexture("AlbedoMap_1", inexperienced)
materials.setTexture(
"NormalMap_1",
assetManager.loadTexture(greenTextureNormalPath)
)
materials.setFloat("AlbedoMap_1_scale", 32f)
/** Add texture into the blue layer */
val blue: Texture = assetManager.loadTexture(blueTexturePath)
blue.setWrap(WrapMode.Repeat)
materials.setTexture("AlbedoMap_2", blue)
materials.setTexture(
"NormalMap_2",
assetManager.loadTexture(blueTextureNormalPath)
)
materials.setFloat("AlbedoMap_2_scale", 128f)
HillHeightMap.NORMALIZE_RANGE = 100f
That is how I generate the alphamap
personal var alphamap: WeakReference? = null
personal var rendered: Boolean = false
personal val tex1Height = 0f
personal val tex2Height = 75f
personal val tex3Height = 80f
personal val maxHeight = 300f
if (rendered && alphamap != null && alphamap?.get() != null) return alphamap!!.get()!!
val peak = heightmap.measurement
val width = heightmap.measurement
val knowledge = BufferUtils.createByteBuffer(width * peak * 4)
for (x in 0 till width) {
for (z in 0 till peak) {
var alpha = 255
var purple = 0
var inexperienced = 0
var blue = 0
val pointHeight = heightmap.getScaledHeightAtPoint(z, width-(x + 1))
if (pointHeight tex3Height) blue = 255
else if (pointHeight > tex2Height) inexperienced = 255
else if (pointHeight > tex1Height) purple = 255
else if (pointHeight
How can I make the transition between textures smoother/much less noticeable?