Page MenuHome

Maths Node: Additional functions
Needs ReviewPublic

Authored by Charlie Jolly (charlie) on Tue, Oct 1, 3:49 PM.
"Love" token, awarded by R2792."Love" token, awarded by brilliant_ape."Love" token, awarded by wuzzle."Like" token, awarded by MasterNurmi."Love" token, awarded by B_Engstler."Love" token, awarded by koloved."Like" token, awarded by MetinSeven."Love" token, awarded by ogierm."Love" token, awarded by zanqdo."Like" token, awarded by nacioss."Love" token, awarded by ZohaibAli."Love" token, awarded by jonathanl."Love" token, awarded by RemingtonCreative."Love" token, awarded by 100drips."Love" token, awarded by astrand130."Love" token, awarded by lordodin."Love" token, awarded by craig_jones."Love" token, awarded by CadenMitchell."Love" token, awarded by blueprintrandom."Love" token, awarded by monio.



Maths Node: Additional functions

When creating shaders and using math functions it is expected that Blender should match functions in other DCC applications, game engines and shading languages such as GLSL and OSL.

This patch intends to add missing functions to the Blender maths node.

Ideally, it would be nice to have these functions available to vectors too but that is not part of this patch.

This patch adds the following functions trunc, snap, wrap, compare, pingpong, sign, radians, degrees, cosh, sinh, tanh, exp, smoothmin and inversesqrt.

Sign function is based on GLSL and OSL functions and returns zero when x == 0.

As mentioned here:

Diff Detail

rB Blender
Build Status
Buildable 5378
Build 5378: arc lint + arc unit

Event Timeline

Maths Node: Additional functions

Add functions sign, radians, degrees, cosh, sinh, tanh, exp and inversesqrt.

Charlie Jolly (charlie) retitled this revision from Maths Node: Add Radians and Degree utility functions to Maths Node: Additional functions.Tue, Oct 8, 9:58 PM
Charlie Jolly (charlie) edited the summary of this revision. (Show Details)

Move inversesqrtf to function

Charlie Jolly (charlie) edited the summary of this revision. (Show Details)Wed, Oct 9, 2:01 PM
Charlie Jolly (charlie) updated this revision to Diff 18999.EditedMon, Oct 14, 6:55 PM

Add trunc and snap

Add wrap, almost and madd

Almost: provides comparison function with tolerance fabs(a-b) <= c ? 1 : 0
Wrap: this wraps a value around and generates a triange/pingpong wave (might need to rename this function)
Madd: combine commonly used multiply and add a * b + c, reduces node clutter

Rename wrap to pingpong.

Add wrap, this is similar to modulo but works more reliably for negative numbers.

Charlie Jolly (charlie) updated this revision to Diff 19041.EditedWed, Oct 16, 2:14 AM

Add smoothmin and smoothmax functions (slower but very nice!).
Rename Almost to Compare, makes more sense and is used elsewhere in Blender.
Wrap function expanded with adjustable minimum value. wrap(x, max, min).
Tidy math menu with headings.

I think that's about it for new functions!!

Charlie Jolly (charlie) edited the summary of this revision. (Show Details)Wed, Oct 16, 2:48 PM