don-tnowe / godot-sprite-painter

Image editor right inside Godot 4.
MIT License
79 stars 8 forks source link

Images can't be edited from File System in New Projects #2

Open Ark2000 opened 1 year ago

Ark2000 commented 1 year ago

sprite_painter_bug.webm

Ark2000 commented 1 year ago

neither the eraser tool.

don-tnowe commented 1 year ago

Bug; editing of textures from the File System (rather than in an object on the scene) currently doesn't work. As a workaround, try placing your image into a Sprite and selecting the new sprite.

It looks like different behavior from when I worked with it. Or not, but I'll take note of this. Thanks!

don-tnowe commented 1 year ago

Looked more into this. Images can't be edited properly if they don't have alpha. If you undo after it goes black, the area you painted in comes back

There needs to be a way to change an image's format into one with alpha support, but I couldn't find it in my short search. Need to seek solutions later

seafiish commented 1 year ago

Throwing in my two cents. I was looking into older Godot sprite editor plugins (Godoxel, Sprite Editor), and it seems like Godoxel uses RGBA8 format. Sprite Editor has no mention of format somehow.

image

I rooted around some more and other examples of image creation in Godoxel set the format to RGBA8 as well. I think Godoxel does have alpha support. I have no idea if Godot 4 changed formatting API.

I still have a lot to learn and I'm not 100% sure what the problem is so I realize this may not be helpful at all, but I hope it helps in some way! I love the plugin btw :D

don-tnowe commented 1 year ago

Yep, RGBA8 supports alpha, but RGB8 does not. However, images saved from other software will use the no-alpha format if there is, well, no alpha. image.create() lets you choose format, but I'm loading not creating, and load_png does not.

I'd convert, but there seems to be no easy way in Godot. Methods creating images from other images take an array of bytes, and the same image in different formats has different raw data. blit_rect copy-pastes a rectange or the whole image, but requires same format, too.

When I can, I'll try manually editing the byte array. RGBA8 and RGB is just 4 bytes vs. 3 bytes per pixel... right?...

seafiish commented 1 year ago

Some strange behavior to report. I was tinkering around and suddenly the Godot icon.svg broke. It wouldn't let me draw like Ark observed. I also noticed it wouldn't let me pan around, and when I tried to increase the border size by 1 the entire canvas disappeared.

When I tried messing around more, it crashed. I can't open the project again. Okay, fresh project, new install. Try to enable plugin, it crashes. I delete both projects and make another one with another install. Same thing. It appears to be unusable for me now for some reason

seafiish commented 1 year ago

Back with more to report. Updated to Godot 4.0.2 (from 4.0.1). I can use it now. I assume this is just because it's a fresh Godot install

Here's my findings: (All my settings are the default out-of-the-box, except I have my Blender path defined)

Issues with SVGs:

The Godot icon.svg should have alpha, (it has the rounded corners so there's some transparency), but I'm having the same issue Ark described.

Issues with PNGs:

https://user-images.githubusercontent.com/118695973/233219505-89a038c4-c818-45cd-a6d7-1954e314ed5d.mp4

I had another minor crash issue while messing with the full-white image, but I didn't need to do another Godot install.

I'm new to bug reporting so apologies if I could have done something better, but I hope this is helpful! ^^

don-tnowe commented 1 year ago

🤨 you can't edit SVG files. This is a raster editor! They can be loaded because they're converted to raster by Godot - they can theoretically be converted (plugin saves in .png) but that results in data loss, I might later add a prompt to convert to PNG.

The no-panning/no-editing issue is possible for PNG, I don't know why it happens because I just checked and it doesn't break if you open from FileSystem. That's in the example project - on new projects it broke for me

seafiish commented 1 year ago

Aha! I wondered if that was what was going on. I know Godot rasterizes them though so I figured I would still document my findings.

Hmm. If that's the case you should probably remove svg loading support entirely or put up a warning if someone does. Just my two cents though

don-tnowe commented 1 year ago

Alpha issue fixed by 216c6c1b0f07f47e6612524c164137e1e59f5283 . Need reliable reproduction of the no-edit-from-filesystem issue.