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

Compact image-generation texture modifier #9767

Closed
wants to merge 1 commit into from

Conversation

appgurueu
Copy link
Contributor

@appgurueu appgurueu commented Apr 27, 2020

  • Goal of the PR: Allowing larger mod-generated images by implementing a more compact texture modifier
  • How does the PR work? Takes width and height & colors as hex-string-RGBA-array
  • Does it resolve any reported issue? Closes Allow more complex texture modifiers #6821

Status

This PR is Ready for Review.

How to test

minetest.register_craftitem("testmod:testitem", {
	inventory_image = "[image:2x2:".."FF0000FF".."00FF00FF".."0000FFFF".."FFFFFF00",
	description = "Test Item"
})

Results in this:

Screenshot

@appgurueu appgurueu changed the title 6821 Compact image-generation texture modifier Apr 27, 2020
@sfan5 sfan5 added @ Client / Audiovisuals @ Script API Feature ✨ PRs that add or enhance a feature labels Apr 27, 2020
@sfan5
Copy link
Member

sfan5 commented Apr 27, 2020

I wonder if there isn't a better solution to dynamically generated images.

@appgurueu
Copy link
Contributor Author

I wonder if there isn't a better solution to dynamically generated images.

There most likely is, but not without much effort.

@rubenwardy
Copy link
Member

I suggest having PNG data in the same way that data URLs work, constructed with a helper on the server

It would be nice to fix texture caching to not cache everything when doing stuff like this, though

@nerzhul
Copy link
Member

nerzhul commented Apr 28, 2020

raw_image sounds better than image for me, as we are low level here

@appgurueu
Copy link
Contributor Author

I suggest having PNG data in the same way that data URLs work, constructed with a helper on the server

So propose minetest.raw_image(data) returns base64-compressed PNG data, with data being a Lua list of RGBA byte strings. Accordingly, the raw_image modifier would take that data.

@SmallJoker
Copy link
Member

👎 this PR should either implement a modifier for raw image data, or image data encoded as base64.

@appgurueu
Copy link
Contributor Author

Closing this in favor of @sfan5's PR.

@appgurueu appgurueu closed this May 29, 2020
@sorcerykid
Copy link
Contributor

Unless i missed something, I wasn't aware that the other PR allowed for programmatic generation of textures. From my reading, it implements pushing of already existing media files to the client, which is completely different.

@v-rob
Copy link
Member

v-rob commented Jun 3, 2020

I believe this PR still can serve a purpose. This allows highly customizable textures, working for things like e.g. painting or sign mods. You could, I suppose, create a PPM image, save it with a cryptic name like mymod_generated_###.ppm where the number increments every time you create a new image, and load that -- not an ideal solution. Neither is tons of ^combine[s with intermediate caching.

Personally, I think using a hexadecimal color string for each pixel is overkill though. Offering a palette modifier would also be a good solution, like ^palette[2x2:#F00#0F0#00F#0000:0123 (the same as the example picture) would offer a good compromise, since many really dynamic things won't need that many colors but will need many pixels. It could go from 0-9, then A-Z, and finally a-z for a total of 62 palette colors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow more complex texture modifiers
7 participants