Compare commits
393 Commits
bjd/comman
...
v1.25.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8de5fdd551 | ||
|
|
ecca3abe98 | ||
|
|
8570e35224 | ||
|
|
84df9f9a03 | ||
|
|
5f93fb9613 | ||
|
|
75f77fdbdd | ||
|
|
7825d582c2 | ||
|
|
5deb0ba933 | ||
|
|
18e917aaf2 | ||
|
|
a165f3890a | ||
|
|
f88b6d9c97 | ||
|
|
db8ecd9952 | ||
|
|
b5ec06c2d2 | ||
|
|
dfbac8385e | ||
|
|
eaab737b2c | ||
|
|
45991cda0a | ||
|
|
09a016bb6f | ||
|
|
31607d355d | ||
|
|
a67d50b9e2 | ||
|
|
8d42f53c80 | ||
|
|
5e21a55bce | ||
|
|
85930ea2e8 | ||
|
|
4b3cde8b39 | ||
|
|
eedfa85355 | ||
|
|
bb54c6c807 | ||
|
|
c23f905858 | ||
|
|
8c7be0a1d0 | ||
|
|
878497b3d5 | ||
|
|
a155561769 | ||
|
|
8b86a0ed2e | ||
|
|
26f9a9b122 | ||
|
|
6e5f6978fb | ||
|
|
0d31d7b2de | ||
|
|
dd862b7e0a | ||
|
|
52065f2cbd | ||
|
|
77c02d5831 | ||
|
|
f7e4c8d16d | ||
|
|
b7410474ff | ||
|
|
384cc4ebf6 | ||
|
|
7c0643f122 | ||
|
|
58abae3067 | ||
|
|
4742693869 | ||
|
|
6c39e474ea | ||
|
|
5c8977c906 | ||
|
|
6b3cc2e2f3 | ||
|
|
76b2edd6ea | ||
|
|
8ebb37d011 | ||
|
|
3366db83ef | ||
|
|
5415254aac | ||
|
|
caacc61602 | ||
|
|
e902df19b2 | ||
|
|
40b372dda7 | ||
|
|
fd330a98aa | ||
|
|
90c23a7d5d | ||
|
|
5710304114 | ||
|
|
0f684820bc | ||
|
|
e1d2d6ade6 | ||
|
|
e0b6f2ca71 | ||
|
|
2a35ee279b | ||
|
|
5abf780360 | ||
|
|
181f158ea9 | ||
|
|
f4087fc81d | ||
|
|
82793f9b82 | ||
|
|
537576e84a | ||
|
|
375d1f55e3 | ||
|
|
597218963f | ||
|
|
0d29b3ddc8 | ||
|
|
e0e3b42623 | ||
|
|
0995ca6614 | ||
|
|
3d741fc8d4 | ||
|
|
c20772b458 | ||
|
|
4a6b659098 | ||
|
|
2b93f08ca5 | ||
|
|
fca62b8fff | ||
|
|
dee6d9de2c | ||
|
|
574e3e7521 | ||
|
|
29fdf82ac5 | ||
|
|
c8cf2a54e8 | ||
|
|
bfd32e67d4 | ||
|
|
95915367fa | ||
|
|
b769cfda62 | ||
|
|
40ac88dfed | ||
|
|
6d96082f07 | ||
|
|
21f913db1c | ||
|
|
699a578966 | ||
|
|
babbfa1394 | ||
|
|
73f0d58e10 | ||
|
|
9cb4b74bbd | ||
|
|
f2c8456971 | ||
|
|
e571600c30 | ||
|
|
e84c94d3eb | ||
|
|
e791d4818f | ||
|
|
cdadb43e50 | ||
|
|
edaff60fbf | ||
|
|
3f64e46557 | ||
|
|
32dab23bc6 | ||
|
|
362de7dd31 | ||
|
|
6b01fbb903 | ||
|
|
4934d9f7bc | ||
|
|
ed73955b00 | ||
|
|
3f1f2726c4 | ||
|
|
1a7bd7ea8d | ||
|
|
946ea43436 | ||
|
|
7f42385f5f | ||
|
|
8845ac2b75 | ||
|
|
da85001d4d | ||
|
|
8d15079937 | ||
|
|
adc542b5cd | ||
|
|
72feb044a3 | ||
|
|
c0ba260ddf | ||
|
|
2da215e8e7 | ||
|
|
4d0368b5f1 | ||
|
|
d11c78857d | ||
|
|
e829d90c4a | ||
|
|
a8006acd33 | ||
|
|
86ec502040 | ||
|
|
b19a73cc50 | ||
|
|
a99c695932 | ||
|
|
8cd720b53a | ||
|
|
04df79e58f | ||
|
|
a4b3717762 | ||
|
|
1035e442ee | ||
|
|
60d3638f15 | ||
|
|
3e7d3c9035 | ||
|
|
eb360be2ad | ||
|
|
485ac8704d | ||
|
|
dc74540423 | ||
|
|
96219c22db | ||
|
|
f3b7048775 | ||
|
|
aaed6fb376 | ||
|
|
35a5d3310f | ||
|
|
9da79a1d2d | ||
|
|
595b355d1b | ||
|
|
3a67d769f4 | ||
|
|
6fb536a937 | ||
|
|
bb460d78d8 | ||
|
|
838835a715 | ||
|
|
63acd53e23 | ||
|
|
fcd2d0457b | ||
|
|
58fc26461b | ||
|
|
fd82f6b04e | ||
|
|
cef3200533 | ||
|
|
634500c398 | ||
|
|
b3e294ac54 | ||
|
|
2bf7535ad0 | ||
|
|
3315f75de9 | ||
|
|
bbe7dbfa92 | ||
|
|
5697922a65 | ||
|
|
4da83df2b9 | ||
|
|
8f156d6588 | ||
|
|
cec0871c11 | ||
|
|
41a809368b | ||
|
|
ea53eb9290 | ||
|
|
05875057c9 | ||
|
|
44125926d1 | ||
|
|
60734349de | ||
|
|
fbfd5ec0ec | ||
|
|
a74a95cc65 | ||
|
|
bc0ea16ff0 | ||
|
|
b2dc8aa84c | ||
|
|
9987e8b6ab | ||
|
|
0d9bdcc008 | ||
|
|
b5c634045e | ||
|
|
1f05531d53 | ||
|
|
88f382f0e3 | ||
|
|
3e59925900 | ||
|
|
ea404f8d4f | ||
|
|
602a550d93 | ||
|
|
12abbe2d23 | ||
|
|
fb0ee97588 | ||
|
|
56ef48c9c3 | ||
|
|
47c3dd3dd1 | ||
|
|
c181648bfa | ||
|
|
0cf78b3abe | ||
|
|
22889a7ad9 | ||
|
|
a14451d0ac | ||
|
|
5dfdab10b7 | ||
|
|
d6f2e3b8e9 | ||
|
|
df30517743 | ||
|
|
8f80643c1a | ||
|
|
5aea9be2fb | ||
|
|
ad02e483d0 | ||
|
|
f463d53036 | ||
|
|
b8d4408524 | ||
|
|
fef70be848 | ||
|
|
bdb12d9b24 | ||
|
|
43ad283a83 | ||
|
|
2e4936afc4 | ||
|
|
891ffabd11 | ||
|
|
e2c19498b4 | ||
|
|
c32630b265 | ||
|
|
bf21e78d02 | ||
|
|
525d4e08a3 | ||
|
|
2e9bf6d694 | ||
|
|
e845f01d85 | ||
|
|
bef48be7b4 | ||
|
|
b54fdc9e6e | ||
|
|
cedbf2e30b | ||
|
|
592f8d1b0d | ||
|
|
29612a684e | ||
|
|
e6d5807399 | ||
|
|
fa2553251f | ||
|
|
7387718852 | ||
|
|
a503a6209a | ||
|
|
ce3e5f74e8 | ||
|
|
f37112358e | ||
|
|
f368b14621 | ||
|
|
6960b1148a | ||
|
|
3cc23aac25 | ||
|
|
11dc8740f2 | ||
|
|
4b797cff88 | ||
|
|
fe1c1736cd | ||
|
|
4058ef5f09 | ||
|
|
d25ca01624 | ||
|
|
d96f87dbbf | ||
|
|
8a2e31023f | ||
|
|
1ea8e171d9 | ||
|
|
e2be3dd0ac | ||
|
|
1c51164e7b | ||
|
|
f190f03530 | ||
|
|
055fc7cbc1 | ||
|
|
9073fc3dc3 | ||
|
|
2409dc9bc4 | ||
|
|
6586c8d70b | ||
|
|
ac0c94da69 | ||
|
|
d19d6a72b0 | ||
|
|
c81b5d98ef | ||
|
|
756866675f | ||
|
|
ebcd4925f7 | ||
|
|
13bed4fdf9 | ||
|
|
1dae5c6b6c | ||
|
|
8e6663e4b0 | ||
|
|
ba804444b8 | ||
|
|
58cfb85004 | ||
|
|
ab46481b45 | ||
|
|
4296782399 | ||
|
|
ef375a7103 | ||
|
|
fd258b7765 | ||
|
|
147de8d372 | ||
|
|
eb2a1928b6 | ||
|
|
35b033102f | ||
|
|
7bc65421a9 | ||
|
|
736514cf37 | ||
|
|
db0158dae8 | ||
|
|
e706695ed1 | ||
|
|
e8877ffe2d | ||
|
|
1fd5d9dae6 | ||
|
|
cd48089318 | ||
|
|
6379ab22c9 | ||
|
|
0bf02b75d5 | ||
|
|
c4259b5598 | ||
|
|
6b3c1179bc | ||
|
|
c1a0e61e8e | ||
|
|
fc06298ed4 | ||
|
|
4ca87b188c | ||
|
|
f1f60c3e0d | ||
|
|
76d21b56af | ||
|
|
0ab0e50a4f | ||
|
|
34f4c06a5c | ||
|
|
6de36f1e53 | ||
|
|
2a9a3b1ac2 | ||
|
|
84b73a3770 | ||
|
|
662a10e273 | ||
|
|
ecce02502e | ||
|
|
d17875aea1 | ||
|
|
b8897a68f9 | ||
|
|
84efd4871e | ||
|
|
85ea5a6b70 | ||
|
|
77891acb92 | ||
|
|
74fe102035 | ||
|
|
25cc554925 | ||
|
|
d787a521b5 | ||
|
|
46e52c71e1 | ||
|
|
1dad27a172 | ||
|
|
60d230b380 | ||
|
|
d7cb38e706 | ||
|
|
ce00cca6ee | ||
|
|
d627d57bad | ||
|
|
8ffc776f1c | ||
|
|
be032b52c1 | ||
|
|
4388e81e5f | ||
|
|
71a185d139 | ||
|
|
d2cf5985ac | ||
|
|
debcbb8e5c | ||
|
|
b9dd62c7d3 | ||
|
|
dc2b430f34 | ||
|
|
e5ef4e8868 | ||
|
|
c0d6cd3ac3 | ||
|
|
b63ab2dc19 | ||
|
|
5d8dad561c | ||
|
|
8933be1ae2 | ||
|
|
6b66b48b1d | ||
|
|
9c23eb6e33 | ||
|
|
baea54a3fc | ||
|
|
d9f800454c | ||
|
|
f9ee0de07a | ||
|
|
2786d0a9f7 | ||
|
|
491e8032e6 | ||
|
|
ef3f13f5d3 | ||
|
|
bcb5b2d790 | ||
|
|
02de3f2e2a | ||
|
|
0e7bb53c07 | ||
|
|
759109d478 | ||
|
|
54d5af6edf | ||
|
|
38fbe47ced | ||
|
|
f066c925ba | ||
|
|
994fdf4e1d | ||
|
|
50b50d65e3 | ||
|
|
0aaa985649 | ||
|
|
29564f8eae | ||
|
|
c15db68a5b | ||
|
|
3452fb3e56 | ||
|
|
35eb8e7be1 | ||
|
|
834b774128 | ||
|
|
5aa0eb9f9d | ||
|
|
d9a6e2e649 | ||
|
|
cb823b16a1 | ||
|
|
0bd41e877e | ||
|
|
ecc3e73967 | ||
|
|
464b4c24f9 | ||
|
|
32367516e8 | ||
|
|
1709a55606 | ||
|
|
58b4455979 | ||
|
|
ea1dede19c | ||
|
|
20ea3381fa | ||
|
|
7aa6fccd7c | ||
|
|
adbd54f4f8 | ||
|
|
9d54261f18 | ||
|
|
a97757c9ae | ||
|
|
7c79d9f89d | ||
|
|
bf0914f813 | ||
|
|
b96bc30fbd | ||
|
|
62b50eb8ba | ||
|
|
b4932e384a | ||
|
|
5e68dc5f8d | ||
|
|
f222f1b925 | ||
|
|
22e4a54782 | ||
|
|
1289922c5f | ||
|
|
2839c352b8 | ||
|
|
6a01cbc312 | ||
|
|
6193156556 | ||
|
|
fe23aa917d | ||
|
|
eb8a29a332 | ||
|
|
0626902530 | ||
|
|
042bfe2597 | ||
|
|
97133f3591 | ||
|
|
d06cc4390e | ||
|
|
6047d3235f | ||
|
|
2cda6e35bd | ||
|
|
8f8d51e17b | ||
|
|
6919e3b274 | ||
|
|
10bf944410 | ||
|
|
9a2f6fdb53 | ||
|
|
761977d385 | ||
|
|
21248f15b5 | ||
|
|
4f32817f6d | ||
|
|
cc9e05e711 | ||
|
|
419d68d4db | ||
|
|
8450232448 | ||
|
|
cc51726590 | ||
|
|
318e22af51 | ||
|
|
68ac87dc24 | ||
|
|
acb8f00075 | ||
|
|
06d9183aaa | ||
|
|
75af25419d | ||
|
|
f6b90d2a31 | ||
|
|
a3822f4af0 | ||
|
|
bcdad769ff | ||
|
|
be4fb4fdbb | ||
|
|
65394f6301 | ||
|
|
b0beee03bc | ||
|
|
fe1de41b8e | ||
|
|
a37b431e87 | ||
|
|
98107016b9 | ||
|
|
8bccfc2863 | ||
|
|
f54a0a3452 | ||
|
|
6778ab0624 | ||
|
|
269d636785 | ||
|
|
39862c91ce | ||
|
|
523f4026b4 | ||
|
|
a6bf162431 | ||
|
|
826e8d181c | ||
|
|
16dfadbba0 | ||
|
|
5cbb97551f | ||
|
|
defee767c3 | ||
|
|
9560318521 | ||
|
|
ef09feb048 | ||
|
|
39f323fe09 | ||
|
|
11b95304ea | ||
|
|
b7c30a7916 | ||
|
|
4cae48fc77 | ||
|
|
d1a93f0557 | ||
|
|
b93059fad7 |
6
.github/ISSUE_TEMPLATE/bug_report.md
vendored
6
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@@ -4,8 +4,6 @@ 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.
|
||||
|
||||
@@ -20,8 +18,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 **full** logs from your console here. Please *do not*
|
||||
use screenshots of logs, copy them as text, use gist or attach an *uncompressed* file.
|
||||
If applicable, copy logs from your console here. Please *do not*
|
||||
use screenshots of logs, copy them as text.
|
||||
|
||||
**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,11 +13,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- 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@v3.3.0
|
||||
- uses: actions/checkout@v2.0.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-22.04
|
||||
runs-on: ubuntu-18.04
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/checkout@v2.0.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@v3.3.0
|
||||
- uses: actions/checkout@v2.0.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-22.04]
|
||||
os: [macos-latest, ubuntu-18.04]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/checkout@v2.0.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@v3.3.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
build\windows\build-github.bat presubmit
|
||||
@@ -43,11 +43,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/setup-java@v3
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '17'
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/android && printf "y" | ./build.sh presubmit
|
||||
@@ -57,7 +53,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/ios && printf "y" | ./build.sh presubmit
|
||||
@@ -70,7 +66,7 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/web && printf "y" | ./build.sh presubmit
|
||||
|
||||
124
.github/workflows/release.yml
vendored
124
.github/workflows/release.yml
vendored
@@ -31,7 +31,7 @@ jobs:
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
os: [macos-latest, ubuntu-22.04]
|
||||
os: [macos-latest, ubuntu-18.04]
|
||||
|
||||
steps:
|
||||
- name: Decide Git ref
|
||||
@@ -39,29 +39,24 @@ jobs:
|
||||
run: |
|
||||
REF=${RELEASE_TAG:-${GITHUB_REF}}
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v3.3.0
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
run: |
|
||||
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
|
||||
cd build/$WORKFLOW_OS && printf "y" | ./build.sh release
|
||||
cd ../..
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
xargs -L 1 sudo pip3 install < build/common/requirements.txt
|
||||
if [ -f out/filament-release-darwin.tgz ]; then mv out/filament-release-darwin.tgz out/filament-${TAG}-mac.tgz; fi;
|
||||
if [ -f out/filament-release-linux.tgz ]; then mv out/filament-release-linux.tgz out/filament-${TAG}-linux.tgz; fi;
|
||||
- uses: actions/github-script@v6
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
with:
|
||||
script: |
|
||||
const upload = require('./build/common/upload-release-assets');
|
||||
const { TAG } = process.env;
|
||||
const globber = await glob.create('out/*.tgz');
|
||||
await upload({ github, context }, await globber.glob(), TAG);
|
||||
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
|
||||
|
||||
build-web:
|
||||
name: build-web
|
||||
@@ -74,27 +69,22 @@ jobs:
|
||||
run: |
|
||||
REF=${RELEASE_TAG:-${GITHUB_REF}}
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v3.3.0
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
run: |
|
||||
cd build/web && printf "y" | ./build.sh release
|
||||
cd ../..
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
xargs -L 1 sudo pip3 install < build/common/requirements.txt
|
||||
mv out/filament-release-web.tgz out/filament-${TAG}-web.tgz
|
||||
- uses: actions/github-script@v6
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
with:
|
||||
script: |
|
||||
const upload = require('./build/common/upload-release-assets');
|
||||
const { TAG } = process.env;
|
||||
const globber = await glob.create('out/*.tgz');
|
||||
await upload({ github, context }, await globber.glob(), TAG);
|
||||
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
|
||||
|
||||
build-android:
|
||||
name: build-android
|
||||
@@ -107,26 +97,14 @@ jobs:
|
||||
run: |
|
||||
REF=${RELEASE_TAG:-${GITHUB_REF}}
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v3.3.0
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v2.0.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 }}
|
||||
run: |
|
||||
cd build/android && printf "y" | ./build.sh release
|
||||
cd ../..
|
||||
mv out/filament-android-release.aar out/filament-${TAG}-android.aar
|
||||
mv out/filamat-android-release.aar out/filamat-${TAG}-android.aar
|
||||
mv out/filamat-android-lite-release.aar out/filamat-${TAG}-lite-android.aar
|
||||
mv out/gltfio-android-release.aar out/gltfio-${TAG}-android.aar
|
||||
mv out/filament-utils-android-release.aar out/filament-utils-${TAG}-android.aar
|
||||
- name: Sign sample-gltf-viewer
|
||||
run: |
|
||||
echo "${APK_KEYSTORE_BASE64}" > filament.jks.base64
|
||||
@@ -141,15 +119,18 @@ jobs:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
APK_KEYSTORE_BASE64: ${{ secrets.APK_KEYSTORE_BASE64 }}
|
||||
APK_KEYSTORE_PASS: ${{ secrets.APK_KEYSTORE_PASS }}
|
||||
- uses: actions/github-script@v6
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
xargs -L 1 sudo pip3 install < build/common/requirements.txt
|
||||
mv out/filament-android-release.aar out/filament-${TAG}-android.aar
|
||||
mv out/filamat-android-release.aar out/filamat-${TAG}-android.aar
|
||||
mv out/filamat-android-lite-release.aar out/filamat-${TAG}-lite-android.aar
|
||||
mv out/gltfio-android-release.aar out/gltfio-${TAG}-android.aar
|
||||
mv out/filament-utils-android-release.aar out/filament-utils-${TAG}-android.aar
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.aar out/*.apk
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
with:
|
||||
script: |
|
||||
const upload = require('./build/common/upload-release-assets');
|
||||
const { TAG } = process.env;
|
||||
const globber = await glob.create(['out/*.aar', 'out/*.apk'].join('\n'));
|
||||
await upload({ github, context }, await globber.glob(), TAG);
|
||||
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
|
||||
|
||||
build-ios:
|
||||
name: build-ios
|
||||
@@ -162,27 +143,22 @@ jobs:
|
||||
run: |
|
||||
REF=${RELEASE_TAG:-${GITHUB_REF}}
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
- uses: actions/checkout@v3.3.0
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
run: |
|
||||
cd build/ios && printf "y" | ./build.sh release
|
||||
cd ../..
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
xargs -L 1 sudo pip3 install < build/common/requirements.txt
|
||||
mv out/filament-release-ios.tgz out/filament-${TAG}-ios.tgz
|
||||
- uses: actions/github-script@v6
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
with:
|
||||
script: |
|
||||
const upload = require('./build/common/upload-release-assets');
|
||||
const { TAG } = process.env;
|
||||
const globber = await glob.create('out/*.tgz');
|
||||
await upload({ github, context }, await globber.glob(), TAG);
|
||||
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
|
||||
|
||||
build-windows:
|
||||
name: build-windows
|
||||
@@ -195,26 +171,22 @@ jobs:
|
||||
run: |
|
||||
REF=${RELEASE_TAG:-${GITHUB_REF}}
|
||||
TAG=${REF##*/}
|
||||
echo "ref=${REF}" >> $GITHUB_OUTPUT
|
||||
echo "tag=${TAG}" >> $GITHUB_OUTPUT
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
shell: bash
|
||||
- uses: actions/checkout@v3.3.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
run: |
|
||||
build\windows\build-github.bat release
|
||||
cd ..\..
|
||||
move out\filament-windows.tgz out\filament-%TAG%-windows.tgz
|
||||
shell: cmd
|
||||
- uses: actions/github-script@v6
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
pip3 install PyGithub
|
||||
mv out/filament-windows.tgz out/filament-${TAG}-windows.tgz
|
||||
python build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
shell: bash
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
with:
|
||||
script: |
|
||||
const upload = require('./build/common/upload-release-assets');
|
||||
const { TAG } = process.env;
|
||||
const globber = await glob.create('out/*.tgz');
|
||||
await upload({ github, context }, await globber.glob(), TAG);
|
||||
GITHUB_API_KEY: ${{ secrets.GITHUB_API_KEY }}
|
||||
|
||||
1
.github/workflows/verify-release-notes.yml
vendored
1
.github/workflows/verify-release-notes.yml
vendored
@@ -24,4 +24,3 @@ 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@v3.3.0
|
||||
- uses: actions/checkout@v2.0.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@v3.3.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
build\windows\build-github.bat continuous
|
||||
|
||||
35
BUILDING.md
35
BUILDING.md
@@ -5,7 +5,7 @@
|
||||
To build Filament, you must first install the following tools:
|
||||
|
||||
- CMake 3.19 (or more recent)
|
||||
- clang 14.0 (or more recent)
|
||||
- clang 7.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,10 +13,9 @@ section below.
|
||||
|
||||
To build Filament for Android you must also install the following:
|
||||
|
||||
- Android Studio Flamingo or more recent
|
||||
- Android Studio Arctic Fox or more recent
|
||||
- Android SDK
|
||||
- Android NDK 25.1 or higher
|
||||
- Java 17
|
||||
- Android NDK "side-by-side" 23.1 or higher
|
||||
|
||||
### Environment variables
|
||||
|
||||
@@ -78,7 +77,7 @@ To turn an option on or off:
|
||||
|
||||
```
|
||||
$ cd <cmake-build-directory>
|
||||
$ cmake . -DOPTION=ON # Replace OPTION with the option name, set to ON / OFF
|
||||
$ cmake . -DOPTION=ON # Relace OPTION with the option name, set to ON / OFF
|
||||
```
|
||||
|
||||
Options can also be set with the CMake GUI.
|
||||
@@ -87,14 +86,12 @@ Options can also be set with the CMake GUI.
|
||||
|
||||
Make sure you've installed the following dependencies:
|
||||
|
||||
- `clang-14` or higher
|
||||
- `clang-7` or higher
|
||||
- `libglu1-mesa-dev`
|
||||
- `libc++-14-dev` (`libcxx-devel` and `libcxx-static` on Fedora) or higher
|
||||
- `libc++abi-14-dev` (`libcxxabi-static` on Fedora) or higher
|
||||
- `libc++-7-dev` (`libcxx-devel` and `libcxx-static` on Fedora) or higher
|
||||
- `libc++abi-7-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.
|
||||
@@ -114,7 +111,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-14
|
||||
# Or use a specific version of clang, for instance /usr/bin/clang-7
|
||||
$ CC=/usr/bin/clang CXX=/usr/bin/clang++ CXXFLAGS=-stdlib=libc++ \
|
||||
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../release/filament ../..
|
||||
```
|
||||
@@ -124,8 +121,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-14 100
|
||||
$ update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-14 100
|
||||
$ 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/cc cc /usr/bin/clang 100
|
||||
$ update-alternatives --install /usr/bin/c++ c++ /usr/bin/clang++ 100
|
||||
```
|
||||
@@ -181,7 +178,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 be installed by opening Visual Studio and selecting _Get Tools and
|
||||
The latest Windows SDK can also by 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
|
||||
@@ -355,7 +352,7 @@ same version that our continuous builds use.
|
||||
|
||||
```
|
||||
cd <your chosen parent folder for the emscripten SDK>
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.15.zip > emsdk.zip
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/refs/tags/3.1.9.zip > emsdk.zip
|
||||
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
|
||||
python ./emsdk.py install latest
|
||||
python ./emsdk.py activate latest
|
||||
@@ -371,11 +368,13 @@ export EMSDK=<your chosen home for the emscripten SDK>
|
||||
|
||||
The EMSDK variable is required so that the build script can find the Emscripten SDK. The build
|
||||
creates a `samples` folder that can be used as the root of a simple static web server. Note that you
|
||||
cannot open the HTML directly from the filesystem due to CORS. We recommend using the emrun tool
|
||||
to create a quick localhost server:
|
||||
cannot open the HTML directly from the filesystem due to CORS. One way to deal with this is to
|
||||
use Python to create a quick localhost server:
|
||||
|
||||
```
|
||||
emrun out/cmake-webgl-release/web/samples --no_browser --port 8000
|
||||
cd out/cmake-webgl-release/web/samples
|
||||
python3 -m http.server # Python 3
|
||||
python -m SimpleHTTPServer # Python 2.7
|
||||
```
|
||||
|
||||
You can then open http://localhost:8000/suzanne.html in your web browser.
|
||||
|
||||
120
CMakeLists.txt
120
CMakeLists.txt
@@ -31,22 +31,20 @@ 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."
|
||||
)
|
||||
|
||||
set(FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB "3" CACHE STRING
|
||||
"Per render pass arena size. Must be roughly 1 MB larger than FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB, default 3."
|
||||
set(FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB "2" CACHE STRING
|
||||
"Per render pass arena size. Must be roughly 1 MB larger than FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB, default 2."
|
||||
)
|
||||
|
||||
set(FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB "2" CACHE STRING
|
||||
"Size of the high-level draw commands buffer. Rule of thumb, 1 MB less than FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB, default 2."
|
||||
set(FILAMENT_PER_FRAME_COMMANDS_SIZE_IN_MB "1" CACHE STRING
|
||||
"Size of the high-level draw commands buffer. Rule of thumb, 1 MB less than FILAMENT_PER_RENDER_PASS_ARENA_SIZE_IN_MB, default 1."
|
||||
)
|
||||
|
||||
set(FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB "2" CACHE STRING
|
||||
"Size of the command-stream buffer. As a rule of thumb use the same value as FILAMENT_PER_FRRAME_COMMANDS_SIZE_IN_MB, default 2."
|
||||
set(FILAMENT_MIN_COMMAND_BUFFERS_SIZE_IN_MB "1" CACHE STRING
|
||||
"Size of the command-stream buffer. As a rule of thumb use the same value as FILAMENT_PER_FRRAME_COMMANDS_SIZE_IN_MB, default 1."
|
||||
)
|
||||
|
||||
set(FILAMENT_OPENGL_HANDLE_ARENA_SIZE_IN_MB "4" CACHE STRING
|
||||
@@ -69,30 +67,25 @@ endif()
|
||||
# ==================================================================================================
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if (CCACHE_PROGRAM)
|
||||
if (WIN32)
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${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_BINARY_DIR}/launch-c"
|
||||
"${CMAKE_BINARY_DIR}/launch-cxx"
|
||||
)
|
||||
|
||||
if (CMAKE_GENERATOR STREQUAL "Xcode")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CC "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_CXX "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LD "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_XCODE_ATTRIBUTE_LDPLUSPLUS "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
else()
|
||||
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()
|
||||
set(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -106,10 +99,6 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
# ==================================================================================================
|
||||
if (UNIX AND NOT APPLE AND NOT ANDROID AND NOT WEBGL)
|
||||
set(LINUX TRUE)
|
||||
else()
|
||||
# since cmake 3.25 LINUX is automatically set based on CMAKE_SYSTEM_NAME, which the android
|
||||
# cmake files are setting to "Linux".
|
||||
set(LINUX FALSE)
|
||||
endif()
|
||||
|
||||
if (LINUX)
|
||||
@@ -124,16 +113,11 @@ 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_SUPPORTS_XLIB)
|
||||
if (FILAMENT_SUPPORTS_XCB OR FILAMENT_SUPORTS_XLIB)
|
||||
add_definitions(-DFILAMENT_SUPPORTS_X11)
|
||||
set(FILAMENT_SUPPORTS_X11 TRUE)
|
||||
endif()
|
||||
@@ -353,29 +337,19 @@ endif()
|
||||
# ==================================================================================================
|
||||
# Release compiler flags
|
||||
# ==================================================================================================
|
||||
if (NOT MSVC AND NOT IOS)
|
||||
# Omitting stack frame pointers prevents the generation of readable stack traces in crash reports on iOS
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer")
|
||||
|
||||
# These aren't compatible with -fembed-bitcode (and seem to have no effect on Apple platforms anyway)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections")
|
||||
if (NOT IOS)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffunction-sections -fdata-sections")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# On Android RELEASE builds, we disable exceptions and RTTI to save some space (about 75 KiB
|
||||
# saved by -fno-exception and 10 KiB saved by -fno-rtti).
|
||||
if (ANDROID OR IOS OR WEBGL)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-rtti")
|
||||
|
||||
if (ANDROID OR WEBGL)
|
||||
# Omitting unwind info prevents the generation of readable stack traces in crash reports on iOS
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-unwind-tables -fno-asynchronous-unwind-tables")
|
||||
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")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
endif()
|
||||
|
||||
# With WebGL, we disable RTTI even for debug builds because we pass emscripten::val back and forth
|
||||
@@ -385,17 +359,13 @@ if (WEBGL)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-rtti")
|
||||
endif()
|
||||
|
||||
if (WEBGL_PTHREADS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Debug compiler flags
|
||||
# ==================================================================================================
|
||||
if (FILAMENT_ENABLE_ASAN_UBSAN)
|
||||
set(EXTRA_SANITIZE_OPTIONS "-fsanitize=address -fsanitize=undefined")
|
||||
endif()
|
||||
|
||||
# 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 (NOT MSVC AND NOT WEBGL)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector")
|
||||
endif()
|
||||
@@ -431,8 +401,8 @@ endif()
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GC_SECTIONS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${GC_SECTIONS} ${B_SYMBOLIC_FUNCTIONS}")
|
||||
|
||||
if (WEBGL_PTHREADS)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -pthread")
|
||||
if (WEBGL)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -s USE_WEBGL2=1")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -515,14 +485,9 @@ if (FILAMENT_SUPPORTS_METAL)
|
||||
set(MATC_API_FLAGS ${MATC_API_FLAGS} -a metal)
|
||||
endif()
|
||||
|
||||
# Enable debug info (preserves names in SPIR-V)
|
||||
if (FILAMENT_ENABLE_MATDBG)
|
||||
set(MATC_OPT_FLAGS ${MATC_OPT_FLAGS} -d)
|
||||
endif()
|
||||
|
||||
# Disable optimizations
|
||||
# Disable optimizations and enable debug info (preserves names in SPIR-V)
|
||||
if (FILAMENT_DISABLE_MATOPT)
|
||||
set(MATC_OPT_FLAGS ${MATC_OPT_FLAGS} -g)
|
||||
set(MATC_OPT_FLAGS -gd)
|
||||
endif()
|
||||
|
||||
set(MATC_BASE_FLAGS ${MATC_API_FLAGS} -p ${MATC_TARGET} ${MATC_OPT_FLAGS})
|
||||
@@ -577,7 +542,7 @@ function(list_licenses OUTPUT MODULES)
|
||||
endif()
|
||||
endforeach()
|
||||
configure_file(${FILAMENT}/build/licenses.inc.in ${OUTPUT})
|
||||
endfunction()
|
||||
endfunction(list_licenses)
|
||||
|
||||
set(COMBINE_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/build/linux/combine-static-libs.sh")
|
||||
if (WIN32)
|
||||
@@ -697,8 +662,7 @@ add_subdirectory(${EXTERNAL}/imgui/tnt)
|
||||
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}/meshoptimizer)
|
||||
add_subdirectory(${EXTERNAL}/cgltf/tnt)
|
||||
add_subdirectory(${EXTERNAL}/draco/tnt)
|
||||
add_subdirectory(${EXTERNAL}/jsmn/tnt)
|
||||
@@ -735,9 +699,7 @@ if (IS_HOST_PLATFORM)
|
||||
if (FILAMENT_SUPPORTS_OPENGL)
|
||||
add_subdirectory(${LIBRARIES}/bluegl)
|
||||
endif()
|
||||
if (NOT FILAMENT_SKIP_SDL2)
|
||||
add_subdirectory(${LIBRARIES}/filamentapp)
|
||||
endif()
|
||||
add_subdirectory(${LIBRARIES}/filamentapp)
|
||||
add_subdirectory(${LIBRARIES}/imageio)
|
||||
|
||||
add_subdirectory(${FILAMENT}/samples)
|
||||
|
||||
@@ -164,7 +164,8 @@ private:
|
||||
|
||||
### Strings
|
||||
|
||||
- Never use `std::string` in the Filament core renderer. Prefer `utils::CString` or `std::string_view`.
|
||||
- Never use `std::string` in the Filament core renderer. Prefer `utils::CString` or
|
||||
`utils::StaticString`.
|
||||
- When using `std::string` in tools, always include the `std::` qualifier to disambiguate it
|
||||
from other string types.
|
||||
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -187,7 +187,7 @@
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright 2023 The Android Open Source Project
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
# 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`
|
||||
11
README.md
11
README.md
@@ -31,7 +31,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.filament:filament-android:1.42.0'
|
||||
implementation 'com.google.android.filament:filament-android:1.25.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.42.0'
|
||||
pod 'Filament', '~> 1.25.0'
|
||||
```
|
||||
|
||||
### Snapshots
|
||||
@@ -117,9 +117,9 @@ steps:
|
||||
- Image-based lighting
|
||||
- Physically-based camera (shutter speed, sensitivity and aperture)
|
||||
- Physical light units
|
||||
- Point lights, spot lights, and directional light
|
||||
- Point lights, spot lights and directional light
|
||||
- Specular anti-aliasing
|
||||
- Point, spot, and directional light shadows
|
||||
- Spot and directional light shadows
|
||||
- Cascaded shadows
|
||||
- EVSM, PCSS, DPCF, or PCF shadows
|
||||
- Transparent shadows
|
||||
@@ -179,7 +179,6 @@ steps:
|
||||
- [x] KHR_mesh_quantization
|
||||
- [x] KHR_texture_basisu
|
||||
- [x] KHR_texture_transform
|
||||
- [x] EXT_meshopt_compression
|
||||
|
||||
|
||||
## Rendering with Filament
|
||||
|
||||
@@ -9,15 +9,26 @@ Before starting, ensure that each of these branches is up-to-date with origin:
|
||||
- rc/$RELEASE
|
||||
- main
|
||||
|
||||
## 0. Check versions.
|
||||
## 0. Make sure the rc/$RELEASE branch has the correct version.
|
||||
|
||||
Make sure the rc/$RELEASE branch has the correct Filament version. It should have the version
|
||||
corresponding to its name, $RELEASE.
|
||||
It should have the version corresponding to its name, $RELEASE.
|
||||
|
||||
Make sure `MATERIAL_VERSION` has been bumped to a new version if this is a MAJOR or MINOR release
|
||||
(first two version numbers).
|
||||
## 1. Update RELEASE_NOTES.md on the rc branch.
|
||||
|
||||
## 1. Bump Filament versions on main to $RELEASE.
|
||||
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.
|
||||
|
||||
Checkout main and run the following command to bump Filament's version to $RELEASE:
|
||||
|
||||
@@ -33,19 +44,49 @@ Release Filament $RELEASE
|
||||
|
||||
Do not push to origin yet.
|
||||
|
||||
## 2. Update RELEASE_NOTES.md on main.
|
||||
## 3. Cherry-pick RELEASE_NOTES change from rc branch to main.
|
||||
|
||||
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.
|
||||
```
|
||||
git cherry-pick rc/$RELEASE
|
||||
```
|
||||
|
||||
Amend these changes to the "Release Filament $RELEASE" commit.
|
||||
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.
|
||||
|
||||
```
|
||||
git add -u
|
||||
git commit --amend --no-edit
|
||||
```
|
||||
|
||||
## 3. Run release script.
|
||||
## 4. Run release script.
|
||||
|
||||
```
|
||||
build/common/release.sh rc/$RELEASE rc/$NEXT_RELEASE
|
||||
@@ -54,18 +95,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.
|
||||
|
||||
## 4. Push the release branch.
|
||||
## 5. Push the release branch.
|
||||
|
||||
```
|
||||
git push origin release
|
||||
```
|
||||
|
||||
## 5. Create the GitHub release.
|
||||
## 6. 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.
|
||||
|
||||
## 6. Delete the old rc branch (optional).
|
||||
## 7. Delete the old rc branch (optional).
|
||||
|
||||
This step is optional. The old rc branch may be left alive for a few weeks for posterity.
|
||||
|
||||
@@ -73,7 +114,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
|
||||
```
|
||||
|
||||
## 7. Bump the version on the new rc branch to $NEXT_RELEASE.
|
||||
## 8. Bump the version on the new rc branch to $NEXT_RELEASE.
|
||||
|
||||
```
|
||||
git checkout rc/$NEXT_RELEASE
|
||||
@@ -86,19 +127,19 @@ Commit the changes to rc/$NEXT_RELEASE with the title:
|
||||
Bump version to $NEXT_RELEASE
|
||||
```
|
||||
|
||||
## 8. Push main.
|
||||
## 9. Push main.
|
||||
|
||||
```
|
||||
git push origin main
|
||||
```
|
||||
|
||||
## 9. Push the new rc branch.
|
||||
## 10. Push the new rc branch.
|
||||
|
||||
```
|
||||
git push origin -u rc/$NEXT_RELEASE
|
||||
```
|
||||
|
||||
## 10. Rebuild the GitHub release (if failed).
|
||||
## 11. Rebuild the GitHub release (if failed).
|
||||
|
||||
Sometimes the GitHub release job will fail. In this case, you can manually re-run the release job.
|
||||
|
||||
|
||||
284
RELEASE_NOTES.md
284
RELEASE_NOTES.md
@@ -3,289 +3,7 @@
|
||||
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.
|
||||
|
||||
**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
|
||||
|
||||
- gltfio: expose joint inverse bind matrices via method on FilamentInstance
|
||||
- filamesh: add error when uv coords size does not match num of vertices. (#6351)
|
||||
|
||||
## v1.31.0
|
||||
|
||||
- java: fix confusing typo in Camera documentation
|
||||
- engine: the output color space can be set on `ColorGrading`. This API currently has limitations,
|
||||
please refer to the documentation for more details
|
||||
- Support for RGTC and BPTC texture compression
|
||||
- engine: fix TransformManager high precision mode when using transactions
|
||||
- web: added TypeScript definition for `Engine.destroy`
|
||||
- materials: `getNormalizedViewportCoord()` now returns the logical (i.e. user) viewport
|
||||
normalized position and keeps z reversed [⚠️ **Recompile Materials**]
|
||||
- backend: workaround Adreno shader compiler bug (#6355) [⚠️ **Recompile Materials**]
|
||||
- geometry: change computing tangent basis from normal vector to use Frisvad's method
|
||||
|
||||
## v1.30.0
|
||||
|
||||
- engine: optimize per-shadow UBO [⚠️ **Recompile Materials**]
|
||||
- engine: fix potential memory corruption with larger scenes
|
||||
- engine: VSM's MSAA setting is now per-view instead of per-light [⚠️ **API Change**]
|
||||
|
||||
## v1.29.0
|
||||
|
||||
- gltfio: calculate primitive's AABB correctly.
|
||||
- gltfio: recompute bounding boxes with morph targets
|
||||
- engine: add missing getters on `MaterialInstance`
|
||||
- WebGL: add missing `ColorGrading` JS bindings
|
||||
- engine: improvements/cleanup of Shadow mapping code [⚠️ **Recompile Materials**]
|
||||
|
||||
## v1.28.3
|
||||
|
||||
|
||||
- backend: add support for GGP platform
|
||||
- engine: primitives with `CullingMode::FRONT_AND_BACK` are now skipped.
|
||||
|
||||
## v1.28.2
|
||||
|
||||
- gltfio: support EXT_meshopt_compression
|
||||
- release packaging: fixed location of default IBL file
|
||||
|
||||
## v1.28.1
|
||||
|
||||
- gltfio: fix reloading crash in ubershader mode
|
||||
- Vulkan: improve performance in the readPixels path
|
||||
- engine: raise the spot shadows limit to 64, from 14.
|
||||
- engine: add experimental support for point light shadows.
|
||||
- gltfio: fix ubershader issues with assignment of dummy textures
|
||||
- gltfio: material instances and variants are now accessed via `FilamentInstance` [⚠️ **API Change**]
|
||||
- gltfio: the animator can now only be accessed via `FilamentInstance` [⚠️ **API Change**]
|
||||
- engine: fix "stable" shadows and make the default cascade splits logarithmic.
|
||||
- engine: Add new quality options to EVSM shadows + rendering fixes
|
||||
|
||||
## v1.28.0
|
||||
|
||||
- engine: LiSPSM is now a user settable option
|
||||
- engine: get the morph target buffer to the given primitive
|
||||
- Java: Fix TransformManager.getChildren()
|
||||
- Metal: newer devices are no longer limited to 16 samplers per Material.
|
||||
- gltfio: fix interpretation of occlusion strength
|
||||
- engine: minsdk is now 21 instead of 19. This allows the use of OpenGL ES 3.1
|
||||
- Vulkan: fix black screen regression
|
||||
|
||||
## v1.27.2
|
||||
|
||||
- gltfio: punctual lights are now duplicated when adding new asset instances
|
||||
- gltfio: FilamentInstance getAsset method now returns an immutable asset
|
||||
- gltfio: allow zero-instance assets
|
||||
- gltfio: fix regression with meshes that have no material
|
||||
- gltfio: fix regression with recomputeBoundingBoxes()
|
||||
- filamesh / matinfo: fix minor ASAN issues
|
||||
- engine: Added `Engine::resetBackendState()`, available only in WebGL builds
|
||||
|
||||
## v1.27.1
|
||||
|
||||
- Java: add methods for TransformManager.getChildCount(), TransformManager.getChildren() and Scene.hasEntity()
|
||||
- engine: Fix stencil buffer writes with OpenGL backend.
|
||||
- gltfio: add new virtual method to MaterialProvider that all plugins must implement
|
||||
- gltfio: add an assert for inconsistent sRGB flags among usages of a particular texture
|
||||
- engine: improve scissor documentation
|
||||
- backend: scissor is no longer clipped to the viewport (done on filament side)
|
||||
- samples: add debug overdraw visualization to gltf_viewer
|
||||
|
||||
## v1.27.0
|
||||
|
||||
- WebGL: reduce max instance count to work around Chrome issues [⚠️ **Recompile Materials**]
|
||||
- engine: rework material/shader sampler binding code [⚠️ **Recompile Materials**]
|
||||
- gltfio: move the API for `recomputeBoundingBoxes` [⚠️ **API Change**]
|
||||
- engine: add support for specialization constants [⚠️ **Recompile Materials**]
|
||||
- gltfio: fix spotlight regression
|
||||
- gltfio: clear the MaterialInstance cache when creating new instances
|
||||
|
||||
## v1.26.0
|
||||
|
||||
- engine: new feature level APIs, see `Engine::getSupportedFeatureLevel()`
|
||||
- engine: add new stencil API to `View` and stencil state APIs to `MaterialInstance` [**NEW API**].
|
||||
- engine: Fix guard bands and TAA with `vertexDomain:Device` [⚠️ **Recompile Materials**]
|
||||
- engine: `clipSpaceTransform` is now only available with `vertexDomain:Device` [⚠️ **API Change**]
|
||||
- gltfio: add unified `AssetLoader::createAsset()` method [⚠️ **API Change**]
|
||||
- gltfio: all assets are now "instanced" [⚠️ **API Change**]
|
||||
|
||||
## v1.25.6
|
||||
|
||||
- engine: Add `CONFIG_MINSPEC_UBO_SIZE` as a nicer way to allow exceeding the ES3.0 minspec.
|
||||
- gltfio: minor efficiency improvement for Android and WebGL builds.
|
||||
- gltfio: add support for concurrent texture downloading and decoding.
|
||||
|
||||
## v1.25.5
|
||||
|
||||
- WebGL: upgraded the JS bindings to work with emsdk 3.1.15
|
||||
- WebGL: added missing IBL builder to TypeScript annotations
|
||||
- engine: Fix incorrect precision restoration when computing accurate world translations
|
||||
- engine: make `MaterialInstance` public API friendly to `std::string_view` parameters
|
||||
- gltfio: add 'detach' methods to allow ownership transfer of entities and components
|
||||
|
||||
## v1.25.4
|
||||
|
||||
- backend: streamline texture upload APIs [⚠️ **API Change**]
|
||||
|
||||
## v1.25.3
|
||||
|
||||
- engine: Fix Adreno gpu crash introduced by gpu morph target change
|
||||
- engine: Add optional memory configuration parameters to Engine initialization
|
||||
|
||||
## v1.25.2
|
||||
|
||||
- engine: `Camera::getNear()` and `Camera::getCullingFar()` now return `doubles`
|
||||
- Metal: implement scissor support.
|
||||
- engine: `Renderer::getUserTime()` now returns seconds as documented (#5722) [⚠️ **API Fix**]
|
||||
|
||||
## v1.25.1
|
||||
|
||||
- engine: add support for automatic instancing. Must be enabled with `Engine::setAutomaticInstancingEnabled(bool)`
|
||||
## main branch
|
||||
|
||||
## v1.25.0
|
||||
|
||||
|
||||
@@ -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 -Pcom.google.android.filament.skip-samples
|
||||
gradlew -Pcom.google.android.filament.dist-dir=..\out\android-release\filament assembleRelease -Pfilament_skip_samples
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -12,10 +12,7 @@
|
||||
// When set, support for Vulkan will be excluded.
|
||||
//
|
||||
// com.google.android.filament.matdbg
|
||||
// When set, enables matdbg
|
||||
//
|
||||
// com.google.android.filament.matnopt
|
||||
// When set, disable shader optimizations.
|
||||
// When set, enables matdbg, disables shader optimizations
|
||||
//
|
||||
// com.google.android.filament.skip-samples
|
||||
// Exclude samples from the project. Useful to speed up compilation.
|
||||
@@ -32,12 +29,15 @@
|
||||
|
||||
// Publishing to Maven Central:
|
||||
// - Build and upload artifacts with ./gradlew publish
|
||||
// - Close and release staging repo on Nexus with ./gradlew closeAndReleaseStagingRepository
|
||||
// - Close and release staging repo on Nexus with ./gradlew closeAndReleaseRepository
|
||||
//
|
||||
// The following is needed in ~/gradle/gradle.properties:
|
||||
//
|
||||
// sonatypeUsername=nexus_user
|
||||
// sonatypePassword=nexus_password
|
||||
// SONATYPE_NEXUS_USERNAME=nexus_user
|
||||
// SONATYPE_NEXUS_PASSWORD=nexus_password
|
||||
//
|
||||
// nexusUsername=nexus_user
|
||||
// nexusPassword=nexus_password
|
||||
//
|
||||
// signing.keyId=pgp_key_id
|
||||
// signing.password=pgp_key_password
|
||||
@@ -47,7 +47,7 @@
|
||||
buildscript {
|
||||
def path = providers
|
||||
.gradleProperty("com.google.android.filament.dist-dir")
|
||||
.get()
|
||||
.forUseAtConfigurationTime().get()
|
||||
|
||||
def directory = objects.fileProperty().fileValue(new File(path)).getAsFile().get()
|
||||
def filamentPath = directory.absolutePath
|
||||
@@ -59,19 +59,18 @@ buildscript {
|
||||
// Warning: changing this property does not work well with incremental builds.
|
||||
def excludeVulkan = providers
|
||||
.gradleProperty("com.google.android.filament.exclude-vulkan")
|
||||
.forUseAtConfigurationTime()
|
||||
.isPresent()
|
||||
|
||||
def matdbg = providers
|
||||
.gradleProperty("com.google.android.filament.matdbg")
|
||||
.isPresent()
|
||||
|
||||
def matnopt = providers
|
||||
.gradleProperty("com.google.android.filament.matnopt")
|
||||
.forUseAtConfigurationTime()
|
||||
.isPresent()
|
||||
|
||||
def abis = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
|
||||
def newAbis = providers
|
||||
.gradleProperty("com.google.android.filament.abis")
|
||||
.forUseAtConfigurationTime()
|
||||
.get()
|
||||
.split(',')
|
||||
if (!newAbis.contains("all")) {
|
||||
@@ -79,22 +78,19 @@ buildscript {
|
||||
}
|
||||
|
||||
ext.versions = [
|
||||
'jdk': 17,
|
||||
'minSdk': 19,
|
||||
'targetSdk': 33,
|
||||
'compileSdk': 33,
|
||||
'kotlin': '1.9.0',
|
||||
'kotlin_coroutines': '1.7.2',
|
||||
'buildTools': '34.0.0',
|
||||
'ndk': '25.1.8937393',
|
||||
'androidx_core': '1.10.1',
|
||||
'androidx_annotations': '1.6.0'
|
||||
'targetSdk': 31,
|
||||
'compileSdk': 31,
|
||||
'kotlin': '1.6.21',
|
||||
'kotlin_coroutines': '1.6.1',
|
||||
'buildTools': '32.0.0',
|
||||
'ndk': '24.0.8215888'
|
||||
]
|
||||
|
||||
ext.deps = [
|
||||
'androidx': [
|
||||
'annotations': "androidx.annotation:annotation:${versions.androidx_annotations}",
|
||||
'core': "androidx.core:core:${versions.androidx_core}",
|
||||
'annotations': "androidx.annotation:annotation:1.3.0",
|
||||
'core': "androidx.core:core:1.7.0",
|
||||
],
|
||||
'kotlin': "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}",
|
||||
'coroutines': [
|
||||
@@ -104,7 +100,8 @@ buildscript {
|
||||
]
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:8.1.0'
|
||||
// NOTE: See TODO in gradle.properties once we move to Gradle 7.4
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
|
||||
}
|
||||
|
||||
@@ -116,7 +113,7 @@ buildscript {
|
||||
"-DFILAMENT_DIST_DIR=${filamentPath}".toString(),
|
||||
"-DFILAMENT_SUPPORTS_VULKAN=${excludeVulkan ? 'OFF' : 'ON'}".toString(),
|
||||
"-DFILAMENT_ENABLE_MATDBG=${matdbg ? 'ON' : 'OFF'}".toString(),
|
||||
"-DFILAMENT_DISABLE_MATOPT=${matnopt ? 'ON' : 'OFF'}".toString()
|
||||
"-DFILAMENT_DISABLE_MATOPT=${matdbg ? 'ON' : 'OFF'}".toString()
|
||||
]
|
||||
|
||||
ext.cppFlags = [
|
||||
@@ -127,7 +124,6 @@ buildscript {
|
||||
"-fno-asynchronous-unwind-tables",
|
||||
"-fno-rtti",
|
||||
"-ffast-math",
|
||||
"-fno-finite-math-only",
|
||||
"-ffp-contract=fast",
|
||||
"-fvisibility-inlines-hidden",
|
||||
"-fvisibility=hidden",
|
||||
@@ -152,18 +148,14 @@ buildscript {
|
||||
}
|
||||
|
||||
plugins {
|
||||
id "io.github.gradle-nexus.publish-plugin" version "1.3.0"
|
||||
id 'io.codearte.nexus-staging' version '0.30.0'
|
||||
}
|
||||
|
||||
// See https://github.com/gradle-nexus/publish-plugin
|
||||
// Publish to https://oss.sonatype.org/ (not s01)
|
||||
nexusPublishing {
|
||||
// Nexus Staging configuration
|
||||
// See https://github.com/Codearte/gradle-nexus-staging-plugin/
|
||||
nexusStaging {
|
||||
packageGroup = 'com.google.android'
|
||||
repositories {
|
||||
sonatype {
|
||||
stagingProfileId = '9a75a224a4f17b'
|
||||
}
|
||||
}
|
||||
stagingProfileId = '9a75a224a4f17b'
|
||||
}
|
||||
|
||||
subprojects {
|
||||
@@ -195,7 +187,6 @@ subprojects {
|
||||
}
|
||||
|
||||
ndk {
|
||||
//noinspection ChromeOsAbiSupport
|
||||
abiFilters(*rootProject.ext.abis)
|
||||
}
|
||||
|
||||
@@ -216,8 +207,8 @@ subprojects {
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,14 +142,6 @@ 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,17 +17,6 @@ android {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
singleVariant("fullRelease") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
singleVariant("liteRelease") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -126,8 +126,8 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderUniform
|
||||
JNIEnv* env, jclass, jlong nativeBuilder, jint uniformType, jint precision, jstring name_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter(name, (MaterialBuilder::UniformType) uniformType,
|
||||
(MaterialBuilder::ParameterPrecision) precision);
|
||||
builder->parameter((MaterialBuilder::UniformType) uniformType,
|
||||
(MaterialBuilder::ParameterPrecision) precision, name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
@@ -137,8 +137,8 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderUniform
|
||||
jstring name_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter(name, (size_t) size, (MaterialBuilder::UniformType) uniformType,
|
||||
(MaterialBuilder::ParameterPrecision) precision);
|
||||
builder->parameter((MaterialBuilder::UniformType) uniformType, (size_t) size,
|
||||
(MaterialBuilder::ParameterPrecision) precision, name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
@@ -148,8 +148,9 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSampler
|
||||
jint precision, jstring name_) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter(name, (MaterialBuilder::SamplerType) samplerType,
|
||||
(MaterialBuilder::SamplerFormat) format, (MaterialBuilder::ParameterPrecision) precision);
|
||||
builder->parameter((MaterialBuilder::SamplerType) samplerType,
|
||||
(MaterialBuilder::SamplerFormat) format, (MaterialBuilder::ParameterPrecision) precision,
|
||||
name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
@@ -250,13 +251,6 @@ 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,12 +360,6 @@ 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);
|
||||
@@ -590,7 +584,6 @@ 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,12 +1,5 @@
|
||||
android {
|
||||
namespace 'com.google.android.filament'
|
||||
|
||||
publishing {
|
||||
singleVariant("release") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -84,13 +84,13 @@ Java_com_google_android_filament_Camera_nLookAt(JNIEnv*, jclass, jlong nativeCam
|
||||
camera->lookAt({eye_x, eye_y, eye_z}, {center_x, center_y, center_z}, {up_x, up_y, up_z});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetNear(JNIEnv*, jclass, jlong nativeCamera) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
return camera->getNear();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jdouble JNICALL
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetCullingFar(JNIEnv*, jclass,
|
||||
jlong nativeCamera) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
|
||||
@@ -278,112 +278,6 @@ 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) {
|
||||
@@ -422,36 +316,3 @@ Java_com_google_android_filament_Engine_nGetEntityManager(JNIEnv*, jclass, jlong
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) &engine->getEntityManager();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Engine_nSetAutomaticInstancingEnabled(JNIEnv*, jclass, jlong nativeEngine, jboolean enable) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
engine->setAutomaticInstancingEnabled(enable);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nIsAutomaticInstancingEnabled(JNIEnv*, jclass, jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jboolean)engine->isAutomaticInstancingEnabled();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Engine_nGetSupportedFeatureLevel(JNIEnv *, jclass,
|
||||
jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jint)engine->getSupportedFeatureLevel();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Engine_nSetActiveFeatureLevel(JNIEnv *, jclass,
|
||||
jlong nativeEngine, jint ordinal) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jint)engine->setActiveFeatureLevel((Engine::FeatureLevel)ordinal);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Engine_nGetActiveFeatureLevel(JNIEnv *, jclass,
|
||||
jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jint)engine->getActiveFeatureLevel();
|
||||
}
|
||||
@@ -76,10 +76,10 @@ extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderShadowOptions(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jint mapSize, jint cascades, jfloatArray splitPositions,
|
||||
jfloat constantBias, jfloat normalBias, jfloat shadowFar, jfloat shadowNearHint,
|
||||
jfloat shadowFarHint, jboolean stable, jboolean lispsm,
|
||||
jfloat shadowFarHint, jboolean stable,
|
||||
jfloat polygonOffsetConstant, jfloat polygonOffsetSlope,
|
||||
jboolean screenSpaceContactShadows, jint stepCount,
|
||||
jfloat maxShadowDistance, jboolean elvsm, jfloat blurWidth, jfloat shadowBulbRadius) {
|
||||
jfloat maxShadowDistance, jint vsmMsaaSamples, jfloat blurWidth, jfloat shadowBulbRadius) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
LightManager::ShadowOptions shadowOptions {
|
||||
.mapSize = (uint32_t)mapSize,
|
||||
@@ -90,14 +90,13 @@ Java_com_google_android_filament_LightManager_nBuilderShadowOptions(JNIEnv* env,
|
||||
.shadowNearHint = shadowNearHint,
|
||||
.shadowFarHint = shadowFarHint,
|
||||
.stable = (bool)stable,
|
||||
.lispsm = (bool)lispsm,
|
||||
.polygonOffsetConstant = polygonOffsetConstant,
|
||||
.polygonOffsetSlope = polygonOffsetConstant,
|
||||
.screenSpaceContactShadows = (bool)screenSpaceContactShadows,
|
||||
.stepCount = uint8_t(stepCount),
|
||||
.maxShadowDistance = maxShadowDistance,
|
||||
.vsm = {
|
||||
.elvsm = (bool)elvsm,
|
||||
.msaaSamples = (uint8_t) vsmMsaaSamples,
|
||||
.blurWidth = blurWidth
|
||||
},
|
||||
.shadowBulbRadius = shadowBulbRadius
|
||||
|
||||
@@ -153,14 +153,6 @@ 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,21 +246,17 @@ 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, jlong sampler_) {
|
||||
jlong nativeTexture, jint 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, JniUtils::from_long(sampler_));
|
||||
instance->setParameter(name, texture, sampler);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
@@ -345,14 +341,6 @@ Java_com_google_android_filament_MaterialInstance_nSetDepthWrite(JNIEnv*,
|
||||
instance->setDepthWrite(enable);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilWrite(JNIEnv*, jclass,
|
||||
jlong nativeMaterialInstance, jboolean enable) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilWrite(enable);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetDepthCulling(JNIEnv*,
|
||||
@@ -361,78 +349,6 @@ 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,
|
||||
jlong nativeMaterialInstance, jlong function, jlong face) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilCompareFunction(
|
||||
static_cast<MaterialInstance::StencilCompareFunc>(function),
|
||||
static_cast<MaterialInstance::StencilFace>(face));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilOpStencilFail(JNIEnv*, jclass,
|
||||
jlong nativeMaterialInstance, jlong op, jlong face) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilOpStencilFail(
|
||||
static_cast<MaterialInstance::StencilOperation>(op),
|
||||
static_cast<MaterialInstance::StencilFace>(face));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilOpDepthFail(JNIEnv*, jclass,
|
||||
jlong nativeMaterialInstance, jlong op, jlong face) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilOpDepthFail(
|
||||
static_cast<MaterialInstance::StencilOperation>(op),
|
||||
static_cast<MaterialInstance::StencilFace>(face));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilOpDepthStencilPass(JNIEnv*, jclass,
|
||||
jlong nativeMaterialInstance, jlong op, jlong face) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilOpDepthStencilPass(
|
||||
static_cast<MaterialInstance::StencilOperation>(op),
|
||||
static_cast<MaterialInstance::StencilFace>(face));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilReferenceValue(JNIEnv*, jclass,
|
||||
jlong nativeMaterialInstance, jint value, jlong face) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilReferenceValue(value, static_cast<MaterialInstance::StencilFace>(face));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilReadMask(JNIEnv*, jclass,
|
||||
jlong nativeMaterialInstance, jint readMask, jlong face) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilReadMask(readMask, static_cast<MaterialInstance::StencilFace>(face));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetStencilWriteMask(JNIEnv*, jclass,
|
||||
jlong nativeMaterialInstance, jint writeMask, jlong face) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setStencilWriteMask(writeMask, static_cast<MaterialInstance::StencilFace>(face));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetName(JNIEnv* env, jclass,
|
||||
@@ -464,83 +380,3 @@ Java_com_google_android_filament_MaterialInstance_nDuplicate(JNIEnv* env, jclass
|
||||
}
|
||||
return (jlong)mi;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetMaskThreshold(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->getMaskThreshold();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetSpecularAntiAliasingVariance(JNIEnv* env,
|
||||
jclass clazz, jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->getSpecularAntiAliasingVariance();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetSpecularAntiAliasingThreshold(JNIEnv* env,
|
||||
jclass clazz, jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->getSpecularAntiAliasingThreshold();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsDoubleSided(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isDoubleSided();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetCullingMode(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return (jint)instance->getCullingMode();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsColorWriteEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isColorWriteEnabled();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsDepthWriteEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isDepthWriteEnabled();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsStencilWriteEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*)nativeMaterialInstance;
|
||||
return instance->isStencilWriteEnabled();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nIsDepthCullingEnabled(JNIEnv* env, jclass clazz,
|
||||
jlong nativeMaterialInstance) {
|
||||
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,13 +150,6 @@ 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) {
|
||||
@@ -201,19 +194,12 @@ Java_com_google_android_filament_RenderableManager_nBuilderSkinning(JNIEnv*, jcl
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderEnableSkinningBuffers(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_RenderableManager_nEnableSkinningBuffers(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) {
|
||||
@@ -353,13 +339,6 @@ 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) {
|
||||
@@ -367,20 +346,6 @@ 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) {
|
||||
|
||||
@@ -83,11 +83,3 @@ Java_com_google_android_filament_Scene_nGetLightCount(JNIEnv *env, jclass type,
|
||||
Scene* scene = (Scene*) nativeScene;
|
||||
return (jint) scene->getLightCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Scene_nHasEntity(JNIEnv *env, jclass type, jlong nativeScene,
|
||||
jint entityId) {
|
||||
Scene* scene = (Scene*) nativeScene;
|
||||
Entity entity = Entity::import(entityId);
|
||||
return (jboolean) scene->hasEntity(entity);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/Engine.h>
|
||||
#include <filament/SwapChain.h>
|
||||
|
||||
#include "common/CallbackUtils.h"
|
||||
@@ -27,14 +26,9 @@ 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(nullptr, [callback](SwapChain* swapChain) {
|
||||
auto *callback = JniCallback::make(env, handler, runnable);
|
||||
swapChain->setFrameCompletedCallback([](void* user) {
|
||||
JniCallback* callback = (JniCallback*)user;
|
||||
JniCallback::postToJavaAndDestroy(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);
|
||||
}, callback);
|
||||
}
|
||||
|
||||
@@ -188,6 +188,69 @@ Java_com_google_android_filament_Texture_nGetInternalFormat(JNIEnv*, jclass,
|
||||
return (jint) texture->getFormat();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImage(JNIEnv* env, jclass, jlong nativeTexture,
|
||||
jlong nativeEngine, jint level, jint xoffset, jint yoffset, jint width, jint height,
|
||||
jobject storage, jint remaining,
|
||||
jint left, jint top, jint type, jint alignment,
|
||||
jint stride, jint format,
|
||||
jobject handler, jobject runnable) {
|
||||
Texture* texture = (Texture*) nativeTexture;
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
|
||||
size_t sizeInBytes = getTextureDataSize(texture, (size_t) level, (Texture::Format) format,
|
||||
(Texture::Type) type, (size_t) stride, (size_t) height, (size_t) alignment);
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes, (backend::PixelDataFormat) format,
|
||||
(backend::PixelDataType) type, (uint8_t) alignment, (uint32_t) left, (uint32_t) top,
|
||||
(uint32_t) stride,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, (uint32_t) xoffset, (uint32_t) yoffset,
|
||||
(uint32_t) width, (uint32_t) height, std::move(desc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImageCompressed(JNIEnv *env, jclass,
|
||||
jlong nativeTexture, jlong nativeEngine, jint level, jint xoffset, jint yoffset,
|
||||
jint width, jint height, jobject storage, jint remaining,
|
||||
jint, jint, jint, jint, jint compressedSizeInBytes, jint compressedFormat,
|
||||
jobject handler, jobject runnable) {
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
|
||||
size_t sizeInBytes = (size_t) compressedSizeInBytes;
|
||||
|
||||
AutoBuffer nioBuffer(env, storage, 0);
|
||||
if (sizeInBytes > (size_t(remaining) << nioBuffer.getShift())) {
|
||||
// BufferOverflowException
|
||||
return -1;
|
||||
}
|
||||
|
||||
void *buffer = nioBuffer.getData();
|
||||
auto *callback = JniBufferCallback::make(engine, env, handler, runnable, std::move(nioBuffer));
|
||||
|
||||
Texture::PixelBufferDescriptor desc(buffer, sizeInBytes,
|
||||
(backend::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level, (uint32_t) xoffset, (uint32_t) yoffset,
|
||||
(uint32_t) width, (uint32_t) height, std::move(desc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImage3D(JNIEnv* env, jclass, jlong nativeTexture,
|
||||
jlong nativeEngine, jint level,
|
||||
@@ -290,10 +353,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemap(JNIEnv *env, jclass,
|
||||
(uint32_t) stride,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
texture->setImage(*engine, (size_t) level, std::move(desc), faceOffsets);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -328,10 +388,7 @@ Java_com_google_android_filament_Texture_nSetImageCubemapCompressed(JNIEnv *env,
|
||||
(backend::CompressedPixelDataType) compressedFormat, (uint32_t) compressedSizeInBytes,
|
||||
callback->getHandler(), &JniBufferCallback::postToJavaAndDestroy, callback);
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
texture->setImage(*engine, (size_t) level, std::move(desc), faceOffsets);
|
||||
#pragma clang diagnostic pop
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -511,7 +568,9 @@ public:
|
||||
|
||||
private:
|
||||
void* mData = nullptr;
|
||||
jobject mBitmap{};
|
||||
jobject mBitmap = nullptr;
|
||||
jobject mHandler = nullptr;
|
||||
jobject mCallback = nullptr;
|
||||
AndroidBitmapInfo mInfo{};
|
||||
};
|
||||
|
||||
|
||||
@@ -18,139 +18,142 @@
|
||||
|
||||
#include <filament/TextureSampler.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
|
||||
using namespace filament;
|
||||
|
||||
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,
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nCreateSampler(JNIEnv *env, jclass type, jint min,
|
||||
jint max, jint s, jint t, jint r) {
|
||||
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);
|
||||
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;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nCreateCompareSampler(JNIEnv *, jclass,
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nCreateCompareSampler(JNIEnv *env, jclass type,
|
||||
jint mode, jint function) {
|
||||
TextureSampler sampler(static_cast<TextureSampler::CompareMode>(mode),
|
||||
static_cast<TextureSampler::CompareFunc>(function));
|
||||
return to_long(sampler);
|
||||
return TextureSampler(static_cast<TextureSampler::CompareMode>(mode),
|
||||
static_cast<TextureSampler::CompareFunc>(function)).getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetMinFilter(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getMinFilter());
|
||||
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());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetMinFilter(JNIEnv *, jclass, jlong sampler_, jint filter) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setMinFilter(static_cast<TextureSampler::MinFilter>(filter));
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetMagFilter(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getMagFilter());
|
||||
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());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetMagFilter(JNIEnv *, jclass, jlong sampler_, jint filter) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setMagFilter(static_cast<TextureSampler::MagFilter>(filter));
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeS(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getWrapModeS());
|
||||
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());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeS(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setWrapModeS(static_cast<TextureSampler::WrapMode>(mode));
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeT(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getWrapModeT());
|
||||
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());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeT(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setWrapModeT(static_cast<TextureSampler::WrapMode>(mode));
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetWrapModeR(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getWrapModeR());
|
||||
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());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetWrapModeR(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setWrapModeR(static_cast<TextureSampler::WrapMode>(mode));
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetCompareMode(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getCompareMode());
|
||||
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());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetCompareMode(JNIEnv *, jclass, jlong sampler_, jint mode) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setCompareMode(static_cast<TextureSampler::CompareMode>(mode),
|
||||
sampler.getCompareFunc());
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetCompareFunction(JNIEnv *, jclass, jlong sampler) {
|
||||
return static_cast<jint>(from_long(sampler).getCompareFunc());
|
||||
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());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetCompareFunction(JNIEnv *, jclass, jlong sampler_, jint function) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setCompareMode(sampler.getCompareMode(),
|
||||
static_cast<TextureSampler::CompareFunc>(function));
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nGetAnisotropy(JNIEnv *, jclass, jlong sampler) {
|
||||
return from_long(sampler).getAnisotropy();
|
||||
Java_com_google_android_filament_TextureSampler_nGetAnisotropy(JNIEnv *env, jclass type,
|
||||
jint sampler_) {
|
||||
TextureSampler &sampler = reinterpret_cast<TextureSampler &>(sampler_);
|
||||
return sampler.getAnisotropy();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_TextureSampler_nSetAnisotropy(JNIEnv *, jclass, jlong sampler_, jfloat anisotropy) {
|
||||
TextureSampler sampler{from_long(sampler_)};
|
||||
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_);
|
||||
sampler.setAnisotropy(anisotropy);
|
||||
return to_long(sampler);
|
||||
return sampler.getSamplerParams().u;
|
||||
}
|
||||
|
||||
@@ -110,26 +110,6 @@ Java_com_google_android_filament_TransformManager_nGetParent(JNIEnv*, jclass,
|
||||
return tm->getParent((TransformManager::Instance) i).getId();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_TransformManager_nGetChildCount(JNIEnv*, jclass,
|
||||
jlong nativeTransformManager, jint i) {
|
||||
TransformManager* tm = (TransformManager*) nativeTransformManager;
|
||||
return tm->getChildCount((TransformManager::Instance) i);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_TransformManager_nGetChildren(JNIEnv* env,
|
||||
jclass, jlong nativeTransformManager, jint i,
|
||||
jintArray outEntities_, jint count) {
|
||||
TransformManager* tm = (TransformManager*) nativeTransformManager;
|
||||
jint* entities = env->GetIntArrayElements(outEntities_, nullptr);
|
||||
// This is very very gross, we just pretend Entity is just like an jint
|
||||
// (which it is), but still.
|
||||
tm->getChildren((TransformManager::Instance) i,
|
||||
reinterpret_cast<Entity *>(entities), (size_t) count);
|
||||
env->ReleaseIntArrayElements(outEntities_, entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_TransformManager_nSetTransform(JNIEnv* env,
|
||||
jclass, jlong nativeTransformManager, jint i,
|
||||
|
||||
@@ -149,13 +149,12 @@ Java_com_google_android_filament_View_nSetShadowType(JNIEnv*, jclass, jlong nati
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetVsmShadowOptions(JNIEnv*, jclass, jlong nativeView,
|
||||
jint anisotropy, jboolean mipmapping, jboolean highPrecision, jfloat minVarianceScale,
|
||||
jint anisotropy, jboolean mipmapping, jfloat minVarianceScale,
|
||||
jfloat lightBleedReduction) {
|
||||
View* view = (View*) nativeView;
|
||||
View::VsmShadowOptions options;
|
||||
options.anisotropy = (uint8_t)anisotropy;
|
||||
options.mipmapping = (bool)mipmapping;
|
||||
options.highPrecision = (bool)highPrecision;
|
||||
options.minVarianceScale = minVarianceScale;
|
||||
options.lightBleedReduction = lightBleedReduction;
|
||||
view->setVsmShadowOptions(options);
|
||||
@@ -315,14 +314,12 @@ 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 cutOffDistance,
|
||||
jfloat r, jfloat g, jfloat b, jfloat density, jfloat inScatteringStart,
|
||||
jfloat inScatteringSize, jboolean fogColorFromIbl, jlong skyColorNativeObject, jboolean enabled) {
|
||||
jfloat distance, jfloat maximumOpacity, jfloat height, jfloat heightFalloff, jfloat r,
|
||||
jfloat g, jfloat b, jfloat density, jfloat inScatteringStart,
|
||||
jfloat inScatteringSize, jboolean fogColorFromIbl, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
Texture* skyColor = (Texture*) skyColorNativeObject;
|
||||
View::FogOptions options = {
|
||||
.distance = distance,
|
||||
.cutOffDistance = cutOffDistance,
|
||||
.maximumOpacity = maximumOpacity,
|
||||
.height = height,
|
||||
.heightFalloff = heightFalloff,
|
||||
@@ -331,7 +328,6 @@ 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);
|
||||
@@ -466,21 +462,6 @@ Java_com_google_android_filament_View_nPick(JNIEnv* env, jclass,
|
||||
}, callback->getHandler());
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetStencilBufferEnabled(JNIEnv *, jclass, jlong nativeView,
|
||||
jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setStencilBufferEnabled(enabled);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_View_nIsStencilBufferEnabled(JNIEnv *, jclass, jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return view->isStencilBufferEnabled();
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetGuardBandOptions(JNIEnv *, jclass,
|
||||
@@ -488,30 +469,3 @@ 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();
|
||||
}
|
||||
|
||||
@@ -365,7 +365,7 @@ public class Camera {
|
||||
* By default, this is an identity matrix.
|
||||
* </p>
|
||||
*
|
||||
* @param inScaling diagonal of the scaling matrix to be applied after the projection matrix.
|
||||
* @param scaling diagonal of the scaling matrix to be applied after the projection matrix.
|
||||
*
|
||||
* @see Camera#setProjection
|
||||
* @see Camera#setLensProjection
|
||||
@@ -400,7 +400,7 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's model matrix.
|
||||
* Sets the camera's view matrix.
|
||||
* <p>
|
||||
* Helper method to set the camera's entity transform component.
|
||||
* Remember that the Camera "looks" towards its -z axis.
|
||||
@@ -409,32 +409,32 @@ public class Camera {
|
||||
*
|
||||
* <pre>
|
||||
* engine.getTransformManager().setTransform(
|
||||
* engine.getTransformManager().getInstance(camera->getEntity()), modelMatrix);
|
||||
* engine.getTransformManager().getInstance(camera->getEntity()), viewMatrix);
|
||||
* </pre>
|
||||
*
|
||||
* @param modelMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
* @param viewMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
*/
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) float[] modelMatrix) {
|
||||
Asserts.assertMat4fIn(modelMatrix);
|
||||
nSetModelMatrix(getNativeObject(), modelMatrix);
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) float[] viewMatrix) {
|
||||
Asserts.assertMat4fIn(viewMatrix);
|
||||
nSetModelMatrix(getNativeObject(), viewMatrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's model matrix.
|
||||
* Sets the camera's view matrix.
|
||||
* <p>
|
||||
* Helper method to set the camera's entity transform component.
|
||||
* Remember that the Camera "looks" towards its -z axis.
|
||||
* <p>
|
||||
*
|
||||
* @param modelMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
* @param viewMatrix The camera position and orientation provided as a <b>rigid transform</b> matrix.
|
||||
*/
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) double[] modelMatrix) {
|
||||
Asserts.assertMat4In(modelMatrix);
|
||||
nSetModelMatrixFp64(getNativeObject(), modelMatrix);
|
||||
public void setModelMatrix(@NonNull @Size(min = 16) double[] viewMatrix) {
|
||||
Asserts.assertMat4In(viewMatrix);
|
||||
nSetModelMatrixFp64(getNativeObject(), viewMatrix);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's model matrix.
|
||||
* Sets the camera's view matrix.
|
||||
*
|
||||
* @param eyeX x-axis position of the camera in world space
|
||||
* @param eyeY y-axis position of the camera in world space
|
||||
@@ -456,7 +456,7 @@ public class Camera {
|
||||
* @return Distance to the near plane
|
||||
*/
|
||||
public float getNear() {
|
||||
return (float)nGetNear(getNativeObject());
|
||||
return nGetNear(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -464,7 +464,7 @@ public class Camera {
|
||||
* @return Distance to the far plane
|
||||
*/
|
||||
public float getCullingFar() {
|
||||
return (float)nGetCullingFar(getNativeObject());
|
||||
return nGetCullingFar(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -549,10 +549,10 @@ public class Camera {
|
||||
/**
|
||||
* Retrieves the camera's view matrix. The view matrix is the inverse of the model matrix.
|
||||
*
|
||||
* @param out A 16-float array where the view matrix will be stored, or null in which
|
||||
* @param out A 16-float array where the model view will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-float array containing the camera's column-major view matrix.
|
||||
* @return A 16-float array containing the camera's view as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public float[] getViewMatrix(@Nullable @Size(min = 16) float[] out) {
|
||||
@@ -567,7 +567,7 @@ public class Camera {
|
||||
* @param out A 16-double array where the model view will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-double array containing the camera's column-major view matrix.
|
||||
* @return A 16-double array containing the camera's view as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public double[] getViewMatrix(@Nullable @Size(min = 16) double[] out) {
|
||||
@@ -787,8 +787,8 @@ public class Camera {
|
||||
private static native void nSetModelMatrix(long nativeCamera, float[] in);
|
||||
private static native void nSetModelMatrixFp64(long nativeCamera, double[] in);
|
||||
private static native void nLookAt(long nativeCamera, double eyeX, double eyeY, double eyeZ, double centerX, double centerY, double centerZ, double upX, double upY, double upZ);
|
||||
private static native double nGetNear(long nativeCamera);
|
||||
private static native double nGetCullingFar(long nativeCamera);
|
||||
private static native float nGetNear(long nativeCamera);
|
||||
private static native float nGetCullingFar(long nativeCamera);
|
||||
private static native void nGetProjectionMatrix(long nativeCamera, double[] out);
|
||||
private static native void nGetCullingProjectionMatrix(long nativeCamera, double[] out);
|
||||
private static native void nGetScaling(long nativeCamera, double[] out);
|
||||
|
||||
@@ -118,7 +118,6 @@ public class ColorGrading {
|
||||
*
|
||||
* @deprecated Use {@link ColorGrading.Builder#toneMapper(ToneMapper)}
|
||||
*/
|
||||
@Deprecated
|
||||
public enum ToneMapping {
|
||||
/** Linear tone mapping (i.e. no tone mapping). */
|
||||
LINEAR,
|
||||
@@ -232,7 +231,6 @@ public class ColorGrading {
|
||||
*
|
||||
* @deprecated Use {@link #toneMapper(ToneMapper)}
|
||||
*/
|
||||
@Deprecated
|
||||
public Builder toneMapping(ToneMapping toneMapping) {
|
||||
nBuilderToneMapping(mNativeBuilder, toneMapping.ordinal());
|
||||
return this;
|
||||
|
||||
@@ -47,7 +47,7 @@ import com.google.android.filament.proguard.UsedByReflection;
|
||||
* <pre>
|
||||
* import com.google.android.filament.*
|
||||
*
|
||||
* Engine engine = Engine.create();
|
||||
* Engin engine = Engine.create();
|
||||
* SwapChain swapChain = engine.createSwapChain(nativeWindow);
|
||||
* Renderer renderer = engine.createRenderer();
|
||||
* Scene scene = engine.createScene();
|
||||
@@ -107,7 +107,6 @@ import com.google.android.filament.proguard.UsedByReflection;
|
||||
*/
|
||||
public class Engine {
|
||||
private static final Backend[] sBackendValues = Backend.values();
|
||||
private static final FeatureLevel[] sFeatureLevelValues = FeatureLevel.values();
|
||||
|
||||
private long mNativeObject;
|
||||
|
||||
@@ -142,18 +141,6 @@ public class Engine {
|
||||
NOOP,
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the backend's feature levels.
|
||||
*/
|
||||
public enum FeatureLevel {
|
||||
/** Reserved, don't use */
|
||||
FEATURE_LEVEL_0,
|
||||
/** OpenGL ES 3.0 features (default) */
|
||||
FEATURE_LEVEL_1,
|
||||
/** OpenGL ES 3.1 features + 31 textures units + cubemap arrays */
|
||||
FEATURE_LEVEL_2
|
||||
};
|
||||
|
||||
private Engine(long nativeEngine) {
|
||||
mNativeObject = nativeEngine;
|
||||
mTransformManager = new TransformManager(nGetTransformManager(nativeEngine));
|
||||
@@ -271,88 +258,6 @@ public class Engine {
|
||||
return sBackendValues[(int) nGetBackend(getNativeObject())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to enable accurate translations.
|
||||
* If you need this Engine to handle a very large world space, one way to achieve this
|
||||
* automatically is to enable accurate translations in the TransformManager. This helper
|
||||
* provides a convenient way of doing that.
|
||||
* This is typically called once just after creating the Engine.
|
||||
*/
|
||||
public void enableAccurateTranslations() {
|
||||
getTransformManager().setAccurateTranslationsEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the feature level supported by the selected backend.
|
||||
*
|
||||
* A specific feature level needs to be set before the corresponding features can be used.
|
||||
*
|
||||
* @return FeatureLevel supported the selected backend.
|
||||
* @see #setActiveFeatureLevel
|
||||
*/
|
||||
@NonNull
|
||||
public FeatureLevel getSupportedFeatureLevel() {
|
||||
return sFeatureLevelValues[(int) nGetSupportedFeatureLevel(getNativeObject())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate all features of a given feature level. By default FeatureLevel::FEATURE_LEVEL_1 is
|
||||
* active. The selected feature level must not be higher than the value returned by
|
||||
* getActiveFeatureLevel() and it's not possible lower the active feature level.
|
||||
*
|
||||
* @param featureLevel the feature level to activate. If featureLevel is lower than
|
||||
* getActiveFeatureLevel(), the current (higher) feature level is kept.
|
||||
* If featureLevel is higher than getSupportedFeatureLevel(), an exception
|
||||
* is thrown, or the program is terminated if exceptions are disabled.
|
||||
*
|
||||
* @return the active feature level.
|
||||
*
|
||||
* @see #getSupportedFeatureLevel
|
||||
* @see #getActiveFeatureLevel
|
||||
*/
|
||||
@NonNull
|
||||
public FeatureLevel setActiveFeatureLevel(@NonNull FeatureLevel featureLevel) {
|
||||
return sFeatureLevelValues[(int) nSetActiveFeatureLevel(getNativeObject(), featureLevel.ordinal())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the currently active feature level.
|
||||
* @return currently active feature level
|
||||
* @see #getSupportedFeatureLevel
|
||||
* @see #setActiveFeatureLevel
|
||||
*/
|
||||
@NonNull
|
||||
public FeatureLevel getActiveFeatureLevel() {
|
||||
return sFeatureLevelValues[(int) nGetActiveFeatureLevel(getNativeObject())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables automatic instancing of render primitives. Instancing of render primitive
|
||||
* can greatly reduce CPU overhead but requires the instanced primitives to be identical
|
||||
* (i.e. use the same geometry) and use the same MaterialInstance. If it is known that the
|
||||
* scene doesn't contain any identical primitives, automatic instancing can have some
|
||||
* overhead and it is then best to disable it.
|
||||
*
|
||||
* Disabled by default.
|
||||
*
|
||||
* @param enable true to enable, false to disable automatic instancing.
|
||||
*
|
||||
* @see RenderableManager
|
||||
* @see MaterialInstance
|
||||
*/
|
||||
public void setAutomaticInstancingEnabled(boolean enable) {
|
||||
nSetAutomaticInstancingEnabled(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if automatic instancing is enabled, false otherwise.
|
||||
* @see #setAutomaticInstancingEnabled
|
||||
*/
|
||||
public boolean isAutomaticInstancingEnabled() {
|
||||
return nIsAutomaticInstancingEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
|
||||
// SwapChain
|
||||
|
||||
/**
|
||||
@@ -449,141 +354,6 @@ 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
|
||||
|
||||
/**
|
||||
@@ -823,11 +593,8 @@ public class Engine {
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys all Filament-known components from this <code>entity</code>.
|
||||
* Destroys an <code>entity</code> and all its components.
|
||||
* <p>
|
||||
* This method destroys Filament components only, not the <code>entity</code> itself. To destroy
|
||||
* the <code>entity</code> use <code>EntityManager#destroy</code>.
|
||||
*
|
||||
* It is recommended to destroy components individually before destroying their
|
||||
* <code>entity</code>, this gives more control as to when the destruction really happens.
|
||||
* Otherwise, orphaned components are garbage collected, which can happen at a later time.
|
||||
@@ -920,17 +687,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 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 long nCreateFence(long nativeEngine);
|
||||
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);
|
||||
@@ -943,22 +710,6 @@ 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);
|
||||
@@ -966,9 +717,4 @@ public class Engine {
|
||||
private static native long nGetRenderableManager(long nativeEngine);
|
||||
private static native long nGetJobSystem(long nativeEngine);
|
||||
private static native long nGetEntityManager(long nativeEngine);
|
||||
private static native void nSetAutomaticInstancingEnabled(long nativeEngine, boolean enable);
|
||||
private static native boolean nIsAutomaticInstancingEnabled(long nativeEngine);
|
||||
private static native int nGetSupportedFeatureLevel(long nativeEngine);
|
||||
private static native int nSetActiveFeatureLevel(long nativeEngine, int ordinal);
|
||||
private static native int nGetActiveFeatureLevel(long nativeEngine);
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class LightManager {
|
||||
*/
|
||||
@NonNull
|
||||
@Size(min = 3)
|
||||
public float[] cascadeSplitPositions = { 0.125f, 0.25f, 0.50f };
|
||||
public float[] cascadeSplitPositions = { 0.25f, 0.50f, 0.75f };
|
||||
|
||||
/** Constant bias in world units (e.g. meters) by which shadows are moved away from the
|
||||
* light. 1mm by default.
|
||||
@@ -280,25 +280,9 @@ public class LightManager {
|
||||
* Controls whether the shadow map should be optimized for resolution or stability.
|
||||
* When set to true, all resolution enhancing features that can affect stability are
|
||||
* disabling, resulting in significantly lower resolution shadows, albeit stable ones.
|
||||
*
|
||||
* Setting this flag to true always disables LiSPSM (see below).
|
||||
*/
|
||||
public boolean stable = false;
|
||||
|
||||
/**
|
||||
* LiSPSM, or light-space perspective shadow-mapping is a technique allowing to better
|
||||
* optimize the use of the shadow-map texture. When enabled the effective resolution of
|
||||
* shadows is greatly improved and yields result similar to using cascades without the
|
||||
* extra cost. LiSPSM comes with some drawbacks however, in particular it is incompatible
|
||||
* with blurring because it effectively affects the blur kernel size.
|
||||
*
|
||||
* Blurring is only an issue when using ShadowType.VSM with a large blur or with
|
||||
* ShadowType.PCSS however.
|
||||
*
|
||||
* If these blurring artifacts become problematic, this flag can be used to disable LiSPSM.
|
||||
*/
|
||||
public boolean lispsm = false;
|
||||
|
||||
/**
|
||||
* Constant bias in depth-resolution units by which shadows are moved away from the
|
||||
* light. The default value of 0.5 is used to round depth values up.
|
||||
@@ -350,12 +334,17 @@ public class LightManager {
|
||||
*/
|
||||
|
||||
/**
|
||||
* When elvsm is set to true, "Exponential Layered VSM without Layers" are used. It is
|
||||
* an improvement to the default EVSM which suffers important light leaks. Enabling
|
||||
* ELVSM for a single shadowmap doubles the memory usage of all shadow maps.
|
||||
* ELVSM is mostly useful when large blurs are used.
|
||||
* The number of MSAA samples to use when rendering VSM shadow maps.
|
||||
* Must be a power-of-two and greater than or equal to 1. A value of 1 effectively turns
|
||||
* off MSAA.
|
||||
* Higher values may not be available depending on the underlying hardware.
|
||||
*
|
||||
* <p>
|
||||
* <strong>Warning: This API is still experimental and subject to change.</strong>
|
||||
* </p>
|
||||
*/
|
||||
public boolean elvsm = false;
|
||||
@IntRange(from = 1)
|
||||
public int vsmMsaaSamples = 1;
|
||||
|
||||
/**
|
||||
* Blur width for the VSM blur. Zero do disable.
|
||||
@@ -481,6 +470,11 @@ public class LightManager {
|
||||
/**
|
||||
* Whether this Light casts shadows (disabled by default)
|
||||
*
|
||||
* <p>
|
||||
* <b>warning:</b>
|
||||
* {@link Type#POINT} lights cannot cast shadows.
|
||||
* </p>
|
||||
*
|
||||
* @param enable Enables or disables casting shadows from this Light.
|
||||
*
|
||||
* @return This Builder, for chaining calls.
|
||||
@@ -502,11 +496,11 @@ public class LightManager {
|
||||
nBuilderShadowOptions(mNativeBuilder,
|
||||
options.mapSize, options.shadowCascades, options.cascadeSplitPositions,
|
||||
options.constantBias, options.normalBias, options.shadowFar, options.shadowNearHint,
|
||||
options.shadowFarHint, options.stable, options.lispsm,
|
||||
options.shadowFarHint, options.stable,
|
||||
options.polygonOffsetConstant, options.polygonOffsetSlope,
|
||||
options.screenSpaceContactShadows,
|
||||
options.stepCount, options.maxShadowDistance,
|
||||
options.elvsm, options.blurWidth, options.shadowBulbRadius);
|
||||
options.stepCount, options.maxShadowDistance, options.vsmMsaaSamples,
|
||||
options.blurWidth, options.shadowBulbRadius);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -1004,6 +998,8 @@ public class LightManager {
|
||||
* lightbulbs.
|
||||
*
|
||||
* @param efficiency Efficiency in percent. This depends on the type of lightbulb used.
|
||||
*
|
||||
* @return This Builder, for chaining calls.
|
||||
*/
|
||||
public void setIntensity(@EntityInstance int i, float watts, float efficiency) {
|
||||
nSetIntensity(mNativeObject, i , watts, efficiency);
|
||||
@@ -1162,14 +1158,7 @@ public class LightManager {
|
||||
private static native void nDestroyBuilder(long nativeBuilder);
|
||||
private static native boolean nBuilderBuild(long nativeBuilder, long nativeEngine, int entity);
|
||||
private static native void nBuilderCastShadows(long nativeBuilder, boolean enable);
|
||||
private static native void nBuilderShadowOptions(long nativeBuilder, int mapSize,
|
||||
int cascades, float[] splitPositions,
|
||||
float constantBias, float normalBias,
|
||||
float shadowFar, float shadowNearHint, float shadowFarhint,
|
||||
boolean stable, boolean lispsm,
|
||||
float polygonOffsetConstant, float polygonOffsetSlope,
|
||||
boolean screenSpaceContactShadows, int stepCount, float maxShadowDistance,
|
||||
boolean elvsm, float blurWidth, float shadowBulbRadius);
|
||||
private static native void nBuilderShadowOptions(long nativeBuilder, int mapSize, int cascades, float[] splitPositions, float constantBias, float normalBias, float shadowFar, float shadowNearHint, float shadowFarhint, boolean stable, float polygonOffsetConstant, float polygonOffsetSlope, boolean screenSpaceContactShadows, int stepCount, float maxShadowDistance, int vsmMsaaSamples, float blurWidth, float shadowBulbRadius);
|
||||
private static native void nBuilderCastLight(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderPosition(long nativeBuilder, float x, float y, float z);
|
||||
private static native void nBuilderDirection(long nativeBuilder, float x, float y, float z);
|
||||
|
||||
@@ -36,7 +36,6 @@ import java.util.Set;
|
||||
*
|
||||
* @see <a href="https://google.github.io/filament/Materials.html">Filament Materials Guide</a>
|
||||
*/
|
||||
@UsedByNative("AssetLoader.cpp")
|
||||
public class Material {
|
||||
static final class EnumCache {
|
||||
private EnumCache() { }
|
||||
@@ -503,17 +502,6 @@ 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.
|
||||
*
|
||||
@@ -926,7 +914,6 @@ 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);
|
||||
|
||||
@@ -20,11 +20,7 @@ import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Size;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByNative;
|
||||
|
||||
@UsedByNative("AssetLoader.cpp")
|
||||
public class MaterialInstance {
|
||||
private static final Material.CullingMode[] sCullingModeValues = Material.CullingMode.values();
|
||||
private Material mMaterial;
|
||||
private String mName;
|
||||
private long mNativeObject;
|
||||
@@ -53,54 +49,6 @@ public class MaterialInstance {
|
||||
MAT4
|
||||
}
|
||||
|
||||
/**
|
||||
* Operations that control how the stencil buffer is updated.
|
||||
*/
|
||||
public enum StencilOperation {
|
||||
/**
|
||||
* Keeps the current value.
|
||||
*/
|
||||
KEEP,
|
||||
/**
|
||||
* Sets the value to 0.
|
||||
*/
|
||||
ZERO,
|
||||
/**
|
||||
* Sets the value to the stencil reference value.
|
||||
*/
|
||||
REPLACE,
|
||||
/**
|
||||
* Increments the current value. Clamps to the maximum representable unsigned value.
|
||||
*/
|
||||
INCR_CLAMP,
|
||||
/**
|
||||
* Increments the current value. Wraps value to zero when incrementing the maximum
|
||||
* representable unsigned value.
|
||||
*/
|
||||
INCR_WRAP,
|
||||
/**
|
||||
* Decrements the current value. Clamps to 0.
|
||||
*/
|
||||
DECR_CLAMP,
|
||||
/**
|
||||
* Decrements the current value. Wraps value to the maximum representable unsigned value
|
||||
* when decrementing a value of zero.
|
||||
*/
|
||||
DECR_WRAP,
|
||||
/**
|
||||
* Bitwise inverts the current value.
|
||||
*/
|
||||
INVERT,
|
||||
}
|
||||
|
||||
public enum StencilFace {
|
||||
FRONT,
|
||||
BACK,
|
||||
FRONT_AND_BACK
|
||||
}
|
||||
// Converts the StencilFace enum ordinal to Filament's equivalent bit field.
|
||||
static final int[] sStencilFaceMapping = {0x1, 0x2, 0x3};
|
||||
|
||||
public MaterialInstance(Engine engine, long nativeMaterialInstance) {
|
||||
mNativeObject = nativeMaterialInstance;
|
||||
mNativeMaterial = nGetMaterial(mNativeObject);
|
||||
@@ -403,40 +351,19 @@ public class MaterialInstance {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set-up a custom scissor rectangle; by default it is disabled.
|
||||
* Set up a custom scissor rectangle; by default this encompasses the View.
|
||||
*
|
||||
* <p>
|
||||
* The scissor rectangle gets clipped by the View's viewport, in other words, the scissor
|
||||
* cannot affect fragments outside of the View's Viewport.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Currently the scissor is not compatible with dynamic resolution and should always be
|
||||
* disabled when dynamic resolution is used.
|
||||
* </p>
|
||||
*
|
||||
* @param left left coordinate of the scissor box relative to the viewport
|
||||
* @param bottom bottom coordinate of the scissor box relative to the viewport
|
||||
* @param left left coordinate of the scissor box
|
||||
* @param bottom bottom coordinate of the scissor box
|
||||
* @param width width of the scissor box
|
||||
* @param height height of the scissor box
|
||||
*
|
||||
* @see #unsetScissor
|
||||
* @see View#setViewport
|
||||
* @see View#setDynamicResolutionOptions
|
||||
*/
|
||||
public void setScissor(@IntRange(from = 0) int left, @IntRange(from = 0) int bottom,
|
||||
@IntRange(from = 0) int width, @IntRange(from = 0) int height) {
|
||||
nSetScissor(getNativeObject(), left, bottom, width, height);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scissor rectangle to its default disabled setting.
|
||||
* <p>
|
||||
* Currently the scissor is not compatible with dynamic resolution and should always be
|
||||
* disabled when dynamic resolution is used.
|
||||
* </p>
|
||||
* @see View#setDynamicResolutionOptions
|
||||
*/
|
||||
/** Returns the scissor rectangle to its default setting, which encompasses the View. */
|
||||
public void unsetScissor() {
|
||||
nUnsetScissor(getNativeObject());
|
||||
}
|
||||
@@ -474,14 +401,6 @@ public class MaterialInstance {
|
||||
nSetMaskThreshold(getNativeObject(), threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the minimum alpha value a fragment must have to not be discarded when the blend
|
||||
* mode is MASKED
|
||||
*/
|
||||
public float getMaskThreshold() {
|
||||
return nGetMaskThreshold(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the screen space variance of the filter kernel used when applying specular
|
||||
* anti-aliasing. The default value is set to 0.15. The specified value should be between
|
||||
@@ -495,14 +414,6 @@ public class MaterialInstance {
|
||||
nSetSpecularAntiAliasingVariance(getNativeObject(), variance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the screen space variance of the filter kernel used when applying specular
|
||||
* anti-aliasing.
|
||||
*/
|
||||
public float getSpecularAntiAliasingVariance() {
|
||||
return nGetSpecularAntiAliasingVariance(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the clamping threshold used to suppress estimation errors when applying specular
|
||||
* anti-aliasing. The default value is set to 0.2. The specified value should be between 0
|
||||
@@ -516,14 +427,6 @@ public class MaterialInstance {
|
||||
nSetSpecularAntiAliasingThreshold(getNativeObject(), threshold);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the clamping threshold used to suppress estimation errors when applying specular
|
||||
* anti-aliasing.
|
||||
*/
|
||||
public float getSpecularAntiAliasingThreshold() {
|
||||
return nGetSpecularAntiAliasingThreshold(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables double-sided lighting if the parent Material has double-sided capability,
|
||||
* otherwise prints a warning. If double-sided lighting is enabled, backface culling is
|
||||
@@ -537,14 +440,6 @@ public class MaterialInstance {
|
||||
nSetDoubleSided(getNativeObject(), doubleSided);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether double-sided lighting is enabled when the parent Material has double-sided
|
||||
* capability.
|
||||
*/
|
||||
public boolean isDoubleSided() {
|
||||
return nIsDoubleSided(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default triangle culling state that was set on the material.
|
||||
*
|
||||
@@ -552,18 +447,10 @@ public class MaterialInstance {
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:culling">
|
||||
* Rasterization: culling</a>
|
||||
*/
|
||||
public void setCullingMode(@NonNull Material.CullingMode mode) {
|
||||
public void setCullingMode(Material.CullingMode mode) {
|
||||
nSetCullingMode(getNativeObject(), mode.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the face culling mode.
|
||||
*/
|
||||
@NonNull
|
||||
public Material.CullingMode getCullingMode() {
|
||||
return sCullingModeValues[nGetCullingMode(getNativeObject())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default color-buffer write state that was set on the material.
|
||||
*
|
||||
@@ -575,13 +462,6 @@ public class MaterialInstance {
|
||||
nSetColorWrite(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether color write is enabled.
|
||||
*/
|
||||
public boolean isColorWriteEnabled() {
|
||||
return nIsColorWriteEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default depth-buffer write state that was set on the material.
|
||||
*
|
||||
@@ -593,27 +473,6 @@ public class MaterialInstance {
|
||||
nSetDepthWrite(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether depth write is enabled.
|
||||
*/
|
||||
public boolean isDepthWriteEnabled() {
|
||||
return nIsDepthWriteEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or Disable stencil writes
|
||||
*/
|
||||
public void setStencilWrite(boolean enable) {
|
||||
nSetStencilWrite(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether stencil write is enabled.
|
||||
*/
|
||||
public boolean isStencilWriteEnabled() {
|
||||
return nIsStencilWriteEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default depth testing state that was set on the material.
|
||||
*
|
||||
@@ -625,231 +484,6 @@ 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.
|
||||
*/
|
||||
public boolean isDepthCullingEnabled() {
|
||||
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}).
|
||||
*
|
||||
* <p>
|
||||
* It's possible to set separate stencil comparison functions; one for front-facing polygons,
|
||||
* and one for back-facing polygons. The face parameter determines the comparison function(s)
|
||||
* updated by this call.
|
||||
* </p>
|
||||
*
|
||||
* @param func the stencil comparison function
|
||||
* @param face the faces to update the comparison function for
|
||||
*/
|
||||
public void setStencilCompareFunction(TextureSampler.CompareFunction func, StencilFace face) {
|
||||
nSetStencilCompareFunction(getNativeObject(), func.ordinal(),
|
||||
sStencilFaceMapping[face.ordinal()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil comparison function for both front and back-facing polygons.
|
||||
* @see #setStencilCompareFunction(TextureSampler.CompareFunction, StencilFace)
|
||||
*/
|
||||
public void setStencilCompareFunction(TextureSampler.CompareFunction func) {
|
||||
setStencilCompareFunction(func, StencilFace.FRONT_AND_BACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil fail operation (default is {@link StencilOperation#KEEP}).
|
||||
*
|
||||
* <p>
|
||||
* The stencil fail operation is performed to update values in the stencil buffer when the
|
||||
* stencil test fails.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It's possible to set separate stencil fail operations; one for front-facing polygons, and one
|
||||
* for back-facing polygons. The face parameter determines the stencil fail operation(s) updated
|
||||
* by this call.
|
||||
* </p>
|
||||
*
|
||||
* @param op the stencil fail operation
|
||||
* @param face the faces to update the stencil fail operation for
|
||||
*/
|
||||
public void setStencilOpStencilFail(StencilOperation op, StencilFace face) {
|
||||
nSetStencilOpStencilFail(getNativeObject(), op.ordinal(),
|
||||
sStencilFaceMapping[face.ordinal()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil fail operation for both front and back-facing polygons.
|
||||
* @see #setStencilOpStencilFail(StencilOperation, StencilFace)
|
||||
*/
|
||||
public void setStencilOpStencilFail(StencilOperation op) {
|
||||
setStencilOpStencilFail(op, StencilFace.FRONT_AND_BACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the depth fail operation (default is {@link StencilOperation#KEEP}).
|
||||
*
|
||||
* <p>
|
||||
* The depth fail operation is performed to update values in the stencil buffer when the depth
|
||||
* test fails.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It's possible to set separate depth fail operations; one for front-facing polygons, and one
|
||||
* for back-facing polygons. The face parameter determines the depth fail operation(s) updated
|
||||
* by this call.
|
||||
* </p>
|
||||
*
|
||||
* @param op the depth fail operation
|
||||
* @param face the faces to update the depth fail operation for
|
||||
*/
|
||||
public void setStencilOpDepthFail(StencilOperation op, StencilFace face) {
|
||||
nSetStencilOpDepthFail(getNativeObject(), op.ordinal(),
|
||||
sStencilFaceMapping[face.ordinal()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the depth fail operation for both front and back-facing polygons.
|
||||
* @see #setStencilOpDepthFail(StencilOperation, StencilFace)
|
||||
*/
|
||||
public void setStencilOpDepthFail(StencilOperation op) {
|
||||
setStencilOpDepthFail(op, StencilFace.FRONT_AND_BACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the depth-stencil pass operation (default is {@link StencilOperation#KEEP}).
|
||||
*
|
||||
* <p>
|
||||
* The depth-stencil pass operation is performed to update values in the stencil buffer when
|
||||
* both the stencil test and depth test pass.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It's possible to set separate depth-stencil pass operations; one for front-facing polygons,
|
||||
* and one for back-facing polygons. The face parameter determines the depth-stencil pass
|
||||
* operation(s) updated by this call.
|
||||
* </p>
|
||||
*
|
||||
* @param op the depth-stencil pass operation
|
||||
* @param face the faces to update the depth-stencil operation for
|
||||
*/
|
||||
public void setStencilOpDepthStencilPass(StencilOperation op, StencilFace face) {
|
||||
nSetStencilOpDepthStencilPass(getNativeObject(), op.ordinal(),
|
||||
sStencilFaceMapping[face.ordinal()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the depth-stencil pass operation for both front and back-facing polygons.
|
||||
* @see #setStencilOpDepthStencilPass(StencilOperation, StencilFace)
|
||||
*/
|
||||
public void setStencilOpDepthStencilPass(StencilOperation op) {
|
||||
setStencilOpDepthStencilPass(op, StencilFace.FRONT_AND_BACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil reference value (default is 0).
|
||||
*
|
||||
* <p>
|
||||
* The stencil reference value is the left-hand side for stencil comparison tests. It's also
|
||||
* used as the replacement stencil value when {@link StencilOperation} is
|
||||
* {@link StencilOperation#REPLACE}.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It's possible to set separate stencil reference values; one for front-facing polygons, and
|
||||
* one for back-facing polygons. The face parameter determines the reference value(s) updated by
|
||||
* this call.
|
||||
* </p>
|
||||
*
|
||||
* @param value the stencil reference value (only the least significant 8 bits are used)
|
||||
* @param face the faces to update the reference value for
|
||||
*/
|
||||
public void setStencilReferenceValue(@IntRange(from = 0, to = 255) int value, StencilFace face) {
|
||||
nSetStencilReferenceValue(getNativeObject(), value, sStencilFaceMapping[face.ordinal()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil reference value for both front and back-facing polygons.
|
||||
* @see #setStencilReferenceValue(int, StencilFace)
|
||||
*/
|
||||
public void setStencilReferenceValue(@IntRange(from = 0, to = 255) int value) {
|
||||
setStencilReferenceValue(value, StencilFace.FRONT_AND_BACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil read mask (default is 0xFF).
|
||||
*
|
||||
* <p>
|
||||
* The stencil read mask masks the bits of the values participating in the stencil comparison
|
||||
* test- both the value read from the stencil buffer and the reference value.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It's possible to set separate stencil read masks; one for front-facing polygons, and one for
|
||||
* back-facing polygons. The face parameter determines the stencil read mask(s) updated by this
|
||||
* call.
|
||||
* </p>
|
||||
*
|
||||
* @param readMask the read mask (only the least significant 8 bits are used)
|
||||
* @param face the faces to update the read mask for
|
||||
*/
|
||||
public void setStencilReadMask(@IntRange(from = 0, to = 255) int readMask, StencilFace face) {
|
||||
nSetStencilReadMask(getNativeObject(), readMask, sStencilFaceMapping[face.ordinal()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil read mask for both front and back-facing polygons.
|
||||
* @see #setStencilReadMask(int, StencilFace)
|
||||
*/
|
||||
public void setStencilReadMask(@IntRange(from = 0, to = 255) int readMask) {
|
||||
setStencilReadMask(readMask, StencilFace.FRONT_AND_BACK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil write mask (default is 0xFF).
|
||||
*
|
||||
* <p>
|
||||
* The stencil write mask masks the bits in the stencil buffer updated by stencil operations.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* It's possible to set separate stencil write masks; one for front-facing polygons, and one for
|
||||
* back-facing polygons. The face parameter determines the stencil write mask(s) updated by this
|
||||
* call.
|
||||
* </p>
|
||||
*
|
||||
* @param writeMask the write mask (only the least significant 8 bits are used)
|
||||
* @param face the faces to update the read mask for
|
||||
*/
|
||||
public void setStencilWriteMask(@IntRange(from = 0, to = 255) int writeMask, StencilFace face) {
|
||||
nSetStencilWriteMask(getNativeObject(), writeMask, sStencilFaceMapping[face.ordinal()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the stencil write mask for both front and back-facing polygons.
|
||||
* @see #setStencilWriteMask(int, StencilFace)
|
||||
*/
|
||||
public void setStencilWriteMask(int writeMask) {
|
||||
setStencilWriteMask(writeMask, StencilFace.FRONT_AND_BACK);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed MaterialInstance");
|
||||
@@ -900,7 +534,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, long sampler);
|
||||
@NonNull String name, long nativeTexture, int sampler);
|
||||
|
||||
private static native void nSetScissor(long nativeMaterialInstance,
|
||||
@IntRange(from = 0) int left, @IntRange(from = 0) int bottom,
|
||||
@@ -922,39 +556,10 @@ public class MaterialInstance {
|
||||
private static native void nSetCullingMode(long nativeMaterialInstance, long mode);
|
||||
private static native void nSetColorWrite(long nativeMaterialInstance, boolean enable);
|
||||
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);
|
||||
private static native void nSetStencilOpStencilFail(long nativeMaterialInstance, long op,
|
||||
long face);
|
||||
private static native void nSetStencilOpDepthFail(long nativeMaterialInstance, long op,
|
||||
long face);
|
||||
private static native void nSetStencilOpDepthStencilPass(long nativeMaterialInstance, long op,
|
||||
long face);
|
||||
private static native void nSetStencilReferenceValue(long nativeMaterialInstance, int value,
|
||||
long face);
|
||||
private static native void nSetStencilReadMask(long nativeMaterialInstance, int readMask,
|
||||
long face);
|
||||
private static native void nSetStencilWriteMask(long nativeMaterialInstance, int writeMask,
|
||||
long face);
|
||||
|
||||
private static native String nGetName(long nativeMaterialInstance);
|
||||
private static native long nGetMaterial(long nativeMaterialInstance);
|
||||
|
||||
private static native long nDuplicate(long otherNativeMaterialInstance, String name);
|
||||
|
||||
|
||||
private static native float nGetMaskThreshold(long nativeMaterialInstance);
|
||||
private static native float nGetSpecularAntiAliasingVariance(long nativeMaterialInstance);
|
||||
private static native float nGetSpecularAntiAliasingThreshold(long nativeMaterialInstance);
|
||||
private static native boolean nIsDoubleSided(long nativeMaterialInstance);
|
||||
private static native int nGetCullingMode(long nativeMaterialInstance);
|
||||
private static native boolean nIsColorWriteEnabled(long nativeMaterialInstance);
|
||||
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,6 +81,8 @@ 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,79 +257,23 @@ 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.
|
||||
* 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>
|
||||
* rendering. However clients can control ordering at a coarse level using <em>priority</em>.</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.
|
||||
*
|
||||
@@ -356,16 +300,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 32767. 0 is invalid.
|
||||
* the maximum number of instances allowed is 65535. 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 32767.
|
||||
* @param instanceCount the number of instances silently clamped between 1 and 65535.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder instances(@IntRange(from = 1, to = 32767) int instanceCount) {
|
||||
public Builder instances(@IntRange(from = 1, to = 65535) int instanceCount) {
|
||||
nBuilderInstances(mNativeBuilder, instanceCount);
|
||||
return this;
|
||||
}
|
||||
@@ -417,19 +361,7 @@ public class RenderableManager {
|
||||
*/
|
||||
@NonNull
|
||||
public Builder enableSkinningBuffers(boolean 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);
|
||||
nEnableSkinningBuffers(mNativeBuilder, enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -723,15 +655,6 @@ 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.
|
||||
*
|
||||
@@ -741,23 +664,6 @@ 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.
|
||||
@@ -970,7 +876,6 @@ 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);
|
||||
@@ -980,8 +885,7 @@ 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 nBuilderEnableSkinningBuffers(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderFog(long nativeBuilder, boolean enabled);
|
||||
private static native void nEnableSkinningBuffers(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderLightChannel(long nativeRenderableManager, int channel, boolean enable);
|
||||
private static native void nBuilderInstances(long nativeRenderableManager, int instances);
|
||||
|
||||
@@ -994,10 +898,7 @@ 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);
|
||||
|
||||
@@ -124,24 +124,7 @@ public class Renderer {
|
||||
*/
|
||||
public static class ClearOptions {
|
||||
/**
|
||||
* Color (sRGB linear) to use to clear the RenderTarget (typically the SwapChain).
|
||||
*
|
||||
* The RenderTarget is cleared using this color, which won't be tone-mapped since
|
||||
* tone-mapping is part of View rendering (this is not).
|
||||
*
|
||||
* When a View is rendered, there are 3 scenarios to consider:
|
||||
* - Pixels rendered by the View replace the clear color (or blend with it in
|
||||
* `BlendMode.TRANSLUCENT` mode).
|
||||
*
|
||||
* - With blending mode set to `BlendMode.TRANSLUCENT`, Pixels untouched by the View
|
||||
* are considered fulling transparent and let the clear color show through.
|
||||
*
|
||||
* - With blending mode set to `BlendMode.OPAQUE`, Pixels untouched by the View
|
||||
* are set to the clear color. However, because it is now used in the context of a View,
|
||||
* it will go through the post-processing stage, which includes tone-mapping.
|
||||
*
|
||||
* For consistency, it is recommended to always use a Skybox to clear an opaque View's
|
||||
* background, or to use black or fully-transparent (i.e. {0,0,0,0}) as the clear color.
|
||||
* Color to use to clear the SwapChain
|
||||
*/
|
||||
@NonNull
|
||||
public float[] clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
@@ -163,15 +163,6 @@ public class Scene {
|
||||
return nGetLightCount(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given entity is in the Scene.
|
||||
*
|
||||
* @return Whether the given entity is in the Scene.
|
||||
*/
|
||||
public boolean hasEntity(@Entity int entity) {
|
||||
return nHasEntity(getNativeObject(), entity);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Scene");
|
||||
@@ -191,5 +182,4 @@ public class Scene {
|
||||
private static native void nRemoveEntities(long nativeScene, int[] entities);
|
||||
private static native int nGetRenderableCount(long nativeScene);
|
||||
private static native int nGetLightCount(long nativeScene);
|
||||
private static native boolean nHasEntity(long nativeScene, int entity);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import java.nio.ReadOnlyBufferException;
|
||||
* Stream supports three different configurations:
|
||||
*
|
||||
* <dl>
|
||||
* <dt>TEXTURE_ID</dt> <dd>takes an OpenGL texture ID and incurs a copy</dd>
|
||||
* <dt>ACQUIRED</dt> <dd>connects to an Android AHardwareBuffer</dd>
|
||||
* <dt>NATIVE</dt> <dd>connects to an Android SurfaceTexture</dd>
|
||||
* </dl>
|
||||
@@ -65,6 +66,12 @@ import java.nio.ReadOnlyBufferException;
|
||||
* </ul>
|
||||
*
|
||||
* <p>
|
||||
* The <b>TEXTURE_ID</b> configuration achieves synchronization automatically. In this mode,
|
||||
* Filament performs a copy on the main thread during beginFrame by blitting the external image into
|
||||
* an internal round-robin queue of images. This copy has a run-time cost.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* For <b>ACQUIRED</b> streams, there is no need to perform the copy because Filament explictly
|
||||
* acquires the stream, then releases it later via a callback function. This configuration is
|
||||
* especially useful when the Vulkan backend is enabled.
|
||||
@@ -111,7 +118,8 @@ public class Stream {
|
||||
* By default, Stream objects are {@link StreamType#ACQUIRED ACQUIRED} and must have external images pushed to them via
|
||||
* {@link #setAcquiredImage}.
|
||||
*
|
||||
* To create a {@link StreamType#NATIVE NATIVE} stream, call the <pre>stream</pre> method on the builder.
|
||||
* To create a {@link StreamType#NATIVE NATIVE} stream, call one of the <pre>stream</pre> methods
|
||||
* on the builder.
|
||||
*/
|
||||
public static class Builder {
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // Keep to finalize native resources
|
||||
@@ -203,7 +211,7 @@ public class Stream {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this <code>Stream</code> is NATIVE or ACQUIRED.
|
||||
* Indicates whether this <code>Stream</code> is NATIVE, TEXTURE_ID, or ACQUIRED.
|
||||
*/
|
||||
public StreamType getStreamType() {
|
||||
return sStreamTypeValues[nGetStreamType(getNativeObject())];
|
||||
@@ -222,7 +230,7 @@ public class Stream {
|
||||
* also where the callback is invoked. This method can only be used for streams that were
|
||||
* constructed without calling the {@link Builder.stream} method.
|
||||
*
|
||||
* See {@link Stream} for more information about NATIVE and ACQUIRED configurations.
|
||||
* See {@link Stream} for more information about NATIVE, TEXTURE_ID, and ACQUIRED configurations.
|
||||
*
|
||||
* @param hwbuffer {@link android.hardware.HardwareBuffer HardwareBuffer} (requires API level 26)
|
||||
* @param handler {@link java.util.concurrent.Executor Executor} or {@link android.os.Handler Handler}.
|
||||
|
||||
@@ -91,34 +91,11 @@ 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.
|
||||
@@ -137,6 +114,10 @@ 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>
|
||||
@@ -160,5 +141,4 @@ public class SwapChain {
|
||||
}
|
||||
|
||||
private static native void nSetFrameCompletedCallback(long nativeSwapChain, Object handler, Runnable callback);
|
||||
private static native boolean nIsSRGBSwapChainSupported(long nativeEngine);
|
||||
}
|
||||
|
||||
@@ -250,19 +250,7 @@ public class Texture {
|
||||
SRGB8_ALPHA8_ASTC_10x8,
|
||||
SRGB8_ALPHA8_ASTC_10x10,
|
||||
SRGB8_ALPHA8_ASTC_12x10,
|
||||
SRGB8_ALPHA8_ASTC_12x12,
|
||||
|
||||
// RGTC formats available with a GLES extension
|
||||
RED_RGTC1, // BC4 unsigned
|
||||
SIGNED_RED_RGTC1, // BC4 signed
|
||||
RED_GREEN_RGTC2, // BC5 unsigned
|
||||
SIGNED_RED_GREEN_RGTC2, // BC5 signed
|
||||
|
||||
// BPTC formats available with a GLES extension
|
||||
RGB_BPTC_SIGNED_FLOAT, // BC6H signed
|
||||
RGB_BPTC_UNSIGNED_FLOAT,// BC6H unsigned
|
||||
RGBA_BPTC_UNORM, // BC7
|
||||
SRGB_ALPHA_BPTC_UNORM // BC7 sRGB
|
||||
SRGB8_ALPHA8_ASTC_12x12
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -308,19 +296,7 @@ public class Texture {
|
||||
SRGB8_ALPHA8_ASTC_10x8,
|
||||
SRGB8_ALPHA8_ASTC_10x10,
|
||||
SRGB8_ALPHA8_ASTC_12x10,
|
||||
SRGB8_ALPHA8_ASTC_12x12,
|
||||
|
||||
// RGTC formats available with a GLES extension
|
||||
RED_RGTC1, // BC4 unsigned
|
||||
SIGNED_RED_RGTC1, // BC4 signed
|
||||
RED_GREEN_RGTC2, // BC5 unsigned
|
||||
SIGNED_RED_GREEN_RGTC2, // BC5 signed
|
||||
|
||||
// BPTC formats available with a GLES extension
|
||||
RGB_BPTC_SIGNED_FLOAT, // BC6H signed
|
||||
RGB_BPTC_UNSIGNED_FLOAT,// BC6H unsigned
|
||||
RGBA_BPTC_UNORM, // BC7
|
||||
SRGB_ALPHA_BPTC_UNORM // BC7 sRGB
|
||||
SRGB8_ALPHA8_ASTC_12x12
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -908,7 +884,7 @@ public class Texture {
|
||||
// TODO: add a setImage() version that takes an android Bitmap
|
||||
|
||||
/**
|
||||
* <code>setImage</code> is used to modify the whole content of the texture from a CPU-buffer.
|
||||
* <code>setImage</code> is used to modify the whole content of the texure from a CPU-buffer.
|
||||
*
|
||||
* <p>This <code>Texture</code> instance must use {@link Sampler#SAMPLER_2D SAMPLER_2D} or
|
||||
* {@link Sampler#SAMPLER_EXTERNAL SAMPLER_EXTERNAL}. If the later is specified
|
||||
@@ -936,7 +912,7 @@ public class Texture {
|
||||
public void setImage(@NonNull Engine engine,
|
||||
@IntRange(from = 0) int level,
|
||||
@NonNull PixelBufferDescriptor buffer) {
|
||||
setImage(engine, level, 0, 0, 0, getWidth(level), getHeight(level), 1, buffer);
|
||||
setImage(engine, level, 0, 0, getWidth(level), getHeight(level), buffer);
|
||||
}
|
||||
|
||||
|
||||
@@ -971,15 +947,33 @@ public class Texture {
|
||||
@IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset,
|
||||
@IntRange(from = 0) int width, @IntRange(from = 0) int height,
|
||||
@NonNull PixelBufferDescriptor buffer) {
|
||||
setImage(engine, level, xoffset, yoffset, 0, width, height, 1, buffer);
|
||||
int result;
|
||||
if (buffer.type == COMPRESSED) {
|
||||
result = nSetImageCompressed(getNativeObject(), engine.getNativeObject(), level,
|
||||
xoffset, yoffset, width, height,
|
||||
buffer.storage, buffer.storage.remaining(),
|
||||
buffer.left, buffer.top, buffer.type.ordinal(), buffer.alignment,
|
||||
buffer.compressedSizeInBytes, buffer.compressedFormat.ordinal(),
|
||||
buffer.handler, buffer.callback);
|
||||
} else {
|
||||
result = nSetImage(getNativeObject(), engine.getNativeObject(), level,
|
||||
xoffset, yoffset, width, height,
|
||||
buffer.storage, buffer.storage.remaining(),
|
||||
buffer.left, buffer.top, buffer.type.ordinal(), buffer.alignment,
|
||||
buffer.stride, buffer.format.ordinal(),
|
||||
buffer.handler, buffer.callback);
|
||||
}
|
||||
if (result < 0) {
|
||||
throw new BufferOverflowException();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <code>setImage</code> is used to modify a sub-region of a 3D texture, 2D texture array or
|
||||
* cubemap from a CPU-buffer. Cubemaps are treated like a 2D array of six layers.
|
||||
* <code>setImage</code> is used to modify a sub-region of the 3D texture or 2D texture array
|
||||
* from a CPU-buffer.
|
||||
*
|
||||
* <p>This <code>Texture</code> instance must use {@link Sampler#SAMPLER_2D_ARRAY SAMPLER_2D_ARRAY},
|
||||
* {@link Sampler#SAMPLER_3D SAMPLER_3D} or {@link Sampler#SAMPLER_CUBEMAP SAMPLER_CUBEMAP}.</p>
|
||||
* <p>This <code>Texture</code> instance must use {@link Sampler#SAMPLER_2D_ARRAY SAMPLER_2D_ARRAY} or
|
||||
* {@link Sampler#SAMPLER_3D SAMPLER_3D}.</p>
|
||||
*
|
||||
* @param engine {@link Engine} this texture is associated to. Must be the
|
||||
* instance passed to {@link Builder#build Builder.build()}.
|
||||
@@ -1052,9 +1046,7 @@ public class Texture {
|
||||
*
|
||||
* @see Builder#sampler
|
||||
* @see PixelBufferDescriptor
|
||||
* @deprecated use {@link #setImage(Engine, int, int, int, int, int, int, int, PixelBufferDescriptor)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setImage(@NonNull Engine engine, @IntRange(from = 0) int level,
|
||||
@NonNull PixelBufferDescriptor buffer,
|
||||
@NonNull @Size(min = 6) int[] faceOffsetsInBytes) {
|
||||
@@ -1266,6 +1258,18 @@ public class Texture {
|
||||
private static native int nGetTarget(long nativeTexture);
|
||||
private static native int nGetInternalFormat(long nativeTexture);
|
||||
|
||||
private static native int nSetImage(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int width, int height,
|
||||
Buffer storage, int remaining, int left, int top, int type, int alignment,
|
||||
int stride, int format,
|
||||
Object handler, Runnable callback);
|
||||
|
||||
private static native int nSetImageCompressed(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int width, int height,
|
||||
Buffer storage, int remaining, int left, int top, int type, int alignment,
|
||||
int compressedSizeInBytes, int compressedFormat,
|
||||
Object handler, Runnable callback);
|
||||
|
||||
private static native int nSetImage3D(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth,
|
||||
Buffer storage, int remaining, int left, int top, int type, int alignment,
|
||||
|
||||
@@ -126,7 +126,7 @@ public class TextureSampler {
|
||||
NEVER
|
||||
}
|
||||
|
||||
long mSampler = 0; // bit field used by native
|
||||
int 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 r (depth) direction.
|
||||
* Sets the wrapping mode in the t (depth) direction.
|
||||
* @param mode wrapping mode
|
||||
*/
|
||||
public void setWrapModeR(WrapMode mode) {
|
||||
@@ -342,26 +342,26 @@ public class TextureSampler {
|
||||
}
|
||||
}
|
||||
|
||||
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 nCreateSampler(int min, int max, int s, int t, int r);
|
||||
private static native int nCreateCompareSampler(int mode, int function);
|
||||
|
||||
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 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 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 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 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 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 float nGetAnisotropy(long sampler);
|
||||
private static native long nSetAnisotropy(long sampler, float anisotropy);
|
||||
private static native float nGetAnisotropy(int sampler);
|
||||
private static native int nSetAnisotropy(int sampler, float anisotropy);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.google.android.filament;
|
||||
|
||||
import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.Size;
|
||||
@@ -200,36 +199,6 @@ import androidx.annotation.Size;
|
||||
return nGetParent(mNativeObject, i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of children of an {@link EntityInstance}.
|
||||
*
|
||||
* @param i the {@link EntityInstance} of the transform component to query.
|
||||
* @return The number of children of the queried component.
|
||||
*/
|
||||
public int getChildCount(@EntityInstance int i) {
|
||||
return nGetChildCount(mNativeObject, i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of children for a transform component.
|
||||
*
|
||||
* @param i the {@link EntityInstance} of the transform component to get the children
|
||||
* from.
|
||||
* @param outEntities array to receive the result sized to the maximum number of children to
|
||||
* retrieve. If <code>null</code> is given, a new suitable array sized to
|
||||
* {@link #getChildCount(int)} is allocated.
|
||||
* @return Array of retrieved children {@link Entity}.
|
||||
*/
|
||||
public @Entity @NonNull int[] getChildren(@EntityInstance int i, @Nullable int[] outEntities) {
|
||||
if (outEntities == null) {
|
||||
outEntities = new int[getChildCount(i)];
|
||||
}
|
||||
if (outEntities.length > 0) {
|
||||
nGetChildren(mNativeObject, i, outEntities, outEntities.length);
|
||||
}
|
||||
return outEntities;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a local transform of a transform component.
|
||||
* <p>This operation can be slow if the hierarchy of transform is too deep, and this
|
||||
@@ -391,8 +360,6 @@ import androidx.annotation.Size;
|
||||
private static native void nDestroy(long nativeTransformManager, int entity);
|
||||
private static native void nSetParent(long nativeTransformManager, int i, int newParent);
|
||||
private static native int nGetParent(long nativeTransformManager, int i);
|
||||
private static native int nGetChildCount(long nativeTransformManager, int i);
|
||||
private static native void nGetChildren(long nativeEntityManager, int i, int[] outEntities, int count);
|
||||
private static native void nSetTransform(long nativeTransformManager, int i, float[] localTransform);
|
||||
private static native void nSetTransformFp64(long nativeTransformManager, int i, double[] localTransform);
|
||||
private static native void nGetTransform(long nativeTransformManager, int i, float[] outLocalTransform);
|
||||
|
||||
@@ -27,8 +27,6 @@ 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}.
|
||||
*
|
||||
@@ -795,7 +793,7 @@ public class View {
|
||||
public void setVsmShadowOptions(@NonNull VsmShadowOptions options) {
|
||||
mVsmShadowOptions = options;
|
||||
nSetVsmShadowOptions(getNativeObject(), options.anisotropy, options.mipmapping,
|
||||
options.highPrecision, options.minVarianceScale, options.lightBleedReduction);
|
||||
options.minVarianceScale, options.lightBleedReduction);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -964,11 +962,9 @@ public class View {
|
||||
assertFloat3In(options.color);
|
||||
mFogOptions = options;
|
||||
nSetFogOptions(getNativeObject(), options.distance, options.maximumOpacity, options.height,
|
||||
options.heightFalloff, options.cutOffDistance,
|
||||
options.color[0], options.color[1], options.color[2],
|
||||
options.heightFalloff, 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);
|
||||
}
|
||||
|
||||
@@ -1015,45 +1011,6 @@ public class View {
|
||||
return mDepthOfFieldOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables use of the stencil buffer.
|
||||
*
|
||||
* <p>
|
||||
* The stencil buffer is an 8-bit, per-fragment unsigned integer stored alongside the depth
|
||||
* buffer. The stencil buffer is cleared at the beginning of a frame and discarded after the
|
||||
* color pass.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Each fragment's stencil value is set during rasterization by specifying stencil operations on
|
||||
* a {@link Material}. The stencil buffer can be used as a mask for later rendering by setting a
|
||||
* {@link Material}'s stencil comparison function and reference value. Fragments that don't pass
|
||||
* the stencil test are then discarded.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* Post-processing must be enabled in order to use the stencil buffer.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* A renderable's priority (see {@link RenderableManager#setPriority(int, int)}) is useful to
|
||||
* control the order in which primitives are drawn.
|
||||
* </p>
|
||||
*
|
||||
* @param enabled True to enable the stencil buffer, false disables it (default)
|
||||
*/
|
||||
public void setStencilBufferEnabled(boolean enabled) {
|
||||
nSetStencilBufferEnabled(getNativeObject(), enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the stencil buffer is enabled.
|
||||
* @see View#setStencilBufferEnabled(boolean)
|
||||
*/
|
||||
public boolean isStencilBufferEnabled() {
|
||||
return nIsStencilBufferEnabled(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* A class containing the result of a picking query
|
||||
*/
|
||||
@@ -1098,29 +1055,10 @@ 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;
|
||||
@@ -1130,51 +1068,13 @@ public class View {
|
||||
mPickingQueryResult.fragCoords[2] = mFragCoordsZ;
|
||||
mUserCallback.onPick(mPickingQueryResult);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
private final OnPickCallback mUserCallback;
|
||||
private final PickingQueryResult mPickingQueryResult = new PickingQueryResult();
|
||||
@Entity int mRenderable;
|
||||
float mDepth;
|
||||
float mFragCoordsX;
|
||||
float mFragCoordsY;
|
||||
float mFragCoordsZ;
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
@@ -1205,7 +1105,7 @@ public class View {
|
||||
private static native void nSetRenderQuality(long nativeView, int hdrColorBufferQuality);
|
||||
private static native void nSetDynamicLightingOptions(long nativeView, float zLightNear, float zLightFar);
|
||||
private static native void nSetShadowType(long nativeView, int type);
|
||||
private static native void nSetVsmShadowOptions(long nativeView, int anisotropy, boolean mipmapping, boolean highPrecision, float minVarianceScale, float lightBleedReduction);
|
||||
private static native void nSetVsmShadowOptions(long nativeView, int anisotropy, boolean mipmapping, float minVarianceScale, float lightBleedReduction);
|
||||
private static native void nSetSoftShadowOptions(long nativeView, float penumbraScale, float penumbraRatioScale);
|
||||
private static native void nSetColorGrading(long nativeView, long nativeColorGrading);
|
||||
private static native void nSetPostProcessingEnabled(long nativeView, boolean enabled);
|
||||
@@ -1218,7 +1118,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 cutOffDistance, float v, float v1, float v2, float density, float inScatteringStart, float inScatteringSize, boolean fogColorFromIbl, long skyColorNativeObject, boolean enabled);
|
||||
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 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);
|
||||
@@ -1231,12 +1131,6 @@ public class View {
|
||||
private static native void nSetGuardBandOptions(long nativeView, boolean enabled);
|
||||
private static native boolean nIsScreenSpaceRefractionEnabled(long nativeView);
|
||||
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.
|
||||
@@ -1392,13 +1286,13 @@ public class View {
|
||||
/**
|
||||
* resolution of vertical axis (2^levels to 2048)
|
||||
*/
|
||||
public int resolution = 384;
|
||||
public int resolution = 360;
|
||||
/**
|
||||
* bloom x/y aspect-ratio (1/32 to 32)
|
||||
*/
|
||||
public float anamorphism = 1.0f;
|
||||
/**
|
||||
* number of blur levels (1 to 11)
|
||||
* number of blur levels (3 to 11)
|
||||
*/
|
||||
public int levels = 6;
|
||||
/**
|
||||
@@ -1457,109 +1351,48 @@ public class View {
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to control large-scale fog in the scene
|
||||
* Options to control fog in the scene
|
||||
*/
|
||||
public static class FogOptions {
|
||||
/**
|
||||
* Distance in world units [m] from the camera to where the fog starts ( >= 0.0 )
|
||||
* distance in world units from the camera 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 [m]. This sets the "sea level".
|
||||
* fog's floor in world units
|
||||
*/
|
||||
public float height = 0.0f;
|
||||
/**
|
||||
* 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.
|
||||
* how fast fog dissipates with altitude
|
||||
*/
|
||||
public float heightFalloff = 1.0f;
|
||||
/**
|
||||
* 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
|
||||
* fog's color (linear), see fogColorFromIbl
|
||||
*/
|
||||
@NonNull @Size(min = 3)
|
||||
public float[] color = {1.0f, 1.0f, 1.0f};
|
||||
public float[] color = {0.5f, 0.5f, 0.5f};
|
||||
/**
|
||||
* 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`.
|
||||
* fog's density at altitude given by 'height'
|
||||
*/
|
||||
public float density = 0.1f;
|
||||
/**
|
||||
* Distance in world units [m] from the camera where the Sun in-scattering starts.
|
||||
* distance in world units from the camera where in-scattering starts
|
||||
*/
|
||||
public float inScatteringStart = 0.0f;
|
||||
/**
|
||||
* 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.
|
||||
* size of in-scattering (>0 to activate). Good values are >> 1 (e.g. ~10 - 100).
|
||||
*/
|
||||
public float inScatteringSize = -1.0f;
|
||||
/**
|
||||
* 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
|
||||
* Fog color will be modulated by the IBL color in the view direction.
|
||||
*/
|
||||
public boolean fogColorFromIbl = false;
|
||||
/**
|
||||
* 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
|
||||
* enable or disable fog
|
||||
*/
|
||||
public boolean enabled = false;
|
||||
}
|
||||
@@ -1943,20 +1776,6 @@ public class View {
|
||||
* Whether to generate mipmaps for all VSM shadow maps.
|
||||
*/
|
||||
public boolean mipmapping = false;
|
||||
/**
|
||||
* The number of MSAA samples to use when rendering VSM shadow maps.
|
||||
* Must be a power-of-two and greater than or equal to 1. A value of 1 effectively turns
|
||||
* off MSAA.
|
||||
* Higher values may not be available depending on the underlying hardware.
|
||||
*/
|
||||
public int msaaSamples = 1;
|
||||
/**
|
||||
* Whether to use a 32-bits or 16-bits texture format for VSM shadow maps. 32-bits
|
||||
* precision is rarely needed, but it does reduces light leaks as well as "fading"
|
||||
* of the shadows in some situations. Setting highPrecision to true for a single
|
||||
* shadow map will double the memory usage of all shadow maps.
|
||||
*/
|
||||
public boolean highPrecision = false;
|
||||
/**
|
||||
* VSM minimum variance scale, must be positive.
|
||||
*/
|
||||
@@ -1986,11 +1805,4 @@ public class View {
|
||||
*/
|
||||
public float penumbraRatioScale = 1.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for stereoscopic (multi-eye) rendering.
|
||||
*/
|
||||
public static class StereoscopicOptions {
|
||||
public boolean enabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* 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,14 +84,6 @@ 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
|
||||
* }
|
||||
* });
|
||||
@@ -183,7 +175,7 @@ public class UiHelper {
|
||||
}
|
||||
|
||||
private static class SurfaceViewHandler implements RenderSurface {
|
||||
private final SurfaceView mSurfaceView;
|
||||
private SurfaceView mSurfaceView;
|
||||
|
||||
SurfaceViewHandler(SurfaceView surface) {
|
||||
mSurfaceView = surface;
|
||||
@@ -200,7 +192,7 @@ public class UiHelper {
|
||||
}
|
||||
|
||||
private static class SurfaceHolderHandler implements RenderSurface {
|
||||
private final SurfaceHolder mSurfaceHolder;
|
||||
private SurfaceHolder mSurfaceHolder;
|
||||
|
||||
SurfaceHolderHandler(SurfaceHolder surface) {
|
||||
mSurfaceHolder = surface;
|
||||
@@ -217,7 +209,7 @@ public class UiHelper {
|
||||
}
|
||||
|
||||
private class TextureViewHandler implements RenderSurface {
|
||||
private final TextureView mTextureView;
|
||||
private TextureView mTextureView;
|
||||
private Surface mSurface;
|
||||
|
||||
TextureViewHandler(TextureView surface) { mTextureView = surface; }
|
||||
@@ -244,10 +236,6 @@ public class UiHelper {
|
||||
}
|
||||
mSurface = surface;
|
||||
}
|
||||
|
||||
public Surface getSurface() {
|
||||
return mSurface;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,14 +481,6 @@ 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,7 +1,4 @@
|
||||
apply plugin: 'kotlin-android'
|
||||
kotlin {
|
||||
jvmToolchain(versions.jdk)
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.google.android.filament.utils'
|
||||
@@ -24,11 +21,16 @@ android {
|
||||
excludes += ['lib/*/libfilament-jni.so', 'lib/*/libgltfio-jni.so']
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
singleVariant("release") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
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"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -41,7 +43,7 @@ dependencies {
|
||||
implementation deps.coroutines.android
|
||||
|
||||
api project(':filament-android')
|
||||
api project(':gltfio-android')
|
||||
api module("com.google.android.filament:gltfio-android:${VERSION_NAME}")
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
|
||||
|
||||
@@ -70,8 +70,7 @@ Java_com_google_android_filament_utils_AutomationEngine_nStartBatchMode(JNIEnv*
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_utils_AutomationEngine_nTick(JNIEnv* env, jclass klass,
|
||||
jlong nativeAutomation, jlong nativeEngine,
|
||||
jlong view, jlongArray materials, jlong renderer, jfloat deltaTime) {
|
||||
jlong nativeAutomation, jlong view, jlongArray materials, jlong renderer, jfloat deltaTime) {
|
||||
using MaterialPointer = MaterialInstance*;
|
||||
jsize materialCount = 0;
|
||||
jlong* longMaterials = nullptr;
|
||||
@@ -91,8 +90,7 @@ Java_com_google_android_filament_utils_AutomationEngine_nTick(JNIEnv* env, jclas
|
||||
.materials = ptrMaterials,
|
||||
.materialCount = (size_t) materialCount,
|
||||
};
|
||||
Engine* engine = (Engine*)nativeEngine;
|
||||
automation->tick(engine, content, deltaTime);
|
||||
automation->tick(content, deltaTime);
|
||||
if (longMaterials) {
|
||||
env->ReleaseLongArrayElements(materials, longMaterials, 0);
|
||||
delete[] ptrMaterials;
|
||||
@@ -101,8 +99,7 @@ Java_com_google_android_filament_utils_AutomationEngine_nTick(JNIEnv* env, jclas
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_utils_AutomationEngine_nApplySettings(JNIEnv* env, jclass klass,
|
||||
jlong nativeAutomation, jlong nativeEngine,
|
||||
jstring json, jlong view, jlongArray materials, jlong nativeIbl,
|
||||
jlong nativeAutomation, jstring json, jlong view, jlongArray materials, jlong nativeIbl,
|
||||
jint sunlightEntity, jintArray assetLights, jlong nativeLm, jlong scene, jlong renderer) {
|
||||
using MaterialPointer = MaterialInstance*;
|
||||
|
||||
@@ -143,8 +140,8 @@ Java_com_google_android_filament_utils_AutomationEngine_nApplySettings(JNIEnv* e
|
||||
.assetLights = (Entity*) intLights,
|
||||
.assetLightCount = (size_t) lightCount,
|
||||
};
|
||||
Engine* engine = (Engine*)nativeEngine;
|
||||
automation->applySettings(engine, nativeJson, jsonLength, content);
|
||||
|
||||
automation->applySettings(nativeJson, jsonLength, content);
|
||||
env->ReleaseStringUTFChars(json, nativeJson);
|
||||
if (longMaterials) {
|
||||
env->ReleaseLongArrayElements(materials, longMaterials, 0);
|
||||
@@ -166,28 +163,22 @@ 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");
|
||||
const jfieldID cameraFocalLength = env->GetFieldID(klass, "cameraFocalLength", "F");
|
||||
const jfieldID cameraFocusDistance = env->GetFieldID(klass, "cameraFocusDistance", "F");
|
||||
const jfieldID autoScaleEnabled = env->GetFieldID(klass, "autoScaleEnabled", "Z");
|
||||
const jfieldID autoInstancingEnabled = env->GetFieldID(klass, "autoInstancingEnabled", "Z");
|
||||
|
||||
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);
|
||||
env->SetFloatField(result, cameraFocalLength, options.cameraFocalLength);
|
||||
env->SetFloatField(result, cameraFocusDistance, options.cameraFocusDistance);
|
||||
env->SetBooleanField(result, autoScaleEnabled, options.autoScaleEnabled);
|
||||
env->SetBooleanField(result, autoInstancingEnabled, options.autoInstancingEnabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
|
||||
@@ -97,15 +97,12 @@ 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;
|
||||
public float cameraFocalLength = 28.0f;
|
||||
public float cameraFocusDistance = 0.0f;
|
||||
public boolean autoScaleEnabled = true;
|
||||
public boolean autoInstancingEnabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -158,11 +155,10 @@ public class AutomationEngine {
|
||||
* This is when settings get applied, screenshots are (optionally) exported, and the internal
|
||||
* test counter is potentially incremented.
|
||||
*
|
||||
* @param engine The filament Engine of interest.
|
||||
* @param content Contains the Filament View, Materials, and Renderer that get modified.
|
||||
* @param deltaTime The amount of time that has passed since the previous tick in seconds.
|
||||
*/
|
||||
public void tick(@NonNull Engine engine, @NonNull ViewerContent content, float deltaTime) {
|
||||
public void tick(@NonNull ViewerContent content, float deltaTime) {
|
||||
if (content.view == null || content.renderer == null) {
|
||||
throw new IllegalStateException("Must provide a View and Renderer");
|
||||
}
|
||||
@@ -175,7 +171,7 @@ public class AutomationEngine {
|
||||
}
|
||||
long nativeView = content.view.getNativeObject();
|
||||
long nativeRenderer = content.renderer.getNativeObject();
|
||||
nTick(mNativeObject, engine.getNativeObject(), nativeView, nativeMaterialInstances, nativeRenderer, deltaTime);
|
||||
nTick(mNativeObject, nativeView, nativeMaterialInstances, nativeRenderer, deltaTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -187,12 +183,10 @@ public class AutomationEngine {
|
||||
* This updates the stashed Settings object, then pushes those settings to the given
|
||||
* Filament objects. Clients can optionally call getColorGrading() after calling this method.
|
||||
*
|
||||
* @param engine Filament Engine to use.
|
||||
* @param settingsJson Contains the JSON string with a set of changes that need to be pushed.
|
||||
* @param content Contains a set of Filament objects that you want to mutate.
|
||||
*/
|
||||
public void applySettings(@NonNull Engine engine, @NonNull String settingsJson,
|
||||
@NonNull ViewerContent content) {
|
||||
public void applySettings(@NonNull String settingsJson, @NonNull ViewerContent content) {
|
||||
if (content.view == null || content.renderer == null) {
|
||||
throw new IllegalStateException("Must provide a View and Renderer");
|
||||
}
|
||||
@@ -211,8 +205,7 @@ public class AutomationEngine {
|
||||
long nativeLm = content.lightManager.getNativeObject();
|
||||
long nativeScene = content.scene.getNativeObject();
|
||||
long nativeRenderer = content.renderer.getNativeObject();
|
||||
nApplySettings(mNativeObject, engine.getNativeObject(),
|
||||
settingsJson, nativeView, nativeMaterialInstances,
|
||||
nApplySettings(mNativeObject, settingsJson, nativeView, nativeMaterialInstances,
|
||||
nativeIbl, content.sunlight, content.assetLights, nativeLm, nativeScene,
|
||||
nativeRenderer);
|
||||
}
|
||||
@@ -273,10 +266,9 @@ public class AutomationEngine {
|
||||
int minFrameCount, boolean verbose);
|
||||
private static native void nStartRunning(long nativeObject);
|
||||
private static native void nStartBatchMode(long nativeObject);
|
||||
private static native void nTick(long nativeObject, long nativeEngine,
|
||||
long view, long[] materials, long renderer, float deltaTime);
|
||||
private static native void nApplySettings(long nativeObject, long nativeEngine,
|
||||
String jsonSettings, long view,
|
||||
private static native void nTick(long nativeObject, long view, long[] materials, long renderer,
|
||||
float deltaTime);
|
||||
private static native void nApplySettings(long nativeObject, String jsonSettings, long view,
|
||||
long[] materials, long ibl, int sunlight, int[] assetLights, long lightManager,
|
||||
long scene, long renderer);
|
||||
private static native void nGetViewerOptions(long nativeObject, Object result);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
@file:Suppress("NOTHING_TO_INLINE", "unused")
|
||||
@file:Suppress("unused")
|
||||
|
||||
package com.google.android.filament.utils
|
||||
|
||||
@@ -24,16 +24,8 @@ enum class MatrixColumn {
|
||||
X, Y, Z, W
|
||||
}
|
||||
|
||||
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);
|
||||
enum class RotationsOrder {
|
||||
XYZ, XZY, YXZ, YZX, ZXY, ZYX
|
||||
}
|
||||
|
||||
data class Mat2(
|
||||
@@ -85,12 +77,6 @@ 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(
|
||||
@@ -103,18 +89,12 @@ 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
|
||||
@@ -126,6 +106,7 @@ data class Mat2(
|
||||
|${x.y} ${y.y}|
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class Mat3(
|
||||
@@ -181,14 +162,6 @@ 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(
|
||||
@@ -208,15 +181,6 @@ 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,
|
||||
@@ -248,7 +212,6 @@ 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(
|
||||
@@ -339,15 +302,6 @@ 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(
|
||||
@@ -376,16 +330,6 @@ 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,
|
||||
@@ -393,26 +337,6 @@ 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(
|
||||
@@ -432,78 +356,6 @@ 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)
|
||||
@@ -642,7 +494,14 @@ 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 rotation(r[order.yaw], r[order.pitch], r[order.roll], order)
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -740,93 +599,13 @@ 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),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* Extract Quaternion rotation from a Matrix
|
||||
*/
|
||||
fun quaternion(m: Mat4): Quaternion {
|
||||
val trace = m.x.x + m.y.y + m.z.z
|
||||
@@ -894,14 +673,9 @@ 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 - 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
|
||||
)
|
||||
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)
|
||||
)
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ import com.google.android.filament.gltfio.*
|
||||
import kotlinx.coroutines.*
|
||||
import java.nio.Buffer
|
||||
|
||||
private const val kNearPlane = 0.05f // 5 cm
|
||||
private const val kFarPlane = 1000.0f // 1 km
|
||||
private const val kNearPlane = 0.05 // 5 cm
|
||||
private const val kFarPlane = 1000.0 // 1 km
|
||||
private const val kAperture = 16f
|
||||
private const val kShutterSpeed = 1f / 125f
|
||||
private const val kSensitivity = 100f
|
||||
@@ -73,6 +73,8 @@ class ModelViewer(
|
||||
get() = resourceLoader.asyncGetLoadProgress()
|
||||
|
||||
var normalizeSkinningWeights = true
|
||||
var recomputeBoundingBoxes = false
|
||||
var ignoreBindTransform = false
|
||||
|
||||
var cameraFocalLength = 28f
|
||||
set(value) {
|
||||
@@ -80,18 +82,6 @@ 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
|
||||
@@ -126,7 +116,7 @@ class ModelViewer(
|
||||
|
||||
materialProvider = UbershaderProvider(engine)
|
||||
assetLoader = AssetLoader(engine, materialProvider, EntityManager.get())
|
||||
resourceLoader = ResourceLoader(engine, normalizeSkinningWeights)
|
||||
resourceLoader = ResourceLoader(engine, normalizeSkinningWeights, recomputeBoundingBoxes, ignoreBindTransform)
|
||||
|
||||
// Always add a direct light source since it is required for shadowing.
|
||||
// We highly recommend adding an indirect light as well.
|
||||
@@ -188,10 +178,10 @@ class ModelViewer(
|
||||
*/
|
||||
fun loadModelGlb(buffer: Buffer) {
|
||||
destroyModel()
|
||||
asset = assetLoader.createAsset(buffer)
|
||||
asset = assetLoader.createAssetFromBinary(buffer)
|
||||
asset?.let { asset ->
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.instance.animator
|
||||
animator = asset.animator
|
||||
asset.releaseSourceData()
|
||||
}
|
||||
}
|
||||
@@ -203,7 +193,7 @@ class ModelViewer(
|
||||
*/
|
||||
fun loadModelGltf(buffer: Buffer, callback: (String) -> Buffer?) {
|
||||
destroyModel()
|
||||
asset = assetLoader.createAsset(buffer)
|
||||
asset = assetLoader.createAssetFromJson(buffer)
|
||||
asset?.let { asset ->
|
||||
for (uri in asset.resourceUris) {
|
||||
val resourceBuffer = callback(uri)
|
||||
@@ -214,7 +204,7 @@ class ModelViewer(
|
||||
resourceLoader.addResourceData(uri, resourceBuffer)
|
||||
}
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.instance.animator
|
||||
animator = asset.animator
|
||||
asset.releaseSourceData()
|
||||
}
|
||||
}
|
||||
@@ -226,7 +216,7 @@ class ModelViewer(
|
||||
*/
|
||||
fun loadModelGltfAsync(buffer: Buffer, callback: (String) -> Buffer) {
|
||||
destroyModel()
|
||||
asset = assetLoader.createAsset(buffer)
|
||||
asset = assetLoader.createAssetFromJson(buffer)
|
||||
fetchResourcesJob = CoroutineScope(Dispatchers.IO).launch {
|
||||
fetchResources(asset!!, callback)
|
||||
}
|
||||
@@ -311,7 +301,7 @@ class ModelViewer(
|
||||
var count = 0
|
||||
val popRenderables = { count = asset.popRenderables(readyRenderables); count != 0 }
|
||||
while (popRenderables()) {
|
||||
for (i in 0 until count) {
|
||||
for (i in 0..count - 1) {
|
||||
val ri = rcm.getInstance(readyRenderables[i])
|
||||
rcm.setScreenSpaceContactShadows(ri, true)
|
||||
}
|
||||
@@ -322,8 +312,8 @@ class ModelViewer(
|
||||
|
||||
private fun addDetachListener(view: android.view.View) {
|
||||
view.addOnAttachStateChangeListener(object : android.view.View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: android.view.View) {}
|
||||
override fun onViewDetachedFromWindow(v: android.view.View) {
|
||||
override fun onViewAttachedToWindow(v: android.view.View?) {}
|
||||
override fun onViewDetachedFromWindow(v: android.view.View?) {
|
||||
uiHelper.detach()
|
||||
|
||||
destroyModel()
|
||||
@@ -371,7 +361,7 @@ class ModelViewer(
|
||||
resourceLoader.addResourceData(uri, buffer)
|
||||
}
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.instance.animator
|
||||
animator = asset.animator
|
||||
asset.releaseSourceData()
|
||||
}
|
||||
}
|
||||
@@ -380,8 +370,7 @@ class ModelViewer(
|
||||
val width = view.viewport.width
|
||||
val height = view.viewport.height
|
||||
val aspect = width.toDouble() / height.toDouble()
|
||||
camera.setLensProjection(cameraFocalLength.toDouble(), aspect,
|
||||
cameraNear.toDouble(), cameraFar.toDouble())
|
||||
camera.setLensProjection(cameraFocalLength.toDouble(), aspect, kNearPlane, kFarPlane)
|
||||
}
|
||||
|
||||
inner class SurfaceCallback : UiHelper.RendererCallback {
|
||||
@@ -405,19 +394,9 @@ 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 = 1.0f) {
|
||||
var w: Float = 0.0f) {
|
||||
|
||||
constructor(v: Float3, w: Float = 1.0f) : this(v.x, v.y, v.z, w)
|
||||
constructor(v: Float3, w: Float = 0.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,84 +52,42 @@ data class Quaternion(
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Quaternion from Euler angles using YPR around a specified order
|
||||
* Construct a Quaternion from Euler angles using YPR around ZYX respectively
|
||||
*
|
||||
* 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)
|
||||
* 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 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, order: RotationsOrder = RotationsOrder.ZYX): Quaternion {
|
||||
fun fromEuler(d: Float3): Quaternion {
|
||||
val r = transform(d, ::radians)
|
||||
return fromEuler(r[order.yaw], r[order.pitch], r[order.roll], order)
|
||||
return fromEulerZYX(r.z, r.y, r.x)
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a Quaternion from Euler yaw, pitch, roll around a specified order.
|
||||
* Construct a Quaternion from Euler angles using YPR around ZYX respectively
|
||||
*
|
||||
* @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.
|
||||
* 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
|
||||
*/
|
||||
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
|
||||
)
|
||||
}
|
||||
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
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -264,44 +222,16 @@ 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
|
||||
)
|
||||
|
||||
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)
|
||||
)
|
||||
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 transform(block: (Float) -> Float): Quaternion {
|
||||
x = block(x)
|
||||
@@ -323,103 +253,6 @@ 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
|
||||
@@ -445,10 +278,6 @@ 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
|
||||
*
|
||||
@@ -458,38 +287,36 @@ fun angle(a: Quaternion, b: Quaternion): Float {
|
||||
* @param a The beginning value
|
||||
* @param b The ending value
|
||||
* @param t The ratio between the two floats
|
||||
* @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.
|
||||
* @param valueEps Prevent blowing up when slerping between two quaternions that are very near each
|
||||
* other. Linear interpolation (lerp) is returned in this case.
|
||||
*
|
||||
* @return Interpolated value between the two floats
|
||||
*/
|
||||
fun slerp(a: Quaternion, b: Quaternion, t: Float, dotThreshold: Float = 0.9995f): Quaternion {
|
||||
fun slerp(a: Quaternion, b: Quaternion, t: Float, valueEps: Float = 0.0000000001f): Quaternion {
|
||||
// could also be computed as: pow(q * inverse(p), t) * p;
|
||||
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
|
||||
}
|
||||
|
||||
val d = dot(a, b)
|
||||
val absd = abs(d)
|
||||
// Prevent blowing up when slerping between two quaternions that are very near each other.
|
||||
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)
|
||||
if ((1.0f - absd) < valueEps) {
|
||||
return normalize(lerp(if (d < 0.0f) -a else a, b, 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.0f - t) * a) + (t * b)
|
||||
return ((1 - t) * a) + (t * b)
|
||||
}
|
||||
|
||||
fun nlerp(a: Quaternion, b: Quaternion, t: Float): Quaternion {
|
||||
@@ -497,12 +324,19 @@ fun nlerp(a: Quaternion, b: Quaternion, t: Float): Quaternion {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a Quaternion to Euler angles
|
||||
* Convert a Quaternion to Euler angles using YPR around ZYX respectively
|
||||
*
|
||||
* @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.
|
||||
* The Euler angles are applied in ZYX order
|
||||
*/
|
||||
fun eulerAngles(q: Quaternion, order: RotationsOrder = RotationsOrder.ZYX): Float3 {
|
||||
return eulerAngles(rotation(q), order)
|
||||
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)))
|
||||
}
|
||||
|
||||
@@ -28,21 +28,12 @@ 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
|
||||
|
||||
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 clamp(x: Float, min: Float, max: Float)= 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)
|
||||
@@ -51,6 +42,4 @@ 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.utils
|
||||
package com.google.android.filament.textured
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.graphics.Bitmap
|
||||
|
||||
@@ -22,8 +22,6 @@ 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,
|
||||
@@ -126,23 +124,11 @@ 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)
|
||||
@@ -305,14 +291,6 @@ 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)
|
||||
@@ -323,14 +301,6 @@ 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)
|
||||
@@ -564,15 +534,6 @@ 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)
|
||||
@@ -588,15 +549,6 @@ 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)
|
||||
@@ -614,12 +566,6 @@ 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
|
||||
@@ -637,11 +583,6 @@ 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),
|
||||
@@ -685,25 +626,10 @@ 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, 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 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 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)
|
||||
@@ -749,11 +675,6 @@ 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),
|
||||
@@ -801,29 +722,10 @@ 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, 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 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 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)
|
||||
@@ -905,44 +807,17 @@ 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 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 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: Float) = Bool4(x < b, y < b, z < b, a < 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)
|
||||
@@ -1402,753 +1277,3 @@ 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)
|
||||
|
||||
@@ -11,10 +11,6 @@ add_library(dracodec STATIC IMPORTED)
|
||||
set_target_properties(dracodec PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libdracodec.a)
|
||||
|
||||
add_library(meshoptimizer STATIC IMPORTED)
|
||||
set_target_properties(meshoptimizer PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libmeshoptimizer.a)
|
||||
|
||||
add_library(ktxreader STATIC IMPORTED)
|
||||
set_target_properties(ktxreader PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libktxreader.a)
|
||||
@@ -80,7 +76,7 @@ set(GLTFIO_SRCS
|
||||
${GLTFIO_DIR}/src/UbershaderProvider.cpp
|
||||
${GLTFIO_DIR}/src/Wireframe.cpp
|
||||
${GLTFIO_DIR}/src/Wireframe.h
|
||||
${GLTFIO_DIR}/src/downcast.h
|
||||
${GLTFIO_DIR}/src/upcast.h
|
||||
|
||||
src/main/cpp/Animator.cpp
|
||||
src/main/cpp/AssetLoader.cpp
|
||||
@@ -103,7 +99,6 @@ set(GLTFIO_INCLUDE_DIRS
|
||||
../../libs/gltfio/include
|
||||
../../third_party/basisu/zstd
|
||||
../../third_party/cgltf
|
||||
../../third_party/meshoptimizer/src
|
||||
../../third_party/robin-map
|
||||
../../third_party/hat-trie
|
||||
../../third_party/stb
|
||||
@@ -116,7 +111,7 @@ target_include_directories(gltfio-jni PRIVATE ${GLTFIO_INCLUDE_DIRS})
|
||||
set_target_properties(gltfio-jni PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.symbols)
|
||||
set_target_properties(gltfio-jni PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.map)
|
||||
target_link_libraries(gltfio-jni filament-jni utils uberzlib log stb ktxreader basis_transcoder zstd uberarchive)
|
||||
target_link_libraries(gltfio-jni dracodec meshoptimizer)
|
||||
target_link_libraries(gltfio-jni dracodec)
|
||||
target_compile_definitions(gltfio-jni PUBLIC GLTFIO_DRACO_SUPPORTED=1)
|
||||
target_include_directories(gltfio-jni PRIVATE ${DRACO_DIR}/src)
|
||||
target_include_directories(gltfio-jni PRIVATE ${DRACO_DIR}/tnt)
|
||||
|
||||
@@ -16,13 +16,6 @@ android {
|
||||
excludes += ['lib/*/libfilament-jni.so']
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
singleVariant("fullRelease") {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -14,4 +14,5 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" />
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.gltfio" />
|
||||
|
||||
@@ -42,7 +42,6 @@ class JavaMaterialProvider : public MaterialProvider {
|
||||
|
||||
jmethodID mMaterialKeyConstructor;
|
||||
jmethodID mCreateMaterialInstance;
|
||||
jmethodID mGetMaterial;
|
||||
jmethodID mGetMaterials;
|
||||
jmethodID mNeedsDummyData;
|
||||
jmethodID mDestroyMaterials;
|
||||
@@ -73,10 +72,6 @@ public:
|
||||
"(L" JAVA_MATERIAL_KEY ";[ILjava/lang/String;Ljava/lang/String;)Lcom/google/android/filament/MaterialInstance;");
|
||||
assert_invariant(mCreateMaterialInstance);
|
||||
|
||||
mGetMaterial = env->GetMethodID(providerClass, "getMaterial",
|
||||
"(L" JAVA_MATERIAL_KEY ";[ILjava/lang/String;)Lcom/google/android/filament/Material;");
|
||||
assert_invariant(mGetMaterial);
|
||||
|
||||
mGetMaterials = env->GetMethodID(providerClass, "getMaterials",
|
||||
"()[Lcom/google/android/filament/Material;");
|
||||
assert_invariant(mGetMaterials);
|
||||
@@ -108,7 +103,7 @@ public:
|
||||
jstring stringExtras = extras ? mEnv->NewStringUTF(extras) : nullptr;
|
||||
|
||||
// Allocate space for the output argument.
|
||||
jintArray uvMapArray = mEnv->NewIntArray(uvmap->size());
|
||||
jintArray uvMapArray = mEnv->NewIntArray(8);
|
||||
|
||||
// Call the Java-based material provider.
|
||||
jobject materialInstance = mEnv->CallObjectMethod(mJavaProvider, mCreateMaterialInstance,
|
||||
@@ -144,49 +139,6 @@ public:
|
||||
return (MaterialInstance*) mEnv->CallLongMethod(materialInstance, mMaterialInstanceGetNativeObject);
|
||||
}
|
||||
|
||||
Material* getMaterial(MaterialKey* config, UvMap* uvmap, const char* label) override {
|
||||
// Create a Java object for the material key and copy the native fields into it.
|
||||
jobject javaKey = mEnv->NewObject(mMaterialKeyClass, mMaterialKeyConstructor);
|
||||
|
||||
auto& helper = MaterialKeyHelper::get();
|
||||
helper.copy(mEnv, javaKey, *config);
|
||||
|
||||
// Convert the optional label into a Java string.
|
||||
jstring stringLabel = label ? mEnv->NewStringUTF(label) : nullptr;
|
||||
|
||||
// Allocate space for the output argument.
|
||||
jintArray uvMapArray = mEnv->NewIntArray(uvmap->size());
|
||||
|
||||
// Call the Java-based material provider.
|
||||
jobject material = mEnv->CallObjectMethod(mJavaProvider, mGetMaterial,
|
||||
javaKey, uvMapArray, stringLabel);
|
||||
|
||||
// Copy the UvMap results from the JVM array into the native array.
|
||||
if (uvmap) {
|
||||
jint* elements = mEnv->GetIntArrayElements(uvMapArray, nullptr);
|
||||
for (size_t i = 0; i < uvmap->size(); i++) {
|
||||
(*uvmap)[i] = (UvSet) elements[i];
|
||||
}
|
||||
mEnv->ReleaseIntArrayElements(uvMapArray, elements, JNI_ABORT);
|
||||
}
|
||||
|
||||
// The config parameter is an in-out parameter so we need to copy the results from Java.
|
||||
helper.copy(mEnv, *config, javaKey);
|
||||
|
||||
mEnv->DeleteLocalRef(javaKey);
|
||||
mEnv->DeleteLocalRef(uvMapArray);
|
||||
|
||||
if (stringLabel) {
|
||||
mEnv->DeleteLocalRef(stringLabel);
|
||||
}
|
||||
|
||||
if (material == nullptr) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return (Material*) mEnv->CallLongMethod(material, mMaterialGetNativeObject);
|
||||
}
|
||||
|
||||
const Material* const* getMaterials() const noexcept override {
|
||||
jobjectArray javaMaterials = (jobjectArray) mEnv->CallObjectMethod(mJavaProvider, mGetMaterials);
|
||||
|
||||
@@ -255,11 +207,20 @@ Java_com_google_android_filament_gltfio_AssetLoader_nDestroyAssetLoader(JNIEnv*,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nCreateAsset(JNIEnv* env, jclass,
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetFromBinary(JNIEnv* env, jclass,
|
||||
jlong nativeLoader, jobject javaBuffer, jint remaining) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
return (jlong) loader->createAsset((const uint8_t *) buffer.getData(),
|
||||
return (jlong) loader->createAssetFromBinary((const uint8_t *) buffer.getData(),
|
||||
buffer.getSize());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetFromJson(JNIEnv* env, jclass,
|
||||
jlong nativeLoader, jobject javaBuffer, jint remaining) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
return (jlong) loader->createAssetFromJson((const uint8_t *) buffer.getData(),
|
||||
buffer.getSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -172,6 +172,27 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetCameraEntityCount(JNIE
|
||||
return asset->getCameraEntityCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMaterialInstanceCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return asset->getMaterialInstanceCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMaterialInstances(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jlongArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
jsize count = std::min(available, (jsize) asset->getMaterialInstanceCount());
|
||||
jlong* dst = env->GetLongArrayElements(result, nullptr);
|
||||
const MaterialInstance * const* src = asset->getMaterialInstances();
|
||||
for (jsize i = 0; i < count; i++) {
|
||||
dst[i] = (jlong) src[i];
|
||||
}
|
||||
env->ReleaseLongArrayElements(result, dst, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetBoundingBox(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jfloatArray result) {
|
||||
@@ -207,11 +228,49 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetExtras(JNIEnv* env, jc
|
||||
return val ? env->NewStringUTF(val) : nullptr;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetInstance(JNIEnv* , jclass,
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetSkinCount(JNIEnv* , jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return (jlong) asset->getInstance();
|
||||
return (jint) asset->getSkinCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetSkinNames(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jobjectArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
for (int i = 0; i < available; ++i) {
|
||||
const char* name = asset->getSkinNameAt(i);
|
||||
if (name) {
|
||||
env->SetObjectArrayElement(result, (jsize) i, env->NewStringUTF(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetJointCountAt(JNIEnv* , jclass,
|
||||
jlong nativeAsset, jint skinIndex) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return (jint) asset->getJointCountAt(skinIndex);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetJointsAt(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint skinIndex, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getJointsAt(skinIndex),
|
||||
std::min(available, (jsize) asset->getJointCountAt(skinIndex)), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetAnimator(JNIEnv* , jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return (jlong) asset->getAnimator();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
@@ -251,9 +310,49 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetMorphTargetNames(JNIEn
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMaterialVariantCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return (jint) asset->getMaterialVariantCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetMaterialVariantNames(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jobjectArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
for (int i = 0; i < asset->getMaterialVariantCount(); ++i) {
|
||||
const char* name = asset->getMaterialVariantName(i);
|
||||
env->SetObjectArrayElement(result, (jsize) i, env->NewStringUTF(name));
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nApplyMaterialVariant(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint variantIndex) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
asset->applyMaterialVariant(variantIndex);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nReleaseSourceData(JNIEnv* env, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
asset->releaseSourceData();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nAttachSkin(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint skinIndex, jint targetEntity) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
Entity target = Entity::import(targetEntity);
|
||||
asset->attachSkin(skinIndex, target);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nDetachSkin(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint skinIndex, jint targetEntity) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
Entity target = Entity::import(targetEntity);
|
||||
asset->detachSkin(skinIndex, target);
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::gltfio;
|
||||
using namespace utils;
|
||||
|
||||
@@ -62,95 +61,3 @@ Java_com_google_android_filament_gltfio_FilamentInstance_nApplyMaterialVariant(J
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
instance->applyMaterialVariant(variantIndex);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetMaterialVariantCount(JNIEnv*, jclass,
|
||||
jlong nativeInstance) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
return (jint) instance->getMaterialVariantCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetMaterialVariantNames(JNIEnv* env, jclass,
|
||||
jlong nativeInstance, jobjectArray result) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
for (int i = 0; i < instance->getMaterialVariantCount(); ++i) {
|
||||
const char* name = instance->getMaterialVariantName(i);
|
||||
env->SetObjectArrayElement(result, (jsize) i, env->NewStringUTF(name));
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetMaterialInstanceCount(JNIEnv*, jclass,
|
||||
jlong nativeInstance) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
return instance->getMaterialInstanceCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetMaterialInstances(JNIEnv* env, jclass,
|
||||
jlong nativeInstance, jlongArray result) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
jsize count = std::min(available, (jsize) instance->getMaterialInstanceCount());
|
||||
jlong* dst = env->GetLongArrayElements(result, nullptr);
|
||||
const MaterialInstance * const* src = instance->getMaterialInstances();
|
||||
for (jsize i = 0; i < count; i++) {
|
||||
dst[i] = (jlong) src[i];
|
||||
}
|
||||
env->ReleaseLongArrayElements(result, dst, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nAttachSkin(JNIEnv* env, jclass,
|
||||
jlong nativeInstance, jint skinIndex, jint targetEntity) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
Entity target = Entity::import(targetEntity);
|
||||
instance->attachSkin(skinIndex, target);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nDetachSkin(JNIEnv* env, jclass,
|
||||
jlong nativeInstance, jint skinIndex, jint targetEntity) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
Entity target = Entity::import(targetEntity);
|
||||
instance->detachSkin(skinIndex, target);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetSkinCount(JNIEnv* , jclass,
|
||||
jlong nativeInstance) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
return (jint) instance->getSkinCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetSkinNames(JNIEnv* env, jclass,
|
||||
jlong nativeInstance, jobjectArray result) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
for (int i = 0; i < available; ++i) {
|
||||
const char* name = instance->getSkinNameAt(i);
|
||||
if (name) {
|
||||
env->SetObjectArrayElement(result, (jsize) i, env->NewStringUTF(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetJointCountAt(JNIEnv* , jclass,
|
||||
jlong nativeInstance, jint skinIndex) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
return (jint) instance->getJointCountAt(skinIndex);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetJointsAt(JNIEnv* env, jclass,
|
||||
jlong nativeInstance, jint skinIndex, jintArray result) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(instance->getJointsAt(skinIndex),
|
||||
std::min(available, (jsize) instance->getJointCountAt(skinIndex)), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,11 @@ static void destroy(void*, size_t, void *userData) {
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nCreateResourceLoader(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jboolean normalizeSkinningWeights) {
|
||||
jlong nativeEngine, jboolean normalizeSkinningWeights, jboolean recomputeBoundingBoxes,
|
||||
jboolean ignoreBindTransform) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) new ResourceLoader({ engine, {}, (bool) normalizeSkinningWeights});
|
||||
return (jlong) new ResourceLoader({ engine, {}, (bool) normalizeSkinningWeights,
|
||||
(bool) recomputeBoundingBoxes, (bool) ignoreBindTransform});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
|
||||
@@ -49,46 +49,6 @@ Java_com_google_android_filament_gltfio_UbershaderProvider_nDestroyMaterials(JNI
|
||||
|
||||
extern "C" JNIEXPORT long JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nCreateMaterialInstance(JNIEnv* env, jclass,
|
||||
jlong nativeProvider, jobject materialKey, jintArray uvmap, jstring label, jstring extras) {
|
||||
MaterialKey nativeKey = {};
|
||||
|
||||
auto& helper = MaterialKeyHelper::get();
|
||||
helper.copy(env, nativeKey, materialKey);
|
||||
|
||||
const char* nativeLabel = label ? env->GetStringUTFChars(label, nullptr) : nullptr;
|
||||
const char* nativeExtras = extras ? env->GetStringUTFChars(extras, nullptr) : nullptr;
|
||||
|
||||
UvMap nativeUvMap = {};
|
||||
auto provider = (MaterialProvider*) nativeProvider;
|
||||
MaterialInstance* instance = provider->createMaterialInstance(&nativeKey, &nativeUvMap,
|
||||
nativeLabel, nativeExtras);
|
||||
|
||||
// Copy the UvMap results from the native array into the JVM array.
|
||||
jint* elements = env->GetIntArrayElements(uvmap, nullptr);
|
||||
if (elements) {
|
||||
const size_t javaSize = env->GetArrayLength(uvmap);
|
||||
for (int i = 0, n = std::min(javaSize, nativeUvMap.size()); i < n; ++i) {
|
||||
elements[i] = nativeUvMap[i];
|
||||
}
|
||||
env->ReleaseIntArrayElements(uvmap, elements, 0);
|
||||
}
|
||||
|
||||
// The config parameter is an in-out parameter so we need to copy the results back to Java.
|
||||
helper.copy(env, materialKey, nativeKey);
|
||||
|
||||
if (label) {
|
||||
env->ReleaseStringUTFChars(label, nativeLabel);
|
||||
}
|
||||
|
||||
if (extras) {
|
||||
env->ReleaseStringUTFChars(extras, nativeExtras);
|
||||
}
|
||||
|
||||
return (long) instance;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT long JNICALL
|
||||
Java_com_google_android_filament_gltfio_UbershaderProvider_nGetMaterial(JNIEnv* env, jclass,
|
||||
jlong nativeProvider, jobject materialKey, jintArray uvmap, jstring label) {
|
||||
MaterialKey nativeKey = {};
|
||||
|
||||
@@ -96,10 +56,9 @@ Java_com_google_android_filament_gltfio_UbershaderProvider_nGetMaterial(JNIEnv*
|
||||
helper.copy(env, nativeKey, materialKey);
|
||||
|
||||
const char* nativeLabel = label ? env->GetStringUTFChars(label, nullptr) : nullptr;
|
||||
|
||||
UvMap nativeUvMap = {};
|
||||
auto provider = (MaterialProvider*) nativeProvider;
|
||||
Material* material = provider->getMaterial(&nativeKey, &nativeUvMap, nativeLabel);
|
||||
MaterialInstance* instance = provider->createMaterialInstance(&nativeKey, &nativeUvMap, nativeLabel);
|
||||
|
||||
// Copy the UvMap results from the native array into the JVM array.
|
||||
jint* elements = env->GetIntArrayElements(uvmap, nullptr);
|
||||
@@ -118,7 +77,7 @@ Java_com_google_android_filament_gltfio_UbershaderProvider_nGetMaterial(JNIEnv*
|
||||
env->ReleaseStringUTFChars(label, nativeLabel);
|
||||
}
|
||||
|
||||
return (long) material;
|
||||
return (long) instance;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT int JNICALL
|
||||
|
||||
@@ -26,8 +26,8 @@ import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* Consumes a blob of glTF 2.0 content (either JSON or GLB) and produces a {@link FilamentAsset}
|
||||
* object, which is a bundle of Filament textures, vertex buffers, index buffers, etc. An asset is
|
||||
* composed of 1 or more FilamentInstance objects which contain entities and components.
|
||||
* object, which is a bundle of Filament entities, material instances, textures, vertex buffers,
|
||||
* and index buffers.
|
||||
*
|
||||
* <p>AssetLoader does not fetch external buffer data or create textures on its own. Clients can use
|
||||
* the provided {@link ResourceLoader} class for this, which obtains the URI list from the asset.
|
||||
@@ -51,7 +51,7 @@ import java.nio.Buffer;
|
||||
* filamentAsset = assets.open("models/lucy.gltf").use { input ->
|
||||
* val bytes = ByteArray(input.available())
|
||||
* input.read(bytes)
|
||||
* assetLoader.createAsset(ByteBuffer.wrap(bytes))!!
|
||||
* assetLoader.createAssetFromJson(ByteBuffer.wrap(bytes))!!
|
||||
* }
|
||||
*
|
||||
* val resourceLoader = ResourceLoader(engine)
|
||||
@@ -115,11 +115,20 @@ public class AssetLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link FilamentAsset} from the contents of a GLB or GLTF file.
|
||||
* Creates a {@link FilamentAsset} from the contents of a GLB file.
|
||||
*/
|
||||
@Nullable
|
||||
public FilamentAsset createAsset(@NonNull Buffer buffer) {
|
||||
long nativeAsset = nCreateAsset(mNativeObject, buffer, buffer.remaining());
|
||||
public FilamentAsset createAssetFromBinary(@NonNull Buffer buffer) {
|
||||
long nativeAsset = nCreateAssetFromBinary(mNativeObject, buffer, buffer.remaining());
|
||||
return nativeAsset != 0 ? new FilamentAsset(mEngine, nativeAsset) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link FilamentAsset} from the contents of a GLTF file.
|
||||
*/
|
||||
@Nullable
|
||||
public FilamentAsset createAssetFromJson(@NonNull Buffer buffer) {
|
||||
long nativeAsset = nCreateAssetFromJson(mNativeObject, buffer, buffer.remaining());
|
||||
return nativeAsset != 0 ? new FilamentAsset(mEngine, nativeAsset) : null;
|
||||
}
|
||||
|
||||
@@ -149,7 +158,7 @@ public class AssetLoader {
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new instance to the asset.
|
||||
* Adds a new instance to an instanced asset.
|
||||
*
|
||||
* Use this with caution. It is more efficient to pre-allocate a max number of instances, and
|
||||
* gradually add them to the scene as needed. Instances can also be "recycled" by removing and
|
||||
@@ -160,6 +169,8 @@ public class AssetLoader {
|
||||
* create/destroy churn, as noted above.
|
||||
*
|
||||
* This cannot be called after FilamentAsset#releaseSourceData().
|
||||
* This cannot be called on a non-instanced asset.
|
||||
* Animation is not supported in new instances.
|
||||
* See also AssetLoader#createInstancedAsset().
|
||||
*/
|
||||
@Nullable
|
||||
@@ -191,7 +202,8 @@ public class AssetLoader {
|
||||
private static native long nCreateAssetLoader(long nativeEngine, Object provider,
|
||||
long nativeEntities);
|
||||
private static native void nDestroyAssetLoader(long nativeLoader);
|
||||
private static native long nCreateAsset(long nativeLoader, Buffer buffer, int remaining);
|
||||
private static native long nCreateAssetFromBinary(long nativeLoader, Buffer buffer, int remaining);
|
||||
private static native long nCreateAssetFromJson(long nativeLoader, Buffer buffer, int remaining);
|
||||
private static native long nCreateInstancedAsset(long nativeLoader, Buffer buffer, int remaining,
|
||||
long[] nativeInstances);
|
||||
private static native long nCreateInstance(long nativeLoader, long nativeAsset);
|
||||
|
||||
@@ -23,6 +23,7 @@ import androidx.annotation.Nullable;
|
||||
import com.google.android.filament.Box;
|
||||
import com.google.android.filament.Engine;
|
||||
import com.google.android.filament.Entity;
|
||||
import com.google.android.filament.MaterialInstance;
|
||||
|
||||
/**
|
||||
* Owns a bundle of Filament objects that have been created by <code>AssetLoader</code>.
|
||||
@@ -34,32 +35,25 @@ import com.google.android.filament.Entity;
|
||||
* <code>NameComponentManager</code>, <code>RenderableManager</code>, and others.</p>
|
||||
*
|
||||
* <p>In addition to the aforementioned entities, an asset has strong ownership over a list of
|
||||
* <code>VertexBuffer</code>, <code>IndexBuffer</code>, and <code>Texture</code>.</p>
|
||||
* <code>VertexBuffer</code>, <code>IndexBuffer</code>, <code>MaterialInstance</code>, and
|
||||
* <code>Texture</code>.</p>
|
||||
*
|
||||
* <p>Clients can use {@link ResourceLoader} to create textures, compute tangent quaternions, and
|
||||
* upload data into vertex buffers and index buffers.</p>
|
||||
*
|
||||
* @see ResourceLoader
|
||||
* @see FilamentInstance
|
||||
* @see Animator
|
||||
* @see AssetLoader
|
||||
*/
|
||||
public class FilamentAsset {
|
||||
private long mNativeObject;
|
||||
private FilamentInstance mPrimaryInstance;
|
||||
private Animator mAnimator;
|
||||
private Engine mEngine;
|
||||
|
||||
FilamentAsset(Engine engine, long nativeObject) {
|
||||
mEngine = engine;
|
||||
mNativeObject = nativeObject;
|
||||
}
|
||||
|
||||
public FilamentInstance getInstance() {
|
||||
if (mPrimaryInstance != null) {
|
||||
return mPrimaryInstance;
|
||||
}
|
||||
long nativeInstance = nGetInstance(getNativeObject());
|
||||
mPrimaryInstance = new FilamentInstance(this, nativeInstance);
|
||||
return mPrimaryInstance;
|
||||
mAnimator = null;
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
@@ -175,11 +169,19 @@ public class FilamentAsset {
|
||||
return result;
|
||||
}
|
||||
|
||||
public @NonNull MaterialInstance[] getMaterialInstances() {
|
||||
final int count = nGetMaterialInstanceCount(mNativeObject);
|
||||
MaterialInstance[] result = new MaterialInstance[count];
|
||||
long[] natives = new long[count];
|
||||
nGetMaterialInstances(mNativeObject, natives);
|
||||
for (int i = 0; i < count; i++) {
|
||||
result[i] = new MaterialInstance(mEngine, natives[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bounding box computed from the supplied min / max values in glTF accessors.
|
||||
*
|
||||
* This does not return a bounding box over all FilamentInstance, it's just a straightforward
|
||||
* AAAB that can be determined at load time from the asset data.
|
||||
*/
|
||||
public @NonNull Box getBoundingBox() {
|
||||
float[] box = new float[6];
|
||||
@@ -204,6 +206,77 @@ public class FilamentAsset {
|
||||
return nGetExtras(mNativeObject, entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the <code>Animator</code> interface for this asset.
|
||||
*
|
||||
* <p>When calling this for the first time, this must be called after
|
||||
* {@link ResourceLoader#loadResources} or {@link ResourceLoader#asyncBeginLoad}. When the asset
|
||||
* is destroyed, its animator becomes invalid.</p>
|
||||
*/
|
||||
public @NonNull Animator getAnimator() {
|
||||
if (mAnimator != null) {
|
||||
return mAnimator;
|
||||
}
|
||||
long nativeAnimator = nGetAnimator(getNativeObject());
|
||||
if (nativeAnimator == 0) {
|
||||
throw new IllegalStateException("Unable to create animator");
|
||||
}
|
||||
mAnimator = new Animator(nativeAnimator);
|
||||
return mAnimator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skin count of this asset.
|
||||
*/
|
||||
public int getSkinCount() {
|
||||
return nGetSkinCount(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skin name at skin index in this asset.
|
||||
*/
|
||||
public @NonNull String[] getSkinNames() {
|
||||
String[] result = new String[getSkinCount()];
|
||||
nGetSkinNames(getNativeObject(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the given skin to the given node, which must have an associated mesh with
|
||||
* BONE_INDICES and BONE_WEIGHTS attributes.
|
||||
*
|
||||
* This is a no-op if the given skin index or target is invalid.
|
||||
*/
|
||||
public void attachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) {
|
||||
nAttachSkin(getNativeObject(), skinIndex, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the given skin to the given node, which must have an associated mesh with
|
||||
* BONE_INDICES and BONE_WEIGHTS attributes.
|
||||
*
|
||||
* This is a no-op if the given skin index or target is invalid.
|
||||
*/
|
||||
public void detachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) {
|
||||
nDetachSkin(getNativeObject(), skinIndex, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the joint count at skin index in this asset.
|
||||
*/
|
||||
public int getJointCountAt(@IntRange(from = 0) int skinIndex) {
|
||||
return nGetJointCountAt(getNativeObject(), skinIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets joints at skin index in this asset.
|
||||
*/
|
||||
public @NonNull @Entity int[] getJointsAt(@IntRange(from = 0) int skinIndex) {
|
||||
int[] result = new int[getJointCountAt(skinIndex)];
|
||||
nGetJointsAt(getNativeObject(), skinIndex, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the names of all morph targets in the given entity.
|
||||
*/
|
||||
@@ -222,6 +295,31 @@ public class FilamentAsset {
|
||||
return uris;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of all material variants.
|
||||
*/
|
||||
public @NonNull String[] getMaterialVariantNames() {
|
||||
String[] names = new String[nGetMaterialVariantCount(mNativeObject)];
|
||||
nGetMaterialVariantNames(mNativeObject, names);
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given material variant to all primitives that it affects.
|
||||
*
|
||||
* This is efficient because it merely swaps around persistent MaterialInstances. If you change
|
||||
* a material parameter while a certain variant is active, the updated value will be remembered
|
||||
* after you re-apply that variant.
|
||||
*
|
||||
* If the asset is instanced, this affects all instances in the same way.
|
||||
* To set the variant on an individual instance, use FilamentInstance#applyMaterialVariant.
|
||||
*
|
||||
* Ignored if variantIndex is out of bounds.
|
||||
*/
|
||||
public void applyMaterialVariant(@IntRange(from = 0) int variantIndex) {
|
||||
nApplyMaterialVariant(getNativeObject(), variantIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reclaims CPU-side memory for URI strings, binding lists, and raw animation data.
|
||||
*
|
||||
@@ -233,10 +331,8 @@ public class FilamentAsset {
|
||||
nReleaseSourceData(mNativeObject);
|
||||
}
|
||||
|
||||
public Engine getEngine() { return mEngine; }
|
||||
|
||||
void clearNativeObject() {
|
||||
mPrimaryInstance = null;
|
||||
if (mAnimator != null) mAnimator.clearNativeObject();
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
@@ -260,17 +356,28 @@ public class FilamentAsset {
|
||||
private static native int nGetCameraEntityCount(long nativeAsset);
|
||||
private static native void nGetCameraEntities(long nativeAsset, int[] result);
|
||||
|
||||
private static native int nGetMaterialInstanceCount(long nativeAsset);
|
||||
private static native void nGetMaterialInstances(long nativeAsset, long[] nativeResults);
|
||||
|
||||
private static native int nGetMaterialVariantCount(long nativeAsset);
|
||||
private static native void nGetMaterialVariantNames(long nativeAsset, String[] result);
|
||||
|
||||
private static native int nGetMorphTargetCount(long nativeAsset, int entity);
|
||||
private static native void nGetMorphTargetNames(long nativeAsset, int entity, String[] result);
|
||||
|
||||
private static native void nAttachSkin(long nativeAsset, int skinIndex, int entity);
|
||||
private static native void nDetachSkin(long nativeAsset, int skinIndex, int entity);
|
||||
|
||||
private static native void nGetBoundingBox(long nativeAsset, float[] box);
|
||||
private static native String nGetName(long nativeAsset, int entity);
|
||||
private static native String nGetExtras(long nativeAsset, int entity);
|
||||
|
||||
private static native long nGetInstance(long nativeAsset);
|
||||
|
||||
private static native long nGetAnimator(long nativeAsset);
|
||||
private static native void nApplyMaterialVariant(long nativeAsset, int variantIndex);
|
||||
private static native int nGetSkinCount(long nativeAsset);
|
||||
private static native void nGetSkinNames(long nativeAsset, String[] result);
|
||||
private static native int nGetJointCountAt(long nativeAsset, int skinIndex);
|
||||
private static native void nGetJointsAt(long nativeAsset, int skinIndex, int[] result);
|
||||
private static native int nGetResourceUriCount(long nativeAsset);
|
||||
private static native void nGetResourceUris(long nativeAsset, String[] result);
|
||||
|
||||
private static native void nReleaseSourceData(long nativeAsset);
|
||||
}
|
||||
|
||||
@@ -19,9 +19,7 @@ package com.google.android.filament.gltfio;
|
||||
import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.filament.Engine;
|
||||
import com.google.android.filament.Entity;
|
||||
import com.google.android.filament.MaterialInstance;
|
||||
|
||||
/**
|
||||
* Provides access to a hierarchy of entities that have been instanced from a glTF asset.
|
||||
@@ -87,58 +85,6 @@ public class FilamentInstance {
|
||||
return mAnimator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skin count of this instance.
|
||||
*/
|
||||
public int getSkinCount() {
|
||||
return nGetSkinCount(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the skin name at skin index in this instance.
|
||||
*/
|
||||
public @NonNull String[] getSkinNames() {
|
||||
String[] result = new String[getSkinCount()];
|
||||
nGetSkinNames(getNativeObject(), result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the given skin to the given node, which must have an associated mesh with
|
||||
* BONE_INDICES and BONE_WEIGHTS attributes.
|
||||
*
|
||||
* This is a no-op if the given skin index or target is invalid.
|
||||
*/
|
||||
public void attachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) {
|
||||
nAttachSkin(getNativeObject(), skinIndex, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Attaches the given skin to the given node, which must have an associated mesh with
|
||||
* BONE_INDICES and BONE_WEIGHTS attributes.
|
||||
*
|
||||
* This is a no-op if the given skin index or target is invalid.
|
||||
*/
|
||||
public void detachSkin(@IntRange(from = 0) int skinIndex, @Entity int target) {
|
||||
nDetachSkin(getNativeObject(), skinIndex, target);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the joint count at skin index in this instance.
|
||||
*/
|
||||
public int getJointCountAt(@IntRange(from = 0) int skinIndex) {
|
||||
return nGetJointCountAt(getNativeObject(), skinIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets joints at skin index in this instance.
|
||||
*/
|
||||
public @NonNull @Entity int[] getJointsAt(@IntRange(from = 0) int skinIndex) {
|
||||
int[] result = new int[getJointCountAt(skinIndex)];
|
||||
nGetJointsAt(getNativeObject(), skinIndex, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies the given material variant to all primitives in this instance.
|
||||
*
|
||||
@@ -148,43 +94,9 @@ public class FilamentInstance {
|
||||
nApplyMaterialVariant(mNativeObject, variantIndex);
|
||||
}
|
||||
|
||||
public @NonNull MaterialInstance[] getMaterialInstances() {
|
||||
final int count = nGetMaterialInstanceCount(mNativeObject);
|
||||
MaterialInstance[] result = new MaterialInstance[count];
|
||||
long[] natives = new long[count];
|
||||
nGetMaterialInstances(mNativeObject, natives);
|
||||
Engine engine = mAsset.getEngine();
|
||||
for (int i = 0; i < count; i++) {
|
||||
result[i] = new MaterialInstance(engine, natives[i]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the names of all material variants.
|
||||
*/
|
||||
public @NonNull String[] getMaterialVariantNames() {
|
||||
String[] names = new String[nGetMaterialVariantCount(mNativeObject)];
|
||||
nGetMaterialVariantNames(mNativeObject, names);
|
||||
return names;
|
||||
}
|
||||
|
||||
private static native int nGetRoot(long nativeInstance);
|
||||
private static native int nGetEntityCount(long nativeInstance);
|
||||
private static native void nGetEntities(long nativeInstance, int[] result);
|
||||
private static native long nGetAnimator(long nativeInstance);
|
||||
|
||||
private static native int nGetMaterialInstanceCount(long nativeAsset);
|
||||
private static native void nGetMaterialInstances(long nativeAsset, long[] nativeResults);
|
||||
|
||||
private static native void nApplyMaterialVariant(long nativeInstance, int variantIndex);
|
||||
private static native int nGetMaterialVariantCount(long nativeAsset);
|
||||
private static native void nGetMaterialVariantNames(long nativeAsset, String[] result);
|
||||
|
||||
private static native void nGetJointsAt(long nativeInstance, int skinIndex, int[] result);
|
||||
private static native int nGetSkinCount(long nativeInstance);
|
||||
private static native void nGetSkinNames(long nativeInstance, String[] result);
|
||||
private static native int nGetJointCountAt(long nativeInstance, int skinIndex);
|
||||
private static native void nAttachSkin(long nativeInstance, int skinIndex, int entity);
|
||||
private static native void nDetachSkin(long nativeInstance, int skinIndex, int entity);
|
||||
private static native int nGetRoot(long nativeAsset);
|
||||
private static native int nGetEntityCount(long nativeAsset);
|
||||
private static native void nGetEntities(long nativeAsset, int[] result);
|
||||
private static native long nGetAnimator(long nativeAsset);
|
||||
private static native void nApplyMaterialVariant(long nativeAsset, int variantIndex);
|
||||
}
|
||||
|
||||
@@ -24,85 +24,47 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.Size;
|
||||
|
||||
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() {}
|
||||
@@ -142,12 +104,6 @@ public interface MaterialProvider {
|
||||
public @Nullable MaterialInstance createMaterialInstance(MaterialKey config,
|
||||
@NonNull @Size(min = 8) int[] uvmap, @Nullable String label, @Nullable String extras);
|
||||
|
||||
/**
|
||||
* Creates or fetches a compiled Filament material corresponding to the given config.
|
||||
*/
|
||||
public @Nullable Material getMaterial(MaterialKey config, @NonNull @Size(min = 8) int[] uvmap,
|
||||
@Nullable String label);
|
||||
|
||||
/**
|
||||
* Creates and returns an array containing all cached materials.
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,7 @@ public class ResourceLoader {
|
||||
*/
|
||||
public ResourceLoader(@NonNull Engine engine) {
|
||||
long nativeEngine = engine.getNativeObject();
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine, false);
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine, false, false, false);
|
||||
mNativeStbProvider = nCreateStbProvider(nativeEngine);
|
||||
mNativeKtx2Provider = nCreateKtx2Provider(nativeEngine);
|
||||
nAddTextureProvider(mNativeObject, "image/jpeg", mNativeStbProvider);
|
||||
@@ -60,12 +60,16 @@ public class ResourceLoader {
|
||||
*
|
||||
* @param engine the engine that gets passed to all builder methods
|
||||
* @param normalizeSkinningWeights scale non-conformant skinning weights so they sum to 1
|
||||
* @param recomputeBoundingBoxes use computed bounding boxes rather than the ones in the asset
|
||||
* @param ignoreBindTransform ignore skinned primitives bind transform when compute bounding boxes
|
||||
* @throws IllegalAccessException
|
||||
* @throws InvocationTargetException
|
||||
*/
|
||||
public ResourceLoader(@NonNull Engine engine, boolean normalizeSkinningWeights) {
|
||||
public ResourceLoader(@NonNull Engine engine, boolean normalizeSkinningWeights,
|
||||
boolean recomputeBoundingBoxes, boolean ignoreBindTransform) {
|
||||
long nativeEngine = engine.getNativeObject();
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine, normalizeSkinningWeights);
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine, normalizeSkinningWeights,
|
||||
recomputeBoundingBoxes, ignoreBindTransform);
|
||||
mNativeStbProvider = nCreateStbProvider(nativeEngine);
|
||||
mNativeKtx2Provider = nCreateKtx2Provider(nativeEngine);
|
||||
nAddTextureProvider(mNativeObject, "image/jpeg", mNativeStbProvider);
|
||||
@@ -177,7 +181,7 @@ public class ResourceLoader {
|
||||
}
|
||||
|
||||
private static native long nCreateResourceLoader(long nativeEngine,
|
||||
boolean normalizeSkinningWeights);
|
||||
boolean normalizeSkinningWeights, boolean recomputeBoundingBoxes, boolean ignoreBindTransform);
|
||||
private static native void nDestroyResourceLoader(long nativeLoader);
|
||||
private static native void nAddResourceData(long nativeLoader, String url, Buffer buffer,
|
||||
int remaining);
|
||||
|
||||
@@ -20,7 +20,6 @@ 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;
|
||||
@@ -58,16 +57,10 @@ public class UbershaderProvider implements MaterialProvider {
|
||||
|
||||
public @Nullable MaterialInstance createMaterialInstance(MaterialKey config,
|
||||
@NonNull @Size(min = 8) int[] uvmap, @Nullable String label, @Nullable String extras) {
|
||||
long nativeMaterialInstance = nCreateMaterialInstance(mNativeObject, config, uvmap, label, extras);
|
||||
long nativeMaterialInstance = nCreateMaterialInstance(mNativeObject, config, uvmap, label);
|
||||
return nativeMaterialInstance == 0 ? null : new MaterialInstance(null, nativeMaterialInstance);
|
||||
}
|
||||
|
||||
public @Nullable Material getMaterial(MaterialKey config, @NonNull @Size(min = 8) int[] uvmap,
|
||||
@Nullable String label) {
|
||||
long nativeMaterial = nGetMaterial(mNativeObject, config, uvmap, label);
|
||||
return nativeMaterial == 0 ? null : new Material(nativeMaterial);
|
||||
}
|
||||
|
||||
public @NonNull Material[] getMaterials() {
|
||||
final int count = nGetMaterialCount(mNativeObject);
|
||||
Material[] result = new Material[count];
|
||||
@@ -95,7 +88,6 @@ public class UbershaderProvider implements MaterialProvider {
|
||||
nDestroyMaterials(mNativeObject);
|
||||
}
|
||||
|
||||
@UsedByNative("AssetLoader.cpp")
|
||||
public long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
@@ -104,8 +96,6 @@ public class UbershaderProvider implements MaterialProvider {
|
||||
private static native void nDestroyUbershaderProvider(long nativeProvider);
|
||||
private static native void nDestroyMaterials(long nativeProvider);
|
||||
private static native long nCreateMaterialInstance(long nativeProvider,
|
||||
MaterialKey config, int[] uvmap, String label, String extras);
|
||||
private static native long nGetMaterial(long nativeProvider,
|
||||
MaterialKey config, int[] uvmap, String label);
|
||||
private static native int nGetMaterialCount(long nativeProvider);
|
||||
private static native void nGetMaterials(long nativeProvider, long[] result);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
GROUP=com.google.android.filament
|
||||
VERSION_NAME=1.42.0
|
||||
VERSION_NAME=1.25.0
|
||||
|
||||
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
|
||||
|
||||
@@ -18,12 +18,11 @@ POM_DEVELOPER_NAME=Filament Team
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
android.useAndroidX=true
|
||||
android.defaults.buildfeatures.buildconfig=true
|
||||
android.nonTransitiveRClass=false
|
||||
android.nonFinalResIds=false
|
||||
|
||||
org.gradle.unsafe.configuration-cache=true
|
||||
# TODO: Remove this when we switch to Gradle 7.4
|
||||
org.gradle.unsafe.configuration-cache.max-problems=3
|
||||
|
||||
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,10 +86,63 @@ 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-8.0-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
14
android/proguard-rules.pro
vendored
14
android/proguard-rules.pro
vendored
@@ -14,17 +14,3 @@
|
||||
-keepclassmembers class * {
|
||||
@com.google.android.filament.proguard.UsedBy* *;
|
||||
}
|
||||
|
||||
# These classes is loaded via env->FindClass() from Utils.cpp
|
||||
# They are in the utils namespace and therefore not covered by previous rules.
|
||||
-keep class com.google.android.filament.utils.KTX1Loader
|
||||
-keep class com.google.android.filament.utils.HDRLoader
|
||||
|
||||
# These native JNI methods are loaded via env->RegisterNatives() from Utils.cpp
|
||||
-keepclassmembers class com.google.android.filament.utils.KTX1Loader {
|
||||
native <methods>;
|
||||
}
|
||||
-keepclassmembers class com.google.android.filament.utils.HDRLoader {
|
||||
native <methods>;
|
||||
}
|
||||
|
||||
|
||||
@@ -112,9 +112,9 @@ the Android SDK.
|
||||
|
||||
## Android Studio
|
||||
|
||||
You must use the latest stable release of Android Studio. To open the project, point Studio to the
|
||||
`android` folder. After opening the project and syncing to gradle, select the sample of your choice
|
||||
using the drop-down widget in the toolbar.
|
||||
You must use Android Studio 3.6 RC 1 or higher. To open the project, point Studio to the `android`
|
||||
folder. After opening the project and syncing to gradle, select the sample of your choice using the
|
||||
drop-down widget in the toolbar.
|
||||
|
||||
## Compiling
|
||||
|
||||
|
||||
@@ -40,11 +40,6 @@ android {
|
||||
dependenciesInfo {
|
||||
includeInApk = false
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.gltf">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ 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
|
||||
@@ -57,9 +56,7 @@ 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
|
||||
@@ -80,7 +77,6 @@ class MainActivity : Activity() {
|
||||
choreographer = Choreographer.getInstance()
|
||||
|
||||
doubleTapDetector = GestureDetector(applicationContext, doubleTapListener)
|
||||
singleTapDetector = GestureDetector(applicationContext, singleTapListener)
|
||||
|
||||
modelViewer = ModelViewer(surfaceView)
|
||||
viewerContent.view = modelViewer.view
|
||||
@@ -92,7 +88,6 @@ class MainActivity : Activity() {
|
||||
surfaceView.setOnTouchListener { _, event ->
|
||||
modelViewer.onTouchEvent(event)
|
||||
doubleTapDetector.onTouchEvent(event)
|
||||
singleTapDetector.onTouchEvent(event)
|
||||
true
|
||||
}
|
||||
|
||||
@@ -234,7 +229,6 @@ class MainActivity : Activity() {
|
||||
modelViewer.scene.skybox = sky
|
||||
modelViewer.scene.indirectLight = ibl
|
||||
viewerContent.indirectLight = ibl
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -343,11 +337,6 @@ 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()
|
||||
@@ -364,11 +353,9 @@ class MainActivity : Activity() {
|
||||
fun loadSettings(message: RemoteServer.ReceivedMessage) {
|
||||
val json = StandardCharsets.UTF_8.decode(message.buffer).toString()
|
||||
viewerContent.assetLights = modelViewer.asset?.lightEntities
|
||||
automation.applySettings(modelViewer.engine, json, viewerContent)
|
||||
automation.applySettings(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()
|
||||
}
|
||||
|
||||
@@ -430,25 +417,10 @@ class MainActivity : Activity() {
|
||||
|
||||
// Just for testing purposes, this releases the current model and reloads the default model.
|
||||
inner class DoubleTapListener : GestureDetector.SimpleOnGestureListener() {
|
||||
override fun onDoubleTap(e: MotionEvent): Boolean {
|
||||
override fun onDoubleTap(e: MotionEvent?): Boolean {
|
||||
modelViewer.destroyModel()
|
||||
createDefaultRenderables()
|
||||
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,10 +6,6 @@ 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")
|
||||
@@ -40,11 +36,6 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.hellocam">
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ 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
|
||||
@@ -402,8 +401,6 @@ 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,10 +6,6 @@ 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")
|
||||
@@ -40,11 +36,6 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.hellotriangle">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
||||
@@ -29,7 +29,6 @@ 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
|
||||
@@ -120,13 +119,8 @@ class MainActivity : Activity() {
|
||||
private fun setupView() {
|
||||
scene.skybox = Skybox.Builder().color(0.035f, 0.035f, 0.035f, 1.0f).build(engine)
|
||||
|
||||
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
|
||||
}
|
||||
// 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
|
||||
@@ -160,11 +154,7 @@ class MainActivity : Activity() {
|
||||
}
|
||||
|
||||
private fun loadMaterial() {
|
||||
var name = "materials/baked_color.filamat"
|
||||
if (engine.activeFeatureLevel == Engine.FeatureLevel.FEATURE_LEVEL_0) {
|
||||
name = "materials/baked_color_es2.filamat"
|
||||
}
|
||||
readUncompressedAsset(name).let {
|
||||
readUncompressedAsset("materials/baked_color.filamat").let {
|
||||
material = Material.Builder().payload(it, it.remaining()).build(engine)
|
||||
}
|
||||
}
|
||||
@@ -314,17 +304,7 @@ class MainActivity : Activity() {
|
||||
inner class SurfaceCallback : UiHelper.RendererCallback {
|
||||
override fun onNativeWindowChanged(surface: Surface) {
|
||||
swapChain?.let { engine.destroySwapChain(it) }
|
||||
|
||||
// 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)
|
||||
swapChain = engine.createSwapChain(surface, uiHelper.swapChainFlags)
|
||||
displayHelper.attach(renderer, surfaceView.display);
|
||||
}
|
||||
|
||||
@@ -347,8 +327,6 @@ 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 {
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
// 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,10 +6,6 @@ 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")
|
||||
@@ -46,11 +42,6 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.ibl">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ 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
|
||||
@@ -118,10 +117,9 @@ class MainActivity : Activity() {
|
||||
}
|
||||
|
||||
private fun setupView() {
|
||||
// ambient occlusion is the cheapest effect that adds a lot of quality
|
||||
view.ambientOcclusionOptions = view.ambientOcclusionOptions.apply {
|
||||
enabled = true
|
||||
}
|
||||
val ssaoOptions = view.ambientOcclusionOptions
|
||||
ssaoOptions.enabled = true
|
||||
view.ambientOcclusionOptions = ssaoOptions
|
||||
|
||||
// NOTE: Try to disable post-processing (tone-mapping, etc.) to see the difference
|
||||
// view.isPostProcessingEnabled = false
|
||||
@@ -305,8 +303,6 @@ 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,10 +6,6 @@ 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")
|
||||
@@ -39,11 +35,6 @@ android {
|
||||
aaptOptions {
|
||||
noCompress 'filamat', 'ktx'
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility versions.jdk
|
||||
targetCompatibility versions.jdk
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.google.android.filament.litcube">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user