Kryslin's lScripts

Kryslin

Well-known member
Since I seem to be posting these things all over the place, I'd figure I'd start a thread down here and post (repost) them here...

First up is the BiasComb and Bias Show tools...
View attachment BiasTools.zip

BiasShow has been updated to handle vertices that don't have a bias map assigned to them.

The zip file contains two lscripts; BiasComb and BiasShow.

These are both fire-and-forget lscripts for use in Modeler.

Bias Comb Usage :
1) Hide the geometry you don't want to have combed (Not really necessary, but why take chances?).
2) Run lscript
3) If the model has no existing bias maps, choose (new), and enter a name in the text box. Otherwise, choose an existing bias map
***The script cannot tell the difference between a bias map and one re-mapped to the 0...1 domain. Things could get ugly if you choose
***the wrong bias map. The remapped version this script produces ends with a "_rm".
4) Choose a surface to comb away from.
5) Choose which surfaces to comb (ctrl-click to select multiples)
6) Choose how the bias vector gets computed; either vector addition, or interpolation between the vertex normal and the computed bias vector. Vector addition gives results closest to Sasquatch quick combing.
7) Choose whether you want to overwite the existing map, or average the new bias map with the existing one. If you are generating a new map, it will lock in overwrite, whether you choose it or average.
8) Press "OK".
9) Wait. It's slow, I know. I wrote this to be as memory friendly as possible, so very little gets loaded into arrays.
10) Done!

Multiple passes of combing are supported. By creating a box or sphere, you can hide various portions of geometry, choose average, and brush away from the surface you assigned to you brushing object.

Usage of Bias Show:
1) Select some polygons or vertices.
2) Run lscript.
3) Choose your bias map.
4) If you have a weight map for fur length, you can choose it. If not, select Fixed.
5) Press Ok.
6) 2pt. Polygons representing the bias vector stored in the selected map are created in the first background layer available.
7) Done!

The geometry in the background layer is disposable, and least for now.

I hope people find these useful, or at least amusing. It's been tested on Lightwave 2015.3, and should work on 11.6.3.
I make no guarantee for suitability of purpose. Use at own risk. Free to distribute. If you modify it, I'd like a copy of the change.
I've stomped most of the bugs. If you find one, let me know.

Neither of these scripts likes malformed geometry, so no 1 & 2 pt polygons. The results aren't pretty.
(I'll be working on correcting this later. Got more alpha testing to do for someone...)
 

Greenlaw

Eat your peas.
The script seems to work here but the Bias Show script gets interrupted by this:

Capture.PNG

When I close the debug window, the script continues and finishes creating the visual guides. Not sure why it does that but I thought you should know.
 

Oldcode

Member
Hey Kryslin,

So, these tools are to comb hair in Modeler, yes? Also, what exactly is a Bias Map? I don't think I've ever heard the term before. Sorry for my ignorance.
 

Kryslin

Well-known member
Because I had the debugger enabled. Grrr...

Open BiasShow.ls in notepad (or similar), and either delete the debug(); statement, or put a // in front of it, and save it. I'll update the zip file...

I can be sooooo stooopid!
 

Kryslin

Well-known member
Hey Kryslin,

So, these tools are to comb hair in Modeler, yes? Also, what exactly is a Bias Map? I don't think I've ever heard the term before. Sorry for my ignorance.


A Bias map is a type of RGB vertex map that has vector information stored in it. You can see what a Bias Map looks like under the surface window -> advanced->vertex color map menu item. Fiber FX uses it to determine the directions hair 'grows'. You use BiasComb to generate the map, and send the object to layout. Under Styling, there's an option to use a Bias Map. Click the remapped option if you're using a bias map whose values have been remapped to the 0...1 range. You can also choose how strong the effect of the bias map is.

The overall effect is similar to Sasquatch's Quick Combing. With the right placement, you can get fur "just right" with only a single combing pass.

- - - Updated - - -

Updated Zip:
View attachment BiasTools.zip

Debug line squashed.
 

Greenlaw

Eat your peas.
I got it to work in Layout. Just a 'junky' test so nothing exciting to show. But it does work!

For anybody new to using the Bias Map feature in FiberFX, look under the Styling tab and apply the map from the list at the bottom. You also need to turn up Direction Bias before you see anything in the render. (Just crank it up to 100% and adjust from there as needed.)
 
Last edited:

Greenlaw

Eat your peas.
@Oldcode, the old FiberFX Strand Modeler (in Modeler) can also be used to generate a Bias Map. Strand Modeler does not 'auto comb' like Kryslin's tool does, but if you need specific direction control, it's another option. I used this a few times years ago to quickly knock out hair for a few background characters.

@Kryslin, Thanks for creating these scripts Steve! I think these tools are going to be very useful additions to my FiberFX toolkit. :)

BTW, I tried the latest and the debugger no longer pops up. Yay!

Will play with this more when I get home tonight.
 
Last edited:

Kevbarnes

New member
- Not sure where to post this, but I'll stick it here for now. - This shows an additional use of your script -

Just used you excellent 'Show Bias' to generate fiber guides.

1_GenerateGuidesFromBiasMap.JPG 2_ExtendingGuidesForFeatherShape.JPG

As the guides are generated from the bias map they are automatically grown at the combed root angle which has saved a bit of time

I used a weight map of 10% to get an initial short guide then add 5 more nodes using Strand tool. this gives me 6 nodes per fiber to shape the feathers (as detailed in a previouse post). This is not necessary if you only need fur

The benefit of fiber guides is that get dynamic simulation on them from Bullet or LW dynamics.
 

Kryslin

Well-known member
Yes, it was just Bias Show that was updated. I don't even think it has a version number.

And gee, someone figured out another use for Bias Show. :)
 

Kryslin

Well-known member
Should have a small update to both tomorrow.

I've made the remapped bias map generation optional, and added versions to the menus to both.
 

Greenlaw

Eat your peas.
Looking forward to it.

I meant to try Bias Tools on my 'Brudders' characters this weekend and compare it to the FiberMesh and Edit Guides versions. I suspect it will hold up respectably well, especially for how little effort it takes to use the tool. Maybe I can run that test after you release the next build. :D
 

Kryslin

Well-known member
Bias Comb 1.01 & Bias Show 1.02

Updated the BiasComb and BiasShow lScripts:
-Both now display version numbers in their requesters.
-Generating the remapped bias map in BiasComb is now optional, controlled by a checkbox.
 

Attachments

  • BiasTools.zip
    3.5 KB · Views: 325

Kryslin

Well-known member
Here we go again...

Presenting Kryslin's Hair Tools! These are a set of lscripts that help with the generation of guide curves for use in hair styles.

View attachment HairTools.zip



The long hair in this image is an example of what can be done with the tools in the .zip file, along with Lightwave's normal modify tools (translate, rotate, scale, jitter, etc.) There were a couple of experimental tools used as well, but those are kind of jittery, and not working quite as well as I'd hoped.

These have actually been ready for quite a long time - December 2015, in fact. The problem with releasing them is that they duplicate functionality in TrueArt's EasySpline kit, and with the beta hair styling tools from the defunct(?) TrueHair kit. Sensei's tools are far faster than mine, and probably more capable. Mine do get bogged down under large item counts (I have tested up to 4K items...!), but they do get the job done. I provided these tools free of charge, whereas Sensei's are a marketable plugin. If you need speed, please, buy his EasySpline plugin.

Documentation is included in the zip file. As with most of my lscript plugins, they are fire and forget - Select, run Script, done.

Some do need a little work and tweaking, mainly for undo-ing operations. And I double checked to make sure the debug(); statements are commented out. :)

I hope someone besides me finds these useful.
 

busy days, but i'll be testing these down the road. they do look incredibly useful(!)
so hope to make some video previews later on.
 

Kryslin

Well-known member
I've got a few more hair guide tools, each serving some obscure purpose...
-Superwiggle - resamples guide splines so that they have a wave to them. It works, but I need to work on my resample and waveform algorithms...the waves aren't wavy enough. :)
-Ragged - randomizes the lengths of the ends of splines.
-GrowHair - different from MakeHair; it grows a spline out along the surface normal of the polygon. May refine this more to include gravity and collision with geometry.
-SelStrandPoints - Selects all the points in a guide except for the first two or three...
-Resample Spline - eliminates co-linear points and culls point based on the dot product of two vectors on an arbitrary spline of at least three control points.

These tools, however, are somewhat twitchy, or slow running, or unstable if you don't use them in precisely the way they're intended.
The spline resample lscripts suffer from not know the exact Catmull-Rom evaluation formula LW3DG uses... I've got a good approximation, but it's still off a bit.

Here's a copy of my "Documentation", for those who wonder what's in the zip...

Code:
Steve's Hair Tools
Tools Version 1.0
Docs Version 1.0
11 May 2017

License:
Free to use, free to modify, free to distribute - just give me credit for the originals.  Use at your own risk, however.

Tools			File Name
--------------------------------------------------------------------------------------
Extrude Spline		(smp_ExtrudeSpline.ls)
	Select a spline, or a point on a spline, execute script.  This adds a new point
	at the end of the spline, which can be manipulated with any of the normal modeler
	tools.  Very useful for making hair guides.  Works on multiple selections, though
	it might be a bit slow on larger selections.

Flatten points		(smp_FlattenPoints_v2.ls)
	Takes a group of points and sets their X,Y, or Z values to the Min, Max or Average
	value, depending on what options are set.  Also flattens to a plane defined by the
	first 2 points selected and the center of the mass of points.

Make Hair		(smp_MakeHair.ls)
	Takes a polygon selection and puts a small, 2 point spline curve at the center
	point.  Root depth is how far under the surface the start point is, and height
	is how far above the surface the end of the second point is.  Points are selected
	and ready to use with Extrude Spline.

	-Make Point on Surface adds a third point to the spline, right at the center of the polygon.
	-Assign Surface lets you assign a surface name to the spline curves, allowing for some
	organization of multiple groups of curves.
	-Surface Name is the name of the surface you wish to assign to the curve.  This box isn't
	active unless Assign Surface is checked, above.


Select End		(smp_SelSplineEnd.ls)
Select Start		(smp_SelSplineStart.ls)
	With a spline (or group of splines) selected, selects the End Point or Start point, respectively.

Select Next		(smp_SelSplineNext.ls)
Select Prev		(smp_SelSplinePrev.ls)
	With a point (or group of points) on spline curves selected, selects the Next or Previous points,
	respectively

SplineSmooth		(smp_smoothspline.ls)
	Applies a simple smoothing algorithm to a spline curve.  Select a spline curve(s), and run the script.

Straighten Spline	(smp_straightencurve.ls)
	Straightens spline curves along a plane defined by the start of the curve, the mid control point, and
	the end point of the curve.

XTrim Spline 		(smp_trimspline.ls)
	Select a point along a spline curve, execute script.  Spline is cut at the selected point, everything
	past the selected point is discarded.
 
Top Bottom