mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-04-26 08:39:34 -05:00
Fixes #2748 - Adjusted URP emissiveFactor analog to Built-in material
This commit is contained in:
parent
dd8c1d1539
commit
7a7ba6b9ad
|
|
@ -1,5 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering;
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
|
|
@ -174,7 +175,16 @@ namespace UniGLTF
|
||||||
{
|
{
|
||||||
if (!context.IsEmissionEnabled) return;
|
if (!context.IsEmissionEnabled) return;
|
||||||
|
|
||||||
dst.emissiveFactor = context.EmissionColorLinear.ToFloat3(ColorSpace.Linear, ColorSpace.Linear);
|
var emissiveFactor = context.EmissionColorLinear.ToFloat3(ColorSpace.Linear, ColorSpace.Linear);
|
||||||
|
// Unity uses HDR color for emission factor. Normalize it if any component is greater than 1.
|
||||||
|
// If not normalized, glTF validator throws an error "VALUE_NOT_IN_RANGE"
|
||||||
|
var maxComponent = emissiveFactor.Max();
|
||||||
|
if (maxComponent > 1)
|
||||||
|
{
|
||||||
|
emissiveFactor = emissiveFactor.Select(x => x / maxComponent).ToArray();
|
||||||
|
glTF_KHR_materials_emissive_strength.Serialize(ref dst.extensions, maxComponent);
|
||||||
|
}
|
||||||
|
dst.emissiveFactor = emissiveFactor;
|
||||||
if (context.EmissionTexture != null)
|
if (context.EmissionTexture != null)
|
||||||
{
|
{
|
||||||
var index = textureExporter.RegisterExportingAsSRgb(context.EmissionTexture, true);
|
var index = textureExporter.RegisterExportingAsSRgb(context.EmissionTexture, true);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user