Home Technical Talk

Flow Map Painting Script - Early Alpha

2

Replies

  • haiddasalami
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Nice stuff Mattias! Been slowly working on a Maya version but running into some problems but your source code has been quite useful :)
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    http://www.scriptspot.com/3ds-max/scripts/flow-map-painter

    thanks for the comments guys :)
    and @haiddasalami: glad I could help :)

    I uploaded a new version by the way, capped off the maximum value popping and fiddled with the values a bit to make the brush change color value more quickly.

    the production has slowed down a bit due to a freelance assignment i'm working on, but the weekends are still devoted to programming so i'm gonna record a video this weekend, and start ironing out the maxscript code to reduce bugs and make it more user friendly

    on the to do list:

    .ini file to save the user settings and preferences
    images on the brush buttons
    working soft circular brush
    working normal circular brush
    fixing .fx shader (not correct yet, I've just noticed)
    recording an introduction video
    create a demo in UDK using a painted flow map

    after all that, my top priority is to get viewport preview up and running, but i've been running into trouble on that. if anyone has worked with scripted materials, please let me know I could really use some help on that :p
  • Norman3D
    Offline / Send Message
    Norman3D polycounter lvl 14
    MaVCArt wrote: »
    after all that, my top priority is to get viewport preview up and running, but i've been running into trouble on that. if anyone has worked with scripted materials, please let me know I could really use some help on that :p

    I might be able to help you out on that front! Sorry I haven't been around msn lately, hehe. I'll show up this weekend ;)
    Great work by the way!
  • Norman3D
    Offline / Send Message
    Norman3D polycounter lvl 14
    A small preview here:

    [ame="http://www.youtube.com/watch?v=UxAsUjFUa9I"]FlowScript_Realtime Update Fix[/ame]

    I also created a new FX file for this.
    I noticed that the greenish "neutral" color is quite noisy if you open it in photoshop and increase the contrast.
    In the shader I'm adding the flow map to the UV_Coord. So if the neutral color was black, the noise would go away!
  • mLichy
  • Computron
    Offline / Send Message
    Computron polycounter lvl 7
    I tried it again, still could not get it to work. I set everything up in the order the help file says and then started to paint. Nothing changes and I never get an option to bake my changes. I am just using a tesselated plane.
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    in the version that is uploaded at the moment, viewport preview doesn't work yet, so you still have to use the 2D preview in the script window i'm afraid :) enable the "enable 2D preview" button if you want to see something :)

    however, as soon as I manage to finish the video i'm recording on how to use the script and on how to use the map you create with it in a UDK shader, you will have viewport preview at your disposal :)
  • Computron
    Offline / Send Message
    Computron polycounter lvl 7
    The problem is nothing actually shows up in the actual map. Is this compatable with max 2012 64?
  • Norman3D
    Offline / Send Message
    Norman3D polycounter lvl 14
    Computron wrote: »
    The problem is nothing actually shows up in the actual map. Is this compatable with max 2012 64?

    I noticed this as well. I think that in order for the changes to be saved to the map (in this version) you have to disable the "SB" brush button and the "Painting" button.

    But in the next version Mattias releases it will be saving the changes to the bitmap file in real-time.
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    Computron wrote: »
    The problem is nothing actually shows up in the actual map. Is this compatable with max 2012 64?

    it should be, that is my version of max :) but as norman said, it could be that the script does not yet save the bitmap if you exit max without "properly" exiting the script :)
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    right, here's a new update for you guys!

    a big one this time, unfortunately I haven't had the time to record a proper video of it being used, or one of how to use the map properly in a shader. i'm working on it though, but I want it to be good for you guys :)

    the big features that are now working:

    realtime viewport preview, enabling you to paint in real time, on your mesh, with a shader previewing the flow map applied in a shader. (both made possible by Norman "Norman3D" Schaar, thanks man!)

    normal square brush

    normal circular brush

    eraser (this is gonna be handy)

    fast performance

    bitmap saving upon properly exiting the script (disabling the brush button)


    incoming: soft circular brush, airbrush and noise brush, of which the soft circular brush is the most prominent.

    also, in this version of the script, the UI got an overhaul, taking up less space, and removing obsolete UI elements that were confusing to begin with. (again, courtesy of Norman Schaar on what to remove, thanks again ;) )


    that's about it, here's a screenshot of the script/plugin in action:

    capturegay.jpg

    and here's, again, the download link for the plugin

    http://www.scriptspot.com/3ds-max/scripts/flow-map-painter


    ps: unfortunately, apart from the weekends, I wouldn't exptect too many updates for the next two weeks: i'm hard-pressed to finish a freelance assignment and I gotta make that deadline :)
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Mother of all that is digital! Just gave it a quick whirl and it's soo much fun!
  • havardsc
    Looks good man.
    Looking at the last picture, what color space are you painting in? Default color seems to be black and you use the blue channel?
  • Computron
    Offline / Send Message
    Computron polycounter lvl 7
    Still not working for me. Followed the instructions multiple time to the T. Only paints these small dots now:

    EvUKa.png

    Also, the realtime shader just shows a bright solid grey.
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    havardsc wrote: »
    Looks good man.
    Looking at the last picture, what color space are you painting in? Default color seems to be black and you use the blue channel?

    yes, this is something me and Norman have had heated discussions over: in order to only use the R and G channels, we have to use only half of the 255 values, and since those are integer values, 2*0.5 gets lost. not only is this bad for accuracy of the flow map, it is also a source of problems: a solid color of 128 for everything but the parts that flow actually results in the entire texture panning very slightly. I have looked into just putting solid white in the blue channel to be able to use that as a mask, and then perhaps using the alpha channel for generating a foam mask or something, but it's something that is currently under heavy discussion :)

    also, @Computron: looks like you're using the soft brush, that's not working at the moment i'm afraid :s only the first two brushes with "NB" and "CB", as well as the eraser ("ER") are working :)

    I should have disabled the non working buttons in the UI for now, but keep in mind that this is still a WIP and actually still an alpha ;)
  • SirCalalot
    Offline / Send Message
    SirCalalot polycounter lvl 10
    Sweet Jesus I need to get home and try this new version.

    Also, are there plans to have icons instead of letters on the brush buttons? I know that these are the least of your worries at the moment, but I thought I'd mention it for later down the line :)
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    SirCalalot wrote: »
    Sweet Jesus I need to get home and try this new version.

    Also, are there plans to have icons instead of letters on the brush buttons? I know that these are the least of your worries at the moment, but I thought I'd mention it for later down the line :)

    thanks, great to hear ^^
    and yes, that's actually the first thing on my agenda once I get the soft brush working: getting the UI up and running properly, and more user-friendly. I have some images ready and waiting, they'll be included in the next update

    also, I just modified the .rar file: the whole thing was confusing since there was a .ms file twice and a .fx file twice... now, there are only the necessary files,

    so @Computron, it might be that you ran the old version of the script, in which case it's understandable and entirely my fault, I sincerely apologise :) please re-download and re-run, it should work fine now :)

    edit: for those of you not using 3ds max 2012, I am going to compile a 2011 and 2010 compatible version this evening, if I can manage to make that work :)
    the reason they're not compatible is because the header file libraries of the SDK have apparently been randomized or something between the 2011 and 2012 versions of max, which is why it's not a simple matter of re-compiling and passing another version of the software to the compiler. it's actually a matter of downloading the 2011 SDK, figuring out the header file library structure for it, creating a solution file with that SDK, including the header files I need, and then re-compiling it for both 64 and 32 bit. easier said than done, but at least I know which header files I need :p
  • SirCalalot
    Offline / Send Message
    SirCalalot polycounter lvl 10
    God speed, MaVCArt.
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    edit: i'm sorry for the people who don't use max 2012, but i'm gonna have to wait until this weekend to compile a version for max 2010 and 2011, i'm afraid I don't have time right now :s in the meantime, i'll try to fix the alpha channel still being lost and to keep working on the video, but i can't promise anything before the weekend :)
  • cman2k
    Offline / Send Message
    cman2k polycounter lvl 17
    This is a tool with great potential!

    The 3ds max shader you are using was flawed (No offense). It offset UVs positions rather than rotate their vectors, so it did not show flow properly. I have resolved this using Valve and Kyle Hayward's work as a model.

    The way this plugin encodes it's information is also flawed, I think. I believe the green channel's information is flipped. I analyzed the data a lot and made my shader as correct as possible according to other examples and math I have seen. In order to get my shader to work properly with the data generated by this plugin, I had to manually invert the green channel's output.

    I would be happy to release this shader I am showing here - given you look into the channel-flipped issue and we work out what's going on. I don't want to release it with the hack it currently has.

    I look forward to seeing this further improved...great work so far!

    flowmap_shader_preview.gif


    P.S. - Bug visible in my gif preview: sometimes the bottom left of the texture gets random input...I think it may be related to brushstrokes near the edge of the object, that don't get their positions caught and default to the zero/zero position.
  • Norman3D
    Offline / Send Message
    Norman3D polycounter lvl 14
    There is nothing "incorrect" about the shader or in the shader in your link.

    The flowmap in the link you posted contains +U +V and -U and -V deformations in the red and green channel.
    The issue here is that the neutral/non deformation color has to be a perfect grey color, 50% white. Since we have a 0-255 range the correct neutral value would be 127.5. But we can't have floats in pixels :).
    This results in inaccurate distortion, specially if you start tweaking the strength of the distortion. The neutral color will be wither and will thus pan the texture in U and V, when it should remain still.

    In order to avoid this the flowmap in this script is using 4 channels:
    Red = +U
    Green = +V
    Blue = -U
    Alpha = -V
    The shader then adds the red channel to the (inverted) blue channel.
    The green shader is "added" to the (inverted) alpha channel.
    Finally this is added to a UV_Coordinate node.
    If there are no deformations all 4 channels will be black, adding this to the UV_Coordinates, will result in no change whatsover, which is the intended result.
    This method also has twice the range of information at our disposal since we are storing half of the distortion in two additional channels.

    Additionally we could convert a 4 channel flowmap to a flowmap, like the one in the link you provided, with a simple photoshop action. All you would be doing is compressing the information stored in 4 channels in just 2. You'll have 50% less precision and then of course the issue with the neutral color not being mathematically neutral, and shifting stuff around. I hope that clears it up!

    EDIT: regarding the "vectors rotating". This is entirely up to you. The example shader is doing an offset to the UV coordinates. You have two values that control the offset speed in X and Y.

    In UDK you could tile the coordinates or rotate, or flip them, whatever you want. It's independent from the deformation.
  • cman2k
    Offline / Send Message
    cman2k polycounter lvl 17
    Hmm. Thanks for the additional information, it's interesting, for sure. I presumed you were working with a model similar to everyone else, and I did indeed notice the problem you mentioned, so it's pretty cool that this plugin finds a way around the accuracy issues.

    A photoshop filter does seem a little cumbersome to me...maybe eventually this plugin can support both a 2-channel method and a 4-channel method? The 2-channel method seems pretty established, even if the 4-channel method is more accurate and clean.

    Also if the shader included is correct, I'm still confused as to why it doesn't have the same kind of directional changes as mine. It doesn't make the texture pan different directions, the way my preview does, as far as I can tell. It just offsets their pan, which doesn't really help you preview which directions you are painting...?
  • Norman3D
    Offline / Send Message
    Norman3D polycounter lvl 14
    cman2k wrote: »
    A photoshop filter does seem a little cumbersome to me...maybe eventually this plugin can support both a 2-channel method and a 4-channel method? The 2-channel method seems pretty established, even if the 4-channel method is more accurate and clean.

    I guess a button could be added to the script that converts the existing 4channel flowmap to a "traditional" 2 channel one.
    cman2k wrote: »
    Also if the shader included is correct, I'm still confused as to why it doesn't have the same kind of directional changes as mine. It doesn't make the texture pan different directions, the way my preview does, as far as I can tell. It just offsets their pan, which doesn't really help you preview which directions you are painting...?

    Well it's not a matter of correct or incorrect. The provided shader as it's setup, pans in the U axis I believe. You can tweak it so that it pans in U and V. This makes sense to me for stuff like the water in L4D2, where it need to go into a certain direction to guide the player.

    If you want the texture to rotate you'll need a different shader. But the flowmap is still 100% valid.

    If you want to see what direction you are painting, maybe use a different checker texture? I think it's also a bit hard to tell at the moment because the circle brush is very harsh and has no fall-off. Once that is implemented I'll make much more sense imo. For now try to blur the final flowmap in photoshop and check the results with the shader.

    The brushes should be quite intuitive, they work similar to the smudge brush in photoshop.
  • cman2k
    Offline / Send Message
    cman2k polycounter lvl 17
    Norman3D wrote: »
    Red = +U
    Green = +V
    Blue = -U
    Alpha = -V

    So I was puzzling over this part, because I noticed that my painted flow maps had empty (white) alpha channels, every time.

    Then I did a test for Y, and I noticed that it doesn't matter if you paint positive or negative, up or down...it always draws the same type of data. Definitely think there is something wrong going on here.

    paint_y_flow.gif

    It brings up a good point though...if this is really going to store data in the alpha channel, and we want feedback through the preview image - how do you give feedback for the alpha channel's data?

    It's funny - I now realize that my previous image was working only by chance. I painted my Y info fast on one side and slow on the other, and that just happened to work with my shader (which was presuming slow was up, and fast was down).
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    I think that version of the plugin still incrementally calculates the color values, whereas the next update doesn't, exactly to prevent that kind of thing :) i'm wondering what is wrong though, what you are showing shouldn't be happening, looking at the code
  • cman2k
    Offline / Send Message
    cman2k polycounter lvl 17
    Doesn't really make much sense to me either. You can clearly see it happening in that clip, and I have noticed it before, but here is an example from a different time where I painted many lines towards the center, and clearly it wasn't happening when I did this (same version of script).

    flow_vortex_test.jpg
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    it sounds like there may be something wrong with garbage collection and the script somehow not always resetting the colors properly... I'll try adding some additional data resets to see what happens.
  • Anuxinamoon
    Offline / Send Message
    Anuxinamoon polycounter lvl 14
    Heya!
    Not sure what's happening here but for some reason its all painting blackness. I tried to go back to previous version but they all now give the same result.

    Any idea why this is doing this?

    Also how can I uninstall the script so that I can try install again? Removing the fmc from the scripts folder doesn't seem to work :p
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    actually there's a huge update coming, so hang in there :p I haven't been sitting still all this time, you can be sure of that ;)

    i just wanted to give you guys an actual proper update instead of small tweaks all the time :p


    in any case, you should try removing the FMC-FMCPainter.ms file from users\username\appdata\autodesk\3ds max 2012\enu\UI\scripts\

    basically that's the userscripts folder, where max stores all it's macoscripts behind the scenes
    also, delete the fmc.gup file from the plugins folder in the 3ds max folder in program files, that's the actual plugin with the C++ code that handles all the heavy stuff the script needs. that should do it, if I remember correctly :)
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    right, new update :D

    big one this time, update list is on scriptspot:

    http://www.scriptspot.com/3ds-max/scripts/flow-map-painter

    capturefv.jpg

    short update list:

    - massive UI and useability update, with improved actual functionality
    - layer functionality (with layer names!)
    - layer combination button
    - layer export button
    - button images for brushes
    - custom icon for macroscript
    - .ini file functionality
    - some other stuff :p

    also, there is a VIDEO incoming as soon as I get the permission to post it :D
  • Ace-Angel
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    right so here is the long-requested video demonstrating the usage of my script/plugin on an actual mesh that could use it, plus it's result on that same mesh inside UDK.

    note: yes, this mesh is highly tesselated, no the script does not need this per se. I did this to have some resolution in my mesh purely for presentational purposes.
    the mesh you are painting on DOES need UV coordinates. in this case this translates to a planar projection UV, so that what you are painting is very close to it's result in 2D

    the result in UDK makes use of several blending textures, and the shader itself is way too heavy for actual use in a game, due to the high amount of textures used. again, I did this for presentational/tech demo purposes, the shader itself does NOT need it, you can use two textures just fine. this one uses around eight.

    [vv]44648007[/vv]

    enjoy :)
  • mLichy
    No HD :( Sick stuff though!
  • Ace-Angel
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Seriously Sick Stuff Son!

    And damn does that effect look delicious!
  • shaderfx
    Offline / Send Message
    shaderfx polycounter lvl 9
    Well done, Mattias!
  • Paunescu.Daniel
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    right so I haven't had time since the posting of my video to work on this, but I would like to ask those of you who have seen the opportunity to test the script, to offer some suggestions as to how to go about improving it.

    is dynamic layer creation absolutely necessary? or are four pre-created layers enough?

    also, what is the general resolution you guys would work at; currently the script stops working on other resolutions than 512 pixels, and I have no idea why, as that value is not hard coded anywhere that I know of. the width and length values do get initialised at 512 pixels, but that's it.

    another question I would like to ask is what kinds of brushes you guys want; is the addition of the soft brush (still working on it) enough, or do you want to be able to use custom alphas.
    note that the bulge and contract brushes are also in development, so they're planned as well

    what kind of control do you want? these are things that are quite important for me to know, so I can create this script according to the wishes of the community.
  • SirCalalot
    Offline / Send Message
    SirCalalot polycounter lvl 10
    You've hit the nail on the head with regards to brushes.
    Besides the obvious soft brush, bulge and contract brushes would be wonderful!
    As currently there is no real way to create sink holes or upwellings.

    Another idea I had last night would be to have a 'twist' brush that rotates when you hold down the mouse.
    Add this to custom alpha brushes and you'll have most bases covered!

    Are there plans for a Maya version when the Max version is out of this early testing phase?
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    SirCalalot wrote: »
    Are there plans for a Maya version when the Max version is out of this early testing phase?

    a twist brush is a very good idea ^^ i have no idea how to create that, but i'll certainly look into it! ^^

    in regards to the maya version: I would love to, but i'm afraid I don't know any python, have never worked with maya before and do not have maya or the maya sdk currently installed, so it's kind of a stretch, but as soon as I get this bugger working i'll look into the possibility. sorry but that's all I can do :)
  • divi
    Offline / Send Message
    divi polycounter lvl 12
    that is really cool shit.
  • Anuxinamoon
    Offline / Send Message
    Anuxinamoon polycounter lvl 14
    Looking good! I'll try out the install right now and re-install this update!
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    http://www.scriptspot.com/3ds-max/scripts/flow-map-painter

    uploaded a new version, very small edit, pretty big difference; you can now paint in all resolutions and everything should work just fine :)

    so go ahead and try it out at 8192 pixels, I dare you XD
  • Shuriken UK
    Damn you must be a legitimate genius! I watched the video and straight away I knew I'd stumbled across something great! I'm yet to play with anything like this, but when I create some streams or maybe a volcano in my UDK levels, I'll know where to look!

    Just hope I can get it to work properly. I'm not too good with scripts, they never seem to work for me lol.
  • Anuxinamoon
    Offline / Send Message
    Anuxinamoon polycounter lvl 14
    Haven't tried the new update you just posted, but I tried to paint some flow maps for hair and I experienced insane slow down and lots of Not Respondings (waiting ) as I painted.

    :(
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    Haven't tried the new update you just posted, but I tried to paint some flow maps for hair and I experienced insane slow down and lots of Not Respondings (waiting ) as I painted.

    :(

    hmm, how much RAM/GPU do you have? my laptop is pretty shitty and it can handle painting just fine without too many slow downs, but i haven't yet experienced a not responding message.
    are you executing max as administrator? if not, try that. the script generates and edits in real time four bitmaps in a folder that is created in the userscripts folder inside the AppData folder - I'm trying to find a way to delete it after you're done with it but for now I can't; C++ tells max that it can't edit or delete the bitmap as long as the code is still editing it, or at least as long as the code assumes it is editing it.

    something that might help is to go to the folder where the layers are saved - I made a button in the bottom of the layer rollout that says copy path, that copies the path where the layer bitmaps are saved to the clipboard - just paste it in your browser and go to the directory. once there, delete the bitmaps and the .ini file and try to start up max again as admin :)

    if that doesn't help, please do say so, as that means there's probably some other problem that I haven't encountered before.
    you are working with max 12 64 bit aren't you?
  • Anuxinamoon
    Offline / Send Message
    Anuxinamoon polycounter lvl 14
    Okies I'll have a go at running in admin mode.

    Yup using 64bit max 2012, 12gb ram and couple of GTX 580's, so if you can use it on your laptop I should be able to go smooth sailing on this.
    Perhaps my max is bogged down with other things, I'm running M2M script (max to maya) which seems to break a few key things... maybe I'll try deleting that script and seeing how that goes if the admin mode doesn't cut the mustard.

    Thanks!
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    one thing that i've thought of in the meantime is that in the version of the script you're using, only the 512 resolution works. if you're painting in another resolution, that will be the cause of the script slowing down; in the newly uploaded version that has been fixed, so I suggest you update, that might help :)
  • Pampers
    Tried this out in UDK with a flow shader I found in another thread, but the color values seems to be different so the results I got was pretty weird. Do you have any example shadesr to use in UDK?
    Also the painted map gets very spotty, especially with large brush sizes.
  • MaVCArt
    Offline / Send Message
    MaVCArt polycounter lvl 8
    captureujb.jpg

    i quickly recreated the very core of the shader I used in the video - i can't upload upk file, since there are some external files in there that I can't share. (copyright and all)

    but in this screenshot, all you really need is there. hope this helps :)

    about the spottiness: i'm assuming you are referring to a slight noise on the painted maps. this is something that can not be helped at the moment, unfortunately, since basically when you're using the script, you are painting inside a 3D program, not photoshop :) the bitmap creation algorithms of max are lacking, but since it's a 3D program that's understandable. in any case, a photoshop pass before getting the map into the engine is always advised, so you can fix the noise in photoshop :)
  • Pampers
    Thanks, slowly moving towards a more and more decent result :) Although how fast I do the stroke motion seems to affect the direction, which is making it difficult to paint accurately in detailed areas. Also the paint radius in the viewport seems to be much smaller than the strokes that get painted on the map, which also makes it hard for small detailing.
2
Sign In or Register to comment.