Skip to content

Commit

Permalink
v0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
phuong-axie committed Apr 1, 2024
1 parent f8fdac1 commit 993f8a7
Show file tree
Hide file tree
Showing 16 changed files with 474 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ public class Axie2dBuilderResult
public class Axie2dBuilder
{
public IAxieMixerMaterials axieMixerMaterials { get; private set; }
public bool isGraphicLinear { get; private set; }

public void Init(IAxieMixerMaterials axieMixerMaterials)
{
this.axieMixerMaterials = axieMixerMaterials;
this.isGraphicLinear = QualitySettings.activeColorSpace == ColorSpace.Linear;
}

public int GetSampleColorVariant(AxieCore.AxieMixer.CharacterClass characterClass, int colorValue)
Expand Down Expand Up @@ -95,7 +97,8 @@ public Axie2dBuilderResult BuildSpineAdultCombo(Dictionary<string, string> adult
else
{
builderResult.skeletonDataAsset = skeletonDataAsset;
builderResult.sharedGraphicMaterial = axieMixerMaterials.GetSampleGraphicMaterial(AxieFormType.Normal);
builderResult.sharedGraphicMaterial = isGraphicLinear ? axieMixerMaterials.GetSampleLinearGraphicMaterial(AxieFormType.Normal, colorVariant, 0) : //phuongnk - tmp solution shift value is not correct
axieMixerMaterials.GetSampleGraphicMaterial(AxieFormType.Normal);
}
return builderResult;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ public interface IAxieMixerMaterials
IAxieGenesStuff GetGenesStuff(AxieFormType formType);
IAxieMixerStuff GetMixerStuff(AxieFormType formType);
Material GetSampleGraphicMaterial(AxieFormType formType);
Material GetSampleLinearGraphicMaterial(AxieFormType formType, byte colorVariant, byte colorShift);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public class SingleStuff {
public IAxieGenesStuff axieGenesStuff;
public IAxieMixerStuff axieMixerStuff;
public Material sampleGraphicMaterial;
public Material sampleGraphicLinearMaterial;
public Dictionary<string, Material> materials = new Dictionary<string, Material>();
public Dictionary<string, Material> variantMaterials = new Dictionary<string, Material>();
}
SingleStuff[ ] stuffs = new SingleStuff[(int)AxieFormType.Count];

Expand All @@ -45,6 +47,23 @@ public Material GetSampleGraphicMaterial(AxieFormType formType)
return stuffs[(int)formType].sampleGraphicMaterial;
}

public Material GetSampleLinearGraphicMaterial(AxieFormType formType, byte colorVariant, byte colorShift)
{
if (stuffs[(int)formType] == null) return null;
var stuff = stuffs[(int)formType];
string key = $"linear_{colorVariant}-{colorShift}";
Material ret;
if(stuff.variantMaterials.TryGetValue(key, out ret))
{
return ret;
}
ret = new Material(stuffs[(int)formType].sampleGraphicLinearMaterial);
ret.SetFloat("_ColorVariant", colorVariant);
ret.SetFloat("_ColorShift", colorShift);
stuff.variantMaterials.Add(key, ret);
return ret;
}

public IAxieGenesStuff GetGenesStuff(AxieFormType formType) {
if (stuffs[(int)formType] == null) return null;
return stuffs[(int)formType].axieGenesStuff;
Expand Down Expand Up @@ -92,7 +111,15 @@ Dictionary<string, Material> baseMaterials
UnityEngine.Assertions.Assert.IsTrue(materials.Count == 1);
sampleGraphicMaterial = materials[0];
}


Material sampleGraphicLinearMaterial = null;
if (baseMaterials.TryGetValue("graphic-linear", out var baseGraphicLinearMaterial))
{
List<Material> materials = LoadMaterials(atlasStuffSingle, baseGraphicLinearMaterial);
UnityEngine.Assertions.Assert.IsTrue(materials.Count == 1);
sampleGraphicLinearMaterial = materials[0];
}

stuffs[(int)formType] = new SingleStuff
{
atlasStuffs = atlasStuffs,
Expand All @@ -101,6 +128,7 @@ Dictionary<string, Material> baseMaterials
axieGenesStuff = axieGenesStuff,
axieMixerStuff = axieMixerStuff,
sampleGraphicMaterial = sampleGraphicMaterial,
sampleGraphicLinearMaterial = sampleGraphicLinearMaterial,
materials = baseMaterials
};
}
Expand Down
8 changes: 0 additions & 8 deletions Assets/AxieInfinity/AxieMixerUnity/Resources/Sprites.meta

This file was deleted.

Loading

0 comments on commit 993f8a7

Please sign in to comment.