Add pbr swatch feature to layers tab

This commit is contained in:
MathemanFlo
2022-03-10 08:43:52 +01:00
parent 478c5227f5
commit 273d6a2c23
3 changed files with 8 additions and 5 deletions
+4 -1
View File
@@ -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);
+2 -2
View File
@@ -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);
}
+2 -2
View File
@@ -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();
}