ZKX'S Blogs
  • ZKX'S BLOG
  • action
    • road-map
    • todo-list
    • temp
  • 游戏技术
    • 物理
    • algorithm
      • obstacle-avoidance
      • path-finding
    • Assets
      • 解包资源
      • Sound
      • text
      • 动画
      • image
        • image-tools
        • maple-story
        • 项目图
        • SD
        • AI
          • ai-model
          • Novel ai
          • transformer
          • ComfyUI
            • start
          • sd
            • four-view
            • image-assets
            • icon
              • working-flow
            • tutorials
              • introduction
              • model-traning
        • ui
          • ui-todo
          • work
          • ui-tutorials
            • 一颗豆Studio
            • image-process
              • 8-minute
              • 1. 现代图形绘制流水导论
            • xiao-long-bao
              • game-ui
              • ps-skill
      • model
        • Houdini
        • Blender
          • animation
          • 配合 Unity 建模流程
          • common-use
          • Blender 配置
          • plugins
          • Words
          • tutorials
            • Imphenzia
            • blender-4.0
              • 建模篇
              • 10. role-anim
              • 11. room-anim
              • 2. lighting
              • 3. material
              • 场景动画
              • 5. item-animation
              • 6. engrave
              • 7. role
              • 8. face
              • 9. bone
      • vfx
        • vfx-assets
        • vfx
      • 视频录制
    • README_冲突文件_zkx_20240828215908
      • 计算机科学
      • 代码写法
        • functional-programming
        • programing-driven
      • data-structure
        • tree
      • multi-threads
        • consistent-hash
        • I/O 多路复用
        • reactor-proactor
        • zero-copy
      • 操作系统
        • cpu-cache_冲突文件_zkx_20240828215908
        • soa_冲突文件_zkx_20240828215908
        • memory
          • memory-allocation
          • memory-recycle_冲突文件_zkx_20240828215908
          • 预读机制
          • virtual-memory_冲突文件_zkx_20240828215908
        • 进程线程
          • base_冲突文件_zkx_20240828215908
          • communicate_冲突文件_zkx_20240828215908
    • 笔记
      • Bevy 引擎研究
      • render-pass
      • usd
      • Interview
      • breaking
        • multi-threads
      • GPU
        • multi-threads
        • DirectX 12 3D 游戏开发实战
        • Analyze
        • vulkan
          • Vulkan 应用
          • Vulkan 坐标系
          • Vulkan 创建 CubeMap
          • 渲染器流程
          • Vulkan 对象
          • vulkan-learn
            • Vulkan tutorials
              • Comparison of graphics apis
              • Official Vulkan Tutorial
              • brendan-galea
                • Vulkan Game Enggine
              • Vulkan-lecture-series
                • Vulkan Essentials
                • Swap chain
                • 03. Resources & Descriptors
                • Commands and Command Buffers
                • pipeline and stages
                • 07. Synchronization
      • projects
        • fbx
        • 动画
          • animation-graphs_冲突文件_zkx_20240828215918
          • animation-programming-basics_冲突文件_zkx_20240828215918
          • README_冲突文件_zkx_20240828215918
            • 1. Intro to Physics-Based Animation_冲突文件_zkx_20240828215918
            • Vector
            • 3. Rigid body dynamic_冲突文件_zkx_20240828215918
            • 4.Rigid Contacts_冲突文件_zkx_20240828215918
            • 5.Cloth Simulation_冲突文件_zkx_20240828215918
          • arm
            • 1. Introduction to Character Animation_冲突文件_zkx_20240828215918
          • 程序动画
            • 程序动画
        • GLTF
          • 皮肤
        • 网格生成
          • Mesh Gen
          • 网格
          • 程序化地形
          • games-202-几何建模和处理
            • 1. 课程介绍
            • 2. 数据拟合
      • 渲染
        • 渲染器
        • 管线和引擎
          • 颜色空间
          • 法线映射
          • Render Graph
          • 渲染管线
        • 游戏引擎
          • font
          • gpu-instance
          • 光照纹理
          • 光线追踪
          • 蒙皮动画
          • Skybox
          • 文字
          • texture-compress
          • UI
          • view-port-mode_冲突文件_zkx_20240828215919
          • 虚拟纹理
        • performance
          • HLOD
          • tools
        • controller
          • 2d 后处理和光照
          • 抗锯齿
          • buffer
          • 延时渲染
          • hclip
          • 后处理
          • 阴影
          • transparency
          • culling
            • Culling
            • hiz
        • 技术美术
          • 艺术表达
            • 各向异性
            • 一些特效
            • 非真实感渲染(卡通渲染)
            • Outline
            • 次表面散射
            • Tone Mapping
          • Filament 渲染器里的算法
            • 2 Overview
            • Notation
            • 4 Material System
            • 5. Lighting
          • 自然模拟
            • BRDF
            • 全局光照 GI
            • 光照
            • 物理真实的渲染
            • Blogs
            • 反射
            • UE 中的物理光照系统
            • 体渲染
            • water
            • 天气系统
        • 渲染教程
          • apex-legends-mobile
          • Shader 入门精要笔记
          • 庄懂-美术向 TA 课程
          • games-202
            • Introduction and Overview
            • Real-Time Physically-Based Materials
            • real-time-physically-based-materials-2
            • 实时光线追踪 1
            • 实时光线追踪 2
            • A Glimpse of Industrial Solusion
            • 2. Recap of CG Basics
            • Real time Shadows 1
            • Real time shadows 2
            • 实时环境光 上
            • 实时环境光 下
            • 实时全局光照 1
            • 实时全局光照 2
            • Realtime global illumination 3
      • 渲染笔记
      • tutorials
        • mobile-optimize
        • modern-mobile-rendering-note
        • README_冲突文件_zkx_20240828215908
          • 7. 游戏循环及实时模拟_冲突文件_zkx_20240828215908
          • multi-threads
          • multi-threads
          • 12. 碰撞和刚体动力学
          • multi-threads
          • cargo-mobile
          • 15. 运行时游戏性基础系统
          • multi-threads
          • C/ C++ 的数据、代码及内存
          • 4. 游戏所需要的三维数学
          • 5. 游戏支持系统_冲突文件_zkx_20240828215908
          • base
          • cargo-mobile
          • projects
          • multi-threads
        • GAMES104-现代游戏引擎: 从入门到实践
          • 第一节:游戏引擎导论
          • 第二节:引擎架构分层
          • 第三节:如何构建游戏世界
          • 第四节:游戏引擎中的渲染实现
          • 第五节:光和材质
          • 第六节:游戏中大气和云的渲染
          • 第七课:游戏中渲染管线、后处理和其他
          • 第八课:引擎中的动画技术基础
          • Advanced Animation Technology
          • Physics System
          • 物理系统应用
          • 粒子系统和音效系统
          • 玩法
          • 基础 AI 上
          • 基础 AI 下
          • 高级 AI 上
          • 高级 AI 下 Machine Learning
          • 网络架构基础 上
          • 网络架构基础 下
          • 网络架构进阶 上
          • 网络架构进阶 下
          • Data-Oriented Programming and Job System 面向数据编程
          • Data Oriented 下
          • 动态全局光照和 Luman
          • 全局光照和 lumen 下
          • GPU-Driven Geometry pipeline - Nanite
          • Nanite - 2
        • games-106
          • multi-threads
          • 2. 图形绘制流水的基本原理和实践 (1)
          • 3. 图形绘制流水的基本原理和实践 (2)
          • 4. 图形绘制流水的基本原理和实践 (3)
          • 绘制管线中的计算频率
          • 6. 性能分析
    • game-ai
      • game-ai-book
      • behaviour
      • base
      • goap
      • sli97
    • 游戏设计
      • battle-system
      • 新手引导
      • character-controller
      • game-designer-books
      • game-theory
      • 关卡策划
      • 模块化设计
      • simple-note
      • player-behaviour
      • skill
      • 缝合怪和肉鸽
      • 顶视角
      • tps-vs-fps
      • 策划实用网站
      • culture
      • 游戏数值
        • battle-numerical
        • 战斗数值
        • 装备数值
      • 游戏设计教程
        • 超简短的独立游戏开发教学第一季
        • 超简短的独立游戏开发教学第二季
        • zelda-phisics-sound
    • 游戏引擎编程语言
      • english
      • CPP
        • cmake-tutorial
        • 编译
        • 包管理
        • cpp 工程结构
        • 智能指针
      • C#
        • GC
        • Web
        • 语言执行原理
        • weak-reference_冲突文件_zkx_20240828215917
      • Rust
        • base
        • cargo
        • macro
        • Rust android
        • rust-async_冲突文件_zkx_20240828215917
        • 跨平台
        • FFI
        • 文件操作
        • Rust Macros
        • Rust 内存管理
        • Rust Option 和 Result 的处理
        • Rust 中的引用
        • Rust 正则表达式
        • 学习 Rust
          • Rust 笔记
        • 使用 Rust 写 Vulkan
          • 开源中间件和项目
          • Rust 光线追踪
    • 数学
      • Fractal
      • 机器学习
      • 元胞自动机
      • 曲线
      • 半球积分
      • 线性代数的本质
      • 低差异序列
      • 噪声
      • 四元数
      • 有向距离场
      • 空间变换
      • 球谐函数
      • physics
        • Games 401
        • soft-body
  • 游戏
    • 赛博朋克 2077
    • 艾尔登法环
    • 密室逃脱
    • 日式
    • 冒险岛国际服
    • no-oxygen
    • oil-game
    • text-game
  • 工具
    • shell
    • 博客搭建
      • 基础
      • 美化
      • 使用 Markdown 做博客
      • my-blogs
    • controller
      • sofunny
    • 游戏引擎使用
      • 虚幻引擎
      • Unity
        • plugins
        • client
          • life-time
          • 网络
          • weixin
          • 3c
            • input
            • animator
              • Reference
            • games-105-计算机角色动画基础
              • Motion
            • golden-rush
              • cargo-mobile
              • 工程技术
            • input
              • input-system
          • 代码
            • 协程
            • 事件系统
            • 游戏框架
            • projects
              • JobSystem
              • unitask
          • DOTS
            • ai_冲突文件_zkx_20240828215923
            • Entity component system
            • errors_冲突文件_zkx_20240828215923
            • SubScene
            • ecs-sample-note
              • advance
              • bake
              • base-practice
              • graphical
              • render
              • resource
          • Unity 编辑器使用技巧
            • 自定义模块
            • 下载
            • android
              • 调试安卓机
              • install-apk
            • Unity 工具
              • Editor UI
              • OnGUI
          • memory
            • 安卓内存
            • Unity 内存分布
            • native-memory
          • performance
            • accelerate
            • game-performance-note
            • performance-optimize
            • plugins
          • Unity UI
            • 设计
            • layout
            • shader-ui
            • Reference
        • others
          • Mod for Unity Game
          • weixin-game
          • xr
          • interview
            • junior-unity-client_冲突文件_zkx_20240828215923
          • 会议笔记
            • Unity 开放日 - 厦门分享总结
          • render-pipeline
            • ET Framework
            • DOTS-training-samples
              • 蚂蚁模拟
            • ECSSample
              • Advanced
              • Boids
              • hellocube_冲突文件_zkx_20240828215923
        • render
          • baking
          • gpu-driven
          • 粒子系统
          • Visual Effect Graph
          • 渲染管线
            • batch-render-group
            • inverse-z
            • platform-shader
            • scriptable-renderer
            • Universal Render Pipeline
            • HDRP
              • HDRP 中的 Anti-Aliasing
              • HDRP 自定义渲染阶段
              • 曝光
              • Lit 光照
              • SimpleLit
            • SRP
              • SRP Batch
              • SRP 概览
          • Unity shader 使用
            • Compute Shader
            • Draw Procedural
            • macro
            • 顶点坐标
            • Shader graph
            • 着色器语法
            • variant
            • Shader 预热
        • 资源管理
          • Addressable
          • config
          • 商业化的资源管理和热更新
          • AssetBundle
            • problems
            • skills
            • tutorials
          • asset
            • asset-live-time
            • Asset 简介
    • Git 进阶使用
      • git 常用方法
      • Git 使用出问题时的解决办法
      • git-submodule
      • basic
        • Git 基础
        • Github
        • Git 同步
    • IDE
      • Rider
      • 主题
    • 语法格式
      • 正则化
    • Windows
      • Windows 应用
由 GitBook 提供支持
在本页
  • 4.1 Standard model
  • 4.2 Dielectrics and conductors
  • 4.3 Energy conservation
  • 4.4 Specular BRDF
  • 4.4.1 Normal distribution function (specular D)
  • 4.4.2 Geometric shadowing (specular G)
  • 4.5 Diffuse BRDF
  • Improving the BRDFs
  • 4.8 Parameterization
  • 4.8.3 Remapping 参数映射
  • 各材质参数的大概影响

这有帮助吗?

在GitHub上编辑
  1. 游戏技术
  2. 笔记
  3. 渲染
  4. 技术美术
  5. Filament 渲染器里的算法

4 Material System

上一页Notation下一页5. Lighting

最后更新于1年前

这有帮助吗?

材质系统

4.1 Standard model

材质的表面表现为漫反射项 + 高光反射项

  1. diffuse componnet, fd

  2. specular component, fr

image-20230224092240378
image.png

微表面模型

  • 宏观表面

  • 微观表面

  • Shadowing

  • Masking

表面越粗糙,反射 Lobe 越大

微表面模型表达式

  • D:微表面分布,NDF or Normal Distribution Function,主要的着色贡献项

  • G:微表面的可见性项,减少反射出的光线

  • F:决定高光反射和漫反射的贡献权重

  • |n * v|, |n * l| 积分的归一化项

4.2 Dielectrics and conductors

  • 金属,Metalic, Conductor

  • 非金属,non-metallic,Dielectric

BSDF

  • 用 fd 模拟 BSDF 中的 Scatter

  • 纯金属材质是没有漫反射的

4.3 Energy conservation

G 项会造成出射能量损失,需要在遮挡严重(粗糙度高),反射性强的区域进行能量补偿实现能量守恒。

4.4 Specular BRDF

镜面 brdf

4.4.1 Normal distribution function (specular D)

长尾法线分布函数可以去拟合真实世界表面 D_GGX:

  • 光亮衰减处长尾

  • 高光处短峰

float D_GGX(float NoH, float roughness) {
    float a = NoH * roughness;
    float k = roughness / (1.0 - NoH * NoH + a * a);
    return k * k * (1.0 / PI);
}
  • NoH :视线与出射光靠近程度,结果成正比

  • roughness, a : 粗糙程度,减少 NoH 影响

4.4.2 Geometric shadowing (specular G)

几何阴影函数,模型表面的自遮挡损失能量,减少光强,得到剩余出射的光强

float V_SmithGGXCorrelated(float NoV, float NoL, float roughness) {
    float a2 = roughness * roughness;
    float GGXV = NoL * sqrt(NoV * NoV * (1.0 - a2) + a2);
    float GGXL = NoV * sqrt(NoL * NoL * (1.0 - a2) + a2);
    return 0.5 / (GGXV + GGXL);
}
  • NoV :视线到模型表面垂直程度,正相关

  • NoL :出射光到模型表面的垂直程度,正相关

  • roughness, a:负相关

4.4.3 Fresnel (specular F)

菲涅尔项

描述能量在两个介质之间的传递效率

菲涅尔效应

  • 入射光线和平面越接近平行,反射光越高,折射光越低

  • 反射效率还取决于材质 IOR(index of refraction),即光线从空气到材质的角度比。

fx :法线和光线夹角为 x 时的菲涅尔项的值

  • f0 (incident specular reflectance) : 入射反射光线和平面近乎垂直时的折射率,正相关,由 IOR 决定。

  • f90 (reflectance at grazing angles ): 入射反射光线和平面近乎平行时的折射率,在光滑表面上几乎为 1 正相关

  • u , v * h: 视线和入射光线的靠近程度,在 f90 和 f0 之间插值

Shlick 方法来近似 fx

F_Schlick(float u, vec3 h, vec3 f0, float f90)

  • 在自然界中的金属和非金属 f90 一般都为 1

所以优化上面代码

vec3 F_Schlick(float u, vec3 f0) {
    float f = pow(1.0 - u, 5.0);
    return f + f0 * (1.0 - f);
}

4.5 Diffuse BRDF

兰伯特漫反射 Fd_Lambert

任意角度的出射光相同颜色

float Fd_Lambert() {
    return 1.0 / PI;
}

vec3 Fd = diffuseColor * Fd_Lambert();

Burley 漫反射

也需要考虑到菲涅尔项,所以在模型边缘又一圈高亮反射的高光(retro-reflections)

float Fd_Burley(float NoV, float NoL, float LoH, float roughness) {
    float f90 = 0.5 + 2.0 * roughness * LoH * LoH;
    float lightScatter = F_Schlick(NoL, 1.0, f90);
    float viewScatter = F_Schlick(NoV, 1.0, f90);
    return lightScatter * viewScatter * (1.0 / PI);
}

Improving the BRDFs

Energy gain in diffuse reflectance

当前的 Lambert 漫反射会产生不符合物理的能量,所以需要进行能量衰减。但是过于复杂所以不实现。

Energy loss in specular reflectance

镜面反射在 G 项会产生能量损失,金属度高的时候镜面反射大。粗糙度高的时候能量损失大。所以在粗糙金属时能量损失最大。使用能量补偿 energy compensation 来弥补损失。

4.8 Parameterization

参数化

Parameter
Definition

BaseColor

Diffuse albedo for non-metallic surfaces, and specular color for metallic surfaces

Metallic

Whether a surface appears to be dielectric (0.0) or conductor (1.0). Often used as a binary value (0 or 1)

Roughness

Perceived smoothness (0.0) or roughness (1.0) of a surface. Smooth surfaces exhibit sharp reflections

Reflectance

Fresnel reflectance at normal incidence for dielectric surfaces. This replaces an explicit index of refraction

Emissive

Additional diffuse albedo to simulate emissive surfaces (such as neons, etc.) This parameter is mostly useful in an HDR pipeline with a bloom pass

Ambient occlusion

4.8.2 类型和取值范围

Parameter
Type and range

BaseColor

Linear RGB [0..1]

Metallic

Scalar [0..1]

Roughness

Scalar [0..1]

Reflectance

Scalar [0..1]

Emissive

Linear RGB [0..1] + exposure compensation

Ambient occlusion

Scalar [0..1]

metallic, roughness and reflectance parameters affect the appearance of a surface.

Color space

加载图片,把颜色传入 shader 时要把 sRGB 图片的颜色从 0.45 Gama 空间转到 1.0 linear 空间。压暗颜色。

4.8.3 Remapping 参数映射

remap the parameters baseColor , roughness and reflectance .

4.8.3.1 基础颜色映射

vec3 diffuseColor = (1.0 - metallic) * baseColor.rgb

  • 非金属(Dielectrics,绝缘体)大范围的反射,将 BaseColor 作为漫反射颜色,

  • 金属(Conductor,Metal)没有漫反射项,基本没有漫反射颜色

4.8.3.2 Reflectance remapping 反射率映射

Dielectrics 非金属反射率

  • 输入的非金属反射率(感知到的反射率 perception reflectance)参数为 [0 ~ 1],

  • reflectance 一般由艺术家控制,不过怎么控制其最终 f0 都不高,一般工作流也没有 reflectance 项,所以默认为 0。

  • 自然界中的绝缘体反射率为 [2% ~ 16%],需要进行映射

  • 绝缘体的镜面反射是消色差的,所以在各个颜色上的反射系数相同

  • f0 指视线与法线成 0 度时的反射率,f90 指视线和法线成 90 度此时任何材质反射率都为 1

Material
Reflectance
IOR
Linear value

Water

2%

1.33

0.35

Fabric

4% to 5.6%

1.5 to 1.62

0.5 to 0.59

Common liquids

2% to 4%

1.33 to 1.5

0.35 to 0.5

Common gemstones

5% to 16%

1.58 to 2.33

0.56 to 1.0

Plastics, glass

4% to 5%

1.5 to 1.58

0.5 to 0.56

Other dielectric materials

2% to 5%

1.33 to 1.58

0.35 to 0.56

Eyes

2.5%

1.38

0.39

Skin

2.8%

1.4

0.42

Hair

4.6%

1.55

0.54

Teeth

5.8%

1.63

0.6

Default value

4%

1.5

0.5

Conductors 金属反射率

Metal
f0f0 in sRGB
Hexadecimal
Color

Silver

0.97, 0.96, 0.91

#f7f4e8

Aluminum

0.91, 0.92, 0.92

#e8eaea

Titanium

0.76, 0.73, 0.69

#c1baaf

Iron

0.77, 0.78, 0.78

#c4c6c6

Platinum

0.83, 0.81, 0.78

#d3cec6

Gold

1.00, 0.85, 0.57

#ffd891

Brass

0.98, 0.90, 0.59

#f9e596

Copper

0.97, 0.74, 0.62

#f7bc9e

f0=baseColor⋅metallicf_0 = baseColor ⋅ metallicf0​=baseColor⋅metallic
  • 金属的反射率就是其颜色

  • 导体的反射是基于颜色与金属度的并且接近于 1,所以导体的 baseColor 和 metallic 在设置的时候都需要接近 1

  • 反射力度无关 Reflectance

总体反射率

材质整体的反射由非金属反射和金属反射加权平均得到,非金属的反射率是 ior,金属反射率是其基本颜色

vec3 f0 = 0.16 * reflectance * reflectance * (1.0 - metallic) + baseColor * metallic;

粗糙度映射

α=perceptualRoughness2α=perceptualRoughness^2α=perceptualRoughness2

各材质参数的大概影响

image.png

image.png

image-20230224093841161
image.png
image.png
image.png

理想状态应该积分各个方向的输入

对公式进行简化

Defines how much of the ambient light is accessible to a surface point. It is a per-pixel shadowing factor between 0.0 and 1.0. This parameter will be discussed in more details in the section

image-20230224100211538

人所感知到的略大于实际的粗糙度

lighting
*Microfacets*
Masking and shadowing of microfacets
image-20230224092623444
BRDF modelization for dielectric and conductor surfaces
image.png
image.png