Skip to content

Commit

Permalink
[ME] fix normalmap conversion on item copy and timeline texture change (
Browse files Browse the repository at this point in the history
#252)

* Convert normal maps on item copy

* Convert normalmaps during timeline texture changing
  • Loading branch information
RikkiBalboa authored May 13, 2024
1 parent 0b6a03a commit ad0d19f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,10 @@ protected override void OnObjectsCopied(ReadOnlyDictionary<int, ObjectCtrlInfo>
MaterialTextureProperty newTextureProperty = new MaterialTextureProperty(copiedItem.Value.GetSceneId(), loadedProperty.MaterialName, loadedProperty.Property, loadedProperty.TexID, loadedProperty.Offset, loadedProperty.OffsetOriginal, loadedProperty.Scale, loadedProperty.ScaleOriginal);

bool setTex = false;
if (loadedProperty.TexID != null) setTex = SetTexture(ociItem.objectItem, newTextureProperty.MaterialName, newTextureProperty.Property, TextureDictionary[(int)newTextureProperty.TexID].Texture);

var tex = TextureDictionary[(int)newTextureProperty.TexID].Texture;
Instance.ConvertNormalMap(ref tex, newTextureProperty.Property);
if (loadedProperty.TexID != null) setTex = SetTexture(ociItem.objectItem, newTextureProperty.MaterialName, newTextureProperty.Property, tex);

bool setOffset = SetTextureOffset(ociItem.objectItem, newTextureProperty.MaterialName, newTextureProperty.Property, newTextureProperty.Offset);
bool setScale = SetTextureScale(ociItem.objectItem, newTextureProperty.MaterialName, newTextureProperty.Property, newTextureProperty.Scale);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ internal static void PopulateTimeline()
owner: "MaterialEditor",
id: "textureProperty",
name: "Texture Property",
interpolateBefore: (oci, parameter, leftValue, rightValue, factor) => SetTexture(parameter.GetGameObject(oci), parameter.materialName, parameter.propertyName, GetTextureByDictionaryID(leftValue)),
interpolateBefore: (oci, parameter, leftValue, rightValue, factor) =>
{
var tex = GetTextureByDictionaryID(leftValue);
MaterialEditorPluginBase.Instance.ConvertNormalMap(ref tex, parameter.propertyName);
SetTexture(parameter.GetGameObject(oci), parameter.materialName, parameter.propertyName, tex);
},
interpolateAfter: null,
getValue: (oci, parameter) =>
{
Expand Down

0 comments on commit ad0d19f

Please sign in to comment.