procedural texture with varied coverage

I want to generate textures with varied coverage, namely, the percentage of filled pixels varies.
From the coding perspective, we could achieve this using quad-tree, i.e., subdivide the image into nodes, and filling in nodes until reaching the required percentage.
The problem is how to achieve this in blender? I insist to use procedural texture instead of UV mapping because, the latter might not use up the whole image, thus the percentage of coverage would likely change.
Any help is appreciated.
Here is an image I got using quad-tree, it doesn’t look natural, but the texture coverage is 50%, and that’s the effect I want.


Hi kw

The interesting thing about the texture you would like is the application of the texture at different scales
At each level of subdivision each square is either left untouched, or subdivided more

Here is an attempt at what you would like using the brick texture to subdivide to a number of levels
I don’t know how to do loops in nodes so that you can achieve an arbitrary number of divisions
I imagine that writing this as an OSL shader you can do the number of divisions programatically

The idea is to use the brick texture to divide the surface into a number of white/black squares



I have left the mortar in to outline the squares, but you can delete this for your use

Now for the next iteration another brick texture is used with double the scale
This is mixed in with the first iteration so that the black squares are unaffected, but the white squares are further subdivided
Again I have left the mortar on



You can add any number of iterations, doubling the scale each time
After four iterations I get to


You can see that the place you would add your texture is the highlighted mix node
These have a noise texture and white, but you could put the 2 textures you would like to alternate

There are 2 input values.
One is the initial scaling choose this to determine the size of the squares to start from
The other that chooses the value of the level of the output of the brick texture, determining the proportion of the white and black squares, vary this value to change the proportion of each texture chosen
You could change this value differently with each iteration

Hope this helps

Martin

Hello Martin,

Thanks for your reply, that’s great work.

I have another question. Is it possible to use procedural texture to combine a cloud texture and a strip texture, something look like this, where the coverage is 30%, 50%, and 80%. I current use an image texture, but the resolution is not high enough. Since I’m using GPU rendering, I don’t think OSL is an option. Thank you.






Hi @kw

Bands are easy.
There is a wave texture that you can use.
Set the property to ‘saw tooth’ which gives a fac value output that varies from 0 to 1 and then some math to use this to extract the percentage you would like. e.g. ‘greater than 0.25’ for 25%


Since you are using GPU rendering then OSL is perfect for any complicated shaders you want to create
OSL is specifically targetted at GPUs to create useful shaders
But if you don’t want the bother then noodly cycles shaders are also fun

Hope this helps

Martin

Hello Martin,

I read from here https://blender.stackexchange.com/questions/2129/does-osl-work-on-the-gpu/2130 that it’s almost as much work as writing Cycles from scratch to enable GPU rendering for OSL. I’m not sure if this information is outdated. But your approach ought to do the job. Appreciate it.

Ooops, you are quite right. I kinda assumed that since it is a shader language it was optimised for GPUs. I was wrong. Sorry :smiley:

Hi Martin, I have one more question, how to change the albedo of the whole texture automatically, what I did is separate the rgb channels and scale the intensity of each channel, but it doesn’t seem right to me. thanks.

Hi kw

There are various ways to change the brightness of the texture
The simplist would be to feed the colour output of the colour mix {that feeds into the BDSF shader} through a HSV node
This node enables you to tweak the hue saturation values of the colour separately
You can do it the way you suggested so you have tight control over each colour component
Or you could do it with a colour ramp

What do you mean by “doesn’t seem quite right”?

Best regards

Martin

Hi Martin,

I want to have a texture generator that takes two inputs: coverage, and albedo, and the first one is done. For the second one, the approach you suggested and the one that I’m currently using have an issue, because they change the lightness after the base colour is determined, therefore, the albedo of the base colour is not taken into consideration.

final albedo = albedo of base color * lighness

For example, if I want a texture with 0.5 albedo (final albedo), but without knowing the base colour, I have no way of knowing how to set the second input value (lightness) because the different base colour has distinctive albedos.

I don’t know if there is a way to set the colour in the color ramp node, if there is, then the problem can be solved pretty easily.

This image has albedo = 0.1, but the white area still looks pretty bright, that’s what I meant ‘not right’


never mind the last one, I figured out why it doesn’t look right, the intensity of white strip is not changed.