Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

990 B
Raw Blame
def write_bytes(file, source):
    with open(source.path, mode="rb") as binary:
        buffer = binary.read()
        buffer = buffer[148:]  # skip .dds header

        file.write(f"0x{buffer[0]:02x}")
        for byte in range(1, len(buffer)):
            file.write(f",0x{buffer[byte]:02x}")


def run(target, source, env):
    with open(str(target[0]), "w", encoding="utf-8", newline="\n") as file:
        file.write(f'/* WARNING, THIS FILE WAS GENERATED BY THE "{source[0].name}" SCRIPT, DO NOT EDIT */ \n\n')

        file.write(
            "// LTC Lookup table for BRDF fitting by Eric Heitz (https://eheitzresearch.wordpress.com/415-2/) \n"
        )
        file.write("constexpr int LTC_LUT_DIMENSIONS = 64; // 64x64\n")
        file.write("inline constexpr uint8_t LTC_LUT1[] = {")
        write_bytes(file, source[1])
        file.write("};\n\n")

        file.write("inline constexpr uint8_t LTC_LUT2[] = {")
        write_bytes(file, source[2])
        file.write("};\n\n")