bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.49k stars 3.51k forks source link

Stochastic texture sampling #13682

Open torsteingrindvik opened 4 months ago

torsteingrindvik commented 4 months ago

What problem does this solve or what need does it fill?

I want to easily make tiled textures look non-tiled.

What solution would you like?

I'd like Bevy support where as a user I have some tunable settings that allow me to adapt my textures to look non-tiled.

What alternative(s) have you considered?

Using tools such as krita, photoshop etc. and following tutorials to make textures look non-tiled, or rolling my own shader.

Additional context

This reddit post has a great video, and they also show their shader code, usage example, link to paper its based on etc. and might be a good starting point (either for development or further research)

Here is a snapshot from the above video to show the effect:

Off:

image

On:

image

torsteingrindvik commented 3 months ago

https://discordapp.com/channels/691052431525675048/743663924229963868/1247968409522802850

...it should be an extended material. We should probably have a discussion about how we want to handle this kind of thing

The problem being this: StandardMaterial is going to be too big if we keep adding things to it without limit. My proposal is to set the limit at the intersection of glTF + ratified KHR extensions and Principled BSDF in Blender. That means basically we add sheen and then we're done. (edited) [7:42 PM] But there's obviously room for a lot more features and the question is what to do with them. The ideal would be to use MaterialX and allow the user to create their own ubershader with a node graph. But that's a lot of work and I think we would want a shorter term solution. [7:47 PM] My current thought is to add documented helper WGSL functions that allow users to create their own ubershaders, and then some sort of convenience abstraction for common usages. Perhaps decals, for example, could have a built-in ExtendedMaterial that allows for albedo + normal map decals on the StandardMaterial. Likewise triplanar mapping could have a built-in ExtendedMaterial that does blending on a StandardMaterial. Etc

@pcwalton adding your comments from discord here since they might be useful context in the future.

pcwalton commented 3 months ago

Also see Inigo Quilez' articles on this https://iquilezles.org/articles/texturerepetition/