Extruding the image on a layer down the sides of an extrusion
I have dozens of layers that each have hundreds of small shapes on them, each with various colors or patterns. I need to extrude these layers in 3D. But I need the colors around the edges of the shapes to be the color that goes down the extruded sides. Is there any way to do this? I can not edit the texture for each shape. There are hundreds of shapes on each layer, all different sizes and colors. This needs to be some automated thing. Basically I want the row of pixels that is around the edge of the shape to be continued down the sides of the shape when it is extruded.
(I'm using Photoshop CC v 20.0.2)
Here's a simplified example of what I want.

