fabmax / kool

An OpenGL / WebGPU engine for Desktop JVM, Android and Javascript written in Kotlin
https://fabmax.github.io/kool/kool-js
Apache License 2.0
273 stars 16 forks source link

Question: What is the hdri environment image encoding type ? #30

Closed Protoxy22 closed 1 year ago

Protoxy22 commented 1 year ago

Hi, I would like to render an hdri sky environment on my scene but I don't understand the format of the image used on the demo. How can I generate them ? Thank you

fabmax commented 1 year ago

The HDRIs are in the RGBe format, which stores HDR image information in regular 8-bit color channels (by using the alpha channel as a per-pixel exponent). I thought there were web-based conversion-utils but I wasn't able to quickly find one, so I added my conversion code for the jvm platform.

It should be straightforward to convert a regular hdri with it:

fun main() {
    val inputFile = File("path/to/inputImage.hdr")
    val outputFile = File("path/to/outputImage.rgbe.png")
    val rgbeImage = HdrImageConversion.convertHdrImageToRgbe(inputFile)
    ImageIO.write(rgbeImage, "png", outputFile)
}

A good source to find more HDRIs is Poly Haven

Protoxy22 commented 1 year ago

Amazing, thanks !