INNER CODE UNIT · Python
interleaved
SedulousWorks/SedulousEngine · Scripts/generate_brdf_lut.py:139
interleaved = np.stack([scale_u16, bias_u16], axis=-1) # [SIZE, SIZE, 2]
return interleaved.tobytes()
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")