Custom envmap

This commit is contained in:
luboslenco
2018-10-11 12:19:13 +02:00
parent 806cb79071
commit bede391c8f
15 changed files with 196977 additions and 196316 deletions
View File
+2 -2
View File
@@ -1,2 +1,2 @@
CC0 environment maps courtesy of hdri haven
https://hdrihaven.com/
CC0 environment maps courtesy of hdri haven
https://hdrihaven.com/
@@ -1,26 +1,26 @@
Copyright 2014-2015 Dario Manesku. All rights reserved.
https://github.com/dariomanesku/cmft
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
https://github.com/dariomanesku/cmft/blob/master/LICENSE
Copyright 2014-2015 Dario Manesku. All rights reserved.
https://github.com/dariomanesku/cmft
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
https://github.com/dariomanesku/cmft/blob/master/LICENSE

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

@@ -1,15 +1,15 @@
Bomberman created by:
Rui Teixeira
Inspired by the livestream of:
Sebastian Cavazzoli (https://bit.ly/2JRyNPe)
Original concept by:
Lucas Lazora (https://bit.ly/2JsFKqv)
HDRI map from:
https://hdrihaven.com
Bomberman created by:
Rui Teixeira
Inspired by the livestream of:
Sebastian Cavazzoli (https://bit.ly/2JRyNPe)
Original concept by:
Lucas Lazora (https://bit.ly/2JsFKqv)
HDRI map from:
https://hdrihaven.com
+4 -2
View File
@@ -1,2 +1,4 @@
ArmorPaint - 3D PBR Texture Painting
https://armorpaint.org/manual/
Thank you for supporting ArmorPaint!
Quick start:
https://armorpaint.org/manual/
+196742 -196035
View File
File diff suppressed because it is too large Load Diff
+11
View File
@@ -68,6 +68,9 @@ class App {
uimodal = new Zui({ font: f, scaleFactor: armory.data.Config.raw.window_scale });
iron.App.notifyOnInit(function() {
// #if arm_debug
// iron.Scene.active.sceneParent.getTrait(armory.trait.internal.DebugConsole).visible = false;
// #end
iron.App.notifyOnUpdate(update);
iron.Scene.active.root.addTrait(new UITrait());
iron.Scene.active.root.addTrait(new UINodes());
@@ -228,6 +231,14 @@ class App {
}
uimodal.beginLayout(g, right - 100, bottom - 30, 100);
if (uimodal.button("OK")) {
showFiles = false;
filesDone(path);
UITrait.inst.dirty = 2;
}
uimodal.endLayout(false);
uimodal.beginLayout(g, right - 200, bottom - 30, 100);
if (uimodal.button("Cancel")) {
showFiles = false;
UITrait.inst.dirty = 2;
+15
View File
@@ -0,0 +1,15 @@
package arm;
import haxe.macro.Context;
class Macro {
macro public static function buildDate():ExprOf<String> {
return Context.makeExpr(Date.now().toString(), Context.currentPos());
}
macro public static function buildSha():ExprOf<String> {
var proc = new sys.io.Process('git', ['log', "--pretty=format:'%h'", '-n', '1']);
return Context.makeExpr(proc.stdout.readLine(), Context.currentPos());
}
}
+162 -60
View File
@@ -459,7 +459,7 @@ class UITrait extends iron.Trait {
var scale = armory.data.Config.raw.window_scale;
ui = new Zui( { theme: arm.App.theme, font: arm.App.font, scaleFactor: scale, color_wheel: arm.App.color_wheel } );
loadBundled(['cursor.png', 'mat_slot.jpg', 'brush_draw.png', 'brush_erase.png', 'brush_fill.png', 'brush_bake.png', 'brush_colorid.png', 'cay_thumb.jpg'], done);
loadBundled(['cursor.png', 'mat_slot.jpg', 'brush_draw.png', 'brush_erase.png', 'brush_fill.png', 'brush_bake.png', 'brush_colorid.png', 'env_thumb.jpg'], done);
}
var haxeTrace:Dynamic->haxe.PosInfos->Void;
@@ -467,7 +467,7 @@ class UITrait extends iron.Trait {
function consoleTrace(v:Dynamic, ?inf:haxe.PosInfos) {
lastTrace = Std.string(v);
haxeTrace(v, inf);
}
}
function showMessage(s:String) {
messageTimer = 3.0;
@@ -500,6 +500,101 @@ class UITrait extends iron.Trait {
UITrait.inst.assetNames.push(name);
Canvas.assetMap.set(asset.id, image);
hwnd.redraws = 2;
// Set envmap, has to be 2K res for now
if (StringTools.endsWith(path.toLowerCase(), ".hdr") && image.width == 2048) {
#if kha_krom
var sys = kha.System.systemId;
var p = Krom.getFilesLocation() + '/' + iron.data.Data.dataPath;
var cmft = p + "/cmft" + (sys == "Windows" ? ".exe" : sys == "Linux" ? "-linux64" : "-osx");
var cmd = '';
var tmp = Krom.getFilesLocation() + '/';
// Irr
cmd = cmft;
cmd += ' --input "' + path + '"';
cmd += ' --filter shcoeffs';
cmd += ' --outputNum 1';
cmd += ' --output0 "' + tmp + 'tmp_irr"';
Krom.sysCommand(cmd);
// Rad
cmd = cmft;
cmd += ' --input "' + path + '"';
cmd += ' --filter radiance';
cmd += ' --dstFaceSize 256';
cmd += ' --srcFaceSize 256';
cmd += ' --excludeBase false';
cmd += ' --glossScale 8';
cmd += ' --glossBias 3';
cmd += ' --lightingModel blinnbrdf';
cmd += ' --edgeFixup none';
cmd += ' --numCpuProcessingThreads 4';
cmd += ' --useOpenCL true';
cmd += ' --clVendor anyGpuVendor';
cmd += ' --deviceType gpu';
cmd += ' --deviceIndex 0';
cmd += ' --generateMipChain true';
cmd += ' --inputGammaNumerator 1.0';
cmd += ' --inputGammaDenominator 1.0';
cmd += ' --outputGammaNumerator 1.0';
cmd += ' --outputGammaDenominator 1.0';
cmd += ' --outputNum 1';
cmd += ' --output0 "' + tmp + 'tmp_rad"';
cmd += ' --output0params hdr,rgbe,latlong';
Krom.sysCommand(cmd);
#end
// Load irr
iron.data.Data.getBlob(tmp + "tmp_irr.c", function(blob:kha.Blob) {
var lines = blob.toString().split("\n");
var band0 = lines[5];
var band1 = lines[6];
var band2 = lines[7];
band0 = band0.substring(band0.indexOf("{"), band0.length);
band1 = band1.substring(band1.indexOf("{"), band1.length);
band2 = band2.substring(band2.indexOf("{"), band2.length);
var band = band0 + band1 + band2;
band = StringTools.replace(band, "{", "");
band = StringTools.replace(band, "}", "");
var ar = band.split(",");
var buf = new kha.arrays.Float32Array(27);
for (i in 0...ar.length) buf[i] = Std.parseFloat(ar[i]);
iron.Scene.active.world.probe.irradiance = buf;
dirty = 2;
});
// World envmap
iron.Scene.active.world.envmap = image;
// Load mips
var mipsCount = 9;
var mipsLoaded = 0;
var mips:Array<kha.Image> = [];
while (mips.length < mipsCount + 2) mips.push(null);
var mw = 1024;
var mh = 512;
for (i in 0...mipsCount) {
iron.data.Data.getImage(tmp + "tmp_rad_" + i + "_" + mw + "x" + mh + ".hdr", function(mip:kha.Image) {
mips[i] = mip;
mipsLoaded++;
if (mipsLoaded == mipsCount) {
// 2x1 and 1x1 mips
mips[mipsCount] = kha.Image.create(2, 1, kha.graphics4.TextureFormat.RGBA128);
mips[mipsCount + 1] = kha.Image.create(1, 1, kha.graphics4.TextureFormat.RGBA128);
// Set radiance
image.setMipmaps(mips);
iron.Scene.active.world.probe.radiance = image;
dirty = 2;
// Update thumb
bundled.set("env_thumb.jpg", mips[0]);
}
}, true); // Readable
mw = Std.int(mw / 2);
mh = Std.int(mh / 2);
}
}
});
}
@@ -1199,7 +1294,7 @@ class UITrait extends iron.Trait {
if (arm.App.uienabled && !ui.inputRegistered) ui.registerInput();
// var brushImg = bundled.get('brush.jpg');
var envThumbCay = bundled.get('cay_thumb.jpg');
var envThumb = bundled.get('env_thumb.jpg');
var cursorImg = bundled.get('cursor.png');
var mouse = iron.system.Input.getMouse();
g.color = 0xffffffff;
@@ -1371,7 +1466,7 @@ class UITrait extends iron.Trait {
if (selectedObject.name == "Scene") {
selectedType = "(Scene)";
// ui.image(envThumbCay);
// ui.image(envThumb);
var p = iron.Scene.active.world.getGlobalProbe();
ui.row([1/2, 1/2]);
var envType = ui.combo(Id.handle({position: 0}), ["Outdoor"], "Map");
@@ -1529,59 +1624,59 @@ class UITrait extends iron.Trait {
brushScale = ui.slider(Id.handle({value: brushScale}), "UV Scale", 0.0, 2.0, true);
brushStrength = ui.slider(Id.handle({value: brushStrength}), "Strength", 0.0, 1.0, true);
}
}
if (ui.panel(Id.handle({selected: true}), "Paint Channels")) {
ui.row([1/3,1/3,1/3]);
if (ui.panel(Id.handle({selected: true}), "Paint Channels")) {
ui.row([1/3,1/3,1/3]);
var baseHandle = Id.handle({selected: paintBase});
paintBase = ui.check(baseHandle, "Base");
if (baseHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var norHandle = Id.handle({selected: paintNor});
paintNor = ui.check(norHandle, "Normal");
if (norHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var heightHandle = Id.handle({selected: paintHeight});
paintHeight = ui.check(heightHandle, "Height");
if (heightHandle.changed) {
for (l in layers) l.make_texpaint_opt();
for (l in undoLayers) l.make_texpaint_opt();
iron.App.notifyOnRender(initHeightLayer);
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
ui.row([1/3,1/3,1/3]);
var occHandle = Id.handle({selected: paintOcc});
paintOcc = ui.check(occHandle, "Occlusion");
if (occHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var roughHandle = Id.handle({selected: paintRough});
paintRough = ui.check(roughHandle, "Roughness");
if (roughHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var metHandle = Id.handle({selected: paintMet});
paintMet = ui.check(metHandle, "Metallic");
if (metHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
paintVisible = ui.check(Id.handle({selected: paintVisible}), "Visible Only");
var baseHandle = Id.handle({selected: paintBase});
paintBase = ui.check(baseHandle, "Base");
if (baseHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var norHandle = Id.handle({selected: paintNor});
paintNor = ui.check(norHandle, "Normal");
if (norHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var heightHandle = Id.handle({selected: paintHeight});
paintHeight = ui.check(heightHandle, "Height");
if (heightHandle.changed) {
for (l in layers) l.make_texpaint_opt();
for (l in undoLayers) l.make_texpaint_opt();
iron.App.notifyOnRender(initHeightLayer);
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
ui.row([1/3,1/3,1/3]);
var occHandle = Id.handle({selected: paintOcc});
paintOcc = ui.check(occHandle, "Occlusion");
if (occHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var roughHandle = Id.handle({selected: paintRough});
paintRough = ui.check(roughHandle, "Roughness");
if (roughHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
var metHandle = Id.handle({selected: paintMet});
paintMet = ui.check(metHandle, "Metallic");
if (metHandle.changed) {
UINodes.inst.updateCanvasMap();
UINodes.inst.parsePaintMaterial();
}
paintVisible = ui.check(Id.handle({selected: paintVisible}), "Visible Only");
}
if (ui.panel(Id.handle({selected: true}), "Material")) {
@@ -1685,7 +1780,7 @@ class UITrait extends iron.Trait {
if (ui.button("2D View")) show2DView();
}
if (ui.panel(Id.handle({selected: false}), "Viewport")) {
if (ui.panel(Id.handle({selected: false}), "Camera")) {
var scene = iron.Scene.active;
var cam = scene.cameras[0];
ui.row([1/2,1/2]);
@@ -1708,12 +1803,13 @@ class UITrait extends iron.Trait {
}
}
}
}
ui.text("Lighting");
ui.image(envThumbCay);
if (ui.panel(Id.handle({selected: false}), "Lighting")) {
ui.image(envThumb);
var p = iron.Scene.active.world.getGlobalProbe();
ui.row([1/2, 1/2]);
var envType = ui.combo(Id.handle({position: 0}), ["Indoor"], "Map");
var envType = ui.combo(Id.handle({position: 0}), ["Default"], "Map");
p.raw.strength = ui.slider(Id.handle({value: p.raw.strength}), "Environment", 0.0, 5.0, true);
ui.row([1/2, 1/2]);
@@ -1925,7 +2021,7 @@ class UITrait extends iron.Trait {
isHeight = ui.check(Id.handle({selected: isHeight}), "Height");
}
if (ui.tab(htab, "Prefs")) {
if (ui.tab(htab, "Preferences")) {
var hscale = Id.handle({value: armory.data.Config.raw.window_scale});
ui.slider(hscale, "UI Scale", 0.5, 4.0, true);
if (ui.changed && !iron.system.Input.getMouse().down()) {
@@ -1950,7 +2046,13 @@ class UITrait extends iron.Trait {
Krom.fileSaveBytes("data/config.arm", haxe.io.Bytes.ofString(haxe.Json.stringify(armory.data.Config.raw)).getData());
#end
}
ui.text("v0.5 armorpaint.org");
if (ui.panel(Id.handle({selected: false}), "About")) {
ui.text("v0.5");
ui.text(Macro.buildSha());
ui.text(Macro.buildDate());
ui.text("armorpaint.org");
}
if (ui.panel(Id.handle({selected: true}), "Console")) {
ui.text(lastTrace);
-176
View File
@@ -1,176 +0,0 @@
#!/bin/bash
#
# Copyright 2014-2015 Dario Manesku. All rights reserved.
# License: http://www.opensource.org/licenses/BSD-2-Clause
#
CMFT=./cmft-osx
# Prints help.
#eval $CMFT --help
# Use this to list available OpenCL devices that can be used with cmft for processing.
#eval $CMFT --printCLDevices
# Typical parameters for irradiance filter.
# eval $CMFT $@ --input "test.jpg" \
# --filter irradiance \
# --srcFaceSize 0 \
# --dstFaceSize 0 \
# --outputNum 1 \
# --output0 "test_irr" \
# --output0params hdr,rgbe,latlong
# Typical parameters for generating spherical harmonics coefficients.
eval $CMFT $@ --input "test.hdr" \
--filter shcoeffs \
--outputNum 1 \
--output0 "test"
# Typical parameters for radiance filter.
# eval $CMFT $@ --input "test.jpg" \
# ::Filter options \
# --filter radiance \
# --srcFaceSize 64 \
# --excludeBase false \
# --mipCount 7 \
# --glossScale 10 \
# --glossBias 3 \
# --lightingModel blinnbrdf \
# --edgeFixup none \
# --dstFaceSize 64 \
# ::Processing devices \
# --numCpuProcessingThreads 4 \
# --useOpenCL true \
# --clVendor anyGpuVendor \
# --deviceType gpu \
# --deviceIndex 0 \
# ::Aditional operations \
# --inputGammaNumerator 2.2 \
# --inputGammaDenominator 1.0 \
# --outputGammaNumerator 1.0 \
# --outputGammaDenominator 2.2 \
# --generateMipChain true \
# ::Output \
# --outputNum 1 \
# --output0 "envmap_rad" \
# --output0params hdr,rgbe,latlong \
# --output1 "okretnica_pmrem" \
# --output1params ktx,rgba8,cubemap
# Cmft can also be run without any processing filter. This can be used for performing image manipulations or exporting different image format.
#eval $CMFT $@ --input "okretnica.tga" \
# --filter none \
# ::Aditional operations \
# --inputGamma 1.0 \
# --inputGammaDenominator 1.0 \
# --outputGamma 1.0 \
# --outputGammaDenominator 1.0 \
# --generateMipChain true \
# ::Cubemap transformations \
# --posXrotate90 \
# --posXrotate180 \
# --posXrotate270 \
# --posXflipH \
# --posXflipV \
# --negXrotate90 \
# --negXrotate180 \
# --negXrotate270 \
# --negXflipH \
# --negXflipV \
# --posYrotate90 \
# --posYrotate180 \
# --posYrotate270 \
# --posYflipH \
# --posYflipV \
# --negYrotate90 \
# --negYrotate180 \
# --negYrotate270 \
# --negYflipH \
# --negYflipV \
# --posZrotate90 \
# --posZrotate180 \
# --posZrotate270 \
# --posZflipH \
# --posZflipV \
# --negZrotate90 \
# --negZrotate180 \
# --negZrotate270 \
# --negZflipH \
# --negZflipV \
# ::Output \
# --outputNum 1 \
# --output0 "okretnica_dds" \
# --output0params dds,bgra8,cubemap \
# Cmft with all parameters listed. This is mainly to have a look at what is all possible.
#eval $CMFT $@ --input "okretnica.tga" \
# ::Filter options \
# --filter radiance \
# --srcFaceSize 256 \
# --excludeBase false \
# --mipCount 7 \
# --glossScale 10 \
# --glossBias 3 \
# --lightingModel blinnbrdf \
# --edgeFixup none \
# --dstFaceSize 256 \
# ::Processing devices \
# --numCpuProcessingThreads 4 \
# --useOpenCL true \
# --clVendor anyGpuVendor \
# --deviceType gpu \
# --deviceIndex 0 \
# ::Aditional operations \
# --inputGamma 1.0 \
# --inputGammaDenominator 1.0 \
# --outputGamma 1.0 \
# --outputGammaDenominator 1.0 \
# --generateMipChain false \
# ::Cubemap transformations \
# --posXrotate90 \
# --posXrotate180 \
# --posXrotate270 \
# --posXflipH \
# --posXflipV \
# --negXrotate90 \
# --negXrotate180 \
# --negXrotate270 \
# --negXflipH \
# --negXflipV \
# --posYrotate90 \
# --posYrotate180 \
# --posYrotate270 \
# --posYflipH \
# --posYflipV \
# --negYrotate90 \
# --negYrotate180 \
# --negYrotate270 \
# --negYflipH \
# --negYflipV \
# --posZrotate90 \
# --posZrotate180 \
# --posZrotate270 \
# --posZflipH \
# --posZflipV \
# --negZrotate90 \
# --negZrotate180 \
# --negZrotate270 \
# --negZflipH \
# --negZflipV \
# ::Output \
# --outputNum 5 \
# --output0 "cmft_cubemap" --output0params dds,bgra8,cubemap \
# --output1 "cmft_hstrip" --output1params dds,bgra8,hstrip \
# --output2 "cmft_cubecross" --output2params ktx,rgba32f,hcross \
# --output3 "cmft_facelist" --output3params tga,bgra8,facelist \
# --output4 "cmft_latlong" --output4params hdr,rgbe,latlong
# eval $CMFT $@ --input "shrine.hdr" \
# --filter none \
# ::Output \
# --outputNum 1 \
# --dstFaceSize 0 \
# --output0 "test" \
# --output0params hdr,rgbe,latlong
BIN
View File
Binary file not shown.