Add albedo output to the raytracer
This commit is contained in:
parent
8bfe44b3cd
commit
3cc8dbc102
4 changed files with 21 additions and 9 deletions
|
|
@ -74,9 +74,10 @@ void renderCommand(const std::string& scenePath) {
|
|||
|
||||
std::cout << "\nRender finished with average render time per sample - " << (end - start) << " (ms)\n";
|
||||
|
||||
writeImage(output.normals, "normals.png");
|
||||
writeImage(output.normals, "normal.png");
|
||||
writeImage(output.color, "color.png");
|
||||
writeImage(output.depth, "depth.png");
|
||||
writeImage(output.albedo, "albedo.png");
|
||||
}
|
||||
|
||||
int main(int argc, const char** argv) {
|
||||
|
|
|
|||
|
|
@ -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});
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ namespace tp {
|
|||
RenderBuffer normals;
|
||||
RenderBuffer color;
|
||||
RenderBuffer depth;
|
||||
RenderBuffer albedo;
|
||||
// albedo, reflectance ...
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue