From 273d6a2c2379e825f0ae9c94698f3d644df0a547 Mon Sep 17 00:00:00 2001 From: MathemanFlo Date: Thu, 10 Mar 2022 08:43:52 +0100 Subject: [PATCH] Add pbr swatch feature to layers tab --- Sources/arm/App.hx | 5 ++++- Sources/arm/Layers.hx | 4 ++-- Sources/arm/data/LayerSlot.hx | 4 ++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Sources/arm/App.hx b/Sources/arm/App.hx index 639c4737..0e6e3eb3 100644 --- a/Sources/arm/App.hx +++ b/Sources/arm/App.hx @@ -415,7 +415,10 @@ class App { TabMaterials.acceptSwatchDrag(dragSwatch); } else if (inLayers || inViewport) { - Layers.createColorLayer(dragSwatch.base.value); + var color = dragSwatch.base; + color.A = dragSwatch.opacity; + + Layers.createColorLayer(color.value, dragSwatch.occlusion, dragSwatch.roughness, dragSwatch.metallic); } else if (inSwatches) { TabSwatches.acceptSwatchDrag(dragSwatch); diff --git a/Sources/arm/Layers.hx b/Sources/arm/Layers.hx index 1c4e7aef..fade07cf 100644 --- a/Sources/arm/Layers.hx +++ b/Sources/arm/Layers.hx @@ -917,13 +917,13 @@ class Layers { Context.layerPreviewDirty = true; } - public static function createColorLayer(baseColor: Int) { + public static function createColorLayer(baseColor: Int, occlusion = 1.0, roughness = Layers.defaultRough, metallic = 0.0 ) { function _init() { var l = newLayer(false); History.newLayer(); l.uvType = UVMap; l.objectMask = Context.layerFilter; - l.clear(baseColor); + l.clear(baseColor, occlusion, roughness, metallic); } iron.App.notifyOnInit(_init); } diff --git a/Sources/arm/data/LayerSlot.hx b/Sources/arm/data/LayerSlot.hx index 7f5eb75b..615a58d4 100644 --- a/Sources/arm/data/LayerSlot.hx +++ b/Sources/arm/data/LayerSlot.hx @@ -165,7 +165,7 @@ class LayerSlot { } } - public function clear(baseColor = 0x00000000, baseImage: kha.Image = null) { + public function clear(baseColor = 0x00000000, baseImage: kha.Image = null, occlusion = 1.0, roughness = Layers.defaultRough, metallic = 0.0) { texpaint.g4.begin(); texpaint.g4.clear(baseColor); // Base texpaint.g4.end(); @@ -180,7 +180,7 @@ class LayerSlot { texpaint_nor.g4.clear(kha.Color.fromFloats(0.5, 0.5, 1.0, 0.0)); // Nor texpaint_nor.g4.end(); texpaint_pack.g4.begin(); - texpaint_pack.g4.clear(kha.Color.fromFloats(1.0, Layers.defaultRough, 0.0, 0.0)); // Occ, rough, met + texpaint_pack.g4.clear(kha.Color.fromFloats(occlusion, roughness, metallic, 0.0)); // Occ, rough, met texpaint_pack.g4.end(); }