Package org.dark.shaders.util
Class TextureData
java.lang.Object
org.dark.shaders.util.TextureData
A class for reading csv data to the program so that textures such as material maps and normal maps can be handled.
- Since:
- Alpha 1.5
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enum -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidFinds objects that are missing normal maps and automatically generates normal maps for them.static com.fs.starfarer.api.graphics.SpriteAPIautoGenNormalMap(String spritePath, String key, TextureData.ObjectType type, int frame) Creates a normal map for the given sprite.static TextureEntrygetTextureData(String key, TextureData.TextureDataType map, TextureData.ObjectType type, int frame) Gets the requested texture map data.static TextureEntrygetTextureDataWithAutoGen(String key, TextureData.TextureDataType map, TextureData.ObjectType type, int frame, Object object, boolean unloadedOk) Gets the requested texture map data, with the possibility of auto-generation of normal maps.static booleanQueries if material maps are configured to be loaded or not.static booleanQueries if normal maps are configured to be loaded or not.static booleanQueries if surface maps are configured to be loaded or not.static voidmapSpriteToMNSWithAutoGen(String key, String spriteName, TextureData.ObjectType type, int frame, boolean autoGen, boolean autoGenOverride) Utility function to associate a sprite with the internal texture database.static voidreadTextureDataCSV(String localPath) Loads a texture data CSV and makes that data available internally.static voidreadTextureDataCSVNoOverwrite(String localPath) Loads a texture data CSV and makes that data available internally.static voidunloadAndPreloadTextures(Collection<com.fs.starfarer.api.fleet.FleetMemberAPI> members) Unloads all unnecessary material/normal/surface maps to save VRAM.
-
Field Details
-
AUTOGEN_OVERRIDE_TAG
- See Also:
-
NO_AUTOGEN_TAG
- See Also:
-
ALWAYS_PRELOAD_TAG
- See Also:
-
-
Constructor Details
-
TextureData
public TextureData()
-
-
Method Details
-
getTextureData
public static TextureEntry getTextureData(String key, TextureData.TextureDataType map, TextureData.ObjectType type, int frame) Gets the requested texture map data. This is guaranteed to never return an auto-generated normal map; use getTextureDataWithAutoGen if you want that. Will load a texture into the game if needed.- Parameters:
key- The ID of the desired material/normal/surface map texture.map- Whether the desired texture is a material, normal, or surface map.type- What kind of object the texture is intended for.frame- The frame of the animation, for an animated weapon. Use 0 for non-animated weapons and ships.- Returns:
- The requested data. Null if no such TextureData entry exists.
- Since:
- Alpha 1.5
-
getTextureDataWithAutoGen
public static TextureEntry getTextureDataWithAutoGen(String key, TextureData.TextureDataType map, TextureData.ObjectType type, int frame, Object object, boolean unloadedOk) Gets the requested texture map data, with the possibility of auto-generation of normal maps.This function can be used to procedurally preload specific texture maps at the start of combat. In an EveryFrameScript or similar type of plugin, wait for ShaderHook.TEXTURE_PRELOAD_KEY to be set and then call this function for every map that should be preloaded.
- Parameters:
key- The ID of the desired material/normal/surface map texture.map- Whether the desired texture is a material, normal, or surface map.type- What kind of object the texture is intended for.frame- The frame of the animation, for an animated weapon. Use 0 for non-animated weapons and ships. Ignored if type isn't TURRET or HARDPOINT.object- The associated object that the texture is for. Should be ShipAPI for a ship or cover, WeaponAPI for a weapon, WeaponAPI or MissileAPI for a missile, CombatEntityAPI for an asteroid. If null, shall not auto-generate and shall not retrieve an entry that was auto-generated. If you don't have the right type of object for some reason, any non-null object will permit retrieval (but not generation).unloadedOk- Return unloaded TextureEntries, if necessary. Almost always should be false.- Returns:
- The requested data. Null if no such TextureData entry exists and nothing could be auto-generated.
- Since:
- 1.11.0
-
readTextureDataCSV
Loads a texture data CSV and makes that data available internally. Duplicate entries will replace previous data.- Parameters:
localPath- The local path to the csv file (ex. "data/lights/core_texture_data.csv").- Since:
- Alpha 1.5
-
readTextureDataCSVNoOverwrite
Loads a texture data CSV and makes that data available internally. Duplicate entries will NOT replace previous data.- Parameters:
localPath- The local path to the csv file (ex. "data/lights/core_texture_data.csv").- Since:
- Alpha 1.5
-
autoGenMissingNormalMaps
public static void autoGenMissingNormalMaps()Finds objects that are missing normal maps and automatically generates normal maps for them. Results are cached in the GraphicsLib/cache folder so that they don't need to be regenerated on each game load. However, since mod updates can occasionally update existing sprites, a hash of the mod list (and version numbers) is tracked between game loads, so that the cache can be invalidated and regenerated if anything in the mod list changes.This function is intended to be used internally by GraphicsLib.
- Since:
- 1.11.0
-
unloadAndPreloadTextures
public static void unloadAndPreloadTextures(Collection<com.fs.starfarer.api.fleet.FleetMemberAPI> members) Unloads all unnecessary material/normal/surface maps to save VRAM. Preloads necessary material/normal/surface maps based on context. Any textures that were missed will be reloaded on demand, during combat.This function is intended to be used internally by GraphicsLib.
- Parameters:
members- The complete set of fleet members to use for preload context. If none are provided, all textures will be unloaded.- Since:
- 1.11.0
-
mapSpriteToMNSWithAutoGen
public static void mapSpriteToMNSWithAutoGen(String key, String spriteName, TextureData.ObjectType type, int frame, boolean autoGen, boolean autoGenOverride) Utility function to associate a sprite with the internal texture database. Can auto-generate a normal map.- Parameters:
key- The ID associated with the object that the sprite is meant for. The hull ID, weapon ID, etc.spriteName- The path of the sprite.type- What kind of object it is.frame- The frame of the animation, for an animated weapon. Use 0 for non-animated weapons. Ignored if type isn't TURRET or HARDPOINT.autoGen- Enable auto-generation of normal maps.autoGenOverride- Causes the texture to not be marked as auto-generated.- Since:
- 1.11.0
-
autoGenNormalMap
public static com.fs.starfarer.api.graphics.SpriteAPI autoGenNormalMap(String spritePath, String key, TextureData.ObjectType type, int frame) Creates a normal map for the given sprite. The image corresponding to the returned Sprite is saved to the GraphicsLib/cache folder. If a cached version of the image exists, it will be loaded from the disk so that it doesn't have to be regenerated from scratch. However, if the mod list changed since the previous run of the game (i.e., any mod ID or mod version is different), the cache is invalidated and the normal map will always be regenerated.- Parameters:
spritePath- The path of the sprite to generate a normal map for.key- The ID associated with the object that the sprite is meant for. The hull ID, weapon ID, etc.type- What kind of object the normal map is for.frame- The frame of the animation, for an animated weapon. Use 0 for non-animated weapons. Ignored if type isn't TURRET or HARDPOINT.- Returns:
- The requested sprite. Null if an error occurred.
- Since:
- 1.11.0
-
isLoadMaterial
public static boolean isLoadMaterial()Queries if material maps are configured to be loaded or not.- Returns:
- True if material maps should be loaded.
- Since:
- 1.10.0
-
isLoadNormal
public static boolean isLoadNormal()Queries if normal maps are configured to be loaded or not.- Returns:
- True if normal maps should be loaded.
- Since:
- 1.10.0
-
isLoadSurface
public static boolean isLoadSurface()Queries if surface maps are configured to be loaded or not.- Returns:
- True if surface maps should be loaded.
- Since:
- 1.10.0
-