-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Randomized textures (sprite strip) #2746
Comments
OK |
I made an issue like this at some point, I guess it got lost. |
#2433 would still clutter the texture folder though with multiple alternatives of the same texture, I think having them all in 1 texture file is a bit more handy. |
I dunno, it may help some people with texture packs, depending on what they are trying to do. We could add both as an alternative for people. |
This feature sounds like it could be useful. I agree with KenneyNL that it would probably be better to use sprite strips rather than individual files, as it would be more like the current system for animated nodes. |
Some questions arise: How and when should the sprite be selected? Should the sprite be allowed to change on a game restart? |
Some things I can answer from a game designer perspective;
|
|
@4aiman there is no need to store this extra information; it can be pseudo-randomly generated each time the mapblock mesh is updated. |
@PilzAdam Now there's a good idea, give the man a medal! Okay, so it's kindof hard to do that over the internet. In fact, we could just use the seed provided by the world already, seeing as it's used for the rest of mapgen. That might work. |
@PilzAdam so the textures will "dance" on every update? |
@4aiman I think the idea was to have the seed be based off of the mapblock position, so that the "random" numbers will be the same every time for any given mapblock. |
I think as C1ffisme and cheapie mentioned, if the random texture would be based on either just the node position or both the node position and the map seed (for a little bit more randomness), then the texture chosen should appear to be "random" while still remaining consistent. |
Oh... now I get it :) I acknowledge that the initial problem raised in current issue will be solved and fully covered by PilzAdam's solution, but still.. Also, there's a separate issue about the connected textures. How hard would it be to add a way to use metadata to store the number of the texture? |
@4aiman I agree that it would probably be good to have a way to set the texture of the node, as that would open up a lot of other possibilities such as connected nodes, nodes that change their appearance (like furnaces, battery boxes), etc. In the case of a random texture a random number could just be selected on create to determine the random texture. However, I'm not sure how well that would end up working in terms of storing the metadata. |
@ExcaliburZero I'm not insisting on anything. |
This can be implemented using a simple random number generator that is seeded for each surface with e.g. (x + z <<8 + y <<16 + face). For an example how to make randomness consistent across mesh/map updates look at my random_xz patch or the "plant fun" patch which has this element in it. (PR 3923) |
Would storing a single number make such a big diffrence to map block size? i have very little understanding of that at the moment. but it does seem like an extremly small amount of data.. this feature would also mean less nodes being created due to the many nodes that create 2 of each for purposes of having diffrent looks etc.. Grass textured nodes would especially benefit from this, being able to loose that repetative look. thats almost imposible to get rid off without leaving it looking plain. If it really bugs people, maybe providing 2 versions of this would be better:
so in essence you would use method 1 for things like grass and other large surfaces and you would use method 2 for things like furnaces.. getting the best of both worlds. ? |
Having a method like |
@sofar thats a good point. but where would it store it. In a file of its own? Either way it sounds like a good solution. Im just curios :) Edit: Ive just awnsered my own question by looking at the pr: #3446 & #3923 |
it can't be truly random, as the mesh for each block gets regenerated regularly and you don't want the texture of your grass to change just because someone placed a dirt block somewhere. A fixed seed works well. This is all client-side as well. |
Can't you just use a RNG with a seed of (x_100+y_10+z+mapgenseed) % m |
@rubenwardy that's what that is. |
|
This conflicts with merging nodes in stripes. But as that merging doesn’t seem to affect performance (maybe it does on older GFX, but on my |
Consider sofar's idea:
|
So, we have several options:
I’d prefer (1) and (3) (for different use cases), but have nothing against (2) as yet another option. We have random Y-offset for plantlike, after all. P.S. @paramat What sofar suggests is just an implementation detail. It looks acceptable both for (1) and (2). Just note that such texture usage is not GPU-friendly per se, so needs some tricks to work well. (Really, the whole MT needs these tricks, like using texture atlases). |
Whilst we are on this subject... is there a reason why we use different texture files for each face instead of 1 texture that wraps the node? i would think the latter would be more efficient |
@ryan-nolan If we used one file with each face a texture would have to be six times larger if every face was the same, as it would have to include the same texture six times. Now it's possible that somehow it could be coded to read differently depending on the texture size, but then if you wanted to have two faces different you'd still have to use a texture with all six faces on it. Like @tobyplowy said not very efficient for artists and it would lead to bloat. |
It also wouldn't help with performance at all. The Engine doesn't render all sides of a cube. A related optimisation which would be worth doing is texture atlasing - this existed in previous versions (until 0.4.2 or so) but was buggy due to a bad implementation. I believe this could have a good performance improvement by not switching texture context when rendering. |
sofar is on point with this comment: We already have it for sounds, why not textures too? There's plenty of texture packs with multiple alternates that can support it immediately. Currently I have to register 5-10 node definitions for each unique node in order to support it. And that's only when placing the node (on_place), not in mapgen at all. A quite horrible example shouldn't have to botch the whole issue. (Though #2433 is a better fit for this specific solution) |
Because we are still limited to IrrLicht, which lacks texture arrays, for example. Animation is done by choosing a texture (by name!) before even starting rendering (the texture strip itself is only used to cut these parts from it). But the same hack with normal nodes will mean using several times more textures, that's not very good as texture changing is slow, and that will slow meshgen (which is our bottleneck) down considerably too. OTOH, using strip as is would mean bugs at edges. Seriously, I may eventually fork IrrLicht and add support for some cool features I and we need... sfan5 confirms that’s a good idea) UPD: fixed the name, that was sfan5 and not nerzhul. http://irc.minetest.net/minetest-dev/2017-12-28#i_5182234 |
Buildaworld have a fork of irrlicht with some more graphics features, may be worth looking at that |
@rubenwardy Their fork looks great! It seems to have everything we need! Of course it needs some adoption, e.g. they dropped Win32 support recently, we can’t do that. But it looks very-very promising) |
I implemented that in Lua without any need for texture or engine changes. It works, but it’s hacky, though 😄 |
That solution is fine if you just want random rotation of nodes, but it doesn’t work reliably for alternating textures (no other interacting mod will recognize |
The solution is horribly hacky and after releasing it a better solution without flooding the world with metadata came in my mind 😄
Yes, rotating nodeboxes would break how they are intended to look, but that wasn’t my goal. If ever properly implemented this implementation should handle it correctly and not simply override/force anything. With my hacky code it’s possible to define the facedirs for the nodes so all facedirs where the node looks bad in can be omitted while defining the allowed rotation facedirs. I do this for grass for example. |
So who's disapproving of sofar's idea of implementation? No-one? Ok, let's move forward. Multiple alternate textures per node, randomized each placementNow, even though #2433 is closed in favor of this long-winded and sprawly discussion, it quite sums it up. There would be no new Lua API addition because just like how sound alternates work, the engine would at each rendering of a node look for textures called |
How should it interoperate with texture combining? |
Not sure, ideas? 🤔 |
@numberZero I think initially it should probably ignore any texture combining arguments to keep it simple. At the moment i cant imagine an example where this would be useful with texture combining. imo |
The one I think of is alternates of the dirt texture because that texture is usually overlayed with a grass texture for sides. |
@tacotexmex That's a good point, i didn't think of that |
I wouldn't mind at all if simply the first texture in the series was always used in texture combinations. |
In regard to numbers 3 & 4... Maybe allow the client to randomize it? If there are a lot of randomized nodes in the world (say, implementing a randomized grass texture), it could increase the size of data storage & transfer. I could be wrong, but I can't think of a use case where randomized textures being consistent between players & clients would be useful. |
(For choosing a random texture one can make a hash of the node pos, tile index and map seed. It won't change after digging and placing the node again, but that's fine imo.) Related: |
In a same way that nodes are currently animated (sprite strip) it could also function to give nodes a random appearance. Upon placing the node, a random frame of the stripe strip will be selected. The random seed could be done using a noise.
This would eliminate the duplication of nodes to achieve random node textures.
The text was updated successfully, but these errors were encountered: