Home Technical Talk

How to paint flow/anisotropic/comb maps in Photoshop.

polycounter lvl 16
Offline / Send Message
Swizzle polycounter lvl 16
After seeing Ben Mathis'/Poopinmymouth's tutorial on how to do flow maps in PaintShop Pro, I realized that there's a very simple way to create flow maps in Photoshop using a simplified version of his method.

First, either render out or copy the cone normal from Ben's tutorial:
KzekW.png

It helps if this cone image is the same size as the flow map you'd like to create, or even larger. The larger the better, in fact.

Once you have the cone normal, open it and your flow map as two separate documents in Photoshop and mask out the center of the cone normal:

kQLsY.png

It's important that you do this as a mask so you can be sure you're able to sample the very center pixel of the cone by turning the mask on and off. Masking out the center ensures that you don't sample directions from the wrong side of the cone at the start of your stroke.

Once you have the cone normal masked, turn off the mask by Shift+Clicking on it, sample the center pixel with the Clone Stamp tool, and switch to your flow map document.

By sampling the cone normal document, you can now stamp normal vectors onto your flow/comb map quickly and easily:
07LrF.png

This technique can be used to create flow/comb maps for anything that actually uses them, be it hair, flowing water, or animated particles like you might see in Uncharted 3.

uqL9B.png

Replies

  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Yay, awesome that you came up with a way to do this in Photoshop. Gonna update my tutorial to include this method.
  • Funky Bunnies
    Offline / Send Message
    Funky Bunnies polycounter lvl 17
    so boss, im really excited to try this out, thanks man!
  • Dylan Brady
    Offline / Send Message
    Dylan Brady polycounter lvl 9
    yeah tried this it works super, does need a big size image so you dont run of the edge
  • Hazardous
    Offline / Send Message
    Hazardous polycounter lvl 17
    Awesome Swizzle!!!!!!
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    yeah tried this it works super, does need a big size image so you dont run of the edge

    I'm gonna re render a 1024 version that goes all the way to the edge when I update the tutorial to contain this method
  • Swizzle
    Offline / Send Message
    Swizzle polycounter lvl 16
    Thanks guys! This is super exciting for me because I've been trying to figure out a way to do this since I saw Keith Guerrette's talk at GDC about how they did particles in Uncharted 3 with flow maps and other craziness. The folks at Naughty Dog baked flow maps from combed normals in Maya, but I figured there had to be a better, easier way.

    Props to Poop for leading me to this particular solution.
  • poopinmymouth
    Offline / Send Message
    poopinmymouth polycounter lvl 19
    Actually thinking more about this, I'm kind of wondering how accurate it is. I'm going to try painting real quick with both methods. For example, if you start moving down, but then come back up a little, then down again, your brief up stroke won't have been long enough to take you to the actual up color of the document you're sampling from, whereas the picture tube brush would.
  • Swizzle
    Offline / Send Message
    Swizzle polycounter lvl 16
    Very true. I think the best solution would be to have the brush that's doing the sampling only sample from a single-pixel ring, somehow. To keep things consistent, I'm pretty sure the best way to use this method would be with short strokes.
  • SirCalalot
    Offline / Send Message
    SirCalalot polycounter lvl 10
    Awesome techniques guys, I'll be checking this out later!

    Just out of interest @Swizzle, do you have a link to the slides or a video of Keith Guerrette's talk at GDC?
    Or will I be needing a time machine and a plane ticket to San Francisco?
  • Swizzle
    Offline / Send Message
    Swizzle polycounter lvl 16
    http://www.gdcvault.com/play/1015898/The-Tricks-Up-Our-Sleeves

    There's the link to the slides. It has some of his speech written down as notes, too.
  • SirCalalot
    Offline / Send Message
    SirCalalot polycounter lvl 10
  • Saman
    Offline / Send Message
    Saman polycounter lvl 14
    Just gonna add a couple of things that Dylan and Swizzle mentioned; Make sure to tick off Aligned and set the sample to 'All layers' in the clone stamp tool settings.

    Excellent stuff, Swizzle! Very helpful.
  • olivierth
    Offline / Send Message
    olivierth polycounter lvl 9
    Oh wow, I was looking up the net to find answers about that for a week, never found this thread before!

    I also found a method of creating Aniso. direction maps but in a less artistic and more technical way.

    Here's the link to the thread: http://www.polycount.com/forum/showthread.php?t=74848&page=41 (bottom of page)

    Here's where I'm at, still need to fix the hair patches to finish up the hairdo.... note to self: add eyebrows....


    Munn_150.jpg
  • arrangemonk
    Offline / Send Message
    arrangemonk polycounter lvl 17
    with polar coordinates one can map the cone into a ramp, but i dont know what that would be good for

    edit: this map still confuses medirection.png
  • oXYnary
    Offline / Send Message
    oXYnary polycounter lvl 18
    Necro Bump (but its good info though). I thought the blue channel wasn't used for comb maps? Is the missing last step turn the blue channel to black?
  • Kurt Russell Fan Club
    Offline / Send Message
    Kurt Russell Fan Club polycounter lvl 9
    You have the blue channel set to a constant value (127 or 128 ), so in the areas pointing zero red and zero green, it appears blue.

    The reason why is because you're dealing with a 3d vector that's flat in the depth plane, and because normals get expanded from 0..255 to -1..1. So the halfway point (127.5) is zero.
  • JacqueChoi
    Offline / Send Message
    JacqueChoi polycounter
    ^_^ swizzle so smart!
  • oXYnary
    Offline / Send Message
    oXYnary polycounter lvl 18
    You have the blue channel set to a constant value (127 or 128 ), so in the areas pointing zero red and zero green, it appears blue.

    The reason why is because you're dealing with a 3d vector that's flat in the depth plane, and because normals get expanded from 0..255 to -1..1. So the halfway point (127.5) is zero.

    See then Im confused because I was trying the flowmap maker lotek? created as well as the flowmap plugin for 3ds another member made.

    The blue channels by default on those were black except totally white where you painted. I was also asking an artist from Volition and they mentioned the blue channel should be 0 (black).
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    I think that depends on the shader? If I'm not mistake, blue is neglected when you have a Normal map crossed with your Aniso map, so an extra blue will subdue/unnormalize value, unless you don't plan on using a Nrm?

    But if your shader is setup with the proper clamping and normalization for the crossing, then it won't matter?

    It's been a while, but iirc it all depends on who the shader is written or something.
  • oXYnary
    Offline / Send Message
    oXYnary polycounter lvl 18
    Mmm.. Never can be easy for us. Does anyone know of a listing of what the most popular engines require?

    Fwiw my particular case would be Marmoset or Crytek.
  • oXYnary
    Offline / Send Message
    oXYnary polycounter lvl 18
    Does this method assume that on the UV layout is always pointing to top? I though not since Poops example is using more than planes, but maybe its not as bad because its a simple unwrap.

    I have an unwrapped 3d Model and I got this with Marmoset (showing direction ticked).

    girlcomb.png

    This is the map after I threw out the blue and flipped the channels to get it to work somewhat right.*

    flowmapass.jpg

    The best method I can find thus far is using the 3ds Script to paint them but its super buggy and extremely slow response. Like every second.

    *That was after flipping r/g for the top hair portion as well separability was even worse before.
  • metalliandy
    Offline / Send Message
    metalliandy interpolator
    Hey guys,

    Sorry for the necro. but I just wanted to post a correction to the normal map supplied in the first post.
    The blue channel in the normal map contains too much information (downward pointing normals), so I baked out a couple of corrected ones for people to use.

    The .zip contains 2x16bit cone maps in both X+Y+Z+ & X+Y-Z+ flavours.
    https://dl.dropboxusercontent.com/u/2057427/Polycount/Cone_Map/Cone_Map.zip
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Nice, cheers Andy!
  • fatihG_
    Offline / Send Message
    fatihG_ polycounter lvl 14
    Anisotropic.gif

    Flowmap.png

    I have been experimenting a bit with the mixer brush in photoshop.
    If you set the mixer brush's settings to "dry, heavy load", enable "clean brush after release" and "load brush after stroke", you basically end up with a "tube brush".
    You basically paint with an image now.
    So unlike the Clone Stamp tool, the location of the "Source" will not be updated/move around.

    However, this also means since it wont get updated, it will not be able to paint the directions properly.
    I had to figure out a workaround for this. Basically what I came up with was a brush that basically "masks" the source image and "offsets" it. Also setting "shape dynamics>Angle jitter>control" to direction makes it so that the brush rotates whichever direction you draw your stroke.

    Another drawback is that since the brush is "offset" any slight deviation in your stroke will make the line you draw jitter all over the place(3). (Either my laptop cant handle it properly, or it's just the way Photoshop works.)
    Anyway another workaround for this is to use "lazy nezumi"(2). Basically something like Mudbox/Zbrush's lazy mouse, but for Photoshop. It has a 1 month trial, but you can still use its most basic tools after the trial ends. (Like I am doing.)
    Another problem is that you cant make tight and smooth corners (because of the offset.)

    So basically how I make this work is instead of "painting" the flow map. I draw guidelines using the mixer brush.(4)
    Since it's not possible to sample a single pixel, the brush paints with a slight curved normal. To counter this I lock the layer, blur it by a tiny amount, like 2 pixels.
    Now to fill the "gaps" I use the "Dilation" filter that comes with Xnormal.(5)
    The Dilation filter simply extends the opaque pixels, so you will not have a smooth flow map. Because of this, when I draw the guidelines I try to draw them as dense as possible.
    Anyway after the Dilation filter I apply another blur, of 3-4 pixels.(6)
    Mask it properly so it only covers the area you want.(7)
    Repeat the steps for any other areas you want to paint.(8)
    And you have a somewhat decent flowmap.

    This process is obviously not painless. If anyone knows any improvements, please share. =]

    You can get the brush I used for the "mixer brush" tool here:
    http://www.fagurd.com/misc/FlowMapBrush.abr

    I have also made a little action that does the blurring>dilation>blur steps.
    Which I have bundled with my action set.
    http://www.fagurd.com/misc/FatihGurdal%27sActions.rar
    The actions is simple called "Flowmap" and is a yellow button. (if button mode is enabled).
  • cmgillett
    Very cool, thanks for sharing! Looking forward to messing around with this :D
  • deohboeh
    Offline / Send Message
    deohboeh polycounter lvl 5
    Am going to resurrect this thread.. How do I paint them directions on a map like this?

    Diffuse Map

    22cY2rX.png

    I baked the hairs with a gradient green to red..

    XMcbdoH.png

    Am I doing this right?
  • EarthQuake
    Have you tried the method(s) outlined in the thread? Thats what I would do, baking a gradient doesn't really make sense for aniso direction content.
  • OldSalty
    Offline / Send Message
    OldSalty polycounter lvl 4
    I'm wondering if using a straightened version of the cone map as a flow map for hair cards that have UV's straightened and positioned top to bottom is an effective way of getting the results that a flow map is supposed to produce. I'm not sure that I understand what the colors represent or which part of the hair is meant to be a certain color, but here is what I did and the results seem decent.

    LBbWLEr.jpg
    wFXZz59.jpg
    FqjCsoj.jpg
  • Daew
    Offline / Send Message
    Daew polycounter lvl 9
    from my limited experience with flow maps, I believe each colour represents a direction just like a normal map.

    tumblr_nwd801ENVR1u4xoxco1_540.jpg

    Because my uv shells and mesh weren't straight planes I had to use the conemap(normal map) to direct the direction of the arnistrophic spec.

    So im not sure straightening out the map would work (though for straight uvs, maybe?). With a cone map you get every direction up, down, left, right. If you straighten it, what was once left and right now becomes just left(or right). It doesnt show to well on this image but I added yellow lines to break up what would normally be a straight band of highlight. This happened because of the change in colour and it created a zig zag pattern. (red is horizontal, green is vertical, add them together and you get yellow, diagonal)

    So the cone map really needs to be specific with its directions.

    Im still new to this so i would wait for someone more experienced to chime in.

    (btw that is an old wip image the colours on the neck have been fixed :B)
  • fatihG_
    Offline / Send Message
    fatihG_ polycounter lvl 14
    Little update on the flowmap method I posted 2 years ago.

    https://www.youtube.com/watch?v=6n1kHmhOcKM

    Things that have changed:
    Slight update on the brush.
    Incorporated the 'Solidify' filter instead of Dilation. This filters blends the areas between the 'guides' better.

    Link to brush and cone normal map:
    http://fagurd.com/misc/Flowmap.rar
    https://www.dropbox.com/s/8ighclc6ehhnx5f/Flowmap.rar?dl=0

    Solidify filters:
    http://flamingpear.com/free-trials.html

    Lazy Nezumi:
    https://lazynezumi.com/

    Sorry for the crappy audio!


  • Enalya
    @fatihG_Dude thank you so much, this is the one and only tutorial I could find on the whole internet that helped me further with my hair direction map. Thank you all in this topic :)
  • jfrancis
    Offline / Send Message
    jfrancis polycounter lvl 4
    I used to do something like that in Photoshop, but I might try it in Processing. I was making some headway in Processing coming up with a grooming system for Maxwell Grass.
  • demonslayer
    Offline / Send Message
    demonslayer polycounter lvl 3
    Hi fellas,

    i have to dig out this old topics as iam doing some tests with flow maps in Marmoset TB and Vray.
    What yet confuses me that some engines seem to demand red/green maps only
    https://api.unrealengine.com/udk/Three/AnisotropicLighting.html
    https://80.lv/articles/will-koehler-unreal-engine4-breakdown-scene/


Sign In or Register to comment.