07ustomize on on-PBR to PBatataterials 07onversion önce 3D cencenes GLTF 2.0 Format C#

Non-PBto to PBerial erial aterial erial onversion

This C# kod örneği, malzemeyi PBmaterial malzemeye nasıl dönüştüreceğinizi gösterir ve 3D görüntüsünü GLTF formatında C# 076481 481 dosya manipülasyonu ve dönüşüm 076481 481 ile kaydeder:

C#

 // initialize a new 3D scene

var s = new Scene();

var box = new Box();

s.RootNode.CreateChildNode("box1", box).Material = new PhongMaterial() {DiffuseColor = new Vector3(1, 0, 1)};

GLTFSaveOptions opt = new GLTFSaveOptions(FileFormat.GLTF2);

//Custom material converter to convert PhongMaterial to PbrMaterial

opt.MaterialConverter = delegate(Material material)

{

    PhongMaterial m = (PhongMaterial) material;

    return new PbrMaterial() {Albedo = new Vector3(m.DiffuseColor.x, m.DiffuseColor.y, m.DiffuseColor.z)};

};

// save in GLTF 2.0 format

s.Save("test.gltf", opt);