Je recherche des méthodes possibles pour dessiner des textures sur un terrain en temps réel directement en jeu via un éditeur. Mon jeu utilise HDRP. J'ai essayé avec SetAlphamaps mais les textures ne sont pas affichées
Code : Tout sélectionner
float[,] alphaMap = terrainData.GetAlphamaps(
(int)((hitInfo.point.x / terrainData.size.x) * alphaMapWidth),
(int)((hitInfo.point.z / terrainData.size.z) * alphaMapHeight),
1, 1);
// Modifier l'alpha map du terrain en fonction de la texture
int textureIndex = this.textureIndex % numOfTextures;
for (int i = 0; i < alphaMapWidth; i++)
{
for (int j = 0; j < alphaMapHeight; j++)
{
float distance = Mathf.Sqrt((i - hitInfo.textureCoord.x * alphaMapWidth) * (i - hitInfo.textureCoord.x * alphaMapWidth) + (j - hitInfo.textureCoord.y * alphaMapHeight) * (j - hitInfo.textureCoord.y * alphaMapHeight));
if (distance < brushSize)
{
alphaMap[j, i, textureIndex] += Time.deltaTime;
}
}
}
terrainData.SetAlphamaps(
(int)((hitInfo.point.x / terrainData.size.x) * alphaMapWidth),
(int)((hitInfo.point.z / terrainData.size.z) * alphaMapHeight),
alphaMap);