Assume there is some value p, calculated per-frame, that varies continuously over the surface of an object. The value of p determines the density of some pattern on the surface. For example, in a case with only two possible densities if p < 0.3 it is high density, otherwise it is low.I've thought of a simple high-level solution: create two textures, each of different densities, and based on the value of p sample from the appropriate one. However, there's a problem with the boundary between high- and low-densities.Here is an example to illustrate the problem (note my problem is NOT exclusive to this example pattern of dots. I describe the patterns I'm working with later on):And here is the threshold between low- and high- (displayed on the high density texture but that's not relevant.) If under the line, it implies the high-density texture should be sampled.And finally here is the comparison between what is desired and what would actually happen using this method:The problem is that when a high-density-only circle crosses the line, it will be ignored when p indicates the low-density texture to be sampled, resulting in a truncated circle. I don't know how to solve this problem because p varies every frame, so I can't just 'bake' a boundary between the two densities. It's easy to prevent the reverse problem by creating the high-density texture from the lower one (i.e. if a circle is on the low-density texture ensure it is on the high-density texture.) I'm interested if anyone has a way to improve my solution or even has another method entirely. The constraint here is that p is calculated per-frame in real-time. Another constraint is related to the pattern texture: the pattern is black and white, where black is the pattern and white is the background (like the circles in the example). The pattern may not just be identical shapes repeated, but any arrangement of arbitrary black shapes over a white background. (Maybe pattern is the wrong choice of word.)   I'm not familiar with the research in this field so I wasn't sure which keywords to search, so I'd even appreciate if anyone could point me in the right direction.
How to create a patterned object with variable pattern density in real-time?
texture;shader;real time