Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 798d0b3

Browse files
authored
Merge pull request Interkarma#1679 from petchema/less-stroboscopic-fire-walls
Less stroboscopic fire walls
2 parents 997b950 + 30c6cfa commit 798d0b3

File tree

5 files changed

+32
-2
lines changed

5 files changed

+32
-2
lines changed

Assets/Scripts/API/BaseImageFile.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,16 @@ public Color32[] GetWindowColors32(DFBitmap srcBitmap, int emissionIndex = 0xff)
298298
return emissionColors;
299299
}
300300

301+
public Color32[] GetFireWallColors32(ref Color32[] srcTexture, int width, int height, Color neutralColor, float scale)
302+
{
303+
Color32[] emissionColors = new Color32[width * height];
304+
305+
for (int i = 0; i < emissionColors.Length; i++)
306+
emissionColors[i] = Color32.Lerp(neutralColor, srcTexture[i], scale);
307+
308+
return emissionColors;
309+
}
310+
301311
#endregion
302312

303313
#region Protected Methods

Assets/Scripts/DaggerfallUnityStructs.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public struct CachedMaterial
117117
public FilterMode filterMode; // Filter mode of this material
118118
public int singleFrameCount; // Number of frames in single animated material
119119
public int[] atlasFrameCounts; // Array of frame counts for animated materials
120+
public int framesPerSecond; // Number of frames per second in single animated material
120121

121122
// Windows
122123
public bool isWindow; // True if this is a window material

Assets/Scripts/MaterialReader.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ public class MaterialReader : MonoBehaviour
8787
{
8888
#region Fields
8989

90+
// Constants
91+
public const int FireWallsArchive = 356;
92+
9093
// General settings
9194
public bool AtlasTextures = true;
9295
public bool CompressSkyTextures = false;
@@ -448,6 +451,7 @@ public Material GetMaterial(
448451
recordScales = recordScales,
449452
recordOffsets = recordOffsets,
450453
singleFrameCount = results.textureFile.GetFrameCount(record),
454+
framesPerSecond = archive == FireWallsArchive ? 5 : 0, // Slow down fire walls
451455
};
452456
materialDict.Add(key, newcm);
453457

Assets/Scripts/Utility/GameObjectHelper.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ public static void AssignAnimatedMaterialComponent(CachedMaterial[] cachedMateri
6767
// Assign animation properties
6868
c.TargetMaterial = cm.material;
6969
c.AnimationFrames = materials;
70+
if (cm.framesPerSecond > 0)
71+
c.FramesPerSecond = cm.framesPerSecond;
7072
}
7173
}
7274
}

Assets/Scripts/Utility/TextureReader.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public class TextureReader
3333
public const int AnimalsTextureArchive = 201;
3434
public const int LightsTextureArchive = 210;
3535
public const int FixedTreasureFlatsArchive = 216;
36+
public const int FireWallsArchive = 356;
3637
//public int[] MiscFlatsTextureArchives = new int[] { 97, 205, 211, 212, 213, 301 };
3738

3839
/// <summary>
@@ -269,8 +270,20 @@ public GetTextureResults GetTexture2D(
269270
{
270271
if (settings.createEmissionMap || (settings.autoEmission && isEmissive) && !isWindow)
271272
{
272-
// Just reuse albedo map for basic colour emission
273-
emissionMap = albedoMap;
273+
if (settings.archive != FireWallsArchive)
274+
// Just reuse albedo map for basic colour emission
275+
emissionMap = albedoMap;
276+
else
277+
{
278+
// Mantellan Crux fire walls - lessen stroboscopic effect
279+
Color fireColor = new Color(0.706f, 0.271f, 0.086f); // Average of dim frame (0)
280+
// Color fireColor = new Color(0.773f, 0.38f, 0.122f); // Average of average frames (1 and 3)
281+
// Color fireColor = new Color(0.851f, 0.506f, 0.165f); // Average of bright frame (2)
282+
Color32[] firewallEmissionColors = textureFile.GetFireWallColors32(ref albedoColors, sz.Width, sz.Height, fireColor, 0.3f);
283+
emissionMap = new Texture2D(sz.Width, sz.Height, ParseTextureFormat(alphaTextureFormat), MipMaps);
284+
emissionMap.SetPixels32(firewallEmissionColors);
285+
emissionMap.Apply(true, !settings.stayReadable);
286+
}
274287
resultEmissive = true;
275288
}
276289

0 commit comments

Comments
 (0)