first commit
This commit is contained in:
21
Assets/Synty/PNB_Core/Scripts/HeightMapAssigner.cs
Normal file
21
Assets/Synty/PNB_Core/Scripts/HeightMapAssigner.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteAlways]
|
||||
public class HeightmapAssigner : MonoBehaviour
|
||||
{
|
||||
public Terrain targetTerrain;
|
||||
public Material targetMaterial;
|
||||
|
||||
void Update()
|
||||
{
|
||||
if (targetTerrain == null || targetMaterial == null) return;
|
||||
|
||||
// Get the heightmap texture from the terrain
|
||||
Texture heightmap = targetTerrain.terrainData.heightmapTexture;
|
||||
|
||||
// Pass the data to the shader
|
||||
targetMaterial.SetTexture("_TerrainHeightMap", heightmap);
|
||||
targetMaterial.SetVector("_TerrainPos", targetTerrain.transform.position);
|
||||
targetMaterial.SetVector("_TerrainSize", targetTerrain.terrainData.size);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user