-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TileSet Vertex Shader unexpected behaviour- rendering_quadrant_size affects VERTEX value #86812
Comments
I'm not sure there is an actual bug here. The tilemap doesn't render tiles individually, it renders them as quadrants. So if the quadrant size doesn't align with the size you are using in the fragment shader, then they just won't line up. You need to use a quadrant size that aligns with the data you expect in your shader |
I'm aware that tiles are rendered by quadrants. However, the shader is executed for each tile drawn, the issue is that from the first column (and row) of the new quadrant being drawn, the VERTEX value for all tiles is moved My apologies if i cause confusion. I hope this images help explain the issue the quadrant 2, the VERTEX values of all tiles are moved while this can be "solved" by making the "division value" in the shader and the E.g. suppose a gradient composed by 8x8 tiles,it would require the "division value" to be |
The issue is that TileMap's each quadrant's canvas item position (to which vertices of the in-quadrant-tiles are relative to) is set to its first cell's map-coordinates: godot/scene/2d/tile_map_layer.cpp Lines 496 to 503 in 89cc635
It should be set to the local position of such first cell in the quadrant instead. Note that what's considered cell's position is its center so the question would be whether the quadrant canvas item position should be its first cell's position/center or maybe such cell's top left corner instead. I think top left corner makes more sense. It's not obviously visible issue as godot/scene/2d/tile_map_layer.cpp Line 369 in 89cc635
To visualize given the provided example:
tile_size = 16 The white square below shows the first cell of the quadrant with quadrant-coords
|
@SebasZwolf I think a valid workaround for you use-case might be to use |
This workaround works fine, thanks a lot :0 |
Your welcome. It seems in the time I took to figure out a workaround kleonc figured out a solution 😆 |
Tested versions
System information
Godot v4.2.1.stable - Windows 10.0.22621 - Vulkan (Forward+) - dedicated GeForce GT 730 () - Intel(R) Core(TM) i3-10100F CPU @ 3.60GHz (8 Threads)
Issue description
When the TileMap is drawn, at VERTEX position x:256 or y:256 (or both), it causes the vertex shadow to produce unexpected behaviour.
Steps to reproduce
My tile size is 16*16.
the code required for this shader is the following at it must be used in a TileSet Tile using the TileSet editor.
The code allows to pass to fragment a value that represent the coordinates of the tile (
vec2 pos
).Then it converts it to a value between
0.0; 0.5
and0.5; 1.0
(since the position is divided by 32 instead of 16).this allows to create gradients conntecting 4 tiles
The error appears in every tile that is in x:256 or y:256, in order to provide example, take tile at
(x: 256, y: 0)
: the VERTEX value will have the values:Since is not posible to debug the shader, this values were obtain comparing the VERTEX value of the affected tiles with their neighbors using conditionals inside the fragment shader. This revealed that:
these are the same values of the tile located at
(x:240, y:0)
However, this error will not occur if rendering_quadrant_size is set to 32 or the division value is set to 16.
Minimal reproduction project (MRP)
bugreport.zip
edit: i corrected the table values (the VERTEX values for each vertex for tile
(256, 0)
), values were misplacedThe text was updated successfully, but these errors were encountered: