# Diffraction of a wave passing through double slits

I am trying to create an animation of a wave propagating and passing through a double slit to undergo diffraction. The effect is something similar to the image attached:

I have played with the wave modifier and dynamic paint (canvas for wave plane and brush for slit), but the wave will just propagate through the slit with no observable effect:

I would appreciate any hints into how to achieve this effect.

Quality is butchered by gif format

# You will need 3 Dynamic Paint objects

## Canvas

Highly subdivided Plane with this settings:

Most important thing here is to set Timescale to 0.10 and Speed to 5. I don't know why but this way whole simulation is more stable.

## Collision object

This is just a Brush with Waves > Type > Reflect Only

## Wave generator

Animated Cylinder Brush with Waves > Type > Depth Change. Also you can crank up Factor and Clamp Waves. Seems like these options are producing smoother result.

## Blend file

Here is file with used material and everything else:

The question is tagged 'dynamic paint' and there is already a very good answer about that by cgslav.

This solution uses a shader node tree.

Slits are located by two empties. One is moving to vary the effect (but this is not mandatory of course) and value node is keyed with frame number in order to produce the wave effect.

The overall node setting is the following:

On top, 3 parameters which correspond to:

• A keyed value which is equal to the current frame
• Wave speed
• Wave frequency

On left, coordinates inputs, and from top to bottom:

• Empty1 coordinates
• Empty2 coordinates

Empties coordinates are added to the shaded object coordinates as this will reflect the empties locations.

If we don't want empties, 'vector' input from the 'sine' node groups can be used to locate the slits directly.

The two 'sine' result are then added and recentered to [0, 1] (they could be between [-2, 2] so we multiply by 0.25 and shift by 0.5.

The 'sine' node group:

It calculates the delta between the two vectors so that we can have it length (dot + sqrt).

Multiply frame by speed and add it to the length and multiply this result by the frequency.

Finally it takes the sinus (or cosinus) of it.