mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-07-18 16:21:50 -05:00
Implements UrpFallbackMaterialExporter
This commit is contained in:
parent
182fdbe8b0
commit
d3439abc52
|
|
@ -0,0 +1,36 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// フォールバック目的で最低限なにかをエクスポートする。
|
||||
///
|
||||
/// メインカラーとメインテクスチャをエクスポートする。
|
||||
/// </summary>
|
||||
public class UrpFallbackMaterialExporter
|
||||
{
|
||||
public glTFMaterial ExportMaterial(Material src, ITextureExporter textureExporter)
|
||||
{
|
||||
var dst = new glTFMaterial
|
||||
{
|
||||
name = src.name,
|
||||
pbrMetallicRoughness = new glTFPbrMetallicRoughness(),
|
||||
};
|
||||
|
||||
dst.pbrMetallicRoughness.baseColorFactor = src.color.ToFloat4(ColorSpace.sRGB, ColorSpace.Linear);
|
||||
var index = textureExporter.RegisterExportingAsSRgb(src.mainTexture, false);
|
||||
if (index >= 0)
|
||||
{
|
||||
dst.pbrMetallicRoughness.baseColorTexture = new glTFMaterialBaseColorTextureInfo
|
||||
{
|
||||
index = index,
|
||||
texCoord = 0,
|
||||
};
|
||||
GltfMaterialExportUtils.ExportTextureTransform(src.mainTextureOffset, src.mainTextureScale, dst.pbrMetallicRoughness.baseColorTexture);
|
||||
}
|
||||
|
||||
return dst;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c0269be076674f5988895ecd61b8d316
|
||||
timeCreated: 1722612454
|
||||
Loading…
Reference in New Issue
Block a user