2D view
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#version 450
|
||||
|
||||
uniform sampler2D tex;
|
||||
in vec2 texCoord;
|
||||
in vec4 color;
|
||||
out vec4 FragColor;
|
||||
|
||||
|
||||
void main() {
|
||||
// Show basecolor
|
||||
vec4 texcolor = texture(tex, texCoord) * color;
|
||||
// texcolor.rgb *= color.a;
|
||||
FragColor = vec4(texcolor.rgb, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
#version 450
|
||||
|
||||
in vec3 vertexPosition;
|
||||
in vec2 texPosition;
|
||||
in vec4 vertexColor;
|
||||
uniform mat4 projectionMatrix;
|
||||
out vec2 texCoord;
|
||||
out vec4 color;
|
||||
|
||||
void main() {
|
||||
gl_Position = projectionMatrix * vec4(vertexPosition, 1.0);
|
||||
texCoord = texPosition;
|
||||
color = vertexColor;
|
||||
}
|
||||
+2
-1
@@ -55,6 +55,7 @@ class App extends iron.Trait {
|
||||
notifyOnRender2D(render);
|
||||
object.addTrait(new UITrait());
|
||||
object.addTrait(new UINodes());
|
||||
object.addTrait(new UIView2D());
|
||||
object.addTrait(new FlyCamera());
|
||||
object.addTrait(new OrbitCamera());
|
||||
});
|
||||
@@ -69,7 +70,7 @@ class App extends iron.Trait {
|
||||
if (UINodes.inst == null || UITrait.inst == null) {
|
||||
res = kha.System.windowWidth() - UITrait.defaultWindowW;
|
||||
}
|
||||
else if (UINodes.inst.show) {
|
||||
else if (UINodes.inst.show || UIView2D.inst.show) {
|
||||
res = Std.int((kha.System.windowWidth() - UITrait.inst.windowW) / 2);
|
||||
}
|
||||
else {
|
||||
|
||||
+10
-1
@@ -334,6 +334,7 @@ class UITrait extends iron.Trait {
|
||||
var kb = iron.system.Input.getKeyboard();
|
||||
var shift = kb.down("shift");
|
||||
if (kb.started("tab")) {
|
||||
UIView2D.inst.show = false;
|
||||
UINodes.inst.show = !UINodes.inst.show;
|
||||
arm.App.resize();
|
||||
}
|
||||
@@ -474,17 +475,25 @@ class UITrait extends iron.Trait {
|
||||
}
|
||||
|
||||
function showMaterialNodes() {
|
||||
UIView2D.inst.show = false;
|
||||
if (UINodes.inst.show && !UINodes.inst.isBrush) UINodes.inst.show = false;
|
||||
else { UINodes.inst.show = true; UINodes.inst.isBrush = false; }
|
||||
arm.App.resize();
|
||||
}
|
||||
|
||||
function showBrushNodes() {
|
||||
UIView2D.inst.show = false;
|
||||
if (UINodes.inst.show && UINodes.inst.isBrush) UINodes.inst.show = false;
|
||||
else { UINodes.inst.show = true; UINodes.inst.isBrush = true; }
|
||||
arm.App.resize();
|
||||
}
|
||||
|
||||
function show2DView() {
|
||||
UINodes.inst.show = false;
|
||||
UIView2D.inst.show = !UIView2D.inst.show;
|
||||
arm.App.resize();
|
||||
}
|
||||
|
||||
var outputType = 0;
|
||||
var isBase = true;
|
||||
var isOpac = true;
|
||||
@@ -890,7 +899,7 @@ class UITrait extends iron.Trait {
|
||||
|
||||
if (ui.panel(Id.handle({selected: true}), "Layers")) {
|
||||
if (ui.button("2D View")) {
|
||||
|
||||
show2DView();
|
||||
}
|
||||
// Picked color
|
||||
ui.image(iron.RenderPath.active.renderTargets.get("texpaint_colorid0").image, 0xffffffff, 64);
|
||||
|
||||
+48
-1
@@ -1,7 +1,54 @@
|
||||
package arm;
|
||||
|
||||
class UIView2D {
|
||||
import zui.*;
|
||||
|
||||
class UIView2D extends iron.Trait {
|
||||
|
||||
public static var inst:UIView2D;
|
||||
|
||||
public var show = false;
|
||||
public var wx:Int;
|
||||
public var wy:Int;
|
||||
public var ww:Int;
|
||||
|
||||
var pipe:kha.graphics4.PipelineState;
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
inst = this;
|
||||
|
||||
pipe = new kha.graphics4.PipelineState();
|
||||
pipe.fragmentShader = kha.Shaders.view2d_frag;
|
||||
pipe.vertexShader = kha.Shaders.view2d_vert;
|
||||
var vs = new kha.graphics4.VertexStructure();
|
||||
vs.add("vertexPosition", kha.graphics4.VertexData.Float3);
|
||||
vs.add("texPosition", kha.graphics4.VertexData.Float2);
|
||||
vs.add("vertexColor", kha.graphics4.VertexData.Float4);
|
||||
pipe.inputLayout = [vs];
|
||||
pipe.compile();
|
||||
|
||||
notifyOnRender2D(render2D);
|
||||
}
|
||||
|
||||
function render2D(g:kha.graphics2.Graphics) {
|
||||
ww = Std.int(iron.App.w());
|
||||
wx = Std.int(iron.App.w());
|
||||
wy = 0;
|
||||
|
||||
if (!show) return;
|
||||
|
||||
g.end();
|
||||
if (UINodes.inst.grid == null) UINodes.inst.drawGrid();
|
||||
g.begin(false);
|
||||
|
||||
g.color = 0xffffffff;
|
||||
g.drawImage(UINodes.inst.grid, wx, wy);
|
||||
|
||||
var tw = Std.int(iron.App.w() * 0.95);
|
||||
var tx = Std.int(iron.App.w() + (iron.App.w() - tw) / 2);
|
||||
var ty = Std.int(iron.App.h() / 2 - tw / 2);
|
||||
g.pipeline = pipe;
|
||||
g.drawScaledImage(UITrait.inst.texpaint, tx, ty, tw, tw);
|
||||
g.pipeline = null;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user