Skip to content
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

Adjacent node dependent tiles / Connected textures #15203

Open
cx384 opened this issue Sep 28, 2024 · 3 comments
Open

Adjacent node dependent tiles / Connected textures #15203

cx384 opened this issue Sep 28, 2024 · 3 comments
Labels
@ Client rendering Concept approved Approved by a core dev: PRs welcomed! Feature request Issues that request the addition or enhancement of a feature @ Script API Textures

Comments

@cx384
Copy link
Contributor

cx384 commented Sep 28, 2024

Problem

It's not possible to have custom node tiling, when nodes of the same kind are next to each other.

It would also be great to be able to specify different kinds of connections to different kinds of nodes, but I would be very happy to at least have it for one type, like it is the case for connected nodeboxes.

Related:
#2748
#5369
#8334
#11546

All of those should be solvable by this feature.

Solutions

A solution could work similar to connected nodeboxes, but per tile (a node usually has 6 tiles). It should be able to be connected to all sides, including corners, and maybe also nodes above and below.
We already have glasslike_framed, so I guess it is doable without performance problems.
It does not need param2 so no new drawtype is needed, instead it would be part of the tile definition like animation and align_style.

For the API I think it could look like this, or similar:

  • Tile definition = {name = "image1.png", connection = {Tile Connection definition}}, where image.png is the base image
  • Tile Connection definition = {Tile modifier, Tile modifier, Tile modifier, ...}
  • Tile modifier =
{
  condition = {right = {"node:name", "group:name", ...}, not_left = {"node:name", ...}, not_x_plus_1 = {...} ...}
  type = "concat"
  name = "^image2.png"
}
  • The used texture would be "image1.png^image2.png".

It's a flexible and easy to use solution, but if this doesn't work performance wise, the condition could use bools per side to only support one kind of connected node.

Note that you can't do it like connected nodeboxes, since the order of overlaid textures matters, and fixed textures would mean that you have to manually specify about 2^6 textures even for a very simple connected glass with corners use case.

Alternatives

  • Registering multiple nodes with different textures is unfeasible, even if Add node texture variants #13811 becomes a thing, since you would need to register about 2^10 nodes. (26 adjacent nodes - 8 edges - 8 bit from param2)
  • A less flexible API with a hardcoded tilemap for connected nodes.
  • A more explicit API where you have to set a fixed texture for every connection case. (define up to 6 * 2^26 textures)

Additional context

This is how it could look like for some MTG things, e.g. the Stone Block texture.
ct2

@cx384 cx384 added Feature request Issues that request the addition or enhancement of a feature @ Script API @ Client rendering Textures labels Sep 28, 2024
@Zughy Zughy added the Concept approved Approved by a core dev: PRs welcomed! label Sep 28, 2024
@hlqkj
Copy link

hlqkj commented Sep 29, 2024

I like the proposed condition definition! I think it could also be extended to work with the node meta as well? It would offer even more flexibility to an implementation of texture variants of a node, without consuming param2 bits.

@cx384
Copy link
Contributor Author

cx384 commented Sep 30, 2024

I suppose this wouldn't work performance wise, reading node meta is quite expensive if I'm not wrong.

@Desour
Copy link
Contributor

Desour commented Sep 30, 2024

Reading node meta just requires a hashtable lookup, afaik. The issue is rather that the mapblock mesh maker thread has no access to node meta. And changing this would require copying the respective meta fields, and remeshing if they change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@ Client rendering Concept approved Approved by a core dev: PRs welcomed! Feature request Issues that request the addition or enhancement of a feature @ Script API Textures
Projects
None yet
Development

No branches or pull requests

4 participants