[Closed] Noise modifier
Has anyone re-created the Noise modifier in Maxscript? I’m looking to recreate it and add some additional features to it.
I’ve looked at a few samples for adding noise online, however I’m interested in re-creating the maxscript noise modifier.
Either way,
Was just curious to know if someone had already done this
The light blue object is using the default 3ds Max noise modifier. The darker blue is using my modifier from below. Why does mine not keep the overall width between the vertices the same? It seems to skew them much more than the max default one.
plugin simpleMod MyNoise
name:"MyNoise"
classID:#(0x28923a6b, 0x636f4873)
version:1
(
parameters main rollout:params
(
AlignNoiseX type:#worldunits ui:uiAlignNoiseX default:0
AlignNoiseY type:#worldunits ui:uiAlignNoiseY default:0
AlignNoiseZ type:#worldunits ui:uiAlignNoiseZ default:0
AlignNoiseFrequency type:#float ui:uiAlignNoiseFrequency default:0.0
AlignNoisePhase type:#float ui:uiAlignNoisePhase default:0.0
AlignNoiseScale type:#float ui:uiAlignNoiseScale default:1.0
)
rollout params "Parameters"
(
group "Noise"
(
spinner uiAlignNoiseX "X: " type:#worldUnits range:[-1e9,1e9,0]
spinner uiAlignNoiseY "Y: " type:#worldUnits range:[-1e9,1e9,0]
spinner uiAlignNoiseZ "Z: " type:#worldUnits range:[-1e9,1e9,0]
spinner uiAlignNoiseFrequency "Frequency" range:[0,1e9,.1] type:#float scale:0.01
spinner uiAlignNoisePhase "Phase" range:[-1e9,1e9,1.0] type:#float scale:0.1
spinner uiAlignNoiseScale "Scale" range:[0,1e9,1.0] type:#float scale:0.01
)
)
on map i p do
(
-- add Noise
n = (noise3 ([i*AlignNoiseFrequency, 0 , AlignNoisePhase])) * 10.0 * AlignNoiseScale
p += [AlignNoiseX*n, AlignNoiseY*n, AlignNoiseZ*n]
p
)
)
/* test scene */
clearlistener()
delete objects
obj = Plane length:20 width:150 lengthsegs:1 widthsegs:40 pos:[0,0,0]
addmodifier obj (MyNoise())
select obj
You are creating a different noise3 () for each vertex.
If you want the same result than the light blue image, you should apply the same noise value to the ‘pairs’ of vertex.
In this special case of this plane with 40 widthsegs:
n = (noise3 ([(mod (i-1) 41)*AlignNoiseFrequency, 0 , AlignNoisePhase])) * 10.0 * AlignNoiseScale
Edit: Haven’t seen Jorge’s proposal. It’s possibly a better one.
The noise3() function is not a random noise generator as it might be in other software. It returns the noise value at a given point. If the input value is always the same, the returned value will also always be the same.
In your example, you are feeding the noise3() function it with a different value for each vertex, based on the vertex index, for the x component, and so getting a very different noise values.
Using the vertices index as input value may make sense in and ordered grid, but if they are scattered in a random fashion, then the result won’t be as good.
One way to get the result you want, for the specific example you showed, could be to use the vertices x component as input instead of its index.
n = (noise3 ([[B]p.x[/B]*AlignNoiseFrequency, 0 , AlignNoisePhase])) * AlignNoiseScale
EDIT: It was meant to be p.x not i.
Here is a MXS Noise Modifier based on the SDK version with some modifications. Not fully tested.
plugin simpleMod noiseMXS
name:"Noise MXS"
classID:#(0X391767F4,0X417F1CAB)
(
parameters main rollout:params
(
seed type:#integer ui:spn_seed default:0
scale type:#float ui:spn_scale default:100.0
fractal type:#boolean ui:chk_fractal default:false
roughness type:#float ui:spn_roughness default:0.0
iterations type:#float ui:spn_iterations default:6.0
strengthX type:#worldunits ui:spn_strengthX default:0.0
strengthY type:#worldunits ui:spn_strengthY default:0.0
strengthZ type:#worldunits ui:spn_strengthZ default:0.0
animated type:#boolean ui:chk_animate default:false animatable:false
frequency type:#float ui:spn_freq default:0.25 animatable:false
phase type:#integer ui:spn_phase default:0.0
)
rollout params "Parameters"
(
group "Noise:"
(
spinner spn_seed "Seed:" type:#integer range:[0,1E8,0]
spinner spn_scale "Scale:" type:#float range:[0.00001,1E6,0] scale:0.01
checkbox chk_fractal "Fractal " align:#right
spinner spn_roughness "Roughness:" type:#float range:[0.0, 1.0,0.0] scale:0.005
spinner spn_iterations "Iterations:" type:#float range:[1.0,10.0,1.0] scale:0.01
)
group "Strength:"
(
spinner spn_strengthX "X:" type:#float range:[-1E6,1E6,0] scale:0.01 align:#center
spinner spn_strengthY "Y:" type:#float range:[-1E6,1E6,0] scale:0.01 align:#center
spinner spn_strengthZ "Z:" type:#float range:[-1E6,1E6,0] scale:0.01 align:#center
)
group "Animation:"
(
checkbox chk_animate "Animate Noise" align:#center
spinner spn_freq "Frequency:" type:#float range:[ 0,1E6,0] scale:0.01
spinner spn_phase "Phase:" type:#integer range:[-1E9,1E9,0]
)
)
on map i p do
(
sp = p * (1.0/scale)
t = seed
if animated do t += phase * frequency * 0.2
if fractal then
(
p.x += (fractalNoise [sp.y, sp.z, t] (1-roughness) 2.0 iterations) * strengthX
p.y += (fractalNoise [sp.x, sp.z, t] (1-roughness) 2.0 iterations) * strengthY
p.z += (fractalNoise [sp.x, sp.y, t] (1-roughness) 2.0 iterations) * strengthZ
)else(
p.x += (noise3 [sp.y, sp.z, t]) * strengthX
p.y += (noise3 [sp.x, sp.z, t]) * strengthY
p.z += (noise3 [sp.x, sp.y, t]) * strengthZ
)
p
)
)