Thursday, October 29, 2020
Tuesday, October 27, 2020
Let's see what happens when attempting to integrate a fractured target. The target itself has both a mesh collider and a rigidbody, which are typically not on the initial mesh, so I'm unsure whether or not that will create problems or even if those components will be necessary when all is said and done. Also, the cell fracturing may not play nicely with this complex of a mesh; typically it likes quads, and quading out this mesh could be a headache. Oh well, here goes...
I recently made a few different variations of a painting that I created in Corel Painter last year. The variations are more conceptual rather than finished product. Primarily they were created using the channel mixer tool in combination with adjusting the HSB of various selections.
Here is the original
Friday, October 23, 2020
Box colliders instead of mesh colliders on the windows was apparently a not great thing as the BreakableObjects script specifically looks for a MeshCollider when disabling it on shot. I could probably fix this without breaking anything, but to be safe I'm not going to bother with it; at least, not yet. Anyways, as I said before, I imagine the performance benefits (if any) are negligible compared to the physics hit I'm getting on the fragmented objects.
Running into frame rate issues, which doesn't exactly come as a surprise. Spamming the P2 shotgun (the equivalent of 9 shots) & the sheer number of fractured objects on screen at any given time both seem to impact performance more than anything.
I've already made a couple of adjustments--namely reducing the time until the CombineInstance function fires & drastically reducing the life time of the particle fragments--which seems to have helped, but the performance is still not where it should be. I've also replaced the mesh colliders on the window panes with box colliders, which I would assume is also less expensive, if only barely. Other than that, I'm not yet entirely sure how I'm going to handle this...
Thursday, October 22, 2020
Going back to the fence, which was one of the first, if not the first object that had UV distortion issues, and after a bit more reading and trial and error, I have come to 2 conclusions
- there's something about tiling UVs that fracturing does not like. This can be solved by manually applying the boolean modifiers; however
- doing so somehow affects the maximum # of fragments that the CombineInstance function can handle.
In addition to the UV errors in the corners of the window mesh, I am still experiencing this error.
Tuesday, October 20, 2020
Now working on the large window and despite the UVs all seeming to be in order, for some reason the cell fracture was still distorting the UVs at these corner points. I would suspect that it is likely this is due to those points being poles, but if so, why did this not happen before? ...regardless, setting the debug boolean, manually setting the auto smooth of each piece and then converting to a mesh appeared to solve the problem. Nevertheless, WTF. This process still seems to have some kinks I don't fully understand.
Well, it looks like the bottom portion of this object didn't have UVs, and after making that correction it seemed to export just fine. Though, it's curious why it was sometimes working before. I would have expected the export to fail every time if this were the case. Maybe the fracturing does its best, but sometimes that's not good enough? Maybe it's something else? IDK, at this point half my day feels wasted so whatever...
Started over from scratch. Normals are now properly oriented although I still have no idea what happened because while they appeared as expected in Blender, in Unity they were reversed. Something with the import/export process...perhaps related to the errors I was getting?
The CombineInstance material issue was due to misc objects created by the CellFracturing. These misc objects contain no geometry and no material reference. I can only assume this is an error and although I have seen it, it hasn't been since the very first object I fractured. Not sure why it's resurfacing now, but deleting those objects solves the problem.
Should have expected this would be more difficult after saying what I said in my previous post, aaaaand blogspot has trouble uploading snippet via copy/paste...again. I suppose I should consider myself lucky my monitor doesn't explode and lodge shrapnel into my face.
Somehow, an additional blank/default material is being generated on CombineInstance. I have no idea why this is happening.
Saturday, October 17, 2020
After some doing, I finally got this working!
Fracturing and setting up the non animated door went as expected, but getting it to animate properly while also being destructible required finding and setting a reference I wasn't previously aware of as well as orienting the pivot in a specific way, which, while annoying, I'm not entirely surprised.
Side note, every 5 or so seconds the game suffers massive hitch. The profiler seems to indicate it has something to do with the "Scripts" and while I think the P2 shotgun fragmentation makes this somewhat worse, I cannot be sure exactly what impact it has. I'm not surprised, as the shotgun fires 9 shots simultaneously, which is ~9x the fracturing (depending on shot spread & objects hit), but the hitching may not be an issue were this initial hitching eliminated. I've also noticed that shooting the hitching post tends to more greatly impact the performance, which would indicate the interior (non-destructible mesh) is part of the problem as it is currently the only asset that is setup that way. For now, I'm moving on, because worse case scenario the interior portion is removed; although, I can probably find a more elegant solution.
Friday, October 16, 2020
437 fragments is too many for the CombineInstance function. Without further testing, I'm going to move forward assuming 400 is the limit. I may have to go back and re-fracture a couple (three?) assets once this is all said and done, but for now I'm moving forward because perhaps that won't even be necessary if performance is still good.
Minor caveat regarding this solution: all of the boolean modifiers must be applied prior to making any transform changes. I suspected this might happen, but was hoping due to all of the fragments being parented to the original mesh that I might be able to circumvent this. Well, apparently not. Couldn't quite figure out how to apply the modifier to all ~430 objects simultaneously and there was no way I was going to do this one-by-one. Apparently there are a few methods of doing this and the first one I landed on that worked was converting all of the fragments to a mesh, which technically they already were, but doing so collapses the modifier...simply to 3DS Max. Great
Based on the even division of the error, I figured it must have something to do with tiling UVs.
The error always occurs where there are seams in the UVs. The UVs were previously stacked, but I have moved them +/- 1 unit to better show the tiling.
I think I'm simply going to separate the mesh into 3 separate meshes, fracture each mesh, and then rejoin them. If the issue is as I suspect, this should fix it.
Now that I think I have fair grasp on both fracturing and integrating the result into Unity, it is time to try something a bit more complex. The Saloon
Thursday, October 15, 2020
The barrel is working with the metal banding being separate and ~500 fragments. A couple of things to note:
- The metal bands do not yet have a backface, so those should be added as they could be visible.
- The CombineInstance function fails at ~500 fragments (as you can below to the right). The left portion of the image is prior to the CombineInstance.
The barrel is a bit more complicated, or at least, it should be. The metal banding will be extruded and exist as a separate GO(s), because they should not be destructible; only the wooden planks should be. I'm also thinking everything below the top metal band should be sticky so that only the top 20% (ish) could crumble away.
Wednesday, October 14, 2020
These settings are a bit better, but I don't think it will ever be perfect due to how the system operates and the outcome will always display one of two (if not both) behaviors.
- The GO in question will be a bit too crumbly (as in the example below), or
- The GO will be too stiff and will result in floating fragments.
Anyways, here's the current result
Seems to be working roughly as desired. There are nearly 400 fragments and the CombineInstances isn't throwing the error I referenced a few posts ago, so whatever that limit is, it is more than 400.
There is still some refinement required as sometimes pieces will float in place due to the current settings in the connections panel.
Next up is a trough.
Found the problem! Here is the error that is thrown regarding the mesh combining.
At first I thought that perhaps the string length of the GOs was the problem, as many of my frag GOs has very long names, but it turns out that it is the sheer number of GOs that is causing the problem. I exported only a fraction of the # of fragments, and violá, no more error && no more visual abominations when the CombineInstance function executes. While this doesn't necessarily solve the problem--I would still like a lot of fragments as it helps more specifically identify where the shot has landed; in fact, I would prefer even more--but at least now I am aware of the specific cause.
I could break up the object into multiple prefabs. In this particular instance, 3 prefabs would be ideal--1 for the crossbar and 1 for each support, but that definitely makes the process more cumbersome as it is more GOs to manage, and perhaps more importantly, it doesn't solve the problem; it only sidesteps it. Lacking engineer support it may be a necessary evil.
From the looks of it, there's nothing in the Fragmented Objects scripts that hints at a limited # of fragments, so I suspect it is something native to Unity itself. I wonder if it is something that can be adjusted in the project settings, or if it is hard coded into the engine? I suspect the latter. I could, and still may, do some digging, but I have already spent much more time than intended orienting myself with this package. I guess you get what you pay for :
Tuesday, October 13, 2020
Cont from previous post
Perhaps it is naming issue? The fractured pieces do not all share the same base name due to the fact that I fractured the mesh not as a whole, but as 3 separate pieces that inherent make up the mesh.
Image failed to upload?!??! Dumb, but whatever. The base name of objects don't match, which should be easy enough to understand even without visual reference.
Soooo...this bullshit is happening when the CombineInstance function executes
Athough an error is being thrown, my limited knowledge of code is preventing me from truly understanding why this is happening. I suspect it has something to do with material IDs and the fact that they are sometimes swapped on any given fractured piece. Visually, each individual fractured piece looks as it should, which you can see in the image below; however, upon running the CombineInstance function, the artifacting happens.
I thought that disabling CombineFrags would solve this particular issue, but it does not. I can instead increase the value of the CombineMeshesDelay to an integer that is greater than the amount of game time, and while that would technically solve this particular problem, I would be surprised to encounter performance related issues as a result of this particular "solution."
Regarding the swapped material IDs, I think that this is somehow the result of the Cell Fracturing process, and that somehow when assigning the secondary material ID, the nature (concave vs convex) of the fractured shape might be responsible. For example, previously the entire mesh was fractured. Notice how in the image below the 3 removed pieces reveal that the interior of the mesh is completely solid, which makes every fracture piece convex and ensures the entire mesh can be fractured apart.
However, in this instance, I do not want the entire mesh to break apart, but instead I wanted there to be an underlying piece of geometry that would recognize shot collision, but would not itself break apart, and to do this, the Cell Fracturing can account for interior (child) geometry and will fracture accordingly, giving the following results
Notice how the fractured piece is now concave due to the fact that the fracturing algorithm has conformed to the interior mesh. You can also see examples of this in the 2nd image of this post (the one that displays the actual fracturing).
Still, this is all just a hypothesis and I currently do not have an adequate solution.
Wednesday, October 7, 2020
- A value of 0 is equivalent to disabling that property.
- The larger the StickyTop/Bottom value, the more pieces will be considered to be top/bottom.
- The larger the ConnectedFragments value, the more easily the mesh will crumble.
Tuesday, October 6, 2020
In the process of using Fragmented Objects for destruction purposes. None of the games currently support or have implemented tech such as this and it is very much a missed opportunity to make the user feel as if they exist, and have impact, on the game world. The proof of concept in PL2-Outdoor was a success and now it is time to apply it to a more relevant games.
First, the Fragmented Objects package is not responsible for dynamically fracturing the mesh; the fractured meshes must be user-generated. To do this, I am using Cell Fracture plugin in Blender v2.82, which while not perfect, does generate useable results that don't require breaking up the mesh by hand.
Second, while not new to 3D software, I am new to Blender so there has been (& will be) a bit of learning curve. However, the setup & the major hurdles of the process have already been addressed, so outside of working out the kinks in Blender, I don't foresee any major hurdles and expect in time this to be a relatively straightforward, streamlined process. Perhaps it could even be entirely automated given an engineer's touch, but that's a bit out of my current reach.