使用 Cycles 的光路径节点控制着色器可见性

498 阅读3分钟

持续创作,加速成长!这是我参与「掘金日新计划 · 10 月更文挑战」的第 7 天,点击查看活动详情

软件:Blender 3.3.0

正文

光路径(Light Path)

Cycles 的 Input > Light Path 节点对于创建具有 选择性光学参与 的着色器非常有用。

The Cycles Input > Light Path node is useful for creating shaders with a selective optical participation.

image.png

一个简单的例子是,通过反射/折射,摄像机 “看到” 了明亮的光材质,但实际上并没有照亮场景。

A simple example of that would be a bright light material that is ‘seen’ by the camera and through reflection / refraction but isn’t actually lighting the scene.

基本 光线可见度 可以通过在对象级别设置:

Basic Ray Visibility can be set at the object level via the object’s Cycles setting:

image.png

但是当我们需要设置每个着色器,及其更具体的 Ray Visibility 时,我们可以在 Cycles 着色器中使用 Light Path 节点来设置它:

But when we need to set per shader, and more specific Ray Visibility, we can set it up using a Light Path node within the cycles shader:

image.png

Is ________ Ray 输出将给出 0/1 值,指示采样的射线 是否属于某种类型

The Is ________ Ray outputs will give a 0 / 1 value indicating if the sampled ray is of a certain type,

Ray Length 输出将给出一个表示射线真实长度的浮点值,

The Ray Length output will give a float value representing the ray’s real world length,

_______ Depth 输出将给出一个整数,表示在采样射线之前计算的 光反弹次数

And the ‘_______ Depth’ outputs will give an integer representing the number of light bounces that were computed until the sampled ray.

在这个简单的例子中,我们将看到如何使用 Light path 节点创建一个 只影响反射/折射但不产生漫射光 的光着色器。

In this simple example we see how to use the Light path node to create a light shader that only affects reflections / refraction but not producing any diffuse light.

Mix Shader 用于混合 Transparent ShaderEmission Shader

A Mix Shader is used to mix between a Transparent Shader and an Emission Shader.

Converter > Math Maximum 节点被用作逻辑 OR 操作符,如果光线类型是 Camera RayGlossy RaySingular Ray,则为 混合因子 生成值 1,并使 Emission Shader 激活。

The ‘Converter > Math’ ‘Maximum’ node is used as a logical ‘OR’ operator to produce a value of 1 for the mix factor if the ray type is either a Camera Ray or a Glossy Ray or a Singular Ray, and cause the Emission shader to be active.

对于其他类型的光线,混合值将为 0,Transparent Shader 将被激活。

For other ray types the mix value will be 0 and the Transparent shader will be active.

  • 基础的 Emission Shader

image.png

  • 被设计限制的 Emission Shader

image.png

注意

在写这篇文章的时候,Is Diffuse Ray 输出的 Light Path 节点没有产生预期的结果,所以无法创建一个(创造漫射照明,但不出现在反射和折射中)的光材质。

At the time of writing this post the ‘Is Diffuse Ray’ output of the ‘Light Path’ node didn’t produce expected results so I couldn’t create a light material that creates diffuse lighting but doesn’t appear in reflections and refractions.

相关 Cycles 文档

射线类型可分为四类:

  • 照相机: 光线直接来自照相机。
  • 反射: 光线是由表面反射产生的。
  • 透射: 光线是通过表面透射而产生的。
  • 阴影: 光线用于(透明的)阴影。

Ray types can be divided into four categories:

  • Camera: the ray comes straight from the camera.
  • Reflection: the ray is generated by a reflection off a surface.
  • Transmission: the ray is generated by a transmission through a surface.
  • Shadow: the ray is used for (transparent) shadows.

反射射线透射射线 还可以具有以下特性:

  • 漫反射: 光线是通过漫反射或透射(半透明)产生的。
  • 光泽的: 光线是由光滑镜面反射或透射产生的。
  • 奇异的: 光线是由非常锐利的反射或透射产生的。

Reflection and transmission rays can further have these properties:

  • Diffuse: the ray is generated by a diffuse reflection or transmission (translucency).
  • Glossy: the ray is generated by a glossy specular reflection or transmission.
  • Singulard: the ray is generated by a perfectly sharp reflection or transmission.