Will Timmins' Procedural Shaders

2456

Comments

  • Oso3DOso3D Posts: 14,890

    I'll give it a shot, when I get to that point... I REALLY like ubersurface, so it'd be nice if I could make use of stuff like Occlusion settings and so on.

    On the Iray side of things, I'm coming up with some shaders for the other material zones. That way, if you really want a totally mapless person, you can. The two snags I'm hitting is that irises have a radial pattern that Perlin can't generate reliably (which is only an issue if you are really close up) and eyelashes might just have to be a map (for similar reasons).

    Once I start making Worley shaders, that MIGHT work, but I don't want to work on it yet...

     

  • 3Diva3Diva Posts: 11,287

    I've been curious, what exactly is a "procedural" shader? How is it different from other shaders?

  • Oso3DOso3D Posts: 14,890

    I'm glad you asked!

    Procedural basically means 'generated by an alogorithm.' If you've ever used the 'generate clouds' filter thingie from Photoshop or similar, that's probably using Perlin noise. Different algorithms make different-looking stuff.

    The code in Daz Studio has various packaged code bits. One is Perlin, and one of the cool things about that code is that it ignores UV. So you don't have to worry about seams or UV mapping or even having a UV map at all, it's going to generate patterns along the surface. Also, if you have weird geografts or whatever? Everything flows smoothly from one to the next.

    So, for example, the skins that I've developed do two things, color and bump. The color noise generates a random well-mixed combination of two colors, so that your eye registers it as not 'perfect.' But for it to not look all blotchy and weird, the trick is to pick two very very similar colors. The bump is basically faking the pores and other irregularities of skin, and, again, it's best used in small amounts.

    Conversely, wood grain patterns use more striking color variation. However, with wood, the 'ignores UV map' is a little bit of a problem, because if I make the pattern stretched 'tall' it doesn't matter which way the wood is facing. So I opened up rotation so you can tweak the shader to look right. Not perfect, but hey.

    The code brick for Perlin noise actually has a number of options I don't access in the shader set-up, mainly because some of it won't get used and it's confusing enough. For example, there's an offset parameter to 'move' the pattern along each dimension. Which... is RARELY going to be an issue.

     

    Another advantage of procedural shading is that there's not really a resolution, so even really close to the camera you aren't seeing pixel jaggies. And at long range you don't see obvious tiling patterns. There are limits where it starts looking weird at very long range or very close range, but it has way more range than texture maps for that.

     

  • Oso3DOso3D Posts: 14,890
    edited August 2016

    So that people can use as few maps as possible, I've worked on a few eye colors (sclera and iris). Iris particularly doesn't look right at close range, but at medium to long range, sure!

    I've tweaked five different skin tones: pale light, light, medium, dark, very dark.

    Note that you can make the skins look more realistic if you add some freckles or moles or whatnot with a geoshell layer.

    There is one obvious problem; the palms of the darker skins should be lighter. There is absolutely no way to do that with Perlin noise, so that's one area where you'd either need to use a map... or gloves.

    I might try to make a palm & soles map, because unlike lip color and blush, there's not really a lot of content you can borrow from.

     

    WTP2 Skins Comparison.png
    1920 x 1080 - 2M
    Post edited by Oso3D on
  • grinch2901grinch2901 Posts: 1,246
    There is one obvious problem; the palms of the darker skins should be lighter. There is absolutely no way to do that with Perlin noise, so that's one area where you'd either need to use a map... or gloves.

    I might try to make a palm & soles map, because unlike lip color and blush, there's not really a lot of content you can borrow from.

     

    You mean sort of like a specular map with the whole body blacked out and a lightened area on the palms?  I would imagine that for such a purpose a very low res map would suffice since it's not adding detail but rather moderating color in a small region and doesn't have to be super precise given the organic nature.   If so it would not add a lot of memory demand. 

  • Oso3DOso3D Posts: 14,890

    I was thinking more of a masked overlay (cutout opacity) to either lighten the palms, or have the general skin be lighter and everything but the palms has a darker geoshell layer.

    The problem I'm running into is that it's very hard to generate a mask that doesn't look TERRIBLE.

     

  • ChoholeChohole Posts: 33,604

    I've been curious, what exactly is a "procedural" shader? How is it different from other shaders?

     

    I'm glad you asked!

    Procedural basically means 'generated by an alogorithm.' If you've ever used the 'generate clouds' filter thingie from Photoshop or similar, that's probably using Perlin noise. Different algorithms make different-looking stuff.

    The code in Daz Studio has various packaged code bits. One is Perlin, and one of the cool things about that code is that it ignores UV. So you don't have to worry about seams or UV mapping or even having a UV map at all, it's going to generate patterns along the surface. Also, if you have weird geografts or whatever? Everything flows smoothly from one to the next.

    So, for example, the skins that I've developed do two things, color and bump. The color noise generates a random well-mixed combination of two colors, so that your eye registers it as not 'perfect.' But for it to not look all blotchy and weird, the trick is to pick two very very similar colors. The bump is basically faking the pores and other irregularities of skin, and, again, it's best used in small amounts.

    Conversely, wood grain patterns use more striking color variation. However, with wood, the 'ignores UV map' is a little bit of a problem, because if I make the pattern stretched 'tall' it doesn't matter which way the wood is facing. So I opened up rotation so you can tweak the shader to look right. Not perfect, but hey.

    The code brick for Perlin noise actually has a number of options I don't access in the shader set-up, mainly because some of it won't get used and it's confusing enough. For example, there's an offset parameter to 'move' the pattern along each dimension. Which... is RARELY going to be an issue.

     

    Another advantage of procedural shading is that there's not really a resolution, so even really close to the camera you aren't seeing pixel jaggies. And at long range you don't see obvious tiling patterns. There are limits where it starts looking weird at very long range or very close range, but it has way more range than texture maps for that.

     

    A procedural texture is a computer-generated image created using an algorithm intended to create a realistic surface or volumetric representation of natural elements such as wood, marble, granite, metal, stone, and others, for use in texture mapping.

    Usually, the natural look of the rendered result is achieved by the usage of fractal noise and turbulence functions. These functions are used as a numerical representation of the “randomness” found in nature.

  • Oso3DOso3D Posts: 14,890

    A note on Levels -- level governs how complex the pattern is. At level 1, the pattern almost looks like paisley or similar, simple cellular-looking designs. Each step adds more detail. You can shut off limits and set levels higher than 6, but I've yet to encounter a situation where it's necessary.

     

  • Oso3DOso3D Posts: 14,890

    Just messing around with stuff. The sphere's bump map is Level 2, showing that simpler style. The big test was of the clouds -- I finally figured out a good way to do puffy clouds, though it's a little indistinct -- I made another shader that has Offset exposed. That way you can offset the glow effect from the opacity map slightly, so that you essentially have a drop shadow, giving illusion of solid shapes.

    As for the seaweed and rock, made use of an Iray Decal trick -- if you make a cutout map with a transition from black to white, the decal essentially has an elevation mask. You can adjust the Y scale and height until it looks right.

     

    WTP2 Cloudtest.png
    1748 x 1080 - 3M
  • Oso3DOso3D Posts: 14,890

    One of the powers of procedural shaders is VERY easily applying peeling/smudgy layers to small or large surfaces.

    Following images make use of 'snowy drift layer' to, well, create snow. Also, the driver uses procedural skin stuff, his clothes, ditto. The smoke from the stack, while admittedly not very obvious, is a shader I came up with which, while not procedural, I may through in because what the heck.

     

    WTP2 Snowy scene.png
    1748 x 1080 - 4M
    WTP2 Snowy sceneo.png
    1748 x 1080 - 4M
  • Oso3DOso3D Posts: 14,890

    And a weird use of stars and clouds presets...

    The goddess Nut.

     

    Nut.png
    1080 x 1080 - 833K
  • Oso3DOso3D Posts: 14,890

    You can do all sorts of patterns with existing shaders. Like if you use a skin shader and copy it on to 'WTP Base Color', you can do a pretty convincing vitiligo.

    Here's the Vitiligo preset I just made...

     

     

    Vitiligo.png
    1080 x 1080 - 874K
  • Oso3DOso3D Posts: 14,890
    Had a breakthrough with elevation and normals, so will be adding some terrain shaders. Going to nail down scope creep this week and try to get them ready to go next week.
  • nonesuch00nonesuch00 Posts: 17,929

    That does look good.

  • Oso3DOso3D Posts: 14,890

    The procedural tests are interesting. Sometimes my shaders are faster than regular shaders, sometimes slower. Of course, they also remove texture maps from the scene load, so if you are juuust over the line and falling back to CPU, they are very useful.

     

  • Oso3DOso3D Posts: 14,890

    So this isn't exactly procedural, but one of the things I'm working on for this pack is a height mask; Iray has a wonderful ability to create an image based on the distance of points from the camera, which is useful for compositing or other effects.

    But, particularly with large scenes, it's useful to get effects that depend on height. And volumetric efforts are tricky.

    I was inspired driving into San Francisco today, watching the fog eating the tips of ridges and hills to make this (simple) demonstration.

    All I did was overlay the height map over the image, adjust the curve and opacity a little, and select 'lighten' (so it added a white haze the more high items are). Another approach would be to use the height map as a mask or clipping layer and then paint in some cloudy shapes or whatnot.

    First image is the regular terrain (TD3 with regular TD3 shading), height mask, final result.

     

    Height mask 1.png
    1094 x 881 - 2M
    Height mask 2.png
    1094 x 881 - 74K
    Height mask 3.png
    1094 x 881 - 1005K
  • Oso3DOso3D Posts: 14,890

    Ok, finally figured out what was 'wrong' with my 'cutout based on Normals' shader -- it shows stuff on top, and, flipped around, stuff on bottom INSIDE the object. Using it on a decal solves the problem. Woo.

    For those who don't understand what I just said, short form is 'I now have a shader that you can apply so it appears on the top surfaces of stuff, like snow.'

    This image uses WTP shaders on every surface of the person, his jacket/hat/gloves, the bridle and saddle, all the snow, and the ground (not that you can see much of it).

     

    Traveler heading home after a snow.png
    1748 x 1080 - 3M
  • Charlie JudgeCharlie Judge Posts: 12,328
    edited September 2016

     

    Ok, finally figured out what was 'wrong' with my 'cutout based on Normals' shader -- it shows stuff on top, and, flipped around, stuff on bottom INSIDE the object. Using it on a decal solves the problem. Woo.

    For those who don't understand what I just said, short form is 'I now have a shader that you can apply so it appears on the top surfaces of stuff, like snow.'

    This image uses WTP shaders on every surface of the person, his jacket/hat/gloves, the bridle and saddle, all the snow, and the ground (not that you can see much of it).

     

    Nice work

    Just wondering: What coat is he wearing? Will it close? 

    Thanks

    Post edited by Charlie Judge on
  • JimbowJimbow Posts: 557

    That's really cool. If you could apply it to other axes as well, then you'd have a really useful application for enhancing terrain (steep cliffs and the like).

  • Oso3DOso3D Posts: 14,890
    edited September 2016

    I just expanded that, Jimbow, and managed to get it all in one shader without being too crazy; default is 'put stuff on top' but you can change the direction, mirror it (poles), invert it (everything except top), or both (middle).

    Yeah, the weird black stuff in the third image is annoying. It's something funky with backface that's showing even in decals. Weird. But it's either not an issue for most renders or there are ways around it (for example, you could reverse with stuff is going on which surface)

    (Click on it for full image; only the middle two of 4 panels shows)

    WTP ColorBump Normals Examples.png
    2000 x 500 - 749K
    Post edited by Oso3D on
  • Oso3DOso3D Posts: 14,890

    Oh, the coat: http://www.daz3d.com/pirate-for-genesis-and-genesis-2-males

    And no, it doesn't close. You can move it a bit more open or blow it a little, but anything more than that is going to take something like VWD.

     

  • JimbowJimbow Posts: 557

    Yeah, the weird black stuff in the third image is annoying. It's something funky with backface that's showing even in decals. Weird. But it's either not an issue for most renders or there are ways around it (for example, you could reverse with stuff is going on which surface)

    Could it be a pre-multiplication issue with the alpha?

    http://opticalenquiry.com/nuke/index.php?title=Premultiplication

    http://www.spherevfx.com/written-training/miscellaneous-written-training/understanding-premultiplied-images/

    http://cgi.tutsplus.com/tutorials/getting-an-edge-on-understanding-premultiplication--ae-21862

  • Oh, the coat: http://www.daz3d.com/pirate-for-genesis-and-genesis-2-males

    And no, it doesn't close. You can move it a bit more open or blow it a little, but anything more than that is going to take something like VWD.

     

    Thanks for the information. If it won't close it won't help me in coming up up with something like the clothing in these promos: http://www.daz3d.com/antarctica-expedition-the-encampment-sled-and-poses

  • Oso3DOso3D Posts: 14,890

    Jimbow: I'll have to process that when I'm more coherent. heh.

    I really should have packaged up the initial stuff I was working on and then do this stuff, but... this stuff is very neat. And it's not like I'm doing this for money, so hey.

     

  • Oso3DOso3D Posts: 14,890

    Combination of height and other procedural stuff for the terrain.

    The terrain has a height cutout at the peaks, then a mostly reversed version as a iray decal, but the peak decal has cutout pattern (through which light from below bleeds up).

     

    Mount Infernus.png
    1748 x 1080 - 3M
  • 3Diva3Diva Posts: 11,287

    Thanks for the explination on what Procedural shaders are. Sometimes I don't get notifications when someone responds to me, this seamed to have happend again. I appreciate you taking the time to share your knowledge with us (both here and in other threads - I've learned a lot from reading your advice/help given to others). Thanks for helping the 3D community learn and grow! :)

  • Oso3DOso3D Posts: 14,890

    Duh moment. I forgot there's an option that allows the Perlin noise to 'stick' to the UV geometry. While this is bad for some things, it's great for others, so I tweaked things a bit more. Now, it's perfect for clothing, freckles that don't wander as your pose or position changes, wood, etc.

    In this image, the only texture maps are on the eyelashes and hair.

     

    WTP Room1.png
    1748 x 1080 - 3M
  • Oso3DOso3D Posts: 14,890

    The skin, nails, and everything artificial (clothing etc) are WTP shaded. I didn't bother changing the eyes because you can't see them very clearly anyway (and the texture load is minimal for a single figure, so there's less need to streamline).

     

     

    WTP Dancing Keshi.png
    1080 x 1080 - 707K
  • Oso3DOso3D Posts: 14,890

    Working on making proper icons, decided I like this so much I wanted a larger version...

    (Shader uses noise to generate refraction color and weight, also bump)

     

    WTP Base RefractionBig.png
    1080 x 1080 - 1M
  • These are coming along fantasticly!!!

Sign In or Register to comment.