Commit Graph

1340 Commits

Author SHA1 Message Date
Philip Rideout
8c46e6de9b matdbg: repair invalid JSON and display of active variants.
The JSON response to /api/active became malformed after #4465 because
raw hex strings need to be enclosed by quotes.

This commit changes the variant format in the /api/materials response
to be consistent with one used for /api/active. By using integers
instead of strings, we're avoiding the need to parse integers at run
time.

The JSON error did not appear in the Chrome console because it was being
silenced as a hack to appease "matinfo --web-server". I fix this by
removing the hack and simply emitting a valid response when there's
no live backend.

Also fixed the display of materials, which were always being marked
as active even when they had no active variants.
2022-03-02 15:01:25 -08:00
Ben Doherty
e2177e8b36 Apply some clang-tidy fixes (#5281) 2022-03-02 11:49:45 -08:00
Mathias Agopian
81c1d3ed1a more code size reduction
The main change here is from ResourceList which ended-up generating
a lot of code due to inlining. This class is only used for tracking
user resources and is not in the performance path.

This saves another ~5K or so of code.
2022-03-01 10:03:31 -08:00
Mathias Agopian
50fa816a6e fight more unnecessary inlining 2022-03-01 10:03:31 -08:00
Philip Rideout
94c59d9d97 libutils: fix inconsistent hash in StaticString
This caused a unit test failure because a StaticString constructed
from "make" had a different hash than one constructed from a literal,
even though the two strings were lexigraphically equivalent.
2022-02-28 15:42:06 -08:00
Mathias Agopian
9e5da2d75f more size optimizations 2022-02-25 13:19:31 -08:00
Mathias Agopian
e12f079ac1 don't prevent unrolling of libmath == operator
We were not unrolling the == loop because the generated code with
unrolling was very branchy; but that's not a good call either because
the loop has the same number of unpredicted branches.
Theoretically the compiler should be able to emit a branchless == but
it doesn't. At least we give it a chance.
2022-02-25 13:19:31 -08:00
Philip Rideout
3c0f18753f GLTFIO_LITE does not need volume texture. 2022-02-25 09:28:17 -08:00
Mathias Agopian
a0e4d3df32 fix android build 2022-02-24 22:43:53 -08:00
Philip Rideout
97952e0ddc gltfio ubershader: provide dummy texture for volume thickness.
Fixes logcat spam seen with IridescentDishWithOlives.
2022-02-24 15:02:30 -08:00
Ben Doherty
49b8e5e5d2 Adding missing algorithm include (#5237) 2022-02-22 18:06:53 -08:00
Philip Rideout
249f0a80d8 gltfio: be graceful when model has > 4 weights per vert.
We now handle "too many bone weights" in the same way that we handle
"too many UV sets".  i.e. emit an error message and do not panic.

This change allows us to render the model in #5234 quite reasonably.

Fixes #5234.
2022-02-22 17:34:02 -08:00
Mathias Agopian
697a8370cb There was still a case where skinning wasn’t correctly default initialized
Fixes: #5185
2022-02-18 13:49:12 -08:00
Philip Rideout
67aa6f1913 Update old comments about max color attachment count. 2022-02-17 12:55:31 -08:00
Mathias Agopian
5f7c6c2fbf update material version
This this needed by recent SSR changes.
2022-02-16 11:20:28 -08:00
daemyung jang
001a3e3dc8 Set the morph target buffer by builder (#5179) 2022-02-16 09:20:38 -08:00
Philip Rideout
e99f13b14d Fix some RangeMap behavior and improve its unit test.
The existing unit test had an incorrect expectation in what happens
after splicing an existing range. Fixing the unit test revealed an
actual bug in the RangeMap implementation. It should never modify the
lower bound of an existing interval, because that invalidates the
iterator. It should also never retain a pointer or reference to a range
when the range is potentially removed by subsequent codelines.
2022-02-15 15:46:34 -08:00
Mathias Agopian
5bd5c50c8d Remove unit test that is not very useful. 2022-02-14 12:03:07 -08:00
Mathias Agopian
3f6188edff Enable rough reflections
This works by first generating a reflection buffer which gets blurred,
then the color pass samples from this buffer according to the roughness
of the surface being rendered.

A lot of the changes here involve utilizing "reserved" variants for
the new "SSR" pass and all the fallout from that.
2022-02-13 22:53:47 -08:00
Mathias Agopian
cc0486b3cc Rework material Variant filters
Variants are no longer just a bit mask, but rather a combination of
some bits, depending on the variant. Because of that the variant filer
must be updated.

Basically we now make a distinction between the "variants" as a public
material API and the actual `Variant` data type.

This change does the impedance match between the two.
2022-02-13 22:53:47 -08:00
Mathias Agopian
8314bafc0e reformat Variant.h
indentation was wrong
2022-02-13 22:53:47 -08:00
daemyung jang
9844803b26 Add function overloading for setMorphTargetBufferAt (#5169) 2022-02-10 15:55:41 -08:00
Mathias Agopian
0b3e557b65 New Invokable function wrapper 2022-02-08 20:23:57 -08:00
daemyung jang
0d2faa4573 Revert adding APIs 2022-02-08 10:31:17 -08:00
daemyung jang
1924810c17 Deprecate MorphHelper
These changes bring the loading performance optimization by removing
flush and wait.
2022-02-08 10:31:17 -08:00
Benjamin Doherty
7398183d6f Bump material version 2022-02-07 11:28:45 -08:00
Ben Doherty
4cc8f88a21 Add a MAX_LEGACY_MORPH_TARGETS definition (#5163) 2022-02-07 11:23:49 -08:00
Ben Doherty
e2b8573bd7 Initialize useLegacyMorphing to fix MSAN warning (#5164) 2022-02-04 14:43:18 -08:00
daemyung jang
996981b102 Change CONFIG_MAX_MORPH_TARGET_COUNT's type correctly
CONFIG_MAX_MORPH_TARGET_COUNT should be positive value so size_t is
proper than int.
2022-02-04 11:17:58 -08:00
Mathias Agopian
cde055e5bf Minor cleanups
- Rename projectToPixelMatrix to uvFromViewMatrix, this match our 
existing style better.

- slightly more efficient direction transform

- limit roughness to 0.1 instead of 0.01, because in a lot of cases, 
the roughness increases with the LOD, for instance if it comes from
a texture (to combat aliasing).
2022-02-03 14:54:03 -08:00
daemyung jang
2029c9584e Get the morph target count from glTF
glTF spec says that all primitives MUST have the same number of morph
targets in the same order so these changes are more correct.
2022-02-03 13:26:09 -08:00
daemyung jang
a43b17716f Pass the current variant to GLSLPostProcessor
The current Variant is need to calculate BindingIndexMap correctly.
But we can't use the current Variant when calculate BindingIndexMap
because SamplerBindingMap uses only the dummy Variant. Both are
should be same.
2022-02-02 11:59:04 -08:00
daemyung jang
63032ed0a6 Add the morphing sampler group always
The morphing sampler group can be added if skinning or morphing is
enabled. However SamplerBindingMap can't know skinning or morphing
is enabled because only dummy Variant is used. It causes generating
the different sampler bindings between SamplerBindingMap and
program's sampler groups.

Fixes #5139
2022-02-02 11:59:04 -08:00
Ben Doherty
b6cd6668a6 Fix sampler overflow check in SamplerBindingMap (#5143) 2022-02-02 11:04:08 -08:00
Mathias Agopian
73e339b05d be more consistant with defines names in shaders
all defines coming from material parameters are named `MATERIAL_HAS_...` 
and all defines coming from the variant are named `VARIANT_HAS_...`
2022-01-31 22:53:48 -08:00
Ben Doherty
42172c7395 Add iterator include to Range.h (#5141) 2022-01-31 12:54:27 -08:00
Philip Rideout
fbc0b8dab5 gltf_viewer: fix bad ReadPixels size in headless mode
This fixes the gltf_viewer automated testing mode, invoked via
`--batch=default --headless`.

ReadPixels was being issued with an out-of-bounds size on high DPI
platforms, which caused weird backend errors.

Since we create an invisible SDL window while in headless mode, the
presence of the SDL window does *not* indicate headless vs non-headless.

Partial fix for #5111
2022-01-31 11:34:13 -08:00
daemyung jang
9df13c1cd2 Cleanup code 2022-01-28 21:41:19 -08:00
daemyung jang
5a3853a442 Optimize memory of MorphTargetBuffer (#5046)
* Optimize memory of MorphTargetBuffer

Co-authored-by: Mathias Agopian <mathias@google.com>
2022-01-27 21:19:13 -08:00
Ben Doherty
4c4a93d9b5 Support legacy morphing (#5129)
Support legacy morphing (morphing with targets supplied via VertexAttributes) for older clients. This gives clients more time to transition over to the new MorphTargetBuffer API.
2022-01-27 16:16:53 -08:00
Mathias Agopian
001dcefd8a simplify how we select a material Variant
Instead of building the Variant based on flags in RenderPass, we just
pass the Variant itself to RenderPass. The caller has more knowledge
of what it wants to do.
2022-01-27 15:48:24 -08:00
Mathias Agopian
d114d547be update material version to 18 2022-01-26 14:49:09 -08:00
Philip Rideout
6403e0ce44 gltfio morphing: generate normals when they are missing.
This allows the `Horse.glb` model to work with Vulkan without any
validation errors. As a reminder, the glTF spec says:

```
When normals are not specified, client implementations MUST calculate
flat normals
```

Fixes #5115.
2022-01-26 13:48:05 -08:00
daemyung jang
41cf507746 Bind samplers to specified shader stages (#5036)
Co-authored-by: Ben Doherty <bendoherty@google.com>
Co-authored-by: Mathias Agopian <mathias@google.com>
2022-01-26 12:22:07 -08:00
daemyung jang
354c39be6b Get the morph target count from the renderable (#5077)
* Get the morph target count from the renderable
* Set the morph target count by Builder
* Update morph target weights partially
* Remove noexcept at functions could throw exceptions
* Update Java bindings at RenderableManager
* Add missing comments
* Update morph target weights from offset

Co-authored-by: Mathias Agopian <mathias@google.com>
2022-01-26 10:27:25 -08:00
wangjinhan
26bbe8ade1 fix build android aar on Linux because of case sensitive 2022-01-25 22:39:40 -08:00
daemyung jang
1952f0a1f7 Change morphing APIs to support LOD (#5080)
* Change morphing APIs to support LOD
* Add Java and Web bindings for morphing
* Omit and fix JS bindings
* Fix styles in MorphTargetBuffer.java
2022-01-25 21:57:11 -08:00
Philip Rideout
69fb7170a7 Fix typo in BlueVK script that caused segfault.
Fixes #5026.
2022-01-25 10:23:07 -08:00
Alexey Pelykh
45054eece9 gltfio: support material extras 2022-01-25 10:04:10 -08:00
Philip Rideout
785f7de25d RangeMap: improve naming convention, etc. 2022-01-25 09:58:53 -08:00