ousnius / BodySlide-and-Outfit-Studio

BodySlide and Outfit Studio, a tool to convert, create, and customize outfits and bodies for Bethesda games.
GNU General Public License v3.0
293 stars 64 forks source link

Move brush improvements #420

Closed themilkdrinker0 closed 2 years ago

themilkdrinker0 commented 2 years ago

OS move brush feels weird, I don't know how the 3D softwares do it, but I took some screenshots as an exemple:

Zbrush | Softimage | OS

Untitled-1

Also, that's the maximum radius brush size in OS, it would be nice to have it extended.

sts1skj commented 2 years ago

@themilkdrinker0 What if you fiddle with the "Focus" brush setting slider?

themilkdrinker0 commented 2 years ago

1.0 Focus

image

0.1 Focus

image

Same brush size.

sts1skj commented 2 years ago

@themilkdrinker0 But what about more intermediate values for brush focus? .2, .3, .5, .7, .8?

(I agree the "Size" brush setting needs a higher maximum than 1.0.)

themilkdrinker0 commented 2 years ago

0.2 seems to give the best result, but could be more responsive, that's dragging all the way to the corner of the screen, it would be nice for it to deform closer to the mouse movement.

image

sts1skj commented 2 years ago

Here's the formula for how focus affects the strength of the move at a vertex whose distance from the pointer is "d":

sd = d / radius

strength = (1 - sd^2) * (1 - (sd / focus)^4)

where "radius" is the brush size and "focus" is the focus brush setting, 0<focus<=1.

I have no idea where this formula came from; it's from before I started working on Outfit Studio.

It looks like Zbrush and Softimage use completely different formulas and perhaps even completely different algorithms.

themilkdrinker0 commented 2 years ago

Zbrush also has a second circle inside the brush display circle to represent the focus, this could be helpful too.

sts1skj commented 2 years ago

Here's a graph of the brush strength as a function of d / radius for focus of .1, .4, and .8 (using the formula above, which is from the current Outfit Studio 5.5.2 source code):

image

To me, there are some problems evident in these curves:

  1. The nonzero portion does not extend to 1.
  2. They have approximately the same shape, just different scales.
  3. They have a hard turn when they hit the x axis instead of curving smoothly. (Mathematically, the slope is discontinuous.)
sts1skj commented 2 years ago

Ack! The formula I gave above is for focus<.2 . A different formula is used for .2<focus<1 . So the graphs above are labeled wrong: those are for focus=.08, .02, and .16, not .4, .1, and .8 .

The formula used currently for .2<focus<1 is: x = 5 focus (1 - sd) - 1 strength = (1 - x^2) * (1 - x^4) if x < 0 strength = 1 if x >= 0

Here are the graphs: image

sts1skj commented 2 years ago

Here's an updated graph combining both ranges for focus:

image

sts1skj commented 2 years ago

@themilkdrinker0 Could you post your nif file with the sphere that you used in your screenshots? I want to test some possibilities.

Looking at your screenshots, I can see why .2 would give the best result: it has the nicest-looking curve in the graph.

themilkdrinker0 commented 2 years ago

Sphere.zip

sts1skj commented 2 years ago

Here's a possibility that I'll name "the cubic option":

p = 6^(2 focus-1) x = sd^p strength = 2 x^3 - 3 * x^2 + 1

(I chose the number "6" in the formula to give reasonable extremes: the higher that number, the more pointy it is at 0 and the more flat it is at 1, with .5 staying the same. The other numbers in the formula are necessary for this function to work.)

Here's a graph: image

Here's its effect on the sphere at focus=.5 (and maximum brush size): image

Focus=0: image

Focus=1: image

Focus=.25: image

Focus=.75: image

@themilkdrinker0 What do you think? Is it significantly better? Is there room for improvement?

themilkdrinker0 commented 2 years ago

Looks good to me, just make the 0.5 the default value when opening OS.

sts1skj commented 2 years ago

@ousnius What do you think? May I replace the formula in TweakBrush::getFalloff with the new formula, get rid of the factor-of-5 scaling, and set the default to .5 for all brushes?

themilkdrinker0 also requested that the maximum brush size be increased. It looks like, internally, brush size is scaled by 3. May I increase the scaling to 10?

ousnius commented 2 years ago

@sts1skj Yes, please do so I can play around with the new formula myself. Feel free to increase the scaling to 10, but make sure to adjust the default size (0.150 right now) accordingly to be the same size it is currently.

sts1skj commented 2 years ago

@themilkdrinker0 Ousnius and I have played with the new brush scale some, and we don't like 10, so we're going to keep the old brush scale of 3. But we're also increasing the maximum size of the value that can be input into the text field next to the slider from 1 to 10, so you'll be able to get a larger brush size by typing in the number you want. We're also increasing the precision of the text field from 3 to 4, so you can type in smaller brush sizes.