BodySlide-and-Outfit-Studio
BodySlide-and-Outfit-Studio copied to clipboard
Lone partition triangles display wrongly and sometimes move to the wrong partition
Description In Outfit Studio's partition editor: suppose triangle T belongs to partition A but all of T's neighbors belong to partition B. If partition A is selected, T's color is drawn correctly. If partition B is selected, T's color is drawn as if it were part of partition B.
How to reproduce
- Open a Skyrim LE or SE model in Outfit Studio and click on the partitions tab.
- Make sure there are at least two partitions. Let's call them A and B.
- Pick a triangle T in B that is not close to any triangle in A.
- If necessary, change the brush size so that only T's three vertices can be brushed.
- Select partition A.
- Brush T so that it changes from partition B to A. Be careful to only change T and not any other triangle.
- Select partition B.
Though, on the surface, this bug appears trivial, I have no idea how to fix it trivially. If I were to try to fix it, I might find myself changing hundreds of lines of code, including stuff in the shaders. Since it's easy to work around this bug, I would prefer not to work on it myself.
The reason it's so messy is that partition triangle colors in Outfit Studio are rendered using data attached to the vertices, not data attached to the triangles. But partition membership is fundamentally a triangle property, not a vertex property. So I can't see how to fix the bug without doing something triangle-data-related in OpenGL.
If someone can find a trivial way to fix it, I will be impressed.
Only way to fix it is to use index magic in shaders. I've seen the issue before, but drawing vertex colors is way more straightforward. So I'm probably not looking into it soon, but am open for suggestions.
One way to fix it without touching the shaders would be to duplicate every vertex used by triangles from different partitions, so triangles from different partitions would use their own copies of the vertex with different colors.
On the other hand, if you don't mind changing shader code, you might want to look into geometry shaders (as opposed to vertex and fragment shaders). I don't remember exactly what geometry shaders do, but I seem to remember them doing things along these lines; they might be helpful.
The rendering part of this is now fixed.
Here's a simple problem that is still unfixed. A lone partition triangle will change partition incorrectly to match the surrounding partition if any edit is done. An example:
Suppose triangle T is in partition 1, and all of T's neighbors are in partition 2. Suppose the user then selects partition 2 and paints somewhere far from T. T will switch from partition 1 to 2 (incorrectly).