Cloud asset icon cutout

This commit is contained in:
luboslenco
2021-01-16 16:48:33 +01:00
parent 7f820bf2d5
commit f3c2a60649
2 changed files with 25 additions and 2 deletions
+14
View File
@@ -31,6 +31,7 @@ class Layers {
public static var pipeCopy8: PipelineState;
public static var pipeCopy128: PipelineState;
public static var pipeCopyBGRA: PipelineState;
public static var pipeCopyRGB: PipelineState = null;
public static var pipeInvert8: PipelineState;
public static var pipeMask: PipelineState;
public static var tex0: TextureUnit;
@@ -218,6 +219,19 @@ class Layers {
texaMask = pipeMask.getTextureUnit("texa");
}
public static function makePipeCopyRGB() {
pipeCopyRGB = new PipelineState();
pipeCopyRGB.vertexShader = kha.Shaders.getVertex("layer_view.vert");
pipeCopyRGB.fragmentShader = kha.Shaders.getFragment("layer_copy.frag");
var vs = new VertexStructure();
vs.add("pos", VertexData.Float3);
vs.add("tex", VertexData.Float2);
vs.add("col", VertexData.Float4);
pipeCopyRGB.inputLayout = [vs];
pipeCopyRGB.colorWriteMasksAlpha = [false];
pipeCopyRGB.compile();
}
public static function makeCursorPipe() {
pipeCursor = new PipelineState();
pipeCursor.vertexShader = kha.Shaders.getVertex("cursor.vert");
+11 -2
View File
@@ -143,8 +143,17 @@ class UIFiles {
var abs = File.cacheCloud(handle.text + Path.sep + iconFile);
if (abs != null) {
iron.data.Data.getImage(abs, function(image: kha.Image) {
icon = image;
iconMap.set(handle.text + Path.sep + f, icon);
iron.App.notifyOnInit(function() {
if (Layers.pipeCopyRGB == null) Layers.makePipeCopyRGB();
icon = kha.Image.createRenderTarget(image.width, image.height);
icon.g2.begin(false);
icon.g2.drawImage(Project.materials[0].image, 0, 0); // Used for alpha cutout
icon.g2.pipeline = Layers.pipeCopyRGB;
icon.g2.drawImage(image, 0, 0);
icon.g2.pipeline = null;
icon.g2.end();
iconMap.set(handle.text + Path.sep + f, icon);
});
});
}
}