Friday, November 27, 2020

Performance seems to have definitely improved after making the following edits:
  1. Disabled CastShadows, ReceiveShadows, & UseLightProbes on all meshes and fragments where applicable.
  2. Set a handful of shaders from Standard (Spec) to mobile diffuse.
  3. Separated shutters and swinging doors into two separate occludible GOs. 
While the performance definitely seemed improved, it bears mentioning that the jail and hotel were completely disabled during this test.

 Working on optimization now. Thus far, controlling enabling and disabling of the fractured objects has worked well, but the FPS still has noticeable hitches from time to time--namely when the camera pans from stage to stage & also the hotel due to the sheer # of fractured objects. Reports (from Harry, done on the test machine) states that the FPS, "...actually seems to be doing very well, there's a few places where the FPS will drop for around 40 if you've been machine-gunning with the shotgun..." A quick look into the profiler while viewing only the saloon indicates that the drawing of opaque geometry is taking the longest to process, with physics.processing, and the animators.update being 2nd and 3rd respectively


I'm thinking the following: 
  1. Disable the shadow casting on all of the fragments (maybe disable receive shadows as well?).
  2. Using a more simple shader on the secondary material of the fractured pieces.
  3. Adding the ability to enable & disable the shutters and swinging doors one at a time.
  4. Disabling the fragmented lg windows that are covered by shutters. 
  5. Grouping together of multiple fractured GOs. This could be time intensive as it would require both placing & grouping unique building pieces together in Blender.

Wednesday, November 4, 2020

During the process of optimizing the meshes and maintaining material ID consistency (see previous post), I was merging verts based on a distance threshold, which while good, was still leaving a fair number of coplaner verts. For example, the verts on the right would be merged, but not the verts on the left.


In order to solve this, select all verts (from every fragmented piece), press delete, choose limited dissolve, and set the angular threshold. A value of 1 will suffice without compromising the silhouette of the individual fragments. 

Using this technique in addition to merge verts by distance, I was able to reduce the vert count from ~45k to ~30k on the trough mesh, which is quite a reduction :).






 Regarding fracturing, I am now addressing an issue that I've been aware of for quite some time but have yet to confront--the random reordering of Material IDsThis issue is brought to bear by the need to reuse the door mesh, which uses different, unique materials for the jail, the saloon, & the hotel.

Evidence of the swapped material IDs is exhibited when attempting to manually reassign materials to the individual fragments. ID 1 should be the facade of the door and ID 2 should be a generic wood, yet it can be clearly seen that this is not the case. 

After some searching I found this thread on the Unity forums indicating that on import Unity correlates vert/face values with material ID values. For example, whatever material the very first face (however that is defined) is using would be material 01, whatever material the second face is using would be material 02, etc. In essence, the specific sequential ordering of the faces directly affects the order of the materials on those objects, so despite the objects displaying the correct material ordering in Blender, the import into Unity does not. 

I found a solution here, and (in Blender) select all of the verts of every fragmented object and then "sort mesh elements" by material (ensure the "faces" option is selected). This will effectively reorder the faces according to materials, which is what we need. 

As a side note, I also merged verts by distance and was surprised to see that it removed 6000+ verts without noticeably affecting the mesh. I should do this for all fractured pieces and reimport.