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 通常,我们会遇到很多问题无法用分析的方法来求得精确解,例如由于式子特别,真的 ...
随机推荐
- 一个iOS程序员眼中的跨域问题
摘要: 跨域问题是web开发领域一个常见的问题,相信每个web开发者都遇到"跨域"的问题 最近公司的iOS开发任务比较少,所以自己最近开始了Web开发的任务,在用H5做了很多页面, ...
- c++ 中double与string之间的转换,char *
运行代码为 /* * main.cpp * * Created on: Apr 7, 2016 * Author: lizhen */ #include <iostream> //#inc ...
- ansible Failed to connect to the host via ssh: no such identity: /root/.ssh/id_rsa.bak
中控机和远端主机配置完密钥后,在中控台上通过ansible检测联通性 ansible -i inventory.cfg all -m ping 10.1.1.1 | UNREACHABLE! => ...
- Spring4.0实战 rest相关
package com.paic.pay.merchant.web; import com.paic.pay.merchant.entity.MerchantUser; import com.paic ...
- Vim插件YCM的安装
YouCompleteMe(YCM)是一款非常好用的Vim插件,但是很多人安装的时候会出问题(尤其是涉及到C和C++的补全),我安装的时候也遇到了问题,现在解决了,给大家参考: Step1: 通过Vu ...
- Zabbix整合MegaCLI实现物理硬盘的自动发现和监控
MegaCLI是LSI提供的用户空间管理RAID卡(LSI芯片)工具,适用于大多数的Dell服务器. MegaCLI介绍: http://zh.community.dell.com/techcente ...
- button的默认type居然是submit
今天使用了html中的button标签,用js写了一点代码来完成onclick实践,当我点下它的时候,它不仅执行了我写的function,还把表单给提交了,一查它的button居然是sumbit. 然 ...
- 【转】lightmap
Shader "Diffuse Lightmap" { Properties { _MainTex ("Texture 1", 2D) = "whit ...
- 转JSON提示No serializer found for class
在调用Json串生成方法时,提示: No serializer found for class com.jeremxy.domain.EpgDetail and no propertiesdiscov ...
- pat 团体天梯赛 L2-004. 这是二叉搜索树吗?
L2-004. 这是二叉搜索树吗? 时间限制 400 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 陈越 一棵二叉搜索树可被递归地定义为具有下列性质的 ...