# Correct way to render crepuscular rays in cycles?

While trying to use the new cycles volumetric rending features to create crepuscular rays (with the intention of updating my answer here), I have found this to be a little trickier than I anticipated.

When I create a basic setup with a spot lamp (sun lamps don't seem to work, not sure if that is a result of their one directional nature or what..) and a world material like this:

Which gives me this (500 samples):

The problems with this that make me think that I'm missing something (aside from the rendertime and noise, which I understand to be a part of using bleeding edge new features) are:

• The background shader/sky texture isn't visible at all (volume is too dense?)

• The lamp needed to be set to 50000 strength (this is of course dependent on the distance from the camera, but the kinds of strengths required to get some nice defined rays will blow everything out if volumes are disabled)

I can't seem to get a straight render (no compositing tricks) to look anything remotely like the pretty image in the release notes:

(source: blender.org)

Is this just how it works?
Or is there some trick I have missed (not counting compositing/renderlayer tricks)?

This is really a tricky one.

First off, world surface shader and sun lamps dont work for world volume shading for now (as stated in the manual). Also, if you use object volumes the camera can not be inside the volume. But you can make a cube bubble around the camera and parent it to the camera. E.g use a "Boolean Modifier" with the bubble (intersect) to cut it off. Of course this only works when your bubble sticks out of the volume but you can extrude it in any direction that doesnt point forward anyway.

Here is an example of the node setup for a volume: volume scatter shader and volume absorbtion shader as input to an add shader. Thats it.

For the sun lamp use simple emission with strength of e.g. 9 to get deeper shading for the rays. Also helpful is to set the sampling size for the shadow to 0 to get crisp lines. Background can be set to a Sky Texture.

To keep render settings simple volume scattering events can be set to 0. For the Volume Sampling it might be necessary to tweak the Max Steps (e.g. 2048) and Step Size (e.g. 0.04).

This is what it would look like:

To get more crepuscular rays (like in the image you provided) you could add some shadow shapes between the sun and the volume (acting as clouds). Of course this example looks horrible but you get the idea.

• From version 2.73 on, it is no longer necessary to have the camera be outside of the volume. Also, Volume Scatter and Volume Absortion can now be used as shaders for the Volume node in the World Output. – user1853 May 3 '15 at 5:48