Compare commits
428 Commits
v1.31.1
...
bjd/comman
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
031cd302dd | ||
|
|
87351097ad | ||
|
|
694766682f | ||
|
|
c946ebd1e6 | ||
|
|
25a8291101 | ||
|
|
60c689688d | ||
|
|
763bc1f34a | ||
|
|
ef07638eef | ||
|
|
0aa0efe159 | ||
|
|
ef7bcd1e19 | ||
|
|
702ceda82a | ||
|
|
66b78074de | ||
|
|
8d440cea17 | ||
|
|
3ab8e4d725 | ||
|
|
97f20afdd7 | ||
|
|
42989e76d7 | ||
|
|
ad45cc9092 | ||
|
|
04669f6ab9 | ||
|
|
c3c0dde82f | ||
|
|
ecd5b681d0 | ||
|
|
66081e6cc1 | ||
|
|
aa6e94a128 | ||
|
|
098be2e115 | ||
|
|
17caf6cae9 | ||
|
|
26952631a3 | ||
|
|
fc7b6447b7 | ||
|
|
6c0db37919 | ||
|
|
69f78dbcbe | ||
|
|
c0389ac54c | ||
|
|
c0db909c13 | ||
|
|
46e4e966b9 | ||
|
|
288b59a348 | ||
|
|
1c7293db8d | ||
|
|
6006b47c44 | ||
|
|
6bb29f6e01 | ||
|
|
f1b160db04 | ||
|
|
3bb52f083b | ||
|
|
88337ab358 | ||
|
|
0935fe3fe3 | ||
|
|
96ed19549e | ||
|
|
945e9a2cb5 | ||
|
|
4d703e3807 | ||
|
|
f537f62adf | ||
|
|
7840404132 | ||
|
|
afad361cac | ||
|
|
58b23c290c | ||
|
|
12a73137d7 | ||
|
|
7a136eec5d | ||
|
|
e9bd9ab3a6 | ||
|
|
083bff62e3 | ||
|
|
f713316541 | ||
|
|
bcfdf2f70d | ||
|
|
018d6f877f | ||
|
|
1e4172b820 | ||
|
|
6b6827b70d | ||
|
|
96cccc83c6 | ||
|
|
2468a3a854 | ||
|
|
f68825f2ed | ||
|
|
2a12f71f96 | ||
|
|
74b64a5451 | ||
|
|
7d01e0349b | ||
|
|
80014bf2b1 | ||
|
|
adf3421f4a | ||
|
|
51c65ccfdc | ||
|
|
5d37d08cf8 | ||
|
|
eb18d75b2e | ||
|
|
549c582287 | ||
|
|
6c05029a9f | ||
|
|
b2278986dd | ||
|
|
98a2b8f159 | ||
|
|
0ba891fb14 | ||
|
|
042cd670aa | ||
|
|
95c7e4d02b | ||
|
|
d302525674 | ||
|
|
3dbb7298f8 | ||
|
|
0ed71ab53b | ||
|
|
b1491ae5b1 | ||
|
|
03b8dc8027 | ||
|
|
e3568cd89f | ||
|
|
b35e24daa7 | ||
|
|
f506b27a31 | ||
|
|
9452d5be1d | ||
|
|
ea3f449a08 | ||
|
|
dc9510fe25 | ||
|
|
731dd761d9 | ||
|
|
6726ccb2fb | ||
|
|
5fce0f9ecf | ||
|
|
ad03fc4118 | ||
|
|
3f77ff8815 | ||
|
|
26b5fa1e38 | ||
|
|
24286e6016 | ||
|
|
626577fe3d | ||
|
|
176915b59c | ||
|
|
0b60933c2a | ||
|
|
0e31d6936a | ||
|
|
78d9c43ef1 | ||
|
|
ce253a9563 | ||
|
|
18c3c36727 | ||
|
|
4e6f6a4579 | ||
|
|
84487f4d8d | ||
|
|
45f5a07989 | ||
|
|
0061883dbf | ||
|
|
47e3be11f0 | ||
|
|
420f4000c2 | ||
|
|
4582ce8769 | ||
|
|
3beb39f30b | ||
|
|
b72d6c058a | ||
|
|
0c8f367b29 | ||
|
|
50045edb4f | ||
|
|
f538d1aa43 | ||
|
|
4bd8d2a3b7 | ||
|
|
9fa952d968 | ||
|
|
1edad92d73 | ||
|
|
52282baeff | ||
|
|
85ab9d211d | ||
|
|
6e99a4dcfc | ||
|
|
35c91827af | ||
|
|
5c11b237f3 | ||
|
|
432b5d0427 | ||
|
|
b8b1fadfa1 | ||
|
|
74f5d8a066 | ||
|
|
09aeeccfa7 | ||
|
|
094abdc194 | ||
|
|
f4b97028b0 | ||
|
|
e14cbf2163 | ||
|
|
032cbab7b0 | ||
|
|
e306856c4f | ||
|
|
c1f164190b | ||
|
|
8030a078ff | ||
|
|
11adcbed25 | ||
|
|
c2b10859c9 | ||
|
|
e0e2c76d2f | ||
|
|
b0238c1560 | ||
|
|
5ffb52a17d | ||
|
|
6b34e72418 | ||
|
|
d43c632e55 | ||
|
|
d55dfdebde | ||
|
|
4b12876ebc | ||
|
|
3e12449b8f | ||
|
|
fdc3f302d9 | ||
|
|
07642fec83 | ||
|
|
4ce93232c3 | ||
|
|
ccea370cd9 | ||
|
|
8f6885689b | ||
|
|
64b15fafe2 | ||
|
|
d891acb8c0 | ||
|
|
de0bc718be | ||
|
|
283a06e200 | ||
|
|
3cfb2f8339 | ||
|
|
21164885e8 | ||
|
|
0d745c4fea | ||
|
|
0e2f8b5dda | ||
|
|
321777e8c1 | ||
|
|
aa9f0a4ca3 | ||
|
|
bee8862897 | ||
|
|
fed69025d2 | ||
|
|
f953488a31 | ||
|
|
25708e8082 | ||
|
|
a8afa91b7d | ||
|
|
2806221eda | ||
|
|
a9763376b7 | ||
|
|
153dc08aa7 | ||
|
|
332b924325 | ||
|
|
b2ee4e93d4 | ||
|
|
fda62e0065 | ||
|
|
faafb1464c | ||
|
|
edfd06eaef | ||
|
|
1a83083651 | ||
|
|
5cb3b16f36 | ||
|
|
3aa6913538 | ||
|
|
2c6f723317 | ||
|
|
ddfeaef2ca | ||
|
|
a71baef5d3 | ||
|
|
e63ec23922 | ||
|
|
da17b6f867 | ||
|
|
002becdc4f | ||
|
|
2ade1778b1 | ||
|
|
f6c8ce1fd1 | ||
|
|
8aa1435fbd | ||
|
|
3e29b6e443 | ||
|
|
1a138aea1a | ||
|
|
d40712937d | ||
|
|
cfe1abec08 | ||
|
|
719ed28d7e | ||
|
|
aa1773d633 | ||
|
|
9b8b882818 | ||
|
|
17664d294e | ||
|
|
2ae4ee85e0 | ||
|
|
70bb08a93a | ||
|
|
88f6360321 | ||
|
|
f7538342df | ||
|
|
8e6d5d11b6 | ||
|
|
ac74f09dc8 | ||
|
|
f47265e9c5 | ||
|
|
9243887a3a | ||
|
|
4efac2c0fa | ||
|
|
f3e1d5592a | ||
|
|
c67d9ce09b | ||
|
|
27ee90a56d | ||
|
|
41ccbdbf17 | ||
|
|
17fc3c23ed | ||
|
|
fdb0798f28 | ||
|
|
b4d842c342 | ||
|
|
7cddd832aa | ||
|
|
6a10753267 | ||
|
|
38dba5394e | ||
|
|
108cdd4242 | ||
|
|
228aa6c631 | ||
|
|
8936b3aa66 | ||
|
|
6558448eae | ||
|
|
88be599c2e | ||
|
|
cf1bbf63fc | ||
|
|
4e888d142b | ||
|
|
a5e6d9ef3d | ||
|
|
5e58af466c | ||
|
|
899c15f023 | ||
|
|
861da7b5c9 | ||
|
|
b62cf698a5 | ||
|
|
b928e5c4dc | ||
|
|
b748ea7239 | ||
|
|
bd9ba1139e | ||
|
|
5ed25aa327 | ||
|
|
7f51f21512 | ||
|
|
c24cc726e8 | ||
|
|
7b90a8f921 | ||
|
|
9fb96cd200 | ||
|
|
f881b59d60 | ||
|
|
ebb07520c0 | ||
|
|
29d5ae621a | ||
|
|
6e275514ad | ||
|
|
08503943f4 | ||
|
|
0c547748bf | ||
|
|
19ab9f0403 | ||
|
|
c895554a22 | ||
|
|
968c2c40fa | ||
|
|
de845d2885 | ||
|
|
0e1f57d712 | ||
|
|
6b3dfbc635 | ||
|
|
5e2b4dec99 | ||
|
|
0cd4a143ab | ||
|
|
c7ad9acc79 | ||
|
|
afeaf90d0d | ||
|
|
3603aaafa6 | ||
|
|
6cab8d2cd4 | ||
|
|
ca2f3d76e6 | ||
|
|
a2beaf0582 | ||
|
|
4a116e6791 | ||
|
|
040fc64583 | ||
|
|
e19011d0e0 | ||
|
|
8d3b395e86 | ||
|
|
2d1d8a6eec | ||
|
|
498a355fb2 | ||
|
|
944031af14 | ||
|
|
ee9d427526 | ||
|
|
9b98ae66ce | ||
|
|
126ba44719 | ||
|
|
503e3ba555 | ||
|
|
c264d26edd | ||
|
|
185c68c55b | ||
|
|
4624b0d1a1 | ||
|
|
5fe0a50c99 | ||
|
|
a484fe1de3 | ||
|
|
e48690bdf9 | ||
|
|
bc40ff7f19 | ||
|
|
30979124b5 | ||
|
|
6eb4c5e356 | ||
|
|
38ede3719f | ||
|
|
4503ad1e34 | ||
|
|
9fc6b0d654 | ||
|
|
d00223332e | ||
|
|
d3013ae151 | ||
|
|
b2fc46c320 | ||
|
|
53aac259a0 | ||
|
|
af35b87d5b | ||
|
|
0171452b02 | ||
|
|
065a33c846 | ||
|
|
90601b9471 | ||
|
|
327f630ed7 | ||
|
|
96acc6900d | ||
|
|
91cc36f1ec | ||
|
|
575e54e5d6 | ||
|
|
9a2fd38f33 | ||
|
|
7cba0da0a2 | ||
|
|
d8eb48c9de | ||
|
|
3ccd592eab | ||
|
|
a157546d82 | ||
|
|
3ec704b91c | ||
|
|
331af7bf35 | ||
|
|
473aff9093 | ||
|
|
6ff08f2ac1 | ||
|
|
3db7f6675e | ||
|
|
e501a15ef2 | ||
|
|
4e8974bcd9 | ||
|
|
7914372707 | ||
|
|
3c794247c3 | ||
|
|
ae12e3a51c | ||
|
|
fdc2ab30c0 | ||
|
|
122541eedc | ||
|
|
7e54bc8bcd | ||
|
|
e1ebe97eb5 | ||
|
|
9fed30af55 | ||
|
|
4fd02d7e75 | ||
|
|
e30a99f692 | ||
|
|
b891c52d9b | ||
|
|
74eb8a77e5 | ||
|
|
ba59d6d1b7 | ||
|
|
46efeb7fa8 | ||
|
|
673c1104b2 | ||
|
|
7cca872af5 | ||
|
|
3cef1991b2 | ||
|
|
64493d8636 | ||
|
|
df78322bdc | ||
|
|
f1a967d631 | ||
|
|
ec48dfa453 | ||
|
|
5881a13b20 | ||
|
|
efd9e875db | ||
|
|
6f25e8ae5a | ||
|
|
449519c1b4 | ||
|
|
e2e5f7cee9 | ||
|
|
9d30233a38 | ||
|
|
d684fc4096 | ||
|
|
5f3f3f1b24 | ||
|
|
6aa2a2b89b | ||
|
|
47135164ee | ||
|
|
5a75fb9b53 | ||
|
|
7933b08e85 | ||
|
|
a6809b4550 | ||
|
|
8f77308bca | ||
|
|
65f1e64812 | ||
|
|
79942b3bea | ||
|
|
9ee41b9b6a | ||
|
|
21995e4ac9 | ||
|
|
8dc871c86e | ||
|
|
78785a5bca | ||
|
|
662b4b5ca3 | ||
|
|
bee96d1cf1 | ||
|
|
122ebe1ccb | ||
|
|
e741e165ae | ||
|
|
d38dc24915 | ||
|
|
d12612f091 | ||
|
|
e6d73135c1 | ||
|
|
816612cf0a | ||
|
|
7ca8ba272c | ||
|
|
d337a6d019 | ||
|
|
f79c4c6080 | ||
|
|
2e7fc6229b | ||
|
|
fc724575fa | ||
|
|
84716610b8 | ||
|
|
29983772ed | ||
|
|
d100e628c2 | ||
|
|
94f121f37d | ||
|
|
d9266ba61c | ||
|
|
8389056d2d | ||
|
|
26b8cb238a | ||
|
|
f8d4690cd8 | ||
|
|
c2e2f80945 | ||
|
|
e9efcdf191 | ||
|
|
8ea159520d | ||
|
|
337e18051a | ||
|
|
3c4e094990 | ||
|
|
71e6f3d037 | ||
|
|
d2690bf75a | ||
|
|
44f002a5a1 | ||
|
|
f8442c9ec0 | ||
|
|
b3513c7d1f | ||
|
|
a82e813333 | ||
|
|
dd246aeee4 | ||
|
|
1653d3615b | ||
|
|
4847b00f9e | ||
|
|
d613145c1a | ||
|
|
a788f66e18 | ||
|
|
9ca3a7456c | ||
|
|
5cec001058 | ||
|
|
2fb42f5144 | ||
|
|
02c22a668c | ||
|
|
a7bf90f5be | ||
|
|
f71e90fae0 | ||
|
|
8afb11128d | ||
|
|
2e0c238cc6 | ||
|
|
03b89b4327 | ||
|
|
a878d1f39c | ||
|
|
4a09e13e9d | ||
|
|
0b4d32bf98 | ||
|
|
b940fc9c48 | ||
|
|
2eb0dd7153 | ||
|
|
101c7db9a2 | ||
|
|
032ace2051 | ||
|
|
5754b9907d | ||
|
|
ffb8203ae7 | ||
|
|
906da033dd | ||
|
|
1077405bc1 | ||
|
|
e37df8fc89 | ||
|
|
3799e219fc | ||
|
|
eab14da30e | ||
|
|
84e999fe57 | ||
|
|
f22ff6a340 | ||
|
|
d9d0b93306 | ||
|
|
09248cd451 | ||
|
|
73880428dc | ||
|
|
2a049d1324 | ||
|
|
51cbd74235 | ||
|
|
45246b6109 | ||
|
|
d3956adca8 | ||
|
|
298e54c32a | ||
|
|
4c82f0259d | ||
|
|
d0c043c7ff | ||
|
|
20cbecfd7c | ||
|
|
194defdb1b | ||
|
|
5017cbe67e | ||
|
|
4c4201cb72 | ||
|
|
3ee635f8e4 | ||
|
|
4c2dabffd6 | ||
|
|
185c83dae2 | ||
|
|
15d124b225 | ||
|
|
9c474c5b08 | ||
|
|
f92f283e00 | ||
|
|
f6b94614e8 | ||
|
|
978517b057 | ||
|
|
d911640809 | ||
|
|
473e610430 | ||
|
|
3b9b725406 | ||
|
|
fa742bc6bf | ||
|
|
6a02dd0993 | ||
|
|
243d10f864 | ||
|
|
bbe46071f3 | ||
|
|
8ded184ea3 | ||
|
|
ce407ba844 | ||
|
|
ddb6a7fa93 |
6
.github/ISSUE_TEMPLATE/bug_report.md
vendored
6
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -4,6 +4,8 @@ about: Create a report to help us improve
|
||||
|
||||
---
|
||||
|
||||
⚠️ **Issues not using this template will be systematically closed.**
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
@@ -18,8 +20,8 @@ A clear and concise description of what you expected to happen.
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Logs**
|
||||
If applicable, copy logs from your console here. Please *do not*
|
||||
use screenshots of logs, copy them as text.
|
||||
If applicable, copy **full** logs from your console here. Please *do not*
|
||||
use screenshots of logs, copy them as text, use gist or attach an *uncompressed* file.
|
||||
|
||||
**Desktop (please complete the following information):**
|
||||
- OS: [e.g. iOS]
|
||||
|
||||
6
.github/workflows/android-continuous.yml
vendored
6
.github/workflows/android-continuous.yml
vendored
@@ -13,7 +13,11 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/android && printf "y" | ./build.sh continuous
|
||||
|
||||
2
.github/workflows/ios-continuous.yml
vendored
2
.github/workflows/ios-continuous.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/ios && printf "y" | ./build.sh continuous
|
||||
|
||||
4
.github/workflows/linux-continuous.yml
vendored
4
.github/workflows/linux-continuous.yml
vendored
@@ -10,10 +10,10 @@ on:
|
||||
jobs:
|
||||
build-linux:
|
||||
name: build-linux
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/linux && printf "y" | ./build.sh continuous
|
||||
|
||||
2
.github/workflows/mac-continuous.yml
vendored
2
.github/workflows/mac-continuous.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/mac && printf "y" | ./build.sh continuous
|
||||
|
||||
16
.github/workflows/presubmit.yml
vendored
16
.github/workflows/presubmit.yml
vendored
@@ -15,10 +15,10 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-18.04]
|
||||
os: [macos-latest, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
|
||||
@@ -32,7 +32,7 @@ jobs:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
build\windows\build-github.bat presubmit
|
||||
@@ -43,7 +43,11 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/android && printf "y" | ./build.sh presubmit
|
||||
@@ -53,7 +57,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/ios && printf "y" | ./build.sh presubmit
|
||||
@@ -66,7 +70,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/web && printf "y" | ./build.sh presubmit
|
||||
|
||||
16
.github/workflows/release.yml
vendored
16
.github/workflows/release.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-18.04]
|
||||
os: [macos-latest, ubuntu-22.04]
|
||||
|
||||
steps:
|
||||
- name: Decide Git ref
|
||||
@@ -41,7 +41,7 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
@@ -76,7 +76,7 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
@@ -109,9 +109,13 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- name: Run build script
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
@@ -160,7 +164,7 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
@@ -194,7 +198,7 @@ jobs:
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
|
||||
1
.github/workflows/verify-release-notes.yml
vendored
1
.github/workflows/verify-release-notes.yml
vendored
@@ -24,3 +24,4 @@ jobs:
|
||||
with:
|
||||
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
pull-request-number: ${{ github.event.pull_request.number }}
|
||||
release-notes-file: 'NEW_RELEASE_NOTES.md'
|
||||
|
||||
2
.github/workflows/web-continuous.yml
vendored
2
.github/workflows/web-continuous.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/web && printf "y" | ./build.sh continuous
|
||||
|
||||
2
.github/workflows/windows-continuous.yml
vendored
2
.github/workflows/windows-continuous.yml
vendored
@@ -13,7 +13,7 @@ jobs:
|
||||
runs-on: windows-2019
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
build\windows\build-github.bat continuous
|
||||
|
||||
23
BUILDING.md
23
BUILDING.md
@@ -5,7 +5,7 @@
|
||||
To build Filament, you must first install the following tools:
|
||||
|
||||
- CMake 3.19 (or more recent)
|
||||
- clang 7.0 (or more recent)
|
||||
- clang 14.0 (or more recent)
|
||||
- [ninja 1.10](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages) (or more recent)
|
||||
|
||||
Additional dependencies may be required for your operating system. Please refer to the appropriate
|
||||
@@ -13,9 +13,10 @@ section below.
|
||||
|
||||
To build Filament for Android you must also install the following:
|
||||
|
||||
- Android Studio Arctic Fox or more recent
|
||||
- Android Studio Flamingo or more recent
|
||||
- Android SDK
|
||||
- Android NDK 25.1 or higher
|
||||
- Java 17
|
||||
|
||||
### Environment variables
|
||||
|
||||
@@ -77,7 +78,7 @@ To turn an option on or off:
|
||||
|
||||
```
|
||||
$ cd <cmake-build-directory>
|
||||
$ cmake . -DOPTION=ON # Relace OPTION with the option name, set to ON / OFF
|
||||
$ cmake . -DOPTION=ON # Replace OPTION with the option name, set to ON / OFF
|
||||
```
|
||||
|
||||
Options can also be set with the CMake GUI.
|
||||
@@ -86,12 +87,14 @@ Options can also be set with the CMake GUI.
|
||||
|
||||
Make sure you've installed the following dependencies:
|
||||
|
||||
- `clang-7` or higher
|
||||
- `clang-14` or higher
|
||||
- `libglu1-mesa-dev`
|
||||
- `libc++-7-dev` (`libcxx-devel` and `libcxx-static` on Fedora) or higher
|
||||
- `libc++abi-7-dev` (`libcxxabi-static` on Fedora) or higher
|
||||
- `libc++-14-dev` (`libcxx-devel` and `libcxx-static` on Fedora) or higher
|
||||
- `libc++abi-14-dev` (`libcxxabi-static` on Fedora) or higher
|
||||
- `ninja-build`
|
||||
- `libxi-dev`
|
||||
- `libxcomposite-dev` (`libXcomposite-devel` on Fedora)
|
||||
- `libxxf86vm-dev` (`libXxf86vm-devel` on Fedora)
|
||||
|
||||
After dependencies have been installed, we highly recommend using the [easy build](#easy-build)
|
||||
script.
|
||||
@@ -111,7 +114,7 @@ Your Linux distribution might default to `gcc` instead of `clang`, if that's the
|
||||
```
|
||||
$ mkdir out/cmake-release
|
||||
$ cd out/cmake-release
|
||||
# Or use a specific version of clang, for instance /usr/bin/clang-7
|
||||
# Or use a specific version of clang, for instance /usr/bin/clang-14
|
||||
$ CC=/usr/bin/clang CXX=/usr/bin/clang++ CXXFLAGS=-stdlib=libc++ \
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../release/filament ../..
|
||||
```
|
||||
@@ -121,8 +124,8 @@ solution is to use `update-alternatives` to both change the default compiler, an
|
||||
specific version of clang:
|
||||
|
||||
```
|
||||
$ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-7 100
|
||||
$ update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-7 100
|
||||
$ update-alternatives --install /usr/bin/clang clang /usr/bin/clang-14 100
|
||||
$ update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 100
|
||||
$ update-alternatives --install /usr/bin/cc cc /usr/bin/clang 100
|
||||
$ update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
|
||||
```
|
||||
@@ -178,7 +181,7 @@ Install the following components:
|
||||
- [Python 3.7](https://www.python.org/ftp/python/3.7.0/python-3.7.0.exe)
|
||||
- [CMake 3.14 or later](https://github.com/Kitware/CMake/releases/download/v3.14.7/cmake-3.14.7-win64-x64.msi)
|
||||
|
||||
The latest Windows SDK can also by installed by opening Visual Studio and selecting _Get Tools and
|
||||
The latest Windows SDK can also be installed by opening Visual Studio and selecting _Get Tools and
|
||||
Features..._ under the _Tools_ menu.
|
||||
|
||||
By default, Windows treats the file system as case insensitive. Please do not enable case
|
||||
|
||||
@@ -31,6 +31,8 @@ option(FILAMENT_SKIP_SDL2 "Skip dependencies of SDL2, and SDL2" OFF)
|
||||
|
||||
option(FILAMENT_LINUX_IS_MOBILE "Treat Linux as Mobile" OFF)
|
||||
|
||||
option(FILAMENT_ENABLE_ASAN_UBSAN "Enable Address and Undefined Behavior Sanitizers" OFF)
|
||||
|
||||
set(FILAMENT_NDK_VERSION "" CACHE STRING
|
||||
"Android NDK version or version prefix to be used when building for Android."
|
||||
)
|
||||
@@ -67,25 +69,30 @@ endif()
|
||||
# ==================================================================================================
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if (CCACHE_PROGRAM)
|
||||
set(C_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
set(CXX_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
|
||||
configure_file(build/launch-c.in launch-c)
|
||||
configure_file(build/launch-cxx.in launch-cxx)
|
||||
|
||||
execute_process(COMMAND chmod a+rx
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/launch-c"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/launch-cxx"
|
||||
)
|
||||
|
||||
if (CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_CURRENT_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_CURRENT_BINARY_DIR}/launch-cxx")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_CURRENT_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_CURRENT_BINARY_DIR}/launch-cxx")
|
||||
if (WIN32)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
else()
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_CURRENT_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_CURRENT_BINARY_DIR}/launch-cxx")
|
||||
set(C_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
set(CXX_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
|
||||
configure_file(build/launch-c.in launch-c)
|
||||
configure_file(build/launch-cxx.in launch-cxx)
|
||||
|
||||
execute_process(COMMAND chmod a+rx
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/launch-c"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/launch-cxx"
|
||||
)
|
||||
|
||||
if (CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_CURRENT_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_CURRENT_BINARY_DIR}/launch-cxx")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_CURRENT_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_CURRENT_BINARY_DIR}/launch-cxx")
|
||||
else()
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_CURRENT_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_CURRENT_BINARY_DIR}/launch-cxx")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -117,11 +124,16 @@ if (LINUX)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_XCB)
|
||||
endif()
|
||||
|
||||
# Default Swiftshader build does not enable the xlib extension
|
||||
if (FILAMENT_SUPPORTS_XLIB AND FILAMENT_USE_SWIFTSHADER)
|
||||
set(FILAMENT_SUPPORTS_XLIB OFF)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_XLIB)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_XLIB)
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_XCB OR FILAMENT_SUPORTS_XLIB)
|
||||
if (FILAMENT_SUPPORTS_XCB OR FILAMENT_SUPPORTS_XLIB)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_X11)
|
||||
set(FILAMENT_SUPPORTS_X11 TRUE)
|
||||
endif()
|
||||
@@ -360,6 +372,12 @@ if (ANDROID OR IOS OR WEBGL)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Turn off exceptions on iOS debug as well. This fixes an availability error we see when using
|
||||
# std::visit, which is not supported on iOS 11.0 when exceptions are enabled.
|
||||
if (IOS)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-exceptions")
|
||||
endif()
|
||||
|
||||
# With WebGL, we disable RTTI even for debug builds because we pass emscripten::val back and forth
|
||||
# between C++ and JavaScript in order to efficiently access typed arrays, which are unbound.
|
||||
# NOTE: This is not documented in emscripten so we should consider a different approach.
|
||||
@@ -374,10 +392,10 @@ endif()
|
||||
# ==================================================================================================
|
||||
# Debug compiler flags
|
||||
# ==================================================================================================
|
||||
# ASAN is deactivated for now because:
|
||||
# -fsanitize=undefined causes extremely long link times
|
||||
# -fsanitize=address causes a crash with assimp, which we can't explain for now
|
||||
#set(EXTRA_SANITIZE_OPTIONS "-fsanitize=undefined -fsanitize=address")
|
||||
if (FILAMENT_ENABLE_ASAN_UBSAN)
|
||||
set(EXTRA_SANITIZE_OPTIONS "-fsanitize=address -fsanitize=undefined")
|
||||
endif()
|
||||
|
||||
if (NOT MSVC AND NOT WEBGL)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector")
|
||||
endif()
|
||||
@@ -497,9 +515,14 @@ if (FILAMENT_SUPPORTS_METAL)
|
||||
set(MATC_API_FLAGS ${MATC_API_FLAGS} -a metal)
|
||||
endif()
|
||||
|
||||
# Disable optimizations and enable debug info (preserves names in SPIR-V)
|
||||
# Enable debug info (preserves names in SPIR-V)
|
||||
if (FILAMENT_ENABLE_MATDBG)
|
||||
set(MATC_OPT_FLAGS ${MATC_OPT_FLAGS} -d)
|
||||
endif()
|
||||
|
||||
# Disable optimizations
|
||||
if (FILAMENT_DISABLE_MATOPT)
|
||||
set(MATC_OPT_FLAGS -gd)
|
||||
set(MATC_OPT_FLAGS ${MATC_OPT_FLAGS} -g)
|
||||
endif()
|
||||
|
||||
set(MATC_BASE_FLAGS ${MATC_API_FLAGS} -p ${MATC_TARGET} ${MATC_OPT_FLAGS})
|
||||
@@ -675,6 +698,7 @@ add_subdirectory(${EXTERNAL}/robin-map/tnt)
|
||||
add_subdirectory(${EXTERNAL}/smol-v/tnt)
|
||||
add_subdirectory(${EXTERNAL}/benchmark/tnt)
|
||||
add_subdirectory(${EXTERNAL}/meshoptimizer/tnt)
|
||||
add_subdirectory(${EXTERNAL}/mikktspace)
|
||||
add_subdirectory(${EXTERNAL}/cgltf/tnt)
|
||||
add_subdirectory(${EXTERNAL}/draco/tnt)
|
||||
add_subdirectory(${EXTERNAL}/jsmn/tnt)
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -187,7 +187,7 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
Copyright 2023 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
15
NEW_RELEASE_NOTES.md
Normal file
15
NEW_RELEASE_NOTES.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# Filament Release Notes log
|
||||
|
||||
**If you are merging a PR into main**: please add the release note below, under the *Release notes
|
||||
for next branch cut* header.
|
||||
|
||||
**If you are cherry-picking a commit into an rc/ branch**: add the release note under the
|
||||
appropriate header in [RELEASE_NOTES.md](./RELEASE_NOTES.md).
|
||||
|
||||
## Release notes for next branch cut
|
||||
|
||||
- Fix possible NPE when updating fog options from Java/Kotlin
|
||||
- The `emissive` property was not applied properly to `MASKED` materials, and could cause
|
||||
dark fringes to appear (recompile materials)
|
||||
- Allow glTF materials with transmission/volume extensions to choose their alpha mode
|
||||
instead of forcing `MASKED`
|
||||
@@ -31,7 +31,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.filament:filament-android:1.31.0'
|
||||
implementation 'com.google.android.filament:filament-android:1.42.0'
|
||||
}
|
||||
```
|
||||
|
||||
@@ -40,8 +40,8 @@ Here are all the libraries available in the group `com.google.android.filament`:
|
||||
| Artifact | Description |
|
||||
| ------------- | ------------- |
|
||||
| [](https://maven-badges.herokuapp.com/maven-central/com.google.android.filament/filament-android) | The Filament rendering engine itself. |
|
||||
| [](https://maven-badges.herokuapp.com/maven-central/com.google.android.filament/filament-android-debug) | Debug version of `filament-android`. |
|
||||
| [](https://maven-badges.herokuapp.com/maven-central/com.google.android.filament/gltfio-android) | A glTF 2.0 loader for Filament, depends on `filament-android`. |
|
||||
| [](https://maven-badges.herokuapp.com/maven-central/com.google.android.filament/gltfio-android-lite) | Trimmed version of `gltfio` that does not support some glTF extensions. |
|
||||
| [](https://maven-badges.herokuapp.com/maven-central/com.google.android.filament/filament-utils-android) | KTX loading, Kotlin math, and camera utilities, depends on `gltfio-android`. |
|
||||
| [](https://maven-badges.herokuapp.com/maven-central/com.google.android.filament/filamat-android) | A runtime material builder/compiler. This library is large but contains a full shader compiler/validator/optimizer and supports both OpenGL and Vulkan. |
|
||||
| [](https://maven-badges.herokuapp.com/maven-central/com.google.android.filament/filamat-android-lite) | A much smaller alternative to `filamat-android` that can only generate OpenGL shaders. It does not provide validation or optimizations. |
|
||||
@@ -51,7 +51,7 @@ Here are all the libraries available in the group `com.google.android.filament`:
|
||||
iOS projects can use CocoaPods to install the latest release:
|
||||
|
||||
```
|
||||
pod 'Filament', '~> 1.31.0'
|
||||
pod 'Filament', '~> 1.42.0'
|
||||
```
|
||||
|
||||
### Snapshots
|
||||
|
||||
@@ -9,26 +9,15 @@ Before starting, ensure that each of these branches is up-to-date with origin:
|
||||
- rc/$RELEASE
|
||||
- main
|
||||
|
||||
## 0. Make sure the rc/$RELEASE branch has the correct version.
|
||||
## 0. Check versions.
|
||||
|
||||
It should have the version corresponding to its name, $RELEASE.
|
||||
Make sure the rc/$RELEASE branch has the correct Filament version. It should have the version
|
||||
corresponding to its name, $RELEASE.
|
||||
|
||||
## 1. Update RELEASE_NOTES.md on the rc branch.
|
||||
Make sure `MATERIAL_VERSION` has been bumped to a new version if this is a MAJOR or MINOR release
|
||||
(first two version numbers).
|
||||
|
||||
Checkout the rc/$RELEASE branch. In RELEASE_NOTES.md, locate the header corresponding to $RELEASE
|
||||
and write release notes. To see which commits make up the release, run:
|
||||
|
||||
```
|
||||
build/common/release.sh -c rc/$RELEASE
|
||||
```
|
||||
|
||||
Commit the changes to rc/$RELEASE with the title:
|
||||
|
||||
```
|
||||
Update RELEASE_NOTES for $RELEASE
|
||||
```
|
||||
|
||||
## 2. Bump versions on main to $RELEASE.
|
||||
## 1. Bump Filament versions on main to $RELEASE.
|
||||
|
||||
Checkout main and run the following command to bump Filament's version to $RELEASE:
|
||||
|
||||
@@ -44,49 +33,19 @@ Release Filament $RELEASE
|
||||
|
||||
Do not push to origin yet.
|
||||
|
||||
## 3. Cherry-pick RELEASE_NOTES change from rc branch to main.
|
||||
## 2. Update RELEASE_NOTES.md on main.
|
||||
|
||||
```
|
||||
git cherry-pick rc/$RELEASE
|
||||
```
|
||||
Create a new header in RELEASE_NOTES.md for $NEXT_RELEASE. Copy the release notes in
|
||||
NEW_RELEASE_NOTES.md to RELEASE_NOTES.md under the new header. Clear NEW_RELEASE_NOTES.md.
|
||||
|
||||
Update the headers. The "main branch" header becomes a header for $NEXT_RELEASE, and a new "main
|
||||
branch" header is added.
|
||||
|
||||
For example, this:
|
||||
|
||||
```
|
||||
## main branch
|
||||
- foo
|
||||
- bar
|
||||
|
||||
## v1.9.3
|
||||
- baz
|
||||
- bat
|
||||
```
|
||||
|
||||
becomes:
|
||||
|
||||
```
|
||||
## main branch
|
||||
|
||||
## v1.9.4
|
||||
- foo
|
||||
- bar
|
||||
|
||||
## v1.9.3
|
||||
- baz
|
||||
- bat
|
||||
```
|
||||
|
||||
Ammend these changes to the cherry-picked change.
|
||||
Amend these changes to the "Release Filament $RELEASE" commit.
|
||||
|
||||
```
|
||||
git add -u
|
||||
git commit --amend --no-edit
|
||||
```
|
||||
|
||||
## 4. Run release script.
|
||||
## 3. Run release script.
|
||||
|
||||
```
|
||||
build/common/release.sh rc/$RELEASE rc/$NEXT_RELEASE
|
||||
@@ -95,18 +54,18 @@ build/common/release.sh rc/$RELEASE rc/$NEXT_RELEASE
|
||||
This script will merge rc/$RELEASE into release, delete the rc branch, and create a new rc
|
||||
branch called rc/$NEXT_RELEASE. Verify that everything looks okay locally.
|
||||
|
||||
## 5. Push the release branch.
|
||||
## 4. Push the release branch.
|
||||
|
||||
```
|
||||
git push origin release
|
||||
```
|
||||
|
||||
## 6. Create the GitHub release.
|
||||
## 5. Create the GitHub release.
|
||||
|
||||
Use the GitHub UI to create a GitHub release corresponding to $RELEASE version.
|
||||
Make sure the target is set to the release branch.
|
||||
|
||||
## 7. Delete the old rc branch (optional).
|
||||
## 6. Delete the old rc branch (optional).
|
||||
|
||||
This step is optional. The old rc branch may be left alive for a few weeks for posterity.
|
||||
|
||||
@@ -114,7 +73,7 @@ This step is optional. The old rc branch may be left alive for a few weeks for p
|
||||
git push origin --delete rc/$RELEASE
|
||||
```
|
||||
|
||||
## 8. Bump the version on the new rc branch to $NEXT_RELEASE.
|
||||
## 7. Bump the version on the new rc branch to $NEXT_RELEASE.
|
||||
|
||||
```
|
||||
git checkout rc/$NEXT_RELEASE
|
||||
@@ -127,19 +86,19 @@ Commit the changes to rc/$NEXT_RELEASE with the title:
|
||||
Bump version to $NEXT_RELEASE
|
||||
```
|
||||
|
||||
## 9. Push main.
|
||||
## 8. Push main.
|
||||
|
||||
```
|
||||
git push origin main
|
||||
```
|
||||
|
||||
## 10. Push the new rc branch.
|
||||
## 9. Push the new rc branch.
|
||||
|
||||
```
|
||||
git push origin -u rc/$NEXT_RELEASE
|
||||
```
|
||||
|
||||
## 11. Rebuild the GitHub release (if failed).
|
||||
## 10. Rebuild the GitHub release (if failed).
|
||||
|
||||
Sometimes the GitHub release job will fail. In this case, you can manually re-run the release job.
|
||||
|
||||
|
||||
148
RELEASE_NOTES.md
148
RELEASE_NOTES.md
@@ -3,7 +3,153 @@
|
||||
This file contains one line summaries of commits that are worthy of mentioning in release notes.
|
||||
A new header is inserted each time a *tag* is created.
|
||||
|
||||
## main branch
|
||||
**Do not edit this file unless you are performing a release or cherry-picking into an rc/ branch.**
|
||||
Instead, if you are authoring a PR for the main branch, add your release note to
|
||||
[NEW_RELEASE_NOTES.md](./NEW_RELEASE_NOTES.md).
|
||||
|
||||
## v1.42.1
|
||||
|
||||
## v1.42.0
|
||||
|
||||
- engine: add preliminary support for instanced stereoscopic rendering [⚠️ **Recompile materials**]
|
||||
|
||||
## v1.41.0
|
||||
|
||||
- backend: fix #6997 : picking can fail on Adreno [⚠️ **New Material Version**]
|
||||
- backend: A partial workaround for PowerVR devices (#5118, b/190221124) [⚠️ **Recompile Materials**]
|
||||
|
||||
## v1.40.5
|
||||
|
||||
- backend: Disable timer queries on all Mali GPUs (fixes b/233754398)
|
||||
- engine: Add a way to query the validity of most filament objects (see `Engine::isValid`)
|
||||
- opengl: fix b/290388359 : possible crash when shutting down the engine
|
||||
- engine: Improve precision of frame time measurement when using emulated TimerQueries
|
||||
- backend: Improve frame pacing on Android and Vulkan.
|
||||
- backend: workaround b/291140208 (gltf_viewer crashes on Nexus 6P)
|
||||
- engine: support `setDepthFunc` for `MaterialInstance`
|
||||
- web: Added setDepthFunc()/getDepthFunc() to MaterialInstance
|
||||
- android: Added setDepthFunc()/getDepthFunc() to MaterialInstance
|
||||
|
||||
## v1.40.4
|
||||
|
||||
- gltfio: fix crash when compute morph target without material
|
||||
- matc: fix buggy `variant-filter` flag
|
||||
- web: Added missing setMat3Parameter()/setMat4Parameter() to MaterialInstance
|
||||
- opengl: fix b/290670707 : crash when using the blob cache
|
||||
- engine: fix a crash with `Material::compile()` when a callback is specified
|
||||
|
||||
## v1.40.3
|
||||
|
||||
## v1.40.2
|
||||
|
||||
- rendering: dynamic resolution would not work with a translucent render target and quality > low
|
||||
- Java/Kotlin: user callbacks were not invoked on successful texture upload
|
||||
|
||||
## v1.40.1
|
||||
|
||||
## v1.40.0
|
||||
|
||||
- matc: fix VSM high precision option on mobile [⚠️ **Recompile materials**]
|
||||
- vulkan: support sRGB swap chain
|
||||
- Add new `getMaxAutomaticInstances()` API on `Engine` to get max supported automatic instances.
|
||||
- UiHelper: fix jank when a `TextureView` is resized (fixes b\282220665)
|
||||
- backend: parallel shader compilation support. This breaks and improves the recent `Material::compile` API.
|
||||
|
||||
## v1.39.0
|
||||
|
||||
- matc: workaround a bug in spirv-tools causing vsm to fail [⚠️ **Recompile materials**]
|
||||
|
||||
## v1.38.0
|
||||
|
||||
- engine: a new feature to set a transform on the global-scale fog [⚠️ **Recompile materials**]
|
||||
- engine: large-scale fog can now be opted-out on a per-renderable basis
|
||||
- engine: improve froxelizer resource efficiency [⚠️ **Recompile materials**]
|
||||
- matc: better accounting and validation of used samplers in user materials
|
||||
- engine: add support for sampling fog color from a custom texture [⚠️ **Recompile materials**]
|
||||
- vulkan: introduce new custom swapchain API
|
||||
- vulkan: new context sharing API
|
||||
|
||||
## v1.37.0
|
||||
|
||||
- backend: added `Platform` blob cache APIs, typically used to cache programs [⚠️ **Recompile materials**]
|
||||
|
||||
## v1.36.0
|
||||
|
||||
- engine: a local transform can now be supplied for each GPU instance [⚠️ **Recompile materials**]
|
||||
- everything: Add limited support for OpenGL ES 2.0 devices. [⚠️ **Recompile Materials**]
|
||||
- platform: New virtual on `OpenGLPlatform` to preserve ancillary buffers
|
||||
|
||||
## v1.35.0
|
||||
|
||||
- materials: Materials can now access up to 4 global `vec4` visible by all materials [⚠️ **Recompile Materials**]
|
||||
|
||||
## v1.34.0
|
||||
|
||||
- materials: picking is done in float (prepare for ES2) [⚠️ **New Material Version**]
|
||||
- materials: postLightingBlending is now applied before the fog [⚠️ **Recompile materials**]
|
||||
- vulkan: fix adreno optimized material artifacts [⚠️ **Recompile Materials**]
|
||||
|
||||
## v1.33.0
|
||||
|
||||
- materials: prepare ES2 support [⚠️ **New Material Version**]
|
||||
|
||||
## v1.32.4
|
||||
|
||||
- engine: Add support for _constant parameters_, which are constants that can be specialized after material compilation.
|
||||
- materials: improved size reduction of OpenGL/Metal shaders by ~65% when compiling materials with
|
||||
size optimizations (`matc -S`) [⚠️ **Recompile Materials**]
|
||||
- engine: fix potential crash on Metal devices with A8X GPU (iPad Air 2) [⚠️ **Recompile Materials**]
|
||||
- opengl: support the external image on macOS
|
||||
|
||||
## v1.32.3
|
||||
|
||||
- fog: added an option to disable the fog after a certain distance [⚠️ **Recompile Materials**].
|
||||
- fog: fog color now takes exposure and IBL intensity into account [⚠️ **Recompile Materials**].
|
||||
- materials: implement cascades debugging as a post-process [⚠️ **Recompile Materials**].
|
||||
- materials: use 9 digits or less for floats [⚠️ **Recompile Materials**].
|
||||
- gltfio: fix skinning when objects are far from the origin
|
||||
- materials: remove 4 unneeded variants from `unlit` materials [⚠️ **Recompile Materials**].
|
||||
|
||||
## v1.32.2
|
||||
|
||||
- lighting: the sun disc was computed in low/medium quality instead of high quality. This will
|
||||
provide performance improvements to mobile devices [⚠️ **Recompile Materials**]
|
||||
|
||||
## v1.32.1
|
||||
|
||||
## v1.32.0
|
||||
|
||||
- fog: fixed fog height falloff and computation precision on mobile [⚠️ **Recompile Materials**]
|
||||
- materials: new alphaToCoverage property can be used to control alpha to coverage behavior
|
||||
- materials: added `getUserWorldFromWorldMatrix()` and `getUserWorldPosition()` to retrieve the
|
||||
API-level (user) world position in materials. Deprecated `getWorldOffset()`. [⚠️ **Recompile
|
||||
Materials**]
|
||||
- engine: fix precision issue with `shading_view` in large scenes
|
||||
- vulkan: readPixels is now async (#6560)
|
||||
|
||||
## v1.31.7
|
||||
|
||||
## v1.31.6
|
||||
|
||||
- engine: the default render channel is now 2 instead of 0
|
||||
- gltfio: Fix crash when a MIME type has no texture provider
|
||||
|
||||
## v1.31.5
|
||||
|
||||
- gltfio: fix potential early freeing of data provided with `ResourceLoader::addResourceData`.
|
||||
|
||||
## v1.31.4
|
||||
|
||||
- engine: fix broken picking [⚠️ **Recompile Materials to get the fix**]
|
||||
- engine: added support for sRGB swapchains. See `SwapChain.h`
|
||||
- bluegl: support Windows32
|
||||
|
||||
## v1.31.3
|
||||
|
||||
- vulkan: fix memory leak in readPixels
|
||||
- engine: added support for draw-commands channels (stronger ordering of commands/renderables)
|
||||
|
||||
## v1.31.2
|
||||
|
||||
## v1.31.1
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ gradlew -Pcom.google.android.filament.dist-dir=..\out\android-release\filament a
|
||||
If you're only interested in building SDK, you may skip samples build by passing a `com.google.android.filament.skip-samples` flag:
|
||||
|
||||
```
|
||||
gradlew -Pcom.google.android.filament.dist-dir=..\out\android-release\filament assembleRelease -Pfilament_skip_samples
|
||||
gradlew -Pcom.google.android.filament.dist-dir=..\out\android-release\filament assembleRelease -Pcom.google.android.filament.skip-samples
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,10 @@
|
||||
// When set, support for Vulkan will be excluded.
|
||||
//
|
||||
// com.google.android.filament.matdbg
|
||||
// When set, enables matdbg, disables shader optimizations
|
||||
// When set, enables matdbg
|
||||
//
|
||||
// com.google.android.filament.matnopt
|
||||
// When set, disable shader optimizations.
|
||||
//
|
||||
// com.google.android.filament.skip-samples
|
||||
// Exclude samples from the project. Useful to speed up compilation.
|
||||
@@ -62,6 +65,10 @@ buildscript {
|
||||
.gradleProperty("com.google.android.filament.matdbg")
|
||||
.isPresent()
|
||||
|
||||
def matnopt = providers
|
||||
.gradleProperty("com.google.android.filament.matnopt")
|
||||
.isPresent()
|
||||
|
||||
def abis = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
|
||||
def newAbis = providers
|
||||
.gradleProperty("com.google.android.filament.abis")
|
||||
@@ -72,15 +79,16 @@ buildscript {
|
||||
}
|
||||
|
||||
ext.versions = [
|
||||
'jdk': 17,
|
||||
'minSdk': 19,
|
||||
'targetSdk': 33,
|
||||
'compileSdk': 33,
|
||||
'kotlin': '1.7.10',
|
||||
'kotlin_coroutines': '1.6.1',
|
||||
'buildTools': '33.0.0',
|
||||
'kotlin': '1.9.0',
|
||||
'kotlin_coroutines': '1.7.2',
|
||||
'buildTools': '34.0.0',
|
||||
'ndk': '25.1.8937393',
|
||||
'androidx_core': '1.9.0',
|
||||
'androidx_annotations': '1.3.0'
|
||||
'androidx_core': '1.10.1',
|
||||
'androidx_annotations': '1.6.0'
|
||||
]
|
||||
|
||||
ext.deps = [
|
||||
@@ -96,8 +104,7 @@ buildscript {
|
||||
]
|
||||
|
||||
dependencies {
|
||||
// NOTE: See TODO in gradle.properties once we move to Gradle 7.4
|
||||
classpath 'com.android.tools.build:gradle:7.3.0'
|
||||
classpath 'com.android.tools.build:gradle:8.1.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
|
||||
}
|
||||
|
||||
@@ -109,7 +116,7 @@ buildscript {
|
||||
"-DFILAMENT_DIST_DIR=${filamentPath}".toString(),
|
||||
"-DFILAMENT_SUPPORTS_VULKAN=${excludeVulkan ? 'OFF' : 'ON'}".toString(),
|
||||
"-DFILAMENT_ENABLE_MATDBG=${matdbg ? 'ON' : 'OFF'}".toString(),
|
||||
"-DFILAMENT_DISABLE_MATOPT=${matdbg ? 'ON' : 'OFF'}".toString()
|
||||
"-DFILAMENT_DISABLE_MATOPT=${matnopt ? 'ON' : 'OFF'}".toString()
|
||||
]
|
||||
|
||||
ext.cppFlags = [
|
||||
@@ -120,6 +127,7 @@ buildscript {
|
||||
"-fno-asynchronous-unwind-tables",
|
||||
"-fno-rtti",
|
||||
"-ffast-math",
|
||||
"-fno-finite-math-only",
|
||||
"-ffp-contract=fast",
|
||||
"-fvisibility-inlines-hidden",
|
||||
"-fvisibility=hidden",
|
||||
@@ -144,7 +152,7 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
|
||||
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
|
||||
}
|
||||
|
||||
// See https://github.com/gradle-nexus/publish-plugin
|
||||
@@ -187,6 +195,7 @@ subprojects {
|
||||
}
|
||||
|
||||
ndk {
|
||||
//noinspection ChromeOsAbiSupport
|
||||
abiFilters(*rootProject.ext.abis)
|
||||
}
|
||||
|
||||
@@ -207,8 +216,8 @@ subprojects {
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +142,14 @@ abstract class MaterialCompiler extends TaskWithBinary {
|
||||
if (!exclude_vulkan) {
|
||||
matcArgs += ['-a', 'vulkan']
|
||||
}
|
||||
|
||||
def mat_no_opt = providers
|
||||
.gradleProperty("com.google.android.filament.matnopt")
|
||||
.forUseAtConfigurationTime().present
|
||||
if (mat_no_opt) {
|
||||
matcArgs += ['-g']
|
||||
}
|
||||
|
||||
matcArgs += ['-a', 'opengl', '-p', 'mobile', '-o', getOutputFile(file), file]
|
||||
|
||||
exec.exec {
|
||||
|
||||
@@ -17,6 +17,17 @@ android {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
singleVariant("fullRelease") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
singleVariant("liteRelease") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -250,6 +250,13 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMaskThr
|
||||
builder->maskThreshold(maskThreshold);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderAlphaToCoverage(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jboolean enable) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->alphaToCoverage(enable);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderShadowMultiplier(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean shadowMultiplier) {
|
||||
|
||||
@@ -360,6 +360,12 @@ public class MaterialBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder alphaToCoverage(boolean enable) {
|
||||
nMaterialBuilderAlphaToCoverage(mNativeObject, enable);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder shadowMultiplier(boolean shadowMultiplier) {
|
||||
nMaterialBuilderShadowMultiplier(mNativeObject, shadowMultiplier);
|
||||
@@ -584,6 +590,7 @@ public class MaterialBuilder {
|
||||
private static native void nMaterialBuilderDepthCulling(long nativeBuilder, boolean enable);
|
||||
private static native void nMaterialBuilderDoubleSided(long nativeBuilder, boolean doubleSided);
|
||||
private static native void nMaterialBuilderMaskThreshold(long nativeBuilder, float mode);
|
||||
private static native void nMaterialBuilderAlphaToCoverage(long nativeBuilder, boolean enable);
|
||||
|
||||
private static native void nMaterialBuilderShadowMultiplier(long mNativeObject,
|
||||
boolean shadowMultiplier);
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
android {
|
||||
namespace 'com.google.android.filament'
|
||||
|
||||
publishing {
|
||||
singleVariant("release") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -278,6 +278,112 @@ Java_com_google_android_filament_Engine_nDestroyEntity(JNIEnv*, jclass,
|
||||
engine->destroy(entity);
|
||||
}
|
||||
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidRenderer(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeRenderer) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((Renderer*)nativeRenderer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidView(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeView) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((View*)nativeView);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidScene(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeScene) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((Scene*)nativeScene);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidFence(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeFence) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((Fence*)nativeFence);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidStream(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeStream) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((Stream*)nativeStream);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidIndexBuffer(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeIndexBuffer) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((IndexBuffer*)nativeIndexBuffer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidVertexBuffer(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeVertexBuffer) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((VertexBuffer*)nativeVertexBuffer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidSkinningBuffer(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeSkinningBuffer) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((SkinningBuffer*)nativeSkinningBuffer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidIndirectLight(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeIndirectLight) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((IndirectLight*)nativeIndirectLight);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidMaterial(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeMaterial) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((Material*)nativeMaterial);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidSkybox(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeSkybox) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((Skybox*)nativeSkybox);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidColorGrading(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeColorGrading) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((ColorGrading*)nativeColorGrading);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidTexture(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeTexture) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((Texture*)nativeTexture);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidRenderTarget(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeTarget) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((RenderTarget*)nativeTarget);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsValidSwapChain(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeSwapChain) {
|
||||
Engine* engine = (Engine *)nativeEngine;
|
||||
return (jboolean)engine->isValid((SwapChain*)nativeSwapChain);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Engine_nFlushAndWait(JNIEnv*, jclass,
|
||||
jlong nativeEngine) {
|
||||
|
||||
@@ -153,6 +153,14 @@ Java_com_google_android_filament_Material_nIsDoubleSided(JNIEnv*, jclass,
|
||||
return (jboolean) material->isDoubleSided();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Material_nIsAlphaToCoverageEnabled(JNIEnv*, jclass,
|
||||
jlong nativeMaterial) {
|
||||
Material* material = (Material*) nativeMaterial;
|
||||
return (jboolean) material->isAlphaToCoverageEnabled();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Material_nGetMaskThreshold(JNIEnv*, jclass,
|
||||
|
||||
@@ -246,17 +246,21 @@ Java_com_google_android_filament_MaterialInstance_nSetFloatParameterArray(JNIEnv
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
// defined in TextureSampler.cpp
|
||||
namespace filament::JniUtils {
|
||||
TextureSampler from_long(jlong params) noexcept;
|
||||
} // TextureSamplerJniUtils
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetParameterTexture(
|
||||
JNIEnv *env, jclass, jlong nativeMaterialInstance, jstring name_,
|
||||
jlong nativeTexture, jint sampler_) {
|
||||
jlong nativeTexture, jlong sampler_) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
Texture* texture = (Texture*) nativeTexture;
|
||||
TextureSampler& sampler = reinterpret_cast<TextureSampler&>(sampler_);
|
||||
|
||||
const char *name = env->GetStringUTFChars(name_, 0);
|
||||
instance->setParameter(name, texture, sampler);
|
||||
instance->setParameter(name, texture, JniUtils::from_long(sampler_));
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
@@ -357,6 +361,14 @@ Java_com_google_android_filament_MaterialInstance_nSetDepthCulling(JNIEnv*,
|
||||
instance->setDepthCulling(enable);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetDepthFunc(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jlong function) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setDepthFunc(static_cast<MaterialInstance::DepthFunc>(function));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilCompareFunction(JNIEnv*, jclass,
|
||||
@@ -457,7 +469,6 @@ extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetMaskThreshold(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
// TODO: implement nGetMaskThreshold()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->getMaskThreshold();
|
||||
}
|
||||
@@ -466,7 +477,6 @@ extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetSpecularAntiAliasingVariance(JNIEnv* env,
|
||||
jclass clazz, jlong nativeMaterialInstance) {
|
||||
// TODO: implement nGetSpecularAntiAliasingVariance()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->getSpecularAntiAliasingVariance();
|
||||
}
|
||||
@@ -475,7 +485,6 @@ extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetSpecularAntiAliasingThreshold(JNIEnv* env,
|
||||
jclass clazz, jlong nativeMaterialInstance) {
|
||||
// TODO: implement nGetSpecularAntiAliasingThreshold()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->getSpecularAntiAliasingThreshold();
|
||||
}
|
||||
@@ -484,7 +493,6 @@ extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsDoubleSided(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
// TODO: implement nIsDoubleSided()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isDoubleSided();
|
||||
}
|
||||
@@ -493,7 +501,6 @@ extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetCullingMode(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
// TODO: implement nGetCullingMode()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return (jint)instance->getCullingMode();
|
||||
}
|
||||
@@ -502,7 +509,6 @@ extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsColorWriteEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
// TODO: implement nIsColorWriteEnabled()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isColorWriteEnabled();
|
||||
}
|
||||
@@ -511,7 +517,6 @@ extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsDepthWriteEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
// TODO: implement nIsDepthWriteEnabled()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isDepthWriteEnabled();
|
||||
}
|
||||
@@ -520,7 +525,6 @@ extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsStencilWriteEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
// TODO: implement nIsStencilWriteEnabled()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isStencilWriteEnabled();
|
||||
}
|
||||
@@ -529,7 +533,14 @@ extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsDepthCullingEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
// TODO: implement nIsDepthCullingEnabled()
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isDepthCullingEnabled();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetDepthFunc(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return (jint)instance->getDepthFunc();
|
||||
}
|
||||
|
||||
@@ -150,6 +150,13 @@ Java_com_google_android_filament_RenderableManager_nBuilderPriority(JNIEnv*, jcl
|
||||
builder->priority((uint8_t) priority);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderChannel(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint channel) {
|
||||
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
|
||||
builder->channel((uint8_t) channel);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderCulling(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enabled) {
|
||||
@@ -194,12 +201,19 @@ Java_com_google_android_filament_RenderableManager_nBuilderSkinning(JNIEnv*, jcl
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nEnableSkinningBuffers(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderEnableSkinningBuffers(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enabled) {
|
||||
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
|
||||
builder->enableSkinningBuffers(enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderFog(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enabled) {
|
||||
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
|
||||
builder->fog(enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderSkinningBones(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jint boneCount, jobject bones, jint remaining) {
|
||||
@@ -339,6 +353,13 @@ Java_com_google_android_filament_RenderableManager_nSetPriority(JNIEnv*, jclass,
|
||||
rm->setPriority((RenderableManager::Instance) i, (uint8_t) priority);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetChannel(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jint channel) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
rm->setChannel((RenderableManager::Instance) i, (uint8_t) channel);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetCulling(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jboolean enabled) {
|
||||
@@ -346,6 +367,20 @@ Java_com_google_android_filament_RenderableManager_nSetCulling(JNIEnv*, jclass,
|
||||
rm->setCulling((RenderableManager::Instance) i, enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetFogEnabled(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jboolean enabled) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
rm->setFogEnabled((RenderableManager::Instance) i, enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nGetFogEnabled(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
return (jboolean)rm->getFogEnabled((RenderableManager::Instance) i);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetCastShadows(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jboolean enabled) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/SwapChain.h>
|
||||
|
||||
#include "common/CallbackUtils.h"
|
||||
@@ -26,9 +27,14 @@ extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SwapChain_nSetFrameCompletedCallback(JNIEnv* env, jclass,
|
||||
jlong nativeSwapChain, jobject handler, jobject runnable) {
|
||||
SwapChain* swapChain = (SwapChain*) nativeSwapChain;
|
||||
auto *callback = JniCallback::make(env, handler, runnable);
|
||||
swapChain->setFrameCompletedCallback([](void* user) {
|
||||
JniCallback* callback = (JniCallback*)user;
|
||||
auto* callback = JniCallback::make(env, handler, runnable);
|
||||
swapChain->setFrameCompletedCallback(nullptr, [callback](SwapChain* swapChain) {
|
||||
JniCallback::postToJavaAndDestroy(callback);
|
||||
}, callback);
|
||||
});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_SwapChain_nIsSRGBSwapChainSupported(JNIEnv *, jclass, jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (bool)SwapChain::isSRGBSwapChainSupported(*engine);
|
||||
}
|
||||
|
||||
@@ -511,9 +511,7 @@ public:
|
||||
|
||||
private:
|
||||
void* mData = nullptr;
|
||||
jobject mBitmap = nullptr;
|
||||
jobject mHandler = nullptr;
|
||||
jobject mCallback = nullptr;
|
||||
jobject mBitmap{};
|
||||
AndroidBitmapInfo mInfo{};
|
||||
};
|
||||
|
||||
|
||||
@@ -18,142 +18,139 @@
|
||||
|
||||
#include <filament/TextureSampler.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
using namespace filament;
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nCreateSampler(JNIEnv *env, jclass type, jint min,
|
||||
namespace filament::JniUtils {
|
||||
|
||||
jlong to_long(TextureSampler const& sampler) noexcept {
|
||||
return jlong(utils::bit_cast<uint32_t>(sampler.getSamplerParams()));
|
||||
}
|
||||
|
||||
TextureSampler from_long(jlong params) noexcept {
|
||||
return TextureSampler{
|
||||
utils::bit_cast<backend::SamplerParams>(
|
||||
static_cast<uint32_t>(params))};
|
||||
}
|
||||
|
||||
} // namespace filament::JniUtils
|
||||
|
||||
using namespace JniUtils;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nCreateSampler(JNIEnv *, jclass, jint min,
|
||||
jint max, jint s, jint t, jint r) {
|
||||
return TextureSampler(static_cast<TextureSampler::MinFilter>(min),
|
||||
static_cast<TextureSampler::MagFilter>(max), static_cast<TextureSampler::WrapMode>(s),
|
||||
static_cast<TextureSampler::WrapMode>(t),
|
||||
static_cast<TextureSampler::WrapMode>(r)).getSamplerParams().u;
|
||||
TextureSampler sampler(static_cast<TextureSampler::MinFilter>(min),
|
||||
static_cast<TextureSampler::MagFilter>(max),
|
||||
static_cast<TextureSampler::WrapMode>(s),
|
||||
static_cast<TextureSampler::WrapMode>(t),
|
||||
static_cast<TextureSampler::WrapMode>(r));
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nCreateCompareSampler(JNIEnv *env, jclass type,
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nCreateCompareSampler(JNIEnv *, jclass,
|
||||
jint mode, jint function) {
|
||||
return TextureSampler(static_cast<TextureSampler::CompareMode>(mode),
|
||||
static_cast<TextureSampler::CompareFunc>(function)).getSamplerParams().u;
|
||||
TextureSampler sampler(static_cast<TextureSampler::CompareMode>(mode),
|
||||
static_cast<TextureSampler::CompareFunc>(function));
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetMinFilter(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return static_cast<jint>(sampler.getMinFilter());
|
||||
Java_com_google_android_filament_TextureSampler_nGetMinFilter(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getMinFilter());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetMinFilter(JNIEnv *env, jclass type,
|
||||
jint sampler_, jint filter) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetMinFilter(JNIEnv *, jclass, jlong sampler_, jint filter) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setMinFilter(static_cast<TextureSampler::MinFilter>(filter));
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetMagFilter(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return static_cast<jint>(sampler.getMagFilter());
|
||||
Java_com_google_android_filament_TextureSampler_nGetMagFilter(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getMagFilter());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetMagFilter(JNIEnv *env, jclass type,
|
||||
jint sampler_, jint filter) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetMagFilter(JNIEnv *, jclass, jlong sampler_, jint filter) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setMagFilter(static_cast<TextureSampler::MagFilter>(filter));
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeS(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return static_cast<jint>(sampler.getWrapModeS());
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeS(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getWrapModeS());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeS(JNIEnv *env, jclass type,
|
||||
jint sampler_, jint mode) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeS(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setWrapModeS(static_cast<TextureSampler::WrapMode>(mode));
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeT(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return static_cast<jint>(sampler.getWrapModeT());
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeT(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getWrapModeT());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeT(JNIEnv *env, jclass type,
|
||||
jint sampler_, jint mode) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeT(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setWrapModeT(static_cast<TextureSampler::WrapMode>(mode));
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeR(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return static_cast<jint>(sampler.getWrapModeR());
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeR(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getWrapModeR());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeR(JNIEnv *env, jclass type,
|
||||
jint sampler_, jint mode) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeR(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setWrapModeR(static_cast<TextureSampler::WrapMode>(mode));
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetCompareMode(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return static_cast<jint>(sampler.getCompareMode());
|
||||
Java_com_google_android_filament_TextureSampler_nGetCompareMode(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getCompareMode());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetCompareMode(JNIEnv *env, jclass type,
|
||||
jint sampler_, jint mode) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetCompareMode(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setCompareMode(static_cast<TextureSampler::CompareMode>(mode),
|
||||
sampler.getCompareFunc());
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetCompareFunction(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return static_cast<jint>(sampler.getCompareFunc());
|
||||
Java_com_google_android_filament_TextureSampler_nGetCompareFunction(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getCompareFunc());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetCompareFunction(JNIEnv *env, jclass type,
|
||||
jint sampler_, jint function) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetCompareFunction(JNIEnv *, jclass, jlong sampler_, jint function) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setCompareMode(sampler.getCompareMode(),
|
||||
static_cast<TextureSampler::CompareFunc>(function));
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetAnisotropy(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return sampler.getAnisotropy();
|
||||
Java_com_google_android_filament_TextureSampler_nGetAnisotropy(JNIEnv *, jclass, jlong sampler) {
|
||||
return from_long(sampler).getAnisotropy();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetAnisotropy(JNIEnv *env, jclass type,
|
||||
jint sampler_, jfloat anisotropy) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetAnisotropy(JNIEnv *, jclass, jlong sampler_, jfloat anisotropy) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
sampler.setAnisotropy(anisotropy);
|
||||
return sampler.getSamplerParams().u;
|
||||
return to_long(sampler);
|
||||
}
|
||||
|
||||
@@ -315,12 +315,14 @@ Java_com_google_android_filament_View_nSetBloomOptions(JNIEnv*, jclass,
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetFogOptions(JNIEnv *, jclass , jlong nativeView,
|
||||
jfloat distance, jfloat maximumOpacity, jfloat height, jfloat heightFalloff, jfloat r,
|
||||
jfloat g, jfloat b, jfloat density, jfloat inScatteringStart,
|
||||
jfloat inScatteringSize, jboolean fogColorFromIbl, jboolean enabled) {
|
||||
jfloat distance, jfloat maximumOpacity, jfloat height, jfloat heightFalloff, jfloat cutOffDistance,
|
||||
jfloat r, jfloat g, jfloat b, jfloat density, jfloat inScatteringStart,
|
||||
jfloat inScatteringSize, jboolean fogColorFromIbl, jlong skyColorNativeObject, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
Texture* skyColor = (Texture*) skyColorNativeObject;
|
||||
View::FogOptions options = {
|
||||
.distance = distance,
|
||||
.cutOffDistance = cutOffDistance,
|
||||
.maximumOpacity = maximumOpacity,
|
||||
.height = height,
|
||||
.heightFalloff = heightFalloff,
|
||||
@@ -329,6 +331,7 @@ Java_com_google_android_filament_View_nSetFogOptions(JNIEnv *, jclass , jlong na
|
||||
.inScatteringStart = inScatteringStart,
|
||||
.inScatteringSize = inScatteringSize,
|
||||
.fogColorFromIbl = (bool)fogColorFromIbl,
|
||||
.skyColor = skyColor,
|
||||
.enabled = (bool)enabled
|
||||
};
|
||||
view->setFogOptions(options);
|
||||
@@ -485,3 +488,30 @@ Java_com_google_android_filament_View_nSetGuardBandOptions(JNIEnv *, jclass,
|
||||
View* view = (View*) nativeView;
|
||||
view->setGuardBandOptions({ .enabled = (bool)enabled });
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetMaterialGlobal(JNIEnv * , jclass, jlong nativeView,
|
||||
jint index, jfloat x, jfloat y, jfloat z, jfloat w) {
|
||||
View *view = (View *) nativeView;
|
||||
view->setMaterialGlobal((uint32_t)index, { x, y, z, w });
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nGetMaterialGlobal(JNIEnv *env, jclass clazz,
|
||||
jlong nativeView, jint index, jfloatArray out_) {
|
||||
jfloat* out = env->GetFloatArrayElements(out_, nullptr);
|
||||
View *view = (View *) nativeView;
|
||||
auto result = view->getMaterialGlobal(index);
|
||||
std::copy_n(result.v, 4, out);
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT int JNICALL
|
||||
Java_com_google_android_filament_View_nGetFogEntity(JNIEnv *env, jclass clazz,
|
||||
jlong nativeView) {
|
||||
View *view = (View *) nativeView;
|
||||
return (jint)view->getFogEntity().getId();
|
||||
}
|
||||
|
||||
@@ -118,6 +118,7 @@ public class ColorGrading {
|
||||
*
|
||||
* @deprecated Use {@link ColorGrading.Builder#toneMapper(ToneMapper)}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum ToneMapping {
|
||||
/** Linear tone mapping (i.e. no tone mapping). */
|
||||
LINEAR,
|
||||
@@ -231,6 +232,7 @@ public class ColorGrading {
|
||||
*
|
||||
* @deprecated Use {@link #toneMapper(ToneMapper)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder toneMapping(ToneMapping toneMapping) {
|
||||
nBuilderToneMapping(mNativeBuilder, toneMapping.ordinal());
|
||||
return this;
|
||||
|
||||
@@ -449,6 +449,141 @@ public class Engine {
|
||||
swapChain.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidRenderer(@NonNull Renderer object) {
|
||||
return nIsValidRenderer(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidView(@NonNull View object) {
|
||||
return nIsValidView(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidScene(@NonNull Scene object) {
|
||||
return nIsValidScene(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidFence(@NonNull Fence object) {
|
||||
return nIsValidFence(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidStream(@NonNull Stream object) {
|
||||
return nIsValidStream(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidIndexBuffer(@NonNull IndexBuffer object) {
|
||||
return nIsValidIndexBuffer(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidVertexBuffer(@NonNull VertexBuffer object) {
|
||||
return nIsValidVertexBuffer(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidSkinningBuffer(@NonNull SkinningBuffer object) {
|
||||
return nIsValidSkinningBuffer(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidIndirectLight(@NonNull IndirectLight object) {
|
||||
return nIsValidIndirectLight(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidMaterial(@NonNull Material object) {
|
||||
return nIsValidMaterial(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidSkybox(@NonNull Skybox object) {
|
||||
return nIsValidSkybox(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidColorGrading(@NonNull ColorGrading object) {
|
||||
return nIsValidColorGrading(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidTexture(@NonNull Texture object) {
|
||||
return nIsValidTexture(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidRenderTarget(@NonNull RenderTarget object) {
|
||||
return nIsValidRenderTarget(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the object is valid.
|
||||
* @param object Object to check for validity
|
||||
* @return returns true if the specified object is valid.
|
||||
*/
|
||||
public boolean isValidSwapChain(@NonNull SwapChain object) {
|
||||
return nIsValidSwapChain(getNativeObject(), object.getNativeObject());
|
||||
}
|
||||
|
||||
// View
|
||||
|
||||
/**
|
||||
@@ -785,17 +920,17 @@ public class Engine {
|
||||
private static native long nCreateSwapChain(long nativeEngine, Object nativeWindow, long flags);
|
||||
private static native long nCreateSwapChainHeadless(long nativeEngine, int width, int height, long flags);
|
||||
private static native long nCreateSwapChainFromRawPointer(long nativeEngine, long pointer, long flags);
|
||||
private static native boolean nDestroySwapChain(long nativeEngine, long nativeSwapChain);
|
||||
private static native long nCreateView(long nativeEngine);
|
||||
private static native boolean nDestroyView(long nativeEngine, long nativeView);
|
||||
private static native long nCreateRenderer(long nativeEngine);
|
||||
private static native boolean nDestroyRenderer(long nativeEngine, long nativeRenderer);
|
||||
private static native long nCreateCamera(long nativeEngine, int entity);
|
||||
private static native long nGetCameraComponent(long nativeEngine, int entity);
|
||||
private static native void nDestroyCameraComponent(long nativeEngine, int entity);
|
||||
private static native long nCreateScene(long nativeEngine);
|
||||
private static native boolean nDestroyScene(long nativeEngine, long nativeScene);
|
||||
private static native long nCreateFence(long nativeEngine);
|
||||
|
||||
private static native boolean nDestroyRenderer(long nativeEngine, long nativeRenderer);
|
||||
private static native boolean nDestroyView(long nativeEngine, long nativeView);
|
||||
private static native boolean nDestroyScene(long nativeEngine, long nativeScene);
|
||||
private static native boolean nDestroyFence(long nativeEngine, long nativeFence);
|
||||
private static native boolean nDestroyStream(long nativeEngine, long nativeStream);
|
||||
private static native boolean nDestroyIndexBuffer(long nativeEngine, long nativeIndexBuffer);
|
||||
@@ -808,6 +943,22 @@ public class Engine {
|
||||
private static native boolean nDestroyColorGrading(long nativeEngine, long nativeColorGrading);
|
||||
private static native boolean nDestroyTexture(long nativeEngine, long nativeTexture);
|
||||
private static native boolean nDestroyRenderTarget(long nativeEngine, long nativeTarget);
|
||||
private static native boolean nDestroySwapChain(long nativeEngine, long nativeSwapChain);
|
||||
private static native boolean nIsValidRenderer(long nativeEngine, long nativeRenderer);
|
||||
private static native boolean nIsValidView(long nativeEngine, long nativeView);
|
||||
private static native boolean nIsValidScene(long nativeEngine, long nativeScene);
|
||||
private static native boolean nIsValidFence(long nativeEngine, long nativeFence);
|
||||
private static native boolean nIsValidStream(long nativeEngine, long nativeStream);
|
||||
private static native boolean nIsValidIndexBuffer(long nativeEngine, long nativeIndexBuffer);
|
||||
private static native boolean nIsValidVertexBuffer(long nativeEngine, long nativeVertexBuffer);
|
||||
private static native boolean nIsValidSkinningBuffer(long nativeEngine, long nativeSkinningBuffer);
|
||||
private static native boolean nIsValidIndirectLight(long nativeEngine, long nativeIndirectLight);
|
||||
private static native boolean nIsValidMaterial(long nativeEngine, long nativeMaterial);
|
||||
private static native boolean nIsValidSkybox(long nativeEngine, long nativeSkybox);
|
||||
private static native boolean nIsValidColorGrading(long nativeEngine, long nativeColorGrading);
|
||||
private static native boolean nIsValidTexture(long nativeEngine, long nativeTexture);
|
||||
private static native boolean nIsValidRenderTarget(long nativeEngine, long nativeTarget);
|
||||
private static native boolean nIsValidSwapChain(long nativeEngine, long nativeSwapChain);
|
||||
private static native void nDestroyEntity(long nativeEngine, int entity);
|
||||
private static native void nFlushAndWait(long nativeEngine);
|
||||
private static native long nGetTransformManager(long nativeEngine);
|
||||
|
||||
@@ -503,6 +503,17 @@ public class Material {
|
||||
return nIsDoubleSided(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether instances of this material will use alpha to coverage.
|
||||
*
|
||||
* @see
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:alphatocoverage">
|
||||
* Rasterization: alphaToCoverage</a>
|
||||
*/
|
||||
public boolean isAlphaToCoverageEnabled() {
|
||||
return nIsAlphaToCoverageEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the alpha mask threshold used when the blending mode is set to masked.
|
||||
*
|
||||
@@ -915,6 +926,7 @@ public class Material {
|
||||
private static native boolean nIsDepthWriteEnabled(long nativeMaterial);
|
||||
private static native boolean nIsDepthCullingEnabled(long nativeMaterial);
|
||||
private static native boolean nIsDoubleSided(long nativeMaterial);
|
||||
private static native boolean nIsAlphaToCoverageEnabled(long nativeMaterial);
|
||||
private static native float nGetMaskThreshold(long nativeMaterial);
|
||||
private static native float nGetSpecularAntiAliasingVariance(long nativeMaterial);
|
||||
private static native float nGetSpecularAntiAliasingThreshold(long nativeMaterial);
|
||||
|
||||
@@ -625,6 +625,15 @@ public class MaterialInstance {
|
||||
nSetDepthCulling(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the depth comparison function (default is {@link TextureSampler.CompareFunction#GE}).
|
||||
*
|
||||
* @param func the depth comparison function
|
||||
*/
|
||||
public void setDepthFunc(TextureSampler.CompareFunction func) {
|
||||
nSetDepthFunc(getNativeObject(), func.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether depth culling is enabled.
|
||||
*/
|
||||
@@ -632,6 +641,13 @@ public class MaterialInstance {
|
||||
return nIsDepthCullingEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the depth comparison function.
|
||||
*/
|
||||
public TextureSampler.CompareFunction getDepthFunc() {
|
||||
return TextureSampler.EnumCache.sCompareFunctionValues[nGetDepthFunc(getNativeObject())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil comparison function (default is {@link TextureSampler.CompareFunction#ALWAYS}).
|
||||
*
|
||||
@@ -884,7 +900,7 @@ public class MaterialInstance {
|
||||
@IntRange(from = 0) int offset, @IntRange(from = 1) int count);
|
||||
|
||||
private static native void nSetParameterTexture(long nativeMaterialInstance,
|
||||
@NonNull String name, long nativeTexture, int sampler);
|
||||
@NonNull String name, long nativeTexture, long sampler);
|
||||
|
||||
private static native void nSetScissor(long nativeMaterialInstance,
|
||||
@IntRange(from = 0) int left, @IntRange(from = 0) int bottom,
|
||||
@@ -908,6 +924,7 @@ public class MaterialInstance {
|
||||
private static native void nSetDepthWrite(long nativeMaterialInstance, boolean enable);
|
||||
private static native void nSetStencilWrite(long nativeMaterialInstance, boolean enable);
|
||||
private static native void nSetDepthCulling(long nativeMaterialInstance, boolean enable);
|
||||
private static native void nSetDepthFunc(long nativeMaterialInstance, long function);
|
||||
|
||||
private static native void nSetStencilCompareFunction(long nativeMaterialInstance,
|
||||
long function, long face);
|
||||
@@ -939,4 +956,5 @@ public class MaterialInstance {
|
||||
private static native boolean nIsDepthWriteEnabled(long nativeMaterialInstance);
|
||||
private static native boolean nIsStencilWriteEnabled(long nativeMaterialInstance);
|
||||
private static native boolean nIsDepthCullingEnabled(long nativeMaterialInstance);
|
||||
private static native int nGetDepthFunc(long nativeMaterialInstance);
|
||||
}
|
||||
|
||||
@@ -81,8 +81,6 @@ public class RenderTarget {
|
||||
/**
|
||||
* Sets a texture to a given attachment point.
|
||||
*
|
||||
* <p>All RenderTargets must have a non-null <code>COLOR</code> attachment.</p>
|
||||
*
|
||||
* @param attachment The attachment point of the texture.
|
||||
* @param texture The associated texture object.
|
||||
* @return A reference to this Builder for chaining calls.
|
||||
|
||||
@@ -257,23 +257,79 @@ public class RenderableManager {
|
||||
* Provides coarse-grained control over draw order.
|
||||
*
|
||||
* <p>In general Filament reserves the right to re-order renderables to allow for efficient
|
||||
* rendering. However clients can control ordering at a coarse level using <em>priority</em>.</p>
|
||||
* rendering. However clients can control ordering at a coarse level using \em priority.
|
||||
* The priority is applied separately for opaque and translucent objects, that is, opaque
|
||||
* objects are always drawn before translucent objects regardless of the priority.</p>
|
||||
*
|
||||
* <p>For example, this could be used to draw a semitransparent HUD, if a client wishes to
|
||||
* avoid using a separate View for the HUD. Note that priority is completely orthogonal to
|
||||
* {@link Builder#layerMask}, which merely controls visibility.</p>
|
||||
|
||||
* <p>The Skybox always using the lowest priority, so it's drawn last, which may improve
|
||||
* performance.</p>
|
||||
*
|
||||
* <p>The priority is clamped to the range [0..7], defaults to 4; 7 is lowest priority
|
||||
* (rendered last).</p>
|
||||
*
|
||||
* @see Builder#blendOrder
|
||||
*/
|
||||
|
||||
/**
|
||||
* Provides coarse-grained control over draw order.
|
||||
*
|
||||
* <p>In general Filament reserves the right to re-order renderables to allow for efficient
|
||||
* rendering. However clients can control ordering at a coarse level using priority.
|
||||
* The priority is applied separately for opaque and translucent objects, that is, opaque
|
||||
* objects are always drawn before translucent objects regardless of the priority.</p>
|
||||
*
|
||||
* <p>For example, this could be used to draw a semitransparent HUD, if a client wishes to
|
||||
* avoid using a separate View for the HUD. Note that priority is completely orthogonal to
|
||||
* {@link Builder#layerMask}, which merely controls visibility.</p>
|
||||
|
||||
* <p>The Skybox always using the lowest priority, so it's drawn last, which may improve
|
||||
* performance.</p>
|
||||
*
|
||||
* @param priority clamped to the range [0..7], defaults to 4; 7 is lowest priority
|
||||
* (rendered last).
|
||||
*
|
||||
* @return Builder reference for chaining calls.
|
||||
*
|
||||
* @see Builder#channel
|
||||
* @see Builder#blendOrder
|
||||
* @see #setPriority
|
||||
* @see #setBlendOrderAt
|
||||
*/
|
||||
@NonNull
|
||||
public Builder priority(@IntRange(from = 0, to = 7) int priority) {
|
||||
nBuilderPriority(mNativeBuilder, priority);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the channel this renderable is associated to. There can be 4 channels.
|
||||
*
|
||||
* <p>All renderables in a given channel are rendered together, regardless of anything else.
|
||||
* They are sorted as usual within a channel.</p>
|
||||
* <p>Channels work similarly to priorities, except that they enforce the strongest
|
||||
* ordering.</p>
|
||||
*
|
||||
* <p>Channels 0 and 1 may not have render primitives using a material with `refractionType`
|
||||
* set to `screenspace`.</p>
|
||||
*
|
||||
* @param channel clamped to the range [0..3], defaults to 2.
|
||||
*
|
||||
* @return Builder reference for chaining calls.
|
||||
*
|
||||
* @see Builder::blendOrder()
|
||||
* @see Builder::priority()
|
||||
* @see RenderableManager::setBlendOrderAt()
|
||||
*/
|
||||
@NonNull
|
||||
public Builder channel(@IntRange(from = 0, to = 3) int channel) {
|
||||
nBuilderChannel(mNativeBuilder, channel);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls frustum culling, true by default.
|
||||
*
|
||||
@@ -300,16 +356,16 @@ public class RenderableManager {
|
||||
|
||||
/**
|
||||
* Specifies the number of draw instance of this renderable. The default is 1 instance and
|
||||
* the maximum number of instances allowed is 65535. 0 is invalid.
|
||||
* the maximum number of instances allowed is 32767. 0 is invalid.
|
||||
* All instances are culled using the same bounding box, so care must be taken to make
|
||||
* sure all instances render inside the specified bounding box.
|
||||
* The material can use getInstanceIndex() in the vertex shader to get the instance index and
|
||||
* possibly adjust the position or transform.
|
||||
*
|
||||
* @param instanceCount the number of instances silently clamped between 1 and 65535.
|
||||
* @param instanceCount the number of instances silently clamped between 1 and 32767.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder instances(@IntRange(from = 1, to = 65535) int instanceCount) {
|
||||
public Builder instances(@IntRange(from = 1, to = 32767) int instanceCount) {
|
||||
nBuilderInstances(mNativeBuilder, instanceCount);
|
||||
return this;
|
||||
}
|
||||
@@ -361,7 +417,19 @@ public class RenderableManager {
|
||||
*/
|
||||
@NonNull
|
||||
public Builder enableSkinningBuffers(boolean enabled) {
|
||||
nEnableSkinningBuffers(mNativeBuilder, enabled);
|
||||
nBuilderEnableSkinningBuffers(mNativeBuilder, enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if this renderable is affected by the large-scale fog.
|
||||
* @param enabled If true, enables large-scale fog on this object. Disables it otherwise.
|
||||
* True by default.
|
||||
* @return this <code>Builder</code> object for chaining calls
|
||||
*/
|
||||
@NonNull
|
||||
public Builder fog(boolean enabled) {
|
||||
nBuilderFog(mNativeBuilder, enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -655,6 +723,15 @@ public class RenderableManager {
|
||||
nSetPriority(mNativeObject, i, priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the channel of a renderable
|
||||
*
|
||||
* @see Builder#channel
|
||||
*/
|
||||
public void setChannel(@EntityInstance int i, @IntRange(from = 0, to = 3) int channel) {
|
||||
nSetChannel(mNativeObject, i, channel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes whether or not frustum culling is on.
|
||||
*
|
||||
@@ -664,6 +741,23 @@ public class RenderableManager {
|
||||
nSetCulling(mNativeObject, i, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes whether or not the large-scale fog is applied to this renderable
|
||||
* @see Builder#fog
|
||||
*/
|
||||
public void setFogEnabled(@EntityInstance int i, boolean enabled) {
|
||||
nSetFogEnabled(mNativeObject, i, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether large-scale fog is enabled for this renderable.
|
||||
* @return True if fog is enabled for this renderable.
|
||||
* @see Builder#fog
|
||||
*/
|
||||
public boolean getFogEnabled(@EntityInstance int i) {
|
||||
return nGetFogEnabled(mNativeObject, i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables a light channel.
|
||||
* Light channel 0 is enabled by default.
|
||||
@@ -876,6 +970,7 @@ public class RenderableManager {
|
||||
private static native void nBuilderBoundingBox(long nativeBuilder, float cx, float cy, float cz, float ex, float ey, float ez);
|
||||
private static native void nBuilderLayerMask(long nativeBuilder, int select, int value);
|
||||
private static native void nBuilderPriority(long nativeBuilder, int priority);
|
||||
private static native void nBuilderChannel(long nativeBuilder, int channel);
|
||||
private static native void nBuilderCulling(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderCastShadows(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderReceiveShadows(long nativeBuilder, boolean enabled);
|
||||
@@ -885,7 +980,8 @@ public class RenderableManager {
|
||||
private static native void nBuilderSkinningBuffer(long nativeBuilder, long nativeSkinningBuffer, int boneCount, int offset);
|
||||
private static native void nBuilderMorphing(long nativeBuilder, int targetCount);
|
||||
private static native void nBuilderSetMorphTargetBufferAt(long nativeBuilder, int level, int primitiveIndex, long nativeMorphTargetBuffer, int offset, int count);
|
||||
private static native void nEnableSkinningBuffers(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderEnableSkinningBuffers(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderFog(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderLightChannel(long nativeRenderableManager, int channel, boolean enable);
|
||||
private static native void nBuilderInstances(long nativeRenderableManager, int instances);
|
||||
|
||||
@@ -898,7 +994,10 @@ public class RenderableManager {
|
||||
private static native void nSetAxisAlignedBoundingBox(long nativeRenderableManager, int i, float cx, float cy, float cz, float ex, float ey, float ez);
|
||||
private static native void nSetLayerMask(long nativeRenderableManager, int i, int select, int value);
|
||||
private static native void nSetPriority(long nativeRenderableManager, int i, int priority);
|
||||
private static native void nSetChannel(long nativeRenderableManager, int i, int channel);
|
||||
private static native void nSetCulling(long nativeRenderableManager, int i, boolean enabled);
|
||||
private static native void nSetFogEnabled(long nativeRenderableManager, int i, boolean enabled);
|
||||
private static native boolean nGetFogEnabled(long nativeRenderableManager, int i);
|
||||
private static native void nSetLightChannel(long nativeRenderableManager, int i, int channel, boolean enable);
|
||||
private static native boolean nGetLightChannel(long nativeRenderableManager, int i, int channel);
|
||||
private static native void nSetCastShadows(long nativeRenderableManager, int i, boolean enabled);
|
||||
|
||||
@@ -91,11 +91,34 @@ public class SwapChain {
|
||||
*/
|
||||
public static final long CONFIG_ENABLE_XCB = 0x4;
|
||||
|
||||
/**
|
||||
* Indicates that the SwapChain must automatically perform linear to sRGB encoding.
|
||||
*
|
||||
* This flag is ignored if isSRGBSwapChainSupported() is false.
|
||||
*
|
||||
* When using this flag, post-processing should be disabled.
|
||||
*
|
||||
* @see SwapChain#isSRGBSwapChainSupported
|
||||
* @see View#setPostProcessingEnabled
|
||||
*/
|
||||
public static final long CONFIG_SRGB_COLORSPACE = 0x10;
|
||||
|
||||
SwapChain(long nativeSwapChain, Object surface) {
|
||||
mNativeObject = nativeSwapChain;
|
||||
mSurface = surface;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether createSwapChain supports the SWAP_CHAIN_CONFIG_SRGB_COLORSPACE flag.
|
||||
* The default implementation returns false.
|
||||
*
|
||||
* @param engine A reference to the filament Engine
|
||||
* @return true if SWAP_CHAIN_CONFIG_SRGB_COLORSPACE is supported, false otherwise.
|
||||
*/
|
||||
public static boolean isSRGBSwapChainSupported(@NonNull Engine engine) {
|
||||
return nIsSRGBSwapChainSupported(engine.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the native <code>Object</code> this <code>SwapChain</code> was created from or null
|
||||
* for a headless SwapChain.
|
||||
@@ -114,10 +137,6 @@ public class SwapChain {
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The FrameCompletedCallback is guaranteed to be called on the main Filament thread.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Warning: Only Filament's Metal backend supports frame callbacks. Other backends ignore the
|
||||
* callback (which will never be called) and proceed normally.
|
||||
* </p>
|
||||
@@ -141,4 +160,5 @@ public class SwapChain {
|
||||
}
|
||||
|
||||
private static native void nSetFrameCompletedCallback(long nativeSwapChain, Object handler, Runnable callback);
|
||||
private static native boolean nIsSRGBSwapChainSupported(long nativeEngine);
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public class TextureSampler {
|
||||
NEVER
|
||||
}
|
||||
|
||||
int mSampler = 0; // bit field used by native
|
||||
long mSampler = 0; // bit field used by native
|
||||
|
||||
/**
|
||||
* Initializes the <code>TextureSampler</code> with default values.
|
||||
@@ -276,7 +276,7 @@ public class TextureSampler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the wrapping mode in the t (depth) direction.
|
||||
* Sets the wrapping mode in the r (depth) direction.
|
||||
* @param mode wrapping mode
|
||||
*/
|
||||
public void setWrapModeR(WrapMode mode) {
|
||||
@@ -342,26 +342,26 @@ public class TextureSampler {
|
||||
}
|
||||
}
|
||||
|
||||
private static native int nCreateSampler(int min, int max, int s, int t, int r);
|
||||
private static native int nCreateCompareSampler(int mode, int function);
|
||||
private static native long nCreateSampler(int min, int max, int s, int t, int r);
|
||||
private static native long nCreateCompareSampler(int mode, int function);
|
||||
|
||||
private static native int nGetMinFilter(int sampler);
|
||||
private static native int nSetMinFilter(int sampler, int filter);
|
||||
private static native int nGetMagFilter(int sampler);
|
||||
private static native int nSetMagFilter(int sampler, int filter);
|
||||
private static native int nGetMinFilter(long sampler);
|
||||
private static native long nSetMinFilter(long sampler, int filter);
|
||||
private static native int nGetMagFilter(long sampler);
|
||||
private static native long nSetMagFilter(long sampler, int filter);
|
||||
|
||||
private static native int nGetWrapModeS(int sampler);
|
||||
private static native int nSetWrapModeS(int sampler, int mode);
|
||||
private static native int nGetWrapModeT(int sampler);
|
||||
private static native int nSetWrapModeT(int sampler, int mode);
|
||||
private static native int nGetWrapModeR(int sampler);
|
||||
private static native int nSetWrapModeR(int sampler, int mode);
|
||||
private static native int nGetWrapModeS(long sampler);
|
||||
private static native long nSetWrapModeS(long sampler, int mode);
|
||||
private static native int nGetWrapModeT(long sampler);
|
||||
private static native long nSetWrapModeT(long sampler, int mode);
|
||||
private static native int nGetWrapModeR(long sampler);
|
||||
private static native long nSetWrapModeR(long sampler, int mode);
|
||||
|
||||
private static native int nGetCompareMode(int sampler);
|
||||
private static native int nSetCompareMode(int sampler, int mode);
|
||||
private static native int nGetCompareFunction(int sampler);
|
||||
private static native int nSetCompareFunction(int sampler, int function);
|
||||
private static native int nGetCompareMode(long sampler);
|
||||
private static native long nSetCompareMode(long sampler, int mode);
|
||||
private static native int nGetCompareFunction(long sampler);
|
||||
private static native long nSetCompareFunction(long sampler, int function);
|
||||
|
||||
private static native float nGetAnisotropy(int sampler);
|
||||
private static native int nSetAnisotropy(int sampler, float anisotropy);
|
||||
private static native float nGetAnisotropy(long sampler);
|
||||
private static native long nSetAnisotropy(long sampler, float anisotropy);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import static com.google.android.filament.Asserts.assertFloat3In;
|
||||
import static com.google.android.filament.Asserts.assertFloat4In;
|
||||
import static com.google.android.filament.Colors.LinearColor;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByNative;
|
||||
|
||||
/**
|
||||
* Encompasses all the state needed for rendering a {@link Scene}.
|
||||
*
|
||||
@@ -962,9 +964,11 @@ public class View {
|
||||
assertFloat3In(options.color);
|
||||
mFogOptions = options;
|
||||
nSetFogOptions(getNativeObject(), options.distance, options.maximumOpacity, options.height,
|
||||
options.heightFalloff, options.color[0], options.color[1], options.color[2],
|
||||
options.heightFalloff, options.cutOffDistance,
|
||||
options.color[0], options.color[1], options.color[2],
|
||||
options.density, options.inScatteringStart, options.inScatteringSize,
|
||||
options.fogColorFromIbl,
|
||||
options.skyColor == null ? 0 : options.skyColor.getNativeObject(),
|
||||
options.enabled);
|
||||
}
|
||||
|
||||
@@ -1094,10 +1098,29 @@ public class View {
|
||||
nPick(getNativeObject(), x, y, handler, internalCallback);
|
||||
}
|
||||
|
||||
@UsedByNative("View.cpp")
|
||||
private static class InternalOnPickCallback implements Runnable {
|
||||
private final OnPickCallback mUserCallback;
|
||||
private final PickingQueryResult mPickingQueryResult = new PickingQueryResult();
|
||||
|
||||
@UsedByNative("View.cpp")
|
||||
@Entity
|
||||
int mRenderable;
|
||||
|
||||
@UsedByNative("View.cpp")
|
||||
float mDepth;
|
||||
|
||||
@UsedByNative("View.cpp")
|
||||
float mFragCoordsX;
|
||||
@UsedByNative("View.cpp")
|
||||
float mFragCoordsY;
|
||||
@UsedByNative("View.cpp")
|
||||
float mFragCoordsZ;
|
||||
|
||||
public InternalOnPickCallback(OnPickCallback mUserCallback) {
|
||||
this.mUserCallback = mUserCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
mPickingQueryResult.renderable = mRenderable;
|
||||
@@ -1107,13 +1130,51 @@ public class View {
|
||||
mPickingQueryResult.fragCoords[2] = mFragCoordsZ;
|
||||
mUserCallback.onPick(mPickingQueryResult);
|
||||
}
|
||||
private final OnPickCallback mUserCallback;
|
||||
private final PickingQueryResult mPickingQueryResult = new PickingQueryResult();
|
||||
@Entity int mRenderable;
|
||||
float mDepth;
|
||||
float mFragCoordsX;
|
||||
float mFragCoordsY;
|
||||
float mFragCoordsZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the value of material global variables. There are up-to four such variable each of
|
||||
* type float4. These variables can be read in a user Material with
|
||||
* `getMaterialGlobal{0|1|2|3}()`. All variable start with a default value of { 0, 0, 0, 1 }
|
||||
*
|
||||
* @param index index of the variable to set between 0 and 3.
|
||||
* @param value new value for the variable.
|
||||
* @see #getMaterialGlobal
|
||||
*/
|
||||
public void setMaterialGlobal(int index, @NonNull @Size(min = 4) float[] value) {
|
||||
Asserts.assertFloat4In(value);
|
||||
nSetMaterialGlobal(getNativeObject(), index, value[0], value[1], value[2], value[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the value of the material global variables.
|
||||
* All variable start with a default value of { 0, 0, 0, 1 }
|
||||
*
|
||||
* @param index index of the variable to set between 0 and 3.
|
||||
* @param out A 4-float array where the value will be stored, or null in which case the array is
|
||||
* allocated.
|
||||
* @return A 4-float array containing the current value of the variable.
|
||||
* @see #setMaterialGlobal
|
||||
*/
|
||||
@NonNull @Size(min = 4)
|
||||
public float[] getMaterialGlobal(int index, @Nullable @Size(min = 4) float[] out) {
|
||||
out = Asserts.assertFloat4(out);
|
||||
nGetMaterialGlobal(getNativeObject(), index, out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an Entity representing the large scale fog object.
|
||||
* This entity is always inherited by the View's Scene.
|
||||
*
|
||||
* It is for example possible to create a TransformManager component with this
|
||||
* Entity and apply a transformation globally on the fog.
|
||||
*
|
||||
* @return an Entity representing the large scale fog object.
|
||||
*/
|
||||
@Entity
|
||||
public int getFogEntity() {
|
||||
return nGetFogEntity(getNativeObject());
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
@@ -1157,7 +1218,7 @@ public class View {
|
||||
private static native void nSetSSCTOptions(long nativeView, float ssctLightConeRad, float ssctStartTraceDistance, float ssctContactDistanceMax, float ssctIntensity, float v, float v1, float v2, float ssctDepthBias, float ssctDepthSlopeBias, int ssctSampleCount, int ssctRayCount, boolean ssctEnabled);
|
||||
private static native void nSetBloomOptions(long nativeView, long dirtNativeObject, float dirtStrength, float strength, int resolution, float anamorphism, int levels, int blendMode, boolean threshold, boolean enabled, float highlight,
|
||||
boolean lensFlare, boolean starburst, float chromaticAberration, int ghostCount, float ghostSpacing, float ghostThreshold, float haloThickness, float haloRadius, float haloThreshold);
|
||||
private static native void nSetFogOptions(long nativeView, float distance, float maximumOpacity, float height, float heightFalloff, float v, float v1, float v2, float density, float inScatteringStart, float inScatteringSize, boolean fogColorFromIbl, boolean enabled);
|
||||
private static native void nSetFogOptions(long nativeView, float distance, float maximumOpacity, float height, float heightFalloff, float cutOffDistance, float v, float v1, float v2, float density, float inScatteringStart, float inScatteringSize, boolean fogColorFromIbl, long skyColorNativeObject, boolean enabled);
|
||||
private static native void nSetBlendMode(long nativeView, int blendMode);
|
||||
private static native void nSetDepthOfFieldOptions(long nativeView, float cocScale, float maxApertureDiameter, boolean enabled, int filter,
|
||||
boolean nativeResolution, int foregroundRingCount, int backgroundRingCount, int fastGatherRingCount, int maxForegroundCOC, int maxBackgroundCOC);
|
||||
@@ -1172,6 +1233,10 @@ public class View {
|
||||
private static native void nPick(long nativeView, int x, int y, Object handler, InternalOnPickCallback internalCallback);
|
||||
private static native void nSetStencilBufferEnabled(long nativeView, boolean enabled);
|
||||
private static native boolean nIsStencilBufferEnabled(long nativeView);
|
||||
private static native void nSetMaterialGlobal(long nativeView, int index, float x, float y, float z, float w);
|
||||
private static native void nGetMaterialGlobal(long nativeView, int index, float[] out);
|
||||
private static native int nGetFogEntity(long nativeView);
|
||||
|
||||
|
||||
/**
|
||||
* List of available ambient occlusion techniques.
|
||||
@@ -1327,13 +1392,13 @@ public class View {
|
||||
/**
|
||||
* resolution of vertical axis (2^levels to 2048)
|
||||
*/
|
||||
public int resolution = 360;
|
||||
public int resolution = 384;
|
||||
/**
|
||||
* bloom x/y aspect-ratio (1/32 to 32)
|
||||
*/
|
||||
public float anamorphism = 1.0f;
|
||||
/**
|
||||
* number of blur levels (3 to 11)
|
||||
* number of blur levels (1 to 11)
|
||||
*/
|
||||
public int levels = 6;
|
||||
/**
|
||||
@@ -1392,48 +1457,109 @@ public class View {
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to control fog in the scene
|
||||
* Options to control large-scale fog in the scene
|
||||
*/
|
||||
public static class FogOptions {
|
||||
/**
|
||||
* distance in world units from the camera where the fog starts ( >= 0.0 )
|
||||
* Distance in world units [m] from the camera to where the fog starts ( >= 0.0 )
|
||||
*/
|
||||
public float distance = 0.0f;
|
||||
/**
|
||||
* Distance in world units [m] after which the fog calculation is disabled.
|
||||
* This can be used to exclude the skybox, which is desirable if it already contains clouds or
|
||||
* fog. The default value is +infinity which applies the fog to everything.
|
||||
*
|
||||
* Note: The SkyBox is typically at a distance of 1e19 in world space (depending on the near
|
||||
* plane distance and projection used though).
|
||||
*/
|
||||
public float cutOffDistance = Float.POSITIVE_INFINITY;
|
||||
/**
|
||||
* fog's maximum opacity between 0 and 1
|
||||
*/
|
||||
public float maximumOpacity = 1.0f;
|
||||
/**
|
||||
* fog's floor in world units
|
||||
* Fog's floor in world units [m]. This sets the "sea level".
|
||||
*/
|
||||
public float height = 0.0f;
|
||||
/**
|
||||
* how fast fog dissipates with altitude
|
||||
* How fast the fog dissipates with altitude. heightFalloff has a unit of [1/m].
|
||||
* It can be expressed as 1/H, where H is the altitude change in world units [m] that causes a
|
||||
* factor 2.78 (e) change in fog density.
|
||||
*
|
||||
* A falloff of 0 means the fog density is constant everywhere and may result is slightly
|
||||
* faster computations.
|
||||
*/
|
||||
public float heightFalloff = 1.0f;
|
||||
/**
|
||||
* fog's color (linear), see fogColorFromIbl
|
||||
* Fog's color is used for ambient light in-scattering, a good value is
|
||||
* to use the average of the ambient light, possibly tinted towards blue
|
||||
* for outdoors environments. Color component's values should be between 0 and 1, values
|
||||
* above one are allowed but could create a non energy-conservative fog (this is dependant
|
||||
* on the IBL's intensity as well).
|
||||
*
|
||||
* We assume that our fog has no absorption and therefore all the light it scatters out
|
||||
* becomes ambient light in-scattering and has lost all directionality, i.e.: scattering is
|
||||
* isotropic. This somewhat simulates Rayleigh scattering.
|
||||
*
|
||||
* This value is used as a tint instead, when fogColorFromIbl is enabled.
|
||||
*
|
||||
* @see fogColorFromIbl
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] color = {0.5f, 0.5f, 0.5f};
|
||||
public float[] color = {1.0f, 1.0f, 1.0f};
|
||||
/**
|
||||
* fog's density at altitude given by 'height'
|
||||
* Extinction factor in [1/m] at altitude 'height'. The extinction factor controls how much
|
||||
* light is absorbed and out-scattered per unit of distance. Each unit of extinction reduces
|
||||
* the incoming light to 37% of its original value.
|
||||
*
|
||||
* Note: The extinction factor is related to the fog density, it's usually some constant K times
|
||||
* the density at sea level (more specifically at fog height). The constant K depends on
|
||||
* the composition of the fog/atmosphere.
|
||||
*
|
||||
* For historical reason this parameter is called `density`.
|
||||
*/
|
||||
public float density = 0.1f;
|
||||
/**
|
||||
* distance in world units from the camera where in-scattering starts
|
||||
* Distance in world units [m] from the camera where the Sun in-scattering starts.
|
||||
*/
|
||||
public float inScatteringStart = 0.0f;
|
||||
/**
|
||||
* size of in-scattering (>0 to activate). Good values are >> 1 (e.g. ~10 - 100).
|
||||
* Very inaccurately simulates the Sun's in-scattering. That is, the light from the sun that
|
||||
* is scattered (by the fog) towards the camera.
|
||||
* Size of the Sun in-scattering (>0 to activate). Good values are >> 1 (e.g. ~10 - 100).
|
||||
* Smaller values result is a larger scattering size.
|
||||
*/
|
||||
public float inScatteringSize = -1.0f;
|
||||
/**
|
||||
* Fog color will be modulated by the IBL color in the view direction.
|
||||
* The fog color will be sampled from the IBL in the view direction and tinted by `color`.
|
||||
* Depending on the scene this can produce very convincing results.
|
||||
*
|
||||
* This simulates a more anisotropic phase-function.
|
||||
*
|
||||
* `fogColorFromIbl` is ignored when skyTexture is specified.
|
||||
*
|
||||
* @see skyColor
|
||||
*/
|
||||
public boolean fogColorFromIbl = false;
|
||||
/**
|
||||
* enable or disable fog
|
||||
* skyTexture must be a mipmapped cubemap. When provided, the fog color will be sampled from
|
||||
* this texture, higher resolution mip levels will be used for objects at the far clip plane,
|
||||
* and lower resolution mip levels for objects closer to the camera. The skyTexture should
|
||||
* typically be heavily blurred; a typical way to produce this texture is to blur the base
|
||||
* level with a strong gaussian filter or even an irradiance filter and then generate mip
|
||||
* levels as usual. How blurred the base level is somewhat of an artistic decision.
|
||||
*
|
||||
* This simulates a more anisotropic phase-function.
|
||||
*
|
||||
* `fogColorFromIbl` is ignored when skyTexture is specified.
|
||||
*
|
||||
* @see Texture
|
||||
* @see fogColorFromIbl
|
||||
*/
|
||||
@Nullable
|
||||
public Texture skyColor = null;
|
||||
/**
|
||||
* Enable or disable large-scale fog
|
||||
*/
|
||||
public boolean enabled = false;
|
||||
}
|
||||
@@ -1860,4 +1986,11 @@ public class View {
|
||||
*/
|
||||
public float penumbraRatioScale = 1.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for stereoscopic (multi-eye) rendering.
|
||||
*/
|
||||
public static class StereoscopicOptions {
|
||||
public boolean enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2023 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.android;
|
||||
|
||||
import com.google.android.filament.Engine;
|
||||
import com.google.android.filament.Fence;
|
||||
|
||||
public class FilamentHelper {
|
||||
|
||||
/**
|
||||
* Wait for all pending frames to be processed before returning. This is to avoid a race
|
||||
* between the surface being resized before pending frames are rendered into it.
|
||||
* <p>
|
||||
* For {@link android.view.TextureView} this must be called before the texture's size is
|
||||
* reconfigured, which unfortunately is done by the Android framework before
|
||||
* {@link UiHelper} listeners are invoked. Therefore <code>synchronizePendingFrames</code>
|
||||
* cannot be called from
|
||||
* {@link android.view.TextureView.SurfaceTextureListener#onSurfaceTextureSizeChanged}; instead
|
||||
* a subclass of {@link android.view.TextureView} must be used in order to call it from
|
||||
* {@link android.view.TextureView#onSizeChanged}:
|
||||
* </p>
|
||||
* <pre>
|
||||
* public class MyTextureView extends TextureView {
|
||||
* private Engine engine;
|
||||
* protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
* FilamentHelper.synchronizePendingFrames(engine);
|
||||
* super.onSizeChanged(w, h, oldw, oldh);
|
||||
* }
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* Otherwise, this is typically called from {@link UiHelper.RendererCallback#onResized},
|
||||
* {@link android.view.SurfaceHolder.Callback#surfaceChanged}.
|
||||
*
|
||||
* @param engine Filament engine to synchronize
|
||||
*
|
||||
* @see UiHelper.RendererCallback#onResized
|
||||
* @see android.view.SurfaceHolder.Callback#surfaceChanged
|
||||
* @see android.view.TextureView#onSizeChanged
|
||||
*/
|
||||
static public void synchronizePendingFrames(Engine engine) {
|
||||
Fence fence = engine.createFence();
|
||||
fence.wait(Fence.Mode.FLUSH, Fence.WAIT_FOR_EVER);
|
||||
engine.destroyFence(fence);
|
||||
}
|
||||
}
|
||||
@@ -84,6 +84,14 @@ import com.google.android.filament.SwapChain;
|
||||
* // The native surface has changed size. This is always called at least once
|
||||
* // after the surface is created (after onNativeWindowChanged() is invoked).
|
||||
* public void onResized(int width, int height) {
|
||||
*
|
||||
* // Wait for all pending frames to be processed before returning. This is to
|
||||
* // avoid a race between the surface being resized before pending frames are
|
||||
* // rendered into it.
|
||||
* Fence fence = mEngine.createFence();
|
||||
* fence.wait(Fence.Mode.FLUSH, Fence.WAIT_FOR_EVER);
|
||||
* mEngine.destroyFence(fence);
|
||||
*
|
||||
* // Compute camera projection and set the viewport on the view
|
||||
* }
|
||||
* });
|
||||
@@ -175,7 +183,7 @@ public class UiHelper {
|
||||
}
|
||||
|
||||
private static class SurfaceViewHandler implements RenderSurface {
|
||||
private SurfaceView mSurfaceView;
|
||||
private final SurfaceView mSurfaceView;
|
||||
|
||||
SurfaceViewHandler(SurfaceView surface) {
|
||||
mSurfaceView = surface;
|
||||
@@ -192,7 +200,7 @@ public class UiHelper {
|
||||
}
|
||||
|
||||
private static class SurfaceHolderHandler implements RenderSurface {
|
||||
private SurfaceHolder mSurfaceHolder;
|
||||
private final SurfaceHolder mSurfaceHolder;
|
||||
|
||||
SurfaceHolderHandler(SurfaceHolder surface) {
|
||||
mSurfaceHolder = surface;
|
||||
@@ -209,7 +217,7 @@ public class UiHelper {
|
||||
}
|
||||
|
||||
private class TextureViewHandler implements RenderSurface {
|
||||
private TextureView mTextureView;
|
||||
private final TextureView mTextureView;
|
||||
private Surface mSurface;
|
||||
|
||||
TextureViewHandler(TextureView surface) { mTextureView = surface; }
|
||||
@@ -236,6 +244,10 @@ public class UiHelper {
|
||||
}
|
||||
mSurface = surface;
|
||||
}
|
||||
|
||||
public Surface getSurface() {
|
||||
return mSurface;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -481,6 +493,14 @@ public class UiHelper {
|
||||
} else {
|
||||
mRenderCallback.onResized(width, height);
|
||||
}
|
||||
// We must recreate the SwapChain to guarantee that it sees the new size.
|
||||
// More precisely, for an EGL client, the EGLSurface must be recreated. For
|
||||
// a Vulkan client, the SwapChain must be recreated. Calling
|
||||
// onNativeWindowChanged() will accomplish that.
|
||||
// This requirement comes from SurfaceTexture.setDefaultBufferSize()
|
||||
// documentation.
|
||||
TextureViewHandler textureViewHandler = (TextureViewHandler) mRenderSurface;
|
||||
mRenderCallback.onNativeWindowChanged(textureViewHandler.getSurface());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
apply plugin: 'kotlin-android'
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.utils'
|
||||
@@ -21,16 +24,11 @@ android {
|
||||
excludes += ['lib/*/libfilament-jni.so', 'lib/*/libgltfio-jni.so']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all { config ->
|
||||
// Hack to preserve the version of the dependencies
|
||||
if (!config.name.endsWith('Publication')) {
|
||||
resolutionStrategy {
|
||||
dependencySubstitution {
|
||||
substitute(module("com.google.android.filament:gltfio-android:${VERSION_NAME}")).with(project(":gltfio-android"))
|
||||
substitute(module("com.google.android.filament:gltfio-android-lite:${VERSION_NAME}")).with(project(":gltfio-android"))
|
||||
}
|
||||
publishing {
|
||||
singleVariant("release") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +41,7 @@ dependencies {
|
||||
implementation deps.coroutines.android
|
||||
|
||||
api project(':filament-android')
|
||||
api module("com.google.android.filament:gltfio-android:${VERSION_NAME}")
|
||||
api project(':gltfio-android')
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
|
||||
|
||||
@@ -166,6 +166,8 @@ Java_com_google_android_filament_utils_AutomationEngine_nGetViewerOptions(JNIEnv
|
||||
const jfieldID cameraAperture = env->GetFieldID(klass, "cameraAperture", "F");
|
||||
const jfieldID cameraSpeed = env->GetFieldID(klass, "cameraSpeed", "F");
|
||||
const jfieldID cameraISO = env->GetFieldID(klass, "cameraISO", "F");
|
||||
const jfieldID cameraNear = env->GetFieldID(klass, "cameraNear", "F");
|
||||
const jfieldID cameraFar = env->GetFieldID(klass, "cameraFar", "F");
|
||||
const jfieldID groundShadowStrength = env->GetFieldID(klass, "groundShadowStrength", "F");
|
||||
const jfieldID groundPlaneEnabled = env->GetFieldID(klass, "groundPlaneEnabled", "Z");
|
||||
const jfieldID skyboxEnabled = env->GetFieldID(klass, "skyboxEnabled", "Z");
|
||||
@@ -177,6 +179,8 @@ Java_com_google_android_filament_utils_AutomationEngine_nGetViewerOptions(JNIEnv
|
||||
env->SetFloatField(result, cameraAperture, options.cameraAperture);
|
||||
env->SetFloatField(result, cameraSpeed, options.cameraSpeed);
|
||||
env->SetFloatField(result, cameraISO, options.cameraISO);
|
||||
env->SetFloatField(result, cameraNear, options.cameraNear);
|
||||
env->SetFloatField(result, cameraFar, options.cameraFar);
|
||||
env->SetFloatField(result, groundShadowStrength, options.groundShadowStrength);
|
||||
env->SetBooleanField(result, groundPlaneEnabled, options.groundPlaneEnabled);
|
||||
env->SetBooleanField(result, skyboxEnabled, options.skyboxEnabled);
|
||||
|
||||
@@ -97,6 +97,8 @@ public class AutomationEngine {
|
||||
public float cameraAperture = 16.0f;
|
||||
public float cameraSpeed = 125.0f;
|
||||
public float cameraISO = 100.0f;
|
||||
public float cameraNear = 0.1f;
|
||||
public float cameraFar = 100.0f;
|
||||
public float groundShadowStrength = 0.75f;
|
||||
public boolean groundPlaneEnabled = false;
|
||||
public boolean skyboxEnabled = true;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("unused")
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
|
||||
package com.google.android.filament.utils
|
||||
|
||||
@@ -24,8 +24,16 @@ enum class MatrixColumn {
|
||||
X, Y, Z, W
|
||||
}
|
||||
|
||||
enum class RotationsOrder {
|
||||
XYZ, XZY, YXZ, YZX, ZXY, ZYX
|
||||
enum class RotationsOrder(
|
||||
val yaw: VectorComponent,
|
||||
val pitch: VectorComponent,
|
||||
val roll: VectorComponent) {
|
||||
XYZ(VectorComponent.X, VectorComponent.Y, VectorComponent.Z),
|
||||
XZY(VectorComponent.X, VectorComponent.Z, VectorComponent.Y),
|
||||
YXZ(VectorComponent.Y, VectorComponent.X, VectorComponent.Z),
|
||||
YZX(VectorComponent.Y, VectorComponent.Z, VectorComponent.X),
|
||||
ZXY(VectorComponent.Z, VectorComponent.X, VectorComponent.Y),
|
||||
ZYX(VectorComponent.Z, VectorComponent.Y, VectorComponent.X);
|
||||
}
|
||||
|
||||
data class Mat2(
|
||||
@@ -77,6 +85,12 @@ data class Mat2(
|
||||
operator fun minus(v: Float) = Mat2(x - v, y - v)
|
||||
operator fun times(v: Float) = Mat2(x * v, y * v)
|
||||
operator fun div(v: Float) = Mat2(x / v, y / v)
|
||||
inline fun compareTo(v: Float, delta: Float = 0.0f) = Mat2(
|
||||
x.compareTo(v, delta),
|
||||
y.compareTo(v, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float, delta: Float = 0.0f) = x.equals(v, delta) && y.equals(v, delta)
|
||||
|
||||
operator fun times(m: Mat2) = Mat2(
|
||||
Float2(
|
||||
@@ -89,12 +103,18 @@ data class Mat2(
|
||||
)
|
||||
)
|
||||
|
||||
inline fun compareTo(m: Mat2, delta: Float = 0.0f) = Mat2(
|
||||
x.compareTo(m.x, delta),
|
||||
y.compareTo(m.y, delta)
|
||||
)
|
||||
|
||||
inline fun equals(m: Mat2, delta: Float = 0.0f) = x.equals(m.x, delta) && y.equals(m.y, delta)
|
||||
|
||||
operator fun times(v: Float2) = Float2(
|
||||
x.x * v.x + y.x * v.y,
|
||||
x.y * v.x + y.y * v.y,
|
||||
)
|
||||
|
||||
|
||||
fun toFloatArray() = floatArrayOf(
|
||||
x.x, y.x,
|
||||
x.y, y.y
|
||||
@@ -106,7 +126,6 @@ data class Mat2(
|
||||
|${x.y} ${y.y}|
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class Mat3(
|
||||
@@ -162,6 +181,14 @@ data class Mat3(
|
||||
operator fun minus(v: Float) = Mat3(x - v, y - v, z - v)
|
||||
operator fun times(v: Float) = Mat3(x * v, y * v, z * v)
|
||||
operator fun div(v: Float) = Mat3(x / v, y / v, z / v)
|
||||
inline fun compareTo(v: Float, delta: Float = 0.0f) = Mat3(
|
||||
x.compareTo(v, delta),
|
||||
y.compareTo(v, delta),
|
||||
z.compareTo(v, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float, delta: Float = 0.0f) =
|
||||
x.equals(v, delta) && y.equals(v, delta) && z.equals(v, delta)
|
||||
|
||||
operator fun times(m: Mat3) = Mat3(
|
||||
Float3(
|
||||
@@ -181,6 +208,15 @@ data class Mat3(
|
||||
)
|
||||
)
|
||||
|
||||
inline fun compareTo(m: Mat3, delta: Float = 0.0f) = Mat3(
|
||||
x.compareTo(m.x, delta),
|
||||
y.compareTo(m.y, delta),
|
||||
z.compareTo(m.z, delta)
|
||||
)
|
||||
|
||||
inline fun equals(m: Mat3, delta: Float = 0.0f) =
|
||||
x.equals(m.x, delta) && y.equals(m.y, delta) && z.equals(m.z, delta)
|
||||
|
||||
operator fun times(v: Float3) = Float3(
|
||||
x.x * v.x + y.x * v.y + z.x * v.z,
|
||||
x.y * v.x + y.y * v.y + z.y * v.z,
|
||||
@@ -212,6 +248,7 @@ data class Mat4(
|
||||
constructor(m: Mat4) : this(m.x.copy(), m.y.copy(), m.z.copy(), m.w.copy())
|
||||
|
||||
companion object {
|
||||
|
||||
fun of(vararg a: Float): Mat4 {
|
||||
require(a.size >= 16)
|
||||
return Mat4(
|
||||
@@ -302,6 +339,15 @@ data class Mat4(
|
||||
operator fun minus(v: Float) = Mat4(x - v, y - v, z - v, w - v)
|
||||
operator fun times(v: Float) = Mat4(x * v, y * v, z * v, w * v)
|
||||
operator fun div(v: Float) = Mat4(x / v, y / v, z / v, w / v)
|
||||
inline fun compareTo(v: Float, delta: Float = 0.0f) = Mat4(
|
||||
x.compareTo(v, delta),
|
||||
y.compareTo(v, delta),
|
||||
z.compareTo(v, delta),
|
||||
w.compareTo(v, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float, delta: Float = 0.0f) =
|
||||
x.equals(v, delta) && y.equals(v, delta) && z.equals(v, delta) && w.equals(v, delta)
|
||||
|
||||
operator fun times(m: Mat4) = Mat4(
|
||||
Float4(
|
||||
@@ -330,6 +376,16 @@ data class Mat4(
|
||||
)
|
||||
)
|
||||
|
||||
inline fun compareTo(m: Mat4, delta: Float = 0.0f) = Mat4(
|
||||
x.compareTo(m.x, delta),
|
||||
y.compareTo(m.y, delta),
|
||||
z.compareTo(m.z, delta),
|
||||
w.compareTo(m.w, delta)
|
||||
)
|
||||
|
||||
inline fun equals(m: Mat4, delta: Float = 0.0f) =
|
||||
x.equals(m.x, delta) && y.equals(m.y, delta) && z.equals(m.z, delta) && w.equals(m.w, delta)
|
||||
|
||||
operator fun times(v: Float4) = Float4(
|
||||
x.x * v.x + y.x * v.y + z.x * v.z+ w.x * v.w,
|
||||
x.y * v.x + y.y * v.y + z.y * v.z+ w.y * v.w,
|
||||
@@ -337,6 +393,26 @@ data class Mat4(
|
||||
x.w * v.x + y.w * v.y + z.w * v.z+ w.w * v.w
|
||||
)
|
||||
|
||||
/**
|
||||
* Get the Euler angles in degrees from this rotation Matrix
|
||||
*
|
||||
* Don't forget to extract the rotation with [rotation] if this is a transposed matrix
|
||||
*
|
||||
* @param order The order in which to apply rotations.
|
||||
* Default is [RotationsOrder.ZYX] which means that the object will first be rotated around its Z
|
||||
* axis, then its Y axis and finally its X axis.
|
||||
*
|
||||
* @see eulerAngles
|
||||
*/
|
||||
fun toEulerAngles(order: RotationsOrder = RotationsOrder.ZYX) = eulerAngles(this, order)
|
||||
|
||||
/**
|
||||
* Get the [Quaternion] from this rotation Matrix
|
||||
*
|
||||
* Don't forget to extract the rotation with [rotation] if this is a transposed matrix
|
||||
*
|
||||
* @see quaternion
|
||||
*/
|
||||
fun toQuaternion() = quaternion(this)
|
||||
|
||||
fun toFloatArray() = floatArrayOf(
|
||||
@@ -356,6 +432,78 @@ data class Mat4(
|
||||
}
|
||||
}
|
||||
|
||||
inline fun equal(a: Mat2, b: Float, delta: Float = 0.0f) = Bool2(
|
||||
a.x.equals(b, delta),
|
||||
a.y.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Mat2, b: Mat2, delta: Float = 0.0f) = Bool2(
|
||||
a.x.equals(b.x, delta),
|
||||
a.y.equals(b.y, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Mat2, b: Float, delta: Float = 0.0f) = Bool2(
|
||||
!a.x.equals(b, delta),
|
||||
!a.y.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Mat2, b: Mat2, delta: Float = 0.0f) = Bool2(
|
||||
!a.x.equals(b.x, delta),
|
||||
!a.y.equals(b.y, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Mat3, b: Float, delta: Float = 0.0f) = Bool3(
|
||||
a.x.equals(b, delta),
|
||||
a.y.equals(b, delta),
|
||||
a.z.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Mat3, b: Mat3, delta: Float = 0.0f) = Bool3(
|
||||
a.x.equals(b.x, delta),
|
||||
a.y.equals(b.y, delta),
|
||||
a.z.equals(b.z, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Mat3, b: Float, delta: Float = 0.0f) = Bool3(
|
||||
!a.x.equals(b, delta),
|
||||
!a.y.equals(b, delta),
|
||||
!a.z.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Mat3, b: Mat3, delta: Float = 0.0f) = Bool3(
|
||||
!a.x.equals(b.x, delta),
|
||||
!a.y.equals(b.y, delta),
|
||||
!a.z.equals(b.z, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Mat4, b: Float, delta: Float = 0.0f) = Bool4(
|
||||
a.x.equals(b, delta),
|
||||
a.y.equals(b, delta),
|
||||
a.z.equals(b, delta),
|
||||
a.w.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Mat4, b: Mat4, delta: Float = 0.0f) = Bool4(
|
||||
a.x.equals(b.x, delta),
|
||||
a.y.equals(b.y, delta),
|
||||
a.z.equals(b.z, delta),
|
||||
a.w.equals(b.w, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Mat4, b: Float, delta: Float = 0.0f) = Bool4(
|
||||
!a.x.equals(b, delta),
|
||||
!a.y.equals(b, delta),
|
||||
!a.z.equals(b, delta),
|
||||
!a.w.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Mat4, b: Mat4, delta: Float = 0.0f) = Bool4(
|
||||
!a.x.equals(b.x, delta),
|
||||
!a.y.equals(b.y, delta),
|
||||
!a.z.equals(b.z, delta),
|
||||
!a.w.equals(b.w, delta)
|
||||
)
|
||||
|
||||
fun transpose(m: Mat2) = Mat2(
|
||||
Float2(m.x.x, m.y.x),
|
||||
Float2(m.x.y, m.y.y)
|
||||
@@ -494,14 +642,7 @@ fun rotation(m: Mat4) = Mat4(normalize(m.right), normalize(m.up), normalize(m.fo
|
||||
*/
|
||||
fun rotation(d: Float3, order: RotationsOrder = RotationsOrder.ZYX): Mat4 {
|
||||
val r = transform(d, ::radians)
|
||||
return when(order) {
|
||||
RotationsOrder.XZY -> rotation(r.x, r.z, r.y)
|
||||
RotationsOrder.XYZ -> rotation(r.x, r.y, r.z)
|
||||
RotationsOrder.YXZ -> rotation(r.y, r.x, r.z)
|
||||
RotationsOrder.YZX -> rotation(r.y, r.z, r.x)
|
||||
RotationsOrder.ZYX -> rotation(r.z, r.y, r.x)
|
||||
RotationsOrder.ZXY -> rotation(r.z, r.x, r.y)
|
||||
}
|
||||
return rotation(r[order.yaw], r[order.pitch], r[order.roll], order)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -599,13 +740,93 @@ fun rotation(quaternion: Quaternion): Mat4 {
|
||||
Float4(
|
||||
2.0f * (n.x * n.z + n.y * n.w),
|
||||
2.0f * (n.y * n.z - n.x * n.w),
|
||||
1.0f - 2.0f * (n.x * n.x + n.y * n.y),
|
||||
1.0f - 2.0f * (n.x * n.x + n.y * n.y)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract Quaternion rotation from a Matrix
|
||||
* Get the Euler angles in degrees from a rotation Matrix
|
||||
*
|
||||
* @param m The rotation matrix.
|
||||
* Don't forget to extract the rotation with [rotation] if it's transposed
|
||||
* @param order The order in which to apply rotations.
|
||||
* Default is [RotationsOrder.ZYX] which means that the object will first be rotated around its Z
|
||||
* axis, then its Y axis and finally its X axis.
|
||||
*/
|
||||
fun eulerAngles(m: Mat4, order: RotationsOrder = RotationsOrder.ZYX): Float3 {
|
||||
// We need to more simplify this with RotationsOrder VectorComponents mapped to MatrixColumn
|
||||
return transform(Float3().apply {
|
||||
when (order) {
|
||||
RotationsOrder.XYZ -> {
|
||||
this[order.pitch] = asin(clamp(m.z.x, -1.0f, 1.0f))
|
||||
if (abs(m.z.x) < 0.9999999f) {
|
||||
this[order.yaw] = atan2(-m.z.y, m.z.z)
|
||||
this[order.roll] = atan2(-m.y.x, m.x.x)
|
||||
} else {
|
||||
this[order.yaw] = atan2(m.y.z, m.y.y)
|
||||
this[order.roll] = 0.0f
|
||||
}
|
||||
}
|
||||
RotationsOrder.XZY -> {
|
||||
this[order.pitch] = asin(-clamp(m.y.x, -1.0f, 1.0f))
|
||||
if (abs(m.y.x) < 0.9999999f) {
|
||||
this[order.yaw] = atan2(m.y.z, m.y.y)
|
||||
this[order.roll] = atan2(m.z.x, m.x.x)
|
||||
} else {
|
||||
this[order.yaw] = atan2(-m.z.y, m.z.z)
|
||||
this[order.roll] = 0.0f
|
||||
}
|
||||
}
|
||||
RotationsOrder.YXZ -> {
|
||||
this[order.pitch] = asin(-clamp(m.z.y, -1.0f, 1.0f))
|
||||
if (abs(m.z.y) < 0.9999999f) {
|
||||
this[order.yaw] = atan2(m.z.x, m.z.z)
|
||||
this[order.roll] = atan2(m.x.y, m.y.y)
|
||||
} else {
|
||||
this[order.yaw] = atan2(-m.x.z, m.x.x)
|
||||
this[order.roll] = 0.0f
|
||||
}
|
||||
}
|
||||
RotationsOrder.YZX -> {
|
||||
this[order.pitch] = asin(clamp(m.x.y, -1.0f, 1.0f))
|
||||
if (abs(m.x.y) < 0.9999999f) {
|
||||
this[order.roll] = atan2(-m.z.y, m.y.y)
|
||||
this[order.yaw] = atan2(-m.x.z, m.x.x)
|
||||
} else {
|
||||
this[order.roll] = 0.0f
|
||||
this[order.yaw] = atan2(m.z.x, m.z.z)
|
||||
}
|
||||
}
|
||||
RotationsOrder.ZXY -> {
|
||||
this[order.pitch] = asin(clamp(m.y.z, -1.0f, 1.0f))
|
||||
if (abs(m.y.z) < 0.9999999f) {
|
||||
this[order.roll] = atan2(-m.x.z, m.z.z)
|
||||
this[order.yaw] = atan2(-m.y.x, m.y.y)
|
||||
} else {
|
||||
this[order.roll] = 0.0f
|
||||
this[order.yaw] = atan2(m.x.y, m.x.x)
|
||||
}
|
||||
}
|
||||
RotationsOrder.ZYX -> {
|
||||
this[order.pitch] = asin(-clamp(m.x.z, -1.0f, 1.0f))
|
||||
if (abs(m.x.z) < 0.9999999f) {
|
||||
this[order.roll] = atan2(m.y.z, m.z.z)
|
||||
this[order.yaw] = atan2(m.x.y, m.x.x)
|
||||
} else {
|
||||
this[order.roll] = 0.0f
|
||||
this[order.yaw] = atan2(-m.y.x, m.y.y)
|
||||
}
|
||||
}
|
||||
}
|
||||
}, ::degrees)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the [Quaternion] from a rotation Matrix
|
||||
*
|
||||
* @param m The rotation matrix.
|
||||
* Don't forget to extract the rotation with [rotation] if it's transposed
|
||||
*/
|
||||
fun quaternion(m: Mat4): Quaternion {
|
||||
val trace = m.x.x + m.y.y + m.z.z
|
||||
@@ -673,9 +894,14 @@ fun perspective(fov: Float, ratio: Float, near: Float, far: Float): Mat4 {
|
||||
}
|
||||
|
||||
fun ortho(l: Float, r: Float, b: Float, t: Float, n: Float, f: Float) = Mat4(
|
||||
Float4(x = 2.0f / (r - 1.0f)),
|
||||
Float4(y = 2.0f / (t - b)),
|
||||
Float4(z = -2.0f / (f - n)),
|
||||
Float4(-(r + l) / (r - l), -(t + b) / (t - b), -(f + n) / (f - n), 1.0f)
|
||||
Float4(x = 2.0f / (r - l)),
|
||||
Float4(y = 2.0f / (t - b)),
|
||||
Float4(z = -2.0f / (f - n)),
|
||||
Float4(
|
||||
-(r + l) / (r - l),
|
||||
-(t + b) / (t - b),
|
||||
-(f + n) / (f - n),
|
||||
1.0f
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import com.google.android.filament.gltfio.*
|
||||
import kotlinx.coroutines.*
|
||||
import java.nio.Buffer
|
||||
|
||||
private const val kNearPlane = 0.05 // 5 cm
|
||||
private const val kFarPlane = 1000.0 // 1 km
|
||||
private const val kNearPlane = 0.05f // 5 cm
|
||||
private const val kFarPlane = 1000.0f // 1 km
|
||||
private const val kAperture = 16f
|
||||
private const val kShutterSpeed = 1f / 125f
|
||||
private const val kSensitivity = 100f
|
||||
@@ -80,6 +80,18 @@ class ModelViewer(
|
||||
updateCameraProjection()
|
||||
}
|
||||
|
||||
var cameraNear = kNearPlane
|
||||
set(value) {
|
||||
field = value
|
||||
updateCameraProjection()
|
||||
}
|
||||
|
||||
var cameraFar = kFarPlane
|
||||
set(value) {
|
||||
field = value
|
||||
updateCameraProjection()
|
||||
}
|
||||
|
||||
val scene: Scene
|
||||
val view: View
|
||||
val camera: Camera
|
||||
@@ -179,7 +191,7 @@ class ModelViewer(
|
||||
asset = assetLoader.createAsset(buffer)
|
||||
asset?.let { asset ->
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.getInstance().animator
|
||||
animator = asset.instance.animator
|
||||
asset.releaseSourceData()
|
||||
}
|
||||
}
|
||||
@@ -202,7 +214,7 @@ class ModelViewer(
|
||||
resourceLoader.addResourceData(uri, resourceBuffer)
|
||||
}
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.getInstance().animator
|
||||
animator = asset.instance.animator
|
||||
asset.releaseSourceData()
|
||||
}
|
||||
}
|
||||
@@ -299,7 +311,7 @@ class ModelViewer(
|
||||
var count = 0
|
||||
val popRenderables = { count = asset.popRenderables(readyRenderables); count != 0 }
|
||||
while (popRenderables()) {
|
||||
for (i in 0..count - 1) {
|
||||
for (i in 0 until count) {
|
||||
val ri = rcm.getInstance(readyRenderables[i])
|
||||
rcm.setScreenSpaceContactShadows(ri, true)
|
||||
}
|
||||
@@ -359,7 +371,7 @@ class ModelViewer(
|
||||
resourceLoader.addResourceData(uri, buffer)
|
||||
}
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.getInstance().animator
|
||||
animator = asset.instance.animator
|
||||
asset.releaseSourceData()
|
||||
}
|
||||
}
|
||||
@@ -368,7 +380,8 @@ class ModelViewer(
|
||||
val width = view.viewport.width
|
||||
val height = view.viewport.height
|
||||
val aspect = width.toDouble() / height.toDouble()
|
||||
camera.setLensProjection(cameraFocalLength.toDouble(), aspect, kNearPlane, kFarPlane)
|
||||
camera.setLensProjection(cameraFocalLength.toDouble(), aspect,
|
||||
cameraNear.toDouble(), cameraFar.toDouble())
|
||||
}
|
||||
|
||||
inner class SurfaceCallback : UiHelper.RendererCallback {
|
||||
@@ -392,9 +405,19 @@ class ModelViewer(
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
cameraManipulator.setViewport(width, height)
|
||||
updateCameraProjection()
|
||||
synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
private fun synchronizePendingFrames(engine: Engine) {
|
||||
// Wait for all pending frames to be processed before returning. This is to
|
||||
// avoid a race between the surface being resized before pending frames are
|
||||
// rendered into it.
|
||||
val fence = engine.createFence()
|
||||
fence.wait(Fence.Mode.FLUSH, Fence.WAIT_FOR_EVER)
|
||||
engine.destroyFence(fence)
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val kDefaultObjectPosition = Float3(0.0f, 0.0f, -4.0f)
|
||||
}
|
||||
|
||||
@@ -33,9 +33,9 @@ data class Quaternion(
|
||||
var x: Float = 0.0f,
|
||||
var y: Float = 0.0f,
|
||||
var z: Float = 0.0f,
|
||||
var w: Float = 0.0f) {
|
||||
var w: Float = 1.0f) {
|
||||
|
||||
constructor(v: Float3, w: Float = 0.0f) : this(v.x, v.y, v.z, w)
|
||||
constructor(v: Float3, w: Float = 1.0f) : this(v.x, v.y, v.z, w)
|
||||
constructor(v: Float4) : this(v.x, v.y, v.z, v.w)
|
||||
constructor(q: Quaternion) : this(q.x, q.y, q.z, q.w)
|
||||
|
||||
@@ -52,42 +52,84 @@ data class Quaternion(
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Quaternion from Euler angles using YPR around ZYX respectively
|
||||
* Construct a Quaternion from Euler angles using YPR around a specified order
|
||||
*
|
||||
* The Euler angles are applied in ZYX order.
|
||||
* i.e: a vector is first rotated about X (roll) then Y (pitch) and then Z (yaw).
|
||||
* Uses intrinsic Tait-Bryan angles. This means that rotations are performed with respect to
|
||||
* the local coordinate system.
|
||||
* That is, for order 'XYZ', the rotation is first around the X axis (which is the same as
|
||||
* the world-X axis), then around local-Y (which may now be different from the world
|
||||
* Y-axis), then local-Z (which may be different from the world Z-axis)
|
||||
*
|
||||
* @param d Per axis Euler angles in degrees
|
||||
* Yaw, pitch, roll (YPR) are taken accordingly to the rotations order input.
|
||||
* @param order The order in which to apply rotations.
|
||||
* Default is [RotationsOrder.ZYX] which means that the object will first be rotated around
|
||||
* its Z axis, then its Y axis and finally its X axis.
|
||||
*/
|
||||
fun fromEuler(d: Float3): Quaternion {
|
||||
fun fromEuler(d: Float3, order: RotationsOrder = RotationsOrder.ZYX): Quaternion {
|
||||
val r = transform(d, ::radians)
|
||||
return fromEulerZYX(r.z, r.y, r.x)
|
||||
return fromEuler(r[order.yaw], r[order.pitch], r[order.roll], order)
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Quaternion from Euler angles using YPR around ZYX respectively
|
||||
* Construct a Quaternion from Euler yaw, pitch, roll around a specified order.
|
||||
*
|
||||
* The Euler angles are applied in ZYX order.
|
||||
* i.e: a vector is first rotated about X (roll) then Y (pitch) and then Z (yaw).
|
||||
*
|
||||
* @param roll about X axis in radians
|
||||
* @param pitch about Y axis in radians
|
||||
* @param yaw about Z axis in radians
|
||||
* @param roll about 1st rotation axis in radians. Z in case of ZYX order
|
||||
* @param pitch about 2nd rotation axis in radians. Y in case of ZYX order
|
||||
* @param yaw about 3rd rotation axis in radians. X in case of ZYX order
|
||||
* @param order The order in which to apply rotations.
|
||||
* Default is [RotationsOrder.ZYX] which means that the object will first be rotated around its Z
|
||||
* axis, then its Y axis and finally its X axis.
|
||||
*/
|
||||
fun fromEulerZYX(yaw: Float = 0.0f, pitch: Float = 0.0f, roll: Float = 0.0f): Quaternion {
|
||||
val cy = cos(yaw * 0.5f)
|
||||
val sy = sin(yaw * 0.5f)
|
||||
val cp = cos(pitch * 0.5f)
|
||||
val sp = sin(pitch * 0.5f)
|
||||
val cr = cos(roll * 0.5f)
|
||||
val sr = sin(roll * 0.5f)
|
||||
|
||||
return Quaternion(
|
||||
sr * cp * cy - cr * sp * sy,
|
||||
cr * sp * cy + sr * cp * sy,
|
||||
cr * cp * sy - sr * sp * cy,
|
||||
cr * cp * cy + sr * sp * sy
|
||||
)
|
||||
fun fromEuler(
|
||||
yaw: Float = 0.0f,
|
||||
pitch: Float = 0.0f,
|
||||
roll: Float = 0.0f,
|
||||
order: RotationsOrder = RotationsOrder.ZYX
|
||||
): Quaternion {
|
||||
val c1 = cos(yaw * 0.5f)
|
||||
val s1 = sin(yaw * 0.5f)
|
||||
val c2 = cos(pitch * 0.5f)
|
||||
val s2 = sin(pitch * 0.5f)
|
||||
val c3 = cos(roll * 0.5f)
|
||||
val s3 = sin(roll * 0.5f)
|
||||
return when (order) {
|
||||
RotationsOrder.XZY -> Quaternion(
|
||||
s1 * c2 * c3 - c1 * s2 * s3,
|
||||
c1 * c2 * s3 - s1 * s2 * c3,
|
||||
s1 * c2 * s3 + c1 * s2 * c3,
|
||||
s1 * s2 * s3 + c1 * c2 * c3)
|
||||
RotationsOrder.XYZ -> Quaternion(
|
||||
s1 * c2 * c3 + s2 * s3 * c1,
|
||||
s2 * c1 * c3 - s1 * s3 * c2,
|
||||
s1 * s2 * c3 + s3 * c1 * c2,
|
||||
c1 * c2 * c3 - s1 * s2 * s3
|
||||
)
|
||||
RotationsOrder.YXZ -> Quaternion(
|
||||
s1 * c2 * s3 + c1 * s2 * c3,
|
||||
s1 * c2 * c3 - c1 * s2 * s3,
|
||||
c1 * c2 * s3 - s1 * s2 * c3,
|
||||
s1 * s2 * s3 + c1 * c2 * c3
|
||||
)
|
||||
RotationsOrder.YZX -> Quaternion(
|
||||
s1 * s2 * c3 + c1 * c2 * s3,
|
||||
s1 * c2 * c3 + c1 * s2 * s3,
|
||||
c1 * s2 * c3 - s1 * c2 * s3,
|
||||
c1 * c2 * c3 - s1 * s2 * s3
|
||||
)
|
||||
RotationsOrder.ZYX -> Quaternion(
|
||||
c1 * c2 * s3 - s1 * s2 * c3,
|
||||
s1 * c2 * s3 + c1 * s2 * c3,
|
||||
s1 * c2 * c3 - c1 * s2 * s3,
|
||||
s1 * s2 * s3 + c1 * c2 * c3
|
||||
)
|
||||
RotationsOrder.ZXY -> Quaternion(
|
||||
c1 * s2 * c3 - s1 * c2 * s3,
|
||||
s1 * s2 * c3 + c1 * c2 * s3,
|
||||
s1 * c2 * c3 + c1 * s2 * s3,
|
||||
c1 * c2 * c3 - s1 * s2 * s3
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -222,16 +264,44 @@ data class Quaternion(
|
||||
inline operator fun minus(v: Float) = Quaternion(x - v, y - v, z - v, w - v)
|
||||
inline operator fun times(v: Float) = Quaternion(x * v, y * v, z * v, w * v)
|
||||
inline operator fun div(v: Float) = Quaternion(x / v, y / v, z / v, w / v)
|
||||
inline fun compareTo(v: Float, delta: Float = 0.0f) = Float4(
|
||||
x.compareTo(v, delta),
|
||||
y.compareTo(v, delta),
|
||||
z.compareTo(v, delta),
|
||||
w.compareTo(v, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float, delta: Float = 0.0f) = Bool4(
|
||||
x.equals(v, delta),
|
||||
y.equals(v, delta),
|
||||
z.equals(v, delta),
|
||||
w.equals(v, delta)
|
||||
)
|
||||
|
||||
inline operator fun times(v: Float3) = (this * Quaternion(v, 0.0f) * inverse(this)).xyz
|
||||
|
||||
inline operator fun plus(q: Quaternion) = Quaternion(x + q.x, y + q.y, z + q.z, w + q.w)
|
||||
inline operator fun minus(q: Quaternion) = Quaternion(x - q.x, y - q.y, z - q.z, w - q.w)
|
||||
inline operator fun times(q: Quaternion) = Quaternion(
|
||||
w * q.x + x * q.w + y * q.z - z * q.y,
|
||||
w * q.y - x * q.z + y * q.w + z * q.x,
|
||||
w * q.z + x * q.y - y * q.x + z * q.w,
|
||||
w * q.w - x * q.x - y * q.y - z * q.z)
|
||||
w * q.x + x * q.w + y * q.z - z * q.y,
|
||||
w * q.y - x * q.z + y * q.w + z * q.x,
|
||||
w * q.z + x * q.y - y * q.x + z * q.w,
|
||||
w * q.w - x * q.x - y * q.y - z * q.z
|
||||
)
|
||||
|
||||
inline fun compareTo(v: Float4, delta: Float = 0.0f) = Float4(
|
||||
x.compareTo(v.x, delta),
|
||||
y.compareTo(v.y, delta),
|
||||
z.compareTo(v.z, delta),
|
||||
w.compareTo(v.w, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float4, delta: Float = 0.0f) = Bool4(
|
||||
x.equals(v.x, delta),
|
||||
y.equals(v.y, delta),
|
||||
z.equals(v.z, delta),
|
||||
w.equals(v.w, delta)
|
||||
)
|
||||
|
||||
inline fun transform(block: (Float) -> Float): Quaternion {
|
||||
x = block(x)
|
||||
@@ -253,6 +323,103 @@ inline operator fun Float.minus(q: Quaternion) = Quaternion(this - q.x, this - q
|
||||
inline operator fun Float.times(q: Quaternion) = Quaternion(this * q.x, this * q.y, this * q.z, this * q.w)
|
||||
inline operator fun Float.div(q: Quaternion) = Quaternion(this / q.x, this / q.y, this / q.z, this / q.w)
|
||||
|
||||
inline fun lessThan(a: Quaternion, b: Float) = Bool4(
|
||||
a.x < b,
|
||||
a.y < b,
|
||||
a.z < b,
|
||||
a.w < b
|
||||
)
|
||||
|
||||
inline fun lessThan(a: Quaternion, b: Quaternion) = Bool4(
|
||||
a.x < b.x,
|
||||
a.y < b.y,
|
||||
a.z < b.z,
|
||||
a.w < b.w
|
||||
)
|
||||
|
||||
inline fun lessThanEqual(a: Quaternion, b: Float) = Bool4(
|
||||
a.x <= b,
|
||||
a.y <= b,
|
||||
a.z <= b,
|
||||
a.w <= b
|
||||
)
|
||||
|
||||
inline fun lessThanEqual(a: Quaternion, b: Quaternion) = Bool4(
|
||||
a.x <= b.x,
|
||||
a.y <= b.y,
|
||||
a.z <= b.z,
|
||||
a.w <= b.w
|
||||
)
|
||||
|
||||
inline fun greaterThan(a: Quaternion, b: Float) = Bool4(
|
||||
a.x > b,
|
||||
a.y > b,
|
||||
a.z > b,
|
||||
a.w > b
|
||||
)
|
||||
|
||||
inline fun greaterThan(a: Quaternion, b: Quaternion) = Bool4(
|
||||
a.x > b.y,
|
||||
a.y > b.y,
|
||||
a.z > b.z,
|
||||
a.w > b.w
|
||||
)
|
||||
|
||||
inline fun greaterThanEqual(a: Quaternion, b: Float) = Bool4(
|
||||
a.x >= b,
|
||||
a.y >= b,
|
||||
a.z >= b,
|
||||
a.w >= b
|
||||
)
|
||||
|
||||
inline fun greaterThanEqual(a: Quaternion, b: Quaternion) = Bool4(
|
||||
a.x >= b.x,
|
||||
a.y >= b.y,
|
||||
a.z >= b.z,
|
||||
a.w >= b.w
|
||||
)
|
||||
|
||||
inline fun equal(a: Quaternion, b: Float, delta: Float = 0.0f) = Bool4(
|
||||
a.x.equals(b, delta),
|
||||
a.y.equals(b, delta),
|
||||
a.z.equals(b, delta),
|
||||
a.w.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Quaternion, b: Quaternion, delta: Float = 0.0f) = Bool4(
|
||||
a.x.equals(b.x, delta),
|
||||
a.y.equals(b.y, delta),
|
||||
a.z.equals(b.z, delta),
|
||||
a.w.equals(b.w, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Quaternion, b: Float, delta: Float = 0.0f) = Bool4(
|
||||
!a.x.equals(b, delta),
|
||||
!a.y.equals(b, delta),
|
||||
!a.z.equals(b, delta),
|
||||
!a.w.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Quaternion, b: Quaternion, delta: Float = 0.0f) = Bool4(
|
||||
!a.x.equals(b.x, delta),
|
||||
!a.y.equals(b.y, delta),
|
||||
!a.z.equals(b.z, delta),
|
||||
!a.w.equals(b.w, delta)
|
||||
)
|
||||
|
||||
inline infix fun Quaternion.lt(b: Float) = Bool4(x < b, y < b, z < b, w < b)
|
||||
inline infix fun Quaternion.lt(b: Float4) = Bool4(x < b.x, y < b.y, z < b.z, w < b.w)
|
||||
inline infix fun Quaternion.lte(b: Float) = Bool4(x <= b, y <= b, z <= b, w <= b)
|
||||
inline infix fun Quaternion.lte(b: Float4) = Bool4(x <= b.x, y <= b.y, z <= b.z, w <= b.w)
|
||||
inline infix fun Quaternion.gt(b: Float) = Bool4(x > b, y > b, z > b, w > b)
|
||||
inline infix fun Quaternion.gt(b: Float4) = Bool4(x > b.x, y > b.y, z > b.z, w > b.w)
|
||||
inline infix fun Quaternion.gte(b: Float) = Bool4(x >= b, y >= b, z >= b, w >= b)
|
||||
inline infix fun Quaternion.gte(b: Float4) = Bool4(x >= b.x, y >= b.y, z >= b.z, w >= b.w)
|
||||
inline infix fun Quaternion.eq(b: Float) = Bool4(x == b, y == b, z == b, w == b)
|
||||
inline infix fun Quaternion.eq(b: Float4) = Bool4(x == b.x, y == b.y, z == b.z, w == b.w)
|
||||
inline infix fun Quaternion.neq(b: Float) = Bool4(x != b, y != b, z != b, w != b)
|
||||
inline infix fun Quaternion.neq(b: Float4) = Bool4(x != b.x, y != b.y, z != b.z, w != b.w)
|
||||
|
||||
inline fun abs(q: Quaternion) = Quaternion(abs(q.x), abs(q.y), abs(q.z), abs(q.w))
|
||||
inline fun length(q: Quaternion) = sqrt(q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w)
|
||||
inline fun length2(q: Quaternion) = q.x * q.x + q.y * q.y + q.z * q.z + q.w * q.w
|
||||
@@ -278,6 +445,10 @@ fun cross(a: Quaternion, b: Quaternion): Quaternion {
|
||||
return Quaternion(m.x, m.y, m.z, 0.0f)
|
||||
}
|
||||
|
||||
fun angle(a: Quaternion, b: Quaternion): Float {
|
||||
return 2.0f * acos(abs(clamp(dot(a, b), -1.0f, 1.0f)))
|
||||
}
|
||||
|
||||
/**
|
||||
* Spherical linear interpolation between two given orientations
|
||||
*
|
||||
@@ -287,36 +458,38 @@ fun cross(a: Quaternion, b: Quaternion): Quaternion {
|
||||
* @param a The beginning value
|
||||
* @param b The ending value
|
||||
* @param t The ratio between the two floats
|
||||
* @param valueEps Prevent blowing up when slerping between two quaternions that are very near each
|
||||
* other. Linear interpolation (lerp) is returned in this case.
|
||||
* @param dotThreshold If the quaternion dot product is greater than this value
|
||||
* (i.e. the quaternions are very close to each other), then the quaternions are
|
||||
* linearly interpolated instead of spherically interpolated.
|
||||
*
|
||||
* @return Interpolated value between the two floats
|
||||
*/
|
||||
fun slerp(a: Quaternion, b: Quaternion, t: Float, valueEps: Float = 0.0000000001f): Quaternion {
|
||||
fun slerp(a: Quaternion, b: Quaternion, t: Float, dotThreshold: Float = 0.9995f): Quaternion {
|
||||
// could also be computed as: pow(q * inverse(p), t) * p;
|
||||
val d = dot(a, b)
|
||||
val absd = abs(d)
|
||||
var dot = dot(a, b)
|
||||
var b1 = b
|
||||
|
||||
// If the dot product is negative, then the interpolation won't follow the shortest angular path
|
||||
// between the two quaterions. In this case, invert the end quaternion to produce an equivalent
|
||||
// rotation that will give us the path we want.
|
||||
if (dot < 0.0f) {
|
||||
dot = -dot
|
||||
b1 = -b
|
||||
}
|
||||
|
||||
// Prevent blowing up when slerping between two quaternions that are very near each other.
|
||||
if ((1.0f - absd) < valueEps) {
|
||||
return normalize(lerp(if (d < 0.0f) -a else a, b, t))
|
||||
return if (dot < dotThreshold) {
|
||||
val angle = acos(dot)
|
||||
val s = sin(angle)
|
||||
a * sin((1.0f - t) * angle) / s + b1 * sin(t * angle) / s
|
||||
} else {
|
||||
// If the angle is too small, use linear interpolation
|
||||
nlerp(a, b1, t)
|
||||
}
|
||||
val npq = sqrt(dot(a, a) * dot(b, b)) // ||p|| * ||q||
|
||||
val acos = acos(clamp(absd / npq, -1.0f, 1.0f))
|
||||
val acos0 = acos * (1.0f - t)
|
||||
val acos1 = acos * t
|
||||
val sina = sin(acos)
|
||||
if (sina < valueEps) {
|
||||
return normalize(lerp(a, b, t))
|
||||
}
|
||||
val isina = 1.0f / sina
|
||||
val s0 = sin(acos0) * isina
|
||||
val s1 = sin(acos1) * isina
|
||||
// ensure we're taking the "short" side
|
||||
return normalize(s0 * a + (if (d < 0.0f) -s1 else (s1)) * b)
|
||||
}
|
||||
|
||||
fun lerp(a: Quaternion, b: Quaternion, t: Float): Quaternion {
|
||||
return ((1 - t) * a) + (t * b)
|
||||
return ((1.0f - t) * a) + (t * b)
|
||||
}
|
||||
|
||||
fun nlerp(a: Quaternion, b: Quaternion, t: Float): Quaternion {
|
||||
@@ -324,19 +497,12 @@ fun nlerp(a: Quaternion, b: Quaternion, t: Float): Quaternion {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Quaternion to Euler angles using YPR around ZYX respectively
|
||||
* Convert a Quaternion to Euler angles
|
||||
*
|
||||
* The Euler angles are applied in ZYX order
|
||||
* @param order The order in which to apply rotations.
|
||||
* Default is [RotationsOrder.ZYX] which means that the object will first be rotated around its Z
|
||||
* axis, then its Y axis and finally its X axis.
|
||||
*/
|
||||
fun eulerAngles(q: Quaternion): Float3 {
|
||||
val nq = normalize(q)
|
||||
return Float3(
|
||||
// roll (x-axis rotation)
|
||||
degrees(atan2(2.0f * (nq.y * nq.z + nq.w * nq.x),
|
||||
nq.w * nq.w - nq.x * nq.x - nq.y * nq.y + nq.z * nq.z)),
|
||||
// pitch (y-axis rotation)
|
||||
degrees(asin(-2.0f * (nq.x * nq.z - nq.w * nq.y))),
|
||||
// yaw (z-axis rotation)
|
||||
degrees(atan2(2.0f * (nq.x * nq.y + nq.w * nq.z),
|
||||
nq.w * nq.w + nq.x * nq.x - nq.y * nq.y - nq.z * nq.z)))
|
||||
fun eulerAngles(q: Quaternion, order: RotationsOrder = RotationsOrder.ZYX): Float3 {
|
||||
return eulerAngles(rotation(q), order)
|
||||
}
|
||||
|
||||
@@ -28,12 +28,21 @@ const val INV_PI = 1.0f / FPI
|
||||
const val INV_TWO_PI = INV_PI * 0.5f
|
||||
const val INV_FOUR_PI = INV_PI * 0.25f
|
||||
|
||||
inline fun clamp(x: Float, min: Float, max: Float)= if (x < min) min else (if (x > max) max else x)
|
||||
val HALF_ONE = Half(0x3c00.toUShort())
|
||||
val HALF_TWO = Half(0x4000.toUShort())
|
||||
|
||||
inline fun clamp(x: Float, min: Float, max: Float) = if (x < min) min else (if (x > max) max else x)
|
||||
|
||||
inline fun clamp(x: Half, min: Half, max: Half) = if (x < min) min else (if (x > max) max else x)
|
||||
|
||||
inline fun saturate(x: Float) = clamp(x, 0.0f, 1.0f)
|
||||
|
||||
inline fun saturate(x: Half) = clamp(x, Half.POSITIVE_ZERO, HALF_ONE)
|
||||
|
||||
inline fun mix(a: Float, b: Float, x: Float) = a * (1.0f - x) + b * x
|
||||
|
||||
inline fun mix(a: Half, b: Half, x: Half) = a * (HALF_ONE - x) + b * x
|
||||
|
||||
inline fun degrees(v: Float) = v * (180.0f * INV_PI)
|
||||
|
||||
inline fun radians(v: Float) = v * (FPI / 180.0f)
|
||||
@@ -42,4 +51,6 @@ inline fun fract(v: Float) = v % 1
|
||||
|
||||
inline fun sqr(v: Float) = v * v
|
||||
|
||||
inline fun sqr(v: Half) = v * v
|
||||
|
||||
inline fun pow(x: Float, y: Float) = (x.toDouble().pow(y.toDouble())).toFloat()
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.textured
|
||||
package com.google.android.filament.utils
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Bitmap
|
||||
|
||||
@@ -22,6 +22,8 @@ import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
import kotlin.math.sqrt
|
||||
import kotlin.math.acos
|
||||
import kotlin.math.absoluteValue
|
||||
|
||||
enum class VectorComponent {
|
||||
X, Y, Z, W,
|
||||
@@ -124,11 +126,23 @@ data class Float2(var x: Float = 0.0f, var y: Float = 0.0f) {
|
||||
inline operator fun minus(v: Float) = Float2(x - v, y - v)
|
||||
inline operator fun times(v: Float) = Float2(x * v, y * v)
|
||||
inline operator fun div(v: Float) = Float2(x / v, y / v)
|
||||
inline fun compareTo(v: Float, delta: Float = 0.0f) = Float2(
|
||||
x.compareTo(v, delta),
|
||||
y.compareTo(v, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float, delta: Float = 0.0f) = x.equals(v, delta) && y.equals(v, delta)
|
||||
|
||||
inline operator fun plus(v: Float2) = Float2(x + v.x, y + v.y)
|
||||
inline operator fun minus(v: Float2) = Float2(x - v.x, y - v.y)
|
||||
inline operator fun times(v: Float2) = Float2(x * v.x, y * v.y)
|
||||
inline operator fun div(v: Float2) = Float2(x / v.x, y / v.y)
|
||||
inline fun compareTo(v: Float2, delta: Float = 0.0f) = Float2(
|
||||
x.compareTo(v.x, delta),
|
||||
y.compareTo(v.y, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float2, delta: Float = 0.0f) = x.equals(v.x, delta) && y.equals(v.y, delta)
|
||||
|
||||
inline fun transform(block: (Float) -> Float): Float2 {
|
||||
x = block(x)
|
||||
@@ -291,6 +305,14 @@ data class Float3(var x: Float = 0.0f, var y: Float = 0.0f, var z: Float = 0.0f)
|
||||
inline operator fun minus(v: Float) = Float3(x - v, y - v, z - v)
|
||||
inline operator fun times(v: Float) = Float3(x * v, y * v, z * v)
|
||||
inline operator fun div(v: Float) = Float3(x / v, y / v, z / v)
|
||||
inline fun compareTo(v: Float, delta: Float = 0.0f) = Float3(
|
||||
x.compareTo(v, delta),
|
||||
y.compareTo(v, delta),
|
||||
z.compareTo(v, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float, delta: Float = 0.0f) =
|
||||
x.equals(v, delta) && y.equals(v, delta) && z.equals(v, delta)
|
||||
|
||||
inline operator fun plus(v: Float2) = Float3(x + v.x, y + v.y, z)
|
||||
inline operator fun minus(v: Float2) = Float3(x - v.x, y - v.y, z)
|
||||
@@ -301,6 +323,14 @@ data class Float3(var x: Float = 0.0f, var y: Float = 0.0f, var z: Float = 0.0f)
|
||||
inline operator fun minus(v: Float3) = Float3(x - v.x, y - v.y, z - v.z)
|
||||
inline operator fun times(v: Float3) = Float3(x * v.x, y * v.y, z * v.z)
|
||||
inline operator fun div(v: Float3) = Float3(x / v.x, y / v.y, z / v.z)
|
||||
inline fun compareTo(v: Float3, delta: Float = 0.0f) = Float3(
|
||||
x.compareTo(v.x, delta),
|
||||
y.compareTo(v.y, delta),
|
||||
z.compareTo(v.z, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float3, delta: Float = 0.0f) =
|
||||
x.equals(v.x, delta) && y.equals(v.y, delta) && z.equals(v.z, delta)
|
||||
|
||||
inline fun transform(block: (Float) -> Float): Float3 {
|
||||
x = block(x)
|
||||
@@ -534,6 +564,15 @@ data class Float4(
|
||||
inline operator fun minus(v: Float) = Float4(x - v, y - v, z - v, w - v)
|
||||
inline operator fun times(v: Float) = Float4(x * v, y * v, z * v, w * v)
|
||||
inline operator fun div(v: Float) = Float4(x / v, y / v, z / v, w / v)
|
||||
inline fun compareTo(v: Float, delta: Float = 0.0f) = Float4(
|
||||
x.compareTo(v, delta),
|
||||
y.compareTo(v, delta),
|
||||
z.compareTo(v, delta),
|
||||
w.compareTo(v, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float, delta: Float = 0.0f) =
|
||||
x.equals(v, delta) && y.equals(v, delta) && z.equals(v, delta) && w.equals(v, delta)
|
||||
|
||||
inline operator fun plus(v: Float2) = Float4(x + v.x, y + v.y, z, w)
|
||||
inline operator fun minus(v: Float2) = Float4(x - v.x, y - v.y, z, w)
|
||||
@@ -549,6 +588,15 @@ data class Float4(
|
||||
inline operator fun minus(v: Float4) = Float4(x - v.x, y - v.y, z - v.z, w - v.w)
|
||||
inline operator fun times(v: Float4) = Float4(x * v.x, y * v.y, z * v.z, w * v.w)
|
||||
inline operator fun div(v: Float4) = Float4(x / v.x, y / v.y, z / v.z, w / v.w)
|
||||
inline fun compareTo(v: Float4, delta: Float = 0.0f) = Float4(
|
||||
x.compareTo(v.x, delta),
|
||||
y.compareTo(v.y, delta),
|
||||
z.compareTo(v.z, delta),
|
||||
w.compareTo(v.w, delta)
|
||||
)
|
||||
|
||||
inline fun equals(v: Float4, delta: Float = 0.0f) =
|
||||
x.equals(v.x, delta) && y.equals(v.y, delta) && z.equals(v.z, delta) && w.equals(v.w, delta)
|
||||
|
||||
inline fun transform(block: (Float) -> Float): Float4 {
|
||||
x = block(x)
|
||||
@@ -566,6 +614,12 @@ inline operator fun Float.minus(v: Float2) = Float2(this - v.x, this - v.y)
|
||||
inline operator fun Float.times(v: Float2) = Float2(this * v.x, this * v.y)
|
||||
inline operator fun Float.div(v: Float2) = Float2(this / v.x, this / v.y)
|
||||
|
||||
inline fun Float.compareTo(v: Float, delta: Float): Float = when {
|
||||
equals(v, delta) -> 0.0f
|
||||
else -> compareTo(v).toFloat()
|
||||
}
|
||||
|
||||
inline fun Float.equals(v: Float, delta: Float) = (this - v).absoluteValue < delta
|
||||
inline fun abs(v: Float2) = Float2(abs(v.x), abs(v.y))
|
||||
inline fun length(v: Float2) = sqrt(v.x * v.x + v.y * v.y)
|
||||
inline fun length2(v: Float2) = v.x * v.x + v.y * v.y
|
||||
@@ -583,6 +637,11 @@ fun refract(i: Float2, n: Float2, eta: Float): Float2 {
|
||||
return if (k < 0.0f) Float2(0.0f) else eta * i - (eta * d + sqrt(k)) * n
|
||||
}
|
||||
|
||||
inline fun angle(a: Float2, b: Float2): Float {
|
||||
val l = length(a) * length(b)
|
||||
return if (l == 0.0f) 0.0f else acos(clamp(dot(a, b) / l, -1.0f, 1.0f))
|
||||
}
|
||||
|
||||
inline fun clamp(v: Float2, min: Float, max: Float): Float2 {
|
||||
return Float2(
|
||||
clamp(v.x, min, max),
|
||||
@@ -626,10 +685,25 @@ inline fun greaterThan(a: Float2, b: Float) = Bool2(a.x > b, a.y > b)
|
||||
inline fun greaterThan(a: Float2, b: Float2) = Bool2(a.x > b.y, a.y > b.y)
|
||||
inline fun greaterThanEqual(a: Float2, b: Float) = Bool2(a.x >= b, a.y >= b)
|
||||
inline fun greaterThanEqual(a: Float2, b: Float2) = Bool2(a.x >= b.x, a.y >= b.y)
|
||||
inline fun equal(a: Float2, b: Float) = Bool2(a.x == b, a.y == b)
|
||||
inline fun equal(a: Float2, b: Float2) = Bool2(a.x == b.x, a.y == b.y)
|
||||
inline fun notEqual(a: Float2, b: Float) = Bool2(a.x != b, a.y != b)
|
||||
inline fun notEqual(a: Float2, b: Float2) = Bool2(a.x != b.x, a.y != b.y)
|
||||
inline fun equal(a: Float2, b: Float, delta: Float = 0.0f) = Bool2(
|
||||
a.x.equals(b, delta),
|
||||
a.y.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Float2, b: Float2, delta: Float = 0.0f) = Bool2(
|
||||
a.x.equals(b.x, delta),
|
||||
a.y.equals(b.y, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Float2, b: Float, delta: Float = 0.0f) = Bool2(
|
||||
!a.x.equals(b, delta),
|
||||
!a.y.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Float2, b: Float2, delta: Float = 0.0f) = Bool2(
|
||||
!a.x.equals(b.x, delta),
|
||||
!a.y.equals(b.y, delta)
|
||||
)
|
||||
|
||||
inline infix fun Float2.lt(b: Float) = Bool2(x < b, y < b)
|
||||
inline infix fun Float2.lt(b: Float2) = Bool2(x < b.x, y < b.y)
|
||||
@@ -675,6 +749,11 @@ fun refract(i: Float3, n: Float3, eta: Float): Float3 {
|
||||
return if (k < 0.0f) Float3(0.0f) else eta * i - (eta * d + sqrt(k)) * n
|
||||
}
|
||||
|
||||
inline fun angle(a: Float3, b: Float3): Float {
|
||||
val l = length(a) * length(b)
|
||||
return if (l == 0.0f) 0.0f else acos(clamp(dot(a, b) / l, -1.0f, 1.0f))
|
||||
}
|
||||
|
||||
inline fun clamp(v: Float3, min: Float, max: Float): Float3 {
|
||||
return Float3(
|
||||
clamp(v.x, min, max),
|
||||
@@ -722,10 +801,29 @@ inline fun greaterThan(a: Float3, b: Float) = Bool3(a.x > b, a.y > b, a.z > b)
|
||||
inline fun greaterThan(a: Float3, b: Float3) = Bool3(a.x > b.y, a.y > b.y, a.z > b.z)
|
||||
inline fun greaterThanEqual(a: Float3, b: Float) = Bool3(a.x >= b, a.y >= b, a.z >= b)
|
||||
inline fun greaterThanEqual(a: Float3, b: Float3) = Bool3(a.x >= b.x, a.y >= b.y, a.z >= b.z)
|
||||
inline fun equal(a: Float3, b: Float) = Bool3(a.x == b, a.y == b, a.z == b)
|
||||
inline fun equal(a: Float3, b: Float3) = Bool3(a.x == b.x, a.y == b.y, a.z == b.z)
|
||||
inline fun notEqual(a: Float3, b: Float) = Bool3(a.x != b, a.y != b, a.z != b)
|
||||
inline fun notEqual(a: Float3, b: Float3) = Bool3(a.x != b.x, a.y != b.y, a.z != b.z)
|
||||
inline fun equal(a: Float3, b: Float, delta: Float = 0.0f) = Bool3(
|
||||
a.x.equals(b, delta),
|
||||
a.y.equals(b, delta),
|
||||
a.z.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Float3, b: Float3, delta: Float = 0.0f) = Bool3(
|
||||
a.x.equals(b.x, delta),
|
||||
a.y.equals(b.y, delta),
|
||||
a.z.equals(b.z, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Float3, b: Float, delta: Float = 0.0f) = Bool3(
|
||||
!a.x.equals(b, delta),
|
||||
!a.y.equals(b, delta),
|
||||
!a.z.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Float3, b: Float3, delta: Float = 0.0f) = Bool3(
|
||||
!a.x.equals(b.x, delta),
|
||||
!a.y.equals(b.y, delta),
|
||||
!a.z.equals(b.z, delta)
|
||||
)
|
||||
|
||||
inline infix fun Float3.lt(b: Float) = Bool3(x < b, y < b, z < b)
|
||||
inline infix fun Float3.lt(b: Float3) = Bool3(x < b.x, y < b.y, z < b.z)
|
||||
@@ -807,17 +905,44 @@ inline fun transform(v: Float4, block: (Float) -> Float) = v.copy().transform(bl
|
||||
inline fun lessThan(a: Float4, b: Float) = Bool4(a.x < b, a.y < b, a.z < b, a.w < b)
|
||||
inline fun lessThan(a: Float4, b: Float4) = Bool4(a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w)
|
||||
inline fun lessThanEqual(a: Float4, b: Float) = Bool4(a.x <= b, a.y <= b, a.z <= b, a.w <= b)
|
||||
inline fun lessThanEqual(a: Float4, b: Float4) = Bool4(a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w)
|
||||
inline fun lessThanEqual(a: Float4, b: Float4) =
|
||||
Bool4(a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w)
|
||||
|
||||
inline fun greaterThan(a: Float4, b: Float) = Bool4(a.x > b, a.y > b, a.z > b, a.w > b)
|
||||
inline fun greaterThan(a: Float4, b: Float4) = Bool4(a.x > b.y, a.y > b.y, a.z > b.z, a.w > b.w)
|
||||
inline fun greaterThanEqual(a: Float4, b: Float) = Bool4(a.x >= b, a.y >= b, a.z >= b, a.w >= b)
|
||||
inline fun greaterThanEqual(a: Float4, b: Float4) = Bool4(a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w)
|
||||
inline fun equal(a: Float4, b: Float) = Bool4(a.x == b, a.y == b, a.z == b, a.w == b)
|
||||
inline fun equal(a: Float4, b: Float4) = Bool4(a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w)
|
||||
inline fun notEqual(a: Float4, b: Float) = Bool4(a.x != b, a.y != b, a.z != b, a.w != b)
|
||||
inline fun notEqual(a: Float4, b: Float4) = Bool4(a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w)
|
||||
inline fun greaterThanEqual(a: Float4, b: Float4) =
|
||||
Bool4(a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w)
|
||||
|
||||
inline infix fun Float4.lt(b: Float) = Bool4(x < b, y < b, z < b, a < b)
|
||||
inline fun equal(a: Float4, b: Float, delta: Float = 0.0f) = Bool4(
|
||||
a.x.equals(b, delta),
|
||||
a.y.equals(b, delta),
|
||||
a.z.equals(b, delta),
|
||||
a.w.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun equal(a: Float4, b: Float4, delta: Float = 0.0f) = Bool4(
|
||||
a.x.equals(b.x, delta),
|
||||
a.y.equals(b.y, delta),
|
||||
a.z.equals(b.z, delta),
|
||||
a.w.equals(b.w, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Float4, b: Float, delta: Float = 0.0f) = Bool4(
|
||||
!a.x.equals(b, delta),
|
||||
!a.y.equals(b, delta),
|
||||
!a.z.equals(b, delta),
|
||||
!a.w.equals(b, delta)
|
||||
)
|
||||
|
||||
inline fun notEqual(a: Float4, b: Float4, delta: Float = 0.0f) = Bool4(
|
||||
!a.x.equals(b.x, delta),
|
||||
!a.y.equals(b.y, delta),
|
||||
!a.z.equals(b.z, delta),
|
||||
!a.w.equals(b.w, delta)
|
||||
)
|
||||
|
||||
inline infix fun Float4.lt(b: Float) = Bool4(x < b, y < b, z < b, w < b)
|
||||
inline infix fun Float4.lt(b: Float4) = Bool4(x < b.x, y < b.y, z < b.z, w < b.w)
|
||||
inline infix fun Float4.lte(b: Float) = Bool4(x <= b, y <= b, z <= b, w <= b)
|
||||
inline infix fun Float4.lte(b: Float4) = Bool4(x <= b.x, y <= b.y, z <= b.z, w <= b.w)
|
||||
@@ -1277,3 +1402,753 @@ data class Bool4(
|
||||
set(index4, v)
|
||||
}
|
||||
}
|
||||
|
||||
data class Half2(var x: Half = Half.POSITIVE_ZERO, var y: Half = Half.POSITIVE_ZERO) {
|
||||
constructor(v: Half) : this(v, v)
|
||||
constructor(v: Half2) : this(v.x, v.y)
|
||||
|
||||
inline var r: Half
|
||||
get() = x
|
||||
set(value) {
|
||||
x = value
|
||||
}
|
||||
inline var g: Half
|
||||
get() = y
|
||||
set(value) {
|
||||
y = value
|
||||
}
|
||||
|
||||
inline var s: Half
|
||||
get() = x
|
||||
set(value) {
|
||||
x = value
|
||||
}
|
||||
inline var t: Half
|
||||
get() = y
|
||||
set(value) {
|
||||
y = value
|
||||
}
|
||||
|
||||
inline var xy: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
inline var rg: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
inline var st: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
|
||||
operator fun get(index: VectorComponent) = when (index) {
|
||||
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x
|
||||
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y
|
||||
else -> throw IllegalArgumentException("index must be X, Y, R, G, S or T")
|
||||
}
|
||||
|
||||
operator fun get(index1: VectorComponent, index2: VectorComponent): Half2 {
|
||||
return Half2(get(index1), get(index2))
|
||||
}
|
||||
|
||||
operator fun get(index: Int) = when (index) {
|
||||
0 -> x
|
||||
1 -> y
|
||||
else -> throw IllegalArgumentException("index must be in 0..1")
|
||||
}
|
||||
|
||||
operator fun get(index1: Int, index2: Int) = Half2(get(index1), get(index2))
|
||||
|
||||
inline operator fun invoke(index: Int) = get(index - 1)
|
||||
|
||||
operator fun set(index: Int, v: Half) = when (index) {
|
||||
0 -> x = v
|
||||
1 -> y = v
|
||||
else -> throw IllegalArgumentException("index must be in 0..1")
|
||||
}
|
||||
|
||||
operator fun set(index1: Int, index2: Int, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
}
|
||||
|
||||
operator fun set(index: VectorComponent, v: Half) = when (index) {
|
||||
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x = v
|
||||
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y = v
|
||||
else -> throw IllegalArgumentException("index must be X, Y, R, G, S or T")
|
||||
}
|
||||
|
||||
operator fun set(index1: VectorComponent, index2: VectorComponent, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
}
|
||||
|
||||
operator fun unaryMinus() = Half2(-x, -y)
|
||||
operator fun inc() = Half2(x++, y++)
|
||||
operator fun dec() = Half2(x--, y--)
|
||||
|
||||
inline operator fun plus(v: Half) = Half2(x + v, y + v)
|
||||
inline operator fun minus(v: Half) = Half2(x - v, y - v)
|
||||
inline operator fun times(v: Half) = Half2(x * v, y * v)
|
||||
inline operator fun div(v: Half) = Half2(x / v, y / v)
|
||||
|
||||
inline operator fun plus(v: Half2) = Half2(x + v.x, y + v.y)
|
||||
inline operator fun minus(v: Half2) = Half2(x - v.x, y - v.y)
|
||||
inline operator fun times(v: Half2) = Half2(x * v.x, y * v.y)
|
||||
inline operator fun div(v: Half2) = Half2(x / v.x, y / v.y)
|
||||
|
||||
inline fun transform(block: (Half) -> Half): Half2 {
|
||||
x = block(x)
|
||||
y = block(y)
|
||||
return this
|
||||
}
|
||||
|
||||
fun toFloatArray() = floatArrayOf(x.toFloat(), y.toFloat())
|
||||
}
|
||||
|
||||
data class Half3(
|
||||
var x: Half = Half.POSITIVE_ZERO,
|
||||
var y: Half = Half.POSITIVE_ZERO,
|
||||
var z: Half = Half.POSITIVE_ZERO
|
||||
) {
|
||||
constructor(v: Half) : this(v, v, v)
|
||||
constructor(v: Half2, z: Half = Half.POSITIVE_ZERO) : this(v.x, v.y, z)
|
||||
constructor(v: Half3) : this(v.x, v.y, v.z)
|
||||
|
||||
inline var r: Half
|
||||
get() = x
|
||||
set(value) {
|
||||
x = value
|
||||
}
|
||||
inline var g: Half
|
||||
get() = y
|
||||
set(value) {
|
||||
y = value
|
||||
}
|
||||
inline var b: Half
|
||||
get() = z
|
||||
set(value) {
|
||||
z = value
|
||||
}
|
||||
|
||||
inline var s: Half
|
||||
get() = x
|
||||
set(value) {
|
||||
x = value
|
||||
}
|
||||
inline var t: Half
|
||||
get() = y
|
||||
set(value) {
|
||||
y = value
|
||||
}
|
||||
inline var p: Half
|
||||
get() = z
|
||||
set(value) {
|
||||
z = value
|
||||
}
|
||||
|
||||
inline var xy: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
inline var rg: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
inline var st: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
|
||||
inline var rgb: Half3
|
||||
get() = Half3(x, y, z)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
}
|
||||
inline var xyz: Half3
|
||||
get() = Half3(x, y, z)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
}
|
||||
inline var stp: Half3
|
||||
get() = Half3(x, y, z)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
}
|
||||
|
||||
operator fun get(index: VectorComponent) = when (index) {
|
||||
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x
|
||||
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y
|
||||
VectorComponent.Z, VectorComponent.B, VectorComponent.P -> z
|
||||
else -> throw IllegalArgumentException("index must be X, Y, Z, R, G, B, S, T or P")
|
||||
}
|
||||
|
||||
operator fun get(index1: VectorComponent, index2: VectorComponent): Half2 {
|
||||
return Half2(get(index1), get(index2))
|
||||
}
|
||||
operator fun get(
|
||||
index1: VectorComponent, index2: VectorComponent, index3: VectorComponent): Half3 {
|
||||
return Half3(get(index1), get(index2), get(index3))
|
||||
}
|
||||
|
||||
operator fun get(index: Int) = when (index) {
|
||||
0 -> x
|
||||
1 -> y
|
||||
2 -> z
|
||||
else -> throw IllegalArgumentException("index must be in 0..2")
|
||||
}
|
||||
|
||||
operator fun get(index1: Int, index2: Int) = Half2(get(index1), get(index2))
|
||||
operator fun get(index1: Int, index2: Int, index3: Int): Half3 {
|
||||
return Half3(get(index1), get(index2), get(index3))
|
||||
}
|
||||
|
||||
inline operator fun invoke(index: Int) = get(index - 1)
|
||||
|
||||
operator fun set(index: Int, v: Half) = when (index) {
|
||||
0 -> x = v
|
||||
1 -> y = v
|
||||
2 -> z = v
|
||||
else -> throw IllegalArgumentException("index must be in 0..2")
|
||||
}
|
||||
|
||||
operator fun set(index1: Int, index2: Int, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
}
|
||||
|
||||
operator fun set(index1: Int, index2: Int, index3: Int, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
set(index3, v)
|
||||
}
|
||||
|
||||
operator fun set(index: VectorComponent, v: Half) = when (index) {
|
||||
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x = v
|
||||
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y = v
|
||||
VectorComponent.Z, VectorComponent.B, VectorComponent.P -> z = v
|
||||
else -> throw IllegalArgumentException("index must be X, Y, Z, R, G, B, S, T or P")
|
||||
}
|
||||
|
||||
operator fun set(index1: VectorComponent, index2: VectorComponent, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
}
|
||||
|
||||
operator fun set(
|
||||
index1: VectorComponent, index2: VectorComponent, index3: VectorComponent, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
set(index3, v)
|
||||
}
|
||||
|
||||
operator fun unaryMinus() = Half3(-x, -y, -z)
|
||||
operator fun inc() = Half3(x++, y++, z++)
|
||||
operator fun dec() = Half3(x--, y--, z--)
|
||||
|
||||
inline operator fun plus(v: Half) = Half3(x + v, y + v, z + v)
|
||||
inline operator fun minus(v: Half) = Half3(x - v, y - v, z - v)
|
||||
inline operator fun times(v: Half) = Half3(x * v, y * v, z * v)
|
||||
inline operator fun div(v: Half) = Half3(x / v, y / v, z / v)
|
||||
|
||||
inline operator fun plus(v: Half2) = Half3(x + v.x, y + v.y, z)
|
||||
inline operator fun minus(v: Half2) = Half3(x - v.x, y - v.y, z)
|
||||
inline operator fun times(v: Half2) = Half3(x * v.x, y * v.y, z)
|
||||
inline operator fun div(v: Half2) = Half3(x / v.x, y / v.y, z)
|
||||
|
||||
inline operator fun plus(v: Half3) = Half3(x + v.x, y + v.y, z + v.z)
|
||||
inline operator fun minus(v: Half3) = Half3(x - v.x, y - v.y, z - v.z)
|
||||
inline operator fun times(v: Half3) = Half3(x * v.x, y * v.y, z * v.z)
|
||||
inline operator fun div(v: Half3) = Half3(x / v.x, y / v.y, z / v.z)
|
||||
|
||||
inline fun transform(block: (Half) -> Half): Half3 {
|
||||
x = block(x)
|
||||
y = block(y)
|
||||
z = block(z)
|
||||
return this
|
||||
}
|
||||
|
||||
fun toFloatArray() = floatArrayOf(x.toFloat(), y.toFloat(), z.toFloat())
|
||||
}
|
||||
|
||||
data class Half4(
|
||||
var x: Half = Half.POSITIVE_ZERO,
|
||||
var y: Half = Half.POSITIVE_ZERO,
|
||||
var z: Half = Half.POSITIVE_ZERO,
|
||||
var w: Half = Half.POSITIVE_ZERO
|
||||
) {
|
||||
constructor(v: Half) : this(v, v, v, v)
|
||||
constructor(v: Half2, z: Half = Half.POSITIVE_ZERO, w: Half = Half.POSITIVE_ZERO) : this(v.x, v.y, z, w)
|
||||
constructor(v: Half3, w: Half = Half.POSITIVE_ZERO) : this(v.x, v.y, v.z, w)
|
||||
constructor(v: Half4) : this(v.x, v.y, v.z, v.w)
|
||||
|
||||
inline var r: Half
|
||||
get() = x
|
||||
set(value) {
|
||||
x = value
|
||||
}
|
||||
inline var g: Half
|
||||
get() = y
|
||||
set(value) {
|
||||
y = value
|
||||
}
|
||||
inline var b: Half
|
||||
get() = z
|
||||
set(value) {
|
||||
z = value
|
||||
}
|
||||
inline var a: Half
|
||||
get() = w
|
||||
set(value) {
|
||||
w = value
|
||||
}
|
||||
|
||||
inline var s: Half
|
||||
get() = x
|
||||
set(value) {
|
||||
x = value
|
||||
}
|
||||
inline var t: Half
|
||||
get() = y
|
||||
set(value) {
|
||||
y = value
|
||||
}
|
||||
inline var p: Half
|
||||
get() = z
|
||||
set(value) {
|
||||
z = value
|
||||
}
|
||||
inline var q: Half
|
||||
get() = w
|
||||
set(value) {
|
||||
w = value
|
||||
}
|
||||
|
||||
inline var xy: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
inline var rg: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
inline var st: Half2
|
||||
get() = Half2(x, y)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
}
|
||||
|
||||
inline var rgb: Half3
|
||||
get() = Half3(x, y, z)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
}
|
||||
inline var xyz: Half3
|
||||
get() = Half3(x, y, z)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
}
|
||||
inline var stp: Half3
|
||||
get() = Half3(x, y, z)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
}
|
||||
|
||||
inline var rgba: Half4
|
||||
get() = Half4(x, y, z, w)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
w = value.w
|
||||
}
|
||||
inline var xyzw: Half4
|
||||
get() = Half4(x, y, z, w)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
w = value.w
|
||||
}
|
||||
inline var stpq: Half4
|
||||
get() = Half4(x, y, z, w)
|
||||
set(value) {
|
||||
x = value.x
|
||||
y = value.y
|
||||
z = value.z
|
||||
w = value.w
|
||||
}
|
||||
|
||||
operator fun get(index: VectorComponent) = when (index) {
|
||||
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x
|
||||
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y
|
||||
VectorComponent.Z, VectorComponent.B, VectorComponent.P -> z
|
||||
VectorComponent.W, VectorComponent.A, VectorComponent.Q -> w
|
||||
}
|
||||
|
||||
operator fun get(index1: VectorComponent, index2: VectorComponent): Half2 {
|
||||
return Half2(get(index1), get(index2))
|
||||
}
|
||||
operator fun get(
|
||||
index1: VectorComponent,
|
||||
index2: VectorComponent,
|
||||
index3: VectorComponent): Half3 {
|
||||
return Half3(get(index1), get(index2), get(index3))
|
||||
}
|
||||
operator fun get(
|
||||
index1: VectorComponent,
|
||||
index2: VectorComponent,
|
||||
index3: VectorComponent,
|
||||
index4: VectorComponent): Half4 {
|
||||
return Half4(get(index1), get(index2), get(index3), get(index4))
|
||||
}
|
||||
|
||||
operator fun get(index: Int) = when (index) {
|
||||
0 -> x
|
||||
1 -> y
|
||||
2 -> z
|
||||
3 -> w
|
||||
else -> throw IllegalArgumentException("index must be in 0..3")
|
||||
}
|
||||
|
||||
operator fun get(index1: Int, index2: Int) = Half2(get(index1), get(index2))
|
||||
operator fun get(index1: Int, index2: Int, index3: Int): Half3 {
|
||||
return Half3(get(index1), get(index2), get(index3))
|
||||
}
|
||||
operator fun get(index1: Int, index2: Int, index3: Int, index4: Int): Half4 {
|
||||
return Half4(get(index1), get(index2), get(index3), get(index4))
|
||||
}
|
||||
|
||||
inline operator fun invoke(index: Int) = get(index - 1)
|
||||
|
||||
operator fun set(index: Int, v: Half) = when (index) {
|
||||
0 -> x = v
|
||||
1 -> y = v
|
||||
2 -> z = v
|
||||
3 -> w = v
|
||||
else -> throw IllegalArgumentException("index must be in 0..3")
|
||||
}
|
||||
|
||||
operator fun set(index1: Int, index2: Int, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
}
|
||||
|
||||
operator fun set(index1: Int, index2: Int, index3: Int, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
set(index3, v)
|
||||
}
|
||||
|
||||
operator fun set(index1: Int, index2: Int, index3: Int, index4: Int, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
set(index3, v)
|
||||
set(index4, v)
|
||||
}
|
||||
|
||||
operator fun set(index: VectorComponent, v: Half) = when (index) {
|
||||
VectorComponent.X, VectorComponent.R, VectorComponent.S -> x = v
|
||||
VectorComponent.Y, VectorComponent.G, VectorComponent.T -> y = v
|
||||
VectorComponent.Z, VectorComponent.B, VectorComponent.P -> z = v
|
||||
VectorComponent.W, VectorComponent.A, VectorComponent.Q -> w = v
|
||||
}
|
||||
|
||||
operator fun set(index1: VectorComponent, index2: VectorComponent, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
}
|
||||
|
||||
operator fun set(
|
||||
index1: VectorComponent, index2: VectorComponent, index3: VectorComponent, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
set(index3, v)
|
||||
}
|
||||
|
||||
operator fun set(
|
||||
index1: VectorComponent, index2: VectorComponent,
|
||||
index3: VectorComponent, index4: VectorComponent, v: Half) {
|
||||
set(index1, v)
|
||||
set(index2, v)
|
||||
set(index3, v)
|
||||
set(index4, v)
|
||||
}
|
||||
|
||||
operator fun unaryMinus() = Half4(-x, -y, -z, -w)
|
||||
operator fun inc() = Half4(x++, y++, z++, w++)
|
||||
operator fun dec() = Half4(x--, y--, z--, w--)
|
||||
|
||||
inline operator fun plus(v: Half) = Half4(x + v, y + v, z + v, w + v)
|
||||
inline operator fun minus(v: Half) = Half4(x - v, y - v, z - v, w - v)
|
||||
inline operator fun times(v: Half) = Half4(x * v, y * v, z * v, w * v)
|
||||
inline operator fun div(v: Half) = Half4(x / v, y / v, z / v, w / v)
|
||||
|
||||
inline operator fun plus(v: Half2) = Half4(x + v.x, y + v.y, z, w)
|
||||
inline operator fun minus(v: Half2) = Half4(x - v.x, y - v.y, z, w)
|
||||
inline operator fun times(v: Half2) = Half4(x * v.x, y * v.y, z, w)
|
||||
inline operator fun div(v: Half2) = Half4(x / v.x, y / v.y, z, w)
|
||||
|
||||
inline operator fun plus(v: Half3) = Half4(x + v.x, y + v.y, z + v.z, w)
|
||||
inline operator fun minus(v: Half3) = Half4(x - v.x, y - v.y, z - v.z, w)
|
||||
inline operator fun times(v: Half3) = Half4(x * v.x, y * v.y, z * v.z, w)
|
||||
inline operator fun div(v: Half3) = Half4(x / v.x, y / v.y, z / v.z, w)
|
||||
|
||||
inline operator fun plus(v: Half4) = Half4(x + v.x, y + v.y, z + v.z, w + v.w)
|
||||
inline operator fun minus(v: Half4) = Half4(x - v.x, y - v.y, z - v.z, w - v.w)
|
||||
inline operator fun times(v: Half4) = Half4(x * v.x, y * v.y, z * v.z, w * v.w)
|
||||
inline operator fun div(v: Half4) = Half4(x / v.x, y / v.y, z / v.z, w / v.w)
|
||||
|
||||
inline fun transform(block: (Half) -> Half): Half4 {
|
||||
x = block(x)
|
||||
y = block(y)
|
||||
z = block(z)
|
||||
w = block(w)
|
||||
return this
|
||||
}
|
||||
|
||||
fun toFloatArray() = floatArrayOf(x.toFloat(), y.toFloat(), z.toFloat(), w.toFloat())
|
||||
}
|
||||
|
||||
inline fun min(v: Half2) = min(v.x, v.y)
|
||||
inline fun min(a: Half2, b: Half2) = Half2(min(a.x, b.x), min(a.y, b.y))
|
||||
inline fun max(v: Half2) = max(v.x, v.y)
|
||||
inline fun max(a: Half2, b: Half2) = Half2(max(a.x, b.x), max(a.y, b.y))
|
||||
|
||||
inline fun transform(v: Half2, block: (Half) -> Half) = v.copy().transform(block)
|
||||
|
||||
inline fun lessThan(a: Half2, b: Half) = Bool2(a.x < b, a.y < b)
|
||||
inline fun lessThan(a: Half2, b: Half2) = Bool2(a.x < b.x, a.y < b.y)
|
||||
inline fun lessThanEqual(a: Half2, b: Half) = Bool2(a.x <= b, a.y <= b)
|
||||
inline fun lessThanEqual(a: Half2, b: Half2) = Bool2(a.x <= b.x, a.y <= b.y)
|
||||
inline fun greaterThan(a: Half2, b: Half) = Bool2(a.x > b, a.y > b)
|
||||
inline fun greaterThan(a: Half2, b: Half2) = Bool2(a.x > b.y, a.y > b.y)
|
||||
inline fun greaterThanEqual(a: Half2, b: Half) = Bool2(a.x >= b, a.y >= b)
|
||||
inline fun greaterThanEqual(a: Half2, b: Half2) = Bool2(a.x >= b.x, a.y >= b.y)
|
||||
inline fun equal(a: Half2, b: Half) = Bool2(a.x == b, a.y == b)
|
||||
inline fun equal(a: Half2, b: Half2) = Bool2(a.x == b.x, a.y == b.y)
|
||||
inline fun notEqual(a: Half2, b: Half) = Bool2(a.x != b, a.y != b)
|
||||
inline fun notEqual(a: Half2, b: Half2) = Bool2(a.x != b.x, a.y != b.y)
|
||||
|
||||
inline infix fun Half2.lt(b: Half) = Bool2(x < b, y < b)
|
||||
inline infix fun Half2.lt(b: Half2) = Bool2(x < b.x, y < b.y)
|
||||
inline infix fun Half2.lte(b: Half) = Bool2(x <= b, y <= b)
|
||||
inline infix fun Half2.lte(b: Half2) = Bool2(x <= b.x, y <= b.y)
|
||||
inline infix fun Half2.gt(b: Half) = Bool2(x > b, y > b)
|
||||
inline infix fun Half2.gt(b: Half2) = Bool2(x > b.x, y > b.y)
|
||||
inline infix fun Half2.gte(b: Half) = Bool2(x >= b, y >= b)
|
||||
inline infix fun Half2.gte(b: Half2) = Bool2(x >= b.x, y >= b.y)
|
||||
inline infix fun Half2.eq(b: Half) = Bool2(x == b, y == b)
|
||||
inline infix fun Half2.eq(b: Half2) = Bool2(x == b.x, y == b.y)
|
||||
inline infix fun Half2.neq(b: Half) = Bool2(x != b, y != b)
|
||||
inline infix fun Half2.neq(b: Half2) = Bool2(x != b.x, y != b.y)
|
||||
|
||||
inline operator fun Half.plus(v: Half3) = Half3(this + v.x, this + v.y, this + v.z)
|
||||
inline operator fun Half.minus(v: Half3) = Half3(this - v.x, this - v.y, this - v.z)
|
||||
inline operator fun Half.times(v: Half3) = Half3(this * v.x, this * v.y, this * v.z)
|
||||
inline operator fun Half.div(v: Half3) = Half3(this / v.x, this / v.y, this / v.z)
|
||||
|
||||
inline fun abs(v: Half3) = Half3(abs(v.x), abs(v.y), abs(v.z))
|
||||
inline fun length(v: Half3) = sqrt(v.x * v.x + v.y * v.y + v.z * v.z)
|
||||
inline fun length2(v: Half3) = v.x * v.x + v.y * v.y + v.z * v.z
|
||||
inline fun distance(a: Half3, b: Half3) = length(a - b)
|
||||
inline fun dot(a: Half3, b: Half3) = a.x * b.x + a.y * b.y + a.z * b.z
|
||||
inline fun cross(a: Half3, b: Half3): Half3 {
|
||||
return Half3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x)
|
||||
}
|
||||
inline infix fun Half3.x(v: Half3): Half3 {
|
||||
return Half3(y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x)
|
||||
}
|
||||
fun normalize(v: Half3): Half3 {
|
||||
val l = HALF_ONE / length(v)
|
||||
return Half3(v.x * l, v.y * l, v.z * l)
|
||||
}
|
||||
|
||||
inline fun reflect(i: Half3, n: Half3) = i - HALF_TWO * dot(n, i) * n
|
||||
fun refract(i: Half3, n: Half3, eta: Half): Half3 {
|
||||
val d = dot(n, i)
|
||||
val k = HALF_ONE - eta * eta * (HALF_ONE - sqr(d))
|
||||
return if (k < Half.POSITIVE_ZERO) Half3() else eta * i - (eta * d + sqrt(k)) * n
|
||||
}
|
||||
|
||||
inline fun clamp(v: Half3, min: Half, max: Half): Half3 {
|
||||
return Half3(
|
||||
clamp(v.x, min, max),
|
||||
clamp(v.y, min, max),
|
||||
clamp(v.z, min, max)
|
||||
)
|
||||
}
|
||||
|
||||
inline fun clamp(v: Half3, min: Half3, max: Half3): Half3 {
|
||||
return Half3(
|
||||
clamp(v.x, min.x, max.x),
|
||||
clamp(v.y, min.y, max.y),
|
||||
clamp(v.z, min.z, max.z)
|
||||
)
|
||||
}
|
||||
|
||||
inline fun mix(a: Half3, b: Half3, x: Half): Half3 {
|
||||
return Half3(
|
||||
mix(a.x, b.x, x),
|
||||
mix(a.y, b.y, x),
|
||||
mix(a.z, b.z, x)
|
||||
)
|
||||
}
|
||||
|
||||
inline fun mix(a: Half3, b: Half3, x: Half3): Half3 {
|
||||
return Half3(
|
||||
mix(a.x, b.x, x.x),
|
||||
mix(a.y, b.y, x.y),
|
||||
mix(a.z, b.z, x.z)
|
||||
)
|
||||
}
|
||||
|
||||
inline fun min(v: Half3) = min(v.x, min(v.y, v.z))
|
||||
inline fun min(a: Half3, b: Half3) = Half3(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z))
|
||||
inline fun max(v: Half3) = max(v.x, max(v.y, v.z))
|
||||
inline fun max(a: Half3, b: Half3) = Half3(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z))
|
||||
|
||||
inline fun transform(v: Half3, block: (Half) -> Half) = v.copy().transform(block)
|
||||
|
||||
inline fun lessThan(a: Half3, b: Half) = Bool3(a.x < b, a.y < b, a.z < b)
|
||||
inline fun lessThan(a: Half3, b: Half3) = Bool3(a.x < b.x, a.y < b.y, a.z < b.z)
|
||||
inline fun lessThanEqual(a: Half3, b: Half) = Bool3(a.x <= b, a.y <= b, a.z <= b)
|
||||
inline fun lessThanEqual(a: Half3, b: Half3) = Bool3(a.x <= b.x, a.y <= b.y, a.z <= b.z)
|
||||
inline fun greaterThan(a: Half3, b: Half) = Bool3(a.x > b, a.y > b, a.z > b)
|
||||
inline fun greaterThan(a: Half3, b: Half3) = Bool3(a.x > b.y, a.y > b.y, a.z > b.z)
|
||||
inline fun greaterThanEqual(a: Half3, b: Half) = Bool3(a.x >= b, a.y >= b, a.z >= b)
|
||||
inline fun greaterThanEqual(a: Half3, b: Half3) = Bool3(a.x >= b.x, a.y >= b.y, a.z >= b.z)
|
||||
inline fun equal(a: Half3, b: Half) = Bool3(a.x == b, a.y == b, a.z == b)
|
||||
inline fun equal(a: Half3, b: Half3) = Bool3(a.x == b.x, a.y == b.y, a.z == b.z)
|
||||
inline fun notEqual(a: Half3, b: Half) = Bool3(a.x != b, a.y != b, a.z != b)
|
||||
inline fun notEqual(a: Half3, b: Half3) = Bool3(a.x != b.x, a.y != b.y, a.z != b.z)
|
||||
|
||||
inline infix fun Half3.lt(b: Half) = Bool3(x < b, y < b, z < b)
|
||||
inline infix fun Half3.lt(b: Half3) = Bool3(x < b.x, y < b.y, z < b.z)
|
||||
inline infix fun Half3.lte(b: Half) = Bool3(x <= b, y <= b, z <= b)
|
||||
inline infix fun Half3.lte(b: Half3) = Bool3(x <= b.x, y <= b.y, z <= b.z)
|
||||
inline infix fun Half3.gt(b: Half) = Bool3(x > b, y > b, z > b)
|
||||
inline infix fun Half3.gt(b: Half3) = Bool3(x > b.x, y > b.y, z > b.z)
|
||||
inline infix fun Half3.gte(b: Half) = Bool3(x >= b, y >= b, z >= b)
|
||||
inline infix fun Half3.gte(b: Half3) = Bool3(x >= b.x, y >= b.y, z >= b.z)
|
||||
inline infix fun Half3.eq(b: Half) = Bool3(x == b, y == b, z == b)
|
||||
inline infix fun Half3.eq(b: Half3) = Bool3(x == b.x, y == b.y, z == b.z)
|
||||
inline infix fun Half3.neq(b: Half) = Bool3(x != b, y != b, z != b)
|
||||
inline infix fun Half3.neq(b: Half3) = Bool3(x != b.x, y != b.y, z != b.z)
|
||||
|
||||
inline operator fun Half.plus(v: Half4) = Half4(this + v.x, this + v.y, this + v.z, this + v.w)
|
||||
inline operator fun Half.minus(v: Half4) = Half4(this - v.x, this - v.y, this - v.z, this - v.w)
|
||||
inline operator fun Half.times(v: Half4) = Half4(this * v.x, this * v.y, this * v.z, this * v.w)
|
||||
inline operator fun Half.div(v: Half4) = Half4(this / v.x, this / v.y, this / v.z, this / v.w)
|
||||
|
||||
inline fun abs(v: Half4) = Half4(abs(v.x), abs(v.y), abs(v.z), abs(v.w))
|
||||
inline fun length(v: Half4) = sqrt(v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w)
|
||||
inline fun length2(v: Half4) = v.x * v.x + v.y * v.y + v.z * v.z + v.w * v.w
|
||||
inline fun distance(a: Half4, b: Half4) = length(a - b)
|
||||
inline fun dot(a: Half4, b: Half4) = a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w
|
||||
fun normalize(v: Half4): Half4 {
|
||||
val l = HALF_ONE / length(v)
|
||||
return Half4(v.x * l, v.y * l, v.z * l, v.w * l)
|
||||
}
|
||||
|
||||
inline fun clamp(v: Half4, min: Half, max: Half): Half4 {
|
||||
return Half4(
|
||||
clamp(v.x, min, max),
|
||||
clamp(v.y, min, max),
|
||||
clamp(v.z, min, max),
|
||||
clamp(v.w, min, max)
|
||||
)
|
||||
}
|
||||
|
||||
inline fun clamp(v: Half4, min: Half4, max: Half4): Half4 {
|
||||
return Half4(
|
||||
clamp(v.x, min.x, max.x),
|
||||
clamp(v.y, min.y, max.y),
|
||||
clamp(v.z, min.z, max.z),
|
||||
clamp(v.w, min.z, max.w)
|
||||
)
|
||||
}
|
||||
|
||||
inline fun mix(a: Half4, b: Half4, x: Half): Half4 {
|
||||
return Half4(
|
||||
mix(a.x, b.x, x),
|
||||
mix(a.y, b.y, x),
|
||||
mix(a.z, b.z, x),
|
||||
mix(a.w, b.w, x)
|
||||
)
|
||||
}
|
||||
|
||||
inline fun mix(a: Half4, b: Half4, x: Half4): Half4 {
|
||||
return Half4(
|
||||
mix(a.x, b.x, x.x),
|
||||
mix(a.y, b.y, x.y),
|
||||
mix(a.z, b.z, x.z),
|
||||
mix(a.w, b.w, x.w))
|
||||
}
|
||||
|
||||
inline fun min(v: Half4) = min(v.x, min(v.y, min(v.z, v.w)))
|
||||
inline fun min(a: Half4, b: Half4): Half4 {
|
||||
return Half4(min(a.x, b.x), min(a.y, b.y), min(a.z, b.z), min(a.w, b.w))
|
||||
}
|
||||
inline fun max(v: Half4) = max(v.x, max(v.y, max(v.z, v.w)))
|
||||
inline fun max(a: Half4, b: Half4): Half4 {
|
||||
return Half4(max(a.x, b.x), max(a.y, b.y), max(a.z, b.z), max(a.w, b.w))
|
||||
}
|
||||
|
||||
inline fun transform(v: Half4, block: (Half) -> Half) = v.copy().transform(block)
|
||||
|
||||
inline fun lessThan(a: Half4, b: Half) = Bool4(a.x < b, a.y < b, a.z < b, a.w < b)
|
||||
inline fun lessThan(a: Half4, b: Half4) = Bool4(a.x < b.x, a.y < b.y, a.z < b.z, a.w < b.w)
|
||||
inline fun lessThanEqual(a: Half4, b: Half) = Bool4(a.x <= b, a.y <= b, a.z <= b, a.w <= b)
|
||||
inline fun lessThanEqual(a: Half4, b: Half4) = Bool4(a.x <= b.x, a.y <= b.y, a.z <= b.z, a.w <= b.w)
|
||||
inline fun greaterThan(a: Half4, b: Half) = Bool4(a.x > b, a.y > b, a.z > b, a.w > b)
|
||||
inline fun greaterThan(a: Half4, b: Half4) = Bool4(a.x > b.y, a.y > b.y, a.z > b.z, a.w > b.w)
|
||||
inline fun greaterThanEqual(a: Half4, b: Half) = Bool4(a.x >= b, a.y >= b, a.z >= b, a.w >= b)
|
||||
inline fun greaterThanEqual(a: Half4, b: Half4) = Bool4(a.x >= b.x, a.y >= b.y, a.z >= b.z, a.w >= b.w)
|
||||
inline fun equal(a: Half4, b: Half) = Bool4(a.x == b, a.y == b, a.z == b, a.w == b)
|
||||
inline fun equal(a: Half4, b: Half4) = Bool4(a.x == b.x, a.y == b.y, a.z == b.z, a.w == b.w)
|
||||
inline fun notEqual(a: Half4, b: Half) = Bool4(a.x != b, a.y != b, a.z != b, a.w != b)
|
||||
inline fun notEqual(a: Half4, b: Half4) = Bool4(a.x != b.x, a.y != b.y, a.z != b.z, a.w != b.w)
|
||||
|
||||
inline infix fun Half4.lt(b: Half) = Bool4(x < b, y < b, z < b, a < b)
|
||||
inline infix fun Half4.lt(b: Half4) = Bool4(x < b.x, y < b.y, z < b.z, w < b.w)
|
||||
inline infix fun Half4.lte(b: Half) = Bool4(x <= b, y <= b, z <= b, w <= b)
|
||||
inline infix fun Half4.lte(b: Half4) = Bool4(x <= b.x, y <= b.y, z <= b.z, w <= b.w)
|
||||
inline infix fun Half4.gt(b: Half) = Bool4(x > b, y > b, z > b, w > b)
|
||||
inline infix fun Half4.gt(b: Half4) = Bool4(x > b.x, y > b.y, z > b.z, w > b.w)
|
||||
inline infix fun Half4.gte(b: Half) = Bool4(x >= b, y >= b, z >= b, w >= b)
|
||||
inline infix fun Half4.gte(b: Half4) = Bool4(x >= b.x, y >= b.y, z >= b.z, w >= b.w)
|
||||
inline infix fun Half4.eq(b: Half) = Bool4(x == b, y == b, z == b, w == b)
|
||||
inline infix fun Half4.eq(b: Half4) = Bool4(x == b.x, y == b.y, z == b.z, w == b.w)
|
||||
inline infix fun Half4.neq(b: Half) = Bool4(x != b, y != b, z != b, w != b)
|
||||
inline infix fun Half4.neq(b: Half4) = Bool4(x != b.x, y != b.y, z != b.z, w != b.w)
|
||||
|
||||
@@ -16,6 +16,13 @@ android {
|
||||
excludes += ['lib/*/libfilament-jni.so']
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
singleVariant("fullRelease") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -28,47 +28,81 @@ import com.google.android.filament.proguard.UsedByNative;
|
||||
|
||||
@UsedByNative("AssetLoader.cpp")
|
||||
public interface MaterialProvider {
|
||||
|
||||
/**
|
||||
* MaterialKey specifies the requirements for a requested glTF material.
|
||||
* The provider creates Filament materials that fulfill these requirements.
|
||||
*/
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public static class MaterialKey {
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean doubleSided;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean unlit;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasVertexColors;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasBaseColorTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasNormalTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasOcclusionTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasEmissiveTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean useSpecularGlossiness;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int alphaMode; // 0 = OPAQUE, 1 = MASK, 2 = BLEND
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean enableDiagnostics;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasMetallicRoughnessTexture; // piggybacks with specularRoughness
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int metallicRoughnessUV; // piggybacks with specularRoughness
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int baseColorUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasClearCoatTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int clearCoatUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasClearCoatRoughnessTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int clearCoatRoughnessUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasClearCoatNormalTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int clearCoatNormalUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasClearCoat;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasTransmission;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasTextureTransforms;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int emissiveUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int aoUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int normalUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasTransmissionTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int transmissionUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasSheenColorTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int sheenColorUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasSheenRoughnessTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int sheenRoughnessUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasVolumeThicknessTexture;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public int volumeThicknessUV;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasSheen;
|
||||
@UsedByNative("MaterialKey.cpp")
|
||||
public boolean hasIOR;
|
||||
|
||||
public MaterialKey() {}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.google.android.filament.Engine;
|
||||
import com.google.android.filament.MaterialInstance;
|
||||
import com.google.android.filament.Material;
|
||||
import com.google.android.filament.VertexBuffer;
|
||||
import com.google.android.filament.proguard.UsedByNative;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -94,6 +95,7 @@ public class UbershaderProvider implements MaterialProvider {
|
||||
nDestroyMaterials(mNativeObject);
|
||||
}
|
||||
|
||||
@UsedByNative("AssetLoader.cpp")
|
||||
public long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
GROUP=com.google.android.filament
|
||||
VERSION_NAME=1.31.0
|
||||
VERSION_NAME=1.42.0
|
||||
|
||||
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
|
||||
|
||||
@@ -18,7 +18,12 @@ POM_DEVELOPER_NAME=Filament Team
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
android.useAndroidX=true
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
|
||||
com.google.android.filament.tools-dir=../../../out/release/filament
|
||||
com.google.android.filament.dist-dir=../out/android-release/filament
|
||||
com.google.android.filament.abis=all
|
||||
#com.google.android.filament.matdbg
|
||||
#com.google.android.filament.matnopt
|
||||
|
||||
@@ -86,63 +86,10 @@ afterEvaluate { project ->
|
||||
}
|
||||
}
|
||||
|
||||
if (project.getPlugins().hasPlugin('com.android.application') ||
|
||||
project.getPlugins().hasPlugin('com.android.library')) {
|
||||
|
||||
task androidJavadocs(type: Javadoc) {
|
||||
source = android.sourceSets.main.java.source
|
||||
classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
|
||||
excludes = ['**/*.kt']
|
||||
}
|
||||
|
||||
task androidJavadocsJar(type: Jar, dependsOn: androidJavadocs) {
|
||||
classifier = 'javadoc'
|
||||
from androidJavadocs.destinationDir
|
||||
}
|
||||
|
||||
task androidSourcesJar(type: Jar) {
|
||||
classifier = 'sources'
|
||||
from android.sourceSets.main.java.source
|
||||
}
|
||||
}
|
||||
|
||||
if (JavaVersion.current().isJava8Compatible()) {
|
||||
allprojects {
|
||||
tasks.withType(Javadoc) {
|
||||
options.addStringOption('Xdoclint:none', '-quiet')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (JavaVersion.current().isJava9Compatible()) {
|
||||
allprojects {
|
||||
tasks.withType(Javadoc) {
|
||||
options.addBooleanOption('html5', true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
artifacts {
|
||||
if (project.getPlugins().hasPlugin('com.android.application') ||
|
||||
project.getPlugins().hasPlugin('com.android.library')) {
|
||||
archives androidSourcesJar
|
||||
archives androidJavadocsJar
|
||||
}
|
||||
}
|
||||
|
||||
android.libraryVariants.all { variant ->
|
||||
tasks.androidJavadocs.doFirst {
|
||||
classpath += files(variant.javaCompileProvider.get().classpath.files.join(File.pathSeparator))
|
||||
}
|
||||
}
|
||||
|
||||
publishing.publications.all { publication ->
|
||||
publication.groupId = GROUP
|
||||
publication.version = VERSION_NAME
|
||||
|
||||
publication.artifact androidSourcesJar
|
||||
publication.artifact androidJavadocsJar
|
||||
|
||||
configurePom(publication.pom)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#Wed Nov 17 10:40:18 PST 2021
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -40,6 +40,11 @@ android {
|
||||
dependenciesInfo {
|
||||
includeInApk = false
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -28,6 +28,7 @@ import com.google.android.filament.Fence
|
||||
import com.google.android.filament.IndirectLight
|
||||
import com.google.android.filament.Skybox
|
||||
import com.google.android.filament.View
|
||||
import com.google.android.filament.View.OnPickCallback
|
||||
import com.google.android.filament.utils.*
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
@@ -56,7 +57,9 @@ class MainActivity : Activity() {
|
||||
private lateinit var modelViewer: ModelViewer
|
||||
private lateinit var titlebarHint: TextView
|
||||
private val doubleTapListener = DoubleTapListener()
|
||||
private val singleTapListener = SingleTapListener()
|
||||
private lateinit var doubleTapDetector: GestureDetector
|
||||
private lateinit var singleTapDetector: GestureDetector
|
||||
private var remoteServer: RemoteServer? = null
|
||||
private var statusToast: Toast? = null
|
||||
private var statusText: String? = null
|
||||
@@ -77,6 +80,7 @@ class MainActivity : Activity() {
|
||||
choreographer = Choreographer.getInstance()
|
||||
|
||||
doubleTapDetector = GestureDetector(applicationContext, doubleTapListener)
|
||||
singleTapDetector = GestureDetector(applicationContext, singleTapListener)
|
||||
|
||||
modelViewer = ModelViewer(surfaceView)
|
||||
viewerContent.view = modelViewer.view
|
||||
@@ -88,6 +92,7 @@ class MainActivity : Activity() {
|
||||
surfaceView.setOnTouchListener { _, event ->
|
||||
modelViewer.onTouchEvent(event)
|
||||
doubleTapDetector.onTouchEvent(event)
|
||||
singleTapDetector.onTouchEvent(event)
|
||||
true
|
||||
}
|
||||
|
||||
@@ -229,6 +234,7 @@ class MainActivity : Activity() {
|
||||
modelViewer.scene.skybox = sky
|
||||
modelViewer.scene.indirectLight = ibl
|
||||
viewerContent.indirectLight = ibl
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -337,6 +343,11 @@ class MainActivity : Activity() {
|
||||
remoteServer?.close()
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
super.onBackPressed()
|
||||
finish()
|
||||
}
|
||||
|
||||
fun loadModelData(message: RemoteServer.ReceivedMessage) {
|
||||
Log.i(TAG, "Downloaded model ${message.label} (${message.buffer.capacity()} bytes)")
|
||||
clearStatusText()
|
||||
@@ -356,6 +367,8 @@ class MainActivity : Activity() {
|
||||
automation.applySettings(modelViewer.engine, json, viewerContent)
|
||||
modelViewer.view.colorGrading = automation.getColorGrading(modelViewer.engine)
|
||||
modelViewer.cameraFocalLength = automation.viewerOptions.cameraFocalLength
|
||||
modelViewer.cameraNear = automation.viewerOptions.cameraNear
|
||||
modelViewer.cameraFar = automation.viewerOptions.cameraFar
|
||||
updateRootTransform()
|
||||
}
|
||||
|
||||
@@ -423,4 +436,19 @@ class MainActivity : Activity() {
|
||||
return super.onDoubleTap(e)
|
||||
}
|
||||
}
|
||||
|
||||
// Just for testing purposes
|
||||
inner class SingleTapListener : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onSingleTapUp(event: MotionEvent): Boolean {
|
||||
modelViewer.view.pick(
|
||||
event.x.toInt(),
|
||||
surfaceView.height - event.y.toInt(),
|
||||
surfaceView.handler, {
|
||||
val name = modelViewer.asset!!.getName(it.renderable)
|
||||
Log.v("Filament", "Picked ${it.renderable}: " + name)
|
||||
},
|
||||
)
|
||||
return super.onSingleTapUp(event)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -36,6 +40,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.android.filament.*
|
||||
import com.google.android.filament.RenderableManager.*
|
||||
import com.google.android.filament.VertexBuffer.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
@@ -401,6 +402,8 @@ class MainActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCallba
|
||||
camera.setProjection(45.0, aspect, 0.1, 20.0, Camera.Fov.VERTICAL)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -36,6 +40,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.android.filament.RenderableManager.PrimitiveType
|
||||
import com.google.android.filament.VertexBuffer.AttributeType
|
||||
import com.google.android.filament.VertexBuffer.VertexAttribute
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
@@ -119,8 +120,13 @@ class MainActivity : Activity() {
|
||||
private fun setupView() {
|
||||
scene.skybox = Skybox.Builder().color(0.035f, 0.035f, 0.035f, 1.0f).build(engine)
|
||||
|
||||
// NOTE: Try to disable post-processing (tone-mapping, etc.) to see the difference
|
||||
// view.isPostProcessingEnabled = false
|
||||
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
|
||||
// post-processing is not supported at feature level 0
|
||||
view.isPostProcessingEnabled = false
|
||||
} else {
|
||||
// NOTE: Try to disable post-processing (tone-mapping, etc.) to see the difference
|
||||
// view.isPostProcessingEnabled = false
|
||||
}
|
||||
|
||||
// Tell the view which camera we want to use
|
||||
view.camera = camera
|
||||
@@ -154,7 +160,11 @@ class MainActivity : Activity() {
|
||||
}
|
||||
|
||||
private fun loadMaterial() {
|
||||
readUncompressedAsset("materials/baked_color.filamat").let {
|
||||
var name = "materials/baked_color.filamat"
|
||||
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
|
||||
name = "materials/baked_color_es2.filamat"
|
||||
}
|
||||
readUncompressedAsset(name).let {
|
||||
material = Material.Builder().payload(it, it.remaining()).build(engine)
|
||||
}
|
||||
}
|
||||
@@ -304,7 +314,17 @@ class MainActivity : Activity() {
|
||||
inner class SurfaceCallback : UiHelper.RendererCallback {
|
||||
override fun onNativeWindowChanged(surface: Surface) {
|
||||
swapChain?.let { engine.destroySwapChain(it) }
|
||||
swapChain = engine.createSwapChain(surface, uiHelper.swapChainFlags)
|
||||
|
||||
// at feature level 0, we don't have post-processing, so we need to set
|
||||
// the colorspace to sRGB (FIXME: it's not supported everywhere!)
|
||||
var flags = uiHelper.swapChainFlags
|
||||
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
|
||||
if (SwapChain.isSRGBSwapChainSupported(engine)) {
|
||||
flags = flags or SwapChain.CONFIG_SRGB_COLORSPACE
|
||||
}
|
||||
}
|
||||
|
||||
swapChain = engine.createSwapChain(surface, flags)
|
||||
displayHelper.attach(renderer, surfaceView.display);
|
||||
}
|
||||
|
||||
@@ -327,6 +347,8 @@ class MainActivity : Activity() {
|
||||
-aspect * zoom, aspect * zoom, -zoom, zoom, 0.0, 10.0)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ material {
|
||||
],
|
||||
|
||||
// This material disables all lighting
|
||||
shadingModel : unlit,
|
||||
shadingModel : unlit
|
||||
}
|
||||
|
||||
fragment {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
// Simple unlit material that uses the colors associated with each vertex.
|
||||
//
|
||||
// This source material must be compiled to a binary material using the matc tool.
|
||||
// The command used to compile this material is:
|
||||
// matc -p mobile -a opengl -o app/src/main/assets/baked_color.filamat app/src/materials/baked_color.mat
|
||||
//
|
||||
// See build.gradle for an example of how to compile materials automatically
|
||||
// Please refer to the documentation for more information about matc and the materials system.
|
||||
|
||||
material {
|
||||
name : baked_color,
|
||||
|
||||
// Lists the required vertex attributes
|
||||
// Here we only need a color (RGBA)
|
||||
requires : [
|
||||
color
|
||||
],
|
||||
|
||||
// This material disables all lighting
|
||||
shadingModel : unlit,
|
||||
featureLevel : 0
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
// You must always call the prepareMaterial() function
|
||||
prepareMaterial(material);
|
||||
|
||||
// We set the material's color to the color interpolated from
|
||||
// the model's vertices
|
||||
material.baseColor = getColor();
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -42,6 +46,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.animation.LinearInterpolator
|
||||
|
||||
import com.google.android.filament.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
@@ -117,9 +118,10 @@ class MainActivity : Activity() {
|
||||
}
|
||||
|
||||
private fun setupView() {
|
||||
val ssaoOptions = view.ambientOcclusionOptions
|
||||
ssaoOptions.enabled = true
|
||||
view.ambientOcclusionOptions = ssaoOptions
|
||||
// ambient occlusion is the cheapest effect that adds a lot of quality
|
||||
view.ambientOcclusionOptions = view.ambientOcclusionOptions.apply {
|
||||
enabled = true
|
||||
}
|
||||
|
||||
// NOTE: Try to disable post-processing (tone-mapping, etc.) to see the difference
|
||||
// view.isPostProcessingEnabled = false
|
||||
@@ -303,6 +305,8 @@ class MainActivity : Activity() {
|
||||
camera.setProjection(45.0, aspect, 0.1, 20.0, Camera.Fov.VERTICAL)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -35,6 +39,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.android.filament.*
|
||||
import com.google.android.filament.RenderableManager.*
|
||||
import com.google.android.filament.VertexBuffer.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
@@ -413,6 +414,8 @@ class MainActivity : Activity() {
|
||||
camera.setProjection(45.0, aspect, 0.1, 20.0, Camera.Fov.VERTICAL)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,10 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.livewallpaper'
|
||||
|
||||
@@ -18,6 +22,11 @@ android {
|
||||
dependenciesInfo {
|
||||
includeInApk = false
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.view.animation.LinearInterpolator
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.google.android.filament.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
|
||||
class FilamentLiveWallpaper : WallpaperService() {
|
||||
@@ -226,6 +227,8 @@ class FilamentLiveWallpaper : WallpaperService() {
|
||||
camera.setProjection(45.0, aspect, 0.1, 20.0, Camera.Fov.VERTICAL)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
meshInputFile = project.layout.projectDirectory.file("../../../third_party/models/shader_ball/shader_ball.obj")
|
||||
meshOutputDir = project.layout.projectDirectory.dir("src/main/assets/models")
|
||||
@@ -46,6 +50,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.animation.LinearInterpolator
|
||||
|
||||
import com.google.android.filament.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
import com.google.android.filament.filamat.MaterialBuilder
|
||||
|
||||
@@ -343,6 +344,8 @@ class MainActivity : Activity() {
|
||||
camera.setProjection(45.0, aspect, 0.1, 20.0, Camera.Fov.VERTICAL)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">Image-Based Lighting</string>
|
||||
<string name="app_name">Material Builder</string>
|
||||
</resources>
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -35,6 +39,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -30,6 +30,7 @@ import com.google.android.filament.RenderableManager.*
|
||||
import com.google.android.filament.Renderer.ClearOptions
|
||||
import com.google.android.filament.VertexBuffer.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
@@ -458,6 +459,8 @@ class MainActivity : Activity() {
|
||||
view1.viewport = Viewport(width / 2, 0, width / 2, height / 2)
|
||||
view2.viewport = Viewport(0, height / 2, width / 2, height / 2)
|
||||
view4.viewport = Viewport(width / 4, height / 4, width / 2, height / 2)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
iblInputFile = project.layout.projectDirectory.file("../../../third_party/environments/studio_small_02_2k.hdr")
|
||||
iblOutputDir = project.layout.projectDirectory.dir("src/main/assets/envs")
|
||||
@@ -38,6 +42,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.google.android.filament.Camera;
|
||||
import com.google.android.filament.Engine;
|
||||
import com.google.android.filament.Entity;
|
||||
import com.google.android.filament.EntityManager;
|
||||
import com.google.android.filament.Fence;
|
||||
import com.google.android.filament.Filament;
|
||||
import com.google.android.filament.IndirectLight;
|
||||
import com.google.android.filament.LightManager;
|
||||
@@ -49,6 +50,7 @@ import com.google.android.filament.TransformManager;
|
||||
import com.google.android.filament.Viewport;
|
||||
|
||||
import com.google.android.filament.android.DisplayHelper;
|
||||
import com.google.android.filament.android.FilamentHelper;
|
||||
import com.google.android.filament.android.TextureHelper;
|
||||
import com.google.android.filament.android.UiHelper;
|
||||
|
||||
@@ -107,6 +109,7 @@ public class MainActivity extends Activity
|
||||
mCamera.setProjection(60.0, aspect, 1.0, 2000.0, Camera.Fov.HORIZONTAL);
|
||||
}
|
||||
mView.setViewport(new Viewport(0, 0, width, height));
|
||||
FilamentHelper.synchronizePendingFrames(mEngine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -36,6 +40,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -38,6 +38,7 @@ import android.os.Build
|
||||
import android.view.MotionEvent
|
||||
import androidx.annotation.RequiresApi
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
|
||||
|
||||
class MainActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCallback {
|
||||
@@ -401,6 +402,8 @@ class MainActivity : Activity(), ActivityCompat.OnRequestPermissionsResultCallba
|
||||
camera.setProjection(45.0, aspect, 0.1, 20.0, Camera.Fov.VERTICAL)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -36,6 +40,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.google.android.filament.RenderableManager.PrimitiveType
|
||||
import com.google.android.filament.VertexBuffer.AttributeType
|
||||
import com.google.android.filament.VertexBuffer.VertexAttribute
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
import java.nio.ByteBuffer
|
||||
import java.nio.ByteOrder
|
||||
@@ -327,6 +328,8 @@ class MainActivity : Activity() {
|
||||
-aspect * zoom, aspect * zoom, -zoom, zoom, 0.0, 10.0)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -43,6 +47,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.view.animation.LinearInterpolator
|
||||
|
||||
import com.google.android.filament.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.utils.*
|
||||
import com.google.android.filament.android.UiHelper
|
||||
|
||||
@@ -230,7 +231,7 @@ class MainActivity : Activity() {
|
||||
animator.repeatCount = ValueAnimator.INFINITE
|
||||
animator.addUpdateListener { a ->
|
||||
val v = (a.animatedValue as Float)
|
||||
camera.lookAt(cos(v) * 4.5, 1.5, sin(v) * 4.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
|
||||
camera.lookAt(cos(v) * 5.5, 1.5, sin(v) * 5.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0)
|
||||
}
|
||||
animator.start()
|
||||
}
|
||||
@@ -252,7 +253,7 @@ class MainActivity : Activity() {
|
||||
|
||||
// Stop the animation and any pending frame
|
||||
choreographer.removeFrameCallback(frameScheduler)
|
||||
animator.cancel();
|
||||
animator.cancel()
|
||||
|
||||
// Always detach the surface before destroying the engine
|
||||
uiHelper.detach()
|
||||
@@ -323,6 +324,8 @@ class MainActivity : Activity() {
|
||||
camera.setProjection(45.0, aspect, 0.1, 20.0, Camera.Fov.VERTICAL)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,10 @@ plugins {
|
||||
|
||||
project.ext.isSample = true
|
||||
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
filamentTools {
|
||||
materialInputDir = project.layout.projectDirectory.dir("src/main/materials")
|
||||
materialOutputDir = project.layout.projectDirectory.dir("src/main/assets/materials")
|
||||
@@ -36,6 +40,11 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.google.android.filament.*
|
||||
import com.google.android.filament.RenderableManager.*
|
||||
import com.google.android.filament.VertexBuffer.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.FilamentHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
|
||||
import java.nio.ByteBuffer
|
||||
@@ -139,9 +140,9 @@ class MainActivity : Activity() {
|
||||
camera = engine.createCamera(engine.entityManager.create())
|
||||
|
||||
// clear the swapchain with transparent pixels
|
||||
val options = renderer.clearOptions
|
||||
options.clear = true
|
||||
renderer.clearOptions = options
|
||||
renderer.clearOptions = renderer.clearOptions.apply {
|
||||
clear = true
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupView() {
|
||||
@@ -350,6 +351,8 @@ class MainActivity : Activity() {
|
||||
-aspect * zoom, aspect * zoom, -zoom, zoom, 0.0, 10.0)
|
||||
|
||||
view.viewport = Viewport(0, 0, width, height)
|
||||
|
||||
FilamentHelper.synchronizePendingFrames(engine)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Before Width: | Height: | Size: 848 KiB After Width: | Height: | Size: 848 KiB |
35
build.sh
35
build.sh
@@ -22,9 +22,11 @@ function print_help {
|
||||
echo " All (and only) git-ignored files under android/ are deleted."
|
||||
echo " This is sometimes needed instead of -c (which still misses some clean steps)."
|
||||
echo " -d"
|
||||
echo " Enable matdbg and disable material optimization."
|
||||
echo " Enable matdbg."
|
||||
echo " -f"
|
||||
echo " Always invoke CMake before incremental builds."
|
||||
echo " -g"
|
||||
echo " Disable material optimization."
|
||||
echo " -i"
|
||||
echo " Install build output"
|
||||
echo " -m"
|
||||
@@ -56,6 +58,9 @@ function print_help {
|
||||
echo " When building for Android, also build select sample APKs."
|
||||
echo " sampleN is an Android sample, e.g., sample-gltf-viewer."
|
||||
echo " This automatically performs a partial desktop build and install."
|
||||
echo " -b"
|
||||
echo " Enable Address and Undefined Behavior Sanitizers (asan/ubsan) for debugging."
|
||||
echo " This is only for the desktop build."
|
||||
echo ""
|
||||
echo "Build types:"
|
||||
echo " release"
|
||||
@@ -85,8 +90,8 @@ function print_help {
|
||||
echo " Desktop matc target, release build:"
|
||||
echo " \$ ./$self_name release matc"
|
||||
echo ""
|
||||
echo " Build gltf_viewer then immediately run it with no arguments:"
|
||||
echo " \$ ./$self_name release run_gltf_viewer"
|
||||
echo " Build gltf_viewer:"
|
||||
echo " \$ ./$self_name release gltf_viewer"
|
||||
echo ""
|
||||
}
|
||||
|
||||
@@ -162,6 +167,11 @@ EGL_ON_LINUX_OPTION="-DFILAMENT_SUPPORTS_EGL_ON_LINUX=OFF"
|
||||
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=OFF"
|
||||
MATDBG_GRADLE_OPTION=""
|
||||
|
||||
MATOPT_OPTION=""
|
||||
MATOPT_GRADLE_OPTION=""
|
||||
|
||||
ASAN_UBSAN_OPTION=""
|
||||
|
||||
IOS_BUILD_SIMULATOR=false
|
||||
BUILD_UNIVERSAL_LIBRARIES=false
|
||||
|
||||
@@ -221,6 +231,8 @@ function build_desktop_target {
|
||||
${SWIFTSHADER_OPTION} \
|
||||
${EGL_ON_LINUX_OPTION} \
|
||||
${MATDBG_OPTION} \
|
||||
${MATOPT_OPTION} \
|
||||
${ASAN_UBSAN_OPTION} \
|
||||
${deployment_target} \
|
||||
${architectures} \
|
||||
../..
|
||||
@@ -347,6 +359,7 @@ function build_android_target {
|
||||
-DCMAKE_INSTALL_PREFIX="../android-${lc_target}/filament" \
|
||||
-DCMAKE_TOOLCHAIN_FILE="../../build/toolchain-${arch}-linux-android.cmake" \
|
||||
${MATDBG_OPTION} \
|
||||
${MATOPT_OPTION} \
|
||||
${VULKAN_ANDROID_OPTION} \
|
||||
../..
|
||||
fi
|
||||
@@ -463,6 +476,7 @@ function build_android {
|
||||
-Pcom.google.android.filament.abis=${ABI_GRADLE_OPTION} \
|
||||
${VULKAN_ANDROID_GRADLE_OPTION} \
|
||||
${MATDBG_GRADLE_OPTION} \
|
||||
${MATOPT_GRADLE_OPTION} \
|
||||
:filament-android:assembleDebug \
|
||||
:gltfio-android:assembleDebug \
|
||||
:filament-utils-android:assembleDebug
|
||||
@@ -477,6 +491,7 @@ function build_android {
|
||||
./gradlew \
|
||||
-Pcom.google.android.filament.dist-dir=../out/android-debug/filament \
|
||||
-Pcom.google.android.filament.abis=${ABI_GRADLE_OPTION} \
|
||||
${MATOPT_GRADLE_OPTION} \
|
||||
:samples:${sample}:assembleDebug
|
||||
done
|
||||
fi
|
||||
@@ -510,6 +525,7 @@ function build_android {
|
||||
-Pcom.google.android.filament.abis=${ABI_GRADLE_OPTION} \
|
||||
${VULKAN_ANDROID_GRADLE_OPTION} \
|
||||
${MATDBG_GRADLE_OPTION} \
|
||||
${MATOPT_GRADLE_OPTION} \
|
||||
:filament-android:assembleRelease \
|
||||
:gltfio-android:assembleRelease \
|
||||
:filament-utils-android:assembleRelease
|
||||
@@ -524,6 +540,7 @@ function build_android {
|
||||
./gradlew \
|
||||
-Pcom.google.android.filament.dist-dir=../out/android-release/filament \
|
||||
-Pcom.google.android.filament.abis=${ABI_GRADLE_OPTION} \
|
||||
${MATOPT_GRADLE_OPTION} \
|
||||
:samples:${sample}:assembleRelease
|
||||
done
|
||||
fi
|
||||
@@ -576,6 +593,7 @@ function build_ios_target {
|
||||
-DIOS=1 \
|
||||
-DCMAKE_TOOLCHAIN_FILE=../../third_party/clang/iOS.cmake \
|
||||
${MATDBG_OPTION} \
|
||||
${MATOPT_OPTION} \
|
||||
../..
|
||||
fi
|
||||
|
||||
@@ -740,7 +758,7 @@ function run_tests {
|
||||
|
||||
pushd "$(dirname "$0")" > /dev/null
|
||||
|
||||
while getopts ":hacCfijmp:q:uvslwtedk:" opt; do
|
||||
while getopts ":hacCfgijmp:q:uvslwtedk:b" opt; do
|
||||
case ${opt} in
|
||||
h)
|
||||
print_help
|
||||
@@ -758,12 +776,16 @@ while getopts ":hacCfijmp:q:uvslwtedk:" opt; do
|
||||
;;
|
||||
d)
|
||||
PRINT_MATDBG_HELP=true
|
||||
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=ON, -DFILAMENT_DISABLE_MATOPT=ON, -DFILAMENT_BUILD_FILAMAT=ON"
|
||||
MATDBG_OPTION="-DFILAMENT_ENABLE_MATDBG=ON, -DFILAMENT_BUILD_FILAMAT=ON"
|
||||
MATDBG_GRADLE_OPTION="-Pcom.google.android.filament.matdbg"
|
||||
;;
|
||||
f)
|
||||
ISSUE_CMAKE_ALWAYS=true
|
||||
;;
|
||||
g)
|
||||
MATOPT_OPTION="-DFILAMENT_DISABLE_MATOPT=ON"
|
||||
MATOPT_GRADLE_OPTION="-Pcom.google.android.filament.matnopt"
|
||||
;;
|
||||
i)
|
||||
INSTALL_COMMAND=install
|
||||
;;
|
||||
@@ -863,6 +885,9 @@ while getopts ":hacCfijmp:q:uvslwtedk:" opt; do
|
||||
BUILD_ANDROID_SAMPLES=true
|
||||
ANDROID_SAMPLES=$(echo "${OPTARG}" | tr ',' '\n')
|
||||
;;
|
||||
b) ASAN_UBSAN_OPTION="-DFILAMENT_ENABLE_ASAN_UBSAN=ON"
|
||||
echo "Enabled ASAN/UBSAN"
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -${OPTARG}" >&2
|
||||
echo ""
|
||||
|
||||
@@ -44,13 +44,20 @@ elif [[ "$LC_UNAME" == "darwin" ]]; then
|
||||
fi
|
||||
source `dirname $0`/../common/build-common.sh
|
||||
|
||||
if [[ "$GITHUB_WORKFLOW" ]]; then
|
||||
java_version=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)
|
||||
if [[ "$java_version" < 17 ]]; then
|
||||
echo "Android builds require Java 17, found version ${java_version} instead"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Unless explicitly specified, NDK version will be set to match exactly the required one
|
||||
FILAMENT_NDK_VERSION=${FILAMENT_NDK_VERSION:-$(cat `dirname $0`/ndk.version)}
|
||||
|
||||
# Install the required NDK version specifically (if not present)
|
||||
if [[ ! -d "${ANDROID_HOME}/ndk/$FILAMENT_NDK_VERSION" ]]; then
|
||||
# NOTE: We MUST use Java 1.8 to run sdkmanager currently, it fails starting with Java 11
|
||||
JAVA_HOME=${JAVA_HOME_8_X64} ${ANDROID_HOME}/tools/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION" > /dev/null
|
||||
${ANDROID_HOME}/cmdline-tools/latest/bin/sdkmanager "ndk;$FILAMENT_NDK_VERSION" > /dev/null
|
||||
fi
|
||||
|
||||
# Only build 1 64 bit target during presubmit to cut down build times during presubmit
|
||||
|
||||
@@ -2,6 +2,11 @@
|
||||
|
||||
set -e
|
||||
|
||||
case "$(uname -s)" in
|
||||
Darwin*) IS_DARWIN=1;;
|
||||
*) ;;
|
||||
esac
|
||||
|
||||
function print_help {
|
||||
local SELF_NAME
|
||||
SELF_NAME=$(basename "$0")
|
||||
@@ -45,7 +50,11 @@ function replace {
|
||||
FIND_STR="${1//\{\{VERSION\}\}/${VERSION_REGEX}}"
|
||||
REPLACE_STR="${1//\{\{VERSION\}\}/${NEW_VERSION}}"
|
||||
local FILE_NAME="$2"
|
||||
sed -i '' -E "s/${FIND_STR}/${REPLACE_STR}/" "${FILE_NAME}"
|
||||
if [ IS_DARWIN ]; then
|
||||
sed -i '' -E "s/${FIND_STR}/${REPLACE_STR}/" "${FILE_NAME}"
|
||||
else
|
||||
sed -i -E "s/${FIND_STR}/${REPLACE_STR}/" "${FILE_NAME}"
|
||||
fi
|
||||
}
|
||||
|
||||
# The following are the canonical locations where the Filament version number is referenced.
|
||||
|
||||
@@ -44,6 +44,10 @@ FILAMENT_HEADERS="$1"
|
||||
includes=()
|
||||
pushd "$FILAMENT_HEADERS" >/dev/null
|
||||
for f in $(find . -name '*.h'); do
|
||||
# Ignore platform headers. These may contain platform-specific includes.
|
||||
if [[ "$f" == *backend/platforms/* ]]; then
|
||||
continue
|
||||
fi
|
||||
include_path="${f#./}" # strip leading ./
|
||||
includes+=("${include_path}")
|
||||
done
|
||||
|
||||
@@ -3,12 +3,4 @@
|
||||
if [[ "$GITHUB_WORKFLOW" ]]; then
|
||||
echo "Running workflow $GITHUB_WORKFLOW (event: $GITHUB_EVENT_NAME, action: $GITHUB_ACTION)"
|
||||
CONTINUOUS_INTEGRATION=true
|
||||
|
||||
# Force Java to be Java 11 minimum, it defaults to 8 in GitHub runners for some platforms
|
||||
export JAVA_HOME=${JAVA_HOME_11_X64}
|
||||
java_version=$(java -version 2>&1 | head -1 | cut -d'"' -f2 | sed '/^1\./s///' | cut -d'.' -f1)
|
||||
if [[ "$java_version" < 11 ]]; then
|
||||
echo "Android builds require Java 11, found version ${java_version} instead"
|
||||
exit 0
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
# version of clang we want to use
|
||||
GITHUB_CLANG_VERSION=8
|
||||
GITHUB_CLANG_VERSION=14
|
||||
# version of CMake to use instead of the default one
|
||||
CMAKE_VERSION=3.19.5
|
||||
# version of ninja to use
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -200,7 +200,7 @@ Energy conservation is one of the key components of a good BRDF for physically b
|
||||
|
||||
## Specular BRDF
|
||||
|
||||
For the specular term, $f_m$ is a mirror BRDF that can be modeled with the Fresnel law, noted $F$ in the Cook-Torrance approximation of the microfacet model integration:
|
||||
For the specular term, $f_r$ is a mirror BRDF that can be modeled with the Fresnel law, noted $F$ in the Cook-Torrance approximation of the microfacet model integration:
|
||||
|
||||
$$\begin{equation}
|
||||
f_r(v,l) = \frac{D(h, \alpha) G(v, l, \alpha) F(v, h, f0)}{4(\NoV)(\NoL)}
|
||||
@@ -485,7 +485,7 @@ void BRDF(...) {
|
||||
// perceptually linear roughness to roughness (see parameterization)
|
||||
float roughness = perceptualRoughness * perceptualRoughness;
|
||||
|
||||
float D = D_GGX(NoH, a);
|
||||
float D = D_GGX(NoH, roughness);
|
||||
vec3 F = F_Schlick(LoH, f0);
|
||||
float V = V_SmithGGXCorrelated(NoV, NoL, roughness);
|
||||
|
||||
@@ -2016,7 +2016,7 @@ I(f(n, v, \alpha)) \equiv \frac{1}{N}\sum_{\forall \, i \in image} f(l_i,
|
||||
\end{equation}$$
|
||||
|
||||
However, in practice we're using _importance sampling_ which needs to take the $pdf$ of the distribution
|
||||
into account and adds a term $\frac{\left<\VoH\right>}{D(h_i, \alpha)\left<\NoH\right>}$.
|
||||
into account and adds a term $\frac{4\left<\VoH\right>}{D(h_i, \alpha)\left<\NoH\right>}$.
|
||||
See Importance Sampling For The IBL section:
|
||||
|
||||
$$\begin{equation}\label{iblImportanceSampling}
|
||||
@@ -3486,15 +3486,15 @@ The _important direction samples_ $l_i$ are calculated as the reflection of $v$
|
||||
**do not** have the same PDF as $h_i$. The PDF of a transformed distribution is given by:
|
||||
|
||||
$$\begin{equation}
|
||||
p(T_r(x)) = p(x) |J(T_r)|
|
||||
p(T_r(x)) = p(x) |J(T_r)|^{-1}
|
||||
\end{equation}$$
|
||||
|
||||
Where $|J(T_r)|$ is the determinant of the Jacobian of the transform. In our case we're considering
|
||||
the transform from $h_i$ to $l_i$ and the determinant of its Jacobian is given in \ref{iblPDF}.
|
||||
|
||||
$$\begin{equation}\label{iblPDF}
|
||||
p(l,v,\Theta) = D(h,\alpha) \left< \NoH \right> |J_{h \rightarrow l}| \\
|
||||
|J_{h \rightarrow l}| = \frac{1}{4 \left< \VoH \right>}
|
||||
p(l,v,\Theta) = D(h,\alpha) \left< \NoH \right> |J_{h \rightarrow l}|^{-1} \\
|
||||
|J_{h \rightarrow l}| = 4 \left< \VoH \right>
|
||||
\end{equation}$$
|
||||
|
||||
### Choosing important directions
|
||||
@@ -3821,7 +3821,7 @@ Since $\left< cos \theta \right>$ does not depend on $\phi$ (azimuthal independe
|
||||
|
||||
$$\begin{align*}
|
||||
C^0_l &= 2\pi \int_0^{\pi} \left< cos \theta \right> y^0_l(\theta) sin \theta d\theta \\
|
||||
C^0_l &= 2\pi K^)_l \int_0^{\frac{\pi}{2}} P^0_l(cos \theta) cos \theta sin \theta d\theta \\
|
||||
C^0_l &= 2\pi K^m_l \int_0^{\frac{\pi}{2}} P^0_l(cos \theta) cos \theta sin \theta d\theta \\
|
||||
C^m_l &= 0, m != 0
|
||||
\end{align*}$$
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -1076,13 +1076,71 @@ fragment {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
### General: constants
|
||||
|
||||
Type
|
||||
: array of constant objects
|
||||
|
||||
Value
|
||||
: Each entry is an object with the properties `name` and `type`, both of `string` type. The name
|
||||
must be a valid GLSL identifier. Entries also have an optional `default`, which can either be a
|
||||
`bool` or `number`, depending on the `type` of the constant. The type must be one of the types
|
||||
described in table [materialConstantsTypes].
|
||||
|
||||
Type | Description | Default
|
||||
:----------------------|:-----------------------------------------|:------------------
|
||||
int | A signed, 32 bit GLSL int | 0
|
||||
float | A single-precision GLSL float | 0.0
|
||||
bool | A GLSL bool | false
|
||||
[Table [materialConstantsTypes]: Material constants types]
|
||||
|
||||
Description
|
||||
: Lists the constant parameters accepted by your material. These constants can be set, or
|
||||
"specialized", at runtime when loading a material package. Multiple materials can be loaded from
|
||||
the same material package with differing constant parameter specializations. Once a material is
|
||||
loaded from a material package, its constant parameters cannot be changed. Compared to regular
|
||||
parameters, constant parameters allow the compiler to generate more efficient code. Access
|
||||
constant parameters from the shader by prefixing the name with `materialConstant_`. For example,
|
||||
a constant parameter named `myConstant` is accessed in the shader as
|
||||
`materialConstant_myConstant`. If a constant parameter is not set at runtime, the default is
|
||||
used.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON
|
||||
material {
|
||||
constants : [
|
||||
{
|
||||
name : overrideAlpha,
|
||||
type : bool
|
||||
},
|
||||
{
|
||||
name : customAlpha,
|
||||
type : float,
|
||||
default : 0.5
|
||||
}
|
||||
],
|
||||
shadingModel : lit,
|
||||
blending : transparent,
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
prepareMaterial(material);
|
||||
if (materialConstants_overrideAlpha) {
|
||||
material.baseColor.a = materialConstants_customAlpha;
|
||||
material.baseColor.rgb *= material.baseColor.a;
|
||||
}
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
### General: variantFilter
|
||||
|
||||
Type
|
||||
: array of `string`
|
||||
|
||||
Value
|
||||
: Each entry must be any of `dynamicLighting`, `directionalLighting`, `shadowReceiver`,`skinning` or `ssr`.
|
||||
: Each entry must be any of `dynamicLighting`, `directionalLighting`, `shadowReceiver`,
|
||||
`skinning`, `ssr`, or `stereo`.
|
||||
|
||||
Description
|
||||
: Used to specify a list of shader variants that the application guarantees will never be
|
||||
@@ -1101,6 +1159,7 @@ Description of the variants:
|
||||
- `fog`, used when global fog is applied to the scene
|
||||
- `vsm`, used when VSM shadows are enabled and the object is a shadow receiver
|
||||
- `ssr`, used when screen-space reflections are enabled in the View
|
||||
- `stereo`, used when stereoscopic rendering is enabled in the View
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON
|
||||
material {
|
||||
@@ -1362,6 +1421,11 @@ Description
|
||||
ALPHA_TO_COVERAGE is enabled for non-translucent views. See the maskThreshold section for more
|
||||
information.
|
||||
|
||||
!!! Note
|
||||
When `blending` is set to `masked`, alpha to coverage is automatically enabled for the material.
|
||||
If this behavior is undesirable, refer to the Rasterization: alphaToCoverage section to turn
|
||||
alpha to coverage off using the `alphaToCoverage` property.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON
|
||||
material {
|
||||
blending : transparent
|
||||
@@ -1602,6 +1666,37 @@ fragment {
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
### Rasterization: alphaToCoverage
|
||||
|
||||
Type
|
||||
: `boolean`
|
||||
|
||||
Value
|
||||
: `true` or `false`. Defaults to `false`.
|
||||
|
||||
Description
|
||||
: Enables or disables alpha to coverage. When alpha to coverage is enabled, the coverage of
|
||||
fragment is derived from its alpha. This property is only meaningful when MSAA is enabled.
|
||||
Note: setting `blending` to `masked` automatically enables alpha to coverage. If this is not
|
||||
desired, you can override this behavior by setting alpha to coverage to false as in the
|
||||
example below.
|
||||
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ JSON
|
||||
material {
|
||||
name : "Alpha to coverage",
|
||||
shadingModel : lit,
|
||||
blending : masked,
|
||||
alphaToCoverage : false
|
||||
}
|
||||
|
||||
fragment {
|
||||
void material(inout MaterialInputs material) {
|
||||
prepareMaterial(material);
|
||||
material.baseColor = materialParams.albedo;
|
||||
}
|
||||
}
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
### Lighting: reflections
|
||||
|
||||
Type
|
||||
@@ -1910,8 +2005,9 @@ struct MaterialVertexInputs {
|
||||
|
||||
!!! TIP: worldPosition
|
||||
To achieve good precision, the `worldPosition` coordinate in the vertex shader is shifted by the
|
||||
camera position. To get the true world-space position, users can add this to
|
||||
`getWorldOffset()`.
|
||||
camera position. To get the true world-space position, users can use
|
||||
`getUserWorldPosition()`, however be aware that the true world-position might not
|
||||
be able to fit in a `float` or might be represented with severely reduced precision.
|
||||
|
||||
!!! TIP: UV attributes
|
||||
By default the vertex shader of a material will flip the Y coordinate of the UV attributes
|
||||
@@ -2264,18 +2360,28 @@ type aliases:
|
||||
Name | Type | Description
|
||||
:-----------------------------------|:--------:|:------------------------------------
|
||||
**getResolution()** | float4 | Dimensions of the view's effective (physical) viewport in pixels: `width`, `height`, `1 / width`, `1 / height`. This might be different from `View::getViewport()` for instance because of added rendering guard-bands.
|
||||
**getWorldCameraPosition()** | float3 | Position of the camera/eye in world space
|
||||
**getWorldOffset()** | float3 | The shift required to obtain API-level world space
|
||||
**getWorldCameraPosition()** | float3 | Position of the camera/eye in world space (see note below)
|
||||
**getWorldOffset()** | float3 | [deprecated] The shift required to obtain API-level world space. Use getUserWorldPosition() instead
|
||||
**getUserWorldFromWorldMatrix()** | float4x4 | Matrix that converts from world space to API-level (user) world space.
|
||||
**getTime()** | float | Current time as a remainder of 1 second. Yields a value between 0 and 1
|
||||
**getUserTime()** | float4 | Current time in seconds: `time`, `(double)time - time`, `0`, `0`
|
||||
**getUserTimeMode(float m)** | float | Current time modulo m in seconds
|
||||
**getUserTimeMod(float m)** | float | Current time modulo m in seconds
|
||||
**getExposure()** | float | Photometric exposure of the camera
|
||||
**getEV100()** | float | [Exposure value at ISO 100](https://en.wikipedia.org/wiki/Exposure_value) of the camera
|
||||
|
||||
!!! TIP: world space
|
||||
To achieve good precision, the "world space" in Filament's shading system does not necessarily
|
||||
match the API-level world space. To obtain the position of the API-level camera, custom
|
||||
materials can add `getWorldOffset()` to `getWorldCameraPosition()`.
|
||||
materials can use `getUserWorldFromWorldMatrix()` to transform `getWorldCameraPosition()`.
|
||||
|
||||
### Material globals
|
||||
|
||||
Name | Type | Description
|
||||
:-----------------------------------|:--------:|:------------------------------------
|
||||
**getMaterialGlobal0()** | float4 | A vec4 visible by all materials, its value is set by `View::setMaterialGlobal(0, float4)`. Its default value is {0,0,0,1}.
|
||||
**getMaterialGlobal1()** | float4 | A vec4 visible by all materials, its value is set by `View::setMaterialGlobal(1, float4)`. Its default value is {0,0,0,1}.
|
||||
**getMaterialGlobal2()** | float4 | A vec4 visible by all materials, its value is set by `View::setMaterialGlobal(2, float4)`. Its default value is {0,0,0,1}.
|
||||
**getMaterialGlobal3()** | float4 | A vec4 visible by all materials, its value is set by `View::setMaterialGlobal(3, float4)`. Its default value is {0,0,0,1}.
|
||||
|
||||
### Vertex only
|
||||
|
||||
@@ -2297,6 +2403,7 @@ The following APIs are only available from the fragment block:
|
||||
:---------------------------------------|:--------:|:------------------------------------
|
||||
**getWorldTangentFrame()** | float3x3 | Matrix containing in each column the `tangent` (`frame[0]`), `bi-tangent` (`frame[1]`) and `normal` (`frame[2]`) of the vertex in world space. If the material does not compute a tangent space normal for bump mapping or if the shading is not anisotropic, only the `normal` is valid in this matrix.
|
||||
**getWorldPosition()** | float3 | Position of the fragment in world space (see note below about world-space)
|
||||
**getUserWorldPosition()** | float3 | Position of the fragment in API-level (user) world-space (see note below about world-space)
|
||||
**getWorldViewVector()** | float3 | Normalized vector in world space from the fragment position to the eye
|
||||
**getWorldNormalVector()** | float3 | Normalized normal in world space, after bump mapping (must be used after `prepareMaterial()`)
|
||||
**getWorldGeometricNormalVector()** | float3 | Normalized normal in world space, before bump mapping (can be used before `prepareMaterial()`)
|
||||
@@ -2313,9 +2420,10 @@ The following APIs are only available from the fragment block:
|
||||
**ycbcrToRgb(float, float2)** | float3 | Converts a luminance and CbCr pair to a sRGB color
|
||||
**uvToRenderTargetUV(float2)** | float2 | Transforms a UV coordinate to allow sampling from a `RenderTarget` attachment
|
||||
|
||||
!!! TIP: world space
|
||||
To obtain API-level world space coordinates, custom materials should add `getWorldOffset()` to
|
||||
`getWorldPosition()` (et al).
|
||||
!!! TIP: world-space
|
||||
To obtain API-level world-space coordinates, custom materials should use `getUserWorldPosition()`
|
||||
or use `getUserWorldFromWorldMatrix()`. Note that API-level world-space coordinates should
|
||||
never or rarely be used because they may not fit in a float3 or have severely reduced precision.
|
||||
|
||||
!!! TIP: sampling from render targets
|
||||
When sampling from a `filament::Texture` that is attached to a `filament::RenderTarget` for
|
||||
@@ -2487,4 +2595,26 @@ pre-multiplied ahead of time. On Android, any texture uploaded from a
|
||||
[Bitmap](https://developer.android.com/reference/android/graphics/Bitmap.html) will be
|
||||
pre-multiplied by default.
|
||||
|
||||
# Sampler usage in Materials
|
||||
|
||||
The number of usable sampler parameters (e.g.: type is `sampler2d`) in materials is limited and
|
||||
depends on the material properties, shading model, feature level and variant filter.
|
||||
|
||||
## Feature level 1 and 2
|
||||
|
||||
`unlit` materials can use up to 12 samplers by default.
|
||||
|
||||
`lit` materials can use up to 9 samplers by default, however if `refractionMode` or `reflectionMode`
|
||||
is set to `screenspace` that number is reduced to 8.
|
||||
|
||||
Finally if `variantFilter` contains the `fog` filter, an extra sampler is made available, such that
|
||||
`unlit` materials can use up to 13 and `lit` materials up to 10 samplers by default.
|
||||
|
||||
## Feature level 3
|
||||
|
||||
16 samplers are available.
|
||||
|
||||
!!! TIP: external samplers
|
||||
Be aware that `external` samplers account for 2 regular samplers.
|
||||
|
||||
<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="../third_party/markdeep/markdeep.min.js"></script><script src="https://casual-effects.com/markdeep/latest/markdeep.min.js"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user