Commit Graph

130 Commits

Author SHA1 Message Date
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
Philip Rideout
462f55e2b4 Add KTX support to roughness-prefilter. 2018-09-25 15:56:12 -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
prideout
1ca4fcadce Fix / simplify roughness-prefilter.
This tool was producing bad output for the monkey roughness map because
the monkey map has an (unnecessary) alpha channel, and the tool was
assuming that the source image has 3 channels.

This fixes that particular case and changes the tool so that it
operates on single-channel data instead of 3-channel data.
2018-09-25 14:54:31 -07:00
Ben Doherty
1360e8f558 Tungsten: Use blurry skybox for mesh preview (#301)
* Use blurry skybox texture for Tungsten preview

* Fix build error with GraphCompilerTest
2018-09-24 18:16:20 -07:00
Ben Doherty
13cb47eead Fix incorrect SPIR-V instructions (#297)
* Add shaders to a program and link

* Remove glslang scope

* Add call to link for preprocessor-only optimization

* Add comment
2018-09-24 16:34:50 -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
Ben Doherty
596c94f6f0 Tungsten: normal mapping capabilities (#274)
* Ability to add code prior to prepareMaterial

* Add normal input on shading node

* Add constant float node

* Add multiply and subtract nodes

* Split math nodes out into MathNodes.kt
2018-09-20 11:09:15 -07:00
Philip Rideout
d3e7103ee5 Fix three bugs that caused bad normals with Suzanne.
(1) Suzanne's normal map is actually linear but we were telling GL that
it is SRGB, so the shader was not reading (0.5,0.5,1.0) from a perfectly
flat normal map.

(2) --linear in mipgen was not honored when consuming PNG files.

(3) The build was not passing --linear to mipgen for the normal map.
2018-09-20 10:01:43 -07:00
Philip Rideout
01590fde91 Combine some ColorTransform funcs with a template.
Tested this with "./build -u" and mipgen.
2018-09-19 12:28:50 -07:00
Philip Rideout
14e1bbdf3d Add --linear to mipgen. 2018-09-19 12:28:50 -07:00
Ben Doherty
29e891a7b1 Tungsten: add IBL to the preview panel (#254)
* Move preview-specific files into new package

* Add venice_sunset resource

* Load IBL from resources

* Generate IBL at build time
2018-09-19 11:16:58 -07:00
Ben Doherty
2218c51306 Add color space option to texture chooser (#266) 2018-09-19 11:02:28 -07:00
Romain Guy
0d37989157 Make the procedural UV grid HDR (#265) 2018-09-18 18:28:56 -07:00
Philip Rideout
fd8b1851a9 Add --grayscale option to mipgen.
By using single-component images instead of RGB, we are greatly reducing
the size of KTX files for roughness, metallic, and ambient occlusion.
2018-09-18 16:46:38 -07:00
Philip Rideout
60c4822884 Fix mipgen issue where mip 0 was missing from KTX.
The libimage API does not include the original image in the returned mip
array, which might make sense when generating individual files, but for
a KTX bundle, we want to include level 0.
2018-09-18 15:13:35 -07:00
prideout
52ee8e570d mipgen can now generate KTX files.
I tested the validity of the resulting KTX files by using macOS Preview,
which can read some types of KTX files. (!)

This CL also adds mipgen to the WebGL build, although its outputs are
not yet used by the sample apps.
2018-09-18 12:42:47 -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
Ben Doherty
cc77160cb4 Tungsten: fix a couple view-related bugs (#255)
* Fix bug when dragging non-selected node

* Fix bug when dragging nodes
2018-09-17 16:16:15 -06:00
prideout
cc6ee64e05 Add "strip alpha" feature to mipgen.
Sometimes the source image might have a useless 1-bit alpha channel
which our image-processing pipeline expands into a proper alpha channel.
This consumes memory and breaks an assertion in our encoder.

I ran into this while testing mipgen with the Suzanne textures.
2018-09-17 15:08:09 -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
Ben Doherty
3e6f1a2c39 Tungsten: add orbit cam manipulator (#244)
* Add orbit cam to Tungsten

* Add kotlin-math library

* Flip mouse wheel event sign if coming from a physical wheel
2018-09-13 17:30:33 -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
Ben Doherty
6ab36e9365 Fix, flip components not working (#239) 2018-09-12 17:29:40 -07:00
Ben Doherty
d0be29fb34 Tungsten: introduce texture sample node (#230)
* Tungsten: introduce texture sample node

* Add uv input to texture sample node

* Only flip components if specified in reverse order
2018-09-12 10:37:03 -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
Ben Doherty
069b4d1180 Tungsten: improvements to shader node (#216)
* Add StringValue and Choice

* Add editorFactory to nodes

* Update graph model when compiling

* Extract compileNode function

* Change inputs based on shadingModel

* Allow nodes to set shading model

* Fix float literals with dimension 1

* Adjust node height for slots

* Improvements to shader node

* Don't ever set a default value

* Add anisotropy and anisotropyDirection
2018-09-06 17:20:55 -07:00
Ben Doherty
7575bcee6e Tungsten: introduce custom view rendering (#205)
* Auto-convert MaterialGraphComponent to Kotlin

* Introduce new view rendering

* Add expressionMap to graph

* Show data width on slots

* Compile all nodes when compiling, even unconnected nodes

* Remove old views
2018-09-05 12:03:34 -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
91279fa818 Exclude comments from brace parsing in vertex/fragment blocks (#200)
* Exclude comments from brace parsing in vertex/fragment blocks

If a comment contained an opening brace { but not the matching
closing one, matc would not count braces properly and not find
the proper end of a vertex/fragment block.

* Add test
2018-09-04 12:03:16 -07:00
Romain Guy
0a8fad46fe Fix typos 2018-09-04 10:27:15 -07:00