Home Technical Talk

Creating "Comb" maps

1
polycounter lvl 19
Offline / Send Message
poopinmymouth polycounter lvl 19
I read this thread: http://www.polycount.com/forum/showthread.php?t=97215 and remembered I'd made something similar a while back.

I figured out how to make a vector based direction map using Paint shop Pro's picture tubes a few years ago and realized I needed to get around to sharing it. So here you go, free to use. *edit* now with example video thanks to Kurt Russel Fan Club making a modded Xoliul shader.

[ame=http://www.youtube.com/watch?v=YBR--OTtBD4&hd=1]"anisotropic comb map example"[/ame]

http://www.poopinmymouth.com/process/hair_tutorial/ng_hair.html

[ame=http://www.youtube.com/watch?v=P9KRnh3cROw&hd=1] "comb map creation"[/ame]

hair_example.gif

Replies

  • arshlevon
    Offline / Send Message
    arshlevon polycounter lvl 18
    This is really cool. We have a program at work that you just load your diffuse map into and it will analyze the directionality of the stokes and generate a vector map. Unfortunately it doesn't work on complicated styles with a lot of overlap, like braids. But, it works great for stuff like your example and hair planes. I will have to give this a shot. Is there no way to archive a similar effect in photoshop? I don't know much about the brush system.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    arshlevon wrote: »
    This is really cool. We have a program at work that you just load your diffuse map into and it will analyze the directionality of the stokes and generate a vector map. Unfortunately it doesn't work on complicated styles with a lot of overlap, like braids. But, it works great for stuff like your example and hair planes. I will have to give this a shot. Is there no way to archive a similar effect in photoshop? I don't know much about the brush system.

    Well, when I put this together 4 years ago, Photoshop had no equivalent of picture tubes, I'm pretty sure it still doesn't, but would love to be surprised. PsP is cheap enough that if a studio were to take up this technique you'd just get one license, and it takes maybe 10 minutes to make a comb map, so someone could just bang them all out really quickly.
  • Farfarer
  • arshlevon
    Offline / Send Message
    arshlevon polycounter lvl 18
    Well, when I put this together 4 years ago, Photoshop had no equivalent of picture tubes, I'm pretty sure it still doesn't, but would love to be surprised. PsP is cheap enough that if a studio were to take up this technique you'd just get one license, and it takes maybe 10 minutes to make a comb map, so someone could just bang them all out really quickly.

    hmm, i am wondering if you can modulate color based on stroke direction? doesn't seem like too hard of thing to accomplish. i know psp is cheap i just like streamlining my workflow between as few programs as possible. i do most of my texture work now in mudbox, i will dig into the brush settings today and see what i can do. thanks for this tip tho, i wanted to blow my brains out with a character recently whose entire hair style was braided braids, tied together with braids.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Talon wrote: »
    If you've got Unity, I have an anisotropic shader here;
    http://www.unifycommunity.com/wiki/index.php?title=Anisotropic_Highlight_Shader

    I do have unity, but not pro. Any chance this can be ported to max?
  • Bigjohn
    Offline / Send Message
    Bigjohn polycounter lvl 11
    The only thing in Photoshop is to set the Foreground/Background jitter to be affected by Rotation (under Color Dynamics). But I don't think that would be too helpful.
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    It's kinda sad that we're in the year 2012 and we still have to 'wing' it when it comes to Directional Maps, when a simple 'flow' direction based upon gravity would do wonders just to fake it.

    But yeah, awesome tutorial, and no, the shader wouldn't be too difficult to translate at all, although it would take some time.
  • PhattyEwok
    Offline / Send Message
    PhattyEwok polycounter lvl 9
    Excuse my lack of knowledge. But what is a comb map and what is it used for. First time ever hearing about these things. Looks super cool though lol whatever it is
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    This is really awesome Poop, I tried for a few hours a while back to make a program to generate flow but ran out of time for the project and just fluffed in a bad solution. This looks better than both my ideas.

    Here's a shader mod for Xoliul that lets you use anisotropic specular. Under spec, select "Anisotropic" and then beneath the Normal Map area there's some new values to enter your Tangent map (the flow map). Here's how it looks with your flow map and a simple desat for the spec map:

    AniAnim.gif

    Edit: It almost certainly won't work with the new shader interface so I'd keep it separate from your default shader and just use it manually when you need to.

    Edit 2: Updated shader so it's much better :)
  • ZacD
    Offline / Send Message
    ZacD ngon master
    I'm waiting for the before and after pics :D
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    PhattyEwok wrote: »
    Excuse my lack of knowledge. But what is a comb map and what is it used for. First time ever hearing about these things. Looks super cool though lol whatever it is

    I'll answer this later today with an illustration as several people have been confused on this.
    This is really awesome Poop, I tried for a few hours a while back to make a program to generate flow but ran out of time for the project and just fluffed in a bad solution. This looks better than both my ideas.

    Here's a shader mod for Xoliul that lets you use anisotropic specular. Under spec, select "Anisotropic" and then beneath the Normal Map area there's some new values to enter your Tangent map (the flow map). Here's how it looks with your flow map and a simple desat for the spec map:

    AniAnim.gif

    Edit: It almost certainly won't work with the new shader interface so I'd keep it separate from your default shader and just use it manually when you need to.

    That's awesome, but I can't seem to get it to work. Check this screenshot. With anisotropic unchecked, specular is in the right position for a blinn/phong type. When I tick anisotropic (with the comb map in the tangent slot) it turns into a fresnel type look. What am I doing wrong? I tried all combinations of flip green/red under tangent as well. Even before entering any maps, if I toggle "anisotropic" it will flip from a phong type correct specular hotspot to this fresnel ish specular.
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Too right, sorry about that -- I didn't do a quick check from scrach. There's a bug in there where if you don't have a normal map set then the tangents aren't corrected so you get those rubbish normals.

    Here's an updated version. Just make sure that also once you assign your tangent map you click that "tangent map" checkbox. All other settings should be okay this time.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    PhattyEwok wrote: »
    Excuse my lack of knowledge. But what is a comb map and what is it used for. First time ever hearing about these things. Looks super cool though lol whatever it is

    Updated the original tutorial to explain better: http://www.poopinmymouth.com/process/hair_tutorial/ng_hair.html


    To simply further, let's look at a braid. This is a photograph, a braid texture would never have such strong highlights painted in, but it shows clearly how the anisotropy flows in different directions based on the hair orientation. Imagine this is your diffuse texture.

    anis_example03.jpg

    Now let's pretent this photo is a texture, and we have assigned the 3d model an anistropic shader with only a single global value. The green arrow represents the angle I chose. The highlights look great on the hair chunks going from upper left to lower right, but are completely wrong on the chunks going from upper right to lower left. If we rotated the direction to make it fit for them, the first chunks would break. In this example we have no comb map, simply a normal anisotropic shader with a global numerical input value in the form of an angle (0-360).

    anis_example04.jpg

    But with a comb map, we can use a different orientation value per-pixel! This will allow for the anisotropy to correctly follow the diffuse and normal map directions. In the same way a shader reads the value of a normal map pixel to determine what angle it should light the object, a shader that uses a comb map to control anisotropy will read the angle from the pixel in the comb map to determine anisotropy angle. This would be what your comb map would look like, the values correspond to the "direction" the hair is flowing. The shader can read this and correctly orient the anisotropic highlight.

    anis_example05.jpg
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Too right, sorry about that -- I didn't do a quick check from scrach. There's a bug in there where if you don't have a normal map set then the tangents aren't corrected so you get those rubbish normals.

    Here's an updated version. Just make sure that also once you assign your tangent map you click that "tangent map" checkbox. All other settings should be okay this time.

    Awesome, got it to work. Just made a quick video showing with and without on the actual Delilah model. Uploading now. This is great, exactly what I was looking for! Thanks so much dude. Do you mind if I host this shader file and link to it within the tutorial page?
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Awesome, I can't wait to see it!

    No problem - I don't mind if you host it at all, but because it's basically the Xoliul shader I'd ask Laurens first.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Ok, emailed him to ask. Updated the html again, and here is the demo video.

    [ame=http://www.youtube.com/watch?v=YBR--OTtBD4&hd=1]"anisotropic comb map example"[/ame]
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    That's cool. I just grabbed your Delilah model to test it myself and couldn't resist banging out an animated gif :D

    AnisoComp_Anim.gif
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Awesome! Mind if I steal that for the page?
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
  • Xoliul
    Offline / Send Message
    Xoliul polycounter lvl 14
    Hey guys, this is great to see! I don't mind at all, just go ahead and share this as long as I get credited.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Awesome, thanks you two. Page updated, credit given, links posted.
  • cupsster
    Offline / Send Message
    cupsster polycounter lvl 11
  • Mark Dygert
    That's cool. I just grabbed your Delilah model to test it myself and couldn't resist banging out an animated gif :D

    AnisoComp_Anim.gif
    It would be great if this was in quicktime format so it can be scrubbed. It's a little dizzying trying to compare the two.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Watch the very first youtube video in the OP, I edited in. It shows very clearly the difference and what the comb map is doing.
  • arrangemonk
    Offline / Send Message
    arrangemonk polycounter lvl 15
    this really just looks like a blurred and then roughed out object space normal map to me
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    this really just looks like a blurred and then roughed out object space normal map to me

    It contains angle information the same way a normal map does yes. The point is how to make it in a human way. There isn't a way to get a comb map from baking a tangent space normal map off a high poly, if that's what you were thinking.
  • Eric Chadwick
    Great work Ben, and everyone else too.

    I added a new wiki page with this and some more stuff.
    http://wiki.polycount.com/FlowMap
  • cw
    Offline / Send Message
    cw polycounter lvl 17
    hi guys,
    here's a quick aniso shader with tangent map - thanks for the xoliul version - using the whole tangent map in the same way as TS normal map was simpler for me to get than the approach I had taken from "Scheuermann_HairRendering.pdf"

    here's the link http://dl.dropbox.com/u/5440025/aniso.fx

    I guess I was too late to really help much, but I will add the secondary specular highlight after Scheuermann and see how it looks in the next days. You can put a channel in the alpha of spec map which allows to shift the spec a bit up and down the surface. It might be hard to do this in the tangent map when authoring - again it is ust ripped from Scheuermann so I claim no credit, just exploring the area. :D

    I've pondered this authoring quagmire a few times over the last 12 months at work, and my plan is thus:

    1) create hair on a reference model based off asset but posibly higher poly count
    2) comb, style, coiffure etc.
    3) run script, (as yet not created) which could:
    a) snapshot splines from hair
    b) matchup spline knots and poly verts from styling cage
    c) project spline onto tangent space of vert to get a relative direction of strand per vert
    d) store this info somehow (texture, vertex colour, something)
    e) post process into something usable.

    It might just work? any other ideas I'm willing to have a pop!
  • Farfarer
    I do have unity, but not pro. Any chance this can be ported to max?
    It'll work fine in Unity Free, it doesn't contain any Pro effects.
  • PhattyEwok
    Offline / Send Message
    PhattyEwok polycounter lvl 9
    Thanks for the explanation poop. Very cool idea now that I understand it.
  • Swizzle
    Offline / Send Message
    Swizzle polycounter lvl 15
    BAM! All Photoshop, all the time, baby!

    http://www.polycount.com/forum/showthread.php?p=1582749#post1582749

    Thanks for the inspiration, poop!
  • Hazardous
    Offline / Send Message
    Hazardous polycounter lvl 12
    This is awesome Poop thanks! I'm going to have to give it a try in one of my future girls!
  • Maph
    Offline / Send Message
    Maph polycounter lvl 8
    And for those that care, I'm making a fancy pants comb map controlled hairshader for Max with some really detailed controls. :)

    aniso2.gif
    [ame="http://www.youtube.com/watch?v=K7sEFQvzP8M"]Hair Shader WIP - YouTube[/ame]
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    That double specular is soooo hot. Perfect for emulating the translucency of hair.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Hazardous wrote: »
    This is awesome Poop thanks! I'm going to have to give it a try in one of my future girls!

    You need to use it on your Hikune character, especially once Maph gets this shader working , as the double specular will really help sell her blue hair.
  • EarthQuake
    When I was at 8ml we had a little app that let you "comb" directly on a model in 3d, and it would spit out a direction map. Unfortunately the source was lost and the app stopped working due to code rot. Hopefully someday it will get re-integrated into marmoset.

    You guys should try loading these into toolbag, the content looks pretty similar to what our app spit out and I believe the anisotropic shader still supports these direction maps.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    I was actually thinking about that. I think I saw a horse comb map from you at one point which is what got me thinking on how to make one of these with off the shelf software.

    How would one go about loading this into toolbag?
  • JordanW
    Offline / Send Message
    JordanW polycounter lvl 19
    This is great, In gears3 we just limited the anisotropic direction to the V direction in UV space and just oriented our planes accordingly but being able to paint it would be really nice!

    The -only- problem I see with a 2d solution is seams, painting anything in tangent space gets hairy on seams.
  • Mark Dygert
    Watch the very first youtube video in the OP, I edited in. It shows very clearly the difference and what the comb map is doing.
    You explained it pretty well, but it is easier to see the difference when you can scrub it.

    Here try it out:
    http://dl.dropbox.com/u/2336353/AnisoComp_Anim.mov
  • Mark Dygert
    JordanW wrote: »
    This is great, In gears3 we just limited the anisotropic direction to the V direction in UV space and just oriented our planes accordingly but being able to paint it would be really nice!

    The -only- problem I see with a 2d solution is seams, painting anything in tangent space gets hairy on seams.
    I wonder if there is a "paint on the model" way this could be done so you paint over seams?

    I guess one work around would be to plot seams along the natural hair grain, which most people probably already do? It wouldn't be as good as painting over seams on the model but it would help disguise the discrepancies.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    It's not exactly tangent space, so you can actually paint it seamless. The comb map follows the hair's visual direction, so you won't have a color change across the seam like a true tangent map. Shouldn't be a problem unless the shader is poor.
  • Bigjohn
    Offline / Send Message
    Bigjohn polycounter lvl 11
    I'm not sure I follow with the two highlights thing. What's the secondary streak for? Is it to simulate the hair's subsurface scattering?
  • EarthQuake
    I was actually thinking about that. I think I saw a horse comb map from you at one point which is what got me thinking on how to make one of these with off the shelf software.

    How would one go about loading this into toolbag?

    Yep that was the one, funnily enough it was the only asset that was made with the tool and made it in game.

    If you open toolbag, you can assign a anisotropic shader from the shader dropdown, which should give you the option to load a direction map, sorry don't have it installed here so I can't be more specific, you should figure it out though.
  • MikeF
    Offline / Send Message
    MikeF polycounter lvl 19
    this is some cool stuff Ben, did you come up with this on your own, or is this some sort of realtime adaptation of a method used for pre-rendered work?
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Bigjohn wrote: »
    I'm not sure I follow with the two highlights thing. What's the secondary streak for? Is it to simulate the hair's subsurface scattering?

    Yes, you'll notice in most photos of hair, the highlight also has a surrounding bit that is closer to the hair's actual color but a bit more saturated. Sells the "hair-ness" of it.

    MikeF wrote: »
    this is some cool stuff Ben, did you come up with this on your own, or is this some sort of realtime adaptation of a method used for pre-rendered work?

    Coming up with the picture tube to create a comb map to control anisotropy direction was all me, but I was pretty sure someone, somewhere was also using a per pixel map, most likely generated with proprietary in house tools, and I wanted something off the shelf.
  • EarthQuake
    Yeah there are a variety of shaders that use a direction map for aniso I'm sure, but a good workflow for creating it, especially outside of weird proprietary apps is in dire need.
  • cw
    Offline / Send Message
    cw polycounter lvl 17
    Maph wrote: »
    And for those that care, I'm making a fancy pants comb map controlled hairshader for Max with some really detailed controls. :)

    aniso2.gif
    Hair Shader WIP - YouTube

    This looks great so far!
  • Funky Bunnies
    Offline / Send Message
    Funky Bunnies polycounter lvl 17
    so badass maph, i cant wait til youre done :)
  • Hazardous
    Offline / Send Message
    Hazardous polycounter lvl 12
    Yes please maph :D !
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    Maph that shader is gold! I can't wait to see the code :D
1
Sign In or Register to comment.