Pixel paint tools

This commit is contained in:
luboslenco
2019-08-06 17:37:44 +02:00
parent 7706251afc
commit ef3fe71b5b
8 changed files with 64 additions and 27 deletions
+24 -16
View File
@@ -129,31 +129,39 @@ class Config {
public static function getTextureRes():Int {
var resHandle = UITrait.inst.resHandle;
if (resHandle.position == 0) return 1024;
if (resHandle.position == 1) return 2048;
if (resHandle.position == 2) return 4096;
if (resHandle.position == 3) return 8192;
if (resHandle.position == 4) return 16384;
if (resHandle.position == 0) return 128;
if (resHandle.position == 1) return 256;
if (resHandle.position == 2) return 512;
if (resHandle.position == 3) return 1024;
if (resHandle.position == 4) return 2048;
if (resHandle.position == 5) return 4096;
if (resHandle.position == 6) return 8192;
if (resHandle.position == 7) return 16384;
return 0;
}
public static function getTextureResBias():Float {
var resHandle = UITrait.inst.resHandle;
if (resHandle.position == 0) return 2.0;
if (resHandle.position == 1) return 1.5;
if (resHandle.position == 2) return 1.0;
if (resHandle.position == 3) return 0.5;
if (resHandle.position == 4) return 0.25;
if (resHandle.position == 5) return 0.125;
if (resHandle.position == 0) return 16.0;
if (resHandle.position == 1) return 8.0;
if (resHandle.position == 2) return 4.0;
if (resHandle.position == 3) return 2.0;
if (resHandle.position == 4) return 1.5;
if (resHandle.position == 5) return 1.0;
if (resHandle.position == 6) return 0.5;
if (resHandle.position == 7) return 0.25;
return 1.0;
}
public static function getTextureResPos(i:Int):Int {
if (i == 1024) return 0;
if (i == 2048) return 1;
if (i == 4096) return 2;
if (i == 8192) return 3;
if (i == 16384) return 4;
if (i == 128) return 0;
if (i == 256) return 1;
if (i == 512) return 2;
if (i == 1024) return 3;
if (i == 2048) return 4;
if (i == 4096) return 5;
if (i == 8192) return 6;
if (i == 16384) return 7;
return 0;
}
}
+6
View File
@@ -1141,6 +1141,12 @@ class MaterialBuilder {
}
}
if (UITrait.inst.drawTexels) {
frag.add_uniform('float texpaintSize', '_texpaintSize');
frag.write('vec2 texel = texCoord * texpaintSize;');
frag.write('basecol *= max(float(mod(int(texel.x), 2.0) == mod(int(texel.y), 2.0)), 0.9);');
}
if (UITrait.inst.drawWireframe) {
// GL_NV_fragment_shader_barycentric
// VK_AMD_shader_explicit_vertex_parameter
+4 -1
View File
@@ -32,11 +32,14 @@ class MaterialParser {
var con = MaterialBuilder.make_mesh(new CyclesShaderData({name: "Material", canvas: null}));
if (sc != null) sc.delete();
sc = new ShaderContext(con.data, function(sc:ShaderContext){});
sc.overrideContext = {}
if (con.frag.sharedSamplers.length > 0) {
sc.overrideContext = {}
var sampler = con.frag.sharedSamplers[0];
sc.overrideContext.shared_sampler = sampler.substr(sampler.lastIndexOf(" ") + 1);
}
if (!UITrait.inst.textureFilter) {
sc.overrideContext.filter = "point";
}
m.shader.raw.contexts.push(sc.raw);
m.shader.contexts.push(sc);
Context.ddirty = 2;
+1 -1
View File
@@ -23,7 +23,7 @@ class TabExport {
if (ui.isHovered) ui.tooltip("Export texture files (Ctrl + Shift + E)");
ui.row([1/2, 1/2]);
ui.combo(UITrait.inst.resHandle, ["1K", "2K", "4K", "8K", "16K"], "Res", true);
ui.combo(UITrait.inst.resHandle, ["128", "256", "512", "1K", "2K", "4K", "8K", "16K"], "Res", true);
if (UITrait.inst.resHandle.changed) {
iron.App.notifyOnRender(Layers.resizeLayers);
UVUtil.uvmap = null;
+11 -5
View File
@@ -134,6 +134,17 @@ class TabPreferences {
ui.combo(UITrait.inst.hsupersample, ["1.0x", "1.5x", "2.0x", "4.0x"], "Super Sample", true);
if (UITrait.inst.hsupersample.changed) Config.applyConfig();
ui.row([1/2, 1/2]);
var cullHandle = Id.handle({selected: UITrait.inst.culling});
UITrait.inst.culling = ui.check(cullHandle, "Cull Backfaces");
if (cullHandle.changed) {
MaterialParser.parseMeshMaterial();
}
var filterHandle = Id.handle({selected: UITrait.inst.textureFilter});
UITrait.inst.textureFilter = ui.check(filterHandle, "Filter Textures");
if (filterHandle.changed) {
MaterialParser.parseMeshMaterial();
}
ui.row([1/2, 1/2]);
ui.check(UITrait.inst.hvxao, "Voxel AO");
if (ui.isHovered) ui.tooltip("Cone-traced AO and shadows");
if (UITrait.inst.hvxao.changed) Config.applyConfig();
@@ -144,11 +155,6 @@ class TabPreferences {
if (UITrait.inst.hbloom.changed) Config.applyConfig();
ui.check(UITrait.inst.hssr, "SSR");
if (UITrait.inst.hssr.changed) Config.applyConfig();
var cullHandle = Id.handle({selected: UITrait.inst.culling});
UITrait.inst.culling = ui.check(cullHandle, "Cull Backfaces");
if (cullHandle.changed) {
MaterialParser.parseMeshMaterial();
}
}
ui.separator();
+8 -3
View File
@@ -72,10 +72,12 @@ class TabViewport {
ui.g.begin(false);
MaterialParser.parseMeshMaterial();
}
var compassHandle = Id.handle({selected: UITrait.inst.showCompass});
UITrait.inst.showCompass = ui.check(compassHandle, "Compass");
if (compassHandle.changed) Context.ddirty = 2;
UITrait.inst.drawTexels = ui.check(UITrait.inst.texelsHandle, "Texels");
if (UITrait.inst.texelsHandle.changed) {
MaterialParser.parseMeshMaterial();
}
ui.row([1/2, 1/2]);
UITrait.inst.showEnvmap = ui.check(UITrait.inst.showEnvmapHandle, "Envmap");
if (UITrait.inst.showEnvmapHandle.changed) {
var world = Scene.active.world;
@@ -83,6 +85,9 @@ class TabViewport {
UITrait.inst.savedEnvmap = world.envmap;
Context.ddirty = 2;
}
var compassHandle = Id.handle({selected: UITrait.inst.showCompass});
UITrait.inst.showCompass = ui.check(compassHandle, "Compass");
if (compassHandle.changed) Context.ddirty = 2;
if (UITrait.inst.showEnvmap) {
UITrait.inst.showEnvmapBlur = ui.check(UITrait.inst.showEnvmapBlurHandle, "Blurred");
+4 -1
View File
@@ -76,7 +76,10 @@ class UITrait {
public var showEnvmapBlurHandle = new Handle({selected: false});
public var drawWireframe = false;
public var wireframeHandle = new Handle({selected: false});
public var drawTexels = false;
public var texelsHandle = new Handle({selected: false});
public var culling = true;
public var textureFilter = true;
public var ui:Zui;
public var colorIdHandle = Id.handle();
@@ -181,7 +184,7 @@ class UITrait {
public var symZ = false;
public var showCompass = true;
public var fillTypeHandle = new Handle();
public var resHandle = new Handle({position: 1}); // 2048
public var resHandle = new Handle({position: 4}); // 2048
public var bitsHandle = new Handle({position: 0}); // 8bit
var newConfirm = false;
public var projectType = 0; // paint, material
+6
View File
@@ -111,7 +111,13 @@ class UIView2D {
var th = tw;
if (tex != null) {
th = tw * (tex.height / tex.width);
if (!UITrait.inst.textureFilter) {
ui.g.imageScaleQuality = kha.graphics2.ImageScaleQuality.Low;
}
ui.g.drawScaledImage(tex, tx, ty, tw, th);
if (!UITrait.inst.textureFilter) {
ui.g.imageScaleQuality = kha.graphics2.ImageScaleQuality.High;
}
}
ui.g.pipeline = null;