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
Random Instance Textures using OSL
Moderator: juanjgon
- Attachments
-
- textureSheet.zip
- (809 Bytes) Downloaded 261 times
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.
I had an idea to use it for volumetric textures but now we can do that with level set volumes and vectrons of course.

Edit: And, of course I misspelled columns (facepalm)...
Cheers
Milan
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);

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
macOS - Windows 7 - Cinema 4D R19.068 - GTX1070TI - GTX780
Hi Milan,
Whilst you lose credit for not posting it, you definitely win in your choice of sample image!
Looks great!
J.
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.
I had an idea to use it for volumetric textures but now we can do that with level set volumes and vectrons of course.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);
Edit: And, of course I misspelled columns (facepalm)...
Cheers
Milan