Sunrays
need clouds to shadow the sun and divide the sky into contrasting
columns of shaded and sunlit air.

The sun's rays reaching planet Earth are all parallel*
and the cloud shadowed regions are parallel too. They are tangible
things, immense columnar volumes, dark, bereft of sunlight.

When the sun is still above the horizon the shadows and rays must
always slant downwards but sometimes they appear instead to shoot
upwards from clouds. This is purely a perspective effect.

Shadow
volumes are real three dimensional objects and they are always seen
in perspective. Take the shadow from cloud "a".
It reaches the ground between the sun and the eye. The shadow is
seen below the cloud. The shadow nearest the ground is closer and
so appears wider. In contrast, shadows from clouds "b"
and "c" slant downwards at exactly the same angle
but reach the ground past the eye. To the eye they appear to radiate
upwards from the cloud and would, if they were still visible, pass
high overhead.

Next time you see sunrays, imagine them for what they really are,
miles long columns of sparkling sunlit air highlighted by the darkness
of adjacent unlit voids. Let the mind fly around and through them
to give them solid form that replaces the flattish way we normally
see the sky.

Rays and shadows are most visible near to the sun. There the shadows
are darkest because the eye is looking along their length. Elsewhere
the path lengths across the shadows are much shorter. There is a
second reason, larger dust particles scatter
sunlight sharply forward and so the air shines brighter
near the sun.
Another direction where the eye looks along the shadows is in the
opposite direction to the sun. There the shadows again darken and
the contrast with the sunlit sky increases. Rays converging towards
the antisolar point are called anti-crepuscular.

*The shadows are not quite parallel
because, although the sun is ~93 million miles away, it is so large
that its globe appears 0.5º across. Rays consequently spread
up to 0.25º each side of the mean direction. This causes the
'umbral' or absolutely unlit parts of cloud shadows to narrow slightly
with increasing distance from the cloud.