2

渲染方程的积分部分在半球范围内(相对于立体角)执行积分。
我可以使用以下代码生成带有相应被积函数值的样本:

n = 10;
rho_s = 0.5;
rho_d = 0.5;

light_phi = degtorad(30);
light_theta = degtorad(60);
[lx ly lz] = sph2cart(light_phi, light_theta, 1);

refDir = cat(3, -lx, -ly, lz);
normal = cat(3, 0, 0, 1);

[sample_phi sample_theta] = meshgrid(0:12:360, 0:3:90);
[sample_x sample_y sample_z] = sph2cart(degtorad(sample_phi), degtorad(sample_theta), 1);
viewDir = cat(3, sample_x, sample_y, sample_z);

dotRL = sum(bsxfun(@times, viewDir, refDir), 3);
dotRL = max(dotRL, 0);

brdf_s = rho_s*(n+2)*(dotRL.^n)/(2*pi);
brdf_d = rho_d/pi;
brdf = brdf_s + brdf_d;

x = sample_x.*brdf; y = sample_y.*brdf; z = sample_z.*brdf;
mesh(x, y, z);
line([0 lx],[0 ly],[0 lz]);

axis equal; axis vis3d;
xlim([-1 1]); ylim([-1 1]); zlim([0 1]); 

我现在面临的问题是如何对这些样本进行积分或近似?

4

0 回答 0