Custom Asset Importing: Difference between revisions

From Ardenfall Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(7 intermediate revisions by the same user not shown)
Line 6: Line 6:
Every mod can have an asset manifest file defined. This lists out all assets you want to import.
Every mod can have an asset manifest file defined. This lists out all assets you want to import.


Create a file called manifest.txt in your mod directory.
Create a file called mod_manifest.txt in your mod directory.


''Example Asset Manifest''<syntaxhighlight lang="json">
''Example Asset Manifest''<syntaxhighlight lang="json">
Line 25: Line 25:
</syntaxhighlight>
</syntaxhighlight>


=== Supported Importers ===
=== Built in Importers ===
There are several built in importers to load up your assets. Most of them are pretty self explanatory!
{| class="wikitable"
|+
!Name
!Description
!ID
!Properties
|-
|GLTFScene
|Imports a GLTF file as a GameObject. Ideal for weapons, items, simple objects.
You can define a built in material to use, and it will automatically apply said material + hook up included textures.
|gltf_scene
|path: the path to the gltf file
shader: (optional) the shader id to import.
|-
|Texture
|Imports a .png or .jpeg as a Texture2D
|texture
|path: the path to the image file
|-
|AudioClip
|Imports a .mp3, .wav, or .ogg as an ArdenAudioClip
|audio_clip
|path: the path to the audio file
|-
|AssetBundle
|Imports a unity asset bundle.
|asset_bundle
|path: the path to the asset bundle file
|-
|ScriptableObject
|Creates a new SO based on properties.
|scriptable_object
|path: the path to the scriptable object definition file
|-
|Material
|Creates a new material based on properties.
|material
|path: the path to the material definition file
|}


==== SimpleModel ====
==== GLTFScene ====
Imports a GLTF file as a GameObject. Ideal for weapons, items, simple objects. You can define a built in material to use, and it will automatically apply said material + hook up included textures.
A GLTF scene / model importer. Will import the GLTF object as a gameobject.


==== Texture ====
Supports material applying using ModMaterialResolver.
Imports a .png or .jpeg as a Texture2D


==== <u>AudioClip</u> ====
Built on the [https://docs.unity3d.com/Packages/com.unity.[email protected]/manual/index.html GLTFFast] library.
Imports a .mp3, .wav, or .ogg as an ArdenAudioClip


=== Custom Importers ===
<u>Properties</u>
Mods can define their own importers. Perhaps you built a tool that can easily create item data assets from a json file. You can register your own importer to read this file, and then you can easily import them as assets! Other mods can also rely on other's importers.
{| class="wikitable"
|+
!Property
!Required
!Default
!Description
|-
|path
|YES
| -
|The path to the gltf / glb file
|-
|material
|NO
|simple_diffuse
|Defines the material to be injected.
Only a single material per scene is supported at the moment.
 
See Supported Materials Templates for a list of default materials to try out.
 
If you leave it blank, will not import any materials.
 
You can also reference a material imported by yourself or another mod. See the Mod Importer for that.
|}
'''ScriptableObject'''
 
You can import scriptable objects by using this importer. This reads a JSON file with the following parameters:
 
<u>JSON Properties</u>
{| class="wikitable"
!Property
!Required
!Default
!Description
|-
|parent
|NO
| -
|The parent scriptable object to copy from. This value is an ID in the lookup table. Note you either need to define 'parent' or 'type', but not both.
|-
|type
|NO
| -
|The class type of the scriptable object. Note you either need to define 'parent' or 'type', but not both.
|-
|parameters
|YES
| -
|An array of parameters to define the scriptable object.
|}
'''Material'''
 
You can import materials by using this importer. This reads a JSON file with the following parameters:
{| class="wikitable"
|}
{| class="wikitable"
!Property
!Required
!Default
!Description
|-
|parent
|YES
| -
|The parent material to copy from. This value is either a supported material template ID (see below) or an ID in the lookup table.
|-
|parameters
|YES
| -
|An array of parameters to define the material.
|}
 
=== Supported Material Templates ===
Due to shader variant stripping, we manually support various 'common' material variants by id reference.
 
'''simple_diffuse'''
 
The standard opaque ardenfall material with most features available. Specular, Emission, Pivot, Cloth Wind, Fresnel, and Triplaner are all enabled.
 
'''simple_diffuse_transparent'''
 
The standard transparent ardenfall material with most features available. Specular, Emission, Pivot, Cloth Wind, Fresnel, and Triplaner are all enabled.
 
'''enchantable_item'''
 
The standard ardenfall material for enchantable items (melee, bows, arrows, etc). Specular, Emission, Cloth Wind, and Enchantment Masks are all enabled.
 
'''character_clothing'''
 
The standard ardenfall material for clothing. Specular, Emission, Cloth Wind, and Fresnel are all enabled.
 
'''character_skin'''
 
The standard ardenfall material for character skin. Specular, Emission, Cloth Wind, Status Effect Masks are all enabled. [This is probably not of use for now]
 
'''character_skin_masked'''


Note an Importer doesn't need to only import a single path (this is why 'path' is a property). Perhaps a single importer takes in a model_path and a data_path, for example.
The standard ardenfall material for character skin, with humanoid masks active. Specular, Emission, Cloth Wind, Status Effect Masks are all enabled. [This is probably not of use for now]


TODO
=== Custom Importers ===
You can also create your own importers for yourself / others to utilize.


=== Example: A Custom Weapon ===
TODO
TODO

Latest revision as of 23:11, 23 August 2026

At some point you may want to import a new model, texture, sound, etc.

This can be done one of two ways - manually via scripting, or by using the built in mod asset importer feature. I suggest the latter, unless you want to do something funky.

Asset Manifest

Every mod can have an asset manifest file defined. This lists out all assets you want to import.

Create a file called mod_manifest.txt in your mod directory.

Example Asset Manifest

{
  "assets": [
    {
      "assetId": "testmod.dog",
      "type": "texture",
      "properties": [
        {
          "name": "path",
          "value": "Assets/dog.png"
        }
      ]
    }
  ]
}

Built in Importers

There are several built in importers to load up your assets. Most of them are pretty self explanatory!

Name Description ID Properties
GLTFScene Imports a GLTF file as a GameObject. Ideal for weapons, items, simple objects.

You can define a built in material to use, and it will automatically apply said material + hook up included textures.

gltf_scene path: the path to the gltf file

shader: (optional) the shader id to import.

Texture Imports a .png or .jpeg as a Texture2D texture path: the path to the image file
AudioClip Imports a .mp3, .wav, or .ogg as an ArdenAudioClip audio_clip path: the path to the audio file
AssetBundle Imports a unity asset bundle. asset_bundle path: the path to the asset bundle file
ScriptableObject Creates a new SO based on properties. scriptable_object path: the path to the scriptable object definition file
Material Creates a new material based on properties. material path: the path to the material definition file

GLTFScene

A GLTF scene / model importer. Will import the GLTF object as a gameobject.

Supports material applying using ModMaterialResolver.

Built on the GLTFFast library.

Properties

Property Required Default Description
path YES - The path to the gltf / glb file
material NO simple_diffuse Defines the material to be injected.

Only a single material per scene is supported at the moment.

See Supported Materials Templates for a list of default materials to try out.

If you leave it blank, will not import any materials.

You can also reference a material imported by yourself or another mod. See the Mod Importer for that.

ScriptableObject

You can import scriptable objects by using this importer. This reads a JSON file with the following parameters:

JSON Properties

Property Required Default Description
parent NO - The parent scriptable object to copy from. This value is an ID in the lookup table. Note you either need to define 'parent' or 'type', but not both.
type NO - The class type of the scriptable object. Note you either need to define 'parent' or 'type', but not both.
parameters YES - An array of parameters to define the scriptable object.

Material

You can import materials by using this importer. This reads a JSON file with the following parameters:

Property Required Default Description
parent YES - The parent material to copy from. This value is either a supported material template ID (see below) or an ID in the lookup table.
parameters YES - An array of parameters to define the material.

Supported Material Templates

Due to shader variant stripping, we manually support various 'common' material variants by id reference.

simple_diffuse

The standard opaque ardenfall material with most features available. Specular, Emission, Pivot, Cloth Wind, Fresnel, and Triplaner are all enabled.

simple_diffuse_transparent

The standard transparent ardenfall material with most features available. Specular, Emission, Pivot, Cloth Wind, Fresnel, and Triplaner are all enabled.

enchantable_item

The standard ardenfall material for enchantable items (melee, bows, arrows, etc). Specular, Emission, Cloth Wind, and Enchantment Masks are all enabled.

character_clothing

The standard ardenfall material for clothing. Specular, Emission, Cloth Wind, and Fresnel are all enabled.

character_skin

The standard ardenfall material for character skin. Specular, Emission, Cloth Wind, Status Effect Masks are all enabled. [This is probably not of use for now]

character_skin_masked

The standard ardenfall material for character skin, with humanoid masks active. Specular, Emission, Cloth Wind, Status Effect Masks are all enabled. [This is probably not of use for now]

Custom Importers

You can also create your own importers for yourself / others to utilize.

TODO