Realistic Spotlights for Blender & Cycles

Software:
Blender 2.79 | Cycles Renderer

There’s currently no built-in support for IES light sources in Blender & Cycles.
We already know that Blender 2.8 will have the feature built into it (which is great news!), and there’s an addon that provides the functionality, but I wasn’t satisfied with it’s workflow, not being integrated well into Cycles.
So I decided to develop a custom Cycles shader (node group) that will provide realistic IES like spotlights in a convenient customizable way.

The Shader I developed is called CG-Lion Spotlight Presets Pack 1.0 and is available for purchase on Blender Market.
It doesn’t load external IES files, but instead has a pre-configured library of 20 spotlights shapes, and also provides features that are not available in IES lighting like tweaking the spotlight beam focus, adding a chromatic dolor dispersion effect, and producing a correctly bright surface at the light source.

CGL_Spotlight_Presets_Pack_1.0_Previews.jpg


Related:

Customizable Photo-realistic Car-paint shader for Cycles
Complex Fresnel texture for Cycles
Optimized Architectural Glazing Shader for Cycles
Procedural Wood Shader for Cycles

Cycles – Nested Refractive Volumes

Software:
Blender 2.79 | Cycles Renderer

When it comes to rendering nested refractive volumes, like a glass containing a beverage, the way to set it up in Cycles is common to many modern ray-tracers.
The touching bodies of refractive material like glass and liquid must overlap each other slightly so that rays being traced “meet” the right surface without having surfaces touching and causing “Z fighting” artifacts.

Transparencies_Air_Bubbles-01

When the render includes volumetric shading, like Volume Absorption (sometimes referred to as “fog”), the meshes must be set-up in a certain way for Cycles to interpret the volumes properly.

Intersecting volumes like a beverage glass and liquid must be separate objects to be rendered correctly. When joined into one mesh the renderer doesn’t treat the different volumes separately even though they have different shaders.
And the result is that the volume (depth) of the inner volume is calculated as just the depth on the intersection (the overlap) of the volumes.
In this example the wine can’t be rendered correctly when the glass and liquid meshes are joined.
The wine liquid doesn’t get it’s deep color because the renderer “thinks” it’s very thin.

Untitled-1.jpg

When the meshes are separated the renderer interprets the wines volume correctly and the Volume Absorption shader produces the right color:

Untitled-2

Setting up cavities within a volume like air bubbles, is similar to many other modern ray-tracers. You just have to create inner meshes that have flipped normals facing inwards, so air bubbles within the wine don’t need to have “air” material, they have the same wine shader, but have their faces flipped.

Note that in this case, it’s the other way around from the previous example.
If the bubble meshes are separate from the liquid mesh the renderer doesn’t interpret them as holes in the liquid volume, and produces an incorrect result:

Untitled-3

When the bubble meshes are joined to the liquid mesh, the volume is interpreted correctly:

Untitled-4.jpg

In short:
For these refractive volumetric effects to be rendered correctly in Cycles,
Surfaces of the same material volume must be joined to one mesh, and separated from meshes belonging to different material volumes.
* This may sound trivial, but it’s not. there are rendering systems in which only the surface shader determines volume interpretation and that has advantages like the convenience to aninate bubbles as separate objects from the liquid itself or the ability to join a glass bottle with the liquid into one mesh model.

 

Related:
> Understanding Transparency Render Settings

Cycles Tangent node & Anisotropic reflection

Software:
Blender 2.82

The Cycles Tangent node defines a Tangent-Space for a mesh by either using one of the object’s local axes (see image A) or by using an available UV layout.
This can be useful when designing an Anisotropic reflection shader like in the case of brushed, machined or lathed metals.
A grey-scale texture can be connected to the Rotation input of the shader to define changes in the Anisotropic direction on the surface (see image B).

Examples:

A. In this example the Tangent node is set to ‘Radial’ Direction mode, in which a object axis is chosen as the radial axis of the Anisotropic direction:
Annotation 2020-05-07 132452

B. In this example a Noise texture’s Factor output is connected to the Anisotropic shader’s Rotation input to create an irregular Anisotropic (metal brushing finish) direction:

Annotation 2020-05-07 133126

 

Related:

  1. Adding a texture to an Area Light
  2. Using the normal’s blue channel to create top-side effects
  3. Nested transparencies

Basic Toon Shading in Blender & Cycles

Software:
Blender 2.79

  1. Set a Toon BSDF as your model’s material.
  2. Activate the Freestyle option in the Render Settings, and set Line Thickness,
    * More line style settings are found in the Render Layers settings.
    * Freestyle lines are only rendered in the final render (F12) and are not rendered in the Cycles viewport interactive render mode.

Minimal Toon setup:Untitled-2.jpg

A more controllable setup:
2 Toon BSDF’s, one for color shading and one for highlights added together, and a Background shader override to control shaded area darkness:
Untitled-1

Blender – quickly clearing multi-materials

Software:
Blender 2.79

Select one or more objects with multiple materials and another object with just one material as the active object, that will be the Active Object.
In the material list open the v menu and choose ‘Copy Material to Others’
This will copy the material settings to all selected objects.

* Link materials command will not achieve the result, it will still keep unneeded materials on selected objects

Untitled-1.jpg

 

Enable the built in addon: ‘Material Utils Specials’

Untitled-2

This addon will add three extra material operations to the material V menu:

Clean Material Slots:
Deletes unused material from the object

Remove Active Slot:
Same as deleting a material by pressing –

Remove all Slots:
Delete all materials assigned to the object

Untitled-2

Cycles True Displacement (experimental)

Software:
Blender 2.79

These are the steps to activate Cycles Render new experimental MTD feature (Micro Triangle Displacement)

Cycles Render settings:
Set ‘Feature Set’ to Experimental.

MTD_A

Object:
Apply a Subdivision Surface modifier and set it to Adaptive mode.
* Adaptive Mode is only available if the modifier has no other modifiers below it.

Set the ‘Dicing Scale’ attribute in pixels to set the displacement accuracy
* Lower numbers will result in greater details and more memory usage

MTD_B

Material Cycles settings:
Set Displacement to ‘True’ or ‘Both’.
* Setting it to Both will automatically use the same height map texture data to drive surface normals (bump) and create a consistent effect

Displacement set to 'True'
Displacement set to ‘True’

Displacement set to 'Both'
Displacement set to ‘Both’

Cycles material node:
Connect a texture to the Displacement input.

White color will displaced to a height of 0.1 units (10cm) by default, manipulate the texture data using math nodes to achieved desired height and offset.

MTD_D.jpg

Cycles Geometry settings:
For more accuracy reduce the Subdivision pixel rates And increase the maximum subdivisions.

MTD_E.jpg

 

Notes:

  1. There is currently conflict between Adaptive Subdivision and Tangent Space Normal Maps that renders objects completely black.
    A solution that is proposed at various discussions is to simply use Object Space mode in the Normal Map node.
    I’m not sure how good is this workaround for non flat surfaces..
    https://developer.blender.org/T49159
  2. When using a procedural fractal texture as a Displacement map, Shaders that are dependent on surface angle may significantly change their appearance in different rendering resolutions because the texture provides more and more detail for the displacement and that changes the nature of the geometry.
  3. The base mesh for the Displacement should be well Subdivided prior to the adaptive Subdivision in order to avoid polygon edges appearing.