Announcement

Collapse
No announcement yet.

Training Livestream - Realtime Simulation and Volume Modelling Experiments - May 2 - Live from Epic!

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

    #76
    RyanB

    I hope this a good place to ask, and You would not mind sharing thoughts about a rather specific question:

    I am using 2D fluid sim to drive evolving wind field, that is used for foliage animation. This wind field covers certain area around the player.
    Center position of this field is snapped to player's position with set snap size,expressed in render target texels, in a pretty much the same manner, as shadow cascade snapping works.
    When shift occurs, I am also shifting contents in all render targets, associated with the sim, by a corresponding number of texels.

    After the shift, simulation border is shifted, exposing texels, where simulation was running not running before, and those texels are populated with initial values( zero pressure zero velocity).
    Now, the problem is, that such shift eventually affects all simulation after some time. I can't say that is exceptionally noticeable, but it is definitely there.

    Seeding new texels with a data by padding to previous border does help, but it is still noticeable unfortunately.

    Maybe You could kindly share some ideas, how this can be handled?
    Last edited by Deathrey; 05-12-2018, 06:00 PM.

    Comment


      #77
      What you are describing is the open boundary problem.

      Typically in fluid sim, the domain is periodic due to the nature of sine waves. There are various other ways of handling the boundary, called boundary conditions.

      The most commonly discussed boundary conditions for graphics are actually methods for solid obstacles, which generally call under the Free-slip and No-slip boundary conditions. In those cases what you basically make sure the texels near obstacles have no velocity aligned with the normal of the obstacle.

      Open boundaries are a bit more complicated. One trick is to clamp UVs to texel centers at every stage of the simulation (ie, including during pressure iterations). This does lead to a problem where inflows can blow up though.

      This became a big issue for me doing the 3d fluid sims for the fortnite launch trailer. Any kind of edge masking, including with a nice soft falloff function, was causing huge ripples and distortions that were ruining the subtlety of the sims.

      Note that for 2D, this is not quite as much the case, since you can afford to make your RTs bigger and use a really wide soft falloff to 0 function. In many cases that will be good enough for 2d if you can afford the larger area. But in 3d you can't afford to increase your volume size.

      I handled it by first clamping to texel centers, but limiting inflows during the advection stage by doing a directional mask dot product with the normal of each open boundary. Then you have a parameter for the inflow dampening.

      The reason that appears to work is because you always want outflows to be able to leave the volume, but since inflow vectors can be generated at boundary texels, if those keep on sampling at the texel centers, the inflow may never go away and thus might 'blow up'. Directional dampening pretends to assume something about the frequency of amplitude of inflows. Definitely not a perfect solution but worked for me.

      The 'real' solutions for this open boundary problem are more complex and expensive. Look up the conjugate gradient method. It's an iterative approach similar to jacobi or newton iterations where you would take some samples to increase the accuracy of the guess for what texels sampled outside of the domain would be. I am told this is what most of the film level solvers use, but I have not actually seen an implementation, and I have never actually seen a paper written describing that particular application. It just requires a good understanding of the mathematics.

      There is a method called "Perfectly Matched Layers" for this which basically use a fourier series to predict the values outside the domain using frequency decomposition.

      Here is one paper on open boundary conditions. Maybe this will give you an idea of why I went with the simple inflow dampening approach.

      https://hal.archives-ouvertes.fr/hal-00685195/document

      Ryan Brucks
      Principal Technical Artist, Epic Games

      Comment


        #78
        Originally posted by RyanB View Post
        What you are describing is the open boundary problem.

        Typically in fluid sim, the domain is periodic due to the nature of sine waves. There are various other ways of handling the boundary, called boundary conditions.

        The most commonly discussed boundary conditions for graphics are actually methods for solid obstacles, which generally call under the Free-slip and No-slip boundary conditions. In those cases what you basically make sure the texels near obstacles have no velocity aligned with the normal of the obstacle.

        Open boundaries are a bit more complicated. One trick is to clamp UVs to texel centers at every stage of the simulation (ie, including during pressure iterations). This does lead to a problem where inflows can blow up though.

        This became a big issue for me doing the 3d fluid sims for the fortnite launch trailer. Any kind of edge masking, including with a nice soft falloff function, was causing huge ripples and distortions that were ruining the subtlety of the sims.

        Note that for 2D, this is not quite as much the case, since you can afford to make your RTs bigger and use a really wide soft falloff to 0 function. In many cases that will be good enough for 2d if you can afford the larger area. But in 3d you can't afford to increase your volume size.

        I handled it by first clamping to texel centers, but limiting inflows during the advection stage by doing a directional mask dot product with the normal of each open boundary. Then you have a parameter for the inflow dampening.

        The reason that appears to work is because you always want outflows to be able to leave the volume, but since inflow vectors can be generated at boundary texels, if those keep on sampling at the texel centers, the inflow may never go away and thus might 'blow up'. Directional dampening pretends to assume something about the frequency of amplitude of inflows. Definitely not a perfect solution but worked for me.

        The 'real' solutions for this open boundary problem are more complex and expensive. Look up the conjugate gradient method. It's an iterative approach similar to jacobi or newton iterations where you would take some samples to increase the accuracy of the guess for what texels sampled outside of the domain would be. I am told this is what most of the film level solvers use, but I have not actually seen an implementation, and I have never actually seen a paper written describing that particular application. It just requires a good understanding of the mathematics.

        There is a method called "Perfectly Matched Layers" for this which basically use a fourier series to predict the values outside the domain using frequency decomposition.

        Here is one paper on open boundary conditions. Maybe this will give you an idea of why I went with the simple inflow dampening approach.

        https://hal.archives-ouvertes.fr/hal-00685195/document
        Thanks for your response.
        I've looked up a paper, named An Introduction to the Conjugate Gradient Method Without the Agonizing Pain to realize that some of the pain is still there.

        I've experimented with soft edge dampening. It definitely improves the situation, but on cascade shifts, the shockwave travelling through the sim is still there. I've evolved that into expanding simulation area to include area beyond cascade dimensions, equal to the size of the shift and slowly blending border from previous position to new position, but this is not very practical, since I can't predict when or how frequent the shift will occur, as it depends on player movement speed, and I will need to prevent shift from happening, until the fade had been completed. Gets a bit bulky at this point.

        I think I will have to go with wrap boundary instead of free slip boundary, and do not shift the sim at all. I will have to ensure, that the particles/objects, I am using to inject the velocity with, exist only one frame, then the shift of the render target, that stores captured velocities, to be injected into the sim, will not reveal the shift at all.

        It gets me into another problem, that is obviously exploding sim with wrap boundary. Without sufficient dampening, it will inevitably explode. I can't reliably measure velocity inflow, because it varies from nothing to N objects of any size injecting any velocity. I guess I will have to just eyeball dampening large enough, for sim not to explode in worst case game condition plus margin of safety.

        Another thing that I cannot get right, is making the sim more or less framerate-independent. Using frame delta time straight up causes hilarious shockwaves. Averaging delta time does help, but I had to smooth it out over past 20 seconds at least to get a stable sim.

        Comment


          #79
          You need to do custom time accumulation. So you actually need to do a while loop and do substeps any time too much time has passed, and skip frames where not enough has passed. This can lead to a vicious cycles if your sim is not optimized enough for that.
          Ryan Brucks
          Principal Technical Artist, Epic Games

          Comment


            #80
            I tried sub-stepping as you suggest, while keeping time delta constant for each step. It indeed solves all the issues, but unfortunaly I can't afford it. I'd want frame to frame load to be more or less coherent. Plus I am already spreading simulation over 3 frames (advection, vorticity calculation, vorticity+force application, divergence, 11 pressure steps in first frame, 15 pressure steps in second frame, 14 pressure steps and gradient subtraction in third frame). I guess I will have to go with constant delta time in any case.

            Also seeding the wind sim(actually injecting velocities every frame, not seeding) for realistic appearance is a bit harder than I thought.

            On a side note, I wanted to share a bit of a trick with vorticity, that seems to help me greatly. When calculation vorticity force and applying this force, instead of sampling nearest pixels in a cross, increase the stride to 2-4 pixels, depending on sim resolution. Doing so generates quite stable and large vortices, even at low pressure iteration counts.
            Last edited by Deathrey; 05-16-2018, 06:06 AM.

            Comment


              #81
              RyanB

              Thanks for the amazing plugin, Ryan! I'm trying to replace the rainbow texture used in the 2DFluid simulation example with a media texture. However, the video doesn't end up playing at all. The fluid sim does still play over the first frame or some random frame of the video.
              This is the 2D Fluid sim I'm referring to:
              https://youtu.be/CWzPP5FAYAg?t=1196

              I'm basically replacing the rainbow like material in the video with a media texture material. It is the material on the Alpha Preview static mesh plane.

              When I place the same media material on a regular plane, it plays and loops just fine.

              I believe the fluid sim itself is based on the Navier-Stokes method.

              Additionally, if I want multiple players to interact with this fluid, how would you recommend doing that? There is no need for networking because I am using a depth camera to track users so the whole project will be running on a single PC.

              Any help will be greatly appreciated.

              Comment


                #82
                For me it worked just fine when I rendered a media texture to a render target. I do that to do some tests of extracting chroma masks and then dilating them etc.

                But I was testing using the new media framework in 4.20. Maybe it did not used to work? There is nothing fancy about seeding that rainbow, its just a draw material to RT event, and from then on it just gets passed into the sim render targets.

                Ryan Brucks
                Principal Technical Artist, Epic Games

                Comment


                  #83
                  How can I download this Plugin?

                  https://www.youtube.com/watch?v=CWzP...outu.be&t=1196

                  Is this?
                  https://www.unrealengine.com/marketp...dscape-seasons

                  Thankyou

                  Comment


                    #84
                    Originally posted by hi.masuda View Post
                    The Cloudscape Seasons was based on the same technology, but it is not the same asset as presented in the stream. This Livestream download sample can be found in this link: here
                    Nilson Lima
                    Technical Director @ Rigel Studios Ltda - twitter: @RigelStudios
                    Join us at Discord: https://discord.gg/uFFSEXY

                    UE4 Marketplace: Cloudscape Seasons
                    supporting: Community FREE Ocean plugin

                    Comment


                      #85
                      Originally posted by NilsonLima View Post

                      The Cloudscape Seasons was based on the same technology, but it is not the same asset as presented in the stream. This Livestream download sample can be found in this link: here
                      Thanks for answer.
                      It was very helpful for me.

                      Comment


                        #86
                        RyanB
                        I was wondering when the plugin will be updated to include the skeletal mesh options so we can create the smoke people you talked about on your blog.


                        https://youtu.be/GvI7qt3kmz4

                        Comment


                          #87
                          RyanB Thanks again for this amazing plugin! I'm still stuck with trying to find a way to get multiple actors to interact with the 2DFluidSim BP.
                          Currently only the Paint_Pawn can affect the render targets in BP_FluidSimulation01. How can I get multiple actors in the scene to interact with the fluidsim by LineTracing. I want to have about 50 spawned actors interacting with the Fluid Simulation by uising linetracing. Any help will be greatly appreciated

                          Comment


                            #88
                            Dear Ryan,

                            thank you for this outstanding plugin and those examples. Also thanks a lot for your shaderbits website and everything else you share with us. My favorite lecture.
                            This was so much inspiring for us, that we started a new project based on the 2D Fluid Simulation idea.
                            It is like a VR-Graffiti-Spray App with fluid effects and other image manipulations.

                            For the original "Force Splat", I use a spotlight attached to the controller. Then a scene capture which captures the spot light footprint.
                            With the modulation of SpotLight Parameters, Light function or the (animated) light material, its possible to create nice varieties of brushes and spray cans.

                            This works fine so far on flat walls. Now we plan to paint on 3D objects.
                            For this, we need a special Shader who can do the following:


                            Here you see the Static Mesh, with UV Space as Texture.
                            The Spotlight is used for the mask.
                            The scene caputures have same location and orientation then the spotlight.
                            Click image for larger version  Name:	overview.jpg Views:	1 Size:	223.3 KB ID:	1581900


                            Left ist the scene capture for the UV Texture
                            Middle is the scene capture for the SpotLight
                            Right is the masked Result
                            Click image for larger version  Name:	20190206-16_43_11M_Spray_UV_Remapped.png Views:	3 Size:	11.2 KB ID:	1581920Click image for larger version  Name:	20190206-16_43_21M_Spray_UV_Remapped.png Views:	2 Size:	12.3 KB ID:	1581921Click image for larger version  Name:	20190206-16_43_25M_Spray_UV_Remapped.png Views:	3 Size:	12.3 KB ID:	1581922


                            Now I want to use the masked Result as a "Pixel Reposition Map".
                            That means, that a given Textures pixel is moved to the UV Position of the masked Results color.
                            (Sorry for this unclever explanation. I try with images now...)

                            1 Click image for larger version  Name:	1.jpg Views:	2 Size:	2.0 KB ID:	15819092 Click image for larger version  Name:	1a.jpg Views:	1 Size:	1.6 KB ID:	15819073 Click image for larger version  Name:	2.jpg Views:	1 Size:	1.6 KB ID:	1581908

                            1. The TextCoord UV Space
                            2. The Masked Result from Scene capture
                            3. The Pixels of (2) are moved to the corresponding pixels of (1)


                            Click image for larger version  Name:	6.jpg Views:	1 Size:	27.4 KB ID:	1581911


                            I am crankin my head with this all christmas holidays. Let me tell you: its so hard not to be a genious...
                            Now, I would like to apply for your help!


                            -----------------------------------------------------------------------------------------

                            Here are some pictures from the current status and some paintings of a school class of 10-year old children (animated with flowmaps):
                            Click image for larger version  Name:	10071.jpg Views:	1 Size:	315.4 KB ID:	1581912Click image for larger version  Name:	46031-Kopie.jpg Views:	1 Size:	288.3 KB ID:	1581914Click image for larger version  Name:	87151-Kopie.jpg Views:	1 Size:	135.7 KB ID:	1581915Click image for larger version  Name:	97689-Kopie.jpg Views:	1 Size:	110.4 KB ID:	1581916Click image for larger version  Name:	97790-Kopie.jpg Views:	1 Size:	218.0 KB ID:	1581917 Click image for larger version  Name:	image_157295.jpg Views:	1 Size:	104.9 KB ID:	1581913

                            We build a real-world Spray-Simulator here in germany nuernberg and plan to donate it to a public city-youth-club.
                            Currently the simulator is located in our blacklight artspace.
                            It consists of a Wooden Box, a rear projection fabric, and a short throw projector inside the box. the dimensions are 3x2m, only 40cm depth.
                            We use the Vive controller for painting (without headset).

                            After the beta-phase, we plan to release a detailed how-to-build website. The Idea is, to support youth-clubs or communities to build their own graffiti/paint walls in a cheap way.
                            Click image for larger version  Name:	15461067532110.jpg Views:	1 Size:	241.2 KB ID:	1581925Click image for larger version  Name:	15461067535254.jpg Views:	1 Size:	122.8 KB ID:	1581924Click image for larger version  Name:	15454992711543.jpg Views:	1 Size:	266.2 KB ID:	1581927Click image for larger version  Name:	15461067534032.jpg Views:	1 Size:	157.5 KB ID:	1581926Click image for larger version  Name:	15454992712024.jpg Views:	1 Size:	159.9 KB ID:	1581923Click image for larger version  Name:	15461067533451.jpg Views:	1 Size:	270.3 KB ID:	1581928

                            -------------------------------------------------------------------------------------------


                            thx again for making this possible.
                            love and light,
                            fabi
                            Last edited by edstoica; 02-07-2019, 08:58 AM.

                            Comment


                              #89
                              That is awesome!

                              Interesting use of positional maps to transfer the data. If performance is an issue, you can actually improve that part by pre-rendering the position map of your static mesh to a texture before hand, and then using a single draw to render the effect of the 'spotlight' or brush cone directly to a render target without a scene capture. The only trade off is that you wouldn't get any self-shadowing like the spotlight/scenecapture approach may get you. May not be an issue for just simple geometric primitives.

                              If you look in the fluid plugin, the hitmask rendering part might have a good example of how that could be done. You would mostly just need to replace the spheremask with a cone distance field function.

                              Looks like some kind of interesting advection brushes going on in those trippy examples.
                              Ryan Brucks
                              Principal Technical Artist, Epic Games

                              Comment


                                #90
                                Hi Ryan,

                                I tried to install the plugin into an Unreal Mod, right after that Unreal stopped working. There is a message that says "The game module '....' could not be loaded. There may be an operating system error or the module may not be properly set up."

                                May i know how to fix it?

                                Thanks.

                                Comment

                                Working...
                                X