Custom Materials

This example shows you how to create and use your own materials and apply them to the map elements.

To see this in action, open the Wrld/Demo/Examples.unity scene in Unity, click the Play button, and select Custom Materials from the dropdown.

Setup Steps

The WRLD Unity package contains simple and default materials that can be used as a starting point along with existing textures that can be modified. The textures are provided under a Creative Commons Attribution 4.0 International Public License. Follow the steps below to copy the existing base materials to start modifying them. To learn more about modifying and working with Unity materials checkout the Unity documentation page for materials.

Setup Steps

  1. Create a Resources folder in your Assets directory if it doesn’t exist
  2. Create a new folder in Resources named MyMaterials
  3. Copy all the materials (*.mat) present in Assets/Wrld/Resources/WrldMaterials/ to the MyMaterials folder using a file browser
  4. Similarly create a MyTextures folder in the Assets directory
  5. Copy all the texture files (*.png) from the Wrld/Textures/ folder to MyTextures
  6. Select the Wrld Map object from the scene hierarchy and expand the WrldMap script
  7. In the Theme Settings set the Materials Directory to “MyMaterials”

Note: The materials have been named semantically and should not be renamed.

Modifying Materials

Making changing to the materials is pretty straightforward from there on. Any changes to the materials in the MyMaterials directory will be directly applied to the map. Making changes to any of these materials during runtime will apply those changes as well.

If creating a material from scratch, prefer to use the Standard Unity shader/material. This type has the best interoperability with mobile platforms and minimizes the difference between each. All values in the shaders can be customized and will work as expected.

Modifying Textures

All diffuse textures in the MyMaterials folder, or in the Assets/Wrld/Resources/WrldMaterials/ directory if materials have not been modified, are referencing textures in the Assets/Wrld/Textures folder and should be changed to use the ones in the MyTextures folder. If any textures are modified, the diffuse texture of the appropriate material should be updated. Modifying textures in the MyTextures folder requires some prerequisite knowledge of the texture atlas layout and the UVs. Click here for further instructions on modifying or creating new textures.

Modifying Landmark Materials

Landmarks are special buildings or locations in the world. These locations often have their own unique texture which is requested and loaded during runtime. Therefore to customize the look of the landmarks, you can provide a base Unity material which is then copied for each different landmark and assigned a diffuse texture at runtime.

  1. Create a new Standard Unity material (MyLandmarkMaterial) in any folder of your choosing
  2. Modify the material as you see fit. Any diffuse texture assigned will be overriden, however the diffuse Albedo will be retained
  3. Select the WrldMap game object in the scene hierarchy and expand the script with the same name
  4. In the Theme Settings, drag and drop MyLandmarkMaterial into the Landmark Override Material input box
  5. This should apply your base MyLandmarkMaterial to all the landmarks that are streamed and assign the diffuse texture accordingly
v0.8.17