Posts: 4
Threads: 1
Joined: Sep 2018
Reputation:
0
Hi,
We want to run a small and reasonably simple water and blood simulation on higher-end iOS devices. So far we have not been able to get the sim running on these devices. I'll post more details of the issues, but before spending more time on this, I have a few questions that I don't see fully answered here. "just use the simple simulation shader" is not an option, as we need the full 3D sim. Advertising seems to imply it should work, so:
1. Should it be possible (performance aside) to run the 3D Obi fluid sim on iOS devices?
2. Is the latest binary compatible with Unity 2017.4.x and 2018.1/2/3.x?
a. If not, when can we expect compatibility?
b. Do we need a new iOS binary lib?
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
06-09-2018, 04:40 PM
(This post was last modified: 06-09-2018, 04:43 PM by josemendez.)
(06-09-2018, 03:17 PM)skicattx Wrote: Hi,
We want to run a small and reasonably simple water and blood simulation on higher-end iOS devices. So far we have not been able to get the sim running on these devices. I'll post more details of the issues, but before spending more time on this, I have a few questions that I don't see fully answered here. "just use the simple simulation shader" is not an option, as we need the full 3D sim. Advertising seems to imply it should work, so:
1. Should it be possible (performance aside) to run the 3D Obi fluid sim on iOS devices?
2. Is the latest binary compatible with Unity 2017.4.x and 2018.1/2/3.x?
a. If not, when can we expect compatibility?
b. Do we need a new iOS binary lib?
1.- Performing a full 3D fluid simulation in mobile is going to use most of the resources in the device (supposing it is even capable of running it, which is a long shot), so unless your game revolves around it I'd advise against doing that. However nothing stops you from running a 3D simulation in a mobile device, you just need to adapt rendering to take depth testing into account. The physics simulation itself is platform agnostic and doesn't care if it is running in 2D or 3D. The only difference lies in rendering.
Obi's fluid renderer pipeline is made to be extensible. Akin to Unity's SRP, it allows you to write your own renderer/shader combinations and comes with two working implementations, each one at one end of the quality/performance spectrum: FluidRenderer (high quality, performance heavy) and SimpleFluidRenderer (low quality, lightweight). See:
http://obi.virtualmethodstudio.com/tutor...ering.html
The SimpleFluidRenderer is designed with mobile devices in mind, since most aren't capable of running a full 3D simulation. Pretty much all fluid gameplay dynamics we've seen in mobile devices are 2D. For this reason the SFP only supports 2D rendering.
You could either:
- Grab the FluidRenderer, see how it performs in your target device, and tweak it until performance is acceptable (downscale fluid buffers, drop lightning calculations from the shaders, etc).
- Build depth-testing on top of the SimpleFluidRenderer.
2.- Yep, it is compatible with all Unity versions up to 2018.2. Haven't tested 2018.3 yet, but should work fine there too.
Posts: 4
Threads: 1
Joined: Sep 2018
Reputation:
0
(06-09-2018, 04:40 PM)josemendez Wrote: 1.- Performing a full 3D fluid simulation in mobile is going to use most of the resources in the device (supposing it is even capable of running it, which is a long shot), so unless your game revolves around it I'd advise against doing that. However nothing stops you from running a 3D simulation in a mobile device, you just need to adapt rendering to take depth testing into account. The physics simulation itself is platform agnostic and doesn't care if it is running in 2D or 3D. The only difference lies in rendering.
Obi's fluid renderer pipeline is made to be extensible. Akin to Unity's SRP, it allows you to write your own renderer/shader combinations and comes with two working implementations, each one at one end of the quality/performance spectrum: FluidRenderer (high quality, performance heavy) and SimpleFluidRenderer (low quality, lightweight). See:
http://obi.virtualmethodstudio.com/tutor...ering.html
The SimpleFluidRenderer is designed with mobile devices in mind, since most aren't capable of running a full 3D simulation. Pretty much all fluid gameplay dynamics we've seen in mobile devices are 2D. For this reason the SFP only supports 2D rendering.
You could either:
- Grab the FluidRenderer, see how it performs in your target device, and tweak it until performance is acceptable (downscale fluid buffers, drop lightning calculations from the shaders, etc).
- Build depth-testing on top of the SimpleFluidRenderer.
2.- Yep, it is compatible with all Unity versions up to 2018.2. Haven't tested 2018.3 yet, but should work fine there too.
Thanks for the info. A couple more questions:
3. Does this work with Metal, or does it require OpenGL on iOS? We are using Metal only.
4. "adapt rendering to take depth testing into account" Is there something about the PC 3D fluid rendering pipeline, say in the Unity example scene with the faucet and bowl, that would not function on say an iPhone 10, or iPad Pro? Just slowly.
We would certainly customize the rendering to our use case, but for now I just want to get something visible on the device regardless of performance.
Posts: 4
Threads: 1
Joined: Sep 2018
Reputation:
0
(06-09-2018, 08:53 PM)skicattx Wrote: Thanks for the info. A couple more questions:
3. Does this work with Metal, or does it require OpenGL on iOS? We are using Metal only.
4. "adapt rendering to take depth testing into account" Is there something about the PC 3D fluid rendering pipeline, say in the Unity example scene with the faucet and bowl, that would not function on say an iPhone 10, or iPad Pro? Just slowly.
We would certainly customize the rendering to our use case, but for now I just want to get something visible on the device regardless of performance.
For any who read this later, an update.
In fact it does run just fine in Metal, on 2018.2.x on iOS. I was able to get the Faucet scene running on an iPhone X with 1000 3D particles in the bowl at nearly 90FPS, a total CPU frame time of about 12ms. So, it is quite possible to run the fluid sim on at least a high-end phone. Sure it's a simple example, but it does run just fine...at least with the default camera position. Move the camera in closer so the water fills more of the screen and it tanks, so the rendering does need some work...but a promising start...
Posts: 6,326
Threads: 24
Joined: Jun 2017
Reputation:
400
Obi Owner:
12-09-2018, 08:19 AM
(This post was last modified: 12-09-2018, 08:21 AM by josemendez.)
(11-09-2018, 09:20 PM)skicattx Wrote: For any who read this later, an update.
In fact it does run just fine in Metal, on 2018.2.x on iOS. I was able to get the Faucet scene running on an iPhone X with 1000 3D particles in the bowl at nearly 90FPS, a total CPU frame time of about 12ms. So, it is quite possible to run the fluid sim on at least a high-end phone. Sure it's a simple example, but it does run just fine...at least with the default camera position. Move the camera in closer so the water fills more of the screen and it tanks, so the rendering does need some work...but a promising start...
Fillrate is most mobile devices achilles' heel, so moving the camera closer to the fluid (making it fill the entire screen) is probably getting the GPU to its knees. If you'd profile this, you'd see the fragment shaders taking up most of the frame time.
One easy way to alleviate this is to simply reduce the fluid rendering resolution. To do this, go to the UpdateFluidRenderingCommandBuffer() method in ObiFluidRenderer.cs, and reduce the resolution of all buffers. For instance:
Code: renderFluid.GetTemporaryRT(refraction,-1,-1,0,FilterMode.Bilinear);
would become this, if rendering at half-screen resolution:
Code: renderFluid.GetTemporaryRT(refraction,-2,-2,0,FilterMode.Bilinear);
Currently only the thickness buffers are rendered at half-res, but I think you can get away with less resolution for pretty much all buffers.
Posts: 4
Threads: 1
Joined: Sep 2018
Reputation:
0
(12-09-2018, 08:19 AM)josemendez Wrote: Fillrate is most mobile devices achilles' heel, so moving the camera closer to the fluid (making it fill the entire screen) is probably getting the GPU to its knees. If you'd profile this, you'd see the fragment shaders taking up most of the frame time.
One easy way to alleviate this is to simply reduce the fluid rendering resolution. To do this, go to the UpdateFluidRenderingCommandBuffer() method in ObiFluidRenderer.cs, and reduce the resolution of all buffers. For instance:
Code: renderFluid.GetTemporaryRT(refraction,-1,-1,0,FilterMode.Bilinear);
would become this, if rendering at half-screen resolution:
Code: renderFluid.GetTemporaryRT(refraction,-2,-2,0,FilterMode.Bilinear);
Currently only the thickness buffers are rendered at half-res, but I think you can get away with less resolution for pretty much all buffers.
Yes, this was in fact my planned next step. Thanks for the pointer.
|