Note that there are some explanatory texts on larger screens.

plurals
  1. POAdvanced moiré a pattern reduction in HLSL / GLSL procedural textures shader - antialiasing
    text
    copied!<p>I am working on a procedural texture, it looks fine, except very far away, the small texture pixels disintegrate into noise and moiré patterns. </p> <p>I have set out to find a solution to average and quantise the scale of the pattern far away and close up, so that close by it is in full detail, and far away it is rounded off so that one pixel of a distant mountain only represents one colour found there, and not 10 or 20 colours at that point.</p> <p>It is easy to do it by rounding the World_Position that the volumetric texture is based on using an if statement i.e.:</p> <pre><code> if( camera-pixel_distance &gt; 1200 meters ) {wpos = round(wpos/3)*3;}//---round far away pixels return texturefucntion(wpos); </code></pre> <p>the result of rounding far away textures is that they will look like this, except very far away:<a href="http://i44.tinypic.com/2r4ph1d.jpg" rel="nofollow noreferrer">http://i44.tinypic.com/2r4ph1d.jpg</a> the trouble with this is i have to make about 5 if conditions for the various distances, and i have to estimate a random good rounding value</p> <p>I tried to make a function that cuts the distance of the pixel into distance steps, and applies a LOD devider to the pixel_worldposition value to make it progressively rounder at distance but i got nonsense results, actually the HLSL was totally flipping out. here is the attempt:</p> <pre><code>float cmra= floor(_WorldSpaceCameraPos/500)*500; //round camera distance by steps of 500m float dst= (1-distance(cmra,pos)/4500)*1000 ; //maximum faraway view is 4500 meters pos= floor(pos/dst)*dst;//close pixels are rounded by 1000, far ones rounded by 20,30 etc </code></pre> <p>it returned nonsense patterns that i could not understand.</p> <p>Are there good documented algorithms for smoothing and rounding distance texture artifacts? can i use the scren pixel resolution, combined with the distance of the pixel, to round each pixel to one color that stays a stable color?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload