Get Default Shader Property

string GetDefaultShaderProperty(TerrainToMeshEnum.ShaderProperty shaderProperty)

Returns names of the shader properties used by the default material. This method can be useful when manually settings up material with textures using Material.SetTexturearrow-up-right method.

TerrainToMeshEnum.ShaderProperty

DiffuseMap

NormalMap

MetallicSmoothnessMaskMap

OcclusionMap

//Example of exporting Basemap textures from terrain and creating material

//Exporting Basemap Diffuse texture
Texture2D diffuseMap = terrainData.TerrainToMesh().ExportBasemapDiffuseTexture(...);

//Exporting Basemap Normal texture
Texture2D normalMap = terrainData.TerrainToMesh().ExportBasemapNormalTexture(...);


//Creating defaul material
Material material = Instantiate(TerrainToMeshUtilities.GetDefaultMaterial());

//Assigning diffuse map to the material
string basemapPropName = TerrainToMeshUtilities.GetDefaultShaderProperty(TerrainToMeshEnum.ShaderProperty.DiffuseMap);
material.SetTexture(basemapPropName, diffuseMap);

//Assigning normal map to the material
string normalmapPropName = TerrainToMeshUtilities.GetDefaultShaderProperty(TerrainToMeshEnum.ShaderProperty.NormalMap);
material.SetTexture(normalmapPropName, normalMap);

Last updated