首页 > 其他分享 >PBR-Book Ch8 Reflection Models

PBR-Book Ch8 Reflection Models

时间:2024-09-02 14:37:51浏览次数:4  
标签:phi const Models Float Book Ch8 theta omega sin

PBR-Book Ch8 Reflection Models

Reflection Models (pbr-book.org)

球坐标系中,使用 \((\theta, phi)\)

  • \(\theta\)

    • given direction to the \(z\) axis
  • \(\phi\)

    • the angle formed with the \(x\) axis after projection of direction onto the \(xy\) lane.

Given a direction vector \(\omega\)

\[\cos \theta = (\bold n \cdot \omega) = ((0, 0, 1) \cdot \omega) = \omega_z \tag{8.1} \]

  • BSDF Inline Functions

\[\cos\theta = \omega_z \\ \cos^2\theta = \omega_z^2 \\ |\cos\theta| = |\omega_z| \]

inline Float CosTheta(const Vector3f &w) { return w.z; }
inline Float Cos2Theta(const Vector3f &w) { return w.z * w.z; }
inline Float AbsCosTheta(const Vector3f &w) { return std::abs(w.z); }

确保 \(\sin^2\theta > 0\)

\[\sin^2\theta = \max(0, 1-\cos^2\theta) \\ \sin\theta = \sqrt{\sin^2\theta} \]

inline Float Sin2Theta(const Vector3f &w) {
    return std::max((Float)0, (Float) 1 - Cos2Theta(w));
}
inline Float SinTheta(const Vector3f &w) {
    return std::sqrt(Sin2Theta(w));
}

\[\tan \theta = \frac{\sin\theta}{\cos\theta} \\ \tan^2 \theta = \frac{\sin^2\theta}{\cos^2\theta} \]

inline Float TanTheta(const Vector3f &w) {
    return SinTheta(w) / CosTheta(w);
}
inline Float Tan2Theta(const Vector3f &w) {
    return Sin2Theta(w) / Cos2Theta(w);
}

image-20240831104628257

如上图,假设 \(\omega\) 是单位向量

\[r = \sin \theta \\ \cos \phi = \frac{x}{r} = \frac{x}{\sin\theta} \\ \sin \phi = \frac{y}{r} = \frac{y}{\sin \theta} \]

inline FLoat CosPhi(const Vector3f &w) {
	Float sinTheta = SinTheta(w);
    return (sinTheta == 0) ? 1 : Clamp(w.x / sinTheta, -1, 1);
}
inline Float SinPhi(const Vector3f &w) {
    Float sinTheta = SinTheta(w);
    return (sinTheta == 0) ? 0 : Clamp(w.y / sinTheta, -1, 1);
}

这里是这样设定的,当 \(\sin \theta = 0\) 时,\(\theta = 0\) 或 \(\theta = \pi\),也就是 \(\omega\) 沿着 \(z\) 轴正向或者负向,此时 \(\phi\) 值其实是未定义的,因为在 \(xOy\) 平面上没有投影

这里设定 \(\cos\phi = 1\) 和 \(\sin\phi = 0\) 其实是为了算法的健壮性和一致性

简单来想可以认为 \(\theta = 0\) 或 \(\theta = \pi\) 时,\(\phi = 0\) (其实 \(\phi\) 没有意义)

\[\cos ^ 2 \phi = \frac{x^2}{\sin^2\theta} \\ \sin ^ 2 \phi = \frac{y^2}{\sin^2\theta} \]

inline Float Cos2Phi(const Vector3f &w)
{
    return CosPhi(w) * CosPhi(w);
}
inline Float Sin2Phi(const Vector3f &w)
{
    return CosPhi(w) * CosPhi(w);
}

The cosine of the angle \(\color{red}{\Delta \phi}\) between two vectors' \(\phi\) values in the shading coordinate system can be found by zeroing the \(z\) coordinate of the two vectors to get 2D vectors and then normalizing them. The dot product of these two vectors gives the cosine of the angle between them. The implementation below rearranges the terms a bit for efficiency so that only a single square root operation needs to be performed.

\[\cos \Delta\phi = \frac{\omega_a \cdot \omega_b}{|\omega_a||\omega_b|} \]

// cosine of Delta Phi
inline Float CosDPhi(const Vector3f &wa, const Vector3f &wb) {
    return Clamp((wa.x * wb.x + wa.y * wb.y) /
                 std::sqrt((wa.x * wa.x + wa.y * wb.y) * 
                           (wb.x * wb.x + wb.y * wb.y)), -1, 1);
}

Keep in Mind

  1. The incident light direction \(\omega_i\) and the outgoing viewing direction \(\omega_o\) will both be normalized and outward facing after being transformed into the local coordinate system at the surface.

    \(\omega_i\) 和 \(\omega_o\) 都是归一化的,且都被变换到局部坐标空间了

  2. By convention in pbrt, the surface normal \(\bold n\) always points to the "outside" of the object, which makes it easy to determine if light is entering or exiting transmissive objects:

    • if the incident light direction \(\omega_i\) is in the same hemisphere as \(\bold n\), then light is entering
    • otherwise, it's exiting.

    Therefore, one detail to keep in mind is that the normal may be on the opposite side of the surface than one or both of the \(\omega_i\) and \(\omega_o\) direction vectors. Unlike many other renderers, pbrt does not flip the normal to lie on the same side as \(\omega_o\)

    \(\omega_i\) 和 \(\bold n\) 同向的话,是正在进入,否则是逃出

    和其他渲染器不同,pbrt 中,\(\omega_i\), \(\omega_o\) 和 \(\bold n\) 可能在表面的相反的边

  3. The local coordinate system used for shading may not be exactly the same as the coordinate system returned by the Shape::Intersect() routines from Chapter 3; they can be modified between intersection and shading to achieve effects like bumping mapping. See Chapter 9 for examples of this kind of modification.

标签:phi,const,Models,Float,Book,Ch8,theta,omega,sin
From: https://www.cnblogs.com/icewalnut/p/18392663

相关文章

  • 批量维护工具ansible之yaml与剧本playbook
    一.简介ansible的剧本playbook采用yaml语法,通过yaml语法可以轻松地表示和定义复杂的任务和配置,无论是单台还是多台服务器的管理,ansible都能够提供统一的语法来描述和执行操作,能快速地应对变更、部署和升级。二.yaml语法基本0.运行AnsiblePlaybookansible-playbookdeploy.yml1.YAM......
  • PoLLMgraph: Unraveling Hallucinations in Large Language Models via State Transit
    本文是LLM系列文章,针对《PoLLMgraph:UnravelingHallucinationsinLargeLanguageModelsviaStateTransitionDynamics》的翻译。PoLLMgraph:通过状态转换动力学揭示大型语言模型中的幻觉摘要1引言2相关工作3PoLLMgraph4实验5结论局限性摘要尽管近......
  • Social Skill Training with Large Language Models
    本文是LLM系列文章,针对《SocialSkillTrainingwithLargeLanguageModels》的翻译。大型语言模型的社交技能训练摘要1引言2角色和模拟的LLM3APAM框架4安全部署愿景5技术挑战6评估7讨论8总结与展望摘要人们依靠解决冲突等社交技能进行有效沟通,......
  • [Paper Reading] ControlNet: Adding Conditional Control to Text-to-Image Diffusio
    ControlNet:AddingConditionalControltoText-to-ImageDiffusionModelslink时间:23.11机构:StandfordTL;DR提出ControlNet算法模型,用来给一个预训练好的text2image的diffusionmodel增加空间条件控制信息。作者尝试使用5w-1M的edges/depth/segmentation/pose等信息训练Co......
  • 浅谈Java loombook框架
    一、基本介绍        Java的LoomProject是一个处于早期开发阶段的项目,旨在为Java平台添加轻量级的协程支持。协程是一种比线程更加轻量级的存在,它可以在一个线程中并发执行多个任务,从而减少上下文切换的开销,并提高系统的吞吐量。        LoomProject提......
  • FPGA第 7 篇,FPGA开发环境搭建,Altrea开发环境搭建,Quartus几个版本之间的区别,以Quartus/
    前言我们知道FPGA的应用领域非常广泛,包括但不限于以下,请看,而且未来应用前景也可以,几乎涵盖了所有涉及数字信号处理和技术实现的领域。上期我们介绍了FPGA的基础知识数字电路,请看,FPGA与数字电路https://blog.csdn.net/weixin_65793170/article/details/141363656?spm=10......
  • BAdam A Memory Efficient Full Parameter Optimization Method for Large Language M
    目录概BAdam代码LuoQ.,YuH.andLiX.BAdam:Amemoryefficientfullparameteroptimizationmethodforlargelanguagemodels.arXivpreprint,2024.概本文介绍了一种Blockcorrdinatedescent(BCD)的训练方式.BAdam当模型本身很大的时候,训练它会成为一......
  • SwapPrompt(论文解读): Test-Time Prompt Adaptation for Vision-Language Models
    2023(NeuralIPS)摘要测试自适应(TTA)是无监督域自适应(UDA)中一种特殊且实用的设置,它允许源域中的预训练模型去适应另一个目标域中的未标记测试数据。为了避免计算密集型的骨干网络微调过程,因此利用预训练视觉语言模型(例CLIP、CoOp)zero-shot的泛化潜力,仅对未见测试域的运行时......
  • Ansible-playbook 应用梳理
    前面已经介绍过Ansible的安装配置及常见模块的使用--《Linux下使用Ansible处理批量操作》Palybook简介palybook是由一个或多个paly组成的列表,play的主要功能在于将事先归并为一组的主机装扮成事先通过ansible中的task定义好的角色。从根本上来讲,所谓task无非是调用ansible......
  • MIXLORA: Enhancing Large Language Models Fine-Tuning with LoRA-based Mixture of
    本文是LLM系列文章,针对《MIXLORA:EnhancingLargeLanguageModelsFine-TuningwithLoRA-basedMixtureofExperts》的翻译。MIXLORA:通过基于LoRA的专家混合来增强大型语言模型的微调摘要1引言2相关工作3MIXLORA4实验5结论摘要微调大型语言模型(LLM)......