INNER CODE UNIT · Python

write_bf_file

SedulousWorks/SedulousEngine · Scripts/generate_brdf_lut.py:143

def write_bf_file(data: bytes, output_path: str):
    """Write the BRDF LUT data as a Beef source file."""
    os.makedirs(os.path.dirname(output_path), exist_ok=True)
    with open(output_path, 'w', newline='\n') as f:
        f.write("// AUTO-GENERATED by Scripts/generate_brdf_lut.py - do not edit by hand.\n")
        f.write("// To regenerate: `python Scripts/generate_brdf_lut.py` from the repo root.\n")
        f.write("\n")
        f.write("namespace Sedulous.Renderer.IBL;\n")
        f.write("\n")
        f.write("/// Pre-baked BRDF integration LUT for split-sum image-based lighting.\n")
        f.write(f"/// {SIZE}x{SIZE} RG16Float, {len(data)} bytes total. Uploaded once to a GPU\n")
        f.write("/// texture at renderer init; sampled by the forward shader for indirect\n")
        f.write("/// specular: `specular = prefilteredColor * (F0 * lut.r + lut.g)`.\n")
        f.write("///\n")
        f.write("/// Row layout: Y = roughness [0,1], X = NdotV [0,1].\n")
        f.write(f"/// Algorithm: GGX importance sampling, {NUM_SAMPLES} samples per texel.\n")
        f.write("static class BRDFLutData\n")
        f.write("{\n")

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…