Hidden Photoshop Script EASILY Generates Random Fills!

237K views 10.5K likes 375 comments

Jump to a step in the video (8)

Click a time to play the video from there.

  1. 0:00 Introduction
  2. 0:28 Remove Background Using Adobe Sensei
  3. 0:59 Fixing Mask Imperfections with the Brush Tool
  4. 1:16 Refine Mask Edges with Select and Mask
  5. 1:35 Convert the Dollar Bill Into a Pattern
  6. 2:06 Generate the Fill with the Random Pattern Fill Script
  7. 3:28 Power Tip for More Realistic Results!
  8. 5:11 Final Thoughts
Show Shortcuts for
Text size
Appearance

Your choices stick across every tutorial on this device.

Random Fill in Photoshop uses a hidden script inside the Fill dialog to scatter copies of a custom pattern across a layer, each one randomly scaled, rotated, and colored.

Sometimes Photoshop’s pattern presets do not fit your photo composite, but we have a solution for you!

In this tutorial, you will discover this hidden Photoshop script that will allow you to generate a random fill from a pattern and create your own.

Key Takeaways

  • A hidden script in the Fill dialog called Random Fill scatters copies of a pattern instead of tiling them in a fixed grid.
  • You have to Define Pattern from your own layer first. Random Fill only scatters a pattern preset that already exists.
  • Color randomness and Brightness randomness are separate sliders. Set color randomness to 0 to keep every copy the same color while brightness still varies.
  • The Rotate Pattern option is what makes the scatter look natural. Without it, every copy lands at the same angle.
  • Running Random Fill a second time on a new layer, with a lower density and a smaller scale, adds depth instead of just piling on more copies.
  • Copying a Drop Shadow layer style onto a new layer needs Alt (Windows) or Option (macOS) held while you drag the fx icon. Dragging it without that key moves the effect instead of copying it.

What You Will Learn

  • How to remove a background with Select Subject and clean up the mask with the Select and Mask workspace.
  • How to turn any layer into a custom pattern with Define Pattern.
  • How to scatter that pattern randomly with the Random Fill script in the Fill dialog.
  • How to control the scale, rotation, color, and density of the scatter.
  • How to stack a second randomized layer and a Drop Shadow to add depth.

Requirements

Before you start

Random Fill in Photoshop Keyboard Shortcuts

ActionWindowsmacOS
Open the Fill dialog boxShift BackspaceShift Delete
Draw a straight line with the Brush Tool (click, then Shift-click again)ShiftShift
Copy a layer style to another layer (drag the fx icon)AltOption

Tutorial Image

To follow along the tutorial, download the image here.

Remove Background Using Select Subject

Start by extracting the Dollar bill from its background. Photoshop’s built-in artificial intelligence (AI) makes creating a selection more straightforward. 

To do that, choose Select > Subject.

If the AI misses out a part of the object you want to select, you may use the Quick Selection tool to add to the selection. You may also use it to subtract from the selection.

Dollar bill picked up by Select Subject and cleaned up with the Quick Selection tool

With the selection active, click on the layer mask icon to create a layer mask based on the selection.

If need be, you can use the Brush Tool and paint on the mask with black (#000000) to hide pixels or paint with white (#ffffff) to reveal. You may also use the Select and Mask Workspace to refine the mask edges.

Convert the Dollar Bill Into a Pattern

Select the Rectangular Marquee tool from the Toolbar.

Then, make a selection a little larger than the dollar bill. 

Rectangular Marquee selection drawn slightly larger than the dollar bill

Select the Layer thumbnail, not the Layer Mask thumbnail.

Layer thumbnail highlighted in the Layers panel rather than the mask thumbnail

Choose Edit > Define Pattern. Name for your new pattern preset.  

Define Pattern dialog where the new dollar bill preset gets its name

Create a New Layer and disable the original layer. 

New empty layer added while the original dollar bill layer is switched off

Generate the Fill with the Random Pattern Fill Script

Bring up the Fill dialog box by pressing ShiftBackspace (Windows) or ShiftDelete (macOS).

On the Fill dialog box,  set the Contents to Pattern.

Fill dialog box with the Contents menu set to Pattern

As the Options appear, set the Custom Pattern to the Dollar Bill pattern preset you just created, which you may also find at the very bottom of the list. 

Check the box for Script and on the drop-down menu beside it, select Random Fill. 

Choosing Random Fill in Photoshop from the Script drop-down in the Fill dialog

Then, press OK.

The previous step brings out the Random Fill dialog box with several options available.

Start with Color randomness and Brightness randomness.

Random Fill dialog showing the Color randomness and Brightness randomness options

The Color randomness determines the variety of colors that will apply in the pattern. Meanwhile, the Brightness randomness applies a different range of brightness among the patterns.

If you want to set the pattern with the same color, then adjust the Color randomness to 0.

Color randomness dropped to 0 so every bill keeps the same color

You can also set the Brightness randomness to 0.2 for a slight difference in brightness.

Brightness randomness set to 0.2 for a slight variation between the bills

Then, check the box for Rotate pattern, so the pattern rotates randomly.

Rotate pattern checked so each copy of the bill lands at a random angle

Increase the Density to its maximum at 10 pixels. 

Density pushed to its maximum of 10 pixels to pack the fill tightly

By setting the Minimum scale factor and the Maximum scale factor to 1 the resulting generated dollar bills will be the same size as the original.

Minimum and maximum scale factors both at 1 to keep the bills at original size

Then, press OK.

Upon exiting, you’ll see how your working document is now filled with the Dollar bill pattern!

Power Tip for More Realistic Results!

Start by creating a New Layer.

Once again, bring out the Fill dialog box by pressing ShiftBackspace (Windows) or ShiftDelete (macOS).

Fill dialog reopened on a fresh layer for the second pass of bills

Then, press OK.

The Random Fill window will remember the previous settings.

Start by setting the Minimum scale factor and the Maximum scale factor to .25 as this sets the Dollar bill to 25% of the original size. 

Scale factors set to .25 so the bills come in at a quarter of their size

Also, set the Density to 9 pixels, to leave gaps in the fill. 

Density lowered to 9 pixels so gaps open up in the fill

Then, press OK.

NOTE: If you can’t see the transparency checkerboard, you might need to disable the previous layers to see its full effect.

Double-click on the New Layer’s side to bring out the Layer Style window and click on the Drop Shadow style.

Layer Style window open with the Drop Shadow style selected

You can edit the Structure and the Quality of the Drop Shadow style to achieve realism according to your preference. But it’s also good enough to use the default settings. Then, press OK to see it in effect. 

Create another New Layer and repeat the process of bringing up the Fill window by pressing ShiftBackspace (Windows) or ShiftDelete (macOS), and press OK.

When the Random Fill window pops up, it will remember the previous settings you applied and press OK. This will apply a new random fill layer of the dollar bill pattern, which helps create depth. 

Another random fill layer of bills stacked on top to build up depth

To apply the same Layer Style with the Drop Shadow in the previous layer, hold Alt (Windows) or Option (macOS) and click-and-drag the fx icon over to the New Layer. Drop it there.

Dragging the fx icon onto the new layer to copy the drop shadow over

And here’s the final result when you keep repeating the process. Once you have a realistic bed of Dollar bills, use it for a photo composite or a poster project!

Random Fill in Photoshop scattering dollar bills across the canvas

Frequently Asked Questions

What is Random Fill in Photoshop?

Random Fill in Photoshop is a script inside the Fill dialog that scatters copies of a pattern across a layer. Each copy gets its own random scale, rotation, color, and spacing, so the result does not look like a repeating tile.

Where do I find the Random Fill script?

Open the Fill dialog and set Contents to Pattern. Check the Script box, then choose Random Fill from the dropdown next to it.

Do I need to create a pattern first?

Yes. Select the area you want to repeat with the Rectangular Marquee tool, then choose Edit > Define Pattern. Random Fill can only scatter a pattern that already exists as a preset.

What is the difference between Color randomness and Brightness randomness?

Color randomness shifts the hue of each copy. Brightness randomness only varies how light or dark each copy looks. Set Color randomness to 0 to keep every copy the same color.

Why does my Random Fill result look flat?

Every copy lands at the same angle unless you check Rotate Pattern. Running Random Fill a second time on a new layer, with a lower Density and a smaller scale, also adds depth.

How do I copy a Drop Shadow to another layer without moving it?

Hold Alt (Windows) or Option (macOS) while you drag the fx icon from one layer onto another. Dragging without that key moves the effect instead of copying it.

Can I use this technique to edit real currency?

No. The dollar bill in this tutorial is a low-resolution, JPEG-compressed stock photo, which is why its serial number is not readable. Do not use this technique on a real, legible bill.

Conclusion

Random Fill in Photoshop turns one pattern into a natural-looking scatter of copies, each with its own random scale, rotation, color, and spacing.

Stack a second, sparser layer and copy the Drop Shadow with Alt (Windows) or Option (macOS) held for a result with real depth.

Comment on the video with any question.

Pro Training

Selections and Masking Mastery

Complete course includes 2.5 hours of step-by-step lessons, 6 structured modules, downloadable practice files, and custom Photoshop brushes. Everything you need to master selections and masks in one place.

View the Course

Keep going

This scatter technique is just the raw material. Next, make the rest of your composite look just as realistic.

Final Image

Drag the slider to see before and after

After: Hidden Photoshop Script EASILY Generates Random Fills!
Before: Hidden Photoshop Script EASILY Generates Random Fills!
Jesús Ramirez

About the author

Jesús Ramirez

Jesús Ramirez is a graphic designer and the founder of the Photoshop Training Channel, which he started in 2012 and has grown past two million YouTube subscribers. He has taught at Adobe MAX, Adobe Summit, and Photoshop World, teaches courses for CreativeLive and Pluralsight, and was one of five artists chosen for Adobe Stock's Make a Masterpiece campaign. His Photoshop templates shipped inside Photoshop CC 2018.

More about Jesús Ramirez

Similar Posts