Fix old applications with new framework.
This commit is contained in:
parent
fe92493afd
commit
262c9f3635
4 changed files with 54 additions and 56 deletions
|
|
@ -73,7 +73,7 @@ void Application1::veachScene() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function that selects implementation at runtime
|
// Function that selects implementation at runtime
|
||||||
Vec3fa Application1::renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application1::renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
if (selected == 0) {
|
if (selected == 0) {
|
||||||
return renderPixelOrig(x, y, camera, stats, sampler);
|
return renderPixelOrig(x, y, camera, stats, sampler);
|
||||||
} else if (selected == 1) {
|
} else if (selected == 1) {
|
||||||
|
|
@ -87,7 +87,7 @@ Vec3fa Application1::renderPixel(float x, float y, const ISPCCamera& camera, Ray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3fa Application1::renderPixelMIS(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application1::renderPixelMIS(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
/* radiance accumulator and weight */
|
/* radiance accumulator and weight */
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -166,12 +166,12 @@ Vec3fa Application1::renderPixelMIS(float x, float y, const ISPCCamera& camera,
|
||||||
Material__preprocess(material_array, matId, brdf, wo, sample);
|
Material__preprocess(material_array, matId, brdf, wo, sample);
|
||||||
|
|
||||||
/* Light ray */
|
/* Light ray */
|
||||||
int id = (int)(RandomSampler_get1D(sampler) * data.scene->lights.size());
|
int id = (int)(sampler.get1D() * data.scene->lights.size());
|
||||||
if (id == data.scene->lights.size())
|
if (id == data.scene->lights.size())
|
||||||
id = data.scene->lights.size() - 1;
|
id = data.scene->lights.size() - 1;
|
||||||
const Light* l = data.scene->lights[id];
|
const Light* l = data.scene->lights[id];
|
||||||
|
|
||||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
Light_SampleRes ls = Lights_sample(l, sample, sampler.get2D());
|
||||||
|
|
||||||
Vec3fa light_diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
Vec3fa light_diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
||||||
|
|
||||||
|
|
@ -207,7 +207,7 @@ Vec3fa Application1::renderPixelMIS(float x, float y, const ISPCCamera& camera,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use cosine sampling
|
// Use cosine sampling
|
||||||
Vec2f uv = RandomSampler_get2D(sampler);
|
Vec2f uv = sampler.get2D();
|
||||||
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
||||||
|
|
||||||
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
||||||
|
|
@ -222,7 +222,7 @@ Vec3fa Application1::renderPixelMIS(float x, float y, const ISPCCamera& camera,
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3fa Application1::renderPixelNextEventEstimation(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application1::renderPixelNextEventEstimation(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
/* radiance accumulator and weight */
|
/* radiance accumulator and weight */
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -274,12 +274,12 @@ Vec3fa Application1::renderPixelNextEventEstimation(float x, float y, const ISPC
|
||||||
Material__preprocess(material_array, matId, brdf, wo, sample);
|
Material__preprocess(material_array, matId, brdf, wo, sample);
|
||||||
|
|
||||||
/* Light ray */
|
/* Light ray */
|
||||||
int id = (int)(RandomSampler_get1D(sampler) * data.scene->lights.size());
|
int id = (int)(sampler.get1D() * data.scene->lights.size());
|
||||||
if (id == data.scene->lights.size())
|
if (id == data.scene->lights.size())
|
||||||
id = data.scene->lights.size() - 1;
|
id = data.scene->lights.size() - 1;
|
||||||
const Light* l = data.scene->lights[id];
|
const Light* l = data.scene->lights[id];
|
||||||
|
|
||||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
Light_SampleRes ls = Lights_sample(l, sample, sampler.get2D());
|
||||||
|
|
||||||
Vec3fa light_diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
Vec3fa light_diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
||||||
|
|
||||||
|
|
@ -302,7 +302,7 @@ Vec3fa Application1::renderPixelNextEventEstimation(float x, float y, const ISPC
|
||||||
|
|
||||||
|
|
||||||
// Use cosine sampling
|
// Use cosine sampling
|
||||||
Vec2f uv = RandomSampler_get2D(sampler);
|
Vec2f uv = sampler.get2D();
|
||||||
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
||||||
|
|
||||||
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
||||||
|
|
@ -317,7 +317,7 @@ Vec3fa Application1::renderPixelNextEventEstimation(float x, float y, const ISPC
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Vec3fa Application1::renderPixelPathTracer(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application1::renderPixelPathTracer(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
/* radiance accumulator and weight */
|
/* radiance accumulator and weight */
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -368,7 +368,7 @@ Vec3fa Application1::renderPixelPathTracer(float x, float y, const ISPCCamera& c
|
||||||
|
|
||||||
|
|
||||||
// Use cosine sampling
|
// Use cosine sampling
|
||||||
Vec2f uv = RandomSampler_get2D(sampler);
|
Vec2f uv = sampler.get2D();
|
||||||
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
||||||
|
|
||||||
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
||||||
|
|
@ -383,7 +383,7 @@ Vec3fa Application1::renderPixelPathTracer(float x, float y, const ISPCCamera& c
|
||||||
}
|
}
|
||||||
|
|
||||||
/* task that renders a single screen tile (original implementation) */
|
/* task that renders a single screen tile (original implementation) */
|
||||||
Vec3fa Application1::renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application1::renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
/* radiance accumulator and weight */
|
/* radiance accumulator and weight */
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -427,14 +427,14 @@ Vec3fa Application1::renderPixelOrig(float x, float y, const ISPCCamera& camera,
|
||||||
|
|
||||||
/* sample BRDF at hit point */
|
/* sample BRDF at hit point */
|
||||||
// Sample3f wi1;
|
// Sample3f wi1;
|
||||||
// Material__sample(material_array, matId, brdf, Lw, wo, sample, wi1, RandomSampler_get2D(sampler));
|
// Material__sample(material_array, matId, brdf, Lw, wo, sample, wi1, RandomSamplerWrapper_get2D(sampler));
|
||||||
|
|
||||||
int id = (int)(RandomSampler_get1D(sampler) * data.scene->lights.size());
|
int id = (int)(sampler.get1D() * data.scene->lights.size());
|
||||||
if (id == data.scene->lights.size())
|
if (id == data.scene->lights.size())
|
||||||
id = data.scene->lights.size() - 1;
|
id = data.scene->lights.size() - 1;
|
||||||
const Light* l = data.scene->lights[id];
|
const Light* l = data.scene->lights[id];
|
||||||
|
|
||||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
Light_SampleRes ls = Lights_sample(l, sample, sampler.get2D());
|
||||||
|
|
||||||
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vec3fa renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) override;
|
Vec3fa renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) override;
|
||||||
Vec3fa renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
Vec3fa renderPixelPathTracer(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelPathTracer(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
Vec3fa renderPixelNextEventEstimation(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelNextEventEstimation(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
Vec3fa renderPixelMIS(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelMIS(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
|
|
||||||
void drawGUI() override {
|
void drawGUI() override {
|
||||||
ImGui::InputInt("Ray depth", &ray_depth);
|
ImGui::InputInt("Ray depth", &ray_depth);
|
||||||
|
|
|
||||||
|
|
@ -134,7 +134,7 @@ Sample createSample(Ray &ray) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Function that selects implementation at runtime
|
// Function that selects implementation at runtime
|
||||||
Vec3fa Application2::renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application2::renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
if (selected == 0) {
|
if (selected == 0) {
|
||||||
return renderPixelOrig(x, y, camera, stats, sampler);
|
return renderPixelOrig(x, y, camera, stats, sampler);
|
||||||
} else if (selected == 1) {
|
} else if (selected == 1) {
|
||||||
|
|
@ -148,7 +148,7 @@ Vec3fa Application2::renderPixel(float x, float y, const ISPCCamera& camera, Ray
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
|
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -177,7 +177,7 @@ Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCam
|
||||||
t = inf;
|
t = inf;
|
||||||
} else {
|
} else {
|
||||||
// printf("%f\n", density);
|
// printf("%f\n", density);
|
||||||
t = - std::log(1.0 - RandomSampler_get1D(sampler)) / max_density;
|
t = - std::log(1.0 - sampler.get1D()) / max_density;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t > 0.0 && t < ray.tfar) {
|
if (t > 0.0 && t < ray.tfar) {
|
||||||
|
|
@ -187,7 +187,7 @@ Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCam
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
float r = RandomSampler_get1D(sampler);
|
float r = sampler.get1D();
|
||||||
Vec3fa p = ray.org + t * ray.dir;
|
Vec3fa p = ray.org + t * ray.dir;
|
||||||
// printf("%f\t%f\t(%f,%f,%f)\n", t, ray.tfar, p.x, p.y, p.z);
|
// printf("%f\t%f\t(%f,%f,%f)\n", t, ray.tfar, p.x, p.y, p.z);
|
||||||
float s = data.densityGrid->sampleW(p);
|
float s = data.densityGrid->sampleW(p);
|
||||||
|
|
@ -198,10 +198,10 @@ Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCam
|
||||||
// printf("(%f,%f,%f)\tr: %f\t%f\ts: %f\t%f\tp:%f\n",p.x, p.y, p.z , r, r * max_density, s, s * density, (s * density) / max_density);
|
// printf("(%f,%f,%f)\tr: %f\t%f\ts: %f\t%f\tp:%f\n",p.x, p.y, p.z , r, r * max_density, s, s * density, (s * density) / max_density);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (RandomSampler_get1D(sampler) * max_density < s * density) {
|
if (sampler.get1D() * max_density < s * density) {
|
||||||
|
|
||||||
// NEE
|
// NEE
|
||||||
int id = (int)(RandomSampler_get1D(sampler) * data.scene->lights.size());
|
int id = (int)(sampler.get1D() * data.scene->lights.size());
|
||||||
if (id == data.scene->lights.size())
|
if (id == data.scene->lights.size())
|
||||||
id = data.scene->lights.size() - 1;
|
id = data.scene->lights.size() - 1;
|
||||||
const Light* l = data.scene->lights.at(id);
|
const Light* l = data.scene->lights.at(id);
|
||||||
|
|
@ -210,7 +210,7 @@ Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCam
|
||||||
sample.Ng = ray.dir;
|
sample.Ng = ray.dir;
|
||||||
sample.Ns = ray.dir;
|
sample.Ns = ray.dir;
|
||||||
|
|
||||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
Light_SampleRes ls = Lights_sample(l, sample, sampler.get2D());
|
||||||
|
|
||||||
/* initialize shadow ray */
|
/* initialize shadow ray */
|
||||||
Ray shadow(sample.P, ls.dir, EPS, ls.dist - EPS, 0.0f);
|
Ray shadow(sample.P, ls.dir, EPS, ls.dist - EPS, 0.0f);
|
||||||
|
|
@ -227,7 +227,7 @@ Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCam
|
||||||
float nee_T = 1.0;
|
float nee_T = 1.0;
|
||||||
float nee_t = 0.0;
|
float nee_t = 0.0;
|
||||||
while (1) {
|
while (1) {
|
||||||
float r = RandomSampler_get1D(sampler);
|
float r = sampler.get1D();
|
||||||
|
|
||||||
nee_t -= std::log(1 - r) / max_density;
|
nee_t -= std::log(1 - r) / max_density;
|
||||||
|
|
||||||
|
|
@ -247,7 +247,7 @@ Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCam
|
||||||
|
|
||||||
|
|
||||||
float pdf;
|
float pdf;
|
||||||
Vec3fa o = sample_phase_function(-ray.dir, scattering_parameter, RandomSampler_get2D(sampler), pdf);
|
Vec3fa o = sample_phase_function(-ray.dir, scattering_parameter, sampler.get2D(), pdf);
|
||||||
|
|
||||||
float temp = data.tempGrid->sampleW(p); // Sample density from the grid
|
float temp = data.tempGrid->sampleW(p); // Sample density from the grid
|
||||||
// float temp = 20;
|
// float temp = 20;
|
||||||
|
|
@ -310,7 +310,7 @@ Vec3fa Application2::renderPixelHeterogeneousNEE(float x, float y, const ISPCCam
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3fa Application2::renderPixelHeterogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application2::renderPixelHeterogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
|
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -339,7 +339,7 @@ Vec3fa Application2::renderPixelHeterogeneous(float x, float y, const ISPCCamera
|
||||||
t = inf;
|
t = inf;
|
||||||
} else {
|
} else {
|
||||||
// printf("%f\n", density);
|
// printf("%f\n", density);
|
||||||
t = - std::log(1.0 - RandomSampler_get1D(sampler)) / max_density;
|
t = - std::log(1.0 - sampler.get1D()) / max_density;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t > 0.0 && t < ray.tfar) {
|
if (t > 0.0 && t < ray.tfar) {
|
||||||
|
|
@ -350,7 +350,7 @@ Vec3fa Application2::renderPixelHeterogeneous(float x, float y, const ISPCCamera
|
||||||
// return Vec3fa(0.0, 0.0, 10.0);
|
// return Vec3fa(0.0, 0.0, 10.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
float r = RandomSampler_get1D(sampler);
|
float r = sampler.get1D();
|
||||||
Vec3fa p = ray.org + t * ray.dir;
|
Vec3fa p = ray.org + t * ray.dir;
|
||||||
// printf("%f\t%f\t(%f,%f,%f)\n", t, ray.tfar, p.x, p.y, p.z);
|
// printf("%f\t%f\t(%f,%f,%f)\n", t, ray.tfar, p.x, p.y, p.z);
|
||||||
float s = data.densityGrid->sampleW(p);
|
float s = data.densityGrid->sampleW(p);
|
||||||
|
|
@ -361,11 +361,11 @@ Vec3fa Application2::renderPixelHeterogeneous(float x, float y, const ISPCCamera
|
||||||
// printf("(%f,%f,%f)\tr: %f\t%f\ts: %f\t%f\tp:%f\n",p.x, p.y, p.z , r, r * max_density, s, s * density, (s * density) / max_density);
|
// printf("(%f,%f,%f)\tr: %f\t%f\ts: %f\t%f\tp:%f\n",p.x, p.y, p.z , r, r * max_density, s, s * density, (s * density) / max_density);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
if (RandomSampler_get1D(sampler) * max_density < s * density) {
|
if (sampler.get1D() * max_density < s * density) {
|
||||||
|
|
||||||
|
|
||||||
float pdf;
|
float pdf;
|
||||||
Vec3fa o = sample_phase_function(-ray.dir, scattering_parameter, RandomSampler_get2D(sampler), pdf);
|
Vec3fa o = sample_phase_function(-ray.dir, scattering_parameter, sampler.get2D(), pdf);
|
||||||
|
|
||||||
float temp = data.tempGrid->sampleW(p); // Sample density from the grid
|
float temp = data.tempGrid->sampleW(p); // Sample density from the grid
|
||||||
// float temp = 20;
|
// float temp = 20;
|
||||||
|
|
@ -425,7 +425,7 @@ Vec3fa Application2::renderPixelHeterogeneous(float x, float y, const ISPCCamera
|
||||||
return L;
|
return L;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
/* radiance accumulator and weight */
|
/* radiance accumulator and weight */
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -452,7 +452,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
||||||
t = inf;
|
t = inf;
|
||||||
} else {
|
} else {
|
||||||
// printf("%f\n", density);
|
// printf("%f\n", density);
|
||||||
t = - std::log(1.0 - RandomSampler_get1D(sampler)) / density;
|
t = - std::log(1.0 - sampler.get1D()) / density;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (t != t | t <= 0) {
|
// if (t != t | t <= 0) {
|
||||||
|
|
@ -465,7 +465,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
||||||
// Nee
|
// Nee
|
||||||
/* Light ray */
|
/* Light ray */
|
||||||
// return {0.0, 0.0, 1.0};
|
// return {0.0, 0.0, 1.0};
|
||||||
int id = (int)(RandomSampler_get1D(sampler) * data.scene->lights.size());
|
int id = (int)(sampler.get1D() * data.scene->lights.size());
|
||||||
if (id == data.scene->lights.size())
|
if (id == data.scene->lights.size())
|
||||||
id = data.scene->lights.size() - 1;
|
id = data.scene->lights.size() - 1;
|
||||||
const Light* l = data.scene->lights.at(id);
|
const Light* l = data.scene->lights.at(id);
|
||||||
|
|
@ -474,7 +474,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
||||||
sample.Ng = ray.dir;
|
sample.Ng = ray.dir;
|
||||||
sample.Ns = ray.dir;
|
sample.Ns = ray.dir;
|
||||||
|
|
||||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
Light_SampleRes ls = Lights_sample(l, sample, sampler.get2D());
|
||||||
|
|
||||||
/* initialize shadow ray */
|
/* initialize shadow ray */
|
||||||
Ray shadow(sample.P, ls.dir, EPS, ls.dist - EPS, 0.0f);
|
Ray shadow(sample.P, ls.dir, EPS, ls.dist - EPS, 0.0f);
|
||||||
|
|
@ -550,7 +550,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
||||||
// new direction
|
// new direction
|
||||||
|
|
||||||
float pdf;
|
float pdf;
|
||||||
Vec3fa o = sample_phase_function(-ray.dir, scattering_parameter, RandomSampler_get2D(sampler), pdf);
|
Vec3fa o = sample_phase_function(-ray.dir, scattering_parameter, sampler.get2D(), pdf);
|
||||||
|
|
||||||
Lw *= 1.0 - absorbtion;
|
Lw *= 1.0 - absorbtion;
|
||||||
|
|
||||||
|
|
@ -590,13 +590,13 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/* Light ray */
|
/* Light ray */
|
||||||
int id = (int)(RandomSampler_get1D(sampler) * data.scene->lights.size());
|
int id = (int)(sampler.get1D() * data.scene->lights.size());
|
||||||
if (id == data.scene->lights.size())
|
if (id == data.scene->lights.size())
|
||||||
id = data.scene->lights.size() - 1;
|
id = data.scene->lights.size() - 1;
|
||||||
// printf("id: %d\n", id);
|
// printf("id: %d\n", id);
|
||||||
const Light* l = data.scene->lights.at(id);
|
const Light* l = data.scene->lights.at(id);
|
||||||
|
|
||||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
Light_SampleRes ls = Lights_sample(l, sample, sampler.get2D());
|
||||||
|
|
||||||
Vec3fa light_diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
Vec3fa light_diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
||||||
|
|
||||||
|
|
@ -669,7 +669,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
||||||
|
|
||||||
|
|
||||||
// Use cosine sampling
|
// Use cosine sampling
|
||||||
Vec2f uv = RandomSampler_get2D(sampler);
|
Vec2f uv = sampler.get2D();
|
||||||
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
Sample3f wi = cosineSampleHemisphere(uv.x, uv.y, sample.Ng);
|
||||||
|
|
||||||
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, wi.v);
|
||||||
|
|
@ -687,7 +687,7 @@ Vec3fa Application2::renderPixelHomogeneous(float x, float y, const ISPCCamera&
|
||||||
}
|
}
|
||||||
|
|
||||||
/* task that renders a single screen tile */
|
/* task that renders a single screen tile */
|
||||||
Vec3fa Application2::renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) {
|
Vec3fa Application2::renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) {
|
||||||
/* radiance accumulator and weight */
|
/* radiance accumulator and weight */
|
||||||
Vec3fa L = Vec3fa(0.0f);
|
Vec3fa L = Vec3fa(0.0f);
|
||||||
Vec3fa Lw = Vec3fa(1.0f);
|
Vec3fa Lw = Vec3fa(1.0f);
|
||||||
|
|
@ -769,7 +769,7 @@ Vec3fa Application2::renderPixelOrig(float x, float y, const ISPCCamera& camera,
|
||||||
// HG phase function
|
// HG phase function
|
||||||
float p = phase(g, angle);
|
float p = phase(g, angle);
|
||||||
float pdf;
|
float pdf;
|
||||||
Vec3f dir = sample_phase_function(-ray.org, g, RandomSampler_get2D(sampler), pdf);
|
Vec3f dir = sample_phase_function(-ray.org, g, sampler.get2D(), pdf);
|
||||||
|
|
||||||
// if -1.0 it means that we're out of the bounding box of the grid
|
// if -1.0 it means that we're out of the bounding box of the grid
|
||||||
if (density != -1.0f) {
|
if (density != -1.0f) {
|
||||||
|
|
@ -813,14 +813,14 @@ Vec3fa Application2::renderPixelOrig(float x, float y, const ISPCCamera& camera,
|
||||||
} else {
|
} else {
|
||||||
/* sample BRDF at hit point */
|
/* sample BRDF at hit point */
|
||||||
Sample3f wi1;
|
Sample3f wi1;
|
||||||
Material__sample(material_array, matId, brdf, Lw, wo, sample, wi1, RandomSampler_get2D(sampler));
|
Material__sample(material_array, matId, brdf, Lw, wo, sample, wi1, sampler.get2D());
|
||||||
|
|
||||||
int id = (int) (RandomSampler_get1D(sampler) * data.scene->lights.size());
|
int id = (int) (sampler.get1D() * data.scene->lights.size());
|
||||||
if (id == data.scene->lights.size())
|
if (id == data.scene->lights.size())
|
||||||
id = data.scene->lights.size() - 1;
|
id = data.scene->lights.size() - 1;
|
||||||
const Light* l = data.scene->lights[id];
|
const Light* l = data.scene->lights[id];
|
||||||
|
|
||||||
Light_SampleRes ls = Lights_sample(l, sample, RandomSampler_get2D(sampler));
|
Light_SampleRes ls = Lights_sample(l, sample, sampler.get2D());
|
||||||
|
|
||||||
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
Vec3fa diffuse = Material__eval(material_array, matId, brdf, wo, sample, ls.dir);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "application.h"
|
||||||
#include "helper.hpp"
|
#include "helper.hpp"
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "math/vec3fa.h"
|
#include "math/vec3fa.h"
|
||||||
|
|
@ -10,11 +11,11 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Vec3fa renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler) override;
|
Vec3fa renderPixel(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler) override;
|
||||||
Vec3fa renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelOrig(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
Vec3fa renderPixelHomogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelHomogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
Vec3fa renderPixelHeterogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelHeterogeneous(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
Vec3fa renderPixelHeterogeneousNEE(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSampler& sampler);
|
Vec3fa renderPixelHeterogeneousNEE(float x, float y, const ISPCCamera& camera, RayStats& stats, RandomSamplerWrapper& sampler);
|
||||||
|
|
||||||
void drawGUI() override {
|
void drawGUI() override {
|
||||||
ImGui::Checkbox("Bounding Box", &boundingBox);
|
ImGui::Checkbox("Bounding Box", &boundingBox);
|
||||||
|
|
@ -55,10 +56,7 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() {
|
void clear() {
|
||||||
data.accu_count = 0;;
|
Application::resetRender();
|
||||||
for (size_t i = 0; i < data.accu_width * data.accu_height; i++) {
|
|
||||||
data.accu[i] = Vec3fx(0.0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void initScene() override;
|
void initScene() override;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue