Triplanar mapping / stochastic texturing

Discussion related to the LuxCore functionality, implementations and API.
neo2068
Developer
Developer
Posts: 260
Joined: Tue Dec 05, 2017 6:06 pm
Location: Germany

Re: Triplanar mapping / stochastic texturing

Post by neo2068 »

Should the triplanar mapping be exported with local mapping or all textures? The imagemap texture node export uvmapping2d as default mapping.
i7 5820K, 32 GB RAM, NVIDIA Geforce RTX 2080 SUPER + GTX 1080, Windows 10 64bit, Blender 2.83.5
Support LuxCoreRender project with salts and bounties
User avatar
lacilaci
Donor
Donor
Posts: 1969
Joined: Fri May 04, 2018 5:16 am

Re: Triplanar mapping / stochastic texturing

Post by lacilaci »

I'm confused cause here https://github.com/LuxCoreRender/BlendLuxCore/pull/320 in the first screenshot alpistihno shows nodes from 2d mapping and in his render it worked... But then again, this should not use uv's.
By the way all the objects I tried had their origins at their centers.
neo2068
Developer
Developer
Posts: 260
Joined: Tue Dec 05, 2017 6:06 pm
Location: Germany

Re: Triplanar mapping / stochastic texturing

Post by neo2068 »

I can confirm that there is something wrong with the triplanar mapping. If I use default color input it renders correctly but if I use local mapping it doesn't. If I use same uv index it renders not correctly, too. With different uv index (but same copied uv map) it renders correctly.

When I use standard colors it renders correctly but with images it does not.

Code: Select all

#triplanar with color
scene.textures.1866357581976Color.type = "triplanar"
scene.textures.1866357581976Color.texture1 = 1 0 0
scene.textures.1866357581976Color.texture2 = 0 0 1
scene.textures.1866357581976Color.texture3 = 0 1 0
scene.textures.1866357581976Color.mapping = "globalmapping3d"
scene.textures.1866357581976Color.mapping.transformation = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
#################################################################################################
# image with uv map
scene.textures.1866357603800Color.type = "imagemap"
scene.textures.1866357603800Color.file = "F:\Users\Michael\AppData\Local\Temp\tmp4hm448oa.png"
scene.textures.1866357603800Color.wrap = "repeat"
scene.textures.1866357603800Color.mapping.type = "uvmapping2d"
scene.textures.1866357603800Color.mapping.uvscale = 0.5 -0.5
scene.textures.1866357603800Color.mapping.uvindex = 0
scene.textures.1866357603800Color.mapping.rotation = 0
scene.textures.1866357603800Color.mapping.uvdelta = 0 2
scene.textures.1866357603800Color.channel = "default"
scene.textures.1866357603800Color.gamma = 2.2000000476837158
scene.textures.1866357603800Color.gain = 1
#################################################################################################
# triplanar with local mapping
scene.textures.1866357602808Color.type = "imagemap"
scene.textures.1866357602808Color.file = "F:\Users\Michael\AppData\Local\Temp\tmp4hm448oa.png"
scene.textures.1866357602808Color.wrap = "repeat"
scene.textures.1866357602808Color.mapping.type = "uvmapping2d"
scene.textures.1866357602808Color.mapping.uvscale = 0.5 -0.5
scene.textures.1866357602808Color.mapping.uvindex = 0
scene.textures.1866357602808Color.mapping.rotation = 0
scene.textures.1866357602808Color.mapping.uvdelta = 0 2
scene.textures.1866357602808Color.channel = "default"
scene.textures.1866357602808Color.gamma = 2.2000000476837158
scene.textures.1866357602808Color.gain = 1
#
scene.textures.1866357604792Color.type = "triplanar"
scene.textures.1866357604792Color.texture1 = "1866357602808Color"
scene.textures.1866357604792Color.texture2 = "1866357602808Color"
scene.textures.1866357604792Color.texture3 = "1866357602808Color"
scene.textures.1866357604792Color.mapping = "localmapping3d"
scene.textures.1866357604792Color.mapping.transformation = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
#################################################################################################
# triplanar with same uv map
scene.textures.1866357596360Color.type = "imagemap"
scene.textures.1866357596360Color.file = "F:\Users\Michael\AppData\Local\Temp\tmp4hm448oa.png"
scene.textures.1866357596360Color.wrap = "repeat"
scene.textures.1866357596360Color.mapping.type = "uvmapping2d"
scene.textures.1866357596360Color.mapping.uvscale = 0.5 -0.5
scene.textures.1866357596360Color.mapping.uvindex = 0
scene.textures.1866357596360Color.mapping.rotation = 0
scene.textures.1866357596360Color.mapping.uvdelta = 0 2
scene.textures.1866357596360Color.channel = "default"
scene.textures.1866357596360Color.gamma = 2.2000000476837158
scene.textures.1866357596360Color.gain = 1
#
scene.textures.1866357582968Color.type = "triplanar"
scene.textures.1866357582968Color.texture1 = "1866357596360Color"
scene.textures.1866357582968Color.texture2 = "1866357596360Color"
scene.textures.1866357582968Color.texture3 = "1866357596360Color"
scene.textures.1866357582968Color.mapping = "uvmapping3d"
scene.textures.1866357582968Color.mapping.transformation = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
scene.textures.1866357582968Color.mapping.uvindex = 0
#################################################################################################
# triplanar with different uv map
scene.textures.1866988283512Color.type = "imagemap"
scene.textures.1866988283512Color.file = "F:\Users\Michael\AppData\Local\Temp\tmp4hm448oa.png"
scene.textures.1866988283512Color.wrap = "repeat"
scene.textures.1866988283512Color.mapping.type = "uvmapping2d"
scene.textures.1866988283512Color.mapping.uvscale = 0.5 -0.5
scene.textures.1866988283512Color.mapping.uvindex = 0
scene.textures.1866988283512Color.mapping.rotation = 0
scene.textures.1866988283512Color.mapping.uvdelta = 0 2
scene.textures.1866988283512Color.channel = "default"
scene.textures.1866988283512Color.gamma = 2.2000000476837158
scene.textures.1866988283512Color.gain = 1
#
scene.textures.1866988282520Color.type = "triplanar"
scene.textures.1866988282520Color.texture1 = "1866988283512Color"
scene.textures.1866988282520Color.texture2 = "1866988283512Color"
scene.textures.1866988282520Color.texture3 = "1866988283512Color"
scene.textures.1866988282520Color.mapping = "uvmapping3d"
scene.textures.1866988282520Color.mapping.transformation = 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1
scene.textures.1866988282520Color.mapping.uvindex = 1
Attachments
triplanar.png
triplanar.blend
(1.62 MiB) Downloaded 188 times
i7 5820K, 32 GB RAM, NVIDIA Geforce RTX 2080 SUPER + GTX 1080, Windows 10 64bit, Blender 2.83.5
Support LuxCoreRender project with salts and bounties
User avatar
lacilaci
Donor
Donor
Posts: 1969
Joined: Fri May 04, 2018 5:16 am

Re: Triplanar mapping / stochastic texturing

Post by lacilaci »

Good, hope this get's solved and we can start using uv-less objects easily.

By the way, is this a good base for stochastic/random texturing like here in fstorm:
tiles:
67801476_859576087762793_4763192252514172928_o.jpg
randomized(with locked rotation so pattern is straight):
68961877_859576027762799_4664134930685493248_o.jpg
or is this unrelated feature?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Triplanar mapping / stochastic texturing

Post by Dade »

I have reworked a bit triplanar texture code and now it works as I expect:

image.jpg

The texture takes a new parameters (".uvindex") to select the UV channel to set (usually 0) and the mapping type should always be "localmapping3d" (the other don't make very much sense):

Code: Select all

scene.textures.tex.type = triplanar
scene.textures.tex.texture1 = tex1
scene.textures.tex.texture2 = tex2
scene.textures.tex.texture3 = tex3
scene.textures.tex.uvindex = 0
scene.textures.tex.mapping.type = localmapping3d
@Neo, can you merge the pull request, add the support for new ".uvindex" parameter and hard code the "localmapping3d" mapping type ? I don't think it is worth exposing that parameter.
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Triplanar mapping / stochastic texturing

Post by Dade »

lacilaci wrote: Fri Jan 03, 2020 7:47 am or is this unrelated feature?
It is not related to triplanar mapping but it can be implemented as a special type of mapping :idea:
Support LuxCoreRender project with salts and bounties
User avatar
lacilaci
Donor
Donor
Posts: 1969
Joined: Fri May 04, 2018 5:16 am

Re: Triplanar mapping / stochastic texturing

Post by lacilaci »

Dade wrote: Sat Jan 04, 2020 1:34 pm I have reworked a bit triplanar texture code and now it works as I expect:


image.jpg


The texture takes a new parameters (".uvindex") to select the UV channel to set (usually 0) and the mapping type should always be "localmapping3d" (the other don't make very much sense):

Code: Select all

scene.textures.tex.type = triplanar
scene.textures.tex.texture1 = tex1
scene.textures.tex.texture2 = tex2
scene.textures.tex.texture3 = tex3
scene.textures.tex.uvindex = 0
scene.textures.tex.mapping.type = localmapping3d
@Neo, can you merge the pull request, add the support for new ".uvindex" parameter and hard code the "localmapping3d" mapping type ? I don't think it is worth exposing that parameter.
Thanks. Can't wait to get my hands on this..
User avatar
alpistinho
Developer
Developer
Posts: 198
Joined: Thu Jul 05, 2018 11:38 pm
Location: Rio de Janeiro

Re: Triplanar mapping / stochastic texturing

Post by alpistinho »

Dade wrote: Sat Jan 04, 2020 1:34 pm I have reworked a bit triplanar texture code and now it works as I expect
Thanks for the help!
Support LuxCoreRender project with salts and bounties
neo2068
Developer
Developer
Posts: 260
Joined: Tue Dec 05, 2017 6:06 pm
Location: Germany

Re: Triplanar mapping / stochastic texturing

Post by neo2068 »

Thanks Dade for reworking. There is still something strange. With local mapping it shouldn't matter how the object is transformed but if you rotate the object then the texture gets distorted. Is the hitpoint position or normal evaluated in local or global coordinate frame?
triplanar.png
i7 5820K, 32 GB RAM, NVIDIA Geforce RTX 2080 SUPER + GTX 1080, Windows 10 64bit, Blender 2.83.5
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Triplanar mapping / stochastic texturing

Post by Dade »

neo2068 wrote: Sat Jan 04, 2020 4:13 pm Is the hitpoint position or normal evaluated in local or global coordinate frame?
I think it may be a problem with the normal not being transformed (only the point is), I will check.
Support LuxCoreRender project with salts and bounties
Post Reply