Physically Accurate Lens Dirt
Lens dirt that only shows up where the light is
- image
- dirt_texture
- bokeh_texture
- IMAGE
Most "lens dirt" filters just paste a grime texture over your whole image at some opacity. That's not what a dirty lens actually looks like - grime on the front element shows up when light scatters through it, which means it appears in the bright parts: window light, neon, specular highlights, bokeh. That's the idea behind Physically Accurate Lens Dirt from TrophiHunter's Photography Nodes pack, and it's why the word "accurate" is in the name. If you want that cinematic, slightly grungy, light-flaring look on a portrait or a moody still, this is the node that does it the honest way.
How it works
The pipeline is three steps, all in real math. First it builds a highlight mask from the image's luma - everything above a threshold value becomes the "this is where light scatters" map. Then it convolves that mask with your bokeh texture using an FFT, which is how the bright areas bloom into soft aperture-shaped blobs the way a real lens would. Finally it multiplies that bokeh glow by your dirt texture and adds it back into the image scaled by intensity. Dirt only appears where there's light, and it inherits the color and shape of your bokeh. The FFT approach also means it scales to full-res images without the cost of a giant convolution kernel.
Inputs that matter - and the one that trips everyone up
image- your IMAGE.dirt_textureandbokeh_texture- both required IMAGE inputs. This is the gotcha: nothing ships with the pack. You have to load your own. Grab any speckle/grime/dust PNG for the dirt, and any soft glow or bokeh image for the bokeh. Reshade texture packs work well - the author explicitly notes that if you use a reshade texture you may not need to blur it, and should setdirt_scaleto 1.intensity- 0 to 4, default 0.5. How strongly the dirt blends in.threshold- 0 to 1, default 0.8. The "max white point": dirt appears above this brightness. Lower it to let dirt show in dimmer scenes.dof_kernel_size- 1 to 256, default 8. Blurs the dirt texture with an aperture-shaped kernel (simulating out-of-focus dirt). If your spots look sharp and digital, raise it.dirt_scale- 1 to 16, default 2. How large the dirt spots are. If they're too small, scale up; reshade textures, set to 1.
Output is a single IMAGE. Wire it into your Save or Preview.
Installing it
Part of the Photography Nodes pack:
cd ComfyUI/custom_nodes
git clone https://github.com/TrophiHunter/ComfyUI_Photography_Nodes
# restart, then find it under TrophiHunter/Photography
Or ComfyUI Manager → search "Photography Nodes" by TrophiHunter. No model files, no requirements.txt - just torch/torchvision, already installed.
Troubleshooting
"Nothing changed" almost always means one of two things: your image has no bright regions above threshold, or your dirt texture is essentially black. Lower the threshold, raise intensity, or swap in a lighter texture. If the dirt looks like hard digital spots, raise dof_kernel_size - that blur is the whole game. And remember it's light-dependent, so it's wasted on flat, evenly-lit scenes; point it at images with actual highlights and it earns the "physically accurate."
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| dirt_texture | IMAGE | — | |
| bokeh_texture | IMAGE | — | |
| intensity | FLOAT | 0.5000–4 | — |
| threshold | FLOAT | 0.8000–1 | — |
| dof_kernel_size | INT | 81–256 | — |
| dirt_scale | INT | 21–16 | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |