Skip to main content
Known Participant
November 2, 2020
Question

Is it possible to create a perlin noise in Photoshop? [Edited by moderator for clarity]

  • November 2, 2020
  • 3 replies
  • 9834 views

Hello,

First question, is it possible in Photoshop to create a perlin noise with a script with slider controls?  Please be advised that I am not asking for the clouds effect.

 

According to the code provided below, the script has to be executed through ES toolkit but I am not getting any results:

 

 

#target estoolkit
var win, windowResource;
 
windowResource = "palette {  \
    orientation: 'column', \
    alignChildren: ['fill', 'top'],  \
    preferredSize:[300, 130], \
    text: 'ScriptUI Window - palette',  \
    margins:15, \
    \
    sliderPanel: Panel { \
        orientation: 'row', \
        alignChildren: 'right', \
        margins:15, \
        text: ' PANEL ', \
        st: StaticText { text: 'Value:' }, \
        sl: Slider { minvalue: 1, maxvalue: 100, value: 30, size:[220,20] }, \
        te: EditText { text: '30', characters: 5, justify: 'left'} \
        } \
    \
    bottomGroup: Group{ \
        cd: Checkbox { text:'Checkbox value', value: true }, \
        cancelButton: Button { text: 'Cancel', properties:{name:'cancel'}, size: [120,24], alignment:['right', 'center'] }, \
        applyButton: Button { text: 'Apply', properties:{name:'ok'}, size: [120,24], alignment:['right', 'center'] }, \
    }\
}"
 
win = new Window(windowResource);
 
win.bottomGroup.cancelButton.onClick = function() {
  return win.close();
};
win.bottomGroup.applyButton.onClick = function() {
  return win.close();
};
 
win.show();

// Set Adobe Photoshop to use pixels and display no dialogs.
app.preferences.rulerUnits = Units.PIXELS;
app.displayDialogs = DialogModes.NO;

var doc = app.activeDocument;

// Get the document dimensions.
var documentWidthAsInteger = app.activeDocument.width.value ; 
var documentHeightAsInteger = app.activeDocument.height.value ;

var perm = new Array(512);
var gradP = new Array(512);

//6t^5-15t^4-10t^3
function fade(t) {
    return t*t*t*(t*(t*6-15)+10);
}

//interpolate between two values
function lerp(a, b, t) {
    return (1-t)*a + t*b;
}

dot2 = function(x, y) {
    return this.x*x + this.y*y;
  };

//generate perlin noise
function perlin(x, y) {
	var X = Math.floor(x);
    var Y = Math.floor(y);

    x = x - X;
    y = y - Y;

    X = X & 255;
    Y = Y & 255;

    var n00 = gradP[X+perm[y]].dot2(x,y);
    var n01 = gradP[X+perm[y+1]].dot2(x,y-1);
    var n10 = gradP[X+1+perm[y]].dot2(x-1,y);
    var n11 = gradP[X+1+perm[y+1]].dot2(x-1,y-1);

    var u = fade(x);

    return lerp(
        lerp(n00, n10, u),
        lerp(n01, n11, u),
        fade(y));
}

function generateNoise() {
    for (var x=0; x<documentWidthAsInteger; x++) {
        for (var y = 0; y < documentHeightAsInteger.length; y++) {
            var value = Math.abs(perlin(x/100, y/100));
            value *= 256;
        };
    }
}

 

Can someone provide me with an answer on how to create a perlin noise with a random seed slider according to the example above as a second question only if first applies?

 

Thank you

This topic has been closed for replies.

3 replies

Trevor.Dennis
Community Expert
Community Expert
November 3, 2020

If anything could do it with a ready made plugin, then Filter Forge would be my best guess.  Are you just trying to produce random monochome fractal noise or specifically a landscape effect?

Makary84Author
Known Participant
November 3, 2020

In my last question I should have asked is it possible to generate a perlin noise with a script in Photoshop. I am just trying to figure out how to create a perlin noise generator script if possible, as the generation process of the script in my original question is good, but the implementation in Photoshop is somehow unfinished, and besides everything there is a lack of documentation to Photoshop scripting. I would need help on that matter if possible.

 

Thank you.

Stephen Marsh
Community Expert
Community Expert
November 2, 2020

The script appears to be a work in progress:

 

 

I presume that the slider offers more control of "scale" or another attribute than Filter > Render > Clouds or Difference Clouds?

 

Google turned up this script, which appears to be the source:

 

https://github.com/aidan-bauer/Photoshop-Perlin-Noise

 

https://feedback.photoshop.com/conversations/photoshop/photoshop-improve-fractal-noise-filters-render-clouds-procedural-noise/5f5f44ef4b561a3d422a30e9

 

Makary84Author
Known Participant
November 2, 2020

Yes you are correct about the source, but is it possible generate a perlin noise out of zero in Photoshop?

Makary84Author
Known Participant
November 2, 2020

My deep excuses about the subject as I didn't realize it was already filled partially. The question has to be "Is it possible to create perlin noise in Photoshop". I kindly ask moderators to change the subject for me to the provided because I don't know how to edit my question. Thank you and my appologies