OSL Random Tile Texture

Forums: OSL Random Tile Texture
Maxon Cinema 4D (Export script developed by abstrax, Integrated Plugin developed by aoktar)

Moderator: aoktar

OSL Random Tile Texture

Postby Koler » Fri Dec 02, 2022 12:00 pm

Koler Fri Dec 02, 2022 12:00 pm
Hello everyone

I want to create a tile material as in the attached file (Reference material). I have 4 sets of maps (diffuse, roughness, normal, displacement) for 1 element of the pattern and I want to place them randomly inside the pattern. I tried using some OSL textures from Octane OSL utilities and SimpleTile.OSL https://github.com/ADN-DevTech/3dsMax-OSL-Shaders/blob/master/3ds%20Max%20Shipping%20Shaders/SimpleTiles.osl, but unfortunately I could not achieve the desired result. If someone has experience in creating such materials, I would be very grateful for help. For convenience, I created a simple test scene, it can be found in the attachment.
Attachments
OSL_Tile.zip
Test scene
(182.1 KiB) Downloaded 41 times
photo_2022-11-28_13-06-26.jpg
Reference material
Koler
Licensed Customer
Licensed Customer
 
Posts: 4
Joined: Fri Jul 28, 2017 12:00 pm

Re: OSL Random Tile Texture

Postby SSmolak » Fri Dec 02, 2022 6:51 pm

SSmolak Fri Dec 02, 2022 6:51 pm
Hi, as I know there is no working OSL script for that in Octane but you can use three methods :

1. Using Octane Instance ID for different objects :

ID.jpg


It needs some preparation. Individual polygons should be extracted to objects using C4D Polygon Islands to Objects. After that Octane Object tag is needed for all of them, select them all and in Instance ID put "num+1" to make every object individual Instane ID number.

2. Using random Vertex Map :

Select polygons and use random_vertex_color.py script to create Vertex Map with random colors.
random_vertex_color.zip
(1.07 KiB) Downloaded 36 times


3. Using Fracture but this is buggy at the moment ( reported it ) but there is limited workaround.
For this method you can use build-in nodes or using OSL :
RandomInstanceColor.osl
(144 Bytes) Downloaded 38 times


All examples with materials using three methods:

random_tiles.zip
(154.25 KiB) Downloaded 39 times

tiles.jpg


Just replace RGB Spectrum nodes with your Texture Images

I see that this code from your link works fine. Also we have built-in nodes like Tile patterns, OSL c4d-tiles.osl.

Some threads :

viewtopic.php?f=9&t=79536
viewtopic.php?f=30&t=74396
viewtopic.php?f=30&t=78482

but the best is Q-Tile Pro : https://3dtools.info/tilepro
Architectural Visualizations http://www.archviz-4d.studio
User avatar
SSmolak
Licensed Customer
Licensed Customer
 
Posts: 1088
Joined: Sat Feb 07, 2015 5:41 pm
Location: Poland

Re: OSL Random Tile Texture

Postby roeland » Sun Dec 04, 2022 9:29 pm

roeland Sun Dec 04, 2022 9:29 pm
Yeah this comes up sometimes, there are a few ways to achieve this. It depends on whether you have the tiles as separate images or as one texture atlas, and whether the tiles are separate objects or one mesh.

For the one mesh / separate image tiles case, one way is to load the sets of images into an image tiles node, and use a to use an OSL shader as UV input. This image tiles node is similar in concept as UDIM, although the OSL shader I attached assumes the images are arranged in one vertical row.

The custom OSL shader by itself has a projection and transform input similar to any built-in texture, so you can put it on a wall with box mapping.

laminate tiles example.orbx
(4.54 KiB) Downloaded 38 times
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1810
Joined: Wed Mar 09, 2011 10:09 pm

Re: OSL Random Tile Texture

Postby SSmolak » Sun Dec 04, 2022 9:44 pm

SSmolak Sun Dec 04, 2022 9:44 pm
roeland wrote:
The custom OSL shader by itself has a projection and transform input similar to any built-in texture, so you can put it on a wall with box mapping.

The attachment laminate tiles example.orbx is no longer available


Thank you it looks that great script you presented here but why it looks different in Cinema 4D, without plank size ?

osl_tiles_C4D.jpg
Architectural Visualizations http://www.archviz-4d.studio
User avatar
SSmolak
Licensed Customer
Licensed Customer
 
Posts: 1088
Joined: Sat Feb 07, 2015 5:41 pm
Location: Poland

Re: OSL Random Tile Texture

Postby roeland » Mon Dec 05, 2022 1:01 am

roeland Mon Dec 05, 2022 1:01 am
SSmolak wrote:Thank you it looks that great script you presented here but why it looks different in Cinema 4D, without plank size ?


It is possible that the Cinema4D plug-in is not able to map the type of that input to a UI widget. This is a version with 2 float inputs for the tile size:
Attachments
laminate tiles example.orbx
(33.61 KiB) Downloaded 41 times
User avatar
roeland
OctaneRender Team
OctaneRender Team
 
Posts: 1810
Joined: Wed Mar 09, 2011 10:09 pm

Re: OSL Random Tile Texture

Postby SSmolak » Mon Dec 05, 2022 1:10 am

SSmolak Mon Dec 05, 2022 1:10 am
roeland wrote:It is possible that the Cinema4D plug-in is not able to map the type of that input to a UI widget. This is a version with 2 float inputs for the tile size:


It looks good now except text strings :

osl_tiles2_C4D.jpg
osl_tiles2_C4D.jpg (9.35 KiB) Viewed 831 times


Thank you for creating this. I will test it soon :)
Architectural Visualizations http://www.archviz-4d.studio
User avatar
SSmolak
Licensed Customer
Licensed Customer
 
Posts: 1088
Joined: Sat Feb 07, 2015 5:41 pm
Location: Poland

Re: OSL Random Tile Texture

Postby SSmolak » Sat Feb 25, 2023 7:28 pm

SSmolak Sat Feb 25, 2023 7:28 pm
If someone interested I added option to offset tiles between rows and moving whole pattern by X and Y.
Attachments
Tiles Projection.zip
(863 Bytes) Downloaded 29 times
Architectural Visualizations http://www.archviz-4d.studio
User avatar
SSmolak
Licensed Customer
Licensed Customer
 
Posts: 1088
Joined: Sat Feb 07, 2015 5:41 pm
Location: Poland

Return to Maxon Cinema 4D


Who is online

Users browsing this forum: No registered users and 16 guests

Fri Apr 19, 2024 3:16 am [ UTC ]