|
@@ -28,7 +28,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
Eigen::Vector3d accum(0,0,0);
|
|
|
std::vector<hit> hits;
|
|
|
hits.reserve(6);
|
|
|
- for(size_t smp = 0;smp < 512;smp++){
|
|
|
+ for(size_t smp = 0;smp < 256;smp++){
|
|
|
Eigen::Vector3f di = lookray + (left * ((pert_dis(rng.m_rng) + float(i - n2)) / n2 / 1.5)) + realup * ((pert_dis(rng.m_rng) + float(j - n2)) / n2 / 1.5);
|
|
|
di.normalize();
|
|
|
struct RTCRayHit rayhit;
|
|
@@ -58,10 +58,10 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
Eigen::Vector3d transport(sc.added_objects[sc.geom_id_to_object_index_map.find(rayhit.hit.geomID)->second]->mat.tex->eval(0,0).cast<double>());
|
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
|
transport.array() *= (it->mat.m_bsdf->eval(
|
|
|
- it->outdir,
|
|
|
- it->indir,
|
|
|
+ -it->outdir,
|
|
|
+ -it->indir,
|
|
|
it->normal
|
|
|
- ).array().cast<double>());
|
|
|
+ ).array().cast<double>()) * it->mat.tex->eval(0,0).array().cast<double>();
|
|
|
for(const auto& pl : sc.pointlight){
|
|
|
struct RTCIntersectContext sh_context;
|
|
|
rtcInitIntersectContext(&sh_context);
|
|
@@ -83,7 +83,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
raycasts++;
|
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
|
if(rsh_ray.tfar > 0){
|
|
|
- transport.array() += pl.color.cast<double>().array() * it->mat.m_bsdf->eval(-sh_ray.normalized(), it->indir, it->normal).cast<double>().array() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
|
+ transport.array() += pl.color.cast<double>().array() * it->mat.m_bsdf->eval(-sh_ray.normalized(), it->indir, it->normal).cast<double>().array() * it->mat.tex->eval(0,0).array().cast<double>() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -115,10 +115,10 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
Eigen::Vector3d transport(0,0,0);
|
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
|
transport.array() *= it->mat.m_bsdf->eval(
|
|
|
- it->outdir,
|
|
|
- it->indir,
|
|
|
+ -it->outdir,
|
|
|
+ -it->indir,
|
|
|
it->normal
|
|
|
- ).array().cast<double>();
|
|
|
+ ).array().cast<double>() * it->mat.tex->eval(0,0).array().cast<double>();
|
|
|
for(const auto& pl : sc.pointlight){
|
|
|
struct RTCIntersectContext sh_context;
|
|
|
rtcInitIntersectContext(&sh_context);
|
|
@@ -140,7 +140,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
raycasts++;
|
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
|
if(rsh_ray.tfar > 0){
|
|
|
- transport.array() += pl.color.cast<double>().array() * it->mat.m_bsdf->eval(-sh_ray.normalized(), it->indir, it->normal).cast<double>().array() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
|
+ transport.array() += pl.color.cast<double>().array() * it->mat.m_bsdf->eval(-sh_ray.normalized(), it->indir, it->normal).cast<double>().array() * it->mat.tex->eval(0,0).array().cast<double>() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -152,10 +152,10 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
Eigen::Vector3d transport(0,0,0);
|
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
|
transport.array() *= (it->mat.m_bsdf->eval(
|
|
|
- it->outdir,
|
|
|
- it->indir,
|
|
|
+ -it->outdir,
|
|
|
+ -it->indir,
|
|
|
it->normal
|
|
|
- ).array().cast<double>());
|
|
|
+ ).array().cast<double>()) * it->mat.tex->eval(0,0).array().cast<double>();
|
|
|
for(const auto& pl : sc.pointlight){
|
|
|
struct RTCIntersectContext sh_context;
|
|
|
rtcInitIntersectContext(&sh_context);
|
|
@@ -177,7 +177,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
raycasts++;
|
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
|
if(rsh_ray.tfar > 0){
|
|
|
- transport.array() += pl.color.cast<double>().array() * it->mat.m_bsdf->eval(-sh_ray.normalized(), it->indir, it->normal).cast<double>().array() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
|
+ transport.array() += pl.color.cast<double>().array() * it->mat.m_bsdf->eval(-sh_ray.normalized(), it->indir, it->normal).cast<double>().array() * it->mat.tex->eval(0,0).array().cast<double>() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -186,7 +186,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
|
inner:
|
|
|
(void)0;
|
|
|
}
|
|
|
- img[j * n + i] = (accum.cast<float>() / 512.0f).array().pow(0.5f).matrix();
|
|
|
+ img[j * n + i] = (accum.cast<float>() / 128.0f).array().pow(0.5f).matrix();
|
|
|
}
|
|
|
}
|
|
|
}
|