9
$\begingroup$

How do I achieve this cool sun particle glow effect?enter image description here

These little circles below:

enter image description here

I need the answer in blender cycles.

$\endgroup$
13
$\begingroup$

The particle glow is caused by specks of dust in the air catching the sun causing bright spots and the depth of field of the camera causing them to be blurred based on the distance from the camera. There are (at least) 3 ways of achieving such an effect with varying advantages and disadvantages :

1) Depth of Field

Position bright particles between the camera and the subject and set the Camera Depth of Field to a suitable value to produce the blurring. The advantage of this method is that it will be physically accurate, but it will require a very large number of Render Samples to get an effective result. This would be fine if you are producing a single still image but not so good if you are planning on animating.

Depth of Field Render Samples DoF final result

2) Compositing

Render a separate layer to contain the bright particles of light. Apply a 'Blur' filter and overlay the result over your image. This is much faster than using the Depth of Field but is less physically accurate and does require the additional stage of the compositor. It's also tricky to get the blurring due to distance from the camera working effectively.

3) Fake the blurred particles within Cycles using materials to simulate blurring

This is less physically accurate than the Camera Depth of Field method but much faster as it does not require additional Render Samples - and does not require any additional compositing step. This makes it fast to render and easy to configure for the desired effect since the results of any changes can be viewed immediately.

However, there are some obstacles in the way of achieving this which need to be overcome :

  1. We need to be able to determine the distance between the camera and each particle.
  2. Cycles doesn't support the 'Billboard' method of particle rendering - this means that we can't simply render planes or circles in the scene as they won't be guaranteed to be parallel to the camera or reflective surface.
  3. We need to be able to control the size of each 'blur' dependent on the distance from the camera. There is not currently a method of controlling the Particle Size dynamically without resorting to Python scripts (as far as I'm aware, anyway).

The first problem is actually quite easy to solve with the Particle Info node and some relatively simple Vector Maths. The other two problems can be solved by using large smoothed Spheres for the particles (since they're the same regardless of orientation) and some Vector Maths to affect which parts of the mesh emit light.

Add a new mesh to the scene to generate the particles from within its volume. This should be sized and positioned where you want to generate the particles - ie, between the camera and the subject. Set the Object Maximum Draw Type to 'Wire' so that the object doesn't obscure the rest of the scene in the 3D view.

maximum draw type

Add a UV Sphere to the scene and set it to Smooth shading. To reduce the number of Faces in the scene you could reduce the Segments and/or Rings - but not too far as the shading needs to be uniform to avoid artifacts in the blurs. I found 16 Segments and 16 Rings works quite well. Move the UV Sphere out of view of the camera (or on to a different layer).

Add a particle system and configure it to mimic floating particles (eg, set the End to '1', set Lifetime to the length of your Scene, set Field Weight of Gravity to 0, add Brownian Motion, Turbulance, Wind, etc.). Set the 'Emit From' to 'Volume' so that the particles are emitted throughout the mesh. Set 'Render' mode to 'Object' and select the UV Sphere. Adjust the Size of the particles until they are shown in the camera view at the maximum size of the desired blurs.

large particles

As the rays could pass through many transparent surfaces due to multiple overlapping particles, you should significantly increase the Max Transparent Bounce Light Path settings.

Max Bounce

Select the Sphere and add a material with a Transparant Shader in place of the default Diffuse. Adding in an Emission shader will produce a solid circle of light for each particle. By adding a Geometry node and combining the Normal with the Incoming ray we can control how far from the centre the circle extends and so vary the size of each circle. By varying this based on the distance from the camera and similarly varying the Strength of the Emission we can generate quite an effective blurred particle effect.

For the distance we can use the following node tree :

distance nodes

This calculates the vector between the Camera and the Particle by subtracting one Position from the other, and feeds the result into a Dot Product node along with its own Normal and this produces the scalar distance between the two.

NOTE : The Camera position is stored in a Combine XYZ node - this can either be set 'by hand' (by copying and pasting the X,Y,Z coordinates from the Camera's properties into the node) or by adding a Driver to do this automaticallty. If the Camera position will move in your scene then you'll need to use the driver method - otherwise simply paste the values into the node.

Using some additional Maths nodes we can combine the Distance with Input values for the Focal Length and Depth of Field of the camera to produce an output that varies between 0 and 1 based on the distance - with 0 representing a particle at the Focal Length and increasing towards 1 at the bounds of the Depth of Focus.

Further Maths nodes can similarly be used to vary the 'brightness' of the emission so it gets dimmer when more spread out to mimic blurred points of light.

To control the size of the emission, use the Dot Product to combine the Normal of the Incoming ray with the Normal at the surface of the Sphere. The result will vary between 1 in the centre and decrease to 0 at the edges and this can be used to control the size of the circle. To simplify the Maths nodes and so that the circle would be uniform in colour, I used a Colour Ramp with one point set to Black at 0.000 and another at White at 0.01 - so any value from -infinity to 0.01 will be dark and anything above will be light. This is then used to vary the size of the circle based on the result from the distance calculation. Multiplying the Strength by the 'brightness' gives us the final blurring effect.

Single particle blurring

Including all particles and a background image produces the following :

full material

Example final render

Note : The effect in the above image is purposefully very subtle. The brightness of the spots can be adjusted by changing the Colour of the Emission shader as desired as well as the Particle Size, and material Focal Length and Depth of Field values.

Blend file can be downloaded here

$\endgroup$
  • 1
    $\begingroup$ Nice tips for fake bokeh dust. $\endgroup$ – 3pointedit Nov 11 '16 at 14:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.