Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension implementation can inject texture loading strategy to ImporterContext #986

Merged
merged 6 commits into from
May 27, 2021

Conversation

Santarh
Copy link
Contributor

@Santarh Santarh commented May 27, 2021

  • fix namespace
  • define ITextureDeserializer
  • ImporterContext can be injected ITextureDeserializer
  • Remove NormalMap conversion on importing.

@Santarh Santarh requested a review from ousttrue May 27, 2021 12:20
public ImporterContext(
GltfParser parser,
IReadOnlyDictionary<SubAssetKey, UnityEngine.Object> externalObjectMap = null,
ITextureDeserializer textureDeserializer = null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

/// <param name="useMipmap">Texture2D の mipmap が生成されるべきか否か</param>
/// <param name="colorSpace">Texture2D の色空間</param>
/// <returns></returns>
Task<Texture2D> LoadTextureAsync(byte[] imageData, bool useMipmap, ColorSpace colorSpace);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

// ConvertToNormalValueFromRawColorWhenCompressionIsRequired
public static Texture2D Import(Texture2D texture)
{
return TextureConverter.CopyTexture(texture, ColorSpace.Linear, false, Encoder);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😄

// > contrary to Unity’s usual convention of using Y as “up”
// https://docs.unity3d.com/2018.4/Documentation/Manual/StandardShaderMaterialParameterNormalMap.html
var data0 = await texDesc.Index0();
var rawTexture = await _textureDeserializer.LoadTextureAsync(data0, texDesc.Sampler.EnableMipMap, ColorSpace.Linear);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_textureDeserializer.LoadTextureAsync

Copy link
Contributor

@ousttrue ousttrue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ITextureDeserializer

@ousttrue ousttrue merged commit 0c3d7b2 into vrm-c:master May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants