|
@@ -54,9 +54,14 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
raycasts++;
|
|
raycasts++;
|
|
if(rayhit.hit.geomID != RTC_INVALID_GEOMETRY_ID){
|
|
if(rayhit.hit.geomID != RTC_INVALID_GEOMETRY_ID){
|
|
if(sc.emitters.contains(rayhit.hit.geomID)){
|
|
if(sc.emitters.contains(rayhit.hit.geomID)){
|
|
|
|
+
|
|
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>());
|
|
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++){
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
- transport.array() *= it->outdir.dot(it->normal);
|
|
|
|
|
|
+ transport.array() *= (it->mat.m_bsdf->eval(
|
|
|
|
+ it->outdir,
|
|
|
|
+ it->indir,
|
|
|
|
+ it->normal
|
|
|
|
+ ).array().cast<double>());
|
|
for(const auto& pl : sc.pointlight){
|
|
for(const auto& pl : sc.pointlight){
|
|
struct RTCIntersectContext sh_context;
|
|
struct RTCIntersectContext sh_context;
|
|
rtcInitIntersectContext(&sh_context);
|
|
rtcInitIntersectContext(&sh_context);
|
|
@@ -78,7 +83,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
raycasts++;
|
|
raycasts++;
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
if(rsh_ray.tfar > 0){
|
|
if(rsh_ray.tfar > 0){
|
|
- transport += pl.color.cast<double>() * std::abs(sh_ray.dot(it->normal)) * (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() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -109,7 +114,11 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
else{
|
|
else{
|
|
Eigen::Vector3d transport(0,0,0);
|
|
Eigen::Vector3d transport(0,0,0);
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
- transport.array() *= it->outdir.dot(it->normal);
|
|
|
|
|
|
+ transport.array() *= it->mat.m_bsdf->eval(
|
|
|
|
+ it->outdir,
|
|
|
|
+ it->indir,
|
|
|
|
+ it->normal
|
|
|
|
+ ).array().cast<double>();
|
|
for(const auto& pl : sc.pointlight){
|
|
for(const auto& pl : sc.pointlight){
|
|
struct RTCIntersectContext sh_context;
|
|
struct RTCIntersectContext sh_context;
|
|
rtcInitIntersectContext(&sh_context);
|
|
rtcInitIntersectContext(&sh_context);
|
|
@@ -131,7 +140,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
raycasts++;
|
|
raycasts++;
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
if(rsh_ray.tfar > 0){
|
|
if(rsh_ray.tfar > 0){
|
|
- transport += pl.color.cast<double>() * std::abs(sh_ray.dot(it->normal)) * 1 / (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() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -142,7 +151,11 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
{
|
|
{
|
|
Eigen::Vector3d transport(0,0,0);
|
|
Eigen::Vector3d transport(0,0,0);
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
for(auto it = hits.rbegin();it != hits.rend();it++){
|
|
- transport.array() *= it->outdir.dot(it->normal);
|
|
|
|
|
|
+ transport.array() *= (it->mat.m_bsdf->eval(
|
|
|
|
+ it->outdir,
|
|
|
|
+ it->indir,
|
|
|
|
+ it->normal
|
|
|
|
+ ).array().cast<double>());
|
|
for(const auto& pl : sc.pointlight){
|
|
for(const auto& pl : sc.pointlight){
|
|
struct RTCIntersectContext sh_context;
|
|
struct RTCIntersectContext sh_context;
|
|
rtcInitIntersectContext(&sh_context);
|
|
rtcInitIntersectContext(&sh_context);
|
|
@@ -164,7 +177,7 @@ std::vector<Eigen::Vector3f> camera::get_image(const scene& sc, size_t n, sample
|
|
raycasts++;
|
|
raycasts++;
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
rtcOccluded1(sc.m_scene, &sh_context, &rsh_ray);
|
|
if(rsh_ray.tfar > 0){
|
|
if(rsh_ray.tfar > 0){
|
|
- transport += pl.color.cast<double>() * std::abs(sh_ray.dot(it->normal)) * 1 / (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() * (1.0 / double(sh_ray_length * sh_ray_length));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|