bubble-wrap icon indicating copy to clipboard operation
bubble-wrap copied to clipboard

Optimize grain implementation

Open bcamper opened this issue 9 years ago • 3 comments
trafficstars

The current grain style implementation uses Fractional Brownian Motion (FBM), which is a very expensive technique:

https://github.com/tangrams/eraser-map/blob/gh-pages/eraser-map.yaml#L500-L534

Yet the actual cases in which the grain is being used, for water, doesn't appear to have much of a "grain-y" effect that would require this level of nuance:

color.rgb -= grain(gl_FragCoord.xy) * 0.1; https://github.com/tangrams/eraser-map/blob/gh-pages/eraser-map.yaml#L543

The grain is being reduced by 10x and applied along with other color mixing. It has a darkening effect, so we don't want to simply remove it, but I believe the same visual effect can be achieved with something simpler, either some other form of noise or even simpler.

@patriciogonzalezvivo, could you please take a look and propose some alternatives?

bcamper avatar Mar 07 '16 16:03 bcamper

cc @sensescape @nvkelso

bcamper avatar Mar 07 '16 16:03 bcamper

Related, removed an unused ground style that also had a grain reference, but appeared nowhere else in the scene file: https://github.com/tangrams/eraser-map/commit/9577cdee39338b962ca1a312e8bf3a3947c5c9c7

bcamper avatar Mar 07 '16 16:03 bcamper

This is what we have now:

00

This is with out the grain:

01

I think to a sensitive eye the perceptual difference is provided by the circular gradient on the overall map and not by the grain really. In that case we can use apply just that with a simple:

    vec2 st = gl_FragCoord.xy/u_resolution.xy - vec2(.5);
    color.rgb -= dot(st, st) * 0.1;

instead of

    color.rgb -= grain(gl_FragCoord.xy) * 0.1;

Where is how it looks

02

patriciogonzalezvivo avatar Mar 07 '16 16:03 patriciogonzalezvivo