Random Instance Textures using OSL

Forums: Random Instance Textures using OSL
Newtek Lightwave 3D (exporter developed by holocube, Integrated Plugin developed by juanjgon)

Moderator: juanjgon

Random Instance Textures using OSL

Postby baltort » Wed Mar 20, 2019 2:46 pm

baltort Wed Mar 20, 2019 2:46 pm
Hi all,

Apologies if this has already been discussed and solved. I recently needed to add A LOT of random textures to A LOT of instances. Using Octane Gradient Texture Nodes was a bit painful so I wrote a really simple OSL node to allow texture sheets. Using this method, we can pack lots of textures into a single grid. The projection node then samples one of the cells based on a the Random Color Node which is different for each instance. As long as your textures aren't to big, or you don't mind your texture sheet getting big, you can apply a lot of textures this way.

My notes from the OSL are here:

// A quick and dirty texture sheet projection node by James Dean.
// Set max count to the total number of images in your sheet (this can less than rows X columns; leave any unused cells on the right of the bottom row)
// Set rows and columns to... the number of rows and columns (what else would you set it to?).
// Connect a RandomColor Texture node up to the Random Texture slot.
// Connect the projection pin from the OSL node into the Texture Image node that holds the texture sheet

// Texture sheets don't have to be square, and nor do the cells (although they all have to be the same size).
// I suggest making the sheet pixel dimensions divisible by the number of rows and columns.
// Sticking to powers of 2 will probably make a programmer happy somewhere.

// Enjoy

texture sheet setup.jpg
Attachments
textureSheet.zip
(809 Bytes) Downloaded 209 times
baltort
Licensed Customer
Licensed Customer
 
Posts: 72
Joined: Mon Jul 07, 2014 4:00 pm

Re: Random Instance Textures using OSL

Postby milanm » Wed Mar 20, 2019 6:06 pm

milanm Wed Mar 20, 2019 6:06 pm
Ha! I made one too. Very useful.

I never posted it on the forums, just mentioned it once, I need to add preview mode and interpolation.

I used _evaluateDelayed instead so that I can have more border modes for tiling and interpolation between slices.

Code: Select all
float Select = 0;
float pu = Projection[0];
float pv = Projection[1];
float cl = Columns_x;
float rw = Rows_y;
         
float uu = ((pu/cl)+mod((1/cl)*floor(Select),1));
float vv = ((((rw-1)+pv)/rw)-mod((1/rw)*floor(Select/cl),1));

c = _evaluateDelayed( FileIn,uu,vv);


I had an idea to use it for volumetric textures but now we can do that with level set volumes and vectrons of course.

Image

Edit: And, of course I misspelled columns (facepalm)...

Cheers
Milan
Last edited by milanm on Sat Mar 23, 2019 1:12 am, edited 1 time in total.
Colorist / VFX artist / Motion Designer
macOS - Windows 7 - Cinema 4D R19.068 - GTX1070TI - GTX780
milanm
Licensed Customer
Licensed Customer
 
Posts: 261
Joined: Tue Apr 30, 2013 7:23 pm

Re: Random Instance Textures using OSL

Postby juanjgon » Wed Mar 20, 2019 11:46 pm

juanjgon Wed Mar 20, 2019 11:46 pm
Looks great! Thanks for sharing it.

-Juanjo
User avatar
juanjgon
Octane Plugin Developer
Octane Plugin Developer
 
Posts: 8867
Joined: Tue Jan 19, 2010 12:01 pm
Location: Spain

Re: Random Instance Textures using OSL

Postby baltort » Mon Mar 25, 2019 11:10 am

baltort Mon Mar 25, 2019 11:10 am
Hi Milan,

Whilst you lose credit for not posting it, you definitely win in your choice of sample image!

Looks great!

J.

milanm wrote:Ha! I made one too. Very useful.

I never posted it on the forums, just mentioned it once, I need to add preview mode and interpolation.

I used _evaluateDelayed instead so that I can have more border modes for tiling and interpolation between slices.

Code: Select all
float Select = 0;
float pu = Projection[0];
float pv = Projection[1];
float cl = Columns_x;
float rw = Rows_y;
         
float uu = ((pu/cl)+mod((1/cl)*floor(Select),1));
float vv = ((((rw-1)+pv)/rw)-mod((1/rw)*floor(Select/cl),1));

c = _evaluateDelayed( FileIn,uu,vv);


I had an idea to use it for volumetric textures but now we can do that with level set volumes and vectrons of course.

Image

Edit: And, of course I misspelled columns (facepalm)...

Cheers
Milan
baltort
Licensed Customer
Licensed Customer
 
Posts: 72
Joined: Mon Jul 07, 2014 4:00 pm

Return to Lightwave 3D


Who is online

Users browsing this forum: No registered users and 15 guests

Tue Apr 23, 2024 3:20 pm [ UTC ]