Add albedo output to the raytracer
This commit is contained in:
parent
bafe6a7f43
commit
3d09f86258
4 changed files with 21 additions and 9 deletions
|
|
@ -45,6 +45,7 @@ using namespace tp;
|
|||
|
||||
void RayTracer::castRay(const Ray& ray, RayCastData& out, alnf farVal) {
|
||||
out.hit = false;
|
||||
out.obj = nullptr;
|
||||
|
||||
farVal *= farVal;
|
||||
|
||||
|
|
@ -120,6 +121,7 @@ void RayTracer::render(const Scene& scene, OutputBuffers& out, const RenderSetti
|
|||
out.color.reserve({ settings.size.x, settings.size.y });
|
||||
out.normals.reserve({ settings.size.x, settings.size.y });
|
||||
out.depth.reserve({ settings.size.x, settings.size.y });
|
||||
out.albedo.reserve({ settings.size.x, settings.size.y });
|
||||
|
||||
mScene = &scene;
|
||||
mSettings = settings;
|
||||
|
|
@ -169,6 +171,7 @@ void RayTracer::render(const Scene& scene, OutputBuffers& out, const RenderSetti
|
|||
out.color.set({ i, j }, 0.f);
|
||||
out.normals.set({ i, j }, 0.f);
|
||||
out.depth.set({ i, j }, 0.f);
|
||||
out.albedo.set({ i, j }, 0.f);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -183,6 +186,13 @@ void RayTracer::render(const Scene& scene, OutputBuffers& out, const RenderSetti
|
|||
|
||||
castRay(ray, castData, mScene->mCamera.getFar());
|
||||
|
||||
halni albedoColor = abs(hash((ualni) castData.obj));
|
||||
halnf albedoColorR = float((albedoColor & 0x00000011) % 155) + 100;
|
||||
halnf albedoColorG = float((albedoColor & 0x00001100) % 155) + 100;
|
||||
halnf albedoColorB = float((albedoColor & 0x00110000) % 155) + 100;
|
||||
|
||||
out.albedo.set({ i, j }, { albedoColorR, albedoColorG, albedoColorB, 1.f });
|
||||
|
||||
if (castData.hit) {
|
||||
LightData lightData;
|
||||
cycle(castData, lightData, mSettings.depth);
|
||||
|
|
@ -198,9 +208,9 @@ void RayTracer::render(const Scene& scene, OutputBuffers& out, const RenderSetti
|
|||
accumulateColor(out.depth.get({ i, j }), { depth, depth, depth, 1.f });
|
||||
|
||||
} else {
|
||||
out.color.set({ i, j }, 0.f);
|
||||
out.normals.set({ i, j }, 0.f);
|
||||
out.depth.set({ i, j }, 0.f);
|
||||
// out.color.set({ i, j }, 0.f);
|
||||
// out.normals.set({ i, j }, 0.f);
|
||||
// out.depth.set({ i, j }, 0.f);
|
||||
}
|
||||
|
||||
// auto tmp = buff.get({i, j});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue