CapsAdmin / pac3

advanced avatar customization for garrysmod
GNU General Public License v3.0
205 stars 94 forks source link

(Bug) OBJ models render hidden spheres #1386

Open TheReeb opened 1 month ago

TheReeb commented 1 month ago

This issue is out of my field frankly, but from my findings when using OBJ models in PAC, they leave behind a sphere that is usually right on, or close to models origin point. Screenshot_8

To make sure I'm not imagining things, the model does not have any hidden sphere models in Blender. Screenshot_9

PAC version is on latest.

pingu7867 commented 1 month ago

I knew this one was gonna be a doozy so I dug. that's actually real, the default CS entity's model is set to scale 0.001, idk why it wasn't just set to 0, but normally it's covered up (it would be in your case, people don't make floating hair without a head), usually you only see the ball if you scaled the model tremendously in pac, and ideally you adjust your scales to fit Hammer Units (units you see in Blender are purely visual. only the numbers matter, and for reference a head is about 10 (HU)) in blender prior to exporting

the entity isn't actually the obj, but instead the obj is built into a separate IMesh that gets drawn separately. The actual entity's model is drawn first for hacky rendering reasons?? If it doesn't get drawn, the obj mesh takes the previous model rendered material (even from outside pac)??? I guess it was done that way so that the material can be defaulted as the default material, but why not just set the render material manually?

and LOL I just discovered a macro optimization drawing the default ball + some torus I got from Blender takes 8-9 microseconds on average setting the render material etc and only drawing the torus takes 4-5 microseconds on average there's side issues because of how fragmented and hacky the rendering code is but it might be good if I can work my way around those

we rarely get this relative amount of optimization relative to the baseline so it's a W if I can make it work without negative side effects

but idk how many objs vs mdls are used by players so idk if it's gonna make a dent in actual use, it's probably not but hey, that's something