Shader fixes

This commit is contained in:
luboslenco
2019-06-06 12:54:44 +02:00
parent 3a1e826fd3
commit e558a7bd7a
10 changed files with 134 additions and 64 deletions
+3 -3
View File
@@ -355,12 +355,12 @@ class App extends iron.Trait {
var isPicker = UITrait.inst.selectedTool == ToolPicker;
Zui.alwaysRedrawWindow =
showMenu ||
isDragging ||
(!UITrait.inst.brush3d) ||
showBox ||
isDragging ||
isPicker ||
UIView2D.inst.show ||
decal ||
UIView2D.inst.show ||
!UITrait.inst.brush3d ||
UITrait.inst.frame < 3;
if (Zui.alwaysRedrawWindow && UITrait.inst.ddirty < 0) UITrait.inst.ddirty = 0;
}
+2 -1
View File
@@ -186,7 +186,8 @@ class RenderPathDeferred {
lastY = mouse.y;
if (!UITrait.inst.dirty()) {
if (mx != lastX || my != lastY || UITrait.inst.ddirty > -2 || mouse.locked) {
if (mx != lastX || my != lastY || mouse.locked) UITrait.inst.ddirty = 0;
if (UITrait.inst.ddirty > -2) {
path.setTarget("");
path.bindTarget(taaFrame % 2 == 0 ? "taa" : "taa2", "tex");
ssaa4 ?
+3 -3
View File
@@ -211,12 +211,12 @@ class UIMenu {
g.begin(false);
}
public static function show(commands:Zui->Void = null) {
public static function show(commands:Zui->Void = null, x = -1, y = -1) {
var uibox = App.uibox;
App.showMenu = true;
menuCommands = commands;
menuX = Std.int(iron.App.x() + iron.system.Input.getMouse().x);
menuY = Std.int(iron.App.y() + iron.system.Input.getMouse().y);
menuX = x > -1 ? x : Std.int(iron.App.x() + iron.system.Input.getMouse().x);
menuY = y > -1 ? y : Std.int(iron.App.y() + iron.system.Input.getMouse().y);
var menuw = uibox.ELEMENT_W() * 1.5;
if (menuX + menuw > kha.System.windowWidth()) {
menuX = Std.int(kha.System.windowWidth() - menuw);
+64 -55
View File
@@ -238,61 +238,7 @@ class UINodes extends iron.Trait {
}
// Node search popup
if (keyboard.started("space")) {
var searchHandle = Id.handle();
var first = true;
UIMenu.show(function(ui:Zui) {
ui.fill(0, 0, ui._w / ui.SCALE, ui.t.ELEMENT_H * 8, ui.t.WINDOW_BG_COL);
ui.textInput(searchHandle, "");
ui.changed = false;
if (first) {
first = false;
ui.startTextEdit(searchHandle); // Focus search bar
ui.textSelectedCurrentText = searchHandle.text;
searchHandle.text = "";
nodeSearchLast = "";
}
var search = ui.textSelectedCurrentText.toLowerCase();
if (searchHandle.text != "") search = searchHandle.text;
if (search != nodeSearchLast) {
nodeSearchOffset = 0;
nodeSearchLast = search;
}
if (ui.isKeyDown) { // Move selection
if (ui.key == kha.input.KeyCode.Down && nodeSearchOffset < 6) nodeSearchOffset++;
if (ui.key == kha.input.KeyCode.Up && nodeSearchOffset > 0) nodeSearchOffset--;
}
var enter = keyboard.down("enter");
var count = 0;
var BUTTON_COL = ui.t.BUTTON_COL;
for (list in NodeCreator.list) {
for (n in list) {
if (n.name.toLowerCase().indexOf(search) >= 0) {
ui.t.BUTTON_COL = count == nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.WINDOW_BG_COL;
if (ui.button(n.name, Left) || (enter && count == nodeSearchOffset)) {
nodeSearchSpawn = makeNode(n, nodes, canvas); // Spawn selected node
canvas.nodes.push(nodeSearchSpawn);
nodes.nodesSelected = [nodeSearchSpawn];
nodes.nodesDrag = true;
hwnd.redraws = 2;
if (enter) {
ui.changed = true;
count = 6; // Trigger break
}
}
if (++count > 6) break;
}
}
if (count > 6) break;
}
if (enter && count == 0) { // Hide popup on enter when node is not found
ui.changed = true;
searchHandle.text = "";
}
ui.t.BUTTON_COL = BUTTON_COL;
});
}
if (keyboard.started("space")) nodeSearch();
if (nodeSearchSpawn != null) {
ui.inputX = mouse.x + App.x(); // Fix inputDX after popup removal
ui.inputY = mouse.y + App.y();
@@ -300,6 +246,64 @@ class UINodes extends iron.Trait {
}
}
function nodeSearch(x = -1, y = -1) {
var keyboard = iron.system.Input.getKeyboard();
var searchHandle = Id.handle();
var first = true;
UIMenu.show(function(ui:Zui) {
ui.fill(0, 0, ui._w / ui.SCALE, ui.t.ELEMENT_H * 8, ui.t.WINDOW_BG_COL);
ui.textInput(searchHandle, "");
ui.changed = false;
if (first) {
first = false;
ui.startTextEdit(searchHandle); // Focus search bar
ui.textSelectedCurrentText = searchHandle.text;
searchHandle.text = "";
nodeSearchLast = "";
}
var search = ui.textSelectedCurrentText.toLowerCase();
if (searchHandle.text != "") search = searchHandle.text;
if (search != nodeSearchLast) {
nodeSearchOffset = 0;
nodeSearchLast = search;
}
if (ui.isKeyDown) { // Move selection
if (ui.key == kha.input.KeyCode.Down && nodeSearchOffset < 6) nodeSearchOffset++;
if (ui.key == kha.input.KeyCode.Up && nodeSearchOffset > 0) nodeSearchOffset--;
}
var enter = keyboard.down("enter");
var count = 0;
var BUTTON_COL = ui.t.BUTTON_COL;
var nodeList = canvasType == 0 ? NodeCreator.list : NodeCreatorBrush.list;
for (list in nodeList) {
for (n in list) {
if (n.name.toLowerCase().indexOf(search) >= 0) {
ui.t.BUTTON_COL = count == nodeSearchOffset ? ui.t.HIGHLIGHT_COL : ui.t.WINDOW_BG_COL;
if (ui.button(n.name, Left) || (enter && count == nodeSearchOffset)) {
var canvas = getCanvas();
nodeSearchSpawn = makeNode(n, nodes, canvas); // Spawn selected node
canvas.nodes.push(nodeSearchSpawn);
nodes.nodesSelected = [nodeSearchSpawn];
nodes.nodesDrag = true;
hwnd.redraws = 2;
if (enter) {
ui.changed = true;
count = 6; // Trigger break
}
}
if (++count > 6) break;
}
}
if (count > 6) break;
}
if (enter && count == 0) { // Hide popup on enter when node is not found
ui.changed = true;
searchHandle.text = "";
}
ui.t.BUTTON_COL = BUTTON_COL;
}, x, y);
}
public function getNodeX():Int {
var mouse = iron.system.Input.getMouse();
return Std.int((mouse.x + App.x() - wx - nodes.PAN_X()) / nodes.SCALE);
@@ -434,6 +438,11 @@ class UINodes extends iron.Trait {
}
}
ui._x += ew + 3;
ui._y = 3;
if (ui.button("Search")) nodeSearch(Std.int(ui._windowX + ui._x), Std.int(ui._windowY + ui._y));
if (ui.isHovered) ui.tooltip("(Space)");
ui.t.BUTTON_COL = BUTTON_COL;
}
+1 -1
View File
@@ -2485,7 +2485,7 @@ class UITrait extends iron.Trait {
}
function tabProperties() {
if (ui.tab(htab, 'Properties')) {
if (ui.tab(htab1, 'Properties')) {
if (selectedObject != null) {
var h = Id.handle();
+9
View File
@@ -0,0 +1,9 @@
#version 450
#include "../Shaders/compiled.inc"
in vec4 pos;
in vec2 nor;
out vec3 voxpositionGeom;
uniform mat4 W;
void main() {
voxpositionGeom = vec3(W * vec4(pos.xyz, 1.0)) / voxelgiHalfExtents;
}
+11
View File
@@ -0,0 +1,11 @@
#version 450
#extension GL_ARB_shader_image_load_store : enable
#include "../Shaders/compiled.inc"
#include "../Shaders/std/math.glsl"
#include "../Shaders/std/imageatomic.glsl"
in vec3 voxposition;
uniform layout(r8) writeonly image3D voxels;
void main() {
if (abs(voxposition.z) > 1.0 || abs(voxposition.x) > 1 || abs(voxposition.y) > 1) return;
imageStore(voxels, ivec3(voxelgiResolution * (voxposition * 0.5 + 0.5)), vec4(1.0));
}
+25
View File
@@ -0,0 +1,25 @@
#version 450
layout(triangles) in;
layout(triangle_strip) out;
layout(max_vertices=3) out;
in vec3 voxpositionGeom[];
out vec3 voxposition;
void main() {
vec3 p1 = voxpositionGeom[1] - voxpositionGeom[0];
vec3 p2 = voxpositionGeom[2] - voxpositionGeom[0];
vec3 p = abs(cross(p1, p2));
for (uint i = 0; i < 3; ++i) {
voxposition = voxpositionGeom[i];
if (p.z > p.x && p.z > p.y) {
gl_Position = vec4(voxposition.x, voxposition.y, 0.0, 1.0);
}
else if (p.x > p.y && p.x > p.z) {
gl_Position = vec4(voxposition.y, voxposition.z, 0.0, 1.0);
}
else {
gl_Position = vec4(voxposition.x, voxposition.z, 0.0, 1.0);
}
EmitVertex();
}
EndPrimitive();
}
+9
View File
@@ -0,0 +1,9 @@
#version 450
#include "../Shaders/compiled.inc"
in vec4 pos;
in vec2 nor;
out vec3 voxpositionGeom;
uniform mat4 W;
void main() {
voxpositionGeom = vec3(W * vec4(pos.xyz, 1.0)) / voxelgiHalfExtents;
}
+7 -1
View File
@@ -6,7 +6,6 @@ project.addLibrary("iron");
project.addLibrary("zui");
project.addLibrary("iron_format");
project.addShaders("compiled/Shaders/*.glsl", { noembed: false});
project.addShaders("compiled/Hlsl/*.glsl", { noprocessing: true, noembed: false });
project.addAssets("compiled/Assets/**", { notinlist: true , destination: "data/{name}" });
project.addAssets("compiled/Shaders/*.arm", { notinlist: true , destination: "data/{name}" });
project.addAssets("Bundled/data/**", { notinlist: true , destination: "data/{name}" });
@@ -54,6 +53,13 @@ project.addDefine('arm_data_dir');
project.addParameter('--macro include("arm.brushnode")');
project.addParameter('-dce full');
if (process.platform === 'win32') {
project.addShaders("compiled/Hlsl/*.glsl", { noprocessing: true, noembed: false });
}
else {
project.addShaders("compiled/Glsl/*.glsl", { noembed: false });
}
if (process.platform === 'win32') {
project.addAssets("Bundled/cmft/cmft.exe", { notinlist: true , destination: "data/{name}" });
}