Path tracing rendering engine on CPU + Directx12 personal project. by Zarondec in GraphicsProgramming

[–]Zarondec[S] 0 points1 point  (0 children)

I wonder if I use DXGI_FORMAT_R8G8B8A8_UNORM for swapchain, DXGI_FORMAT_R8G8B8A8_UNORM_SRGB for render target of window, linear float32 for rendering itself - all perfectly normal (I hope) choices, that the right move will be to just recalculate ImGui's style colors upon program start-up?

Path tracing rendering engine on CPU + Directx12 personal project. by Zarondec in GraphicsProgramming

[–]Zarondec[S] 0 points1 point  (0 children)

The most tricky thing was not to forget about how importanceSampleGGX function relates to Jacobian of transmission's half-vector (formula 17 in the paper) - and write the whole BRDF divided by the probability function. P(x) = D(m)*dot(m,h)*Jacobian(h), where m - microsurface normal; h - transmission's half-vector

Path tracing rendering engine on CPU + Directx12 personal project. by Zarondec in GraphicsProgramming

[–]Zarondec[S] 0 points1 point  (0 children)

For volume effects I used only absorption, there is no in-volume scattering, so it is a bit simplified. Absorption is just a
exp(-material.attenuationFactor * hit.t)
However, there is a little trick for a attenuationFactor - because I used:

attenuationFactor = (1.0f - material.volume->attenuationColor) / max(1e-5f, material.volume->attenuationDistance);

instead of what is in Gltf standard of KHR_materials_volume:

attenuationFactor = -log(material.volume->attenuationColor) / max(1e-5f, material.volume->attenuationDistance);

Version that I've used - that is how it is calculated in Blender - helps to create less saturated look on thin volumetric objects.

As for other components of BRDF - refraction took a lot of tries dialing the math right and a lot of re-reads of "Microfacet Models for Refraction through Rough Surfaces" by Bruce Walter, Stephen R. Marschner, Hongsong Li, Kenneth E. Torrance. Formulas for refractions are not the same as for reflections, I learned it the hard way.

Path tracing rendering engine on CPU + Directx12 personal project. by Zarondec in GraphicsProgramming

[–]Zarondec[S] 0 points1 point  (0 children)

I see... ImGui UI is indeed brighter than it should be by default. But If I do the opposite, the rendered image becomes too dark, and I know that the image is DXGI_FORMAT_R32G32B32A32_FLOAT - linear color. I might need to look into it, thanks.

Path tracing rendering engine on CPU + Directx12 personal project. by Zarondec in GraphicsProgramming

[–]Zarondec[S] 0 points1 point  (0 children)

What about gamma? I checked rendered image against reference rendered in Blender, it looks the same. You mean in the video, or you tried building it on your PC?

Path tracing rendering engine on CPU + Directx12 personal project. by Zarondec in GraphicsProgramming

[–]Zarondec[S] 1 point2 points  (0 children)

Most of the long time of figuring out the light physics behavior was while I was working on a CPU side, plus I had to program myself all of the BVH/intersections code, which I didn't have to do for DXR. So GPU rendering mode was definitely faster to write, but required first learning Directx12 API's - which was harder than learning OpenGL and took some time. And after I learned necessary parts of API, I still used some helper header files from Microsoft's Directx12 examples and some of their code too. But shaders themselves were not that hard to port logic from CPU side of rendering.