Announcement

Collapse
No announcement yet.

Advanced Shaders: Real-Time Vector Field (Flow Map) Generation.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    TheJamsh
    if you know so much, why do you asking?
    just create what you need and use it.

    Leave a comment:


  • replied
    Originally posted by redbox View Post
    Why do you need this?
    I don't need it, it's more proof-of-concept. And I'm fully aware of the issue with vertex-painting flow data because I've already created a vertex-painted flow shader myself, that said, some people have made vertex-painted flow maps with very good results.

    Also, your painted flow will be static, and there is no any difference between using texture made in some flowmap editor or values painted in UDK editor. About droping an rigid bodies into a water - simply use FluidActors. It was created for this purpose.
    I'm aware of that, but the idea is to generate the flow map inside UDK completely, so it becomes Dynamic. You would replace the flow map with a RenderTarget or simply input mathematical data (which was my initial idea). The gradient generated by DepthBiasedAlpha or similar soft-edge code is mathematical, not texture-based, so you could factor in the overall direction to get the correct colours for the direction. You're point about DBA being based on camera position is important though, and I guess you'd have to put together some sort of complex intersection shader to get the right information.

    While Fluid Actors are a good start, they serve no use here.. These create dynamic normal maps and offset their geometry based on that normal, and they only react to an impulse, they don't create normals around a non-moving object. You can however use the fluid-normal node in your material network and factor in your shader normals too.

    And there is one thing you need to understand - you can't draw flow with paint tool, simply moving brush in desired directions. It simply draws colors, but can't use directions or speed of brush to create it.
    So, only one way to draw flow - use colors from some flow scheme, which depends on used technique.
    Thanks for the tips but I'm fully aware of how to make flow maps. I do mine with Maya fluids or the photoshop tools, and use them in particles as well as water shaders. Either way, the shader reads the colour information mathematically, you wouldn't generate colour, just vector2 values from the maths. It would be hideously expensive of course, but proof-of-concept wise it's certainly possible...


    The RenderTarget method seems to be the best way. Unfortunately the programming is beyond me. Food for thought for a more capable programmer out there though!

    Leave a comment:


  • replied
    The game From Dust by UbiSoft has real-time fluid flow (using a different engine though).
    I assume that is what you are trying to accomplish?
    The developers of From Dust released a paper covering some of the design concepts.
    A real-time fluid solver would most likely require full UE3 engine code in order to add that functionality.

    Leave a comment:


  • replied
    Originally posted by TheJamsh View Post
    Just how expensive are Render Targets? I've noticed them used in Hitmasks and suchlike, but are they not insanely expensive too? It strikes me as something that would take a long time to compute
    Render Targets occupy a lot of memory as they're not compressed, so you want the resolution to be as low as you can get away with. They are however, actually feasible. You can't 'generate flow map data' without actually having a flow map to store it in, and at least doing it in Unrealscript doesn't occupy a couple of hundred shader instructions.

    Leave a comment:


  • replied
    Why do you need this?
    Painting with vertex color need to use very tesselated meshes. And results are not so beatiful.
    Here is example with 256*256 texture mask and 32*32 divisions mesh vertex color:

    http://imageshack.us/a/img32/5610/sss1w.jpg

    Also, your painted flow will be static, and there is no any difference between using texture made in some flowmap editor or values painted in UDK editor.
    It have a reason if you creating dynamic flow, which changing it time or in some special cases.
    About droping an rigid bodies into a water - simply use FluidActors. It was created for this purpose.

    And there is one thing you need to understand - you can't draw flow with paint tool, simply moving brush in desired directions. It simply draws colors, but can't use directions or speed of brush to create it.
    So, only one way to draw flow - use colors from some flow scheme, which depends on used technique.
    Here is example:
    http://imageshack.us/a/img560/8063/flowsheet1.png

    But if you still want to try, read few advises below.

    1. For in-editor painted texture:
    Flow should contain color data from -1 to 1, to allow movement in all directions. Also it's better to use uncorrected gamma.
    So, flow maps need to be compressed like normal map (TC_Normalmap, TC_NormalmapUncompressed).
    But with paint tool you can draw only on textures with TC_Default compression.
    Uncheck it's sRGB checkbox to use full gamma and set unpack from -1 to 1.

    2. For in-editor painted vertex color:
    Unpack it in shader with:
    VertexColor.rg * 2 - 1

    About using DepthBiasedAlpha for creating some foam/slowdown mask in water/world intersections:
    1 This mask depends on camera vector, and produces unnatural results on geometry edges.

    http://screencast.com/t/5rrcUyNRPk

    2. You can create slowdown around world edges simply interpolating (0.5, 0.5, 0) color (no flow color) with painted values.

    3. It depends on Bias value and water depth, so if water not so depth, and bias value big, you will get fully foamed and slow water...

    Maybe, but i'm not sure, you can create some flow using WorldPosition node.
    It produce values of positive and negative coordinates, like color values in flow scheme, so it can be used, but I never tried this.

    Leave a comment:


  • replied
    Originally posted by ambershee View Post
    I doubt you can do this without using a texture, and to do it all in shader would be outrageously expensive (if you didn't run out of instructions first).

    Handle it in code and use a render target.
    Just how expensive are Render Targets? I've noticed them used in Hitmasks and suchlike, but are they not insanely expensive too? It strikes me as something that would take a long time to compute

    Leave a comment:


  • replied
    I doubt you can do this without using a texture, and to do it all in shader would be outrageously expensive (if you didn't run out of instructions first).

    Handle it in code and use a render target.

    Leave a comment:


  • Advanced Shaders: Real-Time Vector Field (Flow Map) Generation.

    Lately I've been working on a River/Stream shader that uses Mesh-Painted Vertex Colours to create a flow map in "real-time", which can be modified in the editor at any point. We're all familiar with the concept of Flow Maps by now (there's plenty of documentation around), but I'm interested in a shader that would generate these vector fields in real time, especially as the mesh-painted versions have a much lower density than UV-based vector fields, and can cause pretty awful artefacts.

    By real-time, I mean that if I was to drop an interpActor into a water material in-game, the water would appear to flow around it. We can use soft-edge code to see where geometry intersects (again, all in real-time), and use that alpha information to generate foam, transparency etc. But can we somehow use this information to also generate flow-map data? Surely somehow, you could use the X and Y vectors of the object the material is applied to, factor in the overall water direction (Panner Nodes) and generate a mathematical flow-map on the fly? I guess a texture-based flow map is faster to process, but this would be purely mathematical and require no additional texture samplers. I have SOME idea of how to do it, but has anybody else attempted this before?
Working...
X