• Edited

jonSS That's not how things work.

The only thing you can get from the main viewport are the literal pixels you see on the screen. There's no other data stored there. If something is "drawn" out of the screen, it gets clipped away. It doesn't exist for retrieval. If your view is zoomed, you get pixels of the zoomed image, etc... The main viewport is not a "viewport container" for some larger viewport that magically stores everything you draw at its maximal size.

So if you want to reconstruct a full image of all existing tiles in your map, you'll have to maintain your own tilemap-like data structure that holds coordinates of all "drawn" tiles and references to their original image data, and then blit original image pixels into your final exported image. You can't retrieve that from just what's drawn on the screen, except in rare situations where everything you need is contained within the screen and zoomed exactly 1:1.

Since Godot's TileMap maintains precisely such data structure (among other things), it's be best to just use that instead of reinventing the wheel by making your own clunkier version of it. Especially if you're not well versed in using and combining common data structures.

    xyz Then how would you convert the godot4 tileMap to a png image, or any other " .get_texture().get_image() "
    The godot 4 tileMap doesnt work very well with blur/pixelatte shaders. To work it needs to be inside a viewPort.
    Wont the same problem accour if trying to copy the entire tileMap on screen has an image ?

    • xyz replied to this.
      • Edited

      jonSS The real question is why would you want to convert the entire tilemap to a single image. It doesn't make sense because the whole purpose of tilemaps is precisely to avoid dealing with large images by breaking them down into pieces. If you want to render a blurred tilemap - use a post processing blur shader. It should work equally well with whatever is on the screen.

        xyz theres more options, in doing it this way...
        like for example change the mouse image color/effects etc... It works like a brush in photoshop.
        I tried and i cant get the colors right in a normal tileMap i would have to draw the same wall tiles multiple times, for each diferent color.
        ( not the color of the entire tileMap, the tiles in the mouse icon )

        • xyz replied to this.

          jonSS theres more options, in doing it this way...

          "This way" meaning what exactly?

            xyz Having 1 image in the mouse icon that you manipulate like a brush.
            like ex:
            change color,
            use a shader on it,
            transform size,
            etc... Everything you do on photoshop with a pencil.

            The tileMap in godot 3.5 was one of the best it seems... And the one in godot4 only got flip/rotate at end of 3 years...
            Ask the guys who made those tileSet's to add this option's in their tileMaps. ( Iam sure they re gonna love it. )
            Make an improvement proposal on github with little hearts and kisses... lol

            • xyz replied to this.
              • Edited

              jonSS Having 1 image in the mouse icon that you manipulate like a brush.
              like ex:
              change color,
              use a shader on it,
              transform size,
              etc... Everything you do on photoshop with a pencil.

              You can do all this with sprites. Having all that stuff in a tilemap would make it much less optimized, and in fact it would become so generalized that that you couldn't call it a tilemap any more. The whole point of tilemaps is to trade limitations for optimizations.

                xyz I know... But its easier for me to draw the levels this way, and faster
                Photoshop doesnt give me the option to draw with tileMaps this way... At least i dont know how to get it working on photoshop. And the user doesnt have to switch between programs.

                plus... using blur shaders and color shaders on the gd4 tileMap takes a lot of effort, and apllying it to the brush ( mouse tiles ) is not possible.

                • xyz replied to this.
                  • Edited

                  jonSS Not sure I understand what exactly you're trying to achieve with all this. Maybe give some visual examples.

                    • Edited

                    xyz Ive already did, multiple times... There's not much i can do ?
                    I have the 1st working example on github. ( still havent upLoad the one with working layers and inspector menus, but theres not much of a diference )
                    https://github.com/jonSP12/TileDrawPlugIN_test01.git

                    The script image.gd, that is were he gets the image that its on the mouse icon.
                    the script tileDrawNode.gd that is were the "Lnum" is being made. He breaks that image into tiles and draws them on screen... The dictionary keys arent always increasing.. If 1 key "coords" is for example ( 96,160 ) , and the user presses on mouse in those same "coords" ( 96,160 ) the image is replace... Just like adding a value with the same "key" to a normal dictionary...

                    Ive made a global script, " res://addons/tiledrawtest2/global.gd " and theres a lot of confusion in there, because i didnt knew how plugINs would work... But its easly fixed i just have to start a new one, once i figured out this editor viewport problem.

                    • xyz replied to this.
                      • Edited

                      jonSS No, I meant some existing game example that shows what you want to do.

                      If you want to make your custom tile map system with features that are not covered by Godot's TileMap node you'll likely need to go gdextension route and implement it as a new node type. Tilemaps typically need a lot of brute force iteration over cells which is best done in native code for performance reasons.

                      In principle, it's doable in a way I described earlier. You'll need a custom cell data struct that holds all relevant data for a cell (position, texture, rotation, scale, modulate, effects etc), and then store a list of such data structs for all populated cells. Manipulate data in this list to achieve what you need. You'll also have to maintain additional similarly structured list for a selection/brush if you want to paint with cell "brushes" consisting of multiple cells or do copy-paste like operations.

                      For exporting the whole map as a single image, you'll need to rasterize/blit cells into a big output bitmap. For small maps it can be done by the gpu rendering but if total size exceeds the maximal size of the hardware texture (which is quite likely to happen), you'll have to rasterize "manually" on the cpu, or break it down into multiple images that don't exceed gpu size limit.

                      It's all about handling data; structs, arrays, dicts. Nothing of use happens in a computer without those guys.

                        • Edited

                        xyz I cant do it that way... Just for the colors its an almost infinite number.
                        In the node plugIN "tileDraw" the tiles dont exists... They only exist when they are drawn on to editor.

                        For me... To do such a thing in a normal tileMap would be the same has having the same tilesheet 30x 50x times, for each 30x 50x diferent color.
                        I understand the way you are explaining... add an extra field in the dataBase, apart from "coords" , " img " , another for "color" , " shader " etc...

                        But its very limited... It leads to the same problem the tileMap in gd4 is having... And was having before when the flip/rotate was being added.

                        In my tileMap the tiles come from the image on the mouse icon ( that is an imageRegion, from the entire image on the dock ), once the user presses the mouse, the tiles are added/replace on the "Lnum" list and are drawn on the screen...

                        I cant have limitations, like make a normal tileMap and keep increasing the dictionary list, ( lets say that for example someone would want to add a water or ripple shader )

                        The plugIN that i have its working fine... The only thing missing is to add buttons to change the ( mouse icon image ) color/blur/pixelatte...etc...

                        The only problem iam having is giving the user the oportunity to copy an image region on to the mouse icon from the editor viewPort....
                        This is the only thing that is not working, and i cant get it... Other than that its works perfectly fine, and i bet that is much faster than the current gd4 tileMap... And any other tileMap ever made... Mine its not a tileMap, its TileDraw, its diferent... maybe i should name it "drawSquares" or "drawShapes" ?!?

                        Com'on i just need a way to get that thing that its on the editor viewport ( the image )

                        • xyz replied to this.
                          • Edited

                          jonSS I understand the way you are explaining...

                          I don't think you do.

                          jonSS Com'on i just need a way to get that thing on the editor viewport

                          As I said, that's not how things work. Although it may look to you from your perspective that it's "just" this little thing, to do what you want a lot things need to be handled quite differently under the hood.

                          • Best Answerset by jonSS

                          jonSS Anyway, this is dragging too long and too wide. Your actual question from the title has been answered. And I additionally suggested several possible approaches for your overall problem. Mark the question answered and if you have another specific problem - start a new thread.

                          Ive made 3 new vars, just for the select rectangle...

                          		Select_mXG = snapped(  get_global_mouse_position().x, 32 );
                          		Select_mYG = snapped(  get_global_mouse_position().y, 32 );
                          		Select_mG_all = Vector2(Select_mXG, Select_mYG);

                          The "mgPos2" its the same position being used on the "Lnum" list key: "coords" but i cant bypass the editor camera, the image is never right