- Home /
Best way of creation custom object
Hello all, i need some help. I have to create an object in from of pendulum spiral. The object must be as much real as possible (high level of detalisaion) and must render fast on mobile device (iPhone 4+). I have now spiral created with custom mesh, not optimized (i dont reuse vertices). The problem is that when i apply some deformation to it (i update vertices coordinates), i get miserable FPS, like 10-12. For now: 1) Do i have to optimize my mesh? (reuse vertices etc.) 2) Or are there other ways to create custom object except of programmatical mesh creating? 3) If they are give me please short understanding about them (fast/slow, easy/hard-to-use) or links.
Thank you for attention and for any help. Sorry for terribad English.
Answer by Alec Thilenius · Dec 19, 2012 at 11:13 PM
So it sounds like you have a mesh you want to programmatically deform? Did I understand that correct? Unfortunately it sounds like what you are trying to do will be far too expensive to accomplish on mobile. There are two ways to do per-frame mesh updates. You can do it on the CPU, or on the GPU. If you update your mesh per frame on the CPU then it will be slow, there is no way around it. It’s a VERY expensive operation to iterate over tens of thousands of floats and perform complex math on them given the number FPUs most CPUs have. It’s even more expensive to then reload that updated buffer into graphics memory (Probably more expensive than recomputing it). The second option is to compute everything on the GPU via a computer shader. This is of course not an option for mobile.
Yeah, i know that floats are killer for AR$$anonymous$$ architecture...With Intel all sounds much better/ But i can't believe that's no way to optimize computations to make some of them on GPU, or optimize buffer reloading into graphics memory etc. There are few games with very expensive graphics like Asphalt 7 or GTA 4 on iOS platform and they work even good. I can't believe that my per-frame updating spiral is too hard for this system... I am actually looking for methods of rendering custom objects except mesh, like LineRenderer component etc. Or some OpenGL hooks?
Unfortunately what you are asking is a very VERY complicated field. $$anonymous$$aybe I am not understanding what you are trying to do correctly? Assu$$anonymous$$g I am, then there isn’t much of a way around it. It doesn’t matter if its AR$$anonymous$$ architecture, Intel, PowerPC, or A$$anonymous$$D, a CPU will never be good at FPU calculations. A CPU is a SISD Single Instruction Single Data processor. A CPU can only do 1 FPU calculation per tick (Not all entirely true, but I’m not getting into a discussion about OOO execution units, or $$anonymous$$$$anonymous$$X). A GPU is a Single Instruction $$anonymous$$ultiple Data processor, it is VERY good at FPU calculations, but is very limited in what it can do. To run what you are talking about on a GPU requires you write a ‘kernal’ in HLSL and load it on the GPU. This is not possible on mobile because the GPUs are fixed pipeline and are NOT programmable.
I realize what are you talking about... Sure i won't write kernel driver or something else, which is OS hook. I'll optimize mesh update then.. less mesh updates, less mesh size... And now, i think i got how Asphalt or GTA works on iPhone - they both have nondestructive world so no need mesh updates. Thanks, your posts were very useful. I'll keep topic open for a while - maybe someone else gives me some ideas about faster way to make updatable object without programmatical mesh update.
Computing floats on modern PC isn't that slow. I was actually suprised to discover that my lookup table for Sin() was slower than $$anonymous$$ath.Sin. Almost the same for $$anonymous$$ath.Sqrt(). The FPUs nowadays are really great. Of course a GPU is optimised for float operations, but only of similar kind. A GPU works way different than a CPU. A GPU is great to perform the same actions on a great set of data. Branches for example are slow as hell on the GPU.
Program$$anonymous$$g the GPU is even much more complicated than using threads wisely.
@Bunny83 modern ultra high performance CPUs (Like the Intel extremes) are measure in gigaFLOPS (Billions of floating point instructions per second). $$anonymous$$odern graphics cards are measured in TeraFLOPS (Trillions of floating point operations per second). I would not consider 3 orders of magnitude slower than a GPU "not that slow".
Answer by Bunny83 · Dec 20, 2012 at 01:49 AM
The problem is not the mesh itself. Well it's quite heavy to upload the mesh data into the GPU, but what is by far more expensive is rebuilding a collisionmesh for Physx. I've made this spherify terrain engine for another question here and i had massive lag when updating the MeshCollider mesh. As soon as i removed the collider it works perfectly.
Just to be clear: this sphere is made up by 6 seperate plane meshes with 64x64 vertices (vertices are shared, but that doesn't really matter). It works almost as well on my Nexus7 Android tablet. You can see a little FPS drop when pulling a slider, but not really much.
If you have an android, here's the same thing as APK.
$$anonymous$$y mesh has now 60000 verts, 20000 tris, and sure, no collider! But it's still slow ... I think, i have to optimize mesh, maybe create set of deformated meshes and then enable correspondong mesh each frame