Halloween Costume ideas 2015
Articles by "osl"
@dorothiar #arttips #interview 101 2 Column Template 2012 mentee 2013 2013 mentee 2014 2014 mentee 2014 Portfolio Winner 2014 SCBWI Portfolio Mentorship Winner 2015 mentee 3 Column Template 360 3d 3d print 3d printing 3delight 8bit Abbey McCulloch abstract acryla gouache acrylic action addon adobe Adobe Flash CS3 Adobe Illustrator Advanced Tutorials advection Advertising advice Agata Wierzbicka agents airplane Al Wiseman ALA Alan E. Cober Alan Lee Alex Ross Alexandra Compain-Tissier Alexandra Lekias Alexandra Levasseur Alexandre Korobov Alexis Winter algorithm alien ALT Amelie Hegardt Amit Shimoni amusement an Ana Aranda analog Andrea Hrjnak Andrea Hrnjak andrea offermann andreaoffermann andreazuill Andy Musser Angela DiTerlizzi Angelika Peißker animal logic animals animation animation nodes anime anisculpt Anja Kroencke Anna Higgie Anna Jensen Anna McKay Annabel Briens AnneBerry Anneke Krull Annu Kilpeläinen anstudy anthology António Soares ar arduino area armature arrange array array modifier arrow art art director art directors Art is fun! art reps art tools Artaksiniya arthictecture arthur rackham artists artwork ase Ashlyn Anstee Asian aspiring asset atom attribute attribute transfer audio Audrey Kawasaki augmented reality aurasma Aurelius Battaglia author illustrator automatic automation Autumn Whitehurst avatar Avrom Yanovsky AW14/15 award awards Babeth Lafon Babies baboon Baby Love Background background color bacteria bake baking ball Bamboo banner Banner images banner making Barbara Dziadosz barcode basic bbox beads beats Bec Winnel beginner Bel Johnstone Ben Denison Bernie Fuchs Berto Martinez Beth Krush better photos bge Bijou Karman Bike biscuit bishop black and white black and white art Blair Breitenstein blam blender blender game engine blender3d blending Blinkie Blinky blob blocks Blog Tips blogger Blogging Friends blogs Blonde blur effect in pixlr and photoshop blur images and pictures bmesh bmesh viewer bolognaragazziaward bombing bone bone modeling bones book book launch books boomerang bottle bounding box bowl bpy brian eno brian ormiston Brian Sanders brian won brick bridge Bridget Davies bright Brooke Boynton Hughes build modifier building burns business Buttons bvh cage Caitlin Shearer caldecott calibration camera camera settings camera tips Candle capcom card career Carole Wilmet cartoony Cassandra Rhodin cast Catherine Campbell Cecilia Carlstedt cell center pivot centipede cg cg photography chair challenge Chanel changin color in pixlr changing color chaos character Character Bible character development charcoal charles Charlie Dot Charlie Hebdo Children children's book illustration chocolate Christina Drejenstam christina forshay Christina K christinaforshay Christmas Cindy Derby circle circle dance city cityengine clock clones cloning cloth Cloud based clover CMYK Coco Chanel Cody and the Fountain of Happiness coffee collect collection Collections collision color color balance color cast color correction color mode color study colorful Commercial Use complexity component compositing composition computational thinking computer concept art Condensed Posts conference connect connect the dot connection Connie Lim Conrad Roset constrain constrast contagion content Contest contracts control converter copy copyright Corinna Luyken count Courtney Brims crack Craft craftsmanship Craig & Karl creative creativity creature cricket Cristina Garcia Martin critic criticism critique Crop Crop Tool cross section crowd csv cubism curve curve modifier custom Custom Blog Design Custom Blog Design Tutorial Custom Blog Designers Custom Illustration custom properties Custom Signature custom xml cut cutting plane cycle cycles dae Damien Florébert Cuypers Dan Hillier dance Daniel Egnéus Daniel Segrove Danny Roberts Daren Newman Dasha Tolstikova data data path David Blossom david diaz David Shrigley David Stone Martin Dean Hardscrabble Debbie debbie ohi debbieohi deform deformer degrees deleting background in pixler demo demoscene desaturation of images design design by numbers design process Design Tips dictionaries dictionary Different Text Writing in Pixlr digital digital paint Digital Scrapbook Freebies Digital Scrapbooking disk distance distractions distribute diversion DIY DIY Contest Dolf Veenvliet Doll Doll Bones dolls domino domino effect doodle Doodles door doraemon Doris Jackson Dorothia Rohner dots dpi draw drawing drill driven driver drivers dual versions dummy duplicate duplicates duplication dupliframe dvd dynamic dynamic paint dynamic text E Simms Campbell Easy easy pixlr Easy Tutorials Ed Graham Ed Vebell editing editing photos editors education effect effects ego Eleanor Dalton electric Elia Fernández eliza wheeler Elizabeth Mayville elizawheeler Emily Forgot Emma Zanelli emoticon happy-face Emotional storytelling empathetic characters empty entoforms envy epicycloid EPS Illustration Epson scanner erasers Erin Armstrong Erin Petson erinoshea ernest shepard Esra Roise euler evaluate line Eveline Tarunadjaja evenly spacing vertex event everywhere door exhibition Expandable Posts experiments explode exploded view export expression extrude eye eye color in pixlr eye trick eyeball face rig facial expressions facial setup factory Faiyaz Jafri Families fashion illustration fashion week fcurve feature Featured Fee Harding Feedback fence Fernanda Guedes fibonacci Fifi Lapin file File Types Finalists Finding Nemo fire fix photos Flash Tutorials flicker flip flip flop floor flop flow flower Flowers fnmatch focal point follow up font Fontaine Anderson Fonts food footage For Sale force form formula fractal fracture frame Frames Francois Berthoud Frank Bellamy Frank Furlong Franklin McMahon freckles Fred Steffen FrederiqueBertrand Free for Commercial Use Free for Personal Use Free Stock Photography Free transform tool Freebies Frenchillustration Fritz Siebel frosted mylar fruit ninja Fumi Mini Nakamura Fun function futurism FW2017 fx Gabriel Moreno Gabriella Ibarra game game animation gameart gamma gangnam style Garance Doré Gary Fernandéz gel medium generate generative generator geometric geometry Gerald Lazare Géraldine Georges GIF Gildo Medina Girl Giuseppe Castellano Giveaway glorar goals golden ratio google google docs Google Tools Grant Young graph graphite graphite transfer grease pencil grid group group node growth Gucci Guest Guil Godier gustave dore hair handbook Harper's Bazaar harpercollins Harvey Schmidt Haute Couture head Headers heat map Helena Hauss hexagon hexagonal grid Hiroshi Mizuno Hiroshi Tanabe Holiday Holly Black homology honeycomb hook horror houdini how to how to blur a face or an object in pixlr How to change eye color how to delete an object how to desaturate an image how to edit a image in pixlr how to erase an object how to fix red eye problem how to fix red eyes in pixlt How to fix the parts in pixlr in photoshop How to make a banner in pixlr How to overlap the nevus how to remove a object How to remove an object in pixlr how to remove red eyes How to Remove the Background of an Image in Pixlr How to remove the parts that you don't want in pixlr and photoshop how to replace color How to write a Patterned Text in Pixlr how-to Hsiao-Ron Cheng hsv hue humor Hyshil I love illustration magazine idea ideas Igor+André illusion illustrating illustration illustration board Illustration Books Illustration Intensive Illustration Now! Fashion illustration process Illustrations Illustrative Berlin illustrator Illustrator Intensive Illustrator Tutorials iloveillustration magazine image ediditing lessons Image Ready image sequences image theft imaginative import import text import vertex color improving photos inbetween index visualizer Info Ingrid Bockting ink inktober input Inspiration inspirational quotes install instance instance switching intensive interaction Intermediate Tutorials internet interoperability interpolation intersect intersect edges intersecting intersection interview introduction invoke subprogram io ipad Irana Doucer Isabella Hemmersbach islam islamic iteration Izzie Klingels Jack Hearne Jack Tremblay James Dignan James Gurney japanese Jason Brooks Jean Kim Jeanne Detallante Jen and Chris Creed Photography jen betton Jen Rofé Jenny Mörtsell Jeremy Combot Jeslyn Kate Jesse Auersalo Jessica Jessica Lanan jessicalanan jewellery jewelry jiggle Jim Schaeffing Joe Bowler Joe Cleary Joe Isom Joe Krush Johanna Goodman john maeda John Vernon Lord joint Jordan Sondler JPEG JPG jpop juana martinez-neal juanamartinezneal Judge Judit Garcia Talavera Judith van den Hoek Judy Byron Schachner Jules Julien Julian Beever Julie Verhoeven Jump Break Tool JW Anderson K-Fai Steele Kaethe Butcher Kareem Iliya karel zeman Kate van Harreveld Kathrin Kuhn Kathryn Ault Noble Kathryn Noble Katie Kath kdtree Kei Meguro Kelly Beeman Kelly Light Kelly Smith kelly sonnack Kelly Thompson keyframe keyframing kidlit kidlitartists kimberlygee Kirkus Review Kisoo Chai Kodak Konstantin Kakanias Korean illustration Kotaro Chiba Kozue Himi Kremos Ksenia Finogeeva KT Smail kuler Kustaa Saksi Lanan Laptop larry gritz lasso tool latte lattice Laura Callaghan Laura Laine Lauren Rille layer layering Layla Holzer layout leaf learning learning blender LED Leendert meets Ingrid lego length Leonard Starr lessons levels LFW A/W 14 liangzhu liero lightbox lighting lightning Lina Bodén Lina Ekstrand Linda Dorn line line connect line drawing lines Links Linky Love Linn Olofsdotter Lionel Gilbert Lisa Anchin Lisa Billvik Lisa Krannichfeld lisaanchin lisbeth zwerger Liselotte Watkins list list comprehension List First Last listing locator lofting logo Logo Design Lola Dupré London Fashion Week loop looping loops looptools Lorraine Fox lossless lossy lost weekend lostweekend lotte reininger Louis Glanzman louis vuitton Luciana Rondolini luciograph LULU* lv Lynnie Zulu Mac macgyver macouno maeda Magda Antoniuk magic Magnus Voll Mathiassen mailing mailings maker Makiko Sugawa making banners Malika Favre MAMP mandala manga map map range maplelam mapping Marcel George Maren Esdar Margot Macé Margot van Huijkelom Maribeth Olson Marie El-Ahmar Marilyn Conover Marina Esmeraldo Marine Marbleindex mario Marlies Niemeijer Marsha Riti Martha Rago Martin Krusche Martine Johanna mask masking material materials math matrix matrix apply matryoshka Matt Baker matte medium Matthew Woodson maya maze mdd Meagan Morrison measure megaman Megan Hess Meizhen Xu Mel Crawford memory mentee mentees mentors mentorship program Mercer Mayer Meridth McKean Gimbel mesh mesh cutter meshlab Meta Tags metal gear rising Meyoko Mia Overgaard Micca mice Michael Sanderson Michela Picchi middle grade midi miku Milan milipede minidom Minima Mio Matsumoto mirror cut Misc Miss Blackbirdy miss maple's seeds Miss Take Mitchell Hooks mixamo mixing Mobile Apps mocap mod model modeling modifier modular modulation modulus mold molecule molly idle Molly Ruttan Molly Ruttan Illustration money monitors monkey mono-zero monster monster university morph morpher mosaic mosquito motion motion capture motion capture mouse motion trail moto360 mountain muji Muriel Wood Murray Tinkelman mushroom Music and Podcasts My dead pony Nadia Flower Naiad Einsel Naja Conrad-Hansen Natalie Brockett Natalie Foss nathan vegdahl nautilus Nav Bar navigation needle-felting negotiating Neil Boyle neon nescbwi14 nested New Blogger Questions New Blogger Template Tutorials new user pixlr new year new york New York Fashion week Newbery nicholas nicholas bishop Nicholas Hong Niki Pilkington Niso Ramponi nla No Software node node-based nodebox noise non linear animation Non-Web Font normal Noumeda Carbone npr number NURBS NYFW object object color change object info octopus offset Ola Volo Olaf Hayek old formats opaque projector open movie open shading language open source openshadinglanguage opensoundcontrol optical organization origami original art show Ornaments osc Oscar Schlienger osipa osl outline outliner output Pages paint paint weight painting painting on illustration board painting on wood painting with movie painting with numbers Pair pandas panorama Paper paper lantern parabola parametric parent parenting particle particle info node particles pat david Pat Zietlow Miller pattern Patterned Text Paul Faassen Paul X. Johnson Paula Sanz Caballero PC pdb pebbles pencil Pencil Sketch pencils Penguin perfume perlin Peter Helck Photo CD.8B photo editing software Photo Reference Photobucket photographing art Photographs photography photomerge photoshop Photoshop Brushes Photoshop CS3 Photoshop elements photoshop pixlr desaturaion Photoshop tips Photoshop Tutorials Picture Book Builders picture books Pierre Louis Mascia Piet Paris Pietari Posti pingpong pinnochio pipes pixar pixel pixel art pixel generator pixlr Pixlr advanced Pixlr blog pixlr desaturate keep a colorful part pixlr editting pixlr express Pixlr forum Pixlr free transform Pixlr Lesson Pixlr lessons Pixlr mobile Pixlr resizing images pixlr shortcuts Pixlr tools pixlr tutorial pixlr tutorial with pictures Pixlr Tutorials pixlr white black pixlr.com plant plot plotting ply PNG PNG Illustration podcast point point color pointilism polka dots polyCut polygon Pomme Chan pop-overs portfolio Portfolio award portfolio showcase portfolio-advice portrait position Post Dividers postcard poster Posting pot powdered graphite powerhousemuseum Prada presentation print printmaking Prize procedular procedural process processing programming projection Promotion property prototype PSD psy publishing pulse puppet puppetry pydriver pydrivers pyhandler pyhandlers pyramide python quad quick select set quick tips qumarion Rabbit Moon Rachel Ryle radians radius ramp random random motion randomization randomize range float raspi Ray Houlihan reading reading XML READY-TO-WEAR realflow Rebecca Clarke rebecca dautremer Rebecka Skog rebuild recursive recursivedrawing red eye remove reducing glare reference referencing release remesh modifier remix removal remove remove red eyes remove unwanted objects Removing backgroung render rendering renderman repeat repeater repeating replace replacement replacing color representation rerouter resample resampling research Resizing image resolutions retopology retro review revolve rgb rib Ricardo Fumanal Richard Scarry rig rigging rigify Rikke Jorgensen ring ripple roadkill Robert Heindel Robert J. Lee Robert McCloskey Robert Shore Roberta Zeta Robin Rosenthal robot robotic rocks Rodolfo Montalvo Roller Coaster rotation Rousseau rsl Rubin Pfeffer ruler tool Russ Mills russian rut S/S14 S/S15 S/S16 Sabine Pieper sadako Saftey Pins Sainte Maria Sale Sam Weber Sanda Suy Sandy Kossin santoso Sara Andreasson Sara Singh Sarah Jacoby saturation artist tools scan scanners scanning scatter scbwi SCBWI 2015 mentee SCBWI conference scbwi germany SCBWI mentorship scbwi-la scratch scratchboards screensaver screw screw modifier script scrub sculpting seamless Seamless Patterns Search Engines select by material select by name select by type SEO sequence series set keyframe set keyframes shader shading shadow Shannon Stirnweis shape grammars shape key shapekeys shapes shards shatter Sheilah Beckett shell ship shipping shipwright Shoes SHOWstudio shuffle Sid Barron Sidebar Titles Signature Silja Goetz silkworm Simon and Schuster Simon Varela simple simplicity simulation sine Site Engine Optimization Sjoukje Bierma sketch Sketches sketching skin skin modifier skinning slice slicing slides sloth slow parent smoke smoothstep SN snake Sneek Peek snippet Snow Snow White Snowflakes soccerball social media Social Media Buttons Social Networking society of illustrators Society6 soft body softbody Sonia Menti sound sound wave space spaceship sparta special spider spiderman spiderweb spin spiral Spiros Halaris Spiros Halaris x Urban Decay spline Spot Healing Tool spreadsheet SS16 stack stacking stair stamp Stan Galli star starfish stencyl step Steven G. Dobson still Stina Persson stone stones storytelling strand strand info strands street art string stripes structure studies studio style stylistic summary Summary Posts Summer sun supplies surface Susan Farrington suzanne Suzanne Kaufman sverchok swatch switch sydney system table table of contents take out background Tal Drori tangent tangled Taschen teaching teapot Template Templates tentacle Tess Jacobson Tex Avery text text editor Text Formats Text Styles in Pixlr texture texturing The Cartorialist The Grudge Keeper The Purple Book thinker1 Thomas B. Sawyer thread TIFF tile tilecam tiling time time code Tina Berning Tina Kugler tips tips for artists Toby Neilan Tom Baxter Tom Bjarnason tombow tomie depaola tool tools topology tower Tracy Turnbull Train transfer drawing transferring sketch transform transformation transit travel triangle wave Tricia Springstubb trigger tris tristan lock tube tubes Tutorials twitter type tool typeface typography unbake unity3d universal unquad utah uv valentine Valentino Valerie Servais vanilla variable variation variety vase vector vectorized Velwyn Yossy venus Veronica Ballart Lilja vertex vertex color vertex group vertex paint vertex weight VFX Victoria Boysen video Videos viewer Vintage virtual virtual studio visualization vivid vividfestival VOGUE volumetric voronoi Vote voxel voxelated voxelation walking teapot Walter Einsel wand tool water soluble graphite watercolor wav wave we need diverse books web webbing Week Themes weight welcome Wendy magazine Wendy Plovmand what casues red eyes What is Pixlr Wherever You Go Wide Awake Bear wiggle Will Davies Winner Winnie Fitch Winnie Truong Winter wire wired wireframe wolfram Woman wood woodwork wool wooly wordpress work workflow World writing writing XML www.pixlr.com XML YA yayoi kusama Yelena Bryksenkova yoda Yoko Furusho Yuliya zaha hadid zen zsphere

Hexagon Tiles basic is not so basic.

Nothing quite original in this post, I am just trying to make sense of this Hexagon Tile Shader which originally was written by Larry Gritz.
http://www.renderman.org/RMR/Shaders/LGShaders/

Which then I found out at Blender Forum, already translated by Charlie:
http://blenderartists.org/forum/showthread.php?270332-OSL-Goodness&p=2253925&viewfull=1#post2253925

The original RSL for Hexagon Tile has extra additional layer of texture that is not really related to the hexagon tiling (stain and scuff). So, I stripped those out.



I made a slight modification and I am commenting out some more of the code, so that the shader goes back to the very basic.

OSL HEXAGON TILE



CODE: (with all the commented out codes)
/*
SHADER HISTORY 20140205

1. 
Originally written by Larry Gritz
http://www.renderman.org/RMR/Shaders/LGShaders/

2. 
Modified by Charlie as posted here:
http://blenderartists.org/forum/showthread.php?270332-OSL-Goodness/page9

3. 
Jimmy Gunawan of Blender Sushi (me) decided to study this shader...
Stripped out to the basic of the procedural texture only. Without Closure.

*/

//////////

/*
 * {converted/hacked to OSL from http://www.renderman.org/RMR/Shaders/LGShaders/LGHexTile.sl}
 * hextile.sl -- surface shader for hexagonal tiles in st space
 *
 * DESCRIPTION
 *       This surface shader operates in s-t space and gives a pattern of
 *    hexagonal tiles, similar to that found as floor patterns in public
 *    places and such.
 *       The basic pattern is a hexagona
 l tiling, with a little bit of
 *    color variation from tile to tile.  On top of that is some staining
 *    (presumably due to water or something), which darkens the tile or
 *    mortar underneath it.  Finally, there is scuffing due to people's
 *    shoes, which really only affects the tile part not the mortar part.
 *
 *
 * PARAMTERS
 *    Ka, Kd, Ks, roughness, specularcolor - work just like plastic
 *    tilecolor - the color of the tiles
 *    mortarcolor - the color of the mortar (space between the tiles)
 *    tileradius - the "radius" (in s-t units) of a single tile
 *    mortarwidth - the width of the mortar (in s-t units)
 *    tilevary - the color variance from tile to tile
 *
 * ANTIALIASING
 *    Some rudimentary antialiasing is performed on the borders between
 *    tile and mortar.
 *
 * HINTS & APPLICATIONS
 *    If all of the default parameters are used, the tiles look just like
 *    the floors in the public areas of the Washington DC subway system.
 *
 * AUTHOR: written by Larry Gritz, 1994
 *
 * HISTORY:
 *    15 Feb 1994 -- written by lg
 *
 * last modified 15 Feb 94 by Larry Gritz
 */

shader
LGHexTile (
    point Pos = P,
    //float Ka = .5,
    float Kd = .5,
    //float Ks = .2,
    //float roughness = .1,
    //color specularcolor = 1,
    color tilecolor = color(.55,0,0),
    color mortarcolor = color(.5,.5,.5),
    float tileradius = 0.2,
    float mortarwidth = 0.02,
    float tilevary = 0.15,
    float stretchH = 1.0,
    float stretchV = 1.0,
    //float scuffing = 0.5,
    //float stains = 0.4,
    //float stainfrequency = 2,
    //float scufffrequency = 4,
    //color scuffcolor = color (.05,.05,.05),
    //output closure color Closure = diffuse(N),
    int Seed = 41,
    output color Col = color(1,0,0)
)
{
    #define snoise(x) (2*noise(x)-1)
    #define snoise2(x,y) (2*noise((x),(y))-1)
    #define MINFILTERWIDTH 1.0e-7
    #define M_SQRT3 1.7320508 /* sqrt(3) */
    
    point Nf;
    color Ct, Ctile;
    float tilewidth;
    float ss, tt;
    float ttile, stile;
    float x, y;
    float mortar;
    float swidth, twidth, sfuzz, tfuzz, fuzzmax;
    float mw2, mw2srt3;
    float tileindex;
    float stain, scuff;
    float ks;

    float s = Pos[0] * stretchH;
    float t = Pos[1] * stretchV;

    swidth = abs(Dx(s)) + abs(Dy(s));
    twidth = abs(Dx(t)) + abs(Dy(t));
    sfuzz = .5 * swidth; // blurred lines
    tfuzz = .5 * twidth; // blurred lines
    fuzzmax = max(sfuzz, tfuzz);
    //Nf = N;

    tilewidth = tileradius * M_SQRT3;  
    tt = mod (t, 1.5*tileradius);
    
    ttile = floor(t/(1.5*tileradius));
    if (mod(ttile/2, 1) == 0.5)
       ss = s + tilewidth/2;
    else ss = s;
    
    stile = floor(ss / tilewidth);
    
    ss = mod(ss, tilewidth);
    mortar = 0;
    mw2 = mortarwidth/2;
    
    if (tt < tileradius) 
    {
      mortar =  1 - (smoothstep(mw2,mw2+sfuzz,ss) *
             (1 - smoothstep(tilewidth-mw2-sfuzz,tilewidth-mw2,ss)));
    }
    else 
    {
      x = tilewidth/2 - abs(ss - tilewidth/2);
      y = M_SQRT3 * (tt - tileradius);
      if (y > x) 
      {
      if (mod (ttile/2, 1) == 0.5)
          stile -= 1;
      ttile += 1;
      if (ss > tilewidth/2)
          stile += 1;
      }
      mw2srt3 = M_SQRT3*mw2;
      mortar = (smoothstep(x-mw2srt3-tfuzz, x-mw2srt3, y) *
            (1 - smoothstep(x+mw2srt3, x+mw2srt3+tfuzz, y)));
    }

    tileindex = stile + Seed * ttile;
    Ctile = tilecolor * (1 + tilevary * snoise(tileindex+0.5));

    //stain = stains * smoothstep (.5,1, noise(s*stainfrequency,t*stainfrequency));
    //scuff = scuffing * smoothstep (.6,1, noise(t*scufffrequency-90.26,s*scufffrequency+123.82));

    //ks = Ks * (1-scuff/2);
    //Ct = (1-stain) * mix(mix(Ctile, scuffcolor, scuff), mortarcolor, mortar);
    
    Ct = mix(Ctile, mortarcolor, mortar);

    //Nf = normalize(N); //no faceforward function
    //Closure = Ct*Kd*diffuse(Nf); //no aambient function
    //Closure += specularcolor*ks*microfacet_beckmann(Nf,roughness); 
    
    Col = Ct * Kd;
}

CODE: (cleaned up, but I need to ensure I leave credit and source information)
/*
SHADER HISTORY 20140205

1. 
Originally written by Larry Gritz
http://www.renderman.org/RMR/Shaders/LGShaders/

2. 
Modified by Charlie as posted here:
http://blenderartists.org/forum/showthread.php?270332-OSL-Goodness/page9

3. 
Jimmy Gunawan of Blender Sushi decided to study this shader...
Stripped out to the basic of the procedural texture only. Without Closure.

*/

//////////

/*
 * {converted/hacked to OSL from http://www.renderman.org/RMR/Shaders/LGShaders/LGHexTile.sl}
 * hextile.sl -- surface shader for hexagonal tiles in st space
 *
 * DESCRIPTION
 *       This surface shader operates in s-t space and gives a pattern of
 *    hexagonal tiles, similar to that found as floor patterns in public
 *    places and such.
 *       The basic pattern is a hexagona
 l tiling, with a little bit of
 *    color variation from tile to tile.  On top of that is some staining
 *    (presumably due to water or something), which darkens the tile or
 *    mortar underneath it.  Finally, there is scuffing due to people's
 *    shoes, which really only affects the tile part not the mortar part.
 *
 *
 * PARAMTERS
 *    Ka, Kd, Ks, roughness, specularcolor - work just like plastic
 *    tilecolor - the color of the tiles
 *    mortarcolor - the color of the mortar (space between the tiles)
 *    tileradius - the "radius" (in s-t units) of a single tile
 *    mortarwidth - the width of the mortar (in s-t units)
 *    tilevary - the color variance from tile to tile
 *
 * ANTIALIASING
 *    Some rudimentary antialiasing is performed on the borders between
 *    tile and mortar.
 *
 * HINTS & APPLICATIONS
 *    If all of the default parameters are used, the tiles look just like
 *    the floors in the public areas of the Washington DC subway system.
 *
 * AUTHOR: written by Larry Gritz, 1994
 *
 * HISTORY:
 *    15 Feb 1994 -- written by lg
 *
 * last modified 15 Feb 94 by Larry Gritz
 */

shader
LGHexTile (
    point Pos = P,
    float Kd = .5,
    color tilecolor = color(.55,0,0),
    color mortarcolor = color(.5,.5,.5),
    float tileradius = 0.2,
    float mortarwidth = 0.02,
    float tilevary = 0.15,
    float stretchH = 1.0,
    float stretchV = 1.0,
    int Seed = 41,
    output color Col = color(1,0,0)
)
{
    #define snoise(x) (2*noise(x)-1)
    #define snoise2(x,y) (2*noise((x),(y))-1)
    #define MINFILTERWIDTH 1.0e-7
    #define M_SQRT3 1.7320508 /* sqrt(3) */
    
    point Nf;
    color Ct, Ctile;
    float tilewidth;
    float ss, tt;
    float ttile, stile;
    float x, y;
    float mortar;
    float swidth, twidth, sfuzz, tfuzz, fuzzmax;
    float mw2, mw2srt3;
    float tileindex;
    float stain, scuff;
    float ks;

    float s = Pos[0] * stretchH;
    float t = Pos[1] * stretchV;

    swidth = abs(Dx(s)) + abs(Dy(s));
    twidth = abs(Dx(t)) + abs(Dy(t));
    sfuzz = .5 * swidth; // blurred lines
    tfuzz = .5 * twidth; // blurred lines
    fuzzmax = max(sfuzz, tfuzz);

    tilewidth = tileradius * M_SQRT3;  
    tt = mod (t, 1.5*tileradius);
    
    ttile = floor(t/(1.5*tileradius));
    if (mod(ttile/2, 1) == 0.5)
       ss = s + tilewidth/2;
    else ss = s;
    
    stile = floor(ss / tilewidth);
    
    ss = mod(ss, tilewidth);
    mortar = 0;
    mw2 = mortarwidth/2;
    
    if (tt < tileradius) 
    {
      mortar =  1 - (smoothstep(mw2,mw2+sfuzz,ss) *
             (1 - smoothstep(tilewidth-mw2-sfuzz,tilewidth-mw2,ss)));
    }
    else 
    {
      x = tilewidth/2 - abs(ss - tilewidth/2);
      y = M_SQRT3 * (tt - tileradius);
      if (y > x) 
      {
      if (mod (ttile/2, 1) == 0.5)
          stile -= 1;
      ttile += 1;
      if (ss > tilewidth/2)
          stile += 1;
      }
      mw2srt3 = M_SQRT3*mw2;
      mortar = (smoothstep(x-mw2srt3-tfuzz, x-mw2srt3, y) *
            (1 - smoothstep(x+mw2srt3, x+mw2srt3+tfuzz, y)));
    }

    tileindex = stile + Seed * ttile;
    Ctile = tilecolor * (1 + tilevary * snoise(tileindex+0.5));

    
    Ct = mix(Ctile, mortarcolor, mortar);
    
    // FINALLY...
    Col = Ct * Kd;
}

This Shader Writing business always seems really complicated when the code is revealed like above.

Actually if you take time to write the code line by line and try to see the result, it will be a bit easier to understand. Lots of cryptic Math formula in Shader writing, processing all kind of INPUT values.
  • mix()
  • max()
  • smoothstep()
  • abs()
  • etc...
For most basic shaders, we usually only use global variable P, which assigned to our own custom variable Pos. Of course there are many other Global Variables and values we can use.

INPUT
P (position of point of surface)

The output, we usually only care how it looks like.

OUTPUT
Col (our own custom variable)

What happened in between the INPUT P and OUTPUT Col is a lot of Math and computer graphics magics. Would be wise is to be able to observe step by step and see the resulting "color/image" texture line by line, simply by assigning it to the Col (our output).

The Math part is "hard", especially for non-Math person. Hard because of multifolds of problems.
A really good Math teacher can explain it well, but not always visually well.

TRY:
Go and YouTube search "Shader LIVE Coding" and see how the brain of good shader writers is working. I think they are not normal, they are amazing.

It is a rare to find someone with both VISUAL and MATH minded. Anyway, visualizing each step is a good start.

Not all values can be visualized as texture, some of them is just values, you can actually printing out the values. Read this:

SEEING CODE EVOLVES

CODE: (if we want to see how the texture evolving.... do not copy paste the code below)

shader
LGHexTile (
    point Pos = P,
    float Kd = .5,
    color tilecolor = color(.55,0,0),
    color mortarcolor = color(.5,.5,.5),
    float tileradius = 0.2,
    float mortarwidth = 0.02,
    float tilevary = 0.15,
    float stretchH = 1.0,
    float stretchV = 1.0,
    int Seed = 41,
    output color Col = color(1,0,0)
)
{
    #define snoise(x) (2*noise(x)-1)
    #define snoise2(x,y) (2*noise((x),(y))-1)
    #define MINFILTERWIDTH 1.0e-7
    #define M_SQRT3 1.7320508 /* sqrt(3) */
    
    point Nf;
    color Ct, Ctile;
    float tilewidth;
    float ss, tt;
    float ttile, stile;
    float x, y;
    float mortar;
    float swidth, twidth, sfuzz, tfuzz, fuzzmax;
    float mw2, mw2srt3;
    float tileindex;
    float stain, scuff;
    float ks;

    float s = Pos[0] * stretchH;
    float t = Pos[1] * stretchV;

    swidth = abs(Dx(s)) + abs(Dy(s));
    twidth = abs(Dx(t)) + abs(Dy(t));
    
    //Col = s;



    //Col = t;



    
    sfuzz = .5 * swidth; // blurred lines
    tfuzz = .5 * twidth; // blurred lines
    fuzzmax = max(sfuzz, tfuzz);
   
    
    tilewidth = tileradius * M_SQRT3;
    tt = mod (t, 1.5*tileradius);    
    //Col = tt;
Modulus function will repeat.

    
    ttile = floor(t/(1.5*tileradius));
    //Col = ttile;



    
    if (mod(ttile/2, 1) == 0.5)
       ss = s + tilewidth/2;
    else ss = s;
    
    //Col = ss;



    
    stile = floor(ss / tilewidth);
    //Col = stile;



    
    ss = mod(ss, tilewidth);
    mortar = 0;
    mw2 = mortarwidth/2;
    
    //Col = ss;


This is actually interesting, we get the STAGGER effect like BRICK TEXTURE.

    
    if (tt < tileradius) 
    {
    //Col = mortar;



      mortar =  1 - (smoothstep(mw2,mw2+sfuzz,ss) *
             (1 - smoothstep(tilewidth-mw2-sfuzz,tilewidth-mw2,ss)));

    //Col = mortar;

    }
    else 
    {
      x = tilewidth/2 - abs(ss - tilewidth/2);
      y = M_SQRT3 * (tt - tileradius);
      if (y > x) 
      {
      if (mod (ttile/2, 1) == 0.5)
          stile -= 1;
      ttile += 1;
      if (ss > tilewidth/2)
          stile += 1;
      }
      mw2srt3 = M_SQRT3*mw2;


      
      mortar = (smoothstep(x-mw2srt3-tfuzz, x-mw2srt3, y) *
            (1 - smoothstep(x+mw2srt3, x+mw2srt3+tfuzz, y)));
    }

    tileindex = stile + Seed * ttile;
    
    //Col = tileindex;


There is a bit of Math magic happening here that turns "brick" into hexagons.

    
    Ctile = tilecolor * (1 + tilevary * snoise(tileindex+0.5));

    //Col = mortar;



    
    Ct = mix(Ctile, mortarcolor, mortar);
    
    //Col = Ct * Kd;



}

MEANWHILE IN HOUDINI ...

In Houdini, there is a node called HEXTILE to generate hexagonal tile.



Blender can easily have this hexagonal tile texture as a built-in node as well like the nice Brick Texture node, but what would be nice for us is to understand how this texture tiling was created in the first place.

I tried digging down into the code in Houdini, but the code is hidden inside the #INCLUDE. I have to investigate this further... I am using Mac here and lots of files is inside package, I must check again on the Windows version.

Ok, basically Houdini's VEX Shader Programming Language is more similar to Renderman RSL. OSL is probably "simpler" and I think the nicest part of OSL is being easy to compile in Blender Cycles.

Anyway, if you are like me, always challenged to understand "complexity" and love "procedurality", use all the available tools. Houdini can be your best tool beside Blender.

You see below the difference between Shader Writing VS Node.




OpenGL Programming and such and such...

I am also looking into Shader Writing in Unity, which uses CG language where we need to think about Vertex Shader and Fragment (Pixel) Shader, which of course relates to OpenGL programming.

There is this nice intro video talking about OpenGL Shader Programming from SIGGRAPH 2013:
http://www.youtube.com/watch?v=T8gjVbn8VBk

Shader Writing is certainly something that one needs to study over a very long period of time. It is very abstract like Fractal.

It is unlike Game Programming or other kind of programming, it is simply bizarre. Looking at what people creates using codes is just mind-boggling:
https://www.shadertoy.com

I am still reading this invaluable book by Michel Anders, there is a really well written foundation on shader writing there.

REFERENCES AND INSPIRATIONS

I took a little walk around city of Bandung (West Java, Indonesia) and took some photos. This city that is an ex-Dutch colonization still shows the architecture from the past.








Anyway, writing shader is always a nice brain exercise, now back to Sverchok stuff :)

One only really knows how deep the water when he jumps, otherwise he will only be touching the surface.

After reading that book titled "Open Shading Language for Blender" by Michel Anders which I reviewed in previous post, I decided to revisit some of previous OSL topics and hopefully can make some parts clearer and will explore further some basic concepts.

From this post onward, I am going to write OSL shaders following the structure that Michel uses. And I will probably use some snippet of codes from Michel book, such us when we like to Rotate or Scale or to Mirror procedural textures. When I do so, I will give credit to Michel.

My focus is still on the Procedural Texture and Patterns Generation only, but overtime, I want to also start discovering some useful OSL features we can use.

CONTROLLING SIGNAL USING THE FORCE

I use word "The Force" in the previous posts to help some beginners to grasp the basic concept of pattern generation. Whenever using "The Force", we are really using Math FUNCTIONS (2D or 3D functions) that generates pattern or further modify and reshape pattern. It is okey, you can still think of function as the force.

As you may already see in previous posts, the easiest way we can apply a FUNCTIONS and to actually generate a procedural texture is: to insert the function as a FACTOR of mix() function that will then modulate between 2 colors. The mix() function does this kind of job of MIXING 2 colors really well as we can see later.

Ok, if above paragraph might sound very alien to you, do not worry, I am really going to go back to the basic and slowly building up the complexity.

MATH, FUNCTIONS, AND OSL

Function is a "magical force" that takes input and gives you an output. The "magical force" is Math operations. The Math can be very simple like addition, but can also be really complex.

We do not need to worry about the complexity of functions, all we need to care is to know which function does what to the input and just apply it to get the output.

In computer graphics, we really use functions all the time. Maybe some of you have some computer animation background and you know that you can graph a motion.

With OSL, we will be dealing with function, but especially to see how function can modify and generate pattern of colors.

For example:
Let say we have a function (x + x), which takes input x.
If x = 2, function f(x + x) will give you result of 4.
If x = 4, function f(x + x) will give you result of 8.

We will be dealing with functions all the time when writing OSL.  Time to time, I refer to Renderman documentation on its built-in functions.
http://renderman.pixar.com/resources/current/rps/rslFunctions.html
http://web.engr.oregonstate.edu/~mjb/prman/shaderfunctions.html

INCLUDE
If you see #include notation at the beginning of OSL shader, it means that the shader loads some additional functions in C language that we can use later. <-- Let me know if I am wrong, I am only guessing.

For example:
#include "stdosl.h"

This is stdosl.h file if you open it and look inside. It has some additional variable we can use such as M_PI, etc.

Of course not all functions in Renderman available in OSL, but there are plenty of similar functions, and we can always create/write own function that mimics certain function.
  • sin(), cos() -> wave pattern
  • mod() aka MODULUS
  • abs()
  • sign()
  • step()
  • max()
  • min()
  • smoohstep()
  • ...

More interesting function:
  • distance()
  • noise() -> this function comes in many multiple forms




I want to slowly showing and visualizing each functions that are available in OSL by default and adding reference related to it. Read also OSL specification PDF documentation about functions.
http://www.openshading.com/osl/getting-started/

OSL AND MIX FUNCTION

I am afraid that I started to become very wordy, so now time to get inside Blender and start making things.

My favourite layout is like below:


STEP 001
shader basic_function(
    color ColA = color(1, 0, 0),
    color ColB = color(0, 1, 0),
    output color ColOut = color(0, 0, 1)
)
{
}

That OSL shader above is already working, but it really does nothing much other than:

  • Create color variable ColA and assign RED color.
  • Create color variable ColB and assign GREEN color.
  • With OSL shader to work, we need to have output, so we create a color output and assign it the default color of BLUE. Hence the shader resulting of plain BLUE color.
  • We have not done anything yet inside the shader. 
STEP 002
shader basic_function(
    color ColA = color(1, 0, 0),
    color ColB = color(0, 1, 0),
    output color ColOut = color(0, 0, 1)
)
{
    ColOut = mix(ColA, ColB, 0.5); 
}

We can do something like above which simply mixes 2 colors ColA and ColB and give a result of color that is yellowish. That is our first use of mix() function inside the shader.


Although that is not particularly interesting.

STEP 003
shader basic_function(
    point Pos = P,
    color ColA = color(1, 0, 0),
    color ColB = color(0, 1, 0),
    output color ColOut = color(0, 0, 1)
)
{
    float x = Pos[0];
    float y = Pos[1];
    float z = Pos[2];
    
    ColOut = mix(ColA, ColB, x); 
}

We modify the code and here we bring in P. P is a built-in Global Variable, it is basically storing the pixel position of a surface geometry.

P is really a set of array of 3 values that can be broken up into 3 x Float values, and for ease of use, we just tell Blender to think of it as the X, Y, Z.

Here, things started to get interesting. As you can see, we can mix the 2 colors using X, Y, or Z and it will give a result.


This is fine and dandy. Eventhough we are getting a result, it is still hard to figure out what is really happening in the background. Why is is when we insert the X into mix(), it gives us the result above? What does the function really do to the input values of P?


STEP 004: Experiment time!

COOL: Visualizing Function Using Google Search Plotter

A function can be more easily visualized using graph. The graph itself can be 2D or 3D. Thanks to Google, we can use Google Search to quickly plot graph of function.

For the above function, we are really just using the X values (that goes from minus infinity to zero all the way to positive infinity). And so we get that almost sharp blend between RED and GREEN.

Let's try below:

Google Search: x + y



Let's apply that function inside Blender:

Now, we can really see what is happening! That function is kind of mixing color by slicing into two big area inside square, so that whatever underneath the slice gets the RED and the other half gets the GREEN.

It is very exciting, let's continue with other functions!

Google Search: x * x



You see how it is just a bit touching and it gives that nice blurry red line along Y axis? Apparently we can get more blurry when we divide the X.


Let's try something different:

Google Search: abs(x)



Absolute function abs() will return the absolute value, when we insert X position, we are getting value that is always positive.

In term of writing the function, let's write it like below:

shader basic_function(
    point Pos = P,
    color ColA = color(1, 0, 0),
    color ColB = color(0, 1, 0),
    output color ColOut = color(0, 0, 1)
)
{
    float x = Pos[0];
    float y = Pos[1];
    float z = Pos[2];
    
    float f = abs(x);
    
    ColOut = mix(ColA, ColB, f); 
}

With the absolute function, we can further do something like maybe OFFSET the graph slightly above or below the axis, by modifying the function slightly:



You can see now how we can OFFSET or TRANSLATE that RED "line" quite easily.


Google Search: sin(x)




SNIPPET: sign() function


Google Search: sin(x) + sin(y)

Occasionally, Google gave back a 3D graph, like when we use function above. How would that affect our procedural texture inside OSL?


That is pretty interesting, right?


Of course, not everything can be graphed by Google Plotter, sometimes we need to further test it inside Blender, however, it is a good start. You can also use Wolfram Alpha sometimes for graphing, although the feature is limited unless you have pro account.

RIPPLE FUNCTION

If you do a bit more research on function, you might find "basic functions" that gives a pattern you need.

A quick search using Google leads me to this:

Very useful website and we can certainly borrow the example functions. Of course, things are not always clear cut and of the way we write the function may need to be converted to OSL way of writing function, for example:

x^2 => pow(x,2);

Things like this you learn by looking at examples, by trial and error, you gain experience.

Google Search: sin(10 * ((x/10)^2+(y/10)^2))/10

BLENDER OSL
shader basic_function(
    point Pos = P,
    color ColA = color(1, 0, 0),
    color ColB = color(0, 1, 0),
    output color ColOut = color(0, 0, 1)
)
{
    float x = Pos[0];
    float y = Pos[1];
    float z = Pos[2];
       
    float f = sin(10 * (pow(x/10,2)+pow(y/10,2)))/10;
    
    ColOut = mix(ColA, ColB, sign(f)); 
}




OTHER USEFUL FUNCTIONS

Based on this website:

POWER FUNCTION pow()
To increase the contrast. See below how we can implement it:


SAWTOOH WAVE FUNCTION

x - floor(x)

We can use Wolframalpha for graphing, but I do not like how Wolframalpha keeps asking to sign up for pro feature. So, usually I rely more on blogs and Wiki for informations.


The SAWTOOTH function is interestingly similar to MODULUS function graph, that we have used in previous post when we are generating repeating stripes pattern.


NOISE FUNCTION

noise(x) -> there are many ways we can use the noise function.

Noise gives output that range from 0-1, some other noise may give different range.


Noise function is one of the most interesting and useful functions to generate procedural pattern that is more natural and less repetitive.






cellnoise()


Those are all just the basic of functions, hopefully you can understand this part alright.

SINGLE DOT

I think I wrote about how we can create a single dot using OSL, after reading Michel's book, I am thinking to revisit the idea. It is basically related to distance() function.


distance() and sin()


distance() & modulus mod()



Disturbing the HSV Color Space using Noise.




FURTHER TWEAKING.... or FURTHER TWERKING WITH SHADER? (Updated: 2013.11.28)


sign() function results in texture that is crisp, I think we can assume it creates -1 or 1, no in between. This might be good, but in some cases, we actually want a bit of blur/fuzz, so that we do not get moire pattern. This relates to Anti-Aliasing.

Above started to look like WOOD or WATERMELON shader. However, we need to remember the LAYERING method that I mentioned in the previous post.

It's fun to play around with Math function. Sometimes you get interesting complex pattern by accident. For me, the harder parts will be:
  • To understand what is happening and use it to advantage
  • To make distinction of 2D and 3D procedural texture
  • To organize the shader code so it can be expanded
Maybe with more experience, thing gets a lot easier.

FURTHER SHADER TWEAKING: Combining Star Shader and Other Snippet
THE CODE:
#include "stdosl.h"

shader DPStar(
    int npoints = 5,
    float sctr = 0.5,
    float tctr = 0.5,
    color Color_A = color(1,0,0),
    color Color_B = color(0,1,0),
    float rmin = 0.07,
    float rmax = 0.2,
    float freq = 1.0,
    point Pos = P, // added this so that Vector can be plugged
    output color Col_Out = color(0.8)
)

{
    float PI = M_PI; 
    float ss;
    float tt;
    float angle;
    float r;
    float a;
    float in_out;
    float starangle = 2*PI/npoints;
    
    point p0 = rmax * point(cos(0),sin(0),0);
    point p1 = rmin * point(cos(starangle/2),sin(starangle/2),0);
    
    point d0 = p1 - p0;
    point d1;
    
    float x = Pos[0];
    float y = Pos[1];
    
    ss = x - sctr;
    tt = y - tctr; // s t become u v or X and Y
    angle = atan2(ss, tt) + PI;
    r = sqrt(ss*ss + tt*tt);
    a = mod(angle, starangle)/starangle;
    
    if (a >= 0.5)
        a = 1 - a;

    d1 = r * point(cos(a), sin(a),0) - p0;

    in_out = step(0, d1[0]);
    

    // snippet of my little code
    point myPoint = point(0,0,0);
    float f = distance(d1, a);
    
    Col_Out = mix(Color_A,Color_B, sin(f * freq));
   
}

Psychedelic Christmas..?


ADD NOISE FUNCTION....

THE CODE:
#include "stdosl.h"

shader DPStar(
    int npoints = 5,
    float sctr = 0.5,
    float tctr = 0.5,
    color Color_A = color(1,0,0),
    color Color_B = color(0,1,0),
    float rmin = 0.07,
    float rmax = 0.2,
    float freq = 1.0,
    point Pos = P, // added this so that Vector can be plugged
    output color Col_Out = color(0.8)
)

{
    float PI = M_PI; 
    float ss;
    float tt;
    float angle;
    float r;
    float a;
    float in_out;
    float starangle = 2*PI/npoints;
    
    point p0 = rmax * point(cos(0),sin(0),0);
    point p1 = rmin * point(cos(starangle/2),sin(starangle/2),0);
    
    point d0 = p1 - p0;
    point d1;
    
    float x = Pos[0];
    float y = Pos[1];
    
    ss = x - sctr;
    tt = y - tctr; // s t become u v or X and Y
    angle = atan2(ss, tt) + PI;
    r = sqrt(ss*ss + tt*tt);
    a = mod(angle, starangle)/starangle;
    
    if (a >= 0.5)
        a = 1 - a;

    d1 = r * point(cos(a), sin(a),0) - p0;

    in_out = step(0, d1[0]);
    

    // snippet of my little code
    point myPoint = point(0,0,0);
    float f = distance(d1, a);
    
    Col_Out = mix(Color_A,Color_B, sin(f * freq * noise(f, freq)));
   
}

It feels like Christmas alraedy!
How to turn this shader into something that looks more like "explosion", does anyone know? If you do, please let me know. Thanks!


OTHER LINKS

MKRdezign

Contact Form

Name

Email *

Message *

Powered by Blogger.
Javascript DisablePlease Enable Javascript To See All Widget