All Questions

Community

FATNUT

Getting full TileMap UVs for dissolving and Dissolve Texture Size

Hi Nathan,

I'm trying to dissolve a TileMap, so I can make procedural platforms with it, that dissolve / break.

I haven't found much info on getting the full UVs from the USED tiles in a Map, so the shader dissolves each tile individually, as seen in the image (middle of the tilemap gets dissolved)

I tried this approach:
https://godotengine.org/qa/90483/shader-how-coordinates-texture-the-coordinates-tile-tileset
but since my TileMap script is a tool, it couldn't get this code to run normally (tried printing on the ready() function with no success.

Is there a standard way to get the full UVs, or to convert the TileMap cells into 1 Sprite?
Also, the dissolve texture is only 16x16 pixels, as I want the dissolving to be the same resolution as the player sprite, is there a way to have the texture be absolute / not scale?

(This issue does not have high priority, as I can work on othes features, in case you have your hands full with the Kickstarter Project)

Thank you


Best
FATNUT

  • GDQuestions replied

    The general solution to this problem (applying a shader to the result of multiple sprites baked into one texture) is using a Viewport inside a ViewportContainer. You put your tilemap(s) inside the viewport, with an appropriate camera, and the whole thing will get rendered as one texture displayed by the ViewportContainer.

    You can then apply your shader to the ViewportContainer.

    But in your case, I would try to work with the SCREEN_UV instead of UV, as the coordinates are relative to the whole screen rather than each tile.

    Just mind the SCREEN_UV coordinates go from the bottom-left of the screen (0, 0) and are positive going up and to the right (the top-right corner of the window corresponds to a SCREEN_UV value of (1, 1)). In other words, they're flipped vertically compared to the UV values.

  • FATNUT replied

    Thank you for the info Nathan!

    I'll tinker with all the things and update this thread afterwards.

  • FATNUT replied

    Since I can't edit my previous answer (yielding a 404 error...) I update here.

    The full UV for the tilemap became redundant, since the platforms are now always just 1 tile 'high', but can vary in length. I just scaled the dissolving texture on the x coordinate, so the platforms now dissolve like planned.

    Tinkering around with the Screen_UVs and Viewports did actually create some good results, regarding what I needed / wanted.

    (Image shows my final result, which I am more than happy with!

    EDIT: Testing the 'editting hotfix' for the site.

  • Nathan Lovato replied

    Glad to see you could get results! Thanks for sharing.

    By the way I contacted the platform's devs regarding the edit bug and they just pushed a hotfix for it.