Terrain To Mesh
  • Terrain To Mesh
  • Quick Start
  • Editor Window Settings
    • Mesh
    • Material
    • Objects
    • Save
  • Update Splatmap Shader
  • Run-time API
    • TerrainToMesh
      • ExportMesh
      • ExportTerrainLayers
      • ExportSplatmapMaterial
      • ExportSplatmapTextures
      • HasHoles
      • ExportHolesmapTexture
      • ExportBasemapDiffuseTexture
      • ExportBasemapNormalTexture
      • ExportBasemapMaskTexture
      • ExportBasemapOcclusionTexture
      • ExportGrassTextures
      • ExportGrassAtlasTexture
      • HasPrototypes
      • CountPrototypes
      • ExportPrototypes
    • TerrainToMeshUtilities
      • GenerateGrassMesh
      • GenerateEdgeFallTexture
      • ConvertMeshToOBJ
      • ConvertMeshToOBJAndSaveToFile
      • ConvertMeshToOBJAndAppendToFile
      • GetDefaultMaterial
      • GetDefaultShader
      • GetDefaultShaderProperty
      • SetupDefaultMaterial
      • SetupAlphaCutoutForDefaultMaterial
      • ConvertPrototypesToTreeGameObjects
      • ConvertPrototypesToGrassGameObjects
      • ConvertPrototypesToGrassMeshes
      • ConvertPrototypesToDetailMeshGameObjects
      • ConvertPrototypesToDetailMeshes
      • CalculateExportedMeshVertexCount
      • SetMeshPivotPoint
    • TerrainToMeshEdgeFall
    • TerrainToMeshPrototype
    • TerrainToMeshConversionDetails
  • Help & Contact
Powered by GitBook
On this page

Setup Default Material

void SetupDefaultMaterial(Material material, Texture diffuseMap, bool useDiffuseMapAlphaChannelForCutout, Texture normalMap, Texture metallicSmoothnessMaskMap, Texture occlusionMap)

Setups default material with provided textures.

useDiffuseMapAlphaChannelForCutout - If set to true, material will be changed to the Alpha Cutout and appropriate shader-keywords will be automatically enabled.

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

//Exporting Basemap Diffuse, Normal, Mask and Occlusion textures
Texture2D diffuseMap = terrainData.TerrainToMesh().ExportBasemapDiffuseTexture(...);
Texture2D normalMap = terrainData.TerrainToMesh().ExportBasemapNormalTexture(...);
Texture2D maskMap = terrainData.TerrainToMesh().ExportBasemapMaskTexture(...);
Texture2D occlusionMap = terrainData.TerrainToMesh().ExportBasemapOcclusionTexture(...);


//Creating defaul material
Material material = new Material(TerrainToMeshUtilities.GetDefaultShader());

//Setting up material to use required textures
TerrainToMeshUtilities.SetupDefaultMaterial(material, diffuseMap, false, normalMap, maskMap, occlusionMap);

PreviousGetDefaultShaderPropertyNextSetupAlphaCutoutForDefaultMaterial

Last updated 3 months ago