Commit Graph

55 Commits

Author SHA1 Message Date
Sebastian Hartte
aaf2909194 Correctly set glTypeSize in the tools, and use sized formats for internalFormat 2018-12-06 10:33:49 -08:00
Philip Rideout
eb814a9ff2 Repair test_cmgen. 2018-11-30 18:02:00 -08:00
Adrian Perez
6c66bc26e7 remove another instance of using namespace std (#354) 2018-10-09 01:51:41 +02:00
Adrian Perez
27a2d05c8a Remove 'using namespace std' (#352) 2018-10-08 20:41:08 +02:00
Philip Rideout
06fc8e2f4c Add compression support to cmgen. 2018-10-08 09:25:09 -07:00
Mathias Agopian
1748724826 Use “cubemap” instead of “faces”. Fixes #320. 2018-10-01 11:55:53 -07:00
Mathias Agopian
741b1a412d experimental: add octahedron output support
Octahedron output support for cmgen. use —type=octahedron.

This is still fairly experimental.
2018-10-01 11:49:29 -07:00
Pixelflinger
fae92f2750 Equirectangular export support
this adds a new --type (-t) parameter that is
used to specify cmgen’s output.

faces: outputs cube maps separate faces (default
       and current behavior)
equirect: outputs an equirectangular image
ktx: outputs a ktx file


--format=ktx now implies —type=ktx
2018-09-28 14:37:48 -07:00
Mathias Agopian
13e70f7afa fix typos that caused bilinear filtering in corners to be wrong 2018-09-27 21:45:21 -07:00
Mathias Agopian
cb34ab217b fix typo that could cause a crash 2018-09-27 20:11:27 -07:00
Mathias Agopian
4764eefafc improve cubemap bilinear sampling
We now handle all face corners correctly and
follow the OpenGL recommandation of averaging the
corners of all 3 adjacent faces.
2018-09-27 20:11:27 -07:00
Mathias Agopian
09a753760c better cross conversion. Fix #283. (#302)
- internal cross storage is now always horizontal
  and seamless.

- source cross images are now always converted to
  internal format, conversion includes rescaling
  and sampling if scaling down.

- vertical cross is supported again

- fixes #283

- replace hardcoded constants
2018-09-25 15:40:19 -07:00
prideout
6f2455e7e3 Simplify KTX metadata. 2018-09-25 15:37:49 -07:00
Philip Rideout
6f09389d2f web / cmgen: use KTX metadata for sh coefficients. 2018-09-25 15:37:49 -07:00
Mathias Agopian
3bf0d6a4ab document artifacts due to giving up mipmaps (#299)
* document artifacts due to giving up mipmaps

- also talk about lod remapping
- try to avoid to confuse alpha with roughness

* fix typos
2018-09-24 16:14:52 -07:00
Mathias Agopian
50d8240e67 improve equirectangular conversion
We use a better calculation of the number of
samples needed for a given texel.
2018-09-21 15:11:39 -07:00
Philip Rideout
99a01499d4 Remove vestigial "flip" stuff. 2018-09-21 12:56:29 -07:00
Philip Rideout
d3ad33a8f3 Fix recent cmgen KTX regression.
This fixes a KTX sizing bug that I introduced while incorporating code
review feedback.
2018-09-21 12:23:40 -07:00
Pixelflinger
9187b31279 fix debug environment labels
- front and back labels where inverted:
  +z is the front of the cube and -z is its back
  when looking at the cube from the outside
  with a camera pointing towards -z (and the cube
  in front of it). This is the GL definition.

- make the synthetic uvXXX debug environment 
  colors match those of the debug environment
  (except for -Z/back which is magenta instead
  of black).

- add some documentation about skybox and cube map.
2018-09-21 11:50:29 -07:00
Pixelflinger
09830cd126 Improvements to CMGEN handling of cubemaps
- cmgen now creates reflections maps for all input
assets by default instead of just for equirectangular 
images.

- equirectangular decode doesn't mirror -- that's
done by the mirroring code now.

- mirroring can be turned of with --no-mirror

- option --mirror is gone

- faster mirroring code (do it before generating
  mipmaps)

- added labels to faces of debug.png environment

- added a debug equirectangular image in third_party
(creative commons license)
2018-09-21 11:50:29 -07:00
Pixelflinger
1396cc751c fix constness of CubemapUtils::process 2018-09-21 11:49:56 -07:00
Philip Rideout
2e97539a30 Create exportKtxFaces function, use a switch-case. 2018-09-21 11:25:59 -07:00
Philip Rideout
0a464724c8 Fix inconsistent cube face order.
- KTX / OpenGL are PX,NX,PY,NZ,PZ,NZ.
- Cubemap::Face is NX,PX,NY,PY,NZ,PZ.

I considered changing the Cubemap::Face enum, but applying ^1 upon
export seems less intrusive.
2018-09-21 11:25:59 -07:00
Philip Rideout
68be31afaf The cmgen tool can now generate KTX files.
For each envmap/skybox pair, this will reduce the number of downloads
from 61 files to 3 files.

Note that we are still using sh.txt for coefficients, I'll see if it
would be easy to embed that in the KTX metadata.

Also, I will add KTX support to roughness-prefilter soon.
2018-09-20 15:50:21 -07:00
Romain Guy
0d37989157 Make the procedural UV grid HDR (#265) 2018-09-18 18:28:56 -07:00
Mathias Agopian
944cce7935 Assume V=1 when prefiltering the environement
It looks like assuming V=1 during prefiltering
yields to better results. This is quite subtle.
2018-09-18 01:40:55 -07:00
Mathias Agopian
094453dad8 clarify the LOD -> linear_roughness remapping
This remapping can be confused with roughness, because

linear_roughness = roughness*roughness and 
lod = sqrt(linear_roughness)

so the value of lod is roughness, but conceptually
it’s not.
2018-09-17 20:18:57 -07:00
prideout
3f751f3850 cmgen and mipgen should return an error code upon failure.
These tools can be used in an asset pipeline; build scripts should not
be required to parse stdout in order to determine success.
2018-09-17 14:51:29 -07:00
Romain Guy
4ca4df0f6c Inlude missing headers (#252) 2018-09-17 09:31:10 -07:00
Mathias Agopian
71fed25775 When prefiltering the IBL we were wrongly assuming
f90=0, which is nonsensical.

We now assume f0=f90=1, meaning the fresnel term
always evaluates to 1.

Thankfully this didn’t impact the prefilter too much.


IBLs MUST BE REGENERATED
2018-09-16 17:40:11 -07:00
Mathias Agopian
ea91002412 improve cmgen comments about IBL (#243)
* better comments on calculating the DFG lookup tables

* add comments about computing the “LD” term

* add comments about computing IBL diffuse pre-integration

* be clearer about the determinant of the jacobian
2018-09-13 15:12:45 -07:00
Pixelflinger
1db1426260 fix cmgen unit test 2018-09-11 01:09:22 -07:00
Mathias Agopian
4475cbaf2e fold the lambert brdf into the SH coefs
this saves one multiply in the shader, but most
importantly makes the first SH coefficient a
color and reduces its range

ALL IBLs NEED TO BE REGENERATED using cmgen
2018-09-10 21:09:11 -07:00
Mathias Agopian
abae178ddc cmgen: option to generate the diffuse irradiance
-—ibl-irradiance generates the diffuse irradiance as
a cubemap using importance sampling. 
It can be used in place of the SH version (—-sh-irradiance)
which sometimes presents some ringing artifacts.
2018-09-07 14:31:44 -07:00
Mathias Agopian
f75f19edd0 save debug files in .HDR format instead of .PNG 2018-09-07 14:31:44 -07:00
Mathias Agopian
ad18b6ea39 fix divide-by-zero in cmgen (#201) (#218)
We were doing a divide-by-zero in a case where
the result wasn’t used.
2018-09-06 20:42:45 -07:00
Tim van Scherpenzeel
963342c7cc fix minor error in spelling of stitch (#204) 2018-09-05 12:03:09 -07:00
Romain Guy
1c42a122c9 Fix cubemap mirroring (#203) 2018-09-05 11:46:31 -07:00
Romain Guy
0a8fad46fe Fix typos 2018-09-04 10:27:15 -07:00
Romain Guy
4002498438 Add new HDR environment maps in third_party (#182)
These are much better than the ones we had in assets/
2018-08-29 14:22:58 -07:00
Philip Rideout
aa518369b4 Move deprecated Image out of libs. (#125)
This moves the old Image class into cmgen because it is the only client
that still uses it. We can migrate cmgen to LinearImage in the future.
2018-08-23 10:19:02 -07:00
Philip Rideout
044387308a Migrate imageio to LinearImage. (#111) 2018-08-17 11:22:05 -07:00
Romain Guy
3b110e3774 Fix uninitialized vectors in envmap processing 2018-08-16 14:56:00 -07:00
Romain Guy
58520d7d32 Add spherical harmonics extraction test (#105)
We use a white furnace to test that spherical harmonics are properly computed.
2018-08-16 14:35:12 -07:00
Philip Rideout
6d9668ccf6 Add unit test for cross cube images. (#101) 2018-08-15 15:36:17 -07:00
Romain Guy
b739ac8e86 Fold computations inside the branch 2018-08-14 18:15:01 -07:00
Philip Rideout
b5b90b83f8 Add test_cmgen and promote the "updateOrCompare" function. (#95) 2018-08-14 13:47:31 -07:00
shartte
e6d5a85ec8 clang-cl warning fixes (#83)
* Disable certain MSVC-specific deprecation warnings

* clang-cl.exe warning fixes
2018-08-14 12:55:04 -07:00
Romain Guy
bb553bf53d Fix uninitialized memory bug in cmgen (#93)
We recently changed the default constructor of vector to not initialize the vector to 0. This caused subtle issues in cmgen which was creating arrays of vectors. This change simply forces 0 initialization of those arrays.
2018-08-13 22:24:23 -07:00
Mathias Agopian
7fcefb5f54 make we our indices to the hammersley sequence are within range
fix #87

We just skip samples that have a dot(N,L)<0 which 
means we’re “loosing” some samples. However,
this happens higher levels of the mipmap chain,
and since we’re increasing significantly the 
number of samples as the level increases, this
doesn’t end-up being a problem.
2018-08-13 20:23:21 -07:00