google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.74k stars 1.88k forks source link

How to use cmgen to blur an environment map without downscale? Keep the original size #1608

Closed but0n closed 5 years ago

but0n commented 5 years ago

Hi, I need some blurred environment maps as the skybox of my scene, I tried to use command ./cmgen --type=equirect --size=2048 --ibl-ld=test ~/Downloads/spruit_sunrise_4k.hdr, but it will downscale the image for each roughness level.

How to avoid this? How to generate those image in a particular size?

romainguy commented 5 years ago

Don't use --ibl-ld, use --extract-blur=X --extract=directory instead, where X is a roughness value from 0.0 to 1.0 to control the blur amount. I like to use ~0.09 myself. You can also combine --extract-blur with -x to generate the both the roughness levels for the indirect light and the blurred background:

cmgen -x ~/Desktop/filament_res/env/ --extract-blur=0.08 ~/Documents/Filament/hdr/river.hdr

but0n commented 5 years ago

@romainguy Thanks for your reply, I tried use command: ./cmgen -f=hdr --type=equirect -x test --extract-blur=0.08 spruit_sunrise_4k.hdr, but those output files is always rgb32f format even I specified output file format with -f. My purpose is to generate several 4k images in different blur level.

but0n commented 5 years ago

@romainguy Oops, my mistake, now the output file format is correct with -f hdr, but the downscale problem still: image

but0n commented 5 years ago

Though, now I'm using command ./cmgen -f hdr -s 2048 --type=equirect --extract=test --extract-blur=0.08 spruit_sunrise_4k.hdr to generate blurred image in 4k resolution. Problem solved.

romainguy commented 5 years ago

That's because -x is a feature to do everything with one flag so it always generates mip level. --extract= instead of -x is what you want if you want just one high resolution level.

but0n commented 5 years ago

@romainguy Hi, I got another problem, when I use png file as input, the color of output files looks weird:

image

Another problem is there will be some stripes after blur, how to fix this?

image image image

romainguy commented 5 years ago

The color issue is just an encoding bug: we save the image as sRGB but it contains linear data. It should be an easy fix.

As for the "striping" it's simply banding and I would expect this kind of issue from a bandwidth limited like PNG.

Just to be clear: cmgen's main purpose is to process and output HDR data with high bit depth.

romainguy commented 5 years ago

The fix should be here: https://github.com/google/filament/pull/1646

dandingol03 commented 1 year ago

@but0n Hi, how to render skybox with cubemap whose format is png.