Stochastic Texture Sampling

For people working on the C++ code.
Post Reply
User avatar
Hybrid Dog
Member
Posts: 2853
Joined: Thu Nov 01, 2012 12:46
GitHub: HybridDog

Stochastic Texture Sampling

by Hybrid Dog » Post

Currently textures in Minetest are repeating, for example here all cobblestone nodes are visually made up of the same small stones positioned in the same way everywhere:
stochastic_texture_sampling_off.jpg
stochastic_texture_sampling_off.jpg (114.41 KiB) Viewed 4188 times
With stochastic texture sampling, it is possible to re-use only high frequency details of textures, which makes nodes look more natural, adds visual variety, and prevents artifacts which are visible when a wall of the same node is watched from far away.
Here is the same image with stochastic texture sampling used for all nodes:
stochastic_texture_sampling_on.jpg
stochastic_texture_sampling_on.jpg (117.86 KiB) Viewed 4188 times
Whether stochastic texture sampling looks good depends on the texture, some parameters and opinion. In this case, it looks bad for the mese lamp (in my opinion) because the mese lamp texture should repeat.

I partly implemented stochastic texture sampling in Minetest some time ago and didn't continue because I don't know if it's worth the code complexity.

More screenshots: https://forum.minetest.net/viewtopic.ph ... 24#p423224

The code can be found on this branch in my Minetest fork: https://github.com/HybridDog/minetest/t ... e_sampling

In addition to stochastic texture sampling in Minetest, I have implemented a demonstration program in a single HTML page: https://hybriddog.github.io/stochastic_ ... ling_demo/
(source: https://github.com/HybridDog/stochastic ... ling_demo/)
It allows testing the algorithm with any SDR texture, for example default_stone.png:
stonet.png
stonet.png (63.04 KiB) Viewed 4188 times
It is also possible to implement the algorithm with SVG filters, which I have tried at https://codeberg.org/HybridDog/sts-svg
Last edited by Hybrid Dog on Sun Apr 13, 2025 10:34, edited 2 times in total.

‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪‮
‮‪

Kazooo
Member
Posts: 34
Joined: Sat Apr 13, 2024 23:06
GitHub: Kazooo100
In-game: Kazooo

Re: Stochastic Texture Sampling

by Kazooo » Post

Looks cool! I know there is also seed related textures, called global textures, but MTG doesn't use them.

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests