Skip to content

Instantly share code, notes, and snippets.

@JokerMartini
Created August 20, 2015 16:37
Show Gist options
  • Save JokerMartini/be3fd270dd932eadac74 to your computer and use it in GitHub Desktop.
Save JokerMartini/be3fd270dd932eadac74 to your computer and use it in GitHub Desktop.
Maxscript: This demonstrates how to apply a noise distortion to mathematical values.
try(destroyDialog rlTest)catch()
rollout rlTest "test"
(
spinner uiWidth "Width" range:[-1e6,1e6,300.0] type:#worldUnits
spinner uiHeight "Height" range:[-1e6,1e6,50.0] type:#worldUnits
spinner uiSamples "Samples" range:[1,1e4,100] type:#integer
group "Noise"
(
spinner uiNoiseFrequency "Frequency" range:[0,1e9,.1] type:#float scale:0.01
spinner uiNoisePhase "Phase" range:[-1e9,1e9,1.0] type:#float scale:0.1
spinner uiNoiseScale "Scale" range:[0,1e9,1.0] type:#float scale:0.01
)
fn BuildSample =
(
numSteps = uiSamples.value
height = uiHeight.value
width = uiWidth.value
noiseFrequency = uiNoiseFrequency.value
noisePhase = uiNoisePhase.value
noiseScale = uiNoiseScale.value
delete objects
for i = 0 to numSteps do
(
--f = i/(numSteps-1)
x = width * i / numsteps
z = height * i / numSteps
-- add noise
n = (noise3 ([i*noiseFrequency, 0 , noisePhase])) * 10 * noiseScale
pos = [x,0,z+n]
point pos:pos size:1 cross:true box:true wirecolor:red
)
completeRedraw()
)
on uiWidth changed val do BuildSample()
on uiHeight changed val do BuildSample()
on uiSamples changed val do BuildSample()
on uiNoiseFrequency changed val do BuildSample()
on uiNoisePhase changed val do BuildSample()
on uiNoiseScale changed val do BuildSample()
)
createdialog rlTest
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment