Home Technical Talk

Painting a "flow" normalmap?

We're adding a new feature in our game to help us control the river-current in some of our game levels, so the physics solver can send floating things down-stream, into eddies and out, slowing, speeding, etc. Pretty cool.

We're going to use a normal map to control the current, per-pixel. Awesome. Red and green channels will control direction and speed of the current in the XY plane. Also we can use the length of the normals for additional speed control.

I'm wondering how to author these textures though. So far I'm thinking the best way is just to hand-paint each channel individually. Full-on red for full-strength left-wards current, black "red" for full-on right-wards current, etc. Eddies and swirls get weird though, hard to visualize.

And then there's the length of the normals... how do we paint that? Can't just sculpt a heightfield, how would you represent full-speed current going left down the middle of a river?

Anyone else make something like this, or have some ideas how they would create the map?

Replies

  • Rick Stirling
    Options
    Offline / Send Message
    Rick Stirling polycounter lvl 18
    Would it be worth painting this information into the vertex colour channel of the rivers surface instead?
  • SHEPEIRO
    Options
    Offline / Send Message
    SHEPEIRO polycounter lvl 17
    you could visualize it in threeD, but i would hesitate to sculpt it, my bet would be to use a load of lofted splines to rough out the different flows, and just pass them over and through each other, then just blend and blur those after in PS ( im geussing that it doesnt need to be as acuurate as a normal map), it shouldnt be too much of a head fuck if you work on eachthread of current seperatly, starting at the source and working your way down stream, I would over emphasise the angles though at least while your working and scale it in Y when your done.

    deffinatly think modellling is the way to go it will look like a big slide if you imagin how water would run down that slide it should give you a fair idea of how its going to work, but i do think the speed channel will need some extra work in PS after as you want the centre of each stream to run faster than the edges, and i cant for the life of me figure out how to do that without funking up the direction channels

    sounds like fun, and could look ace
  • Farfarer
    Options
    Offline / Send Message
    You could probably "paint" it in using vertex normals (so it's easier to visualise, if you turn the normal indicators on) and hack a script together to transfer that to a colour map.

    And then bake that out to a texture if needed, or leave it as a per vertex thing.
  • Brice Vandemoortele
    Options
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    I guess that you need texture to be able to access neighboring information or something similar?
    Editing per vertex has several advantages, and you can easily bake the per-vertex info by projecting the object in texture space in the viewport and doing a hardware rendering (like i did for uv reprojection: http://boards.polycount.net/showthread.php?t=61438)

    - you can visualize the info you're painting realtime with a custom cgfx, like a sin() wave per axis moving over time or any feedback more relevant than plain colors.
    - you can generate custom info procedurally: for ex using a sphere's translate and scale transforms as input of your 'baking shader' like you would do with point lights, you can easily generate vectors 'pushed away' by those spheres in texture space of your river, to simulate obstacles. I did a similar test recently: baking the light direction in texture space to create specular from selfillumination maps.

    Having a math control over the output of the shader also gives you the ability to normalize or whatever useful operation, like transferring to world space coordinates.
    You don't really benefit from having a normalized vector tough, since you use information only in the texture plane. Two axis already give you full control over the speed. It's not really relevant having an info into the length when you don't use the 3rd dimension of the vector.
    I guess you could use it for spinning/rotation info or something else :)

    I'd like to see what you can come up with it'll be really interesting :) good luck
  • Eric Chadwick
    Options
    Offline / Send Message
    Thanks for the ideas everyone. It's fun figuring out new tech. Brice, are you offering to write up a Max shader? ;) That would be awesome of course!

    The game is using a non-realistic style, and the water won't be using a visually complicated shader for the rendermesh. In fact the normalmap for the flow will probably be super-low like 32x32. It's a late feature, so not much time to devote for tools. Vertex color might make sense for storage though. I thought about playing with Particle Flow, but I know that'll take some time to get it right, and I have way too many other things that need attention too.

    I'll post some pics in a few months when the project goes public. More ideas welcome anytime.
  • Rick Stirling
    Options
    Offline / Send Message
    Rick Stirling polycounter lvl 18
    I've handpainted things like this before for a pseudo wrinklemap - I converted a base wrinklemap to a gray heightmap and stored it in one channel, then used the other two channels to store hand painted vertical and horizontal changes.

    Vertex colour would have been useful if you were having a complicated surface so you could treat bends in the river differently without having to create more and more maps, though you'd probably need a fair few polys to get any definition.

    I'd be interested to see how this turns out.
  • Brice Vandemoortele
    Options
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    hehe Eric, it depends, is that some sort of job proposal? :P
    maya ftw, I'd need to learn a lot more about max to do it.
  • arrangemonk
    Options
    Offline / Send Message
    arrangemonk polycounter lvl 15
    im very lazy about these things, so i would make a parallel fallof map with z-axis as direction, and use the rendered grayscale image for the blue channel.
    x and y channel can be created, by rearranging the smoothing groups so that you have some sort of segmented optics, now you have 2 normals per vertex and so you have 3 points, this way you can use the vertex and the 2 normal destination points into a layer, and rotate the aiverage of the 2 normal vectors 90 degree downwards and you have the flow direction, this is then rendered out as a targent normal map, and the blue channel is replaced by the grayscale image from earlier. if then normalizing or not is a matter of trying.
    but i thing this is a simple lazymans algorithm to generate your flow normal maps, and not having to think about them lol
    arrangemongsbraincrap.jpg
    hre you can see how i mean that with the normals

    edit: i found spelling mistakes you are free to keep them
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Well if you are talking a regular normal map integration your typical range will be from -1 to +1 on the channels, so length is a little issue. What I would suggest is to leverage the blue channel as a multiplier for the length.

    ie
    L[r+g] = 1
    B = 0-1 * MaxRiverFlowSpeed

    So the force or speed of the river at any given pixel is

    \Normal[r,g,0] * (b*MaxRiverFlowSpeed)

    Not sure how many textures you're going for, but you can get the info with a particle system like you were thinking. If you link its the particle's color to its normalized velocity you effectively get your normal map info so long as you can capture the particle colors with a bake.
    ParticleFlow.jpg
  • arrangemonk
    Options
    Offline / Send Message
    arrangemonk polycounter lvl 15
    http://rapidshare.com/files/224157290/test-river.rar.html

    made a test for my version, if your features are already implemented, and this model + map make results that akt like they should act my methot works, and you only have to scult the river like you want it to look and follow the baking steps
  • Eric Chadwick
    Options
    Offline / Send Message
    Cool ideas.

    Also one of the coders on TCE posted a link to some work he did recently. Very interesting demo, could be an interesting way to create a flow map. Fun to play with too.

    For expediency though I hand-painted a quickie test map this afternoon, just picking colors from a world-space-lit hemisphere, painting swaths and blending them together. Should be good enough for now.
Sign In or Register to comment.