# How to calculate elongated reflection along the perpendicalar axis of a plane

I'm adding a rain effect in my pipeline in forward mode. I'm rendering a reflection map used to mirror the scene on a "wet" ground.

I have raindrops rendered as circles with an animated normalmap and use this to distord the reflection map in xz direction based on a global directional light. Quite simple and easy.

Now I want to add an elongation distortion as we usually see for instance with car lights. I don't know where to start for this calculation. I have a couple of ideas in mind.

One is to use the alpha channel of the reflection map to store some deepness information on the rendered pixel. This is possible because I have a fading effect of the reflection that disappears for distance to the mirror plane > 64. So a 8 bits channel would be sufficient to store this relative distance. Then the deepness information could be compared to the current ground height and used to resample the map at another y location. But two texture reads.

The other idea is to initially elongate the objects when they are rendered to the reflection map. So we need here some scale matrix but in a way that it scales with the mirror plane height as the reference elongation, I mean elongation is not in the [-y, h,+y] but in the [h,+y] range, where h is the distance of the object position relative to the mirror plane. (I hope its clear). The position of the object can be volume centered or volume.min.y relative (for my skinned characters).

A third solution is to use the reflect function to deviate the pixel offset but I did not see how to proceed in forward mode.

Alternatively other probably more general solutions are welcome.

PSTMat = P*XMMatrixScaling(1, R, 1)*XMMatrixTranslation(0, H*(1 - R), 0);

for objects O GlobalMat = WorldMat*PSTMat*ViewProj;