refill-style icon indicating copy to clipboard operation
refill-style copied to clipboard

Port dots styles to use texture

Open bcamper opened this issue 8 years ago • 14 comments
trafficstars

We can simplify and improve performance of the dots-based styles by making them sample from a dot texture (that can be further modified in the shader as needed).

bcamper avatar Dec 14 '16 17:12 bcamper

Porting to uniforms https://github.com/tangrams/refill-style/commit/9898573d8d3aebb8d1ec376478b971b84024a057#diff-2ae5458fe5491a29a9703b5a93751300R1131

@bcamper What about PATTERN_SCALE and DOT_SIZE is ok to add uniforms for those?

patriciogonzalezvivo avatar Dec 14 '16 17:12 patriciogonzalezvivo

Mmmm... I just notice that all those dots have white [1.,1.,1.] as background... is ok @sensescape if I hard code that and use remaining uniform space for DOT_SIZE and PATTERN_SCALE cc @bcamper

patriciogonzalezvivo avatar Dec 14 '16 17:12 patriciogonzalezvivo

  • Assuming background is always white https://github.com/tangrams/refill-style/commit/a1b463a50dbfc0f3ce89c859a5294a30de7baba9

  • DOT_SIZE and PATTERN_SCALE are now uniforms

Next step making the texture! @bcamper I have two ways to go here:

  • make a ONE SDF texture of a dot and then use aastep to clamp it according DOT_SIZE (u_dot_size)
  • make TWO B/W textures with to dots of two different sizes for .25 (https://github.com/tangrams/refill-style/blob/turbo_dots/refill-style.yaml#L1146) and .125

Seams the first one is slightly more expensive but more reusable. Also I would love to use some blocks for this... are we ok for adding tangram-blocks?? cc @nvkelso @bcamper

patriciogonzalezvivo avatar Dec 14 '16 18:12 patriciogonzalezvivo

It might be worth trying both approaches to see what the performance/size difference is. Maybe start with a single dot.

But I'd like all the dependencies for refill in the project itself -- it's been difficult for me to deal with all the imports in Tron (though it was a good experiment), and I'm not yet convinced we want to bring that complexity to other house styles, so I'd rather keep it as an embedded style in here for now.

bcamper avatar Dec 14 '16 18:12 bcamper

👍

patriciogonzalezvivo avatar Dec 14 '16 18:12 patriciogonzalezvivo

In general, performance is more important for these house styles than flexibility. Since a second dot texture probably won't add much size, I would likely prefer that (let's check the size?).

You can also make a generic version for Blocks, with a single texture, and keep an optimized version in this file.

bcamper avatar Dec 14 '16 18:12 bcamper

Cool... @sensescape could you confirmam that the DOT_SIZE in the gh_pages version is what you want? Once we switch to textures will be harder to tweak

patriciogonzalezvivo avatar Dec 14 '16 18:12 patriciogonzalezvivo

@patriciogonzalezvivo ok! reviewing the dot sizes

sensescape avatar Dec 14 '16 18:12 sensescape

thanks!

patriciogonzalezvivo avatar Dec 14 '16 18:12 patriciogonzalezvivo

sooo... I tried with fixed size dot textures... and seams they don't scale right... so I'm taking the other approach: ONE SDF TO RULE THEM ALL!

patriciogonzalezvivo avatar Dec 14 '16 18:12 patriciogonzalezvivo

sorry about this mess, so many dots! looks like I'm using them all park-dots1 mixes dots — DOT_SIZE: .1 dots-rev mixes pattern-dots tiny-dots mixes dots3 — DOT_SIZE: .125 medium-dots mixes dots-medium —DOT_SIZE: .25

sensescape avatar Dec 14 '16 18:12 sensescape

@sensescape THANKS! I hope you don't mind I simplify the names in this commit https://github.com/tangrams/refill-style/commit/a1b463a50dbfc0f3ce89c859a5294a30de7baba9 some stiles where only call by just another style

patriciogonzalezvivo avatar Dec 14 '16 19:12 patriciogonzalezvivo

yes, please @patriciogonzalezvivo the names were confusing me, i was mixing all the dots up, didn't make much sense! thanks!

sensescape avatar Dec 14 '16 19:12 sensescape

All changes are here https://github.com/tangrams/refill-style/pull/33 ready for review and merge : )

patriciogonzalezvivo avatar Dec 14 '16 19:12 patriciogonzalezvivo