Class MaterialReader
Imports Daggerfall images into Unity. Should only be attached to DaggerfallUnity singleton (for which it is a required component). Note: Texture loading methods have been moved to TextureReader class.
Namespace: DaggerfallWorkshop
Assembly: Assembly-CSharp.dll
Syntax
[RequireComponent(typeof(DaggerfallUnity))]
public class MaterialReader : MonoBehaviour
Fields
| Improve this Doc View Source_DaggerfallBillboardBatchNoShadowsShaderName
Declaration
public const string _DaggerfallBillboardBatchNoShadowsShaderName = "Daggerfall/BillboardBatchNoShadows"
Field Value
Type | Description |
---|---|
String |
_DaggerfallBillboardBatchShaderName
Declaration
public const string _DaggerfallBillboardBatchShaderName = "Daggerfall/BillboardBatch"
Field Value
Type | Description |
---|---|
String |
_DaggerfallBillboardShaderName
Declaration
public const string _DaggerfallBillboardShaderName = "Daggerfall/Billboard"
Field Value
Type | Description |
---|---|
String |
_DaggerfallDefaultShaderName
Declaration
public const string _DaggerfallDefaultShaderName = "Daggerfall/Default"
Field Value
Type | Description |
---|---|
String |
_DaggerfallGhostShaderName
Declaration
public const string _DaggerfallGhostShaderName = "Daggerfall/GhostShader"
Field Value
Type | Description |
---|---|
String |
_DaggerfallPixelFontShaderName
Declaration
public const string _DaggerfallPixelFontShaderName = "Daggerfall/PixelFont"
Field Value
Type | Description |
---|---|
String |
_DaggerfallRetroDepthShaderName
Declaration
public const string _DaggerfallRetroDepthShaderName = "Daggerfall/DepthProcessShader"
Field Value
Type | Description |
---|---|
String |
_DaggerfallRetroPalettizationShaderName
Declaration
public const string _DaggerfallRetroPalettizationShaderName = "Daggerfall/RetroPalettization"
Field Value
Type | Description |
---|---|
String |
_DaggerfallRetroPosterizationShaderName
Declaration
public const string _DaggerfallRetroPosterizationShaderName = "Daggerfall/RetroPosterization"
Field Value
Type | Description |
---|---|
String |
_DaggerfallSDFFontShaderName
Declaration
public const string _DaggerfallSDFFontShaderName = "Daggerfall/SDFFont"
Field Value
Type | Description |
---|---|
String |
_DaggerfallTilemapShaderName
Declaration
public const string _DaggerfallTilemapShaderName = "Daggerfall/Tilemap"
Field Value
Type | Description |
---|---|
String |
_DaggerfallTilemapTextureArrayShaderName
Declaration
public const string _DaggerfallTilemapTextureArrayShaderName = "Daggerfall/TilemapTextureArray"
Field Value
Type | Description |
---|---|
String |
_DaggerfallUIBlendShaderName
Declaration
public const string _DaggerfallUIBlendShaderName = "Daggerfall/UIBlend"
Field Value
Type | Description |
---|---|
String |
_DaggerfallUIBlitShaderName
Declaration
public const string _DaggerfallUIBlitShaderName = "Daggerfall/UIBlit"
Field Value
Type | Description |
---|---|
String |
_StandardShaderName
Declaration
public const string _StandardShaderName = "Standard"
Field Value
Type | Description |
---|---|
String |
AlphaTextureFormat
Declaration
public SupportedAlphaTextureFormats AlphaTextureFormat
Field Value
Type | Description |
---|---|
SupportedAlphaTextureFormats |
AtlasKeyGroup
Declaration
public const int AtlasKeyGroup = 512
Field Value
Type | Description |
---|---|
Int32 |
AtlasTextures
Declaration
public bool AtlasTextures
Field Value
Type | Description |
---|---|
Boolean |
CompressModdedTextures
Declaration
public bool CompressModdedTextures
Field Value
Type | Description |
---|---|
Boolean |
CompressSkyTextures
Declaration
public bool CompressSkyTextures
Field Value
Type | Description |
---|---|
Boolean |
CustomBillboardKeyGroup
Declaration
public const int CustomBillboardKeyGroup = 1536
Field Value
Type | Description |
---|---|
Int32 |
CustomWindowColor
Declaration
public Color CustomWindowColor
Field Value
Type | Description |
---|---|
Color |
CustomWindowIntensity
Declaration
public float CustomWindowIntensity
Field Value
Type | Description |
---|---|
Single |
DayWindowColor
Declaration
public Color DayWindowColor
Field Value
Type | Description |
---|---|
Color |
DayWindowIntensity
Declaration
public float DayWindowIntensity
Field Value
Type | Description |
---|---|
Single |
FireWallsArchive
Declaration
public const int FireWallsArchive = 356
Field Value
Type | Description |
---|---|
Int32 |
FogWindowColor
Declaration
public Color FogWindowColor
Field Value
Type | Description |
---|---|
Color |
FogWindowIntensity
Declaration
public float FogWindowIntensity
Field Value
Type | Description |
---|---|
Single |
GenerateNormals
Declaration
public bool GenerateNormals
Field Value
Type | Description |
---|---|
Boolean |
MainFilterMode
Declaration
public FilterMode MainFilterMode
Field Value
Type | Description |
---|---|
FilterMode |
MainKeyGroup
Declaration
public const int MainKeyGroup = 0
Field Value
Type | Description |
---|---|
Int32 |
MipMaps
Declaration
public bool MipMaps
Field Value
Type | Description |
---|---|
Boolean |
NightWindowColor
Declaration
public Color NightWindowColor
Field Value
Type | Description |
---|---|
Color |
NightWindowIntensity
Declaration
public float NightWindowIntensity
Field Value
Type | Description |
---|---|
Single |
NormalTextureStrength
Declaration
public float NormalTextureStrength
Field Value
Type | Description |
---|---|
Single |
ReadableTextures
Declaration
public bool ReadableTextures
Field Value
Type | Description |
---|---|
Boolean |
Sharpen
Declaration
public bool Sharpen
Field Value
Type | Description |
---|---|
Boolean |
SkyFilterMode
Declaration
public FilterMode SkyFilterMode
Field Value
Type | Description |
---|---|
FilterMode |
TileMapKeyGroup
Declaration
public const int TileMapKeyGroup = 1024
Field Value
Type | Description |
---|---|
Int32 |
Properties
| Improve this Doc View SourceIsReady
Gets true if file reading is ready.
Declaration
public bool IsReady { get; }
Property Value
Type | Description |
---|---|
Boolean |
TextureReader
Gets managed texture reader.
Declaration
public TextureReader TextureReader { get; }
Property Value
Type | Description |
---|---|
TextureReader |
Methods
| Improve this Doc View SourceChangeClimate(Int32, ClimateBases, ClimateSeason, WindowStyle)
Get a new Material based on climate.
Declaration
public Material ChangeClimate(int key, ClimateBases climate, ClimateSeason season, WindowStyle windowStyle)
Parameters
Type | Name | Description |
---|---|---|
Int32 | key | Material key. |
ClimateBases | climate | New climate base. |
ClimateSeason | season | New season. |
WindowStyle | windowStyle | New window style. |
Returns
Type | Description |
---|---|
Material | New material. |
ChangeWindowEmissionColor(Material, WindowStyle)
Change emission colour of window materials.
Declaration
public void ChangeWindowEmissionColor(Material material, WindowStyle windowStyle)
Parameters
Type | Name | Description |
---|---|---|
Material | material | Source material to change. |
WindowStyle | windowStyle | New window style. |
ClearCache()
Clears material cache dictionary, forcing material to reload.
Declaration
public void ClearCache()
CreateBillboardMaterial()
Creates a new transparent cutout billboard material for mobiles, misc. objects, etc.
Declaration
public static Material CreateBillboardMaterial()
Returns
Type | Description |
---|---|
Material | Material using Daggerfall/Billboard shader. |
CreateDefaultMaterial()
Creates a new default material for world geometry.
Declaration
public static Material CreateDefaultMaterial()
Returns
Type | Description |
---|---|
Material | Material using Daggerfall/Default shader. |
CreateStandardMaterial(MaterialReader.CustomBlendMode, MaterialReader.CustomSmoothnessMapChannel, Single, Single)
Creates new Standard material with default properties suitable for most Daggerfall textures.
Declaration
public static Material CreateStandardMaterial(MaterialReader.CustomBlendMode blendMode = MaterialReader.CustomBlendMode.Opaque, MaterialReader.CustomSmoothnessMapChannel smoothnessChannel = MaterialReader.CustomSmoothnessMapChannel.AlbedoAlpha, float metallic = 0F, float glossiness = 0F)
Parameters
Type | Name | Description |
---|---|---|
MaterialReader.CustomBlendMode | blendMode | |
MaterialReader.CustomSmoothnessMapChannel | smoothnessChannel | |
Single | metallic | |
Single | glossiness |
Returns
Type | Description |
---|---|
Material | Material using Standard shader. |
GetCachedMaterial(Int32, Int32, Int32, out CachedMaterial, Int32)
Gets CachedMaterial properties. Material will be loaded into cache if not present already.
Declaration
public bool GetCachedMaterial(int archive, int record, int frame, out CachedMaterial cachedMaterialOut, int alphaIndex = -1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Int32 | record | Record index. |
Int32 | frame | Frame index. |
CachedMaterial | cachedMaterialOut | CachedMaterial out. |
Int32 | alphaIndex | Alpha index used if material needs to be loaded. |
Returns
Type | Description |
---|---|
Boolean | True if CachedMaterial found or loaded successfully. |
GetCachedMaterialAtlas(Int32, out CachedMaterial)
Gets CachedMaterial properties for an atlased material. Atlas material will not be loaded automatically if not found in cache.
Declaration
public bool GetCachedMaterialAtlas(int archive, out CachedMaterial cachedMaterialOut)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Atlas archive index. |
CachedMaterial | cachedMaterialOut | CachedMaterial out |
Returns
Type | Description |
---|---|
Boolean | True if CachedMaterial found. |
GetCachedMaterialCustomBillboard(Int32, Int32, Int32, out CachedMaterial)
Gets CachedMaterial properties for a billboard with custom material.
Declaration
public bool GetCachedMaterialCustomBillboard(int archive, int record, int frame, out CachedMaterial cachedMaterialOut)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Int32 | record | Record index. |
Int32 | frame | |
CachedMaterial | cachedMaterialOut | CachedMaterial out |
Returns
Type | Description |
---|---|
Boolean | True if CachedMaterial found. |
GetEditorFlatType(Int32)
Declaration
public static EditorFlatTypes GetEditorFlatType(int record)
Parameters
Type | Name | Description |
---|---|---|
Int32 | record |
Returns
Type | Description |
---|---|
EditorFlatTypes |
GetFlatType(Int32)
Declaration
public static FlatTypes GetFlatType(int archive)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive |
Returns
Type | Description |
---|---|
FlatTypes |
GetMaterial(Int32, Int32, Int32, Int32)
Gets Unity Material from Daggerfall texture.
Declaration
public Material GetMaterial(int archive, int record, int frame = 0, int alphaIndex = -1)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Int32 | record | Record index. |
Int32 | frame | Frame index. |
Int32 | alphaIndex | Index to receive transparent alpha. |
Returns
Type | Description |
---|---|
Material | Material or null. |
GetMaterial(Int32, Int32, Int32, Int32, out Rect, Int32, Boolean, Boolean)
Gets Unity Material from Daggerfall texture with more options.
Declaration
public Material GetMaterial(int archive, int record, int frame, int alphaIndex, out Rect rectOut, int borderSize = 0, bool dilate = false, bool isBillboard = false)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Int32 | record | Record index. |
Int32 | frame | Frame index. |
Int32 | alphaIndex | |
Rect | rectOut | Receives UV rect for texture inside border. |
Int32 | borderSize | Number of pixels internal border around each texture. |
Boolean | dilate | Blend texture into surrounding empty pixels. |
Boolean | isBillboard | Set true when creating atlas material for simple billboards. |
Returns
Type | Description |
---|---|
Material | Material or null. |
GetMaterialAtlas(Int32, Int32, Int32, Int32, out Rect[], out RecordIndex[], Int32, Boolean, Int32, Boolean, Boolean)
Gets Unity Material atlas from Daggerfall texture archive.
Declaration
public Material GetMaterialAtlas(int archive, int alphaIndex, int padding, int maxAtlasSize, out Rect[] rectsOut, out RecordIndex[] indicesOut, int border = 0, bool dilate = false, int shrinkUVs = 0, bool copyToOppositeBorder = false, bool isBillboard = false)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index to create atlas from. |
Int32 | alphaIndex | Index to receive transparent alpha. |
Int32 | padding | Number of pixels each sub-texture. |
Int32 | maxAtlasSize | Max size of atlas. |
Rect[] | rectsOut | Array of rects, one for each record sub-texture and frame. |
RecordIndex[] | indicesOut | Array of record indices into rect array, accounting for animation frames. |
Int32 | border | Number of pixels internal border around each texture. |
Boolean | dilate | Blend texture into surrounding empty pixels. |
Int32 | shrinkUVs | Number of pixels to shrink UV rect. |
Boolean | copyToOppositeBorder | Copy texture edges to opposite border. Requires border, will overwrite dilate. |
Boolean | isBillboard | Set true when creating atlas material for simple billboards. |
Returns
Type | Description |
---|---|
Material | Material or null. |
GetTerrainTextureArrayMaterial(Int32)
Gets Unity Material from Daggerfall terrain using texture arrays.
Declaration
public Material GetTerrainTextureArrayMaterial(int archive)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Returns
Type | Description |
---|---|
Material | Material or null. |
GetTerrainTilesetMaterial(Int32)
Gets Unity Material from Daggerfall terrain tilemap texture.
Declaration
public Material GetTerrainTilesetMaterial(int archive)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Returns
Type | Description |
---|---|
Material | Material or null. |
MakeTextureKey(Int16, Byte, Byte, Int32)
Declaration
public static int MakeTextureKey(short archive, byte record, byte frame = 0, int group = 0)
Parameters
Type | Name | Description |
---|---|---|
Int16 | archive | |
Byte | record | |
Byte | frame | |
Int32 | group |
Returns
Type | Description |
---|---|
Int32 |
ReverseTextureKey(Int32, out Int32, out Int32, out Int32, Int32)
Declaration
public static void ReverseTextureKey(int key, out int archiveOut, out int recordOut, out int frameOut, int group = 0)
Parameters
Type | Name | Description |
---|---|---|
Int32 | key | |
Int32 | archiveOut | |
Int32 | recordOut | |
Int32 | frameOut | |
Int32 | group |
SetBlendMode(Material, MaterialReader.CustomBlendMode, MaterialReader.CustomSmoothnessMapChannel, Single, Single)
Change the blend mode of a Standard material at runtime.
Declaration
public static void SetBlendMode(Material material, MaterialReader.CustomBlendMode blendMode, MaterialReader.CustomSmoothnessMapChannel smoothnessChannel, float metallic, float glossiness)
Parameters
Type | Name | Description |
---|---|---|
Material | material | |
MaterialReader.CustomBlendMode | blendMode | |
MaterialReader.CustomSmoothnessMapChannel | smoothnessChannel | |
Single | metallic | |
Single | glossiness |
SetCachedMaterial(Int32, Int32, Int32, CachedMaterial)
Sets CachedMaterial properties. existing Material will be updated in cache with cachedMaterialIn.
Declaration
public bool SetCachedMaterial(int archive, int record, int frame, CachedMaterial cachedMaterialIn)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Int32 | record | Record index. |
Int32 | frame | Frame index. |
CachedMaterial | cachedMaterialIn | the CachedMaterial used to update the cache. |
Returns
Type | Description |
---|---|
Boolean | True if CachedMaterial was found and updated successfully. |
SetCachedMaterialCustomBillboard(Int32, Int32, Int32, CachedMaterial)
Sets CachedMaterial properties for a billboard with custom material.
Declaration
public void SetCachedMaterialCustomBillboard(int archive, int record, int frame, CachedMaterial cachedMaterialIn)
Parameters
Type | Name | Description |
---|---|---|
Int32 | archive | Archive index. |
Int32 | record | Record index. |
Int32 | frame | |
CachedMaterial | cachedMaterialIn |