beep

osl random projection on instances

Nov 10th, 2019
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. #include <octane-oslintrin.h>
  2.  
  3. shader textureSheet (
  4.  
  5. output point uvOut = 0,
  6.  
  7. int maxcount = 16
  8. [[int min=1, int max=10000]],
  9.  
  10. int columns = 4
  11. [[int min=1, int max=100]],
  12.  
  13. int rows = 4
  14. [[int min=1, int max=100]],
  15.  
  16. color RandomTexture = color(1, 0, 0)
  17.  
  18. )
  19.  
  20. {
  21. color c2 = _evaluateDelayed(RandomTexture, 0.5, 0.5);
  22. int instRnd = (int) floor(c2[0]*maxcount);
  23.  
  24. int column = instRnd % columns;
  25. int row = (int)floor(instRnd / columns);
  26.  
  27. float U2 = (u + column) / columns;
  28. float V2 = (v + rows - row - 1) / rows;
  29.  
  30. uvOut = point(U2, V2, 0);
  31.  
  32. }
Advertisement
Add Comment
Please, Sign In to add comment