Difference between revisions of "Custom Spices"

From HoF2 Community Modding Wiki
Jump to: navigation, search
(Initial commit of spice tutorial)
 
(Added images and example resources download link)
Line 3: Line 3:
 
'''Note: This is a work-in-progress tutorial. At the time of writing, the HoF2/Character/Meeple shader is not available in the editor.'''
 
'''Note: This is a work-in-progress tutorial. At the time of writing, the HoF2/Character/Meeple shader is not available in the editor.'''
  
The steps below assume that you are comfortable using the [[Unity|Unity editor]] and already have an existing (3D model) and appropriate textures/maps generated for/from it. Examples in the form of a [[Factions|Briarfolk]] spice can be found **here**.
+
The steps below assume that you are comfortable using the [[Unity|Unity editor]] and already have an existing (3D model) and appropriate textures/maps generated for/from it. Examples in the form of a [[Factions|Briarfolk]] spice can be found [http://hof2modwiki.cheesetalks.net/examples/briarfolk_spice_files.zip here].
  
 
==Step 1: Add files to your project==
 
==Step 1: Add files to your project==
Line 25: Line 25:
  
 
==Step 2: Add a material==
 
==Step 2: Add a material==
 +
[[File:Material_settings.png|400px|thumb|right|Material settings in the Unity inspector]]
 +
[[File:Remap_mats.png|400px|thumb|right|Remapping materials in an importer mesh]]
 
Due to the way that texture maps are applied, each spice uses its own material, which can be created and assigned via the following steps.
 
Due to the way that texture maps are applied, each spice uses its own material, which can be created and assigned via the following steps.
  
Line 31: Line 33:
 
# For the Albedo, Metallic, Normal Map, and Occlusion texture fields, select the corresponding texture maps.
 
# For the Albedo, Metallic, Normal Map, and Occlusion texture fields, select the corresponding texture maps.
 
# Set Xaris Fade to 0.132 and Rim power to 6.4. The Inner Colour field can be set to 2D2A2AFF (dark red-grey), and the Outer Colour field FF0000FF (red).
 
# Set Xaris Fade to 0.132 and Rim power to 6.4. The Inner Colour field can be set to 2D2A2AFF (dark red-grey), and the Outer Colour field FF0000FF (red).
# Select the 3D mesh in the [[Unity Project Browser|Unity Project Browser]] and tick the Import Materials checkbox. Under Remapped Materials, select the new material you have created, and then click the Apply button.
+
# If your mesh does not include embedded textures, select the 3D mesh in the [[Unity Project Browser|Unity Project Browser]] and tick the Import Materials checkbox. Under Remapped Materials, select the new material you have created, and then click the Apply button.
 
+
<br clear=all>
  
 
==Step 3: Create the spice model prefab==
 
==Step 3: Create the spice model prefab==
 +
[[File:Add_component.png|400px|thumb|right|Adding components to a prefab in the Unity inspector]]
 
Next, a prefab that the game can identify as a spice model needs to be created.
 
Next, a prefab that the game can identify as a spice model needs to be created.
  
Line 40: Line 43:
 
# Drag and drop the 3D mesh onto the newly created prefab (the icon for the prefab should change to a preview of the model)
 
# Drag and drop the 3D mesh onto the newly created prefab (the icon for the prefab should change to a preview of the model)
 
# Using the Add Component button, add the Model, Model Collision, and Spice Model scripts to the prefab
 
# Using the Add Component button, add the Model, Model Collision, and Spice Model scripts to the prefab
 
+
<br clear=all>
  
 
==Step 4: Create the spice==
 
==Step 4: Create the spice==
 +
[[File:spice_model_empty.png|400px|thumb|right|A new spice in the Spices tab with no Model set.]]
 
Finally, we have what we need in order to create the spice itself.
 
Finally, we have what we need in order to create the spice itself.
  
Line 48: Line 52:
 
# Create a new spice by typing its name in the top left text field and clicking the New button.
 
# Create a new spice by typing its name in the top left text field and clicking the New button.
 
# Select the newly created spice in the editor tools, then drag and drop the spice model prefab from step 3 into the Model field.
 
# Select the newly created spice in the editor tools, then drag and drop the spice model prefab from step 3 into the Model field.
 
+
<br clear=all>
  
 
==Step 5: Other bits and pieces==
 
==Step 5: Other bits and pieces==
 
* You may need to add AssetBundle Labels to your material, mesh, and textures. The spice model prefab should have automatically had one assigned.
 
* You may need to add AssetBundle Labels to your material, mesh, and textures. The spice model prefab should have automatically had one assigned.
 +
* Other spice settings and spice model components can be added for additional behaviours if needed.
  
 
<!-- Leave this at the bottom of the page -->
 
<!-- Leave this at the bottom of the page -->
 
[[Category:Howto]]
 
[[Category:Howto]]

Revision as of 01:23, 11 February 2019

This tutorial covers how to add your own custom Spices to Hand of Fate 2.

Note: This is a work-in-progress tutorial. At the time of writing, the HoF2/Character/Meeple shader is not available in the editor.

The steps below assume that you are comfortable using the Unity editor and already have an existing (3D model) and appropriate textures/maps generated for/from it. Examples in the form of a Briarfolk spice can be found here.

Step 1: Add files to your project

Hand of Fate 2 spices require at least five source files, a mesh and four texture maps tailored to that mesh.

3D mesh
The geometry of your spice in a format that Unity can handle, such as a .fbx file, with appropriate UV mapping for the texture maps below.
Albedo texture map
A texture that affects the colour and intensity of light reflected off the spice model.
Metallic texture map
A texture that defines how "metallic" the spice model is.
Normal texture map
A texture that adds extra detail to the spice model.
Occlusion texture map
A texture that affects the indirect lighting that the spice model receives.


Create or locate these files and add them to your project.

  1. The files must be placed somewhere under the Assets folder in your extracted HoF2 SDK folder, but how you choose to organise them is up to you.


Step 2: Add a material

Material settings in the Unity inspector
Remapping materials in an importer mesh

Due to the way that texture maps are applied, each spice uses its own material, which can be created and assigned via the following steps.

  1. Start by creating a new material in the Unity Project Browser (right click, Create->Material).
  2. With the new material selected, select HoF/Character/Meeple from the Shader dropdown in the Inspector panel.
  3. For the Albedo, Metallic, Normal Map, and Occlusion texture fields, select the corresponding texture maps.
  4. Set Xaris Fade to 0.132 and Rim power to 6.4. The Inner Colour field can be set to 2D2A2AFF (dark red-grey), and the Outer Colour field FF0000FF (red).
  5. If your mesh does not include embedded textures, select the 3D mesh in the Unity Project Browser and tick the Import Materials checkbox. Under Remapped Materials, select the new material you have created, and then click the Apply button.


Step 3: Create the spice model prefab

Adding components to a prefab in the Unity inspector

Next, a prefab that the game can identify as a spice model needs to be created.

  1. Create a new empty prefab in the Unity Project Browser (right click, Create->Prefab).
  2. Drag and drop the 3D mesh onto the newly created prefab (the icon for the prefab should change to a preview of the model)
  3. Using the Add Component button, add the Model, Model Collision, and Spice Model scripts to the prefab


Step 4: Create the spice

A new spice in the Spices tab with no Model set.

Finally, we have what we need in order to create the spice itself.

  1. Open up the HoF2 editor tools from the Start Window and select the Spices Tab.
  2. Create a new spice by typing its name in the top left text field and clicking the New button.
  3. Select the newly created spice in the editor tools, then drag and drop the spice model prefab from step 3 into the Model field.


Step 5: Other bits and pieces

  • You may need to add AssetBundle Labels to your material, mesh, and textures. The spice model prefab should have automatically had one assigned.
  • Other spice settings and spice model components can be added for additional behaviours if needed.