Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Lightmap] Bake Tool #457

Open
T-rvw opened this issue Jan 31, 2024 · 7 comments
Open

[Lightmap] Bake Tool #457

T-rvw opened this issue Jan 31, 2024 · 7 comments
Assignees

Comments

@T-rvw
Copy link
Contributor

T-rvw commented Jan 31, 2024

@T-rvw
Copy link
Contributor Author

T-rvw commented Jan 31, 2024

Lightmap meets with NormalMap to get better surface details in indirect light. Use half life 2's 3 basis's solution to blend irradiance values at runtime.

image

@T-rvw
Copy link
Contributor Author

T-rvw commented Jan 31, 2024

Indirect + Direct Lighting Diffuse:
image

Direct Lighting Diffuse:
image

Indirect Lighting Diffuse:
image

@T-rvw
Copy link
Contributor Author

T-rvw commented Jan 31, 2024

@Hinageshi01 You can play with MJP's BakingLab. I got some basic knowledges about baking lightmap implementation.

@T-rvw
Copy link
Contributor Author

T-rvw commented Feb 1, 2024

  • Generate LightmapUV for multiple scene objects to share one lightmap texture
    • XAtlas Implementation
      • For model's every mesh, do below task in parallel
        • Then it will build mesh faces to different groups in MeshFaceGroups::compute()
          • Loop every face
            • Loop face's all adjacent faces if valid. Create a queue container. Init it with current face.
            • Loop every non-unboundary edge belong to the container's first face(pop up)
              • Query current edge's opposite face. If opposite face's material is not same with face, don't put in same group.
              • Skip if opposite face already put in a group.
              • Record face loop order.
              • Add valid opposite faces to previous created queue container.
        • After split faces into different groups considered connections + same materials, we define group number as UV Charts group count
        • Record invalid faces' information such as indexes.
        • Sort all UV Charts group by every Charts group's face number. RadixSort is used here which is widely-used parallel sort algorithm.
        • For every Charts group, do below task in parallel.
          • ChartGroup::computeCharts
            • For every Chart, parameterize it in PiecewiseParam::computeChart.

@Hinageshi01
Copy link
Contributor

Hinageshi01 commented Feb 20, 2024

  1. Generate UV for all meshes
  2. Baking
    • Generate light map
      • UV space rasterization
        • OUT.Position = float4(IN.LightmapUV * 2 - 1, 0, 1);
      • Padding
        • for every empty background pixel, it simply looks at 8 neighbours around it and copies the first non-empty value value it finds.
      • Conservative rasterization, post-padding is not enough for small triangle
        • Repurposing MSAA samples
        • Rendering geometry multiple times with sub-pixel offset √
        • Rendering lines over triangles
      • Optimize shadow leaks
        • push sample points out of shadowed areas where leaks can occur
      • Optimize shadow terminator
        • Adding constant bias to ray start
        • Making shadow rays ignore adjacent faces that are almost coplanar
        • Tessellating/smoothing geometry before ray-tracing
        • Blurring the result
        • Tamy Boubekeur and Marc Alexa. 2008. Phong Tessellation.
          • Determines if the smooth position intersects another surface
          • If any fragment on a triangle intersects another surface, all fragments on the entire triangle should use the flat position
      • Beware of weird triangles with 2 normals pointing out, and one in
      • Fixing UV seams
        • Not quite sure how this works
    • Trace rays
      • OptiX, RadeonRays, DXR
      • UV GBuffer
        • rasterize surface attributes like above
      • Ray bias, to prevent noisy self-overlapping due to floating-point inaccuracy
        • position += sign(normal) * abs(position * 0.0000002)
  3. Some little optimization
    • Denoising
      • Optix AI denoiser
        • Must before UV seam fixing
        • Maybe something like reversible tonemapping is needed to ensure that the input to the denoiser is non-HDR
    • Bicubic interpolation
      • Not quite sure how this works
    • lightmap mip map?

@Hinageshi01
Copy link
Contributor

Solution from Precomputed Global Illumination in Frostbite
Store L1 SH for every texel.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants