Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 4 additions & 14 deletions Assets/Scripts/Loading/BinaryDownloadProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public BinaryDownloadProvider(Dictionary<string, string> content)
/// </summary>
/// <param name="url">URI to request</param>
/// <returns>Object representing the request</returns>
public async Task<IDownload> RequestAsync(Uri url)
public async Task<IDownload> Request(Uri url)
Comment thread
Maurizio-dcl marked this conversation as resolved.
{
var req = new AwaitableDownload(url);
await req.WaitAsync();
Expand All @@ -39,7 +39,7 @@ public async Task<IDownload> RequestAsync(Uri url)
/// <param name="url">URI to request</param>
/// <param name="nonReadable">If true, resulting texture is not CPU readable (uses less memory)</param>
/// <returns>Object representing the request</returns>
public async Task<ITextureDownload> RequestTextureAsync(Uri url, bool nonReadable, bool forceLinear)
public async Task<ITextureDownload> RequestTexture(Uri url, bool nonReadable)
Comment thread
Maurizio-dcl marked this conversation as resolved.
{
var fileName = Path.GetFileName(url.LocalPath);
var file = _content[fileName];
Expand Down Expand Up @@ -159,6 +159,8 @@ public void Dispose()

public class AwaitableTextureDownload : AwaitableDownload, ITextureDownload
{
public Texture2D Texture { get; }

/// <summary>
/// Parameter-less constructor, required for inheritance.
/// </summary>
Expand Down Expand Up @@ -192,17 +194,5 @@ void Init(Uri url, bool nonReadable)
m_Request = CreateRequest(url, nonReadable);
m_AsyncOperation = m_Request.SendWebRequest();
}

/// <inheritdoc />
public IDisposableTexture GetTexture(bool linear)
{
return (m_Request?.downloadHandler as DownloadHandlerTexture)?.texture.ToDisposableTexture();
}
}

internal static class DisposableTextureExtensions
{
internal static IDisposableTexture ToDisposableTexture(this Texture2D texture2D) =>
new NonReusableTexture(texture2D);
}
}
14 changes: 8 additions & 6 deletions Assets/Scripts/Loading/ToonMaterialGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using GLTFast;
using GLTFast.Logging;
using GLTFast.Materials;
using GLTFast.Schema;
using UnityEngine;
using UnityEngine.Rendering;
using Material = UnityEngine.Material;

namespace Loading
{
Expand Down Expand Up @@ -35,28 +37,28 @@ public ToonMaterialGenerator(AvatarColors avatarColors)
//_avatarColors = avatarColors;
}

public Material GenerateMaterial(int materialIndex, GLTFast.Schema.Material gltfMaterial, IGltfReadable gltf,
public Material GenerateMaterial(MaterialBase gltfMaterial, IGltfReadable gltf,
bool pointsSupport = false)
{
var isFacialFeature = IsFacialFeature(gltfMaterial.name);
var mat = new Material(isFacialFeature ? CommonAssets.FacialFeaturesMaterial : CommonAssets.AvatarMaterial)
{ name = gltfMaterial.name };

// Base color and texture
var baseColor = gltfMaterial.pbrMetallicRoughness.BaseColor;
var baseColor = gltfMaterial.PbrMetallicRoughness.BaseColor;
mat.SetColor(BASE_COLOR_ID, baseColor);

if (gltfMaterial.pbrMetallicRoughness.baseColorTexture.index != -1)
if (gltfMaterial.PbrMetallicRoughness.BaseColorTexture.index != -1)
{
mat.SetTexture(MAIN_TEX_ID, gltf.GetTexture(gltfMaterial.pbrMetallicRoughness.baseColorTexture.index));
mat.SetTexture(MAIN_TEX_ID, gltf.GetTexture(gltfMaterial.PbrMetallicRoughness.BaseColorTexture.index));
}

// Emission
mat.SetColor(EMISSIVE_COLOR_ID, gltfMaterial.Emissive * EMISSIVE_MAGIC_NUMBER);

if (gltfMaterial.emissiveTexture.index != -1)
if (gltfMaterial.EmissiveTexture.index != -1)
{
mat.SetTexture(EMISSIVE_TEX_ID, gltf.GetTexture(gltfMaterial.emissiveTexture.index));
mat.SetTexture(EMISSIVE_TEX_ID, gltf.GetTexture(gltfMaterial.EmissiveTexture.index));
}

// Alpha
Expand Down
2 changes: 1 addition & 1 deletion Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"dependencies": {
"com.atteneder.gltfast": "https://github.com/decentraland/unity-gltf.git",
"com.atteneder.gltfast": "https://github.com/atteneder/glTFast.git",
"com.decentraland.unity-shared-dependencies": "git@github.com:decentraland/unity-shared-dependencies.git#main",
"com.unity.cinemachine": "3.1.4",
"com.unity.ide.rider": "3.0.38",
Expand Down
15 changes: 8 additions & 7 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
{
"dependencies": {
"com.atteneder.gltfast": {
"version": "https://github.com/decentraland/unity-gltf.git",
"version": "https://github.com/atteneder/glTFast.git",
"depth": 0,
"source": "git",
"dependencies": {
"com.unity.modules.jsonserialize": "1.0.0",
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.mathematics": "1.2.6",
"com.unity.burst": "1.6.6"
"com.unity.burst": "1.8.24",
"com.unity.collections": "1.2.4"
},
"hash": "e4587451389b6cf93b084ae434d0cc3d32a45076"
"hash": "3360ccae0a91cbc1bafb32d4aa0132fc82add141"
},
"com.decentraland.unity-shared-dependencies": {
"version": "git@github.com:decentraland/unity-shared-dependencies.git#main",
"depth": 0,
"source": "git",
"dependencies": {},
"hash": "da34743b0e4c01191c72f58af715bf2c0dfc2d67"
"hash": "0132f23fb5d1bfa1634a872ef28e131067df7a69"
},
"com.unity.burst": {
"version": "1.8.27",
Expand All @@ -41,7 +42,7 @@
},
"com.unity.collections": {
"version": "2.6.2",
"depth": 2,
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.burst": "1.8.23",
Expand Down Expand Up @@ -94,7 +95,7 @@
},
"com.unity.nuget.mono-cecil": {
"version": "1.11.6",
"depth": 3,
"depth": 2,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
Expand Down Expand Up @@ -177,7 +178,7 @@
},
"com.unity.test-framework.performance": {
"version": "3.2.0",
"depth": 3,
"depth": 2,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.33",
Expand Down
Loading