alipbcs / ZetaRay

Real-time Direct3D 12 path tracer
MIT License
265 stars 7 forks source link

Custom GLTF model loads successfully but renders as black #15

Open L1uyu opened 19 hours ago

L1uyu commented 19 hours ago

I downloaded a GLTF scene from Sketchfab and preprocessed it using the texture tool. The model files can be found here: https://drive.google.com/file/d/1jYqCtRXU_7X5Kn6SAlgw7_LeuJweJP2m/view?usp=sharing The GLTF file loads correctly - the model outline and textures appear fine when viewing the base color. However, the model renders completely black when using the default display mode. Here are some screenshots demonstrating the issue: image image image image Could you please help me identify and debug the potential issue?

alipbcs commented 15 hours ago

Currently, the supported light source types are sun and sky or emissive materials. When the scene has emissive materials, they act as the only light sources. If there are no emissives, then the sun and sky are the light sources.

In this scene, there's only one node with an emissive material called "BLK01_ROAD.002_7", which uses the material called "light" (screenshot attached). The default strength was a bit low, but after increasing it, the scene looks more reasonable. Note that you can change the material properties by first clicking on each object and then modifying the properties in the "Material" section of the UI window.

2

Alternatively, you can edit the glTF file to remove the "emissiveFactor" property of "light", which will cause the scene to switch to sun and sky lighting.

1

L1uyu commented 14 hours ago

thanks for your help. It's great to learn from your codebase. I've also found another issue in my lookdev scene. https://drive.google.com/file/d/1WpK63PotGt6G0UPnDVsyVoaUMWWGDM5B/view?usp=sharing image

The accumulative compositing appears to be causing floating-point precision banding artifacts after g_frame.NumFramesCameraStatic exceeds approximately 250 frames if I choose the indirect mode as path tracing or ReSTIR_PT.

image Since 250 frames doesn't seem sufficient for a noise-free result, I'm wondering if there's any way to solve this issue? I've see the compositing.hlsl and ReSTIR_PT_PathTrace.hlsl. Maybe each li should be preprocessed?

alipbcs commented 5 hours ago

Happy to hear you found the code useful!

The banding is expected as I'm using 16-bit float textures to store output colors. Normally, these textures store just the current frame's output and are rewritten in the next frame. However, when the accumulate option is enabled, values are repeatedly added over time and numerical errors accumulate, leading to banding.

The fix is to simply use 32-bit floats for these textures. In the following lines

  1. Source/ZetaRenderPass/DirectLighting/Emissive/DirectLighting.h: 72
  2. Source/ZetaRenderPass/DirectLighting/Sky/SkyDI.h: 62
  3. Source/ZetaRenderPass/IndirectLighting/IndirectLighting.h: 146. 127
  4. Source/ZetaRenderPass/Compositing/Compositing.h: 104

change DXGI_FORMAT_R16G16B16A16_FLOAT to DXGI_FORMAT_R32G32B32A32_FLOAT. That should fix the banding.