Importance sampling
用蒙特卡洛求解积分时 (Monte Carlo 随机采样对目标积分函数做近似)
importance sampling func p(x)
p(x)值大的地方,Monte Carlo多采几次
值小的地方,少采样一些。
一起贡献MC的积分值
http://blog.sina.com.cn/s/blog_4e5740460100cw5b.html
link1
http://statweb.stanford.edu/~owen/mc/
对 GGX的importance的理解
ImportanceSampleGGX(float2 Xi, float Roughness, float3 N)
{
float a = Roughness * Roughness;
float Phi = 2 * PI * Xi.x;
float CosTheta = sqrt( (1 - Xi.y) / ( 1 + (a*a - 1) * Xi.y ) );
float SinTheta = sqrt( 1 - CosTheta * CosTheta );
float3 H;
H.x = SinTheta * cos( Phi );
H.y = SinTheta * sin( Phi );
H.z = CosTheta;
float3 UpVector = abs(N.z) < 0.999 ? float3(0,0,1) : float3(1,0,0);
float3 TangentX = normalize( cross( UpVector, N ) );
float3 TangentY = cross( N, TangentX );
// Tangent to world space
return TangentX * H.x + TangentY * H.y + N * H.z;
}
http://blog.tobias-franke.eu/2014/03/30/notes_on_importance_sampling.html
link2
链接里的代码,算得是极坐标下的p
我这段代码算得三维的H 换到xyz下面
但为什么p的值就变成H了呢 看着像微表面normal或者 半角向量
因为D就是这个定义 D就是微表面normal的分布函数
而微表面的normal朝各个方向 只有朝向l, v表征的h方向的有贡献,所以是h
整体看importanceSampleGGX的含义就是求解ggx了 公式 link2有提供
感觉,就是用个函数 积个PDF再弄个什么CDF不知道是什么 然后就求出来了 中间出现了P()
The NDF itself is defined as:
Just like above, we start out with the PDF for GGX:
As in the case of Phong, we create two functions for θθ and ϕϕ. First let’s create p(θ)p(θ):
integrate((a^2cos(t)sin(t))/(%pi((a^2−1)cos(t)^2+1)^2), p, 0, 2*%pi)
The integration for ϕϕ is the same as above, so we skip it and instead now create the CDF for p(θ)p(θ):
integrate((2a^2cos(t)sin(t))/((a^2−1)cos(t)^2+1)^2, t, 0, s)
Setting the CDF to a random variable and solving for ss yields:
solve(2a^2(1/((2a^4−4a^2+2)cos(s)^2+2a^2−2)−1/(2a^4−2a^2)) = x, s)
A simple GLSL function to generate important directions looks like this:
vec2 importance_sample_ggx(vec2 xi)
{
float phi = 2.0f * PI * xi.x;
float theta = acos(sqrt((1.0f - xi.y)/
((a*a - 1.0f) * xi.y + 1.0f)
));
return vec2(phi, theta);
}
===========
http://www.cnblogs.com/xbinworld/p/4266146.html
Importance sampling的更多相关文章
- 蒙特卡洛法计算定积分—Importance Sampling
如上图所示,计算区间[a b]上f(x)的积分即求曲线与X轴围成红色区域的面积.下面使用蒙特卡洛法计算区间[2 3]上的定积分:∫(x2+4*x*sin(x))dx # -*- coding: u ...
- Implemented the “Importance Sampling of Reflections from Hair Fibers”
Just the indirect specular pass by importance sampling. With all layers. Manually traced by 3D Ham ...
- [Bayes] Hist & line: Reject Sampling and Importance Sampling
吻合度蛮高,但不光滑. > L= > K=/ > x=runif(L) > *x*(-x)^/K)) > hist(x[ind],probability=T, + xla ...
- Not All Samples Are Created Equal: Deep Learning with Importance Sampling
目录 概 主要内容 "代码" Katharopoulos A, Fleuret F. Not All Samples Are Created Equal: Deep Learnin ...
- 转 如何理解 重要性采样(importance sampling)
分类: 我叫学术帖2011-03-25 13:22 3232人阅读 评论(4) 收藏 举报 图形 重要性采样是非常有意 思的一个方法.我们首先需要明确,这个方法是基于采样的,也就是基于所谓的蒙特卡洛法 ...
- PRML读书会第十一章 Sampling Methods(MCMC, Markov Chain Monte Carlo,细致平稳条件,Metropolis-Hastings,Gibbs Sampling,Slice Sampling,Hamiltonian MCMC)
主讲人 网络上的尼采 (新浪微博: @Nietzsche_复杂网络机器学习) 网络上的尼采(813394698) 9:05:00 今天的主要内容:Markov Chain Monte Carlo,M ...
- 随机采样方法整理与讲解(MCMC、Gibbs Sampling等)
本文是对参考资料中多篇关于sampling的内容进行总结+搬运,方便以后自己翻阅.其实参考资料中的资料写的比我好,大家可以看一下!好东西多分享!PRML的第11章也是sampling,有时间后面写到P ...
- [Bayes] runif: Inversion Sampling
runifum Inversion Sampling 看样子就是个路人甲. Ref: [Bayes] Hist & line: Reject Sampling and Importance S ...
- [Bayes] What is Sampling
Ref: http://blog.csdn.net/xianlingmao/article/details/7768833 通常,我们会遇到很多问题无法用分析的方法来求得精确解,例如由于式子特别,真的 ...
随机推荐
- 理解机器为什么可以学习(一)---Feasibility of learning
主要讲解内容来自机器学习基石课程.主要就是基于Hoeffding不等式来从理论上描述使用训练误差Ein代替期望误差Eout的合理性. PAC : probably approximately corr ...
- [oldboy-django][2深入django]学生管理(Form)--查看(分页)
1 需求: 查看所有学生的信息,(分页功能) 2 前端:bootstrap美化前端 <!DOCTYPE html> <html lang="en"> < ...
- 设计模式 uml元素
uml的构造包含3种 事物4种:结构,行为,分组,注释事物 关系4种:泛化,实现,依赖,关联, 图10种,用例图,类图,对象,包,组件,部署,状态,活动,序列,协作 事物是对模型中最具代表性的成分的抽 ...
- 第六篇:python基础_6 内置函数与常用模块(一)
本篇内容 内置函数 匿名函数 re模块 time模块 random模块 os模块 sys模块 json与pickle模块 shelve模块 一. 内置函数 1.定义 内置函数又被称为工厂函数. 2.常 ...
- 深入理解 Flutter 的编译原理与优化
阿里妹导读:对于开发者而言,Flutter工程和我们的Android/iOS工程有何差别?Flutter的渲染和事件传递机制如何工作?构建缓慢或出错又如何去定位,修改和生效呢?凡此种种,都需要对Flu ...
- BZOJ 3456 城市规划 ——NTT
搞出递推式. 发现可以变成三个函数的乘积. 移项之后就可以求逆+NTT做了. miskoo博客中有讲 #include <map> #include <cmath> #incl ...
- xtrabackup安装使用说明
软件介绍: Percona XtraBackup是一块开源且免费的对MySQL Innodb存储引擎备份数据的工具,使用此工具的时候不需停止MySQL,而且支持压缩备份,支持对Innodb存储引擎做增 ...
- 【VBA】利用Range声明Array(一维/二维)
[说明] B2开始到B?(中间不能有空格),定义一维数组Arr_approver() Dim R_sh As Worksheet Set R_sh = ThisWorkbook.Sheets(&quo ...
- 提高Java开发效率,Idea必装的几款插件
1.codeMaker 重复代码生成工具 domian和dto两个类基本差不多,这个工具就可以通过一个类快速生成另一个类. 2.gsonFormat json转换成Java类 很多时候根据别人接口给的 ...
- 更改MVC3默认错误提示信息 模型验证 validation
原文发布时间为:2011-07-20 -- 来源于本人的百度文章 [由搬家工具导入] Model Metadata and Validation Localization using Conventi ...