MONOGRID / gainmap-js

A Javascript (TypeScript) Port of Adobe Gainmap Technology for storing HDR Images using an SDR Image + a gainmap
https://monogrid.github.io/gainmap-js/
MIT License
70 stars 5 forks source link

Kudos to you - Readme suggestion #41

Open dghez opened 2 months ago

dghez commented 2 months ago

Not really an issue, just wanted to say thanks for the library, i recently tried with three as envMap lighting and i was able to save like 2mb in filesize. Although I kinda suggest to maybe create and explicit a note on the fact you still need to use PMREMGenerator if you want to use that as environment, otherwise it won't work. I took me a while to realise that, was using directly as envmap eheh

  const pmremGenerator = new PMREMGenerator(gl)
  pmremGenerator.compileEquirectangularShader()

  const loader = new HDRJPGLoader(gl)
  loader.loadAsync('..../lighting.jpg').then(res => {
    const envMap = pmremGenerator.fromEquirectangular(res.renderTarget.texture).texture
    scene.value.environment = envMap
  })

Anyway, thanks again ❤️

daniele-pelagatti commented 2 months ago

Hello! Thanks for your kind words.

Regarding your problem, have you tried doing something like

const loader = new HDRJPGLoader(gl)
    .setRenderTargetOptions({ mapping: EquirectangularReflectionMapping }) // <------- see here

scene.environment = ( await loader.loadAsync('..../lighting.jpg') ).renderTarget.texture

last time I checked this worked, but then again three.js constantly changes with time so I could be entirely wrong :smile:

dghez commented 2 months ago

Kinda already closed that project and handed the files but I'll try asap or in the next project I'll need a envmap and I'll update you! ❤️