Fix bugs.
This commit is contained in:
parent
0b8021c139
commit
c1e15155ad
2 changed files with 15 additions and 12 deletions
|
|
@ -146,7 +146,6 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
|||
const Vec3fa wo = neg(ray.dir);
|
||||
|
||||
float mu_t = mu_a + mu_s;
|
||||
// float mu_t = 0.1;
|
||||
float t;
|
||||
if (mu_t == 0) {
|
||||
t = inf;
|
||||
|
|
@ -159,16 +158,20 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
|||
// printf("t: %f;%f\n", t, ray.tfar);
|
||||
// }
|
||||
|
||||
|
||||
if (t > 0.0 && t < ray.tfar) {
|
||||
|
||||
// Nee
|
||||
/* Light ray */
|
||||
return {0.0, 0.0, 0.0};
|
||||
// return {0.0, 0.0, 1.0};
|
||||
int id = (int)(RandomSampler_get1D(sampler) * data.scene->lights.size());
|
||||
if (id == data.scene->lights.size())
|
||||
id = data.scene->lights.size() - 1;
|
||||
const Light* l = data.scene->lights[id];
|
||||
const Light* l = data.scene->lights.at(id);
|
||||
Sample sample;
|
||||
sample.P = ray.org + t * ray.dir;
|
||||
sample.Ng = ray.dir;
|
||||
sample.Ns = ray.dir;
|
||||
|
||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
||||
|
||||
|
|
@ -183,11 +186,11 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
|||
rtcOccluded1(data.g_scene, RTCRay_(shadow), &sargs);
|
||||
RayStats_addShadowRay(stats);
|
||||
|
||||
float scatter = phase(scattering_parameter, dot(ray.dir,shadow.dir));
|
||||
float scatter = phase(scattering_parameter, -dot(-ray.dir,shadow.dir));
|
||||
/* add light contribution if not occluded (NEE) */
|
||||
if (shadow.tfar >= 0.0f) {
|
||||
// L += Lw * light_diffuse * ls.weight;
|
||||
L += Lw * std::pow(M_E, - mu_t * shadow.tfar) * scatter * mu_s * ls.weight * dot(sample.Ng, ls.dir) / data.scene->lights.size();
|
||||
L += Lw * std::pow(M_E, - mu_t * shadow.tfar) * scatter * (mu_s / mu_t) * ls.weight * dot(sample.Ng, ls.dir) / data.scene->lights.size();
|
||||
// L += Lw * light_diffuse * ls.weight/ data.scene->lights.size();
|
||||
}
|
||||
|
||||
|
|
@ -196,7 +199,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
|||
float pdf;
|
||||
Vec3fa o = sample_phase_function(-ray.dir, scattering_parameter, RandomSampler_get2D(sampler), pdf);
|
||||
|
||||
Lw *= std::pow(M_E, - mu_t * t) * mu_s;
|
||||
Lw *= mu_s / mu_t;
|
||||
|
||||
ray = Ray(ray.org + t * ray.dir,o,EPS,inf);
|
||||
|
||||
|
|
@ -207,8 +210,8 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
|||
sample.P = ray.org + ray.tfar * ray.dir;
|
||||
sample.Ng = ray.Ng;
|
||||
sample.Ns = Ns;
|
||||
int matId = data.scene->geometries[ray.geomID]->materialID;
|
||||
unsigned lightID = data.scene->geometries[ray.geomID]->lightID;
|
||||
int matId = data.scene->geometries.at(ray.geomID)->materialID;
|
||||
unsigned lightID = data.scene->geometries.at(ray.geomID)->lightID;
|
||||
sample.Ng = face_forward(ray.dir, normalize(sample.Ng));
|
||||
sample.Ns = face_forward(ray.dir, normalize(sample.Ns));
|
||||
|
||||
|
|
@ -233,7 +236,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
|||
if (id == data.scene->lights.size())
|
||||
id = data.scene->lights.size() - 1;
|
||||
// printf("id: %d\n", id);
|
||||
const Light* l = data.scene->lights[id];
|
||||
const Light* l = data.scene->lights.at(id);
|
||||
|
||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
||||
|
||||
|
|
@ -264,7 +267,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
|||
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
||||
// printf("pdf: %f\n", wi.pdf);
|
||||
|
||||
Lw *= std::pow(M_E, - mu_t * ray.tfar) * diffuse / wi.pdf;
|
||||
Lw *= diffuse / wi.pdf;
|
||||
|
||||
ray = Ray(sample.P,wi.v,EPS,inf);
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ private:
|
|||
|
||||
ImGui::SliderFloat("mu_a", &mu_a, 0.0, 1.0);
|
||||
ImGui::SliderFloat("mu_s", &mu_s, 0.0, 1.0);
|
||||
ImGui::SliderFloat("scattering parameter", &scattering_parameter, 0.0, 1.0);
|
||||
ImGui::SliderFloat("scattering parameter", &scattering_parameter, -1.0, 1.0);
|
||||
|
||||
const char* scenes[] = {"Gnome", "Horse", "Heterogenous"};
|
||||
int oldscene = scene;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue