Page 1 of 2

Texture bombing

Posted: Fri Oct 02, 2020 3:23 pm
by Dade
I have added the support for new texture "bombing" from GPU Gems (https://developer.download.nvidia.com/b ... _ch20.html) as discussed in viewtopic.php?f=4&t=2638.

Texture Bombing

The new texture uses a background and a "bullet" (RGB + mask) to create the result:

Code: Select all

scene.textures.backgroundtex.file = scenes/randomizedtiling/pattern-7.jpg
scene.textures.backgroundtex.gamma = 1.0
scene.textures.backgroundtex.randomizedtiling.enable = 1
scene.textures.backgroundtex.mapping.uvscale = 2 2
##
scene.textures.bullettex.file = autumn-leaf.jpg
scene.textures.bullettex.gamma = 1.0
##
scene.textures.bulletmasktex.file = autumn-leaf.jpg
scene.textures.bulletmasktex.gamma = 1.0
scene.textures.bulletmasktex.channel = alpha
##
scene.textures.bombtex.type = bombing
scene.textures.bombtex.background = backgroundtex
scene.textures.bombtex.bullet = bullettex
scene.textures.bombtex.bullet.mask = bulletmasktex
scene.textures.bombtex.bullet.count = 1
scene.textures.bombtex.mapping.uvscale = 12 12
Starting from this background (with randomized tiling):

tex1.jpg

and using this "bullet":

tex2.jpg

You obtain:

bomb1.jpg

Note: as the leafs have only a single shape (i.e. orientation, they are pointing upward).

Texture Bombing with multiple bullets

It is possible to use multiple "bullet" shapes instead of single one:

tex2-multi.jpg

and telling to the texture the bullet has 4 shapes:

Code: Select all

scene.textures.bombtex.bulletcount = 4
You obtain:
bomb2.jpg
Note: as the leafs have now 4 different shapes (i.e. orientation).

Daisy chained Texture Bombing with multiple bullets

It is possible to daisy chain multiple bombing textures to increase the density and randomness of bullets. This is an example with 3 layered texture bomming:

Code: Select all

scene.textures.backgroundtex.file = scenes/randomizedtiling/pattern-7.jpg
scene.textures.backgroundtex.gamma = 1.0
scene.textures.backgroundtex.randomizedtiling.enable = 1
scene.textures.backgroundtex.mapping.uvscale = 2 2
##
#scene.textures.bullettex.file = autumn-leaf.jpg
scene.textures.bullettex.file = multi-autumn-leaf.jpg
scene.textures.bullettex.gamma = 1.0
##
#scene.textures.bulletmasktex.file = autumn-leaf.jpg
scene.textures.bulletmasktex.file = multi-autumn-leaf.jpg
scene.textures.bulletmasktex.gamma = 1.0
scene.textures.bulletmasktex.channel = alpha
##
scene.textures.bombtex1.type = bombing
scene.textures.bombtex1.background = backgroundtex
scene.textures.bombtex1.bullet = bullettex
scene.textures.bombtex1.bullet.mask = bulletmasktex
scene.textures.bombtex1.bullet.count = 4
scene.textures.bombtex1.mapping.uvscale = 12 12
##
scene.textures.bombtex2.type = bombing
scene.textures.bombtex2.background = bombtex1
scene.textures.bombtex2.bullet = bullettex
scene.textures.bombtex2.bullet.mask = bulletmasktex
scene.textures.bombtex2.bullet.count = 4
scene.textures.bombtex2.mapping.uvscale = 9 9
##
scene.textures.bombtex3.type = bombing
scene.textures.bombtex3.background = bombtex2
scene.textures.bombtex3.bullet = bullettex
scene.textures.bombtex3.bullet.mask = bulletmasktex
scene.textures.bombtex3.bullet.count = 4
scene.textures.bombtex3.mapping.uvscale = 15 15
and the result is:

bomb3.jpg

Note: I have yet to write GPU code.

Re: Texture bombing

Posted: Fri Oct 02, 2020 3:28 pm
by B.Y.O.B.
Would it be possible to support random rotations for the "bullets"?
Having to create multiple fixed orientations and stitching them in an image editing program seems like a bit of a cumbersome and unintuitive workflow to me.

Random sizes would also be useful.

And both rotation and size could have min/max limits for the randomness (e.g. rotate between 60 and 120 degrees, and scale between 0.5x and 2.2x).

edit: It might be a good idea if we could supply a list of filenames to this texture and LuxCore automatically stitches them together into this atlas and detects the count.

Re: Texture bombing

Posted: Mon Oct 05, 2020 8:22 am
by juangea
Pretty interesting, and I agree with everything BYOB said.

It’s like some kind of decal mapping, right?

Re: Texture bombing

Posted: Mon Oct 05, 2020 12:15 pm
by Dade
B.Y.O.B. wrote: Fri Oct 02, 2020 3:28 pm Would it be possible to support random rotations for the "bullets"?
In theory no because the diagonal of a square is larger than the edge (i.e. if you rotate the bullet image, it will not feet the original image: you have to cut corners to fit the original size). See the clipped red square in this test:

clip.jpg

In practice, this problem is very easy to solve by adding an empty border to the bullet image and, most of the time, it is not even necessary or a noticeable problem.

So I added the support for random bullet rotation and scale with the following properties:

Code: Select all

# Random scale range, in this case, scale between 100% and 175% (it can be > 1.0).
scene.textures.bombtex.bullet.randomscale.range = 0.75
# If to enable 360 degree random rotation
scene.textures.bombtex.bullet.randomrotation.enable = 1
The result of using a single leaf bullet image:

bomb-rng.jpg

Re: Texture bombing

Posted: Mon Oct 05, 2020 12:19 pm
by Dade
juangea wrote: Mon Oct 05, 2020 8:22 am It’s like some kind of decal mapping, right?
Yes, procedural (random) generated decal mapping.

Re: Texture bombing

Posted: Wed Oct 07, 2020 6:11 am
by lacilaci
Pretty cool stuff, I love decals...

If you could use box mesh in blender as a boundary and it's Z axis as a projection direction you would pretty much have a proper basic decal system :o

Re: Texture bombing

Posted: Thu Oct 08, 2020 6:21 pm
by B.Y.O.B.
I have added the first basic support in the Blender addon. The node can be found in the "Utils" category (which is getting big).

I have not exposed the multi-bullet stuff yet because I think the usability is not good right now (need to hand-stitch textures into an atlas and tell LuxCore the count). Also I'm not sure it's even needed, because you can always stack multiple bombing textures if you need multiple bullets.

For the scale parameter, I have tried to make it behave almost like the "Scale Randomness" parameter of Blender particles, where 0 = no variations in scale and 1 = maximum variations in scale. For this I multiply the value with 5 internally.

It might be nice if we could control the scale with a texture as well.

Re: Texture bombing

Posted: Thu Oct 08, 2020 11:27 pm
by FarbigeWelt
Dade wrote: Mon Oct 05, 2020 12:15 pm
The result of using a single leaf bullet image:

bomb-rng.jpg
What a nice rendering experiment.
Are you familiar with Georges Seurat and Van Gogh?
😀

Re: Texture bombing

Posted: Sat Oct 24, 2020 11:28 am
by juangea
B.Y.O.B. wrote: Thu Oct 08, 2020 6:21 pm you can always stack multiple bombing textures if you need multiple bullets.
Whould that make a performance difference?

I mean, multiple bullets means that the computation of the bullets distribution is being done once and with multiple textures, also I imagine intersection between bullets can be avoided.

Multiple Bullet nodes means that in every node distribution calculation has to be done, so once per bullet, and they will for sure intersect and fully overlapped some times.

I'm assuming that bullet distribution avoides more or less intersections and overlapping of bullets.

Also I tried it today in 2.90 and random scale and random rotation seem to not be working, they change the scale and the rotation but uniformly.
bombing_not_working.png
Keep in mind that in this case this is an object formed by multiple mesh islands, and they kind of share UV's (so that may be the culptrip and with random UV's is solved)

It's a pretty amazing feature I think :)

Re: Texture bombing

Posted: Sun Nov 01, 2020 9:56 am
by Dade
I added the GPU support for texture bombing.