Fix envmap handling for raytracing path

This commit is contained in:
luboslenco
2020-09-05 15:18:53 +02:00
parent 53bdcbee5d
commit b163d771a3
3 changed files with 12 additions and 10 deletions
+11
View File
@@ -74,6 +74,7 @@ class Context {
public static var savedEnvmap: Image = null;
public static var emptyEnvmap: Image = null;
public static var previewEnvmap: Image = null;
public static var envmapLoaded = false;
public static var showEnvmap = false;
public static var showEnvmapHandle = new Handle({selected: false});
public static var showEnvmapBlur = false;
@@ -375,4 +376,14 @@ class Context {
for (po in Project.paintObjects) if (po.children.length > 0) return po;
return Project.paintObjects[0];
}
public static function loadEnvmap() {
if (!envmapLoaded) {
// TODO: Unable to share texture for both radiance and envmap - reload image
envmapLoaded = true;
iron.data.Data.cachedImages.remove("World_radiance.k");
}
iron.Scene.active.world.loadEnvmap(function(_) {});
if (Context.savedEnvmap == null) Context.savedEnvmap = iron.Scene.active.world.envmap;
}
}
+1 -9
View File
@@ -33,7 +33,6 @@ class UIMenu {
static var changeStarted = false;
static var showMenuFirst = true;
static var hideMenu = false;
static var envmapLoaded = false;
@:access(zui.Zui)
public static function render(g: kha.graphics2.Graphics) {
@@ -184,14 +183,7 @@ class UIMenu {
Context.showEnvmap = ui.check(Context.showEnvmapHandle, " " + tr("Envmap"));
if (Context.showEnvmapHandle.changed) {
var world = Scene.active.world;
if (!envmapLoaded) {
// TODO: Unable to share texture for both radiance and envmap - reload image
envmapLoaded = true;
iron.data.Data.cachedImages.remove("World_radiance.k");
}
world.loadEnvmap(function(_) {});
if (Context.savedEnvmap == null) Context.savedEnvmap = world.envmap;
Context.loadEnvmap();
Context.ddirty = 2;
}
-1
View File
@@ -122,7 +122,6 @@ class UISidebar {
var world = Scene.active.world;
if (Context.savedEnvmap == null) {
// Context.savedEnvmap = world.envmap;
// defaultEnvmap = world.envmap;
Context.defaultIrradiance = world.probe.irradiance;
Context.defaultRadiance = world.probe.radiance;
Context.defaultRadianceMipmaps = world.probe.radianceMipmaps;