Skip to content

ovsky/stochastic-texture-sampling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎲 Stochastic Texture Sampling

High-Performance, Mobile-Optimized Anti-Tiling Shader

Build Platform Optimization License

✨ Description

Stochastic Texture Sampling provides an advanced, highly-optimized solution to one of the most persistent issues in 3D rendering: texture tiling.

By drawing model UVs with an advanced stochastic-projection method, this shader entirely breaks up the noticeable, repeating grid patterns that plague large surfaces like terrain, grass, and architectural floors. Unlike traditional, computationally heavy stochastic methods, this implementation features the most simplified possible calculations, making it fully capable of running smoothly on mobile platforms (iOS/Android) and standalone VR/XR headsets.

Whether you are rendering massive landscapes or detailed environments, this technique makes texture repetition significantly less noticeable without sacrificing your framerate.

📦 Video Showcase & Portfolio: https://orlowski.works/ (Scroll to the bottom of the Showcase section to see the real-time video comparison!)


🌟 Features

🔍 Anti-Tiling Magic: Completely breaks up the unnatural repetition of textures on large meshes using pseudo-random UV offsets and blending, ensuring organic and natural-looking surfaces.

Mobile & XR Optimized: Achieves the visual fidelity of high-end stochastic projection using stripped-down mathematical approximations. Built from the ground up to guarantee maximum performance on mobile GPUs and standalone headsets like Meta Quest.

🌍 Cross-Platform / Engine Agnostic: Written in clean HLSL/GLSL, making it fully compatible with Unity, Unreal Engine 5, or your own custom rendering pipelines.

💡 Preserves Visual Fidelity: Maintains the crispness and quality of your albedo and normal maps without introducing heavy blurring or artifacting common in cheaper anti-tiling workarounds.


🎥 See it in Action!

Seeing is believing. Check out the real-time preview to see the dramatic difference stochastic sampling makes on a heavily repeating texture.

Watch the Video Watch the video

(Click the link above and scroll down to the **Stochastic Texture Sampling** section to watch the live demo!)


🚀 Integration

Integrating this technique into your existing shaders is extremely straightforward.

🎉 Enjoy! :)


⚙️ Instructions

Fast Way (Unity Shader Graph / UE5 Material Editor):

  1. Import the provided Sub-Graph / Material Function into your project.
  2. Connect your base Texture and UV node into the StochasticSample block.
  3. Route the output directly to your Base Color / Albedo.
  4. Done! Watch your tiling issues disappear.

🛠️ Perfect Way (Native HLSL/GLSL):

  1. Include the StochasticSampling.cginc (or .glsl) in your custom shader file.
  2. Replace your standard tex2D() or Sample() calls with the StochasticSample() function.
  3. Pass your texture sampler, UV coordinates, and noise scaling factor.
  4. Compile and marvel at the seamless optimization! 🎊

😸🫂😸 Cooperation

For me, the best payment for a ton of hard work and optimization is seeing people use this in their awesome projects! I'm counting on the GameDev community to help test and expand this tool.

DEVELOPERS:

Above all, if you're a programmer or technical artist, you can help by porting this specific simplified stochastic math to other game engines or WebGL frameworks (like Three.js). My biggest goal is for these rendering techniques to be fully universal.

SUPPORTERS:

If you find edge cases where the blending could be optimized further, or if you create cool variations for specific material types (like water or procedural dirt), feel free to open a Pull Request!


💜😀🩷🫥❤️😈🧡🥶💛

I would be extremely grateful for any help and feedback!

You can reach me via email:

przemek.orlowski@outlook.com

And since you're here, take a look at my portfolio for more high-performance rendering solutions, features, and other tools:

https://orlowski.works/


About

High-Performance, Mobile-Optimized Anti-Tiling Shader

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors