All Projects → Hyper3D → Hyper3d Envmapgen

Hyper3D / Hyper3d Envmapgen

Licence: mit
Pre-filtered mipmapped radiance environment map generator that runs on WebAssembly.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Hyper3d Envmapgen

Magnum Examples
Examples for the Magnum C++11/C++14 graphics engine
Stars: ✭ 180 (+133.77%)
Mutual labels:  webgl, webassembly
Flvplayer
🍭 FlvPlayer.js is a JavaScript player for decode flv to the canvas
Stars: ✭ 210 (+172.73%)
Mutual labels:  webgl, webassembly
Unity Webxr Export
Develop and export WebXR experiences using Unity WebGL
Stars: ✭ 130 (+68.83%)
Mutual labels:  webgl, webassembly
Magnum Bootstrap
Bootstrap projects for Magnum C++11/C++14 graphics engine
Stars: ✭ 69 (-10.39%)
Mutual labels:  webgl, webassembly
Unrust
unrust - A pure rust based (webgl 2.0 / native) game engine
Stars: ✭ 341 (+342.86%)
Mutual labels:  webgl, webassembly
Glas
WebGL in WebAssembly with AssemblyScript
Stars: ✭ 278 (+261.04%)
Mutual labels:  webgl, webassembly
Sandspiel
Creative cellular automata browser game
Stars: ✭ 2,476 (+3115.58%)
Mutual labels:  webgl, webassembly
Gltfpp
glTF 2.0 loader for C++14
Stars: ✭ 22 (-71.43%)
Mutual labels:  webgl, webassembly
Magnum
Lightweight and modular C++11 graphics middleware for games and data visualization
Stars: ✭ 3,728 (+4741.56%)
Mutual labels:  webgl, webassembly
Jessibuca
Jessibuca是一款开源的纯H5直播流播放器
Stars: ✭ 301 (+290.91%)
Mutual labels:  webgl, webassembly
Glchaos.p
3D GPUs Strange Attractors and Hypercomplex Fractals explorer - up to 256 Million particles in RealTime
Stars: ✭ 590 (+666.23%)
Mutual labels:  webgl, webassembly
Magnum Plugins
Plugins for the Magnum C++11/C++14 graphics engine
Stars: ✭ 66 (-14.29%)
Mutual labels:  webgl, webassembly
Wagi
Write HTTP handlers in WebAssembly with a minimal amount of work
Stars: ✭ 75 (-2.6%)
Mutual labels:  webassembly
Veracruz
Main repository for the Veracruz privacy-preserving compute project.
Stars: ✭ 71 (-7.79%)
Mutual labels:  webassembly
Web Audio Javascript Webassembly Sdk Interactive Audio
🌐 Superpowered Web Audio JavaScript and WebAssembly SDK for modern web browsers. Allows developers to implement low-latency interactive audio features into web sites and web apps with a friendly Javascript API. https://superpowered.com
Stars: ✭ 68 (-11.69%)
Mutual labels:  webassembly
Gutenberg Parser Rs
An experimental Rust parser for WordPress Gutenberg post format
Stars: ✭ 76 (-1.3%)
Mutual labels:  webassembly
Deck.gl
WebGL2 powered visualization framework
Stars: ✭ 9,304 (+11983.12%)
Mutual labels:  webgl
Muze
Composable data visualisation library for web with a data-first approach now powered by WebAssembly
Stars: ✭ 1,153 (+1397.4%)
Mutual labels:  webassembly
Axis3d
Functional 3d graphics library
Stars: ✭ 67 (-12.99%)
Mutual labels:  webgl
Create Near App
Create a starter app hooked up to the NEAR blockchain
Stars: ✭ 66 (-14.29%)
Mutual labels:  webassembly

Hyper3D EnvMapGen

Pre-filtered mipmapped radiance environment map generator that runs on WebAssembly. The core functionality is implemented by Rust and is available as a standalone crate.

See the example.

Features

  • LTASG (linear-time approximate spherical Gaussian) filtering that can be used to approximate the Blinn-Phong NDF for small roughness values.
  • The algorithm is implemented to run entirely on the CPU. This allows asynchronous processing that does not interfere with the main thread's operation, which is hard to achieve with a WebGL-based implementation.

Possible TODOs

  • More filtering algorithms and techniques
  • Linear filtering in LTASG
    • The currently used nearest neighbor filtering produces a poor result unless the number of passes is set to at least two or three.
    • Investigate the behavior with large σ values

Browser Support

hyper3d-envmapgen requires a web browser supporting WebAssembly.

IE Edge Firefox Chrome Safari iOS Safari
No ≥ 16 ≥ 53 ≥ 57 ≥ 11 ≥ 11

Usage: JavaScript

With npm do:

npm install --save hyper3d-envmapgen

Other installation methods are not supported at this moment. Use webpack or Browserify. They are really awesome.

The following TypeScript code shows the basic usage of hyper3d-envmapgen:

Just remove the type annotations to convert it to JavaScript.

import { LtasgBlur, ImageFormat } from 'hyper3d-envmapgen';

(async () => {

    // See `ts/ltasgblur.ts` for all options
    const ltasg: LtasgBlur = await LtasgBlur.create({
        // The size of the base mipmap
        imageSize: 128,

        // The σ value (blur size) of each mipmap level. Must be reasonably 
        // smaller than 1.
        mipLevelSigmas: Array.from(
            new Array(8), 
            (_, i) => 0.5 ** (6 - Math.min(4, i))
        ),

        // The number of passes — have an impact on the filtering quality. 
        // You usually specify one of 1, 2, and 3.
        minNumPasses: 2,
    });

    // Construct the mipmap pyramid
    const mipmapLevels = ltasg.process(
        [
            images.positiveX, images.negativeX,
            images.positiveY, images.negativeY,
            images.positiveZ, images.negativeZ,
        ],
        ImageFormat.Srgbx8,
        ImageFormat.Srgbx8,
    ) as Uint8Array[][];

    for (let level = 0; level <= Math.log2(ltasg.size); ++level) {
        for (let i = 0; i < 6; ++i) {
            gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + k, level,
                gl.SRGB_ALPHA_EXT, ltasg.size >> level, ltasg.size >> level,
                0, gl.SRGB_ALPHA_EXT, gl.UNSIGNED_BYTE,
                level < mipmapLevels.length ? mipmapLevels[level][i] : null);
        }
    }
})();

And then in your fragment shader...

float phong_power = 1024.0;
float lod = 6.0 - log2(phong_power) * 0.5 - 1.0;
vec3 image = textureCubeLodEXT(u_Texture, v_Reflect, lod);

Usage: Rust

This repository provides a crate named hyperenvmapgen, which can be found in the directory rust.

This crate is never meant to be stablized. Therefore, it is strongly recommended to specify the revision hash as shown below:

[dependencies.hyperenvmap]
git = "https://github.com/Hyper3D/hyper3d-envmapgen"
rev = "INSERT REVISION HASH HERE"

See rust/examples/blurcubemap.rs for the usage.

Building

# Install the Rust toolchain for WebAssembly compilation
rustup target add wasm32-unknown-unknown --toolchain nightly
cargo install --git https://github.com/alexcrichton/wasm-gc 

# Install necessary packages
npm install

# Build the library
npm run build

# Build and open the demo
npm run start:examples

License

hyper3d-envmapgen, Copyright © 2017 yvt

The source code of this library is licensed under the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].