rj-action-library/Runtime/Procedural/Baking/MultiBakeModeBillboardBase.cs

53 lines
1.5 KiB
C#

using System.Collections;
using System.Collections.Generic;
using Godot;
using System;
using System.Threading.Tasks;
namespace Rokojori
{
public abstract class MultiBakeModeBillboardBase:MultiBakeModeImplementation
{
public override void CreateMaterial( bool preview )
{
var mb = multiBaker;
var material = new StandardMaterial3D();
material.ShadingMode = preview ? BaseMaterial3D.ShadingModeEnum.Unshaded : BaseMaterial3D.ShadingModeEnum.PerPixel;
material.Transparency = BaseMaterial3D.TransparencyEnum.AlphaScissor;
material.AlphaScissorThreshold = 0.5f;
material.AlphaAntialiasingMode = BaseMaterial3D.AlphaAntiAliasing.AlphaToCoverageAndToOne;
material.AlphaAntialiasingEdge = 0.3f;
material.NormalEnabled = ! preview;
Materials.Set( mb.X_outputMesh, material );
}
public override void AssignMaterial( BakingMaterialMode mode, Texture2D texture )
{
var mb = multiBaker;
mb.CacheTexture( mode, texture );
var material = Materials.Get<StandardMaterial3D>( mb.X_outputMesh );
if ( BakingMaterialMode.Albedo == mode || BakingMaterialMode.Preview == mode )
{
RJLog.Log( "Assign albedo" );
material.AlbedoTexture = texture;
}
else if ( BakingMaterialMode.Normals == mode )
{
RJLog.Log( "Assign normal" );
material.NormalTexture = texture;
}
else if ( BakingMaterialMode.ORM == mode )
{
material.OrmTexture = texture;
}
}
}
}