Skip to content

Latest commit

 

History

History
89 lines (69 loc) · 3.43 KB

README.md

File metadata and controls

89 lines (69 loc) · 3.43 KB

Radiance HDR for Unity

openupm GitHub issues GitHub license

This package enables the ability to load Radiance HDR (RGBE) images at runtime in Unity. We support RLE and non-RLE encoded images.

Installing

The easiest way to install is to download and open the Installer Package.

It runs a script that installs the package via a scoped registry.

Afterwards, Radiance HDR for Unity is listed in thePackage Manager (under My Registries) and can be installed and updated from there.

Alternative: Install via GIT URL Add Radiance HDR for Unity via Unity's Package Manager ( Window -> Package Manager ). Click the ➕ on the top left and choose *Add package from GIT URL*.

Enter the following URL: https://github.com/superla-play/RadianceHDRUnity.git#upm


Usage

// Make sure to include the namespace!
using Superla.RadianceHDR;

...
// Load the image however you like in the form of a byte array, be it from
// streaming assets or from the web, etc.
UnityWebRequest www = UnityWebRequest.Get("path/to/image.hdr");
www.downloadHandler = new DownloadHandlerBuffer();
var asyncOp = www.SendWebRequest();
while (!asyncOp.isDone)
{
    await Task.Yield();
}
byte[] imageData = www.downloadHandler.data;

// Pass the byte array to the constructor.
RadianceHDRTexture hdr = new RadianceHDRTexture(imageData);

// Retrieve the generated texture.
Texture2D texture = hdr.texture;

Motivation

During the course of development for other Unity-based projects, we regularly used HDR images for background and lighting purposes in our scenes. Unity handles editor-time import of HDR images without hassle. While exploring options for user-customisable content, we were surprised to find the engine did not support runtime loading of HDR images. We decided that needed to be changed!

Acknowlegements

Radiance HDR for Unity was inspired by the excellent three.js and it's RGBELoader, which was in turn adapted from Bruce Walter's C Loader for RGBE.

License

Copyright (c) 2022-2024 Superla.tv, All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use files in this repository except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Trademarks

Unity is a registered trademark of Unity Technologies.