Compare commits
952 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
defee767c3 | ||
|
|
9560318521 | ||
|
|
ef09feb048 | ||
|
|
b3a79bf82b | ||
|
|
35ace36b7d | ||
|
|
39f323fe09 | ||
|
|
11b95304ea | ||
|
|
b7c30a7916 | ||
|
|
73f1ddfebf | ||
|
|
ed8db2f58f | ||
|
|
06a13d2e25 | ||
|
|
377f043ded | ||
|
|
ea057ca754 | ||
|
|
60ef6581c1 | ||
|
|
2708b3d076 | ||
|
|
6dc278c551 | ||
|
|
e4c1557159 | ||
|
|
090c02b2cf | ||
|
|
86125ca72a | ||
|
|
14532a2e69 | ||
|
|
2312d483c1 | ||
|
|
842425e784 | ||
|
|
6211820a70 | ||
|
|
dc16eb04f8 | ||
|
|
15a24318e8 | ||
|
|
c0bd3590b2 | ||
|
|
b1c78dfc8c | ||
|
|
4cae48fc77 | ||
|
|
489e926635 | ||
|
|
b7c38ef0f1 | ||
|
|
38d37d0d59 | ||
|
|
d1a93f0557 | ||
|
|
5701ca939a | ||
|
|
014abbfb63 | ||
|
|
f097ec7d5a | ||
|
|
be8bd92a34 | ||
|
|
fb42817304 | ||
|
|
c92ebada6f | ||
|
|
c3c535e256 | ||
|
|
6c25f5e50f | ||
|
|
b57510cb3c | ||
|
|
69d9a178bf | ||
|
|
b93059fad7 | ||
|
|
4ddd28a542 | ||
|
|
3092063ebb | ||
|
|
b1070c6508 | ||
|
|
604e4ea77d | ||
|
|
949855f1c8 | ||
|
|
e984d92968 | ||
|
|
915c4d89f3 | ||
|
|
7fb1b853ac | ||
|
|
513b3b8c3a | ||
|
|
f1b310ba0f | ||
|
|
6329b865cf | ||
|
|
13cfad43b7 | ||
|
|
bb8cd6677d | ||
|
|
35ed1cb906 | ||
|
|
bcd8ce3c93 | ||
|
|
84f0e97c78 | ||
|
|
ae9504cbf9 | ||
|
|
696327b35a | ||
|
|
1a95c2b39b | ||
|
|
07393d6237 | ||
|
|
2f294549a7 | ||
|
|
2732d3ac13 | ||
|
|
d7f7ab7aa4 | ||
|
|
0aa23945bb | ||
|
|
6f5ff9dd4b | ||
|
|
8f32c9ad98 | ||
|
|
c529a511f5 | ||
|
|
ab9c14d336 | ||
|
|
6c471bc98c | ||
|
|
96dc7c62d9 | ||
|
|
a33b418478 | ||
|
|
037aa08cf2 | ||
|
|
bde0b477e0 | ||
|
|
a922caed6b | ||
|
|
040adc7fef | ||
|
|
079fda2e74 | ||
|
|
3258972e0e | ||
|
|
79b7e15c7b | ||
|
|
49cfbe79eb | ||
|
|
44f4061227 | ||
|
|
fe280c0c3b | ||
|
|
86946acf08 | ||
|
|
29bb48be09 | ||
|
|
a528c0367c | ||
|
|
6d733091e0 | ||
|
|
b656918c4d | ||
|
|
d3c1964822 | ||
|
|
cf6c518aea | ||
|
|
af2fc39bad | ||
|
|
83b35e5ac2 | ||
|
|
67030982ec | ||
|
|
0aea56e22d | ||
|
|
9c7a8fef24 | ||
|
|
5b0e01329a | ||
|
|
7950b83b58 | ||
|
|
af99270aaa | ||
|
|
76fe0e36fb | ||
|
|
4e3bb9c7c8 | ||
|
|
3e5d9fa0b4 | ||
|
|
331d7c3e00 | ||
|
|
345455cf24 | ||
|
|
29a33ef215 | ||
|
|
7ca281d2b9 | ||
|
|
ce37315ef9 | ||
|
|
d3e3974179 | ||
|
|
785c11a240 | ||
|
|
4dfc78674d | ||
|
|
1c726fcef6 | ||
|
|
897593a8ed | ||
|
|
4f58be1ef1 | ||
|
|
003911f0ec | ||
|
|
de377c8e37 | ||
|
|
bf59b04ad0 | ||
|
|
d14e29d4d3 | ||
|
|
afaac3f18c | ||
|
|
68c647abdb | ||
|
|
7852a9b8cb | ||
|
|
acdb8addfd | ||
|
|
faa785f3f6 | ||
|
|
a0a8d62587 | ||
|
|
681f8fae2e | ||
|
|
4d48cac0aa | ||
|
|
4d51042170 | ||
|
|
2dec7f7996 | ||
|
|
0b653273dc | ||
|
|
b45d45048c | ||
|
|
fb8c51c5e1 | ||
|
|
6a47924482 | ||
|
|
8fdcd8fa62 | ||
|
|
6b6f80562f | ||
|
|
08e411aeac | ||
|
|
b3c57a4ee1 | ||
|
|
0947f80974 | ||
|
|
8155bf04a8 | ||
|
|
815483c5e0 | ||
|
|
05bfa632ff | ||
|
|
931daf3a69 | ||
|
|
4821a95f16 | ||
|
|
4c0a5b5f1d | ||
|
|
4ba95428c2 | ||
|
|
732a6c08de | ||
|
|
0584cea125 | ||
|
|
058c9cd28b | ||
|
|
2ce3b88a13 | ||
|
|
c7c1c01a0e | ||
|
|
827e73b682 | ||
|
|
7ada8372f2 | ||
|
|
749a4d01af | ||
|
|
f4004cf047 | ||
|
|
dc74ee2ddc | ||
|
|
2727cddd7a | ||
|
|
4f239c3e3c | ||
|
|
4bf0d0c0a8 | ||
|
|
d70f1c0ab2 | ||
|
|
991861a512 | ||
|
|
d0367a359b | ||
|
|
d2be23045f | ||
|
|
4cb903a09e | ||
|
|
3ca0a8cd8d | ||
|
|
2c18d7f576 | ||
|
|
379f92417f | ||
|
|
13574f793c | ||
|
|
f69ba63046 | ||
|
|
a13620c66d | ||
|
|
b4a35c3ee2 | ||
|
|
a4e3e0c2d1 | ||
|
|
1a85c93894 | ||
|
|
2c114a9a9f | ||
|
|
f4d8753c24 | ||
|
|
6f28da4798 | ||
|
|
a6390355da | ||
|
|
a120e0a4bb | ||
|
|
642fb5859b | ||
|
|
b4623c9afc | ||
|
|
c4546f1777 | ||
|
|
ea5e8c2d14 | ||
|
|
440687e05a | ||
|
|
bd30abb168 | ||
|
|
d15a906855 | ||
|
|
7584a7bebe | ||
|
|
8f3f30e9cd | ||
|
|
664e7b8a8d | ||
|
|
aa5f88ae0f | ||
|
|
6f5e04d489 | ||
|
|
2113c9a3be | ||
|
|
b0d4934d02 | ||
|
|
2f4dd0bbd4 | ||
|
|
e34db6fc29 | ||
|
|
087e2480d1 | ||
|
|
45efe2df75 | ||
|
|
85ae21fa26 | ||
|
|
77939ad269 | ||
|
|
4a59e6e1ce | ||
|
|
ca68ef22e1 | ||
|
|
7067500a9c | ||
|
|
6ed1fb3b7b | ||
|
|
1613c1bb0e | ||
|
|
1162ae4ddc | ||
|
|
a25179b91e | ||
|
|
81388ab4b4 | ||
|
|
ec9fd58fc0 | ||
|
|
b786b486b6 | ||
|
|
06b191cd53 | ||
|
|
cd168148d8 | ||
|
|
0da20cccdc | ||
|
|
ecbdeb9e6d | ||
|
|
e14c8258f7 | ||
|
|
3862b44ef4 | ||
|
|
f3ed31b5a0 | ||
|
|
06f4920033 | ||
|
|
b0c11c17e9 | ||
|
|
27c4174abd | ||
|
|
71f256585d | ||
|
|
710f83dcf5 | ||
|
|
36b3cc7bf0 | ||
|
|
c6d9d4a9ae | ||
|
|
665b198db0 | ||
|
|
9f267de1b7 | ||
|
|
5c71b0eae2 | ||
|
|
e58043f156 | ||
|
|
c6a8ad9fbe | ||
|
|
97e8035b40 | ||
|
|
1d474b30b9 | ||
|
|
4c81bb0158 | ||
|
|
a2e5cacee0 | ||
|
|
7cfc2c9f24 | ||
|
|
fec214a772 | ||
|
|
6eac638fd2 | ||
|
|
dc891f7299 | ||
|
|
7c4661cc6b | ||
|
|
c7b6d45958 | ||
|
|
c0bf8fa83b | ||
|
|
4fa987c698 | ||
|
|
ec533e6047 | ||
|
|
bdf1272942 | ||
|
|
2e8a80f726 | ||
|
|
2516484566 | ||
|
|
c91d02ab29 | ||
|
|
41f7ea436d | ||
|
|
b224916f09 | ||
|
|
38d2509aaf | ||
|
|
185ed0cc68 | ||
|
|
5d2b12b9a6 | ||
|
|
77aec40a56 | ||
|
|
25d42c939d | ||
|
|
1ad6bccbc2 | ||
|
|
3c1ea07502 | ||
|
|
07e4d1c148 | ||
|
|
1816883428 | ||
|
|
6a6775ebec | ||
|
|
767764e4ff | ||
|
|
d3f6ce6990 | ||
|
|
96032eada5 | ||
|
|
c8aad378c4 | ||
|
|
c067d76d1d | ||
|
|
630f816e7a | ||
|
|
bbf37a5480 | ||
|
|
a07894ca9f | ||
|
|
e03c663bc3 | ||
|
|
1af254db43 | ||
|
|
7621f7e830 | ||
|
|
d7cd247dfc | ||
|
|
9a58bf2460 | ||
|
|
7ee1279792 | ||
|
|
7131bbf62c | ||
|
|
820f551eea | ||
|
|
a6872c840c | ||
|
|
c0452b5e9d | ||
|
|
b136b4aca5 | ||
|
|
59cf9e3b75 | ||
|
|
7ca508cb7a | ||
|
|
96feea1dee | ||
|
|
c5acacff67 | ||
|
|
92f2004c4b | ||
|
|
aed8c7fcb4 | ||
|
|
29f50e0feb | ||
|
|
2aeb33b260 | ||
|
|
132e94b3bb | ||
|
|
f7f86a7c56 | ||
|
|
4a3984692a | ||
|
|
c87cffd57a | ||
|
|
4bbc0c05c4 | ||
|
|
697b1b6907 | ||
|
|
d3f5164fcb | ||
|
|
8882132f43 | ||
|
|
89a8592714 | ||
|
|
9d35aff2d3 | ||
|
|
c6e7382cb9 | ||
|
|
0be094cd4f | ||
|
|
81c60c4efa | ||
|
|
456e057754 | ||
|
|
ab12881888 | ||
|
|
efaf02ca61 | ||
|
|
8f7b25088d | ||
|
|
8f4ffbc782 | ||
|
|
455bed917b | ||
|
|
d5033b5857 | ||
|
|
cf5b6ccba3 | ||
|
|
42c80d5d5e | ||
|
|
2b92b5e060 | ||
|
|
1762baab61 | ||
|
|
ab98548e75 | ||
|
|
5e2c9e3aff | ||
|
|
b8ece355d7 | ||
|
|
79fb878fb9 | ||
|
|
026298182e | ||
|
|
a79effc78b | ||
|
|
66471ee990 | ||
|
|
1fc57b8bf0 | ||
|
|
6b5d21639e | ||
|
|
d70e317065 | ||
|
|
a5c49cc1b6 | ||
|
|
ce995d021a | ||
|
|
9cd2f2edc1 | ||
|
|
5c64ed5125 | ||
|
|
623cd1a5f2 | ||
|
|
94776a01b3 | ||
|
|
f462eafed0 | ||
|
|
7d1dbba2b4 | ||
|
|
8c9cc988a6 | ||
|
|
7a1d9968a7 | ||
|
|
56682794d3 | ||
|
|
87ee5783b7 | ||
|
|
7a1c079050 | ||
|
|
242e8d1b56 | ||
|
|
42d55f226b | ||
|
|
25b43d7c2a | ||
|
|
de3f757013 | ||
|
|
ebd195f8e4 | ||
|
|
a2ce57ade3 | ||
|
|
7a78ccd184 | ||
|
|
963a8958ec | ||
|
|
899ac1224f | ||
|
|
a019de3363 | ||
|
|
79c83f509c | ||
|
|
fde2d2e483 | ||
|
|
b2c63b6cd2 | ||
|
|
1f9d073a64 | ||
|
|
fa0f5e0501 | ||
|
|
fee6a2f075 | ||
|
|
19a212389b | ||
|
|
1b1ef591a4 | ||
|
|
b0acb3216a | ||
|
|
10e1aaadff | ||
|
|
00b522669c | ||
|
|
f125e1730d | ||
|
|
18776fc432 | ||
|
|
4bf21876b4 | ||
|
|
1feca23477 | ||
|
|
b4d2a1991a | ||
|
|
3e6ee4ca5e | ||
|
|
ee6ddf675e | ||
|
|
7e6c38d098 | ||
|
|
7a8755b5b2 | ||
|
|
6461370cb8 | ||
|
|
e56882d20f | ||
|
|
43f7bad8a3 | ||
|
|
31bdb61047 | ||
|
|
2fcca9677d | ||
|
|
a4094193c3 | ||
|
|
1935598a7d | ||
|
|
6c3b7a2282 | ||
|
|
23b62e2d12 | ||
|
|
b281022eb0 | ||
|
|
910c2e9b0e | ||
|
|
9007de03d9 | ||
|
|
1aa57fc425 | ||
|
|
7418fc0222 | ||
|
|
9437907eb4 | ||
|
|
91a009f94c | ||
|
|
ca6b1860be | ||
|
|
fbb8742cbd | ||
|
|
6c173489d7 | ||
|
|
0abe262094 | ||
|
|
bd72f1fd6a | ||
|
|
28912b6f57 | ||
|
|
a3e336921e | ||
|
|
524da0af28 | ||
|
|
adccf9f432 | ||
|
|
c49ffcc354 | ||
|
|
50adc1f661 | ||
|
|
b77e024de9 | ||
|
|
1f77fb5995 | ||
|
|
bf1f32e308 | ||
|
|
2c6042bd44 | ||
|
|
96c770ad9e | ||
|
|
b1563dabe9 | ||
|
|
3ef37f8925 | ||
|
|
ede09e28e3 | ||
|
|
81ea280ea9 | ||
|
|
92c017bdd3 | ||
|
|
6870d360cd | ||
|
|
2d62daf5e8 | ||
|
|
83cff32856 | ||
|
|
8de730f76c | ||
|
|
1f29df6da4 | ||
|
|
c087eb6825 | ||
|
|
038c35fbda | ||
|
|
80fcd133de | ||
|
|
62d0f9f033 | ||
|
|
1e65b4d8af | ||
|
|
f3731fa797 | ||
|
|
28f031e95f | ||
|
|
5104318fff | ||
|
|
68f0ab6312 | ||
|
|
62a591bc73 | ||
|
|
0f6a06a2e1 | ||
|
|
b620a5e358 | ||
|
|
0d652d61f8 | ||
|
|
1b033c7de3 | ||
|
|
eb5eb6c827 | ||
|
|
0e437d244f | ||
|
|
9024b4afd7 | ||
|
|
62ff7b7d0a | ||
|
|
d1ed4f837c | ||
|
|
d62f664957 | ||
|
|
6311b538e1 | ||
|
|
58bb1f61e6 | ||
|
|
8415d18401 | ||
|
|
6df1265bef | ||
|
|
dc51dc197c | ||
|
|
1292610289 | ||
|
|
e9d1e3a82e | ||
|
|
c749f7e798 | ||
|
|
f5068457f2 | ||
|
|
3a3cd1c0ec | ||
|
|
7dfe26def8 | ||
|
|
3b3dc0af81 | ||
|
|
0e38cc770d | ||
|
|
c0eb058728 | ||
|
|
8b515ee4c2 | ||
|
|
65e286e7de | ||
|
|
cdd099951a | ||
|
|
432ed50cb3 | ||
|
|
d4a396d52f | ||
|
|
97c9ad7599 | ||
|
|
15e2447cb5 | ||
|
|
21ed172c55 | ||
|
|
c619f089e7 | ||
|
|
29db39b6a7 | ||
|
|
b50f7dd7de | ||
|
|
6df20f3083 | ||
|
|
5f34b8974f | ||
|
|
bf13f76dea | ||
|
|
92048e6b65 | ||
|
|
c37c04762d | ||
|
|
53a8fd94ba | ||
|
|
b4d16ab3b5 | ||
|
|
0b1fa7fc80 | ||
|
|
010ce1c069 | ||
|
|
f6c3663789 | ||
|
|
d49d0f1762 | ||
|
|
8780d7aae5 | ||
|
|
1ac6f5bbfe | ||
|
|
764d4198bc | ||
|
|
d5d77a46ec | ||
|
|
fb8b9af8fd | ||
|
|
f26b556fce | ||
|
|
9e11e52c92 | ||
|
|
52573ecd95 | ||
|
|
79995349d8 | ||
|
|
e31ebb7a82 | ||
|
|
b4f09325f1 | ||
|
|
ee3c3d0965 | ||
|
|
d08a4e8bd9 | ||
|
|
0a9236c2eb | ||
|
|
0a61faa57a | ||
|
|
26520c8d23 | ||
|
|
64b3d7807b | ||
|
|
ec77086186 | ||
|
|
0187caf10f | ||
|
|
823f5c9c1f | ||
|
|
9a47178b3d | ||
|
|
a3fb5c41f1 | ||
|
|
58df2681dd | ||
|
|
5ef816ef2a | ||
|
|
91f052a9b0 | ||
|
|
6a0a2d965e | ||
|
|
2260fe5b62 | ||
|
|
e07f0dd244 | ||
|
|
d194eec0ad | ||
|
|
addf325d42 | ||
|
|
c019781471 | ||
|
|
de849fa21f | ||
|
|
072d17d64f | ||
|
|
38b9cf4fe3 | ||
|
|
d0a8c6b4fa | ||
|
|
ab2ae245ba | ||
|
|
f53f03b5dd | ||
|
|
474fe9c5ed | ||
|
|
c3c8293862 | ||
|
|
3c42ace496 | ||
|
|
2702ef123c | ||
|
|
89e76fde57 | ||
|
|
37c8f1d8ea | ||
|
|
8416553724 | ||
|
|
f3baecc4be | ||
|
|
89df8355aa | ||
|
|
0e00dbb967 | ||
|
|
786dbdc6e4 | ||
|
|
920dc6b167 | ||
|
|
809379b93d | ||
|
|
4701945c87 | ||
|
|
2c79f4c480 | ||
|
|
cc29359897 | ||
|
|
b54000ccb9 | ||
|
|
c65194fce1 | ||
|
|
d8e2e60692 | ||
|
|
fb643eb422 | ||
|
|
e80ea979a4 | ||
|
|
3e5fe994b9 | ||
|
|
05def1a789 | ||
|
|
b36d29ef77 | ||
|
|
898ae083ee | ||
|
|
9c75c1ecfa | ||
|
|
13767c3bb4 | ||
|
|
064ebd56e0 | ||
|
|
b514b2e996 | ||
|
|
8c7fbb2e01 | ||
|
|
3e67f628ee | ||
|
|
3bd1afedbd | ||
|
|
f19533b149 | ||
|
|
dc5c48de33 | ||
|
|
fc4b88b5e9 | ||
|
|
116b475161 | ||
|
|
cab4a660d3 | ||
|
|
72dafa4887 | ||
|
|
4e873e8007 | ||
|
|
64609cc4aa | ||
|
|
8dc526b536 | ||
|
|
0769aabf29 | ||
|
|
db53ce62ad | ||
|
|
d91eb1180f | ||
|
|
89d47eb05a | ||
|
|
e985546e81 | ||
|
|
8036d65adf | ||
|
|
6a95807105 | ||
|
|
0a387e16d9 | ||
|
|
1ec45c670b | ||
|
|
5a9ebf8db0 | ||
|
|
abd852a9aa | ||
|
|
2c29c67df0 | ||
|
|
1d73027df6 | ||
|
|
54a4545ac5 | ||
|
|
14ce9e30b9 | ||
|
|
cc6361e4f9 | ||
|
|
45ce2d3a17 | ||
|
|
1b6c25ce68 | ||
|
|
e10530d3bb | ||
|
|
043cdcfcff | ||
|
|
880bf0f061 | ||
|
|
7bbea3e503 | ||
|
|
f8e0cedcdb | ||
|
|
2a2c339cf5 | ||
|
|
9dcb1181f3 | ||
|
|
09d9bbb035 | ||
|
|
354d3222cb | ||
|
|
e6be4c312b | ||
|
|
0e2cf44ca4 | ||
|
|
2e0e19d9ce | ||
|
|
63b863d55d | ||
|
|
39c85dcbbb | ||
|
|
45119fe15b | ||
|
|
44c6ba2618 | ||
|
|
af48d7cff1 | ||
|
|
277a999bca | ||
|
|
f231368031 | ||
|
|
a55b75a739 | ||
|
|
f51a6aacc8 | ||
|
|
cc61707cc2 | ||
|
|
e7268a0d1a | ||
|
|
94f5dcc984 | ||
|
|
030e97b381 | ||
|
|
760ec8861a | ||
|
|
4c1fb83379 | ||
|
|
0e39423506 | ||
|
|
cb53a68d71 | ||
|
|
06593a97bb | ||
|
|
c28d9ddb9d | ||
|
|
038cecd8e2 | ||
|
|
26f6349487 | ||
|
|
ddef5ec3c4 | ||
|
|
56285d6227 | ||
|
|
0691283a99 | ||
|
|
1e4fa12f21 | ||
|
|
e20442cad7 | ||
|
|
6555e09a96 | ||
|
|
bee9ab31bc | ||
|
|
6ef7f82df8 | ||
|
|
6f38aaea31 | ||
|
|
98b17780fb | ||
|
|
3159bb2516 | ||
|
|
6054a28b78 | ||
|
|
1ccb311266 | ||
|
|
8587d6b15d | ||
|
|
2ad1e9a9a8 | ||
|
|
9b1a0e2f58 | ||
|
|
e7df636368 | ||
|
|
afade93bad | ||
|
|
8ae8dd59b1 | ||
|
|
bf97e7e15a | ||
|
|
b29311f23e | ||
|
|
5d3cceb2bf | ||
|
|
c52f8908f8 | ||
|
|
cb5fcbc784 | ||
|
|
ca7ef8cbae | ||
|
|
ed326e1e68 | ||
|
|
8094955fc1 | ||
|
|
d31f57eb22 | ||
|
|
ada5444997 | ||
|
|
3c26c2cec1 | ||
|
|
7cdc0c032f | ||
|
|
854fcc7eac | ||
|
|
0e82fdbddd | ||
|
|
f26b761d72 | ||
|
|
167493b85c | ||
|
|
7fc60db151 | ||
|
|
1b36f82c1e | ||
|
|
95c8dd0185 | ||
|
|
63801d2460 | ||
|
|
a60ee4914f | ||
|
|
d4f9ede84b | ||
|
|
6bb909bd0e | ||
|
|
c5a5d15fe3 | ||
|
|
c69547f8ea | ||
|
|
1ef3535ba7 | ||
|
|
3945c232d7 | ||
|
|
db18b2e07b | ||
|
|
a9814f8a88 | ||
|
|
2adfb259c6 | ||
|
|
240d8cd79b | ||
|
|
85c563b628 | ||
|
|
68a78a77a8 | ||
|
|
ad27d10503 | ||
|
|
1366e3dcd1 | ||
|
|
52086fe4d5 | ||
|
|
d99f9cffb2 | ||
|
|
33cbc6bba3 | ||
|
|
7794cd4c65 | ||
|
|
574058e81e | ||
|
|
3ad4f2eceb | ||
|
|
56d9e1f727 | ||
|
|
7c8849065c | ||
|
|
bf0dc32ee3 | ||
|
|
887f8e8a1c | ||
|
|
b1f95646d9 | ||
|
|
a282da78cd | ||
|
|
746e273336 | ||
|
|
b2dd6683be | ||
|
|
526898e7d6 | ||
|
|
00f1c3dae9 | ||
|
|
bb88487b79 | ||
|
|
92b7ee97f5 | ||
|
|
72056ee9e3 | ||
|
|
6330b1625c | ||
|
|
27f4504dfc | ||
|
|
fb0e89d969 | ||
|
|
2ad932f345 | ||
|
|
d8ac60009c | ||
|
|
37e2f46e10 | ||
|
|
17dd44fd91 | ||
|
|
26297feba7 | ||
|
|
05bc60f953 | ||
|
|
df2caf4f62 | ||
|
|
2dbe0b64be | ||
|
|
c79f5a1a29 | ||
|
|
e072e30841 | ||
|
|
aa770d54ae | ||
|
|
559642d54c | ||
|
|
583157d4ef | ||
|
|
44422b3d69 | ||
|
|
f084e50829 | ||
|
|
e8a7d9f0c2 | ||
|
|
a389de3deb | ||
|
|
06eca637b0 | ||
|
|
201bd2c845 | ||
|
|
e6500a8b3b | ||
|
|
db6636aff8 | ||
|
|
ef35654ce9 | ||
|
|
4248eb148e | ||
|
|
73c2a87444 | ||
|
|
55d0063ced | ||
|
|
ca70489556 | ||
|
|
8d817ac787 | ||
|
|
9a550d69b8 | ||
|
|
07d6aebafc | ||
|
|
32604e2c57 | ||
|
|
adb107afc2 | ||
|
|
8d9bd5f4fa | ||
|
|
c88bbc21d0 | ||
|
|
917edec0a7 | ||
|
|
34959dd5e8 | ||
|
|
82ab74efb0 | ||
|
|
968dbdb847 | ||
|
|
e43466d2bc | ||
|
|
cdf03f91c9 | ||
|
|
abe70caeae | ||
|
|
4891bb6157 | ||
|
|
f5e6ec42b3 | ||
|
|
92b2dd835d | ||
|
|
76f0309b58 | ||
|
|
d9e9fabec5 | ||
|
|
a922e914b4 | ||
|
|
4b7677fd13 | ||
|
|
0474a6b8b5 | ||
|
|
241f08bd74 | ||
|
|
b8f8067a87 | ||
|
|
965777da85 | ||
|
|
ffa62d4236 | ||
|
|
94a01c6010 | ||
|
|
232bf728c6 | ||
|
|
0e367580da | ||
|
|
40aad197da | ||
|
|
124fd2c978 | ||
|
|
0d32c58e41 | ||
|
|
09fa87ddfa | ||
|
|
cb356606d9 | ||
|
|
3de9cc1533 | ||
|
|
f1aaf16082 | ||
|
|
4c23f7a436 | ||
|
|
2188923153 | ||
|
|
2f47bab237 | ||
|
|
fe547a7690 | ||
|
|
b4f5a4a0a0 | ||
|
|
5929d5d9dd | ||
|
|
0b7de0ec65 | ||
|
|
87ac282014 | ||
|
|
e525a7c7c4 | ||
|
|
8a84c7f0a3 | ||
|
|
e462c22a07 | ||
|
|
3ea8a25127 | ||
|
|
45df197bd6 | ||
|
|
1ecb83bf73 | ||
|
|
aefa03291e | ||
|
|
6e02fa186a | ||
|
|
756074d8bd | ||
|
|
2caa09bebd | ||
|
|
72a182122a | ||
|
|
0688db7da3 | ||
|
|
0c6d96c407 | ||
|
|
1f48bd3e79 | ||
|
|
7103f4f0b3 | ||
|
|
210234255c | ||
|
|
73312bc6bb | ||
|
|
6ea9872a3e | ||
|
|
d54ceff7a3 | ||
|
|
6cf3e86c8a | ||
|
|
acc36e8d9b | ||
|
|
1670e73287 | ||
|
|
3b52b89fd6 | ||
|
|
c132ede510 | ||
|
|
4e62e4f696 | ||
|
|
c0addf22ed | ||
|
|
880642ef4a | ||
|
|
2f94e5990c | ||
|
|
4a5ce16322 | ||
|
|
454b08362d | ||
|
|
f80c584db0 | ||
|
|
68bcd6c159 | ||
|
|
a9a9061f96 | ||
|
|
196c98fc2a | ||
|
|
9ea2e69579 | ||
|
|
f4da2ef8ec | ||
|
|
8fb65a19b4 | ||
|
|
a2c6c34739 | ||
|
|
a2818037b3 | ||
|
|
02c7a22d43 | ||
|
|
f6e993dfc8 | ||
|
|
8866e2829f | ||
|
|
d016e0f443 | ||
|
|
0cbf6f8d76 | ||
|
|
641b58c409 | ||
|
|
5f0204f7b1 | ||
|
|
660d1a1800 | ||
|
|
8d209a16c5 | ||
|
|
ed786701fc | ||
|
|
4842b1ca13 | ||
|
|
0990550f45 | ||
|
|
84b215c3b0 | ||
|
|
2a7724f601 | ||
|
|
b119d763da | ||
|
|
ff25e6c18f | ||
|
|
2677f05f0d | ||
|
|
bbfa47bbf0 | ||
|
|
060c0d2e6f | ||
|
|
414396efb6 | ||
|
|
6825781718 | ||
|
|
2494fff094 | ||
|
|
924422261f | ||
|
|
f81e819901 | ||
|
|
81a2d70251 | ||
|
|
3a2a40c76a | ||
|
|
6c3fa13e41 | ||
|
|
0ea2354be5 | ||
|
|
079056cfbc | ||
|
|
1230fccbf9 | ||
|
|
73e0facaed | ||
|
|
94b1ad52fa | ||
|
|
6878d0d6e6 | ||
|
|
76e7568994 | ||
|
|
b176b2f0e6 | ||
|
|
af5805e396 | ||
|
|
b98f45df60 | ||
|
|
bb2571233d | ||
|
|
00629bac48 | ||
|
|
81e7f619eb | ||
|
|
b0ab9bb697 | ||
|
|
ae1e6f43f2 | ||
|
|
6eba2f145e | ||
|
|
13666027cc | ||
|
|
62cef096e1 | ||
|
|
af48b60876 | ||
|
|
b71357a955 | ||
|
|
9865a609da | ||
|
|
77bafb295e | ||
|
|
ba4c9dbd09 | ||
|
|
4e9cf8ac02 | ||
|
|
108dae11e9 | ||
|
|
16de98291f | ||
|
|
547f8917b4 | ||
|
|
f1da2ca643 | ||
|
|
9e6ea9454f | ||
|
|
fcd7e198c2 | ||
|
|
82523bd1d3 | ||
|
|
4ec5fac95c | ||
|
|
7fb3810eb1 | ||
|
|
ed2fe83491 | ||
|
|
3fd9c49fb9 | ||
|
|
69c0843d20 | ||
|
|
3f7ef9738d | ||
|
|
3cfc6981a4 | ||
|
|
8b2ea72be2 | ||
|
|
8eaa1f5e88 | ||
|
|
c72f622a87 | ||
|
|
8a0505eb6f | ||
|
|
799e837f35 | ||
|
|
4690ce5602 | ||
|
|
e972126cea | ||
|
|
db40fd8983 | ||
|
|
c2db7b8afd | ||
|
|
f403876784 | ||
|
|
3a9d4c7c77 | ||
|
|
e737ece570 | ||
|
|
948d19c446 | ||
|
|
ee81c9516a | ||
|
|
675012a2eb | ||
|
|
31a4ef10e1 | ||
|
|
a0d43d51c9 | ||
|
|
31035d2b3c | ||
|
|
4e8f323e47 | ||
|
|
4dd3d7ab5e | ||
|
|
63a7bf5ee9 | ||
|
|
0473da9f05 | ||
|
|
e5447f7417 | ||
|
|
62810d8c87 | ||
|
|
ca81d48432 | ||
|
|
b9c857130a | ||
|
|
a9bbc6d3c4 | ||
|
|
3a273b1837 | ||
|
|
5e6ff5a44f | ||
|
|
65129d1b52 | ||
|
|
54d9d870ee | ||
|
|
ffff6dd580 | ||
|
|
dc4a1ed5e5 | ||
|
|
8bbf0ce9ef | ||
|
|
a4e4021950 | ||
|
|
87fe48225f | ||
|
|
af47fa9b6d | ||
|
|
3de1e197aa | ||
|
|
2a1cbe67c6 | ||
|
|
f57404a3f0 | ||
|
|
87d815c659 | ||
|
|
651ccb183e | ||
|
|
67406c42ec | ||
|
|
cb953b4203 | ||
|
|
c0e2cfb684 | ||
|
|
9358c7313e | ||
|
|
02b377c244 | ||
|
|
d2287f584a | ||
|
|
cc94820cb3 | ||
|
|
b17c51e340 | ||
|
|
34dcc90ac7 | ||
|
|
8a1dc0ac65 | ||
|
|
a61bc51271 | ||
|
|
bccb8260e2 | ||
|
|
bedc609051 | ||
|
|
f1cab9296a | ||
|
|
4665f6027f | ||
|
|
891e85ba2b | ||
|
|
6957f54547 | ||
|
|
48ba111ccc | ||
|
|
8f2df79a96 | ||
|
|
415aeef95b | ||
|
|
cabd9be5f0 | ||
|
|
45e6e6eb18 | ||
|
|
b89cac48c5 | ||
|
|
00d55cddb5 | ||
|
|
88dd32b1a7 | ||
|
|
20e7acd24d | ||
|
|
9be871f14b | ||
|
|
0b358081c3 | ||
|
|
d172ae78fd | ||
|
|
5f1c9bc41b | ||
|
|
317d78d7c6 | ||
|
|
46090793a8 | ||
|
|
c3a995dd3d | ||
|
|
8020f7eb78 | ||
|
|
e8e847a662 | ||
|
|
d2c883877d | ||
|
|
0f7f6f6004 | ||
|
|
ebadf9d6a3 | ||
|
|
94fb74d6aa | ||
|
|
60b664d3b9 | ||
|
|
eee9249dfc | ||
|
|
7f7625b4a0 | ||
|
|
c681cd243a | ||
|
|
503e66790b | ||
|
|
a8dc91c238 | ||
|
|
bc554f77f4 | ||
|
|
dada7332c6 | ||
|
|
02b1d0a950 | ||
|
|
bcde742bbc | ||
|
|
79a83e8c46 | ||
|
|
3d56ff3547 | ||
|
|
218c3af11b | ||
|
|
ad20a312d6 | ||
|
|
ad788d6338 | ||
|
|
02b2b79060 | ||
|
|
610dca88a3 | ||
|
|
00a6a68b9c | ||
|
|
7852fd2ffb | ||
|
|
ead4b1d222 | ||
|
|
f290742f1b | ||
|
|
b31f267467 | ||
|
|
47db11a205 | ||
|
|
b263a89b07 | ||
|
|
dbe01d76a2 | ||
|
|
aa3b0a4e16 | ||
|
|
ff66e980eb | ||
|
|
6fbf8a8be0 | ||
|
|
1452ce62f4 | ||
|
|
d84d095c97 | ||
|
|
e1b498f82c | ||
|
|
06726fe361 | ||
|
|
ba3a274357 | ||
|
|
30a3d31a3d | ||
|
|
191c89c3b1 | ||
|
|
42b739154e | ||
|
|
721a251b34 |
14
.github/workflows/android-continuous.yml
vendored
14
.github/workflows/android-continuous.yml
vendored
@@ -3,7 +3,9 @@ name: Android
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- release
|
||||
- rc/**
|
||||
|
||||
jobs:
|
||||
build-android:
|
||||
@@ -11,10 +13,10 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/android && ./build.sh continuous
|
||||
cd build/android && printf "y" | ./build.sh continuous
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filament-android
|
||||
@@ -22,7 +24,7 @@ jobs:
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filamat-android-full
|
||||
path: out/filamat-android-full-release.aar
|
||||
path: out/filamat-android-release.aar
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filamat-android-lite
|
||||
@@ -31,6 +33,10 @@ jobs:
|
||||
with:
|
||||
name: gltfio-android-release
|
||||
path: out/gltfio-android-release.aar
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: gltfio-android-lite-release
|
||||
path: out/gltfio-android-lite-release.aar
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filament-utils-android-release
|
||||
|
||||
11
.github/workflows/ios-continuous.yml
vendored
11
.github/workflows/ios-continuous.yml
vendored
@@ -3,7 +3,9 @@ name: iOS
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- release
|
||||
- rc/**
|
||||
|
||||
jobs:
|
||||
build-ios:
|
||||
@@ -11,11 +13,14 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/ios && ./build.sh continuous
|
||||
cd build/ios && printf "y" | ./build.sh continuous
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filament-ios
|
||||
path: out/filament-release-ios.tgz
|
||||
- name: Build iOS samples
|
||||
run: |
|
||||
cd build/ios && ./build-samples.sh continuous
|
||||
|
||||
8
.github/workflows/linux-continuous.yml
vendored
8
.github/workflows/linux-continuous.yml
vendored
@@ -3,7 +3,9 @@ name: Linux
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- release
|
||||
- rc/**
|
||||
|
||||
jobs:
|
||||
build-linux:
|
||||
@@ -11,10 +13,10 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/linux && ./build.sh continuous
|
||||
cd build/linux && printf "y" | ./build.sh continuous
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filament-linux
|
||||
|
||||
8
.github/workflows/mac-continuous.yml
vendored
8
.github/workflows/mac-continuous.yml
vendored
@@ -3,7 +3,9 @@ name: macOS
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- release
|
||||
- rc/**
|
||||
|
||||
jobs:
|
||||
build-mac:
|
||||
@@ -11,10 +13,10 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/mac && ./build.sh continuous
|
||||
cd build/mac && printf "y" | ./build.sh continuous
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filament-mac
|
||||
|
||||
32
.github/workflows/presubmit.yml
vendored
32
.github/workflows/presubmit.yml
vendored
@@ -12,20 +12,21 @@ jobs:
|
||||
os: [macos-latest, ubuntu-latest]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
|
||||
cd build/$WORKFLOW_OS && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
cd build/$WORKFLOW_OS && printf "y" | ./build.sh presubmit
|
||||
- name: Test material parser
|
||||
run: |
|
||||
out/cmake-release/filament/test/test_material_parser
|
||||
|
||||
build-windows:
|
||||
name: build-windows
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
build\windows\build-github.bat presubmit
|
||||
@@ -36,33 +37,30 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/android && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
cd build/android && printf "y" | ./build.sh presubmit
|
||||
|
||||
build-ios:
|
||||
name: build-iOS
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/ios && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
cd build/ios && printf "y" | ./build.sh presubmit
|
||||
- name: Build iOS samples
|
||||
run: |
|
||||
cd build/ios && ./build-samples.sh presubmit
|
||||
|
||||
build-web:
|
||||
name: build-web
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/web && ./build.sh ${TARGET}
|
||||
env:
|
||||
TARGET: presubmit
|
||||
cd build/web && printf "y" | ./build.sh presubmit
|
||||
|
||||
45
.github/workflows/release.yml
vendored
45
.github/workflows/release.yml
vendored
@@ -30,20 +30,19 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
run: |
|
||||
WORKFLOW_OS=`echo \`uname\` | sed "s/Darwin/mac/" | tr [:upper:] [:lower:]`
|
||||
cd build/$WORKFLOW_OS && ./build.sh release
|
||||
cd build/$WORKFLOW_OS && printf "y" | ./build.sh release
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
pip3 install setuptools
|
||||
pip3 install PyGithub
|
||||
DATE=`date +%Y%m%d`
|
||||
if [ -f out/filament-release-darwin.tgz ]; then mv out/filament-release-darwin.tgz out/filament-${DATE}-mac.tgz; fi;
|
||||
if [ -f out/filament-release-linux.tgz ]; then mv out/filament-release-linux.tgz out/filament-${DATE}-linux.tgz; fi;
|
||||
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;
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
@@ -62,18 +61,17 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/web && ./build.sh release
|
||||
cd build/web && printf "y" | ./build.sh release
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
pip3 install setuptools
|
||||
pip3 install PyGithub
|
||||
DATE=`date +%Y%m%d`
|
||||
mv out/filament-release-web.tgz out/filament-${DATE}-web.tgz
|
||||
mv out/filament-release-web.tgz out/filament-${TAG}-web.tgz
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
@@ -92,22 +90,23 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/android && ./build.sh release
|
||||
cd build/android && printf "y" | ./build.sh release
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
pip3 install setuptools
|
||||
pip3 install PyGithub
|
||||
DATE=`date +%Y%m%d`
|
||||
mv out/filament-android-release.aar out/filament-${DATE}-android.aar
|
||||
mv out/filamat-android-full-release.aar out/filamat-${DATE}-full-android.aar
|
||||
mv out/filamat-android-lite-release.aar out/filamat-${DATE}-lite-android.aar
|
||||
mv out/gltfio-android-release.aar out/gltfio-${DATE}-android.aar
|
||||
mv out/filament-utils-android-release.aar out/filament-utils-${DATE}-android.aar
|
||||
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/gltfio-android-lite-release.aar out/gltfio-${TAG}-lite-android.aar
|
||||
mv out/filament-utils-android-release.aar out/filament-utils-${TAG}-android.aar
|
||||
mv out/filament-utils-android-lite-release.aar out/filament-utils-${TAG}-lite-android.aar
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.aar
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
@@ -126,18 +125,17 @@ jobs:
|
||||
TAG=${REF##*/}
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/ios && ./build.sh release
|
||||
cd build/ios && printf "y" | ./build.sh release
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
pip3 install setuptools
|
||||
pip3 install PyGithub
|
||||
DATE=`date +%Y%m%d`
|
||||
mv out/filament-release-ios.tgz out/filament-${DATE}-ios.tgz
|
||||
mv out/filament-release-ios.tgz out/filament-${TAG}-ios.tgz
|
||||
python3 build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
env:
|
||||
TAG: ${{ steps.git_ref.outputs.tag }}
|
||||
@@ -157,7 +155,7 @@ jobs:
|
||||
echo ::set-output name=ref::${REF}
|
||||
echo ::set-output name=tag::${TAG}
|
||||
shell: bash
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
with:
|
||||
ref: ${{ steps.git_ref.outputs.ref }}
|
||||
- name: Run build script
|
||||
@@ -167,8 +165,7 @@ jobs:
|
||||
- name: Upload release assets
|
||||
run: |
|
||||
pip3 install PyGithub
|
||||
DATE=`date +%Y%m%d`
|
||||
mv out/filament-windows.tgz out/filament-${DATE}-windows.tgz
|
||||
mv out/filament-windows.tgz out/filament-${TAG}-windows.tgz
|
||||
python build/common/upload-assets.py ${TAG} out/*.tgz
|
||||
shell: bash
|
||||
env:
|
||||
|
||||
8
.github/workflows/web-continuous.yml
vendored
8
.github/workflows/web-continuous.yml
vendored
@@ -3,7 +3,9 @@ name: Web
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- release
|
||||
- rc/**
|
||||
|
||||
jobs:
|
||||
build-web:
|
||||
@@ -11,10 +13,10 @@ jobs:
|
||||
runs-on: macos-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
cd build/web && ./build.sh continuous
|
||||
cd build/web && printf "y" | ./build.sh continuous
|
||||
- uses: actions/upload-artifact@v1.0.0
|
||||
with:
|
||||
name: filament-web
|
||||
|
||||
6
.github/workflows/windows-continuous.yml
vendored
6
.github/workflows/windows-continuous.yml
vendored
@@ -3,7 +3,9 @@ name: Windows
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- main
|
||||
- release
|
||||
- rc/**
|
||||
|
||||
jobs:
|
||||
build-windows:
|
||||
@@ -11,7 +13,7 @@ jobs:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1.0.0
|
||||
- uses: actions/checkout@v2.0.0
|
||||
- name: Run build script
|
||||
run: |
|
||||
build\windows\build-github.bat continuous
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -9,7 +9,6 @@ dist-*
|
||||
toolchains
|
||||
filament/docs/html/**
|
||||
.vscode
|
||||
gltf_baker.ini
|
||||
*tmp*.png
|
||||
civetweb.txt
|
||||
/TAGS
|
||||
|
||||
81
BRANCHING.md
Normal file
81
BRANCHING.md
Normal file
@@ -0,0 +1,81 @@
|
||||

|
||||
|
||||
## Which branch do I open my PR against?
|
||||
|
||||
For normal development, open PRs against main. Once they're merged, no further action is necessary.
|
||||
|
||||
If you discover a bug with the latest *release candidate*, open a bug fix PR against the release
|
||||
candidate branch (rc/1.9.0, for example). Once the PR is merged, decide whether it makes sense for
|
||||
the fix to also go into main. If it was a temporary fix, simply make the _correct_ fix in main as
|
||||
you would any other change. If the fix is good for main as well, use `git cherry-pick <sha>` to
|
||||
cherry-pick it into main.
|
||||
|
||||
If an immediate hotfix is needed on the *release* branch, open a PR against the release branch. Once
|
||||
the PR is merged, decide whether the fix is temporary or permanent. If the fix was temporary, make
|
||||
the _correct_ fix in both the next release candidate branch _and_ main. If the fix is good, use `git
|
||||
cherry-pick <sha>` to cherry-pick it into the relase candidate branch and main.
|
||||
|
||||
## What consitutes a bug?
|
||||
|
||||
Only bug fix PRs should be opened against the *release candidate* branch.
|
||||
|
||||
Bugs are defined as one of the following _introduced since the prior release_:
|
||||
|
||||
- crashes
|
||||
- rendering issues
|
||||
- unintentional binary size increases
|
||||
- unintentional public API changes
|
||||
|
||||
For example, a long-standing crash just recently discovered would not necessitate a bug fix PR.
|
||||
|
||||
## Creating a GitHub Release
|
||||
|
||||
Be sure to choose the *release* branch when drafting a GitHub release.
|
||||
|
||||
## Git Commands
|
||||
|
||||
These commands assume a release candidate branch called *rc/1.9.0*.
|
||||
|
||||
### Creating a Release Candidate Branch
|
||||
|
||||
```
|
||||
$ git checkout main
|
||||
$ git pull
|
||||
$ git branch rc/1.9.0
|
||||
$ git push origin rc/1.9.0
|
||||
```
|
||||
|
||||
### Merging the Release Candidate Branch Into Release
|
||||
|
||||
There may be temporary hotfixes in the release branch that should be overriden by the new release
|
||||
candidate. To accomplish this, we first merge release into rc using the _ours_ strategy. Then we
|
||||
merge rc into release.
|
||||
|
||||
```
|
||||
$ git checkout rc/1.9.0
|
||||
$ git pull
|
||||
$ git fetch origin release:release
|
||||
$ git merge -s ours release
|
||||
$ git checkout release
|
||||
$ git merge --no-ff rc/1.9.0
|
||||
$ git push origin release
|
||||
```
|
||||
|
||||
### Deleting the Release Candidate Branch
|
||||
|
||||
```
|
||||
$ git branch -d rc/1.9.0
|
||||
$ git push origin --delete rc/1.9.0
|
||||
```
|
||||
|
||||
### See a History of the Release Branch
|
||||
|
||||
```
|
||||
$ git log --oneline --first-parent
|
||||
|
||||
442b061 (HEAD -> release) Merge branch 'rc/1.9.2' into release
|
||||
ac50d21 Hotfix
|
||||
94dc2f7 Hotfix
|
||||
b34ed5b Merge branch 'rc/1.9.1' into release
|
||||
aeef498 Merge branch 'rc/1.9.0' into release
|
||||
```
|
||||
59
BUILDING.md
59
BUILDING.md
@@ -15,16 +15,11 @@ To build the Java based components of the project you can optionally install (re
|
||||
Additional dependencies may be required for your operating system. Please refer to the appropriate
|
||||
section below.
|
||||
|
||||
Building the `rays` library (used for light baking) is optional and requires the following packages:
|
||||
|
||||
- embree 3.0+
|
||||
- libtbb-dev
|
||||
|
||||
To build Filament for Android you must also install the following:
|
||||
|
||||
- Android Studio 3.6
|
||||
- Android Studio 4.0.1 or more recent
|
||||
- Android SDK
|
||||
- Android NDK "side-by-side" 20 or higher
|
||||
- Android NDK "side-by-side" 21.3 or higher
|
||||
|
||||
### Environment variables
|
||||
|
||||
@@ -79,20 +74,22 @@ compilation step simply pass the `-j` flag to `build.sh`:
|
||||
$ ./build.sh -j release
|
||||
```
|
||||
|
||||
If you use CMake directly instead of the build script, pass `-DENABLE_JAVA=OFF` to CMake instead.
|
||||
If you use CMake directly instead of the build script, pass `-DFILAMENT_ENABLE_JAVA=OFF`
|
||||
to CMake instead.
|
||||
|
||||
### Filament-specific CMake Options
|
||||
|
||||
The following CMake options are boolean options specific to Filament:
|
||||
|
||||
- `ENABLE_JAVA`: Compile Java projects: requires a JDK and the JAVA_HOME env var
|
||||
- `ENABLE_LTO`: Enable link-time optimizations if supported by the compiler
|
||||
- `FILAMENT_BUILD_FILAMAT`: Build filamat and JNI buildings
|
||||
- `FILAMENT_SUPPORTS_METAL`: Include the Metal backend
|
||||
- `FILAMENT_SUPPORTS_VULKAN`: Include the Vulkan backend
|
||||
- `GENERATE_JS_DOCS`: Build WebGL documentation and tutorials
|
||||
- `INSTALL_BACKEND_TEST`: Install the backend test library so it can be consumed on iOS
|
||||
- `USE_EXTERNAL_GLES3`: Experimental: Compile Filament against OpenGL ES 3
|
||||
- `FILAMENT_ENABLE_JAVA`: Compile Java projects: requires a JDK and the JAVA_HOME env var
|
||||
- `FILAMENT_ENABLE_LTO`: Enable link-time optimizations if supported by the compiler
|
||||
- `FILAMENT_BUILD_FILAMAT`: Build filamat and JNI buildings
|
||||
- `FILAMENT_SUPPORTS_METAL`: Include the Metal backend
|
||||
- `FILAMENT_SUPPORTS_VULKAN`: Include the Vulkan backend
|
||||
- `FILAMENT_INSTALL_BACKEND_TEST`: Install the backend test library so it can be consumed on iOS
|
||||
- `FILAMENT_USE_EXTERNAL_GLES3`: Experimental: Compile Filament against OpenGL ES 3
|
||||
- `FILAMENT_USE_SWIFTSHADER`: Compile Filament against SwiftShader
|
||||
- `FILAMENT_SKIP_SAMPLES`: Don't build sample apps
|
||||
|
||||
To turn an option on or off:
|
||||
|
||||
@@ -207,9 +204,12 @@ Install the following components:
|
||||
The latest Windows SDK can also by installed by opening Visual Studio and selecting _Get Tools and
|
||||
Features..._ under the _Tools_ menu.
|
||||
|
||||
Open the `x64 Native Tools Command Prompt for VS 2019`.
|
||||
By default, Windows treats the file system as case insensitive. Please do not enable case
|
||||
sensitivity in your repo, since this does not align with CMake expectations. This can be queried
|
||||
using `fsutil.exe file queryCaseSensitiveInfo`.
|
||||
|
||||
Create a working directory, and run cmake in it:
|
||||
Next, open `x64 Native Tools Command Prompt for VS 2019`, create a working directory, and run
|
||||
CMake in it:
|
||||
|
||||
```
|
||||
> mkdir out
|
||||
@@ -228,6 +228,13 @@ For example, build the `material_sandbox` sample and run it from the `out` direc
|
||||
> samples\Debug\material_sandbox.exe ..\assets\models\monkey\monkey.obj
|
||||
```
|
||||
|
||||
You can also use CMake to invoke the build without opening Visual Studio. For example, from the
|
||||
`out` folder run the following command.
|
||||
|
||||
```
|
||||
> cmake --build . --target gltf_viewer --config Release
|
||||
```
|
||||
|
||||
### Android
|
||||
|
||||
Before building Filament for Android, make sure to build Filament for your host. Some of the
|
||||
@@ -368,7 +375,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/1b1f08f.zip > emsdk.zip
|
||||
curl -L https://github.com/emscripten-core/emsdk/archive/1.39.19.zip > emsdk.zip
|
||||
unzip emsdk.zip ; mv emsdk-* emsdk ; cd emsdk
|
||||
python ./emsdk.py install latest
|
||||
python ./emsdk.py activate latest
|
||||
@@ -447,3 +454,17 @@ $ doxygen docs/doxygen/filament.doxygen
|
||||
```
|
||||
|
||||
Finally simply open `docs/html/index.html` in your web browser.
|
||||
|
||||
## SwiftShader
|
||||
|
||||
To try out Filament's Vulkan support with SwiftShader, first build SwiftShader and set the
|
||||
`SWIFTSHADER_LD_LIBRARY_PATH` variable to the folder that contains `libvk_swiftshader.dylib`:
|
||||
|
||||
```
|
||||
git clone https://github.com/google/swiftshader.git
|
||||
cd swiftshader/build
|
||||
cmake .. && make -j
|
||||
export SWIFTSHADER_LD_LIBRARY_PATH=`pwd`
|
||||
```
|
||||
|
||||
Next, go to your Filament repo and use the [easy build](#easy-build) script with `-t`.
|
||||
|
||||
227
CMakeLists.txt
227
CMakeLists.txt
@@ -11,14 +11,70 @@ project(TNT)
|
||||
# ==================================================================================================
|
||||
# Options
|
||||
# ==================================================================================================
|
||||
option(FILAMENT_ENABLE_JAVA "Compile Java projects, requires a JDK and the JAVA_HOME env var" ON)
|
||||
|
||||
option(ENABLE_JAVA "Compile Java projects, requires a JDK and the JAVA_HOME env var" ON)
|
||||
option(FILAMENT_USE_EXTERNAL_GLES3 "Experimental: Compile Filament against OpenGL ES 3" OFF)
|
||||
|
||||
option(USE_EXTERNAL_GLES3 "Experimental: Compile Filament against OpenGL ES 3" OFF)
|
||||
option(FILAMENT_USE_SWIFTSHADER "Compile Filament against SwiftShader" OFF)
|
||||
|
||||
option(GENERATE_JS_DOCS "Build WebGL documentation and tutorials" OFF)
|
||||
option(FILAMENT_ENABLE_LTO "Enable link-time optimizations if supported by the compiler" OFF)
|
||||
|
||||
option(ENABLE_LTO "Enable link-time optimizations if supported by the compiler" OFF)
|
||||
option(FILAMENT_SKIP_SAMPLES "Don't build samples" OFF)
|
||||
|
||||
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 "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 "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 "2" CACHE STRING
|
||||
"Size of the OpenGL handle arena, default 2."
|
||||
)
|
||||
|
||||
# ==================================================================================================
|
||||
# CMake policies
|
||||
# ==================================================================================================
|
||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.12")
|
||||
cmake_policy(SET CMP0074 NEW)
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Support for ccache
|
||||
# ==================================================================================================
|
||||
find_program(CCACHE_PROGRAM ccache)
|
||||
if (CCACHE_PROGRAM)
|
||||
set(C_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
set(CXX_LAUNCHER "${CCACHE_PROGRAM}")
|
||||
|
||||
configure_file(build/launch-c.in launch-c)
|
||||
configure_file(build/launch-cxx.in launch-cxx)
|
||||
|
||||
execute_process(COMMAND chmod a+rx
|
||||
"${CMAKE_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(CMAKE_C_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-c")
|
||||
set(CMAKE_CXX_COMPILER_LAUNCHER "${CMAKE_BINARY_DIR}/launch-cxx")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Support Vim and Visual Studio Code by generating compile_commands.json
|
||||
# ==================================================================================================
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
|
||||
# ==================================================================================================
|
||||
# OS specific
|
||||
@@ -31,6 +87,19 @@ if (ANDROID OR WEBGL OR IOS)
|
||||
set(IS_MOBILE_TARGET TRUE)
|
||||
endif()
|
||||
|
||||
if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
set(IS_HOST_PLATFORM TRUE)
|
||||
endif()
|
||||
|
||||
if (IOS)
|
||||
# Remove the headerpad_max_install_names linker flag on iOS. It causes warnings when linking
|
||||
# executables with bitcode.
|
||||
string(REPLACE "-Wl,-headerpad_max_install_names" "" CMAKE_C_LINK_FLAGS ${CMAKE_C_LINK_FLAGS})
|
||||
string(REPLACE "-Wl,-headerpad_max_install_names" "" CMAKE_CXX_LINK_FLAGS ${CMAKE_CXX_LINK_FLAGS})
|
||||
string(REPLACE "-Wl,-headerpad_max_install_names" "" CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
|
||||
string(REPLACE "-Wl,-headerpad_max_install_names" "" CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS})
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
# Link statically against c/c++ lib to avoid missing redistriburable such as
|
||||
# "VCRUNTIME140.dll not found. Try reinstalling the app.", but give users
|
||||
@@ -63,30 +132,23 @@ if (WIN32)
|
||||
# Instead generate debug info directly inside obj files.
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${CRT_FLAGS_DEBUG} /Z7")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Check if embree is available.
|
||||
# This is an optional dependency and can be installed with homebrew, apt-get, etc.
|
||||
# ==================================================================================================
|
||||
# Special settings when building on CI.
|
||||
if (${FILAMENT_WINDOWS_CI_BUILD})
|
||||
set(LinkerFlags
|
||||
CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
||||
CMAKE_EXE_LINKER_FLAGS_DEBUG
|
||||
CMAKE_MODULE_LINKER_FLAGS_DEBUG
|
||||
)
|
||||
foreach(LinkerFlag ${LinkerFlags})
|
||||
# The /debug flag outputs .pdb files, which we don't need on CI.
|
||||
string(REPLACE "/debug" "" ${LinkerFlag} ${${LinkerFlag}})
|
||||
|
||||
find_package(embree 3.0 QUIET PATHS /usr/lib64/cmake)
|
||||
if (embree_FOUND AND NOT ANDROID AND NOT IOS)
|
||||
message("Found embree in ${embree_DIR}")
|
||||
set(MKLDNN_THREADING "TBB")
|
||||
include(third_party/OpenImageDenoise/cmake/resource.cmake)
|
||||
include(third_party/OpenImageDenoise/mkl-dnn/cmake/Threading.cmake)
|
||||
include(third_party/OpenImageDenoise/mkl-dnn/cmake/TBB.cmake)
|
||||
find_package(TBB QUIET)
|
||||
if (TBB_FOUND AND "${TBB_VERSION_MAJOR}" VERSION_EQUAL 2019)
|
||||
message("Found TBB ${TBB_VERSION}")
|
||||
add_definitions(-DFILAMENT_HAS_EMBREE)
|
||||
set(DENOISE_LIBRARY OpenImageDenoise)
|
||||
else()
|
||||
message("TBB 2019 not found.")
|
||||
# The /INCREMENTAL flag outputs .ilk files for incremental linking. These are huge, and
|
||||
# we don't need them on CI.
|
||||
string(REPLACE "/INCREMENTAL" "/INCREMENTAL:NO" ${LinkerFlag} ${${LinkerFlag}})
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
message("Embree not found, pipeline features are disabled.")
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
@@ -128,16 +190,14 @@ endif()
|
||||
# Detect use of the clang-cl.exe frontend, which does not support all of clangs normal options
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if ("${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC")
|
||||
set(CLANG_CL true)
|
||||
message(FATAL_ERROR "Building with Clang on Windows is no longer supported. Use MSVC 2019 instead.")
|
||||
endif()
|
||||
elseif (MSVC)
|
||||
set(MSVC_NATIVE true)
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Link time optimizations (LTO)
|
||||
# ==================================================================================================
|
||||
if (ENABLE_LTO)
|
||||
if (FILAMENT_ENABLE_LTO)
|
||||
include(CheckIPOSupported)
|
||||
|
||||
check_ipo_supported(RESULT IPO_SUPPORT)
|
||||
@@ -151,38 +211,51 @@ endif()
|
||||
# ==================================================================================================
|
||||
# General compiler flags
|
||||
# ==================================================================================================
|
||||
set(CXX_STANDARD "-std=c++14")
|
||||
set(CXX_STANDARD "-std=c++17")
|
||||
if (WIN32)
|
||||
set(CXX_STANDARD "/std:c++14")
|
||||
set(CXX_STANDARD "/std:c++17")
|
||||
endif()
|
||||
|
||||
if (MSVC_NATIVE)
|
||||
if (MSVC)
|
||||
set(CXX_STANDARD "/std:c++latest")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} /W0 /Zc:__cplusplus")
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_STANDARD} -fstrict-aliasing -Wno-unknown-pragmas -Wno-unused-function")
|
||||
endif()
|
||||
|
||||
if (USE_EXTERNAL_GLES3)
|
||||
if (FILAMENT_USE_EXTERNAL_GLES3)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_EXTERNAL_GLES3")
|
||||
endif()
|
||||
|
||||
if (FILAMENT_USE_SWIFTSHADER)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DFILAMENT_USE_SWIFTSHADER")
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_USE_MATH_DEFINES=1")
|
||||
endif()
|
||||
|
||||
if (LINUX)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
link_libraries("-static-libgcc -static-libstdc++")
|
||||
link_libraries(libc++.a)
|
||||
link_libraries(libc++abi.a)
|
||||
option(USE_STATIC_LIBCXX "Link against the static runtime libraries." ON)
|
||||
if (${USE_STATIC_LIBCXX})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
|
||||
link_libraries("-static-libgcc -static-libstdc++")
|
||||
link_libraries(libc++.a)
|
||||
link_libraries(libc++abi.a)
|
||||
endif()
|
||||
|
||||
# Only linux, clang doesn't want to use a shared library that is not PIC.
|
||||
# /usr/bin/ld: ../bluegl/libbluegl.a(BlueGL.cpp.o): relocation R_X86_64_32S
|
||||
# against `.bss' can not be used when making a shared object; recompile with -fPIC
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
|
||||
|
||||
endif()
|
||||
|
||||
if (CYGWIN)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions -fno-rtti")
|
||||
endif()
|
||||
|
||||
if (CLANG_CL OR MSVC)
|
||||
if (MSVC)
|
||||
# Since the "secure" replacements that MSVC suggests are not portable, disable
|
||||
# the deprecation warnings. Also disable warnings about use of POSIX functions (i.e. "unlink").
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE")
|
||||
@@ -198,8 +271,13 @@ endif()
|
||||
# ==================================================================================================
|
||||
# Release compiler flags
|
||||
# ==================================================================================================
|
||||
if (NOT CLANG_CL AND NOT MSVC)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections")
|
||||
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)
|
||||
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
|
||||
@@ -222,8 +300,7 @@ endif()
|
||||
# -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")
|
||||
# clang-cl.exe on Windows does not support -fstack-protector.
|
||||
if (NOT CLANG_CL AND NOT MSVC AND NOT WEBGL)
|
||||
if (NOT MSVC AND NOT WEBGL)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector")
|
||||
endif()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_SANITIZE_OPTIONS}")
|
||||
@@ -253,9 +330,6 @@ if (APPLE)
|
||||
# prevents ar from invoking ranlib, let CMake do it
|
||||
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qc -S <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> qc -S <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
elseif (CLANG_CL)
|
||||
set(GC_SECTIONS "")
|
||||
set(B_SYMBOLIC_FUNCTIONS "")
|
||||
endif()
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GC_SECTIONS}")
|
||||
@@ -275,9 +349,8 @@ if (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebIn
|
||||
endif()
|
||||
|
||||
# By default, build with Vulkan support on desktop platforms, although clients must request to use
|
||||
# it at run time. On Android, the build does not include Vulkan support unless CMake is invoked
|
||||
# with -DFILAMENT_SUPPORTS_VULKAN=ON.
|
||||
if (ANDROID OR WIN32 OR WEBGL OR IOS)
|
||||
# it at run time.
|
||||
if (WIN32 OR WEBGL OR IOS)
|
||||
option(FILAMENT_SUPPORTS_VULKAN "Include the Vulkan backend" OFF)
|
||||
else()
|
||||
option(FILAMENT_SUPPORTS_VULKAN "Include the Vulkan backend" ON)
|
||||
@@ -287,8 +360,7 @@ if (FILAMENT_SUPPORTS_VULKAN)
|
||||
endif()
|
||||
|
||||
# Build with Metal support on non-WebGL Apple platforms.
|
||||
# Apple's simulator does not support Metal.
|
||||
if (APPLE AND (NOT IOS OR IOS_ARCH STREQUAL "arm64") AND NOT WEBGL)
|
||||
if (APPLE AND NOT WEBGL)
|
||||
option(FILAMENT_SUPPORTS_METAL "Include the Metal backend" ON)
|
||||
else()
|
||||
option(FILAMENT_SUPPORTS_METAL "Include the Metal backend" OFF)
|
||||
@@ -304,6 +376,13 @@ else()
|
||||
option(FILAMENT_BUILD_FILAMAT "Build filamat and JNI buildings" OFF)
|
||||
endif()
|
||||
|
||||
# By default, link in matdbg for Desktop + Debug only since it pulls in filamat and a web server.
|
||||
if (CMAKE_BUILD_TYPE STREQUAL "Debug" AND IS_HOST_PLATFORM)
|
||||
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" ON)
|
||||
else()
|
||||
option(FILAMENT_ENABLE_MATDBG "Enable the material debugger" OFF)
|
||||
endif()
|
||||
|
||||
# ==================================================================================================
|
||||
# Material compilation flags
|
||||
# ==================================================================================================
|
||||
@@ -404,7 +483,14 @@ endif()
|
||||
# "bluevk" and "samples" targets.
|
||||
# ==================================================================================================
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN AND APPLE)
|
||||
if (FILAMENT_USE_SWIFTSHADER)
|
||||
if (NOT FILAMENT_SUPPORTS_VULKAN)
|
||||
message(ERROR "SwiftShader is only useful when Vulkan is enabled.")
|
||||
endif()
|
||||
find_library(SWIFTSHADER_VK NAMES vk_swiftshader HINTS "$ENV{SWIFTSHADER_LD_LIBRARY_PATH}")
|
||||
message(STATUS "Found SwiftShader VK library in: ${SWIFTSHADER_VK}.")
|
||||
add_definitions(-DFILAMENT_VKLIBRARY_PATH=\"${SWIFTSHADER_VK}\")
|
||||
elseif (FILAMENT_SUPPORTS_VULKAN AND APPLE)
|
||||
find_library(Vulkan_LIBRARY NAMES vulkan HINTS "$ENV{VULKAN_SDK}/lib" "$ENV{VULKAN_SDK}/macOS/lib")
|
||||
if (Vulkan_LIBRARY)
|
||||
set(Vulkan_FOUND ON)
|
||||
@@ -439,11 +525,11 @@ function(get_resgen_vars ARCHIVE_DIR ARCHIVE_NAME)
|
||||
# the equivalent of .incbin, so on Windows we'll just tell resgen to output a C file.
|
||||
if (WEBGL OR WIN32 OR ANDROID_ON_WINDOWS)
|
||||
set(RESGEN_OUTPUTS "${OUTPUTS};${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE)
|
||||
set(RESGEN_FLAGS -cx ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE)
|
||||
set(RESGEN_FLAGS -qcx ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE)
|
||||
set(RESGEN_SOURCE "${ARCHIVE_DIR}/${ARCHIVE_NAME}.c" PARENT_SCOPE)
|
||||
else()
|
||||
set(RESGEN_OUTPUTS "${OUTPUTS}" PARENT_SCOPE)
|
||||
set(RESGEN_FLAGS -x ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE)
|
||||
set(RESGEN_FLAGS -qx ${ARCHIVE_DIR} -p ${ARCHIVE_NAME} PARENT_SCOPE)
|
||||
set(RESGEN_SOURCE "${ARCHIVE_DIR}/${ARCHIVE_NAME}${ASM_SUFFIX}.S" PARENT_SCOPE)
|
||||
set(RESGEN_SOURCE_FLAGS "-I${ARCHIVE_DIR} ${ASM_ARCH_FLAG}" PARENT_SCOPE)
|
||||
endif()
|
||||
@@ -463,27 +549,34 @@ add_subdirectory(${LIBRARIES}/geometry)
|
||||
add_subdirectory(${LIBRARIES}/gltfio)
|
||||
add_subdirectory(${LIBRARIES}/ibl)
|
||||
add_subdirectory(${LIBRARIES}/image)
|
||||
add_subdirectory(${LIBRARIES}/rays)
|
||||
add_subdirectory(${LIBRARIES}/math)
|
||||
add_subdirectory(${LIBRARIES}/mathio)
|
||||
add_subdirectory(${LIBRARIES}/utils)
|
||||
add_subdirectory(${FILAMENT}/filament)
|
||||
add_subdirectory(${FILAMENT}/shaders)
|
||||
add_subdirectory(${EXTERNAL}/hat-trie/tnt)
|
||||
add_subdirectory(${EXTERNAL}/robin-map/tnt)
|
||||
add_subdirectory(${EXTERNAL}/smol-v/tnt)
|
||||
add_subdirectory(${EXTERNAL}/benchmark/tnt)
|
||||
add_subdirectory(${EXTERNAL}/meshoptimizer)
|
||||
add_subdirectory(${EXTERNAL}/cgltf/tnt)
|
||||
add_subdirectory(${EXTERNAL}/xatlas/tnt)
|
||||
add_subdirectory(${EXTERNAL}/draco/tnt)
|
||||
add_subdirectory(${EXTERNAL}/stb/tnt)
|
||||
add_subdirectory(${EXTERNAL}/getopt)
|
||||
|
||||
if (FILAMENT_BUILD_FILAMAT)
|
||||
if (FILAMENT_BUILD_FILAMAT OR IS_HOST_PLATFORM)
|
||||
# spirv-tools must come before filamat, as filamat relies on the presence of the
|
||||
# spirv-tools_SOURCE_DIR variable.
|
||||
add_subdirectory(${EXTERNAL}/spirv-tools)
|
||||
add_subdirectory(${EXTERNAL}/glslang/tnt)
|
||||
add_subdirectory(${EXTERNAL}/spirv-cross/tnt)
|
||||
add_subdirectory(${LIBRARIES}/filamat)
|
||||
|
||||
# the material debugger requires filamat
|
||||
if (FILAMENT_ENABLE_MATDBG OR IS_HOST_PLATFORM)
|
||||
add_subdirectory(${EXTERNAL}/civetweb/tnt)
|
||||
add_subdirectory(${LIBRARIES}/matdbg)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
@@ -495,41 +588,37 @@ if (APPLE)
|
||||
add_subdirectory(${EXTERNAL}/moltenvk/tnt)
|
||||
endif()
|
||||
|
||||
set (FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples)
|
||||
set(FILAMENT_SAMPLES_BINARY_DIR ${PROJECT_BINARY_DIR}/samples)
|
||||
|
||||
if (WEBGL)
|
||||
add_subdirectory(web/filament-js)
|
||||
add_subdirectory(web/samples)
|
||||
|
||||
if (GENERATE_JS_DOCS)
|
||||
add_subdirectory(web/docs)
|
||||
endif()
|
||||
|
||||
add_subdirectory(${EXTERNAL}/imgui/tnt)
|
||||
endif()
|
||||
|
||||
if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
if (IS_HOST_PLATFORM)
|
||||
add_subdirectory(${LIBRARIES}/bluegl)
|
||||
add_subdirectory(${LIBRARIES}/filamentapp)
|
||||
add_subdirectory(${LIBRARIES}/filagui)
|
||||
add_subdirectory(${LIBRARIES}/imageio)
|
||||
add_subdirectory(${LIBRARIES}/matdbg)
|
||||
|
||||
add_subdirectory(${FILAMENT}/java/filamat)
|
||||
add_subdirectory(${FILAMENT}/java/filament)
|
||||
add_subdirectory(${FILAMENT}/java/gltfio)
|
||||
|
||||
add_subdirectory(${FILAMENT}/samples)
|
||||
|
||||
add_subdirectory(${EXTERNAL}/astcenc/tnt)
|
||||
add_subdirectory(${EXTERNAL}/civetweb/tnt)
|
||||
add_subdirectory(${EXTERNAL}/etc2comp)
|
||||
add_subdirectory(${EXTERNAL}/imgui/tnt)
|
||||
add_subdirectory(${EXTERNAL}/libassimp/tnt)
|
||||
add_subdirectory(${EXTERNAL}/libpng/tnt)
|
||||
add_subdirectory(${EXTERNAL}/libsdl2/tnt)
|
||||
add_subdirectory(${EXTERNAL}/libz/tnt)
|
||||
add_subdirectory(${EXTERNAL}/skylight/tnt)
|
||||
add_subdirectory(${EXTERNAL}/tinyexr/tnt)
|
||||
|
||||
add_subdirectory(${TOOLS}/cmgen)
|
||||
add_subdirectory(${TOOLS}/cso-lut)
|
||||
add_subdirectory(${TOOLS}/filamesh)
|
||||
add_subdirectory(${TOOLS}/glslminifier)
|
||||
add_subdirectory(${TOOLS}/matc)
|
||||
@@ -538,13 +627,7 @@ if (NOT ANDROID AND NOT WEBGL AND NOT IOS)
|
||||
add_subdirectory(${TOOLS}/normal-blending)
|
||||
add_subdirectory(${TOOLS}/resgen)
|
||||
add_subdirectory(${TOOLS}/roughness-prefilter)
|
||||
add_subdirectory(${TOOLS}/skygen)
|
||||
add_subdirectory(${TOOLS}/specular-color)
|
||||
|
||||
if (DENOISE_LIBRARY)
|
||||
add_subdirectory(${EXTERNAL}/OpenImageDenoise/tnt)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# Generate exported executables for cross-compiled builds (Android, WebGL, and iOS)
|
||||
|
||||
199
README.md
199
README.md
@@ -1,11 +1,11 @@
|
||||
# Filament
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
[](https://github.com/google/filament/actions?query=workflow%3AAndroid)
|
||||
[](https://github.com/google/filament/actions?query=workflow%3AiOS)
|
||||
[](https://github.com/google/filament/actions?query=workflow%3ALinux)
|
||||
[](https://github.com/google/filament/actions?query=workflow%3AmacOS)
|
||||
[](https://github.com/google/filament/actions?query=workflow%3AWindows)
|
||||
[](https://github.com/google/filament/actions?query=workflow%3AWeb)
|
||||
|
||||
Filament is a real-time physically based rendering engine for Android, iOS, Linux, macOS, Windows,
|
||||
and WebGL. It is designed to be as small as possible and as efficient as possible on Android.
|
||||
@@ -31,26 +31,47 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'com.google.android.filament:filament-android:1.4.4'
|
||||
implementation 'com.google.android.filament:filament-android:1.9.2'
|
||||
}
|
||||
```
|
||||
|
||||
Here are all the libraries available in the group `com.google.android.filament`:
|
||||
|
||||
- `filament-android`: the Filament rendering engine itself
|
||||
- `gltfio-android`: a glTF 2.0 loader for Filament, depends on `filament-android`
|
||||
- `filament-utils-android`: KTX loading, Kotlin math, and camera utilities, depends on `gltfio-android`
|
||||
- `filamat-android-full`: a runtime material builder/compiler. This library is large but contains
|
||||
a full shader compiler/validator/optimizer
|
||||
- `filamat-android-lite`: a much smaller alternative to `filamat-android-full` that can only
|
||||
generate OpenGL shaders. It does not provide validation or optimizations
|
||||
[](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/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 features.
|
||||
|
||||
[](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/filament-utils-android-lite)
|
||||
Trimmed version of `filament-utils` that does not support some glTF features.
|
||||
|
||||
[](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.
|
||||
|
||||
[](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.
|
||||
|
||||
### iOS
|
||||
|
||||
iOS projects can use CocoaPods to install the latest release:
|
||||
|
||||
```
|
||||
pod 'Filament', '~> 1.9.2'
|
||||
```
|
||||
|
||||
### Snapshots
|
||||
|
||||
If you prefer to live on the edge, you can download a continuous build by following the following
|
||||
steps:
|
||||
|
||||
1. Find the [commit](https://github.com/google/filament/commits/master) you're interested in.
|
||||
1. Find the [commit](https://github.com/google/filament/commits/main) you're interested in.
|
||||
2. Click the green check mark under the commit message.
|
||||
3. Click on the _Details_ link for the platform you're interested in.
|
||||
4. On the top right, click on the _Artifacts_ dropdown and choose an artifact.
|
||||
@@ -69,17 +90,13 @@ steps:
|
||||
|
||||
## Examples
|
||||
|
||||
### Materials
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
Here are a few sample materials rendered with Filament:
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
### Applications
|
||||
|
||||
@@ -124,12 +141,21 @@ Here are a few screenshots of applications that use Filament in production:
|
||||
- Image-based lighting
|
||||
- Physically-based camera (shutter speed, sensitivity and aperture)
|
||||
- Physical light units
|
||||
- Point light, spot light and directional light
|
||||
- SSAO
|
||||
- ACES-like tone-mapping
|
||||
- Temporal dithering
|
||||
- FXAA, MSAA and specular anti-aliasing
|
||||
- Dynamic resolution (on Android and iOS)
|
||||
- Point lights, spot lights and directional light
|
||||
- Spot and directional light shadows
|
||||
- Cascaded shadows
|
||||
- VSM or PCF shadows
|
||||
- Contact shadows
|
||||
- Screen-space ambient occlusion
|
||||
- Screen-space refraction
|
||||
- Global fog
|
||||
- HDR bloom
|
||||
- Depth of field bokeh
|
||||
- Multiple tone mappers: ACES, filmic, etc.
|
||||
- Color grading: white balance, channel mixer, shadows/mid-tones/highlights, ASC CDL,
|
||||
contrast, saturation, etc.
|
||||
- TAA, FXAA, MSAA and specular anti-aliasing
|
||||
- Dynamic resolution
|
||||
|
||||
## Rendering with Filament
|
||||
|
||||
@@ -147,7 +173,7 @@ Renderer* renderer = engine->createRenderer();
|
||||
To render a frame you must then create a `View`, a `Scene` and a `Camera`:
|
||||
|
||||
```c++
|
||||
Camera* camera = engine->createCamera();
|
||||
Camera* camera = engine->createCamera(EntityManager::get().create());
|
||||
View* view = engine->createView();
|
||||
Scene* scene = engine->createScene();
|
||||
|
||||
@@ -227,11 +253,12 @@ creating the swap chain in the `onNativeWindowChanged()` callback.
|
||||
|
||||
### iOS
|
||||
|
||||
See `ios/samples` for examples of using Filament on iOS.
|
||||
Filament is supported on iOS 11.0 and above. See `ios/samples` for examples of using Filament on
|
||||
iOS.
|
||||
|
||||
Filament on iOS is largely the same as native rendering with C++. A `CAEAGLLayer` or `CAMetalLayer`
|
||||
is passed to the `createSwapChain` method. Filament for iOS supports both OpenGL ES and Vulkan via
|
||||
MoltenVK.
|
||||
is passed to the `createSwapChain` method. Filament for iOS supports both Metal (preferred) and
|
||||
OpenGL ES.
|
||||
|
||||
## Assets
|
||||
|
||||
@@ -249,56 +276,58 @@ familiar with the [code style](/CODE_STYLE.md).
|
||||
This repository not only contains the core Filament engine, but also its supporting libraries
|
||||
and tools.
|
||||
|
||||
- `android`: Android libraries and projects
|
||||
- `filamat-android`: Filament material generation library (AAR) for Android
|
||||
- `filament-android`: Filament library (AAR) for Android
|
||||
- `gltfio-android`: Filament glTF loading library (AAR) for Android
|
||||
- `samples`: Android-specific Filament samples
|
||||
- `art`: Source for various artworks (logos, PDF manuals, etc.)
|
||||
- `assets`: 3D assets to use with sample applications
|
||||
- `build`: CMake build scripts
|
||||
- `docs`: Documentation
|
||||
- `math`: Mathematica notebooks used to explore BRDFs, equations, etc.
|
||||
- `filament`: Filament rendering engine (minimal dependencies)
|
||||
- `ide`: Configuration files for IDEs (CLion, etc.)
|
||||
- `ios`: Sample projects for iOS
|
||||
- `java`: Java bindings for Filament libraries
|
||||
- `libs`: Libraries
|
||||
- `bluegl`: OpenGL bindings for macOS, Linux and Windows
|
||||
- `bluevk`: Vulkan bindings for macOS, Linux, Windows and Android
|
||||
- `filabridge`: Library shared by the Filament engine and host tools
|
||||
- `filaflat`: Serialization/deserialization library used for materials
|
||||
- `filagui`: Helper library for [Dear ImGui](https://github.com/ocornut/imgui)
|
||||
- `filamat`: Material generation library
|
||||
- `filameshio`: Tiny filamesh parsing library (see also `tools/filamesh`)
|
||||
- `geometry`: Mesh-related utilities
|
||||
- `gltfio`: Loader and optional pipeline for glTF 2.0
|
||||
- `ibl`: IBL generation tools
|
||||
- `image`: Image filtering and simple transforms
|
||||
- `imageio`: Image file reading / writing, only intended for internal use
|
||||
- `matdbg`: DebugServer for inspecting shaders at run-time (debug builds only)
|
||||
- `math`: Math library
|
||||
- `rays`: Simple path tracer used for baking ambient occlusion, etc.
|
||||
- `utils`: Utility library (threads, memory, data structures, etc.)
|
||||
- `samples`: Sample desktop applications
|
||||
- `shaders`: Shaders used by `filamat` and `matc`
|
||||
- `third_party`: External libraries and assets
|
||||
- `environments`: Environment maps under CC0 license that can be used with `cmgen`
|
||||
- `models`: Models under permissive licenses
|
||||
- `textures`: Textures under CC0 license
|
||||
- `tools`: Host tools
|
||||
- `cmgen`: Image-based lighting asset generator
|
||||
- `filamesh`: Mesh converter
|
||||
- `glslminifier`: Minifies GLSL source code
|
||||
- `matc`: Material compiler
|
||||
- `matinfo` Displays information about materials compiled with `matc`
|
||||
- `mipgen` Generates a series of miplevels from a source image
|
||||
- `normal-blending`: Tool to blend normal maps
|
||||
- `resgen` Aggregates binary blobs into embeddable resources
|
||||
- `roughness-prefilter`: Pre-filters a roughness map from a normal map to reduce aliasing
|
||||
- `skygen`: Physically-based sky environment texture generator
|
||||
- `specular-color`: Computes the specular color of conductors based on spectral data
|
||||
- `web`: JavaScript bindings, documentation, and samples
|
||||
- `android`: Android libraries and projects
|
||||
- `filamat-android`: Filament material generation library (AAR) for Android
|
||||
- `filament-android`: Filament library (AAR) for Android
|
||||
- `filament-utils-android`: Extra utilities (KTX loader, math types, etc.)
|
||||
- `gltfio-android`: Filament glTF loading library (AAR) for Android
|
||||
- `samples`: Android-specific Filament samples
|
||||
- `art`: Source for various artworks (logos, PDF manuals, etc.)
|
||||
- `assets`: 3D assets to use with sample applications
|
||||
- `build`: CMake build scripts
|
||||
- `docs`: Documentation
|
||||
- `math`: Mathematica notebooks used to explore BRDFs, equations, etc.
|
||||
- `filament`: Filament rendering engine (minimal dependencies)
|
||||
- `ide`: Configuration files for IDEs (CLion, etc.)
|
||||
- `ios`: Sample projects for iOS
|
||||
- `java`: Java bindings for Filament libraries
|
||||
- `libs`: Libraries
|
||||
- `bluegl`: OpenGL bindings for macOS, Linux and Windows
|
||||
- `bluevk`: Vulkan bindings for macOS, Linux, Windows and Android
|
||||
- `camutils`: Camera manipulation utilities
|
||||
- `filabridge`: Library shared by the Filament engine and host tools
|
||||
- `filaflat`: Serialization/deserialization library used for materials
|
||||
- `filagui`: Helper library for [Dear ImGui](https://github.com/ocornut/imgui)
|
||||
- `filamat`: Material generation library
|
||||
- `filamentapp`: SDL2 skeleton to build sample apps
|
||||
- `filameshio`: Tiny filamesh parsing library (see also `tools/filamesh`)
|
||||
- `geometry`: Mesh-related utilities
|
||||
- `gltfio`: Loader for glTF 2.0
|
||||
- `ibl`: IBL generation tools
|
||||
- `image`: Image filtering and simple transforms
|
||||
- `imageio`: Image file reading / writing, only intended for internal use
|
||||
- `matdbg`: DebugServer for inspecting shaders at run-time (debug builds only)
|
||||
- `math`: Math library
|
||||
- `mathio`: Math types support for output streams
|
||||
- `utils`: Utility library (threads, memory, data structures, etc.)
|
||||
- `samples`: Sample desktop applications
|
||||
- `shaders`: Shaders used by `filamat` and `matc`
|
||||
- `third_party`: External libraries and assets
|
||||
- `environments`: Environment maps under CC0 license that can be used with `cmgen`
|
||||
- `models`: Models under permissive licenses
|
||||
- `textures`: Textures under CC0 license
|
||||
- `tools`: Host tools
|
||||
- `cmgen`: Image-based lighting asset generator
|
||||
- `filamesh`: Mesh converter
|
||||
- `glslminifier`: Minifies GLSL source code
|
||||
- `matc`: Material compiler
|
||||
- `matinfo` Displays information about materials compiled with `matc`
|
||||
- `mipgen` Generates a series of miplevels from a source image
|
||||
- `normal-blending`: Tool to blend normal maps
|
||||
- `resgen` Aggregates binary blobs into embeddable resources
|
||||
- `roughness-prefilter`: Pre-filters a roughness map from a normal map to reduce aliasing
|
||||
- `specular-color`: Computes the specular color of conductors based on spectral data
|
||||
- `web`: JavaScript bindings, documentation, and samples
|
||||
|
||||
## License
|
||||
|
||||
|
||||
191
RELEASE_NOTES.md
191
RELEASE_NOTES.md
@@ -3,7 +3,196 @@
|
||||
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.
|
||||
|
||||
## Next release
|
||||
## v1.9.2
|
||||
|
||||
- Fixes / improvements for contact shadows, fog, and DOF
|
||||
- Reduce SSAO creases caused by geometry tessellation
|
||||
- Fix compilation warnings and issue with Clang 12
|
||||
- Fix JNI crashes
|
||||
- Rename .blurScale to .cocScale in DOF options
|
||||
|
||||
## v1.9.1
|
||||
|
||||
- Improvements to SSAO quality
|
||||
- Fix unoptimized shader crashes with certain OpenGL drivers
|
||||
- Add float versions of math constants to libmath
|
||||
- filament-utils: fix, `CoroutineScope` job should be canceled before destroy
|
||||
|
||||
## v1.9.0
|
||||
|
||||
- `MASKED` mode now leaves destination alpha intact (useful for transparent targets).
|
||||
- `MASKED` mode now benefit from smoothing in `unlit` materials.
|
||||
- Small performance improvement to FXAA.
|
||||
- Fixed `KHR_materials_transmission` to use the `FADE` blending mode.
|
||||
- Fixed frame graph crash when more than 32 stages were required.
|
||||
- Fixed several memory leaks in gltfio and the JavaScript bindings.
|
||||
- Fixed several platform-specific Vulkan bugs and crashes.
|
||||
- Temporal Anti-Aliasing (TAA) is now available as a complement to MSAA and FXAA. It can be turned
|
||||
on and controlled using `View.setTemporalAntiAliasingOptions()`.
|
||||
- Added texture getters to `Skybox` and `IndirectLight` (C++, Java, JavaScript).
|
||||
- Added APIs to create 3D textures and 2D texture arrays.
|
||||
- Internal buffers can now be sized at compile times for applications that render very large
|
||||
numbers of objects.
|
||||
- `View.setAmbientOcclusion()` is deprecated in favor of `View.setAmbientOcclusionOptions`
|
||||
(⚠️ **API change**).
|
||||
- Switched to C++17.
|
||||
- Variance Shadow Mapping (VSM) is now available as an alternative to PCF shadows (experimental).
|
||||
- Reduced compiled material sizes by removing unnecessary variants.
|
||||
- Many improvement and fixes in the Vulkan backend.
|
||||
- Many improvement and fixes in the Metal backend.
|
||||
- Fixed translucent views with custom render targets.
|
||||
- Improved MSAA implementation compatibility on Android devices.
|
||||
- Use "reverse-z" for the depth buffer.
|
||||
- Added a way to create an `Engine` asynchronously.
|
||||
- Highlights are now more stable under depth of field.
|
||||
- New option to compress highlights before bloom.
|
||||
- Improvements and fixes to SSAO and DOF.
|
||||
|
||||
## v1.8.1
|
||||
|
||||
- New CocoaPods sample for iOS.
|
||||
- Filament for iOS now supports iOS 11.
|
||||
- Updated the Emscripten SDK to 1.39.19.
|
||||
- Fixed skinning issue with Emscripten.
|
||||
- JavaScript APIs for color grading and the vignette effect.
|
||||
- Added various missing APIs to Java and JavaScript bindings.
|
||||
- Fixed camera aspect ratio when loading a camera from a glTF file.
|
||||
- gltfio now uses specular anti-aliasing by default.
|
||||
- gltfio now supports the KHR_materials_transmission extension.
|
||||
- Compiled materials do not perform unnecessary fp32 operations anymore.
|
||||
- Improved quality and performance of the depth of field effect.
|
||||
- Fixed transform hierarchy memory corruption when a node is set to be parentless.
|
||||
- Fixed crashed in some browsers and on some mobile devices caused by
|
||||
Google-style line directives in shaders.
|
||||
- Color grading now has a quality option which affects the size and bit depth of the 3D LUT.
|
||||
- Fixed crash in the Metal backend when more than 16 samplers are bound.
|
||||
- Added validation in `Texture::setImage()`.
|
||||
- Fixed refraction/transmission roughness when specular anti-aliasing is enabled.
|
||||
|
||||
## v1.8.0
|
||||
|
||||
- Improved JavaScript API for SurfaceOrientation and Scene.
|
||||
- Updated JavaScript API around Camera construction / destruction (⚠️ **API change**)
|
||||
- Add missing JavaScript API for `View::setVisibleLayers()`.
|
||||
- Fixed regression in JavaScript IcoSphere that caused tutorial to fail.
|
||||
- gltf_viewer now supports viewing with glTF cameras.
|
||||
- gltfio now uses high precision for texture coordinates.
|
||||
- gltfio now supports importing glTF cameras.
|
||||
- gltfio now supports simple instancing of entire assets.
|
||||
- gltfio has improved performance and assumes assets are well-formed.
|
||||
- gltfio now supports name and prefix lookup for entities.
|
||||
- ModelViewer now allows resources to be fetched off the UI thread.
|
||||
- Add support for DOF with Metal backend.
|
||||
- New Depth-of-Field (Dof) algorithm, which is more plausible and about an order of magnitude faster
|
||||
(about 4ms on Pixel4).
|
||||
- SSAO now has an optional high(er) quality upsampler.
|
||||
- Tone mappping now uses the real ACES tone mapper, applied in the proper color space.
|
||||
- Tone mapping is now applied via a LUT.
|
||||
- `View::setToneMapping` is deprecated, use `View::setColorGrading` instead. (⚠️ **API change**)
|
||||
- Color grading capabilities per View: white balance (temperature/tint), channel mixer,
|
||||
tonal ranges (shadows/mid-tones/highlights), ASC CDL (slope/offset/power), contrast, vibrance,
|
||||
saturation, and curves.
|
||||
- New vignette effect.
|
||||
- Improved MSAA performance on mobile.
|
||||
- Improved performance of the post-process pass when bloom is disabled on mobile.
|
||||
- Added support for 3D textures.
|
||||
- Fixed private API access on some versions of Android.
|
||||
- Many improvements and bug fixes in Metal and Vulkan backends.
|
||||
- Fixed bug in the Metal backend when SSR and MSAA were turned on.
|
||||
- Fixed Metal issue with `BufferDescriptor` and `PixelBufferDescriptor`s not being called on
|
||||
the application thread.
|
||||
|
||||
## v1.7.0
|
||||
|
||||
- MaterialInstances now have optional names.
|
||||
- Improved Depth of Field effect: bokeh rotates with the aperture diameter, improved CoC calculation, feather blur radius.
|
||||
- Introduced `getNormalizedViewportCoord` shader API.
|
||||
- Added basic SwiftShader support.
|
||||
- Fixed SwapChain resizing issues in Vulkan.
|
||||
- Added debug option to track `Entities`.
|
||||
- Fixed `Camera` entity leaks.
|
||||
- Removed problematic `CreateEliminateDeadMembersPass`, which broke UBO layout.
|
||||
- Added assert that the engine is not terminated in `flushAndWait()`.
|
||||
- Added several fixes and improvements around objects lifetime management
|
||||
- `gltfio`: AssetLoader now loads names for mesh-free nodes
|
||||
- `gltfio`: Material names are now preserved in ubershader mode
|
||||
- Fixed JNI objects allocation and memory corruption
|
||||
- JNI constructors are now "package private" unless they take an Engine.
|
||||
|
||||
## v1.6.0
|
||||
|
||||
- gltfio: fixed incorrect cone angles with lights.
|
||||
- Specular ambient occlusion now offers 3 modes: off, simple (default on desktop) and bent normals.
|
||||
The latter is more accurate but more expensive and requires a bent normal to be specified in the
|
||||
material. If selected and not bent normal is specified, Filament falls back to the simple mode.
|
||||
- Specular ambient occlusion from bent normals now smoothly disappears as roughness goes from 0.3
|
||||
to 0.1. Specular ambient occlusion can completely remove specular light which looks bad on glossy
|
||||
metals. Use the simple specular occlusion mode for glossy metals instead.
|
||||
- Refraction can now be set on `MaterialBuilder` from Java.
|
||||
- Refraction mode and type can now be set by calling `MaterialBuilder::refractionMode()`.
|
||||
and `MaterialBuilder::refractionType()` instad of `materialRefraction()` and
|
||||
`materialRefractionType()` (️⚠️ **API change**).
|
||||
- Fixed documentation confusion about focused spot vs spot lights.
|
||||
- Fixed a race condition in the job system.
|
||||
- Fixed support for 565 bitmaps on Android.
|
||||
- Added support for timer queries in the Metal backend.
|
||||
- Improved dynamic resolution implementation to be more accurate and target more platforms.
|
||||
- `beginFrame()` now accepts a v-sync timestamp for accurate frame time measurement (used for
|
||||
frame skipping and dynamic resolution). You can pass `0` to get the old behavior (⚠️ **API change**).
|
||||
- Fixed several issues related to multi-view support: removed
|
||||
`View::setClearColor()`, a similar functionality is now handled by `Renderer::setClearOptions()`
|
||||
and `Skybox`, the later now can be set to a constant color (⚠️ **API breakage**).
|
||||
- Fixed spot/point lights rendering bug depending on Viewport position.
|
||||
- Textures can now be swizzled.
|
||||
- The emissive property of materials is now expressed in nits and the alpha channel contains the
|
||||
exposure weight (at 0.0 the exposure is not applied to the emissive component of a surface, at
|
||||
1.0 the exposure is applied just like with any regular light) (⚠️ **API breakage**).
|
||||
- Added new `intensityCandela` and `setIntensityCandela` API to `LightManager` for setting a punctual
|
||||
light's intensity in candela.
|
||||
- Fixed an issue where some `ShadowOptions` were not being respected when passed to
|
||||
`LightManager::Builder`.
|
||||
- Added a Depth of Field post-processing effect
|
||||
|
||||
## v1.5.2
|
||||
|
||||
- gltfio: fixed null pointer exception seen with some Android clients.
|
||||
- Engine now exposes its JobSystem to C++ clients.
|
||||
- Expose setCulling() in public RenderableManager API.
|
||||
|
||||
## v1.5.1
|
||||
|
||||
- Fixed "no texture bound" warning in WebGL.
|
||||
- Fixed a clearing bug with imported render targets.
|
||||
- Fixed the creation potentially invalid entities during shadow map initialization.
|
||||
- Fixed Maven dependencies for the `filament-utils` library.
|
||||
|
||||
## v1.5.0
|
||||
|
||||
⚠️ This release breaks compiled materials, use matc to recompile.
|
||||
|
||||
- The Android support libraries (gltfio and filament-utils) now use dynamic linking.
|
||||
- Removed depth-prepass related APIs. (⚠ API Change)
|
||||
- gltfio: add asynchronous API to ResourceLoader.
|
||||
- gltfio: generate normals for flat-shaded models that do not have normals.
|
||||
- Material instances now allow dynamic depth testing and other rasterization state.
|
||||
- Unlit materials now apply emissive in the same way as lit materials.
|
||||
- Screen-space refraction is now supported.
|
||||
- Support for HDR Bloom as a post-process effect.
|
||||
- Alpha masked objects are now part of the SSAO pass.
|
||||
- Added Java bindings for geometry::SurfaceOrientation.
|
||||
- Fixed bug rendering transparent objects with Metal backend.
|
||||
- Fixed crash on macOS Catalina when rendering with Metal backend.
|
||||
- Fixed bug in Camera::setLensProjection() and added the aspect ratio parameter. (⚠ API Change)
|
||||
- WebGL: Improved TypeScript annotations.
|
||||
- WebGL: Simplified callback API for glTF. (⚠ API Change)
|
||||
- gltfio: Removed deprecated "Bindings" API. (⚠ API Change)
|
||||
- gltfio: Added support for Draco.
|
||||
- gltfio: Reduced the size of the library.
|
||||
- Improved performance of SSAO.
|
||||
- Added support for screen-space contact shadows.
|
||||
- Added support for global fog.
|
||||
- Added support for bent normal maps and specular occlusion from bent normal maps.
|
||||
- Added support for shadow-casting spot lights.
|
||||
|
||||
## v1.4.5
|
||||
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
|
||||
## Prerequisites
|
||||
|
||||
In addition to the requirements for [building Filament on Windows](../README.md#windows), you'll
|
||||
In addition to the requirements for [building Filament on Windows](../BUILDING.md#windows), you'll
|
||||
need the Android SDK and NDK. See [Getting Started with the
|
||||
NDK](https://developer.android.com/ndk/guides/) for detailed installation instructions.
|
||||
|
||||
Ensure the `%ANDROID_HOME%` environment variable is set to your Android SDK installation location.
|
||||
|
||||
All of the following commands should be executed in a Visual Studio x64 Native Tools Command Prompt.
|
||||
On Windows, we require VS2019 for building the host tools. All of the following commands should be
|
||||
executed in a *Visual Studio x64 Native Tools Command Prompt for VS 2019*.
|
||||
|
||||
## Desktop Tools
|
||||
|
||||
@@ -21,11 +22,8 @@ mkdir out\cmake-release
|
||||
cd out\cmake-release
|
||||
cmake ^
|
||||
-G Ninja ^
|
||||
-DCMAKE_CXX_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_C_COMPILER:PATH="C:\Program Files\LLVM\bin\clang-cl.exe" ^
|
||||
-DCMAKE_LINKER:PATH="C:\Program Files\LLVM\bin\lld-link.exe" ^
|
||||
-DCMAKE_INSTALL_PREFIX=..\release\filament ^
|
||||
-DENABLE_JAVA=NO ^
|
||||
-DFILAMENT_ENABLE_JAVA=NO ^
|
||||
-DCMAKE_BUILD_TYPE=Release ^
|
||||
..\..
|
||||
```
|
||||
@@ -39,6 +37,12 @@ ninja matc resgen cmgen
|
||||
The build should succeed and a `ImportExecutables-Release.cmake` file should automatically be
|
||||
created at Filament's root directory.
|
||||
|
||||
If you are going to build Filament samples you should install desktop host tools:
|
||||
|
||||
```
|
||||
ninja install
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
1. Create the build directories.
|
||||
@@ -96,28 +100,28 @@ ninja install
|
||||
|
||||
## Generate AAR
|
||||
|
||||
The Gradle project used to generate the AAR is located at `<filament>\android\filament-android`.
|
||||
The Gradle project used to generate the AAR is located at `<filament>\android`.
|
||||
|
||||
```
|
||||
cd android\filament-android
|
||||
gradlew -Pfilament_dist_dir=..\..\out\android-release\filament assembleRelease
|
||||
copy build\outputs\aar\filament-android-release.aar ..\..\out\
|
||||
cd android
|
||||
gradlew -Pfilament_dist_dir=..\out\android-release\filament assembleRelease
|
||||
copy filament-android\build\outputs\aar\filament-android-release.aar ..\..\out\
|
||||
```
|
||||
|
||||
If you're only interested in building for a single ABI, you'll need to add an `abiFilters` override
|
||||
inside the `build.gradle` file underneath `defaultConfig`:
|
||||
If you're only interested in building for a single ABI, you'll need to pass a `filament_abis` parameter:
|
||||
|
||||
```
|
||||
ndk {
|
||||
abiFilters 'arm64-v8a'
|
||||
}
|
||||
gradlew -Pfilament_dist_dir=..\out\android-release\filament assembleRelease -Pfilament_abis=x86
|
||||
```
|
||||
|
||||
If you're only interested in building SDK, you may skip samples build by passing a `filament_skip_samples` flag:
|
||||
|
||||
```
|
||||
gradlew -Pfilament_dist_dir=..\out\android-release\filament assembleRelease -Pfilament_skip_samples
|
||||
```
|
||||
|
||||
See
|
||||
[NdkOptions](https://google.github.io/android-gradle-dsl/current/com.android.build.gradle.internal.dsl.NdkOptions.html#com.android.build.gradle.internal.dsl.NdkOptions:abiFilters)
|
||||
for more information.
|
||||
|
||||
`filament-android-release.aar` should now be present at `<filament>\out\filament-android-release.aar`.
|
||||
|
||||
See [Using Filament's AAR](../README.md#using-filaments-aar) for usage instructions.
|
||||
See [Using Filament's AAR](../README.md) for usage instructions.
|
||||
|
||||
|
||||
@@ -4,49 +4,106 @@
|
||||
// Path to the Filament distribution/install directory for Android
|
||||
// (produced by make/ninja install). This directory must contain lib/arm64-v8a/ etc.
|
||||
//
|
||||
// filament_tools_dir
|
||||
// Path to the Filament distribution/install directory for desktop.
|
||||
// This directory must contain bin/matc.
|
||||
//
|
||||
// filament_exclude_vulkan
|
||||
// When set, support for Vulkan will be excluded.
|
||||
//
|
||||
// filament_skip_samples
|
||||
// Exclude samples from the project. Useful to speed up compilation.
|
||||
//
|
||||
// filament_abis
|
||||
// List of supported ABIs to build as a comma separated list. Available options are:
|
||||
// arm64-v8a, armeabi-v7a, x86_64, x86, all
|
||||
// Defaults to all.
|
||||
//
|
||||
// Example:
|
||||
// ./gradlew -Pfilament_dist_dir=../dist-android-release assembleRelease
|
||||
// ./gradlew -Pfilament_dist_dir=../dist-android-release assembleRelease -Pfilament_abis=x86
|
||||
|
||||
buildscript {
|
||||
def filamentPath = file("../out/android-release/filament").absolutePath
|
||||
if (project.hasProperty("filament_dist_dir")) {
|
||||
filamentPath = file("$filament_dist_dir").absolutePath
|
||||
filamentPath = file(project.property("filament_dist_dir")).absolutePath
|
||||
}
|
||||
// Our CMake scripts require a forward-slash path for the FILAMENT_DIST_DIR
|
||||
// variable, so here we convert the native path to a forward-slash path.
|
||||
filamentPath = filamentPath.replace(File.separator, '/')
|
||||
|
||||
// Warning: changing this property does not work well with incremental builds.
|
||||
def excludeVulkan = project.hasProperty("filament_exclude_vulkan")
|
||||
|
||||
def abis = ["arm64-v8a", "armeabi-v7a", "x86_64", "x86"]
|
||||
if (project.hasProperty("filament_abis")) {
|
||||
def newAbis = project.property("filament_abis").split(',')
|
||||
if (!newAbis.contains("all")) {
|
||||
abis = newAbis
|
||||
}
|
||||
}
|
||||
|
||||
ext.filamentPath = filamentPath
|
||||
|
||||
// Our minSdkVersion is actually 19, we lie and say 14 here so apps don't have
|
||||
// to increase their minSdkVersion unnecessarily. It is however up to them to
|
||||
// ensure they do not initialize Filament on API levels < 19.
|
||||
// Our minSdkVersion is 19.
|
||||
ext.versions = [
|
||||
'minSdk': 14,
|
||||
'minSdk': 19,
|
||||
'targetSdk': 29,
|
||||
'compileSdk': 29,
|
||||
'kotlin': '1.3.61',
|
||||
'buildTools': '29.0.2',
|
||||
'kotlin': '1.3.72',
|
||||
'buildTools': '30.0.1',
|
||||
'ndk': '21.3.6528147'
|
||||
]
|
||||
|
||||
ext.deps = [
|
||||
'androidx': [
|
||||
'annotations': "androidx.annotation:annotation:1.1.0",
|
||||
'core': "androidx.core:core:1.1.0",
|
||||
'core': "androidx.core:core:1.3.0",
|
||||
],
|
||||
'kotlin': "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${versions.kotlin}"
|
||||
]
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:4.0.1'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
|
||||
}
|
||||
|
||||
ext.cmakeArgs = [
|
||||
"-DANDROID_PIE=ON",
|
||||
"-DANDROID_PLATFORM=21",
|
||||
"-DANDROID_STL=c++_static",
|
||||
"-DFILAMENT_DIST_DIR=${filamentPath}".toString(),
|
||||
"-DFILAMENT_SUPPORTS_VULKAN=${excludeVulkan ? 'OFF' : 'ON'}".toString()
|
||||
]
|
||||
|
||||
ext.cppFlags = [
|
||||
"-std=c++17",
|
||||
"-Wno-unused-command-line-argument",
|
||||
// Required to support API levels below 23
|
||||
"-Wl,--hash-style=both",
|
||||
"-fno-stack-protector",
|
||||
"-fno-exceptions",
|
||||
"-fno-unwind-tables",
|
||||
"-fno-asynchronous-unwind-tables",
|
||||
"-fno-rtti",
|
||||
"-ffast-math",
|
||||
"-ffp-contract=fast",
|
||||
"-fvisibility-inlines-hidden",
|
||||
"-fvisibility=hidden",
|
||||
"-fomit-frame-pointer",
|
||||
"-ffunction-sections",
|
||||
"-fdata-sections",
|
||||
"-Wl,--gc-sections",
|
||||
"-Wl,-Bsymbolic-functions",
|
||||
]
|
||||
|
||||
ext.abis = abis
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.6.0-rc01'
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}"
|
||||
}
|
||||
}
|
||||
|
||||
subprojects { project ->
|
||||
subprojects {
|
||||
group = GROUP
|
||||
version = VERSION_NAME
|
||||
|
||||
@@ -55,4 +112,56 @@ subprojects { project ->
|
||||
google()
|
||||
jcenter()
|
||||
}
|
||||
|
||||
if (!name.startsWith("sample")) {
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
buildToolsVersion versions.buildTools
|
||||
compileSdkVersion versions.compileSdk
|
||||
ndkVersion versions.ndk
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion versions.minSdk
|
||||
targetSdkVersion versions.targetSdk
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.addAll(rootProject.ext.cmakeArgs)
|
||||
cppFlags.addAll(rootProject.ext.cppFlags)
|
||||
}
|
||||
}
|
||||
|
||||
ndk {
|
||||
abiFilters(*rootProject.ext.abis)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gradle.taskGraph.whenReady {
|
||||
gradle.taskGraph.allTasks.each {
|
||||
it.onlyIf {
|
||||
!it.project.ext.has('isSample') || !project.hasProperty('filament_skip_samples')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
3
android/buildSrc/build.gradle
Normal file
3
android/buildSrc/build.gradle
Normal file
@@ -0,0 +1,3 @@
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
@@ -1,18 +1,35 @@
|
||||
// This script accepts the following parameters:
|
||||
// This plugin accepts the following parameters:
|
||||
//
|
||||
// filament_tools_dir
|
||||
// Path to the Filament distribution/install directory for desktop
|
||||
// (produced by make/ninja install). This directory must contain bin/matc
|
||||
// Path to the Filament distribution/install directory for desktop.
|
||||
// This directory must contain bin/matc.
|
||||
//
|
||||
// filament_exclude_vulkan
|
||||
// When set, support for Vulkan will be excluded.
|
||||
//
|
||||
// Example:
|
||||
// ./gradlew -Pfilament_tools_dir=../../dist-release assembleDebug
|
||||
|
||||
import java.nio.file.Paths
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Plugin
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.file.FileType
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.api.logging.Logger
|
||||
import org.gradle.api.tasks.InputDirectory
|
||||
import org.gradle.api.tasks.InputFile
|
||||
import org.gradle.api.tasks.OutputDirectory
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
import org.gradle.api.tasks.incremental.InputFileDetails
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.logging.*
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.api.tasks.incremental.*
|
||||
import org.gradle.work.ChangeType
|
||||
import org.gradle.work.Incremental
|
||||
import org.gradle.work.InputChanges
|
||||
|
||||
import java.nio.file.Paths
|
||||
|
||||
class TaskWithBinary extends DefaultTask {
|
||||
private final String binaryName
|
||||
@@ -65,56 +82,62 @@ class LogOutputStream extends ByteArrayOutputStream {
|
||||
|
||||
// Custom task to compile material files using matc
|
||||
// This task handles incremental builds
|
||||
class MaterialCompiler extends TaskWithBinary {
|
||||
@SuppressWarnings("GroovyUnusedDeclaration")
|
||||
abstract class MaterialCompiler extends TaskWithBinary {
|
||||
@Incremental
|
||||
@InputDirectory
|
||||
File inputDir
|
||||
final DirectoryProperty inputDir = project.objects.directoryProperty()
|
||||
|
||||
@OutputDirectory
|
||||
File outputDir
|
||||
final DirectoryProperty outputDir = project.objects.directoryProperty()
|
||||
|
||||
MaterialCompiler() {
|
||||
super("matc")
|
||||
}
|
||||
|
||||
@SuppressWarnings("GroovyUnusedDeclaration")
|
||||
@TaskAction
|
||||
void execute(IncrementalTaskInputs inputs) {
|
||||
void execute(InputChanges inputs) {
|
||||
if (!inputs.incremental) {
|
||||
project.delete(project.fileTree(outputDir).matching { include '*.filamat' })
|
||||
project.delete(project.fileTree(outputDir.asFile.get()).matching { include '*.filamat' })
|
||||
}
|
||||
|
||||
inputs.outOfDate { InputFileDetails outOfDate ->
|
||||
if (outOfDate.file.directory) return
|
||||
def file = outOfDate.file
|
||||
inputs.getFileChanges(inputDir).each { InputFileDetails change ->
|
||||
if (change.fileType == FileType.DIRECTORY) return
|
||||
|
||||
def out = new LogOutputStream(logger, LogLevel.LIFECYCLE)
|
||||
def err = new LogOutputStream(logger, LogLevel.ERROR)
|
||||
def file = change.file
|
||||
|
||||
def header = ("Compiling material " + file + "\n").getBytes()
|
||||
out.write(header)
|
||||
out.flush()
|
||||
if (change.changeType == ChangeType.REMOVED) {
|
||||
getOutputFile(file).delete()
|
||||
} else {
|
||||
def out = new LogOutputStream(logger, LogLevel.LIFECYCLE)
|
||||
def err = new LogOutputStream(logger, LogLevel.ERROR)
|
||||
|
||||
if (!getBinary().exists()) {
|
||||
throw new GradleException("Could not find ${getBinary()}." +
|
||||
" Ensure Filament has been built/installed before building this app.")
|
||||
def header = ("Compiling material " + file + "\n").getBytes()
|
||||
out.write(header)
|
||||
out.flush()
|
||||
|
||||
if (!getBinary().exists()) {
|
||||
throw new GradleException("Could not find ${getBinary()}." +
|
||||
" Ensure Filament has been built/installed before building this app.")
|
||||
}
|
||||
|
||||
def matcArgs = []
|
||||
if (!project.hasProperty("filament_exclude_vulkan")) {
|
||||
matcArgs += ['-a', 'vulkan']
|
||||
}
|
||||
matcArgs += ['-a', 'opengl', '-p', 'mobile', '-o', getOutputFile(file), file]
|
||||
|
||||
project.exec {
|
||||
standardOutput out
|
||||
errorOutput err
|
||||
executable "${getBinary()}"
|
||||
args matcArgs
|
||||
}
|
||||
}
|
||||
|
||||
project.exec {
|
||||
standardOutput out
|
||||
errorOutput err
|
||||
executable "${getBinary()}"
|
||||
args('-a', 'all', '-p', 'mobile', '-o', getOutputFile(file), file)
|
||||
}
|
||||
}
|
||||
|
||||
inputs.removed { InputFileDetails removed ->
|
||||
getOutputFile(removed.file).delete()
|
||||
}
|
||||
}
|
||||
|
||||
File getOutputFile(final File file) {
|
||||
return new File(outputDir, file.name[0..file.name.lastIndexOf('.')] + 'filamat')
|
||||
return outputDir.file(file.name[0..file.name.lastIndexOf('.')] + 'filamat').get().asFile
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,158 +146,170 @@ class MaterialCompiler extends TaskWithBinary {
|
||||
class IblGenerator extends TaskWithBinary {
|
||||
String cmgenArgs = null
|
||||
|
||||
@SuppressWarnings("GroovyUnusedDeclaration")
|
||||
@Incremental
|
||||
@InputFile
|
||||
File inputFile
|
||||
final RegularFileProperty inputFile = project.objects.fileProperty()
|
||||
|
||||
@OutputDirectory
|
||||
File outputDir
|
||||
final DirectoryProperty outputDir = project.objects.directoryProperty()
|
||||
|
||||
IblGenerator() {
|
||||
super("cmgen")
|
||||
}
|
||||
|
||||
@SuppressWarnings("GroovyUnusedDeclaration")
|
||||
@TaskAction
|
||||
void execute(IncrementalTaskInputs inputs) {
|
||||
void execute(InputChanges inputs) {
|
||||
if (!inputs.incremental) {
|
||||
project.delete(project.fileTree(outputDir).matching { include '*' })
|
||||
project.delete(project.fileTree(outputDir.asFile.get()).matching { include '*' })
|
||||
}
|
||||
|
||||
inputs.outOfDate { InputFileDetails outOfDate ->
|
||||
def file = outOfDate.file
|
||||
inputs.getFileChanges(inputFile).each { InputFileDetails change ->
|
||||
if (change.fileType == FileType.DIRECTORY) return
|
||||
|
||||
def out = new LogOutputStream(logger, LogLevel.LIFECYCLE)
|
||||
def err = new LogOutputStream(logger, LogLevel.ERROR)
|
||||
def file = change.file
|
||||
|
||||
def header = ("Generating IBL " + file + "\n").getBytes()
|
||||
out.write(header)
|
||||
out.flush()
|
||||
if (change.changeType == ChangeType.REMOVED) {
|
||||
getOutputFile(file).delete()
|
||||
} else {
|
||||
def out = new LogOutputStream(logger, LogLevel.LIFECYCLE)
|
||||
def err = new LogOutputStream(logger, LogLevel.ERROR)
|
||||
|
||||
if (!getBinary().exists()) {
|
||||
throw new GradleException("Could not find ${getBinary()}." +
|
||||
" Ensure Filament has been built/installed before building this app.")
|
||||
}
|
||||
def header = ("Generating IBL " + file + "\n").getBytes()
|
||||
out.write(header)
|
||||
out.flush()
|
||||
|
||||
project.exec {
|
||||
standardOutput out
|
||||
if (!cmgenArgs) {
|
||||
cmgenArgs = '-q -x ' + outputDir +
|
||||
' --format=rgb32f --extract-blur=0.08 --extract=' + outputDir.absolutePath
|
||||
if (!getBinary().exists()) {
|
||||
throw new GradleException("Could not find ${getBinary()}." +
|
||||
" Ensure Filament has been built/installed before building this app.")
|
||||
}
|
||||
cmgenArgs = cmgenArgs + " " + file
|
||||
errorOutput err
|
||||
executable "${getBinary()}"
|
||||
args(cmgenArgs.split())
|
||||
}
|
||||
}
|
||||
|
||||
inputs.removed { InputFileDetails removed ->
|
||||
getOutputFile(removed.file).delete()
|
||||
def outputPath = outputDir.get().asFile
|
||||
project.exec {
|
||||
standardOutput out
|
||||
if (!cmgenArgs) {
|
||||
cmgenArgs =
|
||||
'-q -x ' + outputPath + ' --format=rgb32f ' +
|
||||
'--extract-blur=0.08 --extract=' + outputPath.absolutePath
|
||||
}
|
||||
cmgenArgs = cmgenArgs + " " + file
|
||||
errorOutput err
|
||||
executable "${getBinary()}"
|
||||
args(cmgenArgs.split())
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File getOutputFile(final File file) {
|
||||
return new File(outputDir, file.name[0..file.name.lastIndexOf('.') - 1])
|
||||
return outputDir.file(file.name[0..file.name.lastIndexOf('.') - 1]).get().asFile
|
||||
}
|
||||
}
|
||||
|
||||
// Custom task to compile mesh files using filamesh
|
||||
// This task handles incremental builds
|
||||
class MeshCompiler extends TaskWithBinary {
|
||||
@SuppressWarnings("GroovyUnusedDeclaration")
|
||||
@Incremental
|
||||
@InputFile
|
||||
File inputFile
|
||||
final RegularFileProperty inputFile = project.objects.fileProperty()
|
||||
|
||||
@OutputDirectory
|
||||
File outputDir
|
||||
final DirectoryProperty outputDir = project.objects.directoryProperty()
|
||||
|
||||
MeshCompiler() {
|
||||
super("filamesh")
|
||||
}
|
||||
|
||||
@SuppressWarnings("GroovyUnusedDeclaration")
|
||||
@TaskAction
|
||||
void execute(IncrementalTaskInputs inputs) {
|
||||
void execute(InputChanges inputs) {
|
||||
if (!inputs.incremental) {
|
||||
project.delete(project.fileTree(outputDir).matching { include '*.filamesh' })
|
||||
project.delete(project.fileTree(outputDir.asFile.get()).matching { include '*.filamesh' })
|
||||
}
|
||||
|
||||
inputs.outOfDate { InputFileDetails outOfDate ->
|
||||
def file = outOfDate.file
|
||||
inputs.getFileChanges(inputFile).each { InputFileDetails change ->
|
||||
if (change.fileType == FileType.DIRECTORY) return
|
||||
|
||||
def out = new LogOutputStream(logger, LogLevel.LIFECYCLE)
|
||||
def err = new LogOutputStream(logger, LogLevel.ERROR)
|
||||
def file = change.file
|
||||
|
||||
def header = ("Compiling mesh " + file + "\n").getBytes()
|
||||
out.write(header)
|
||||
out.flush()
|
||||
if (change.changeType == ChangeType.REMOVED) {
|
||||
getOutputFile(file).delete()
|
||||
} else {
|
||||
def out = new LogOutputStream(logger, LogLevel.LIFECYCLE)
|
||||
def err = new LogOutputStream(logger, LogLevel.ERROR)
|
||||
|
||||
if (!getBinary().exists()) {
|
||||
throw new GradleException("Could not find ${getBinary()}." +
|
||||
" Ensure Filament has been built/installed before building this app.")
|
||||
def header = ("Compiling mesh " + file + "\n").getBytes()
|
||||
out.write(header)
|
||||
out.flush()
|
||||
|
||||
if (!getBinary().exists()) {
|
||||
throw new GradleException("Could not find ${getBinary()}." +
|
||||
" Ensure Filament has been built/installed before building this app.")
|
||||
}
|
||||
|
||||
project.exec {
|
||||
standardOutput out
|
||||
errorOutput err
|
||||
executable "${getBinary()}"
|
||||
args(file, getOutputFile(file))
|
||||
}
|
||||
}
|
||||
|
||||
project.exec {
|
||||
standardOutput out
|
||||
errorOutput err
|
||||
executable "${getBinary()}"
|
||||
args(file, getOutputFile(file))
|
||||
}
|
||||
}
|
||||
|
||||
inputs.removed { InputFileDetails removed ->
|
||||
getOutputFile(removed.file).delete()
|
||||
}
|
||||
}
|
||||
|
||||
File getOutputFile(final File file) {
|
||||
return new File(outputDir, file.name[0..file.name.lastIndexOf('.')] + 'filamesh')
|
||||
return outputDir.file(file.name[0..file.name.lastIndexOf('.')] + 'filamesh').get().asFile
|
||||
}
|
||||
}
|
||||
|
||||
class FilamentToolsPluginExtension {
|
||||
File materialInputDir
|
||||
File materialOutputDir
|
||||
DirectoryProperty materialInputDir
|
||||
DirectoryProperty materialOutputDir
|
||||
|
||||
String cmgenArgs
|
||||
File iblInputFile
|
||||
File iblOutputDir
|
||||
RegularFileProperty iblInputFile
|
||||
DirectoryProperty iblOutputDir
|
||||
|
||||
File meshInputFile
|
||||
File meshOutputDir
|
||||
RegularFileProperty meshInputFile
|
||||
DirectoryProperty meshOutputDir
|
||||
}
|
||||
|
||||
class FilamentToolsPlugin implements Plugin<Project> {
|
||||
void apply(Project project) {
|
||||
def extension = project.extensions.create('filamentTools', FilamentToolsPluginExtension)
|
||||
extension.materialInputDir = project.objects.directoryProperty()
|
||||
extension.materialOutputDir = project.objects.directoryProperty()
|
||||
extension.iblInputFile = project.objects.fileProperty()
|
||||
extension.iblOutputDir = project.objects.directoryProperty()
|
||||
extension.meshInputFile = project.objects.fileProperty()
|
||||
extension.meshOutputDir = project.objects.directoryProperty()
|
||||
|
||||
project.ext.filamentToolsPath = project.file("../../../out/release/filament")
|
||||
if (project.hasProperty("filament_tools_dir")) {
|
||||
project.ext.filamentToolsPath = project.file("$filament_tools_dir")
|
||||
project.ext.filamentToolsPath = project.file(project.property("filament_tools_dir"))
|
||||
}
|
||||
|
||||
project.tasks.register("filamentCompileMaterials", MaterialCompiler) {
|
||||
enabled = extension.materialInputDir != null && extension.materialOutputDir != null
|
||||
inputDir = extension.materialInputDir
|
||||
outputDir = extension.materialOutputDir
|
||||
enabled =
|
||||
extension.materialInputDir.isPresent() &&
|
||||
extension.materialOutputDir.isPresent()
|
||||
inputDir = extension.materialInputDir.getOrNull()
|
||||
outputDir = extension.materialOutputDir.getOrNull()
|
||||
}
|
||||
|
||||
project.preBuild.dependsOn "filamentCompileMaterials"
|
||||
|
||||
project.tasks.register("filamentGenerateIbl", IblGenerator) {
|
||||
enabled = extension.iblInputFile != null && extension.iblOutputDir != null
|
||||
enabled = extension.iblInputFile.isPresent() && extension.iblOutputDir.isPresent()
|
||||
cmgenArgs = extension.cmgenArgs
|
||||
inputFile = extension.iblInputFile
|
||||
outputDir = extension.iblOutputDir
|
||||
inputFile = extension.iblInputFile.getOrNull()
|
||||
outputDir = extension.iblOutputDir.getOrNull()
|
||||
}
|
||||
|
||||
project.preBuild.dependsOn "filamentGenerateIbl"
|
||||
|
||||
project.tasks.register("filamentCompileMesh", MeshCompiler) {
|
||||
enabled = extension.meshInputFile != null && extension.meshOutputDir != null
|
||||
inputFile = extension.meshInputFile
|
||||
outputDir = extension.meshOutputDir
|
||||
enabled = extension.meshInputFile.isPresent() && extension.meshOutputDir.isPresent()
|
||||
inputFile = extension.meshInputFile.getOrNull()
|
||||
outputDir = extension.meshOutputDir.getOrNull()
|
||||
}
|
||||
|
||||
project.preBuild.dependsOn "filamentCompileMesh"
|
||||
|
||||
@@ -14,23 +14,44 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <functional>
|
||||
|
||||
#include "CallbackUtils.h"
|
||||
|
||||
struct {
|
||||
void acquireCallbackJni(JNIEnv* env, CallbackJni& callbackUtils) {
|
||||
#ifdef ANDROID
|
||||
jclass handlerClass;
|
||||
jmethodID post;
|
||||
callbackUtils.handlerClass = env->FindClass("android/os/Handler");
|
||||
callbackUtils.handlerClass = (jclass) env->NewGlobalRef(callbackUtils.handlerClass);
|
||||
callbackUtils.post = env->GetMethodID(callbackUtils.handlerClass,
|
||||
"post", "(Ljava/lang/Runnable;)Z");
|
||||
#endif
|
||||
jclass executorClass;
|
||||
jmethodID execute;
|
||||
} gCallbackUtils;
|
||||
|
||||
callbackUtils.executorClass = env->FindClass("java/util/concurrent/Executor");
|
||||
callbackUtils.executorClass = (jclass) env->NewGlobalRef(callbackUtils.executorClass);
|
||||
callbackUtils.execute = env->GetMethodID(callbackUtils.executorClass,
|
||||
"execute", "(Ljava/lang/Runnable;)V");
|
||||
}
|
||||
|
||||
void releaseCallbackJni(JNIEnv* env, CallbackJni callbackUtils, jobject handler, jobject callback) {
|
||||
if (handler && callback) {
|
||||
#ifdef ANDROID
|
||||
if (env->IsInstanceOf(handler, callbackUtils.handlerClass)) {
|
||||
env->CallBooleanMethod(handler, callbackUtils.post, callback);
|
||||
}
|
||||
#endif
|
||||
if (env->IsInstanceOf(handler, callbackUtils.executorClass)) {
|
||||
env->CallVoidMethod(handler, callbackUtils.execute, callback);
|
||||
}
|
||||
}
|
||||
env->DeleteGlobalRef(handler);
|
||||
env->DeleteGlobalRef(callback);
|
||||
#ifdef ANDROID
|
||||
env->DeleteGlobalRef(callbackUtils.handlerClass);
|
||||
#endif
|
||||
env->DeleteGlobalRef(callbackUtils.executorClass);
|
||||
}
|
||||
|
||||
JniBufferCallback* JniBufferCallback::make(filament::Engine* engine,
|
||||
JNIEnv* env, jobject handler, jobject callback, AutoBuffer&& buffer) {
|
||||
void* that = engine->streamAlloc(sizeof(JniBufferCallback), alignof(JniBufferCallback));
|
||||
return new (that) JniBufferCallback(env, handler, callback, std::move(buffer));
|
||||
return new JniBufferCallback(env, handler, callback, std::move(buffer));
|
||||
}
|
||||
|
||||
JniBufferCallback::JniBufferCallback(JNIEnv* env, jobject handler, jobject callback,
|
||||
@@ -38,71 +59,39 @@ JniBufferCallback::JniBufferCallback(JNIEnv* env, jobject handler, jobject callb
|
||||
: mEnv(env)
|
||||
, mHandler(env->NewGlobalRef(handler))
|
||||
, mCallback(env->NewGlobalRef(callback))
|
||||
, mBuffer(std::move(buffer)){
|
||||
, mBuffer(std::move(buffer)) {
|
||||
acquireCallbackJni(env, mCallbackUtils);
|
||||
}
|
||||
|
||||
JniBufferCallback::~JniBufferCallback() {
|
||||
if (mHandler && mCallback) {
|
||||
#ifdef ANDROID
|
||||
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.handlerClass)) {
|
||||
mEnv->CallBooleanMethod(mHandler, gCallbackUtils.post, mCallback);
|
||||
}
|
||||
#endif
|
||||
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.executorClass)) {
|
||||
mEnv->CallVoidMethod(mHandler, gCallbackUtils.execute, mCallback);
|
||||
}
|
||||
}
|
||||
mEnv->DeleteGlobalRef(mHandler);
|
||||
mEnv->DeleteGlobalRef(mCallback);
|
||||
releaseCallbackJni(mEnv, mCallbackUtils, mHandler, mCallback);
|
||||
}
|
||||
|
||||
void JniBufferCallback::invoke(void*, size_t, void* user) {
|
||||
JniBufferCallback* data = reinterpret_cast<JniBufferCallback*>(user);
|
||||
// don't call delete here, because we don't own the storage
|
||||
data->~JniBufferCallback();
|
||||
delete data;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
||||
JniImageCallback* JniImageCallback::make(filament::Engine* engine,
|
||||
JNIEnv* env, jobject handler, jobject callback, long image) {
|
||||
void* that = engine->streamAlloc(sizeof(JniImageCallback), alignof(JniImageCallback));
|
||||
return new (that) JniImageCallback(env, handler, callback, image);
|
||||
return new JniImageCallback(env, handler, callback, image);
|
||||
}
|
||||
|
||||
JniImageCallback::JniImageCallback(JNIEnv* env, jobject handler, jobject callback, long image)
|
||||
: mEnv(env)
|
||||
, mHandler(env->NewGlobalRef(handler))
|
||||
, mCallback(env->NewGlobalRef(callback))
|
||||
, mImage(image) { }
|
||||
, mImage(image) {
|
||||
acquireCallbackJni(env, mCallbackUtils);
|
||||
}
|
||||
|
||||
JniImageCallback::~JniImageCallback() {
|
||||
if (mHandler && mCallback) {
|
||||
#ifdef ANDROID
|
||||
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.handlerClass)) {
|
||||
mEnv->CallBooleanMethod(mHandler, gCallbackUtils.post, mCallback);
|
||||
}
|
||||
#endif
|
||||
if (mEnv->IsInstanceOf(mHandler, gCallbackUtils.executorClass)) {
|
||||
mEnv->CallVoidMethod(mHandler, gCallbackUtils.execute, mCallback);
|
||||
}
|
||||
}
|
||||
mEnv->DeleteGlobalRef(mHandler);
|
||||
mEnv->DeleteGlobalRef(mCallback);
|
||||
releaseCallbackJni(mEnv, mCallbackUtils, mHandler, mCallback);
|
||||
}
|
||||
|
||||
void JniImageCallback::invoke(void* image, void* user) {
|
||||
reinterpret_cast<JniImageCallback*>(user)->~JniImageCallback();
|
||||
}
|
||||
|
||||
void registerCallbackUtils(JNIEnv *env) {
|
||||
#ifdef ANDROID
|
||||
gCallbackUtils.handlerClass = env->FindClass("android/os/Handler");
|
||||
gCallbackUtils.handlerClass = (jclass) env->NewGlobalRef(gCallbackUtils.handlerClass);
|
||||
gCallbackUtils.post = env->GetMethodID(gCallbackUtils.handlerClass,
|
||||
"post", "(Ljava/lang/Runnable;)Z");
|
||||
#endif
|
||||
|
||||
gCallbackUtils.executorClass = env->FindClass("java/util/concurrent/Executor");
|
||||
gCallbackUtils.executorClass = (jclass) env->NewGlobalRef(gCallbackUtils.executorClass);
|
||||
gCallbackUtils.execute = env->GetMethodID(gCallbackUtils.executorClass,
|
||||
"execute", "(Ljava/lang/Runnable;)V");
|
||||
void JniImageCallback::invoke(void*, void* user) {
|
||||
JniImageCallback* data = reinterpret_cast<JniImageCallback*>(user);
|
||||
delete data;
|
||||
}
|
||||
|
||||
@@ -23,6 +23,18 @@
|
||||
|
||||
#include <filament/Engine.h>
|
||||
|
||||
struct CallbackJni {
|
||||
#ifdef ANDROID
|
||||
jclass handlerClass = nullptr;
|
||||
jmethodID post = nullptr;
|
||||
#endif
|
||||
jclass executorClass = nullptr;
|
||||
jmethodID execute = nullptr;
|
||||
};
|
||||
|
||||
void acquireCallbackJni(JNIEnv* env, CallbackJni& callbackUtils);
|
||||
void releaseCallbackJni(JNIEnv* env, CallbackJni callbackUtils, jobject handler, jobject callback);
|
||||
|
||||
struct JniBufferCallback {
|
||||
static JniBufferCallback* make(filament::Engine* engine,
|
||||
JNIEnv* env, jobject handler, jobject callback, AutoBuffer&& buffer);
|
||||
@@ -31,12 +43,15 @@ struct JniBufferCallback {
|
||||
|
||||
private:
|
||||
JniBufferCallback(JNIEnv* env, jobject handler, jobject callback, AutoBuffer&& buffer);
|
||||
JniBufferCallback(JniBufferCallback const &) = delete;
|
||||
JniBufferCallback(JniBufferCallback&&) = delete;
|
||||
~JniBufferCallback();
|
||||
|
||||
JNIEnv* mEnv;
|
||||
jobject mHandler;
|
||||
jobject mCallback;
|
||||
AutoBuffer mBuffer;
|
||||
CallbackJni mCallbackUtils;
|
||||
};
|
||||
|
||||
struct JniImageCallback {
|
||||
@@ -47,10 +62,13 @@ struct JniImageCallback {
|
||||
|
||||
private:
|
||||
JniImageCallback(JNIEnv* env, jobject handler, jobject runnable, long image);
|
||||
JniImageCallback(JniBufferCallback const &) = delete;
|
||||
JniImageCallback(JniBufferCallback&&) = delete;
|
||||
~JniImageCallback();
|
||||
|
||||
JNIEnv* mEnv;
|
||||
jobject mHandler;
|
||||
jobject mCallback;
|
||||
long mImage;
|
||||
CallbackJni mCallbackUtils;
|
||||
};
|
||||
|
||||
@@ -18,20 +18,28 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
struct {
|
||||
jclass jniClass;
|
||||
jmethodID getBasePointer;
|
||||
jmethodID getBaseArray;
|
||||
jmethodID getBaseArrayOffset;
|
||||
jmethodID getBufferType;
|
||||
} gNioUtils;
|
||||
#include <utils/Log.h>
|
||||
|
||||
AutoBuffer::AutoBuffer(JNIEnv *env, jobject buffer, jint size, bool commit) noexcept : mEnv(env),
|
||||
AutoBuffer::AutoBuffer(JNIEnv *env, jobject buffer, jint size, bool commit) noexcept :
|
||||
mEnv(env),
|
||||
mDoCommit(commit) {
|
||||
|
||||
mNioUtils.jniClass = env->FindClass("com/google/android/filament/NioUtils");
|
||||
mNioUtils.jniClass = (jclass) env->NewGlobalRef(mNioUtils.jniClass);
|
||||
|
||||
mNioUtils.getBasePointer = env->GetStaticMethodID(mNioUtils.jniClass,
|
||||
"getBasePointer", "(Ljava/nio/Buffer;JI)J");
|
||||
mNioUtils.getBaseArray = env->GetStaticMethodID(mNioUtils.jniClass,
|
||||
"getBaseArray", "(Ljava/nio/Buffer;)Ljava/lang/Object;");
|
||||
mNioUtils.getBaseArrayOffset = env->GetStaticMethodID(mNioUtils.jniClass,
|
||||
"getBaseArrayOffset", "(Ljava/nio/Buffer;I)I");
|
||||
mNioUtils.getBufferType = env->GetStaticMethodID(mNioUtils.jniClass,
|
||||
"getBufferType", "(Ljava/nio/Buffer;)I");
|
||||
|
||||
mBuffer = env->NewGlobalRef(buffer);
|
||||
|
||||
mType = (BufferType) env->CallStaticIntMethod(
|
||||
gNioUtils.jniClass, gNioUtils.getBufferType, mBuffer);
|
||||
mNioUtils.jniClass, mNioUtils.getBufferType, mBuffer);
|
||||
|
||||
switch (mType) {
|
||||
case BufferType::BYTE:
|
||||
@@ -56,16 +64,16 @@ AutoBuffer::AutoBuffer(JNIEnv *env, jobject buffer, jint size, bool commit) noex
|
||||
jlong address = (jlong) env->GetDirectBufferAddress(mBuffer);
|
||||
if (address) {
|
||||
// Direct buffer case
|
||||
mData = reinterpret_cast<void *>(env->CallStaticLongMethod(gNioUtils.jniClass,
|
||||
gNioUtils.getBasePointer, mBuffer, address, mShift));
|
||||
mData = reinterpret_cast<void *>(env->CallStaticLongMethod(mNioUtils.jniClass,
|
||||
mNioUtils.getBasePointer, mBuffer, address, mShift));
|
||||
mUserData = mData;
|
||||
} else {
|
||||
// wrapped array case
|
||||
jarray array = (jarray) env->CallStaticObjectMethod(gNioUtils.jniClass,
|
||||
gNioUtils.getBaseArray, mBuffer);
|
||||
jarray array = (jarray) env->CallStaticObjectMethod(mNioUtils.jniClass,
|
||||
mNioUtils.getBaseArray, mBuffer);
|
||||
|
||||
jint offset = env->CallStaticIntMethod(gNioUtils.jniClass,
|
||||
gNioUtils.getBaseArrayOffset, mBuffer, mShift);
|
||||
jint offset = env->CallStaticIntMethod(mNioUtils.jniClass,
|
||||
mNioUtils.getBaseArrayOffset, mBuffer, mShift);
|
||||
|
||||
mBaseArray = (jarray) env->NewGlobalRef(array);
|
||||
switch (mType) {
|
||||
@@ -104,6 +112,7 @@ AutoBuffer::AutoBuffer(AutoBuffer &&rhs) noexcept {
|
||||
std::swap(mShift, rhs.mShift);
|
||||
std::swap(mBuffer, rhs.mBuffer);
|
||||
std::swap(mBaseArray, rhs.mBaseArray);
|
||||
std::swap(mNioUtils, rhs.mNioUtils);
|
||||
}
|
||||
|
||||
AutoBuffer::~AutoBuffer() noexcept {
|
||||
@@ -138,18 +147,5 @@ AutoBuffer::~AutoBuffer() noexcept {
|
||||
if (mBuffer) {
|
||||
env->DeleteGlobalRef(mBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void registerNioUtils(JNIEnv *env) {
|
||||
gNioUtils.jniClass = env->FindClass("com/google/android/filament/NioUtils");
|
||||
gNioUtils.jniClass = (jclass) env->NewGlobalRef(gNioUtils.jniClass);
|
||||
|
||||
gNioUtils.getBasePointer = env->GetStaticMethodID(gNioUtils.jniClass, "getBasePointer",
|
||||
"(Ljava/nio/Buffer;JI)J");
|
||||
gNioUtils.getBaseArray = env->GetStaticMethodID(gNioUtils.jniClass, "getBaseArray",
|
||||
"(Ljava/nio/Buffer;)Ljava/lang/Object;");
|
||||
gNioUtils.getBaseArrayOffset = env->GetStaticMethodID(gNioUtils.jniClass, "getBaseArrayOffset",
|
||||
"(Ljava/nio/Buffer;I)I");
|
||||
gNioUtils.getBufferType = env->GetStaticMethodID(gNioUtils.jniClass, "getBufferType",
|
||||
"(Ljava/nio/Buffer;)I");
|
||||
mEnv->DeleteGlobalRef(mNioUtils.jniClass);
|
||||
}
|
||||
|
||||
@@ -65,4 +65,12 @@ private:
|
||||
jobject mBuffer = nullptr;
|
||||
jarray mBaseArray = nullptr;
|
||||
bool mDoCommit = false;
|
||||
|
||||
struct {
|
||||
jclass jniClass;
|
||||
jmethodID getBasePointer;
|
||||
jmethodID getBaseArray;
|
||||
jmethodID getBaseArrayOffset;
|
||||
jmethodID getBufferType;
|
||||
} mNioUtils{};
|
||||
};
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
option(FILAMENT_ENABLE_MATDBG "Enables Material debugger" OFF)
|
||||
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
|
||||
set(FILAMAT_FLAVOR "filamat")
|
||||
@@ -7,6 +9,10 @@ if(FILAMAT_LITE)
|
||||
set(FILAMAT_FLAVOR "filamat_lite")
|
||||
endif()
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
message("Library filamat ignores Vulkan settings")
|
||||
endif()
|
||||
|
||||
add_library(${FILAMAT_FLAVOR} STATIC IMPORTED)
|
||||
set_target_properties(${FILAMAT_FLAVOR} PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/lib${FILAMAT_FLAVOR}.a)
|
||||
@@ -29,15 +35,6 @@ set_target_properties(shaders PROPERTIES IMPORTED_LOCATION
|
||||
|
||||
include_directories(${FILAMENT_DIR}/include)
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-stack-protector")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -ffp-contract=fast")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility-inlines-hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_SOURCE_DIR}/libfilamat-jni.map")
|
||||
|
||||
add_library(filamat-jni SHARED
|
||||
@@ -52,4 +49,3 @@ target_link_libraries(filamat-jni
|
||||
log
|
||||
smol-v
|
||||
)
|
||||
|
||||
|
||||
@@ -1,26 +1,4 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
buildToolsVersion versions.buildTools
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
minSdkVersion versions.minSdk
|
||||
targetSdkVersion versions.targetSdk
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-${versions.targetSdk}".toString())
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filamentPath}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
if (project.hasProperty('extra_cmake_args')) {
|
||||
arguments.add(extra_cmake_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
flavorDimensions "functionality"
|
||||
productFlavors {
|
||||
full {
|
||||
@@ -37,23 +15,6 @@ android {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
POM_NAME=Filament Material Builder
|
||||
POM_ARTIFACT_ID_FULL=filamat-android-full
|
||||
POM_ARTIFACT_ID_FULL=filamat-android
|
||||
POM_ARTIFACT_ID_LITE=filamat-android-lite
|
||||
POM_PACKAGING=aar
|
||||
|
||||
@@ -81,6 +81,14 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderName(JN
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->name(name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMaterialDomain(JNIEnv* env,
|
||||
jclass, jlong nativeBuilder, jint domain) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->materialDomain((MaterialBuilder::MaterialDomain) domain);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -103,6 +111,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderUniform
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter((MaterialBuilder::UniformType) uniformType, name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -111,6 +120,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderUniform
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
builder->parameter((MaterialBuilder::UniformType) uniformType, (size_t) size, name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -122,6 +132,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSampler
|
||||
builder->parameter((MaterialBuilder::SamplerType) samplerType,
|
||||
(MaterialBuilder::SamplerFormat) format, (MaterialBuilder::SamplerPrecision) precision,
|
||||
name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -130,6 +141,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderVariabl
|
||||
const char* name = env->GetStringUTFChars(name_, nullptr);
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->variable((MaterialBuilder::Variable) variable, name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -145,6 +157,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMateria
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* code = env->GetStringUTFChars(code_, nullptr);
|
||||
builder->material(code);
|
||||
env->ReleaseStringUTFChars(code_, code);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -153,6 +166,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMateria
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
const char* code = env->GetStringUTFChars(code_, nullptr);
|
||||
builder->materialVertex(code);
|
||||
env->ReleaseStringUTFChars(code_, code);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -246,6 +260,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSpecula
|
||||
builder->specularAntiAliasingThreshold(threshold);
|
||||
}
|
||||
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderClearCoatIorChange(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean clearCoatIorChange) {
|
||||
@@ -269,9 +284,23 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderMultiBo
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderSpecularAmbientOcclusion(
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jboolean specularAO) {
|
||||
JNIEnv*, jclass, jlong nativeBuilder, jint specularAO) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->specularAmbientOcclusion(specularAO);
|
||||
builder->specularAmbientOcclusion((MaterialBuilder::SpecularAmbientOcclusion) specularAO);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderRefractionMode(JNIEnv* env,
|
||||
jclass, jlong nativeBuilder, jint mode) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->refractionMode((MaterialBuilder::RefractionMode) mode);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderRefractionType(JNIEnv* env,
|
||||
jclass, jlong nativeBuilder, jint type) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->refractionType((MaterialBuilder::RefractionType) type);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -304,7 +333,7 @@ Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderOptimiz
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_filamat_MaterialBuilder_nMaterialBuilderVariantFilter(JNIEnv*,
|
||||
jclass, jlong nativeBuilder, jbyte variantFilter) {
|
||||
jclass, jlong nativeBuilder, jint variantFilter) {
|
||||
auto builder = (MaterialBuilder*) nativeBuilder;
|
||||
builder->variantFilter((uint8_t) variantFilter);
|
||||
}
|
||||
|
||||
@@ -66,8 +66,10 @@ public class MaterialBuilder {
|
||||
|
||||
public enum SamplerType {
|
||||
SAMPLER_2D, // 2D texture
|
||||
SAMPLER_2D_ARRAY, // 2D array texture
|
||||
SAMPLER_CUBEMAP, // Cube map texture
|
||||
SAMPLER_EXTERNAL, // External texture
|
||||
SAMPLER_3D // 3D texture
|
||||
}
|
||||
|
||||
public enum SamplerFormat {
|
||||
@@ -146,6 +148,28 @@ public class MaterialBuilder {
|
||||
// mode is ignored. Can be combined with two-sided lighting
|
||||
}
|
||||
|
||||
public enum MaterialDomain {
|
||||
SURFACE,
|
||||
POST_PROCESS
|
||||
}
|
||||
|
||||
public enum SpecularAmbientOcclusion {
|
||||
NONE,
|
||||
SIMPLE,
|
||||
BENT_NORMALS
|
||||
}
|
||||
|
||||
public enum RefractionMode {
|
||||
NONE,
|
||||
CUBEMAP,
|
||||
SCREEN_SPACE
|
||||
}
|
||||
|
||||
public enum RefractionType {
|
||||
SOLID,
|
||||
THIN
|
||||
}
|
||||
|
||||
public enum Platform {
|
||||
DESKTOP,
|
||||
MOBILE,
|
||||
@@ -191,6 +215,12 @@ public class MaterialBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder materialDomain(MaterialDomain domain) {
|
||||
nMaterialBuilderMaterialDomain(mNativeObject, domain.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder shading(@NonNull Shading shading) {
|
||||
nMaterialBuilderShading(mNativeObject, shading.ordinal());
|
||||
@@ -325,6 +355,18 @@ public class MaterialBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder refractionMode(RefractionMode mode) {
|
||||
nMaterialBuilderRefractionMode(mNativeObject, mode.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder refractionType(RefractionType type) {
|
||||
nMaterialBuilderRefractionType(mNativeObject, type.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder clearCoatIorChange(boolean clearCoatIorChange) {
|
||||
nMaterialBuilderClearCoatIorChange(mNativeObject, clearCoatIorChange);
|
||||
@@ -344,8 +386,8 @@ public class MaterialBuilder {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder specularAmbientOcclusion(boolean specularAO) {
|
||||
nMaterialBuilderSpecularAmbientOcclusion(mNativeObject, specularAO);
|
||||
public MaterialBuilder specularAmbientOcclusion(SpecularAmbientOcclusion specularAO) {
|
||||
nMaterialBuilderSpecularAmbientOcclusion(mNativeObject, specularAO.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -374,7 +416,7 @@ public class MaterialBuilder {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MaterialBuilder variantFilter(byte variantFilter) {
|
||||
public MaterialBuilder variantFilter(int variantFilter) {
|
||||
nMaterialBuilderVariantFilter(mNativeObject, variantFilter);
|
||||
return this;
|
||||
}
|
||||
@@ -419,6 +461,7 @@ public class MaterialBuilder {
|
||||
private static native void nDestroyPackage(long nativePackage);
|
||||
|
||||
private static native void nMaterialBuilderName(long nativeBuilder, String name);
|
||||
private static native void nMaterialBuilderMaterialDomain(long nativeBuilder, int domain);
|
||||
private static native void nMaterialBuilderShading(long nativeBuilder, int shading);
|
||||
private static native void nMaterialBuilderInterpolation(long nativeBuilder, int interpolation);
|
||||
private static native void nMaterialBuilderUniformParameter(long nativeBuilder, int type,
|
||||
@@ -450,17 +493,19 @@ public class MaterialBuilder {
|
||||
float variance);
|
||||
private static native void nMaterialBuilderSpecularAntiAliasingThreshold(long mNativeObject,
|
||||
float threshold);
|
||||
private static native void nMaterialBuilderRefractionMode(long nativeBuilder, int mode);
|
||||
private static native void nMaterialBuilderRefractionType(long nativeBuilder, int type);
|
||||
private static native void nMaterialBuilderClearCoatIorChange(long mNativeObject,
|
||||
boolean clearCoatIorChange);
|
||||
private static native void nMaterialBuilderFlipUV(long nativeBuilder, boolean flipUV);
|
||||
private static native void nMaterialBuilderMultiBounceAmbientOcclusion(long nativeBuilder,
|
||||
boolean multiBounceAO);
|
||||
private static native void nMaterialBuilderSpecularAmbientOcclusion(long nativeBuilder,
|
||||
boolean specularAO);
|
||||
int specularAO);
|
||||
private static native void nMaterialBuilderTransparencyMode(long nativeBuilder, int mode);
|
||||
private static native void nMaterialBuilderPlatform(long nativeBuilder, int platform);
|
||||
private static native void nMaterialBuilderTargetApi(long nativeBuilder, int api);
|
||||
private static native void nMaterialBuilderOptimization(long nativeBuilder, int optimization);
|
||||
private static native void nMaterialBuilderVariantFilter(long nativeBuilder,
|
||||
byte variantFilter);
|
||||
int variantFilter);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
option(FILAMENT_SUPPORTS_VULKAN "Enables Vulkan on Android" OFF)
|
||||
option(FILAMENT_ENABLE_MATDBG "Enables Material debugger" OFF)
|
||||
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
|
||||
add_library(filament STATIC IMPORTED)
|
||||
@@ -38,23 +41,19 @@ add_library(smol-v STATIC IMPORTED)
|
||||
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
|
||||
|
||||
if (FILAMENT_ENABLE_MATDBG)
|
||||
add_library(matdbg STATIC IMPORTED)
|
||||
set_target_properties(matdbg PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libmatdbg.a)
|
||||
endif()
|
||||
|
||||
include_directories(.. ${FILAMENT_DIR}/include)
|
||||
set(VERSION_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/libfilament-jni.map")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${VERSION_SCRIPT}")
|
||||
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-stack-protector")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -fno-rtti")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math -ffp-contract=fast")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility-inlines-hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fvisibility=hidden")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -ffunction-sections -fdata-sections")
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS" ${CMAKE_SHARED_LINKER_FLAGS} -Wl,-Bsymbolic-functions")
|
||||
|
||||
add_library(filament-jni-obj OBJECT
|
||||
add_library(filament-jni SHARED
|
||||
src/main/cpp/Camera.cpp
|
||||
src/main/cpp/Colors.cpp
|
||||
src/main/cpp/VertexBuffer.cpp
|
||||
src/main/cpp/ColorGrading.cpp
|
||||
src/main/cpp/Engine.cpp
|
||||
src/main/cpp/EntityManager.cpp
|
||||
src/main/cpp/Fence.cpp
|
||||
@@ -70,46 +69,45 @@ add_library(filament-jni-obj OBJECT
|
||||
src/main/cpp/Scene.cpp
|
||||
src/main/cpp/SkyBox.cpp
|
||||
src/main/cpp/Stream.cpp
|
||||
src/main/cpp/SurfaceOrientation.cpp
|
||||
src/main/cpp/Texture.cpp
|
||||
src/main/cpp/TextureSampler.cpp
|
||||
src/main/cpp/TransformManager.cpp
|
||||
src/main/cpp/VertexBuffer.cpp
|
||||
src/main/cpp/View.cpp
|
||||
# Android specific
|
||||
src/main/cpp/nativewindow/Android.cpp
|
||||
# Private utils
|
||||
src/main/cpp/Filament.cpp
|
||||
# Common utils
|
||||
../common/CallbackUtils.cpp
|
||||
../common/NioUtils.cpp
|
||||
)
|
||||
|
||||
if (NOT DISABLE_FILAMENT_JNI)
|
||||
# Ordering is significant in the following list. The PRIVATE qualifier prevents transitive deps.
|
||||
target_link_libraries(filament-jni
|
||||
PRIVATE filament
|
||||
PRIVATE backend
|
||||
PRIVATE filaflat
|
||||
PRIVATE filabridge
|
||||
PRIVATE geometry
|
||||
PRIVATE ibl
|
||||
PRIVATE log
|
||||
PRIVATE GLESv3
|
||||
PRIVATE EGL
|
||||
PRIVATE android
|
||||
PRIVATE jnigraphics
|
||||
PRIVATE utils
|
||||
$<$<STREQUAL:${FILAMENT_ENABLE_MATDBG},ON>:matdbg>
|
||||
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:bluevk>
|
||||
$<$<STREQUAL:${FILAMENT_SUPPORTS_VULKAN},ON>:smol-v>
|
||||
)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libfilament-jni.map")
|
||||
target_include_directories(filament-jni PRIVATE
|
||||
..
|
||||
${FILAMENT_DIR}/include
|
||||
../../third_party/robin-map
|
||||
../../libs/utils/include)
|
||||
|
||||
add_library(filament-jni SHARED
|
||||
$<TARGET_OBJECTS:filament-jni-obj>
|
||||
# Private utils
|
||||
src/main/cpp/Filament.cpp
|
||||
# Common utils
|
||||
../common/CallbackUtils.cpp
|
||||
../common/NioUtils.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(filament-jni
|
||||
filament
|
||||
backend
|
||||
filaflat
|
||||
filabridge
|
||||
geometry
|
||||
ibl
|
||||
utils
|
||||
log
|
||||
GLESv3
|
||||
EGL
|
||||
android
|
||||
jnigraphics
|
||||
)
|
||||
|
||||
option(FILAMENT_SUPPORTS_VULKAN "Enables Vulkan on Android" OFF)
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
target_link_libraries(filament-jni bluevk smol-v)
|
||||
endif()
|
||||
|
||||
endif()
|
||||
# Force a relink when the version script is changed:
|
||||
set_target_properties(filament-jni PROPERTIES LINK_DEPENDS ${VERSION_SCRIPT})
|
||||
|
||||
@@ -1,50 +1,3 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
buildToolsVersion versions.buildTools
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
minSdkVersion versions.minSdk
|
||||
targetSdkVersion versions.targetSdk
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-${versions.targetSdk}".toString())
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filamentPath}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
if (project.hasProperty('extra_cmake_args')) {
|
||||
arguments.add(extra_cmake_args)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
// To enable validation layers with the Vulkan backend, uncomment the following lines
|
||||
// to copy the appropriate files from the NDK to the device. Also be sure to use a debug
|
||||
// configuration for the native build.
|
||||
// jniLibs {
|
||||
// srcDirs = ["${android.ndkDirectory}/sources/third_party/vulkan/src/build-android/jniLibs"]
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation deps.androidx.annotations
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
LIBFILAMENT {
|
||||
global: Java_com_google_android_filament_*; JNI*;
|
||||
global: *filament*; JNI*;
|
||||
local: *;
|
||||
};
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <filament/Camera.h>
|
||||
|
||||
#include <math/mat4.h>
|
||||
|
||||
using namespace filament;
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -38,9 +40,9 @@ Java_com_google_android_filament_Camera_nSetProjectionFov(JNIEnv*, jclass ,
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Camera_nSetLensProjection(JNIEnv*, jclass,
|
||||
jlong nativeCamera, jdouble focalLength, jdouble near, jdouble far) {
|
||||
jlong nativeCamera, jdouble focalLength, jdouble aspect, jdouble near, jdouble far) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
camera->setLensProjection(focalLength, near, far);
|
||||
camera->setLensProjection(focalLength, aspect, near, far);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -52,6 +54,15 @@ Java_com_google_android_filament_Camera_nSetCustomProjection(JNIEnv *env, jclass
|
||||
env->ReleaseDoubleArrayElements(inMatrix_, inMatrix, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Camera_nSetScaling(JNIEnv* env, jclass,
|
||||
jlong nativeCamera, jdoubleArray inScaling_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jdouble *inScaling = env->GetDoubleArrayElements(inScaling_, NULL);
|
||||
camera->setScaling(*reinterpret_cast<const filament::math::double4*>(inScaling));
|
||||
env->ReleaseDoubleArrayElements(inScaling_, inScaling, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Camera_nLookAt(JNIEnv*, jclass, jlong nativeCamera,
|
||||
jdouble eye_x, jdouble eye_y, jdouble eye_z, jdouble center_x, jdouble center_y,
|
||||
@@ -92,6 +103,26 @@ Java_com_google_android_filament_Camera_nGetProjectionMatrix(JNIEnv *env, jclass
|
||||
env->ReleaseDoubleArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetCullingProjectionMatrix(JNIEnv *env, jclass,
|
||||
jlong nativeCamera, jdoubleArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jdouble *out = env->GetDoubleArrayElements(out_, NULL);
|
||||
const filament::math::mat4& m = camera->getCullingProjectionMatrix();
|
||||
std::copy_n(&m[0][0], 16, out);
|
||||
env->ReleaseDoubleArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetScaling(JNIEnv *env, jclass,
|
||||
jlong nativeCamera, jdoubleArray out_) {
|
||||
Camera *camera = (Camera *) nativeCamera;
|
||||
jdouble *out = env->GetDoubleArrayElements(out_, NULL);
|
||||
const filament::math::double4& s = camera->getScaling();
|
||||
std::copy_n(&s[0], 4, out);
|
||||
env->ReleaseDoubleArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Camera_nGetModelMatrix(JNIEnv *env, jclass,
|
||||
jlong nativeCamera, jfloatArray out_) {
|
||||
|
||||
172
android/filament-android/src/main/cpp/ColorGrading.cpp
Normal file
172
android/filament-android/src/main/cpp/ColorGrading.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/ColorGrading.h>
|
||||
|
||||
#include <math/vec3.h>
|
||||
#include <math/vec4.h>
|
||||
|
||||
using namespace filament;
|
||||
using namespace math;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nCreateBuilder(JNIEnv*, jclass) {
|
||||
return (jlong) new ColorGrading::Builder();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nDestroyBuilder(JNIEnv*, jclass,
|
||||
jlong nativeBuilder) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
delete builder;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderBuild(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jlong nativeEngine) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
return (jlong) builder->build(*engine);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderQuality(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint quality_) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
ColorGrading::QualityLevel quality = (ColorGrading::QualityLevel) quality_;
|
||||
builder->quality(quality);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderToneMapping(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint toneMapping_) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
ColorGrading::ToneMapping toneMapping = (ColorGrading::ToneMapping) toneMapping_;
|
||||
builder->toneMapping(toneMapping);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderWhiteBalance(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat temperature, jfloat tint) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->whiteBalance(temperature, tint);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderChannelMixer(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jfloatArray outRed_, jfloatArray outGreen_, jfloatArray outBlue_) {
|
||||
|
||||
jfloat* outRed = env->GetFloatArrayElements(outRed_, nullptr);
|
||||
jfloat* outGreen = env->GetFloatArrayElements(outGreen_, nullptr);
|
||||
jfloat* outBlue = env->GetFloatArrayElements(outBlue_, nullptr);
|
||||
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->channelMixer(
|
||||
*reinterpret_cast<float3*>(outRed),
|
||||
*reinterpret_cast<float3*>(outGreen),
|
||||
*reinterpret_cast<float3*>(outBlue));
|
||||
|
||||
env->ReleaseFloatArrayElements(outRed_, outRed, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(outGreen_, outGreen, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(outBlue_, outBlue, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderShadowsMidtonesHighlights(JNIEnv* env, jclass, jlong nativeBuilder,
|
||||
jfloatArray shadows_, jfloatArray midtones_, jfloatArray highlights_, jfloatArray ranges_) {
|
||||
|
||||
jfloat* shadows = env->GetFloatArrayElements(shadows_, nullptr);
|
||||
jfloat* midtones = env->GetFloatArrayElements(midtones_, nullptr);
|
||||
jfloat* highlights = env->GetFloatArrayElements(highlights_, nullptr);
|
||||
jfloat* ranges = env->GetFloatArrayElements(ranges_, nullptr);
|
||||
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->shadowsMidtonesHighlights(
|
||||
*reinterpret_cast<float4*>(shadows),
|
||||
*reinterpret_cast<float4*>(midtones),
|
||||
*reinterpret_cast<float4*>(highlights),
|
||||
*reinterpret_cast<float4*>(ranges));
|
||||
|
||||
env->ReleaseFloatArrayElements(shadows_, shadows, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(midtones_, midtones, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(highlights_, highlights, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(ranges_, ranges, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderSlopeOffsetPower(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jfloatArray slope_, jfloatArray offset_, jfloatArray power_) {
|
||||
|
||||
jfloat* slope = env->GetFloatArrayElements(slope_, nullptr);
|
||||
jfloat* offset = env->GetFloatArrayElements(offset_, nullptr);
|
||||
jfloat* power = env->GetFloatArrayElements(power_, nullptr);
|
||||
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->slopeOffsetPower(
|
||||
*reinterpret_cast<float3*>(slope),
|
||||
*reinterpret_cast<float3*>(offset),
|
||||
*reinterpret_cast<float3*>(power));
|
||||
|
||||
env->ReleaseFloatArrayElements(slope_, slope, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(offset_, offset, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(power_, power, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderContrast(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat contrast) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->contrast(contrast);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderVibrance(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat vibrance) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->vibrance(vibrance);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderSaturation(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat saturation) {
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->saturation(saturation);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_ColorGrading_nBuilderCurves(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jfloatArray gamma_, jfloatArray midPoint_, jfloatArray scale_) {
|
||||
|
||||
jfloat* gamma = env->GetFloatArrayElements(gamma_, nullptr);
|
||||
jfloat* midPoint = env->GetFloatArrayElements(midPoint_, nullptr);
|
||||
jfloat* scale = env->GetFloatArrayElements(scale_, nullptr);
|
||||
|
||||
ColorGrading::Builder* builder = (ColorGrading::Builder*) nativeBuilder;
|
||||
builder->curves(
|
||||
*reinterpret_cast<float3*>(gamma),
|
||||
*reinterpret_cast<float3*>(midPoint),
|
||||
*reinterpret_cast<float3*>(scale));
|
||||
|
||||
env->ReleaseFloatArrayElements(gamma_, gamma, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(midPoint_, midPoint, JNI_ABORT);
|
||||
env->ReleaseFloatArrayElements(scale_, scale, JNI_ABORT);
|
||||
}
|
||||
@@ -76,12 +76,12 @@ Java_com_google_android_filament_Engine_nCreateSwapChainFromRawPointer(JNIEnv*,
|
||||
return (jlong) engine->createSwapChain((void*)pointer, (uint64_t) flags);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroySwapChain(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeSwapChain) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
SwapChain *swapChain = (SwapChain *) nativeSwapChain;
|
||||
engine->destroy(swapChain);
|
||||
return engine->destroy(swapChain);
|
||||
}
|
||||
|
||||
// View
|
||||
@@ -93,12 +93,12 @@ Java_com_google_android_filament_Engine_nCreateView(JNIEnv*, jclass,
|
||||
return (jlong) engine->createView();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyView(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeView) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
View *view = (View *) nativeView;
|
||||
engine->destroy(view);
|
||||
return engine->destroy(view);
|
||||
}
|
||||
|
||||
// Renderer
|
||||
@@ -110,17 +110,17 @@ Java_com_google_android_filament_Engine_nCreateRenderer(JNIEnv*, jclass,
|
||||
return (jlong) engine->createRenderer();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyRenderer(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeRenderer) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
engine->destroy(renderer);
|
||||
return engine->destroy(renderer);
|
||||
}
|
||||
|
||||
// Camera
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
extern "C" [[deprecated]] JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Engine_nCreateCamera(JNIEnv*, jclass,
|
||||
jlong nativeEngine) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
@@ -135,7 +135,15 @@ Java_com_google_android_filament_Engine_nCreateCameraWithEntity(JNIEnv*, jclass,
|
||||
return (jlong) engine->createCamera(entity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Engine_nGetCameraComponent(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jint entity_) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Entity& entity = *reinterpret_cast<Entity*>(&entity_);
|
||||
return (jlong) engine->getCameraComponent(entity);
|
||||
}
|
||||
|
||||
extern "C" [[deprecated]] JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyCamera(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeCamera) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
@@ -152,12 +160,12 @@ Java_com_google_android_filament_Engine_nCreateScene(JNIEnv*, jclass,
|
||||
return (jlong) engine->createScene();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyScene(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeScene) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Scene *scene = (Scene *) nativeScene;
|
||||
engine->destroy(scene);
|
||||
return engine->destroy(scene);
|
||||
}
|
||||
|
||||
// Fence
|
||||
@@ -169,89 +177,96 @@ Java_com_google_android_filament_Engine_nCreateFence(JNIEnv*, jclass,
|
||||
return (jlong) engine->createFence();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyFence(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeFence) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Fence *fence = (Fence *) nativeFence;
|
||||
engine->destroy(fence);
|
||||
return engine->destroy(fence);
|
||||
}
|
||||
|
||||
// Stream
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyStream(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeStream) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Stream *stream = (Stream *) nativeStream;
|
||||
engine->destroy(stream);
|
||||
return engine->destroy(stream);
|
||||
}
|
||||
|
||||
// Others...
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyIndexBuffer(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeIndexBuffer) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
IndexBuffer *indexBuffer = (IndexBuffer *) nativeIndexBuffer;
|
||||
engine->destroy(indexBuffer);
|
||||
return engine->destroy(indexBuffer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyVertexBuffer(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeVertexBuffer) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
VertexBuffer *vertexBuffer = (VertexBuffer *) nativeVertexBuffer;
|
||||
engine->destroy(vertexBuffer);
|
||||
return engine->destroy(vertexBuffer);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyIndirectLight(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeIndirectLight) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
engine->destroy(indirectLight);
|
||||
return engine->destroy(indirectLight);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyMaterial(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeMaterial) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Material *material = (Material *) nativeMaterial;
|
||||
engine->destroy(material);
|
||||
return engine->destroy(material);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyMaterialInstance(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeMaterialInstance) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
MaterialInstance* materialInstance =
|
||||
(MaterialInstance*) nativeMaterialInstance;
|
||||
engine->destroy(materialInstance);
|
||||
MaterialInstance* materialInstance = (MaterialInstance*) nativeMaterialInstance;
|
||||
return engine->destroy(materialInstance);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroySkybox(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeSkybox) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Skybox *skybox = (Skybox *) nativeSkybox;
|
||||
engine->destroy(skybox);
|
||||
return engine->destroy(skybox);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyColorGrading(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeColorGrading) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
ColorGrading* colorGrading = (ColorGrading*) nativeColorGrading;
|
||||
return engine->destroy(colorGrading);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyTexture(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeTexture) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
Texture *texture = (Texture *) nativeTexture;
|
||||
engine->destroy(texture);
|
||||
return engine->destroy(texture);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Engine_nDestroyRenderTarget(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeTarget) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
RenderTarget* target = (RenderTarget*) nativeTarget;
|
||||
engine->destroy(target);
|
||||
return engine->destroy(target);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
|
||||
@@ -16,24 +16,16 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
extern void registerCallbackUtils(JNIEnv*);
|
||||
extern void registerMaterial(JNIEnv*);
|
||||
extern void registerNioUtils(JNIEnv*);
|
||||
|
||||
namespace filament {
|
||||
extern jint JNI_OnLoad(JavaVM* vm, void* reserved);
|
||||
};
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
registerCallbackUtils(env);
|
||||
registerMaterial(env);
|
||||
registerNioUtils(env);
|
||||
|
||||
#if ANDROID
|
||||
::filament::JNI_OnLoad(vm, reserved);
|
||||
#endif
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <filament/Texture.h>
|
||||
#include <common/NioUtils.h>
|
||||
#include <common/CallbackUtils.h>
|
||||
#include <math/mat4.h>
|
||||
|
||||
using namespace filament;
|
||||
|
||||
@@ -124,7 +125,7 @@ Java_com_google_android_filament_IndirectLight_nGetRotation(JNIEnv* env, jclass,
|
||||
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" [[deprecated]] JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetDirectionEstimate(JNIEnv* env, jclass,
|
||||
jlong nativeIndirectLight, jfloatArray outDirection_) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
@@ -133,7 +134,7 @@ Java_com_google_android_filament_IndirectLight_nGetDirectionEstimate(JNIEnv* env
|
||||
env->ReleaseFloatArrayElements(outDirection_, outDirection, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" [[deprecated]] JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetColorEstimate(JNIEnv* env, jclass,
|
||||
jlong nativeIndirectLight, jfloatArray outColor_, jfloat x, jfloat y, jfloat z) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
@@ -143,6 +144,22 @@ Java_com_google_android_filament_IndirectLight_nGetColorEstimate(JNIEnv* env, jc
|
||||
env->ReleaseFloatArrayElements(outColor_, outColor, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetReflectionsTexture(JNIEnv* env, jclass,
|
||||
jlong nativeIndirectLight) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
Texture const *tex = indirectLight->getReflectionsTexture();
|
||||
return (jlong) tex;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetIrradianceTexture(JNIEnv* env, jclass,
|
||||
jlong nativeIndirectLight) {
|
||||
IndirectLight *indirectLight = (IndirectLight *) nativeIndirectLight;
|
||||
Texture const *tex = indirectLight->getIrradianceTexture();
|
||||
return (jlong) tex;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_IndirectLight_nGetDirectionEstimateStatic(JNIEnv *env, jclass,
|
||||
jfloatArray sh_, jfloatArray outDirection_) {
|
||||
@@ -162,4 +179,4 @@ Java_com_google_android_filament_IndirectLight_nGetColorEstimateStatic(JNIEnv *e
|
||||
IndirectLight::getColorEstimate((filament::math::float3*)sh, math::float3{x, y, z});
|
||||
env->ReleaseFloatArrayElements(outColor_, outColor, 0);
|
||||
env->ReleaseFloatArrayElements(sh_, sh, JNI_ABORT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,18 @@
|
||||
|
||||
#include <utils/Entity.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace filament;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetComponentCount(JNIEnv*, jclass,
|
||||
jlong nativeLightManager) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getComponentCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_LightManager_nHasComponent(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint entity) {
|
||||
@@ -64,18 +73,32 @@ Java_com_google_android_filament_LightManager_nBuilderCastShadows(JNIEnv*, jclas
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderShadowOptions(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint mapSize, jfloat constantBias, jfloat normalBias, jfloat shadowFar,
|
||||
jfloat shadowNearHint, jfloat shadowFarHint, jboolean stable) {
|
||||
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 screenSpaceContactShadows, jint stepCount,
|
||||
jfloat maxShadowDistance) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->shadowOptions(
|
||||
LightManager::ShadowOptions{.mapSize = (uint32_t)mapSize,
|
||||
.constantBias = constantBias,
|
||||
.normalBias = normalBias,
|
||||
.shadowFar = shadowFar,
|
||||
.shadowNearHint = shadowNearHint,
|
||||
.shadowFarHint = shadowFarHint,
|
||||
.stable = (bool)stable});
|
||||
LightManager::ShadowOptions shadowOptions {
|
||||
.mapSize = (uint32_t)mapSize,
|
||||
.shadowCascades = (uint8_t)cascades,
|
||||
.constantBias = constantBias,
|
||||
.normalBias = normalBias,
|
||||
.shadowFar = shadowFar,
|
||||
.shadowNearHint = shadowNearHint,
|
||||
.shadowFarHint = shadowFarHint,
|
||||
.stable = (bool)stable,
|
||||
.screenSpaceContactShadows = (bool)screenSpaceContactShadows,
|
||||
.stepCount = uint8_t(stepCount),
|
||||
.maxShadowDistance = maxShadowDistance
|
||||
};
|
||||
jfloat *nativeSplits = env->GetFloatArrayElements(splitPositions, NULL);
|
||||
const jsize splitCount = std::min((jsize) 3, env->GetArrayLength(splitPositions));
|
||||
for (jsize i = 0; i < splitCount; i++) {
|
||||
shadowOptions.cascadeSplitPositions[i] = nativeSplits[i];
|
||||
}
|
||||
env->ReleaseFloatArrayElements(splitPositions, nativeSplits, 0);
|
||||
builder->shadowOptions(shadowOptions);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -106,6 +129,13 @@ Java_com_google_android_filament_LightManager_nBuilderColor(JNIEnv*, jclass,
|
||||
builder->color({linearR, linearG, linearB});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderIntensityCandela(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat intensity) {
|
||||
LightManager::Builder *builder = (LightManager::Builder *) nativeBuilder;
|
||||
builder->intensityCandela(intensity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderIntensity__JF(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jfloat intensity) {
|
||||
@@ -155,6 +185,30 @@ Java_com_google_android_filament_LightManager_nBuilderHaloFalloff(JNIEnv*, jclas
|
||||
builder->sunHaloFalloff(haloFalloff);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nComputeUniformSplits(JNIEnv* env, jclass,
|
||||
jfloatArray splitPositions, jint cascades) {
|
||||
jfloat *nativeSplits = env->GetFloatArrayElements(splitPositions, NULL);
|
||||
LightManager::ShadowCascades::computeUniformSplits(nativeSplits, (uint8_t) cascades);
|
||||
env->ReleaseFloatArrayElements(splitPositions, nativeSplits, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nComputeLogSplits(JNIEnv* env, jclass,
|
||||
jfloatArray splitPositions, jint cascades, jfloat near, jfloat far) {
|
||||
jfloat *nativeSplits = env->GetFloatArrayElements(splitPositions, NULL);
|
||||
LightManager::ShadowCascades::computeLogSplits(nativeSplits, (uint8_t) cascades, near, far);
|
||||
env->ReleaseFloatArrayElements(splitPositions, nativeSplits, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nComputePracticalSplits(JNIEnv* env, jclass,
|
||||
jfloatArray splitPositions, jint cascades, jfloat near, jfloat far, jfloat lambda) {
|
||||
jfloat *nativeSplits = env->GetFloatArrayElements(splitPositions, NULL);
|
||||
LightManager::ShadowCascades::computePracticalSplits(nativeSplits, (uint8_t) cascades, near, far, lambda);
|
||||
env->ReleaseFloatArrayElements(splitPositions, nativeSplits, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_LightManager_nBuilderBuild(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jlong nativeEngine, jint entity) {
|
||||
@@ -232,6 +286,13 @@ Java_com_google_android_filament_LightManager_nSetIntensity__JIFF(JNIEnv*, jclas
|
||||
lm->setIntensity((LightManager::Instance) i, watts, efficiency);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetIntensityCandela(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat intensity) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setIntensityCandela((LightManager::Instance) i, intensity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetIntensity(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
@@ -282,7 +343,7 @@ Java_com_google_android_filament_LightManager_nSetSunHaloSize(JNIEnv*, jclass,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetHaloSize(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_LightManager_nGetSunHaloSize(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getSunHaloSize((LightManager::Instance) i);
|
||||
@@ -296,7 +357,7 @@ Java_com_google_android_filament_LightManager_nSetSunHaloFalloff(JNIEnv*, jclass
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_LightManager_nGetHaloFalloff(JNIEnv*, jclass,
|
||||
Java_com_google_android_filament_LightManager_nGetSunHaloFalloff(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->getSunHaloFalloff((LightManager::Instance) i);
|
||||
@@ -304,7 +365,7 @@ Java_com_google_android_filament_LightManager_nGetHaloFalloff(JNIEnv*, jclass,
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_LightManager_nSetShadowCaster(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i, jfloat shadowCaster) {
|
||||
jlong nativeLightManager, jint i, jboolean shadowCaster) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
lm->setShadowCaster((LightManager::Instance) i, shadowCaster);
|
||||
}
|
||||
@@ -313,5 +374,5 @@ extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_LightManager_nIsShadowCaster(JNIEnv*, jclass,
|
||||
jlong nativeLightManager, jint i) {
|
||||
LightManager *lm = (LightManager *) nativeLightManager;
|
||||
return lm->isShadowCaster((LightManager::Instance) i);
|
||||
return (jboolean)lm->isShadowCaster((LightManager::Instance) i);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,6 @@
|
||||
|
||||
using namespace filament;
|
||||
|
||||
struct {
|
||||
jclass parameterClass;
|
||||
jmethodID parameterAdd;
|
||||
jfieldID parameterSamplerOffset;
|
||||
} gMaterial;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Material_nBuilderBuild(JNIEnv *env, jclass,
|
||||
jlong nativeEngine, jobject buffer_, jint size) {
|
||||
@@ -53,6 +47,16 @@ Java_com_google_android_filament_Material_nCreateInstance(JNIEnv*, jclass,
|
||||
return (jlong) material->createInstance();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Material_nCreateInstanceWithName(JNIEnv* env, jclass,
|
||||
jlong nativeMaterial, jstring name_) {
|
||||
Material* material = (Material*) nativeMaterial;
|
||||
const char *name = env->GetStringUTFChars(name_, 0);
|
||||
jlong instance = (jlong) material->createInstance(name);
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
return instance;
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_google_android_filament_Material_nGetName(JNIEnv* env, jclass, jlong nativeMaterial) {
|
||||
@@ -191,16 +195,27 @@ Java_com_google_android_filament_Material_nGetParameters(JNIEnv* env, jclass,
|
||||
size_t received = material->getParameters(info, (size_t) count);
|
||||
assert(received == count);
|
||||
|
||||
jint offset = env->GetStaticIntField(gMaterial.parameterClass, gMaterial.parameterSamplerOffset);
|
||||
jclass parameterClass = env->FindClass("com/google/android/filament/Material$Parameter");
|
||||
parameterClass = (jclass) env->NewLocalRef(parameterClass);
|
||||
|
||||
jmethodID parameterAdd = env->GetStaticMethodID(parameterClass, "add",
|
||||
"(Ljava/util/List;Ljava/lang/String;III)V");
|
||||
|
||||
jfieldID parameterSamplerOffset = env->GetStaticFieldID(parameterClass,
|
||||
"SAMPLER_OFFSET", "I");
|
||||
|
||||
jint offset = env->GetStaticIntField(parameterClass, parameterSamplerOffset);
|
||||
for (size_t i = 0; i < received; i++) {
|
||||
jint type = info[i].isSampler ? (jint) info[i].samplerType + offset : (jint) info[i].type;
|
||||
|
||||
env->CallStaticVoidMethod(
|
||||
gMaterial.parameterClass, gMaterial.parameterAdd,
|
||||
parameterClass, parameterAdd,
|
||||
parameters, env->NewStringUTF(info[i].name), type, (jint) info[i].precision,
|
||||
(jint) info[i].count);
|
||||
}
|
||||
|
||||
env->DeleteLocalRef(parameterClass);
|
||||
|
||||
delete[] info;
|
||||
}
|
||||
|
||||
@@ -221,14 +236,3 @@ Java_com_google_android_filament_Material_nHasParameter(JNIEnv* env, jclass,
|
||||
env->ReleaseStringUTFChars(name_, name);
|
||||
return (jboolean) hasParameter;
|
||||
}
|
||||
|
||||
void registerMaterial(JNIEnv *env) {
|
||||
gMaterial.parameterClass = env->FindClass("com/google/android/filament/Material$Parameter");
|
||||
gMaterial.parameterClass = (jclass) env->NewGlobalRef(gMaterial.parameterClass);
|
||||
|
||||
gMaterial.parameterAdd = env->GetStaticMethodID(gMaterial.parameterClass, "add",
|
||||
"(Ljava/util/List;Ljava/lang/String;III)V");
|
||||
|
||||
gMaterial.parameterSamplerOffset = env->GetStaticFieldID(gMaterial.parameterClass,
|
||||
"SAMPLER_OFFSET", "I");
|
||||
}
|
||||
|
||||
@@ -324,3 +324,43 @@ Java_com_google_android_filament_MaterialInstance_nSetCullingMode(JNIEnv*,
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setCullingMode((MaterialInstance::CullingMode) cullingMode);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetColorWrite(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jboolean enable) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setColorWrite(enable);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetDepthWrite(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jboolean enable) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setDepthWrite(enable);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nSetDepthCulling(JNIEnv*,
|
||||
jclass, jlong nativeMaterialInstance, jboolean enable) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
instance->setDepthCulling(enable);
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetName(JNIEnv* env, jclass,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
return env->NewStringUTF(instance->getName());
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_MaterialInstance_nGetMaterial(JNIEnv* env, jclass,
|
||||
jlong nativeMaterialInstance) {
|
||||
MaterialInstance* instance = (MaterialInstance*) nativeMaterialInstance;
|
||||
return (jlong) instance->getMaterial();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ Java_com_google_android_filament_RenderTarget_nDestroyBuilder(JNIEnv *env, jclas
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderTexture(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jlong nativeTexture) {
|
||||
jlong nativeBuilder, jint attachment, jlong nativeTexture) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
Texture* texture = (Texture*) nativeTexture;
|
||||
builder->texture(RenderTarget::AttachmentPoint(attachment), texture);
|
||||
@@ -47,14 +47,14 @@ Java_com_google_android_filament_RenderTarget_nBuilderTexture(JNIEnv *env, jclas
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderMipLevel(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jint level) {
|
||||
jlong nativeBuilder, jint attachment, jint level) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
builder->mipLevel(RenderTarget::AttachmentPoint(attachment), level);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderFace(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jint face) {
|
||||
jlong nativeBuilder, jint attachment, jint face) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
RenderTarget::CubemapFace cubeface = (RenderTarget::CubemapFace) face;
|
||||
builder->face(RenderTarget::AttachmentPoint(attachment), cubeface);
|
||||
@@ -62,7 +62,7 @@ Java_com_google_android_filament_RenderTarget_nBuilderFace(JNIEnv *env, jclass t
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nBuilderLayer(JNIEnv *env, jclass type,
|
||||
jlong nativeBuilder, jlong attachment, jint layer) {
|
||||
jlong nativeBuilder, jint attachment, jint layer) {
|
||||
RenderTarget::Builder* builder = (RenderTarget::Builder*) nativeBuilder;
|
||||
builder->layer(RenderTarget::AttachmentPoint(attachment), layer);
|
||||
}
|
||||
@@ -77,7 +77,21 @@ Java_com_google_android_filament_RenderTarget_nBuilderBuild(JNIEnv *env, jclass
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nGetMipLevel(JNIEnv *env, jclass type,
|
||||
jlong nativeTarget, jlong attachment) {
|
||||
jlong nativeTarget, jint attachment) {
|
||||
RenderTarget* target = (RenderTarget*) nativeTarget;
|
||||
return (jint) target->getMipLevel(RenderTarget::AttachmentPoint(attachment));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nGetFace(JNIEnv *env, jclass type,
|
||||
long nativeTarget, int attachment) {
|
||||
RenderTarget* target = (RenderTarget*) nativeTarget;
|
||||
return (jint) target->getFace(RenderTarget::AttachmentPoint(attachment));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_RenderTarget_nGetLayer(JNIEnv *env, jclass type,
|
||||
long nativeTarget, int attachment) {
|
||||
RenderTarget* target = (RenderTarget*) nativeTarget;
|
||||
return (jint) target->getLayer(RenderTarget::AttachmentPoint(attachment));
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/RenderableManager.h>
|
||||
@@ -164,6 +163,13 @@ Java_com_google_android_filament_RenderableManager_nBuilderReceiveShadows(JNIEnv
|
||||
builder->receiveShadows(enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderScreenSpaceContactShadows(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jboolean enabled) {
|
||||
RenderableManager::Builder *builder = (RenderableManager::Builder *) nativeBuilder;
|
||||
builder->screenSpaceContactShadows(enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nBuilderSkinning(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jint boneCount) {
|
||||
@@ -261,6 +267,13 @@ Java_com_google_android_filament_RenderableManager_nSetPriority(JNIEnv*, jclass,
|
||||
rm->setPriority((RenderableManager::Instance) i, (uint8_t) priority);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetCulling(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jboolean enabled) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
rm->setCulling((RenderableManager::Instance) i, enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetCastShadows(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jboolean enabled) {
|
||||
@@ -275,6 +288,13 @@ Java_com_google_android_filament_RenderableManager_nSetReceiveShadows(JNIEnv*, j
|
||||
rm->setReceiveShadows((RenderableManager::Instance) i, enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nSetScreenSpaceContactShadows(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i, jboolean enabled) {
|
||||
RenderableManager *rm = (RenderableManager *) nativeRenderableManager;
|
||||
rm->setScreenSpaceContactShadows((RenderableManager::Instance) i, enabled);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_RenderableManager_nIsShadowCaster(JNIEnv*, jclass,
|
||||
jlong nativeRenderableManager, jint i) {
|
||||
|
||||
@@ -30,10 +30,10 @@ using namespace backend;
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_Renderer_nBeginFrame(JNIEnv *, jclass, jlong nativeRenderer,
|
||||
jlong nativeSwapChain) {
|
||||
jlong nativeSwapChain, jlong frameTimeNanos) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
SwapChain *swapChain = (SwapChain *) nativeSwapChain;
|
||||
return (jboolean) renderer->beginFrame(swapChain);
|
||||
return (jboolean) renderer->beginFrame(swapChain, uint64_t(frameTimeNanos));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -144,3 +144,32 @@ Java_com_google_android_filament_Renderer_nResetUserTime(JNIEnv*, jclass, jlong
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
renderer->resetUserTime();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Renderer_nSetDisplayInfo(JNIEnv*, jclass, jlong nativeRenderer,
|
||||
jfloat refreshRate, jlong presentationDeadlineNanos, jlong vsyncOffsetNanos) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
renderer->setDisplayInfo({ .refreshRate = refreshRate,
|
||||
.presentationDeadlineNanos = (uint64_t)presentationDeadlineNanos,
|
||||
.vsyncOffsetNanos = (uint64_t)vsyncOffsetNanos });
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Renderer_nSetFrameRateOptions(JNIEnv*, jclass,
|
||||
jlong nativeRenderer, jfloat interval, jfloat headRoomRatio, jfloat scaleRate, jint history) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
renderer->setFrameRateOptions({ .headRoomRatio = headRoomRatio,
|
||||
.scaleRate = scaleRate,
|
||||
.history = (uint8_t)history,
|
||||
.interval = (uint8_t)interval });
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Renderer_nSetClearOptions(JNIEnv *, jclass ,
|
||||
jlong nativeRenderer, jfloat r, jfloat g, jfloat b, jfloat a,
|
||||
jboolean clear, jboolean discard) {
|
||||
Renderer *renderer = (Renderer *) nativeRenderer;
|
||||
renderer->setClearOptions({ .clearColor = {r, g, b, a},
|
||||
.clear = (bool) clear,
|
||||
.discard = (bool) discard});
|
||||
}
|
||||
|
||||
@@ -62,6 +62,15 @@ Java_com_google_android_filament_Scene_nRemove(JNIEnv *env, jclass type, jlong n
|
||||
scene->remove((Entity&) entity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Scene_nRemoveEntities(JNIEnv *env, jclass type, jlong nativeScene,
|
||||
jintArray entities) {
|
||||
Scene* scene = (Scene*) nativeScene;
|
||||
Entity* nativeEntities = (Entity*) env->GetIntArrayElements(entities, nullptr);
|
||||
scene->removeEntities(nativeEntities, env->GetArrayLength(entities));
|
||||
env->ReleaseIntArrayElements(entities, (jint*) nativeEntities, JNI_ABORT);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Scene_nGetRenderableCount(JNIEnv *env, jclass type,
|
||||
jlong nativeScene) {
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <filament/Skybox.h>
|
||||
|
||||
#include <math/vec4.h>
|
||||
|
||||
using namespace filament;
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
@@ -54,6 +56,13 @@ Java_com_google_android_filament_Skybox_nBuilderIntensity(JNIEnv *env, jclass cl
|
||||
builder->intensity(intensity);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Skybox_nBuilderColor(JNIEnv *, jclass,
|
||||
jlong nativeSkyBoxBuilder, jfloat r, jfloat g, jfloat b, jfloat a) {
|
||||
Skybox::Builder *builder = (Skybox::Builder *) nativeSkyBoxBuilder;
|
||||
builder->color({r, g, b, a});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Skybox_nBuilderBuild(JNIEnv *env, jclass type,
|
||||
jlong nativeSkyBoxBuilder, jlong nativeEngine) {
|
||||
@@ -82,3 +91,18 @@ Java_com_google_android_filament_Skybox_nGetIntensity(JNIEnv *env, jclass clazz,
|
||||
Skybox *skybox = (Skybox *) nativeSkybox;
|
||||
return static_cast<jint>(skybox->getIntensity());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Skybox_nSetColor(JNIEnv *, jclass,
|
||||
jlong nativeSkybox, jfloat r, jfloat g, jfloat b, jfloat a) {
|
||||
Skybox *skybox = (Skybox *) nativeSkybox;
|
||||
skybox->setColor({r, g, b, a});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Skybix_nGetTexture(JNIEnv* env, jclass,
|
||||
jlong nativeSkybox) {
|
||||
Skybox *skybox = (Skybox *) nativeSkybox;
|
||||
Texture const *tex = skybox->getTexture();
|
||||
return (jlong) tex;
|
||||
}
|
||||
|
||||
170
android/filament-android/src/main/cpp/SurfaceOrientation.cpp
Normal file
170
android/filament-android/src/main/cpp/SurfaceOrientation.cpp
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <geometry/SurfaceOrientation.h>
|
||||
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace filament;
|
||||
using namespace filament::geometry;
|
||||
using namespace filament::math;
|
||||
|
||||
namespace {
|
||||
struct JniWrapper {
|
||||
SurfaceOrientation::Builder* builder;
|
||||
AutoBuffer* normals;
|
||||
AutoBuffer* tangents;
|
||||
AutoBuffer* uvs;
|
||||
AutoBuffer* positions;
|
||||
AutoBuffer* triangles16;
|
||||
AutoBuffer* triangles32;
|
||||
};
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nCreateBuilder(JNIEnv* env, jclass) {
|
||||
JniWrapper* wrapper = new JniWrapper();
|
||||
wrapper->builder = new SurfaceOrientation::Builder();
|
||||
return (jlong) wrapper;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nDestroyBuilder(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder) {
|
||||
auto wrapper = (JniWrapper*) nativeBuilder;
|
||||
delete wrapper->builder;
|
||||
delete wrapper->normals;
|
||||
delete wrapper->tangents;
|
||||
delete wrapper->uvs;
|
||||
delete wrapper->positions;
|
||||
delete wrapper->triangles16;
|
||||
delete wrapper->triangles32;
|
||||
delete wrapper;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderVertexCount(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, int vertexCount) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
wrapper->builder->vertexCount(vertexCount);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderTriangleCount(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, int triangleCount) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
wrapper->builder->triangleCount(triangleCount);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderNormals(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jobject javaBuffer, jint remaining, int stride) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
AutoBuffer* buffer = wrapper->normals = new AutoBuffer(env, javaBuffer, remaining);
|
||||
wrapper->builder->normals((const float3 *) buffer->getData(), stride);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderTangents(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jobject javaBuffer, jint remaining, int stride) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
AutoBuffer* buffer = wrapper->tangents = new AutoBuffer(env, javaBuffer, remaining);
|
||||
wrapper->builder->tangents((const float4 *) buffer->getData(), stride);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderUVs(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jobject javaBuffer, int remaining, int stride) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
AutoBuffer* buffer = wrapper->uvs = new AutoBuffer(env, javaBuffer, remaining);
|
||||
wrapper->builder->uvs((const float2 *) buffer->getData(), stride);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderPositions(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jobject javaBuffer, int remaining, int stride) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
AutoBuffer* buffer = wrapper->positions = new AutoBuffer(env, javaBuffer, remaining);
|
||||
wrapper->builder->positions((const float3 *) buffer->getData(), stride);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderTriangles16(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jobject javaBuffer, int remaining) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
AutoBuffer* buffer = wrapper->triangles16 = new AutoBuffer(env, javaBuffer, remaining);
|
||||
wrapper->builder->triangles((const ushort3 *) buffer->getData());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderTriangles32(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder, jobject javaBuffer, int remaining) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
AutoBuffer* buffer = wrapper->triangles32 = new AutoBuffer(env, javaBuffer, remaining);
|
||||
wrapper->builder->triangles((const uint3 *) buffer->getData());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nBuilderBuild(JNIEnv* env, jclass,
|
||||
jlong nativeBuilder) {
|
||||
auto wrapper = (JniWrapper *) nativeBuilder;
|
||||
return (jlong) wrapper->builder->build();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nGetVertexCount(JNIEnv* env, jclass,
|
||||
jlong nativeObject) {
|
||||
SurfaceOrientation* helper = (SurfaceOrientation*) nativeObject;
|
||||
return helper->getVertexCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nGetQuatsAsFloat(JNIEnv* env, jclass,
|
||||
jlong nativeObject, jobject javaBuffer, int remaining) {
|
||||
SurfaceOrientation* helper = (SurfaceOrientation*) nativeObject;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
size_t requestedCount = std::min(buffer.getSize() / sizeof(float4), helper->getVertexCount());
|
||||
helper->getQuats((quatf*) buffer.getData(), requestedCount);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nGetQuatsAsHalf(JNIEnv* env, jclass,
|
||||
jlong nativeObject, jobject javaBuffer, int remaining) {
|
||||
SurfaceOrientation* helper = (SurfaceOrientation*) nativeObject;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
size_t requestedCount = std::min(buffer.getSize() / sizeof(quath), helper->getVertexCount());
|
||||
helper->getQuats((quath*) buffer.getData(), requestedCount);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nGetQuatsAsShort(JNIEnv* env, jclass,
|
||||
jlong nativeObject, jobject javaBuffer, int remaining) {
|
||||
SurfaceOrientation* helper = (SurfaceOrientation*) nativeObject;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
size_t requestedCount = std::min(buffer.getSize() / sizeof(short4), helper->getVertexCount());
|
||||
helper->getQuats((short4*) buffer.getData(), requestedCount);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_SurfaceOrientation_nDestroy(JNIEnv* env, jclass,
|
||||
jlong nativeSurfaceOrientation) {
|
||||
SurfaceOrientation* helper = (SurfaceOrientation*) nativeSurfaceOrientation;
|
||||
delete helper;
|
||||
}
|
||||
@@ -113,6 +113,14 @@ Java_com_google_android_filament_Texture_nBuilderUsage(JNIEnv*, jclass,
|
||||
builder->usage((Texture::Usage) flags);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_Texture_nBuilderSwizzle(JNIEnv *, jclass ,
|
||||
jlong nativeBuilder, jint r, jint g, jint b, jint a) {
|
||||
Texture::Builder *builder = (Texture::Builder *) nativeBuilder;
|
||||
builder->swizzle(
|
||||
(Texture::Swizzle)r, (Texture::Swizzle)g, (Texture::Swizzle)b, (Texture::Swizzle)a);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_Texture_nBuilderBuild(JNIEnv*, jclass,
|
||||
jlong nativeBuilder, jlong nativeEngine) {
|
||||
@@ -225,6 +233,76 @@ Java_com_google_android_filament_Texture_nSetImageCompressed(JNIEnv *env, jclass
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImage3D(JNIEnv* env, jclass, jlong nativeTexture,
|
||||
jlong nativeEngine, jint level,
|
||||
jint xoffset, jint yoffset, jint zoffset,
|
||||
jint width, jint height, jint depth,
|
||||
jobject storage, jint remaining,
|
||||
jint left, jint bottom, 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) 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) bottom,
|
||||
(uint32_t) stride, &JniBufferCallback::invoke, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level,
|
||||
(uint32_t) xoffset, (uint32_t) yoffset, (uint32_t) zoffset,
|
||||
(uint32_t) width, (uint32_t) height, (uint32_t) depth,
|
||||
std::move(desc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImage3DCompressed(JNIEnv *env, jclass,
|
||||
jlong nativeTexture, jlong nativeEngine, jint level,
|
||||
jint xoffset, jint yoffset, jint zoffset,
|
||||
jint width, jint height, jint depth,
|
||||
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,
|
||||
&JniBufferCallback::invoke, callback);
|
||||
|
||||
texture->setImage(*engine, (size_t) level,
|
||||
(uint32_t) xoffset, (uint32_t) yoffset, (uint32_t) zoffset,
|
||||
(uint32_t) width, (uint32_t) height, (uint32_t) depth,
|
||||
std::move(desc));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_Texture_nSetImageCubemap(JNIEnv *env, jclass,
|
||||
jlong nativeTexture, jlong nativeEngine, jint level, jobject storage, jint remaining,
|
||||
@@ -396,7 +474,21 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
AutoBitmap(JNIEnv* env, jobject bitmap, jobject handler, jobject runnable) noexcept
|
||||
: mEnv(env)
|
||||
, mBitmap(env->NewGlobalRef(bitmap))
|
||||
, mHandler(env->NewGlobalRef(handler))
|
||||
, mCallback(env->NewGlobalRef(runnable))
|
||||
{
|
||||
acquireCallbackJni(env, mCallbackUtils);
|
||||
if (mBitmap) {
|
||||
AndroidBitmap_getInfo(mEnv, mBitmap, &mInfo);
|
||||
AndroidBitmap_lockPixels(mEnv, mBitmap, &mData);
|
||||
}
|
||||
}
|
||||
|
||||
~AutoBitmap() noexcept {
|
||||
releaseCallbackJni(mEnv, mCallbackUtils, mHandler, mCallback);
|
||||
if (mBitmap) {
|
||||
AndroidBitmap_unlockPixels(mEnv, mBitmap);
|
||||
mEnv->DeleteGlobalRef(mBitmap);
|
||||
@@ -430,6 +522,7 @@ public:
|
||||
|
||||
PixelDataType getType(int format) const noexcept {
|
||||
switch (format) {
|
||||
case BITMAP_CONFIG_RGB_565: return PixelDataType::USHORT_565;
|
||||
case BITMAP_CONFIG_RGBA_F16: return PixelDataType::HALF;
|
||||
default: return PixelDataType::UBYTE;
|
||||
}
|
||||
@@ -437,19 +530,26 @@ public:
|
||||
|
||||
static void invoke(void* buffer, size_t n, void* user) {
|
||||
AutoBitmap* data = reinterpret_cast<AutoBitmap*>(user);
|
||||
data->~AutoBitmap();
|
||||
delete data;
|
||||
}
|
||||
|
||||
static AutoBitmap* make(Engine* engine, JNIEnv* env, jobject bitmap) {
|
||||
void* that = engine->streamAlloc(sizeof(AutoBitmap), alignof(AutoBitmap));
|
||||
return new (that) AutoBitmap(env, bitmap);
|
||||
return new AutoBitmap(env, bitmap);
|
||||
}
|
||||
|
||||
static AutoBitmap* make(Engine* engine, JNIEnv* env, jobject bitmap,
|
||||
jobject handler, jobject runnable) {
|
||||
return new AutoBitmap(env, bitmap, handler, runnable);
|
||||
}
|
||||
|
||||
private:
|
||||
JNIEnv* mEnv;
|
||||
void* mData = nullptr;
|
||||
jobject mBitmap = nullptr;
|
||||
jobject mHandler = nullptr;
|
||||
jobject mCallback = nullptr;
|
||||
AndroidBitmapInfo mInfo;
|
||||
CallbackJni mCallbackUtils;
|
||||
};
|
||||
|
||||
extern "C"
|
||||
@@ -475,4 +575,27 @@ Java_com_google_android_filament_android_TextureHelper_nSetBitmap(JNIEnv* env, j
|
||||
std::move(desc));
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_android_TextureHelper_nSetBitmapWithCallback(JNIEnv* env, jclass,
|
||||
jlong nativeTexture, jlong nativeEngine, jint level, jint xoffset, jint yoffset,
|
||||
jint width, jint height, jobject bitmap, jint format, jobject handler, jobject runnable) {
|
||||
Texture* texture = (Texture*) nativeTexture;
|
||||
Engine *engine = (Engine *) nativeEngine;
|
||||
|
||||
auto* autoBitmap = AutoBitmap::make(engine, env, bitmap, handler, runnable);
|
||||
|
||||
Texture::PixelBufferDescriptor desc(
|
||||
autoBitmap->getData(),
|
||||
autoBitmap->getSizeInBytes(),
|
||||
autoBitmap->getFormat(format),
|
||||
autoBitmap->getType(format),
|
||||
&AutoBitmap::invoke, autoBitmap);
|
||||
|
||||
texture->setImage(*engine, (size_t) level,
|
||||
(uint32_t) xoffset, (uint32_t) yoffset,
|
||||
(uint32_t) width, (uint32_t) height,
|
||||
std::move(desc));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <utils/Entity.h>
|
||||
#include <filament/TransformManager.h>
|
||||
|
||||
#include <utils/Entity.h>
|
||||
|
||||
#include <math/mat4.h>
|
||||
|
||||
using namespace utils;
|
||||
using namespace filament;
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ Java_com_google_android_filament_VertexBuffer_nSetBufferAt(JNIEnv *env, jclass t
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
extern "C" [[deprecated]] JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_VertexBuffer_nPopulateTangentQuaternions(JNIEnv *env,
|
||||
jclass type, jint quatType, jint quatCount, jobject outBuffer, jint outRemaining,
|
||||
jint outStride, jobject normals, jint normalsRemaining, jint normalsStride,
|
||||
|
||||
@@ -16,14 +16,14 @@
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <filament/Color.h>
|
||||
#include <filament/View.h>
|
||||
#include <filament/Viewport.h>
|
||||
|
||||
using namespace filament;
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetName(JNIEnv* env, jclass,
|
||||
jlong nativeView, jstring name_) {
|
||||
Java_com_google_android_filament_View_nSetName(JNIEnv* env, jclass, jlong nativeView, jstring name_) {
|
||||
View* view = (View*) nativeView;
|
||||
const char* name = env->GetStringUTFChars(name_, 0);
|
||||
view->setName(name);
|
||||
@@ -31,8 +31,7 @@ Java_com_google_android_filament_View_nSetName(JNIEnv* env, jclass,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetScene(JNIEnv*, jclass,
|
||||
jlong nativeView, jlong nativeScene) {
|
||||
Java_com_google_android_filament_View_nSetScene(JNIEnv*, jclass, jlong nativeView, jlong nativeScene) {
|
||||
View* view = (View*) nativeView;
|
||||
Scene* scene = (Scene*) nativeScene;
|
||||
view->setScene(scene);
|
||||
@@ -46,6 +45,14 @@ Java_com_google_android_filament_View_nSetCamera(JNIEnv*, jclass,
|
||||
view->setCamera(camera);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetColorGrading(JNIEnv*, jclass,
|
||||
jlong nativeView, jlong nativeColorGrading) {
|
||||
View* view = (View*) nativeView;
|
||||
ColorGrading* colorGrading = (ColorGrading*) nativeColorGrading;
|
||||
view->setColorGrading(colorGrading);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetViewport(JNIEnv*, jclass,
|
||||
jlong nativeView, jint left, jint bottom, jint width, jint height) {
|
||||
@@ -54,43 +61,13 @@ Java_com_google_android_filament_View_nSetViewport(JNIEnv*, jclass,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetClearColor(JNIEnv*, jclass,
|
||||
jlong nativeView,
|
||||
jfloat linearR, jfloat linearG, jfloat linearB, jfloat linearA) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setClearColor({linearR, linearG, linearB, linearA});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nGetClearColor(JNIEnv* env, jclass,
|
||||
jlong nativeView, jfloatArray out_) {
|
||||
View* view = (View*) nativeView;
|
||||
jfloat* out = env->GetFloatArrayElements(out_, NULL);
|
||||
auto linearColor = view->getClearColor();
|
||||
out[0] = linearColor[0];
|
||||
out[1] = linearColor[1];
|
||||
out[2] = linearColor[2];
|
||||
out[3] = linearColor[3];
|
||||
env->ReleaseFloatArrayElements(out_, out, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetClearTargets(JNIEnv*, jclass,
|
||||
jlong nativeView, jboolean color, jboolean depth, jboolean stencil) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setClearTargets(color, depth, stencil);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetVisibleLayers(JNIEnv*, jclass,
|
||||
jlong nativeView, jint select, jint value) {
|
||||
Java_com_google_android_filament_View_nSetVisibleLayers(JNIEnv*, jclass, jlong nativeView, jint select, jint value) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setVisibleLayers((uint8_t) select, (uint8_t) value);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetShadowsEnabled(JNIEnv*, jclass,
|
||||
jlong nativeView, jboolean enabled) {
|
||||
Java_com_google_android_filament_View_nSetShadowsEnabled(JNIEnv*, jclass, jlong nativeView, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setShadowsEnabled(enabled);
|
||||
}
|
||||
@@ -103,50 +80,31 @@ Java_com_google_android_filament_View_nSetRenderTarget(JNIEnv*, jclass,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetSampleCount(JNIEnv*, jclass,
|
||||
jlong nativeView, jint count) {
|
||||
Java_com_google_android_filament_View_nSetSampleCount(JNIEnv*, jclass, jlong nativeView, jint count) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setSampleCount((uint8_t) count);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetSampleCount(JNIEnv*, jclass,
|
||||
jlong nativeView) {
|
||||
Java_com_google_android_filament_View_nGetSampleCount(JNIEnv*, jclass, jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return view->getSampleCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetAntiAliasing(JNIEnv*, jclass,
|
||||
jlong nativeView, jint type) {
|
||||
Java_com_google_android_filament_View_nSetAntiAliasing(JNIEnv*, jclass, jlong nativeView, jint type) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setAntiAliasing(View::AntiAliasing(type));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetAntiAliasing(JNIEnv*, jclass,
|
||||
jlong nativeView) {
|
||||
Java_com_google_android_filament_View_nGetAntiAliasing(JNIEnv*, jclass, jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return (jint) view->getAntiAliasing();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetToneMapping(JNIEnv*, jclass,
|
||||
jlong nativeView, jint type) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setToneMapping(View::ToneMapping(type));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetToneMapping(JNIEnv*, jclass,
|
||||
jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
return (jint) view->getToneMapping();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetDithering(JNIEnv*, jclass,
|
||||
jlong nativeView, jint dithering) {
|
||||
Java_com_google_android_filament_View_nSetDithering(JNIEnv*, jclass, jlong nativeView, jint dithering) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setDithering((View::Dithering) dithering);
|
||||
}
|
||||
@@ -159,20 +117,16 @@ Java_com_google_android_filament_View_nGetDithering(JNIEnv*, jclass,
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetDynamicResolutionOptions(JNIEnv*,
|
||||
jclass, jlong nativeView, jboolean enabled, jboolean homogeneousScaling,
|
||||
jfloat targetFrameTimeMilli, jfloat headRoomRatio, jfloat scaleRate,
|
||||
jfloat minScale, jfloat maxScale, jint history) {
|
||||
View* view = (View*) nativeView;
|
||||
Java_com_google_android_filament_View_nSetDynamicResolutionOptions(JNIEnv*, jclass, jlong nativeView,
|
||||
jboolean enabled, jboolean homogeneousScaling,
|
||||
jfloat minScale, jfloat maxScale, jint quality) {
|
||||
View* view = (View*)nativeView;
|
||||
View::DynamicResolutionOptions options;
|
||||
options.enabled = enabled;
|
||||
options.homogeneousScaling = homogeneousScaling;
|
||||
options.targetFrameTimeMilli = targetFrameTimeMilli;
|
||||
options.headRoomRatio = headRoomRatio;
|
||||
options.scaleRate = scaleRate;
|
||||
options.minScale = filament::math::float2{minScale};
|
||||
options.maxScale = filament::math::float2{maxScale};
|
||||
options.history = (uint8_t) history;
|
||||
options.minScale = filament::math::float2{ minScale };
|
||||
options.maxScale = filament::math::float2{ maxScale };
|
||||
options.quality = (View::QualityLevel)quality;
|
||||
view->setDynamicResolutionOptions(options);
|
||||
}
|
||||
|
||||
@@ -193,13 +147,6 @@ Java_com_google_android_filament_View_nSetDynamicLightingOptions(JNIEnv*,
|
||||
view->setDynamicLightingOptions(zLightNear, zLightFar);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetDepthPrepass(JNIEnv*,
|
||||
jclass, jlong nativeView, jint value) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setDepthPrepass(View::DepthPrepass(value));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetPostProcessingEnabled(JNIEnv*,
|
||||
jclass, jlong nativeView, jboolean enabled) {
|
||||
@@ -231,25 +178,111 @@ Java_com_google_android_filament_View_nIsFrontFaceWindingInverted(JNIEnv*,
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetAmbientOcclusion(JNIEnv*, jclass, jlong nativeView, jint ordinal) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setAmbientOcclusion((View::AmbientOcclusion)ordinal);
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
view->setAmbientOcclusion((View::AmbientOcclusion) ordinal);
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_View_nGetAmbientOcclusion(JNIEnv*, jclass, jlong nativeView) {
|
||||
View* view = (View*) nativeView;
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
return (jint)view->getAmbientOcclusion();
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetAmbientOcclusionOptions(JNIEnv*, jclass,
|
||||
jlong nativeView, jfloat radius, jfloat bias, jfloat power, jfloat resolution, jfloat intensity) {
|
||||
jlong nativeView, jfloat radius, jfloat bias, jfloat power, jfloat resolution, jfloat intensity,
|
||||
jint quality, jint upsampling, jboolean enabled, jfloat minHorizonAngleRad) {
|
||||
View* view = (View*) nativeView;
|
||||
View::AmbientOcclusionOptions options = {
|
||||
.radius = radius,
|
||||
.bias = bias,
|
||||
.power = power,
|
||||
.bias = bias,
|
||||
.resolution = resolution,
|
||||
.intensity = intensity
|
||||
.intensity = intensity,
|
||||
.quality = (View::QualityLevel)quality,
|
||||
.upsampling = (View::QualityLevel)upsampling,
|
||||
.enabled = (bool)enabled,
|
||||
.minHorizonAngleRad = minHorizonAngleRad
|
||||
};
|
||||
view->setAmbientOcclusionOptions(options);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetBloomOptions(JNIEnv*, jclass,
|
||||
jlong nativeView, jlong nativeTexture,
|
||||
jfloat dirtStrength, jfloat strength, jint resolution, jfloat anamorphism, jint levels,
|
||||
jint blendMode, jboolean threshold, jboolean enabled, jfloat highlight) {
|
||||
View* view = (View*) nativeView;
|
||||
Texture* dirt = (Texture*) nativeTexture;
|
||||
View::BloomOptions options = {
|
||||
.dirt = dirt,
|
||||
.dirtStrength = dirtStrength,
|
||||
.strength = strength,
|
||||
.resolution = (uint32_t)resolution,
|
||||
.anamorphism = anamorphism,
|
||||
.levels = (uint8_t)levels,
|
||||
.blendMode = (View::BloomOptions::BlendMode)blendMode,
|
||||
.threshold = (bool)threshold,
|
||||
.enabled = (bool)enabled,
|
||||
.highlight = highlight
|
||||
};
|
||||
view->setBloomOptions(options);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetFogOptions(JNIEnv *, jclass , jlong nativeView,
|
||||
jfloat distance, jfloat maximumOpacity, jfloat height, jfloat heightFalloff, jfloat r,
|
||||
jfloat g, jfloat b, jfloat density, jfloat inScatteringStart,
|
||||
jfloat inScatteringSize, jboolean fogColorFromIbl, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
View::FogOptions options = {
|
||||
.distance = distance,
|
||||
.maximumOpacity = maximumOpacity,
|
||||
.height = height,
|
||||
.heightFalloff = heightFalloff,
|
||||
.color = math::float3{r, g, b},
|
||||
.density = density,
|
||||
.inScatteringStart = inScatteringStart,
|
||||
.inScatteringSize = inScatteringSize,
|
||||
.fogColorFromIbl = (bool)fogColorFromIbl,
|
||||
.enabled = (bool)enabled
|
||||
};
|
||||
view->setFogOptions(options);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetBlendMode(JNIEnv *, jclass , jlong nativeView, jint blendMode) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setBlendMode((View::BlendMode)blendMode);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetDepthOfFieldOptions(JNIEnv *, jclass ,
|
||||
jlong nativeView, jfloat focusDistance, jfloat cocScale, jfloat maxApertureDiameter, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setDepthOfFieldOptions({.focusDistance = focusDistance, .cocScale = cocScale,
|
||||
.maxApertureDiameter = maxApertureDiameter, .enabled = (bool)enabled});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetVignetteOptions(JNIEnv*, jclass, jlong nativeView, jfloat midPoint, jfloat roundness,
|
||||
jfloat feather, jfloat r, jfloat g, jfloat b, jfloat a, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setVignetteOptions({.midPoint = midPoint, .roundness = roundness, .feather = feather,
|
||||
.color = LinearColorA{r, g, b, a}, .enabled = (bool)enabled});
|
||||
}
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_View_nSetTemporalAntiAliasingOptions(JNIEnv *, jclass,
|
||||
jlong nativeView, jfloat feedback, jfloat filterWidth, jboolean enabled) {
|
||||
View* view = (View*) nativeView;
|
||||
view->setTemporalAntiAliasingOptions({
|
||||
.filterWidth = filterWidth, .feedback = feedback, .enabled = (bool) enabled});
|
||||
}
|
||||
|
||||
@@ -78,6 +78,12 @@ final class Asserts {
|
||||
return out;
|
||||
}
|
||||
|
||||
static void assertFloat3In(@NonNull float[] out) {
|
||||
if (out.length < 3) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 3");
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull @Size(min = 4)
|
||||
static float[] assertFloat4(@Nullable float[] out) {
|
||||
if (out == null) out = new float[4];
|
||||
@@ -86,4 +92,24 @@ final class Asserts {
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static void assertFloat4In(@NonNull float[] out) {
|
||||
if (out.length < 4) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 4");
|
||||
}
|
||||
}
|
||||
|
||||
static double[] assertDouble4(@Nullable double[] out) {
|
||||
if (out == null) out = new double[4];
|
||||
else if (out.length < 4) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 4");
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
static void assertDouble4In(@NonNull double[] in) {
|
||||
if (in.length < 4) {
|
||||
throw new ArrayIndexOutOfBoundsException("Array length must be at least 4");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -195,7 +195,7 @@ public class Camera {
|
||||
/**
|
||||
* Sets the projection matrix from the field-of-view.
|
||||
*
|
||||
* @param fovInDegrees field-of-view in degrees from the camera center axis.
|
||||
* @param fovInDegrees full field-of-view in degrees.
|
||||
* 0 < <code>fovInDegrees</code> < 180
|
||||
*
|
||||
* @param aspect aspect ratio width/height. <code>aspect</code> > 0
|
||||
@@ -226,9 +226,11 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the projection matrix from the focal length
|
||||
* Sets the projection matrix from the focal length.
|
||||
*
|
||||
* @param focalLength lense's focal length in millimeters. <code>focalLength</code> > 0
|
||||
* @param focalLength lens's focal length in millimeters. <code>focalLength</code> > 0
|
||||
*
|
||||
* @param aspect aspect ratio width/height. <code>aspect</code> > 0
|
||||
*
|
||||
* @param near distance in world units from the camera to the near plane.
|
||||
* The near plane's position in view space is z = -<code>near</code>.
|
||||
@@ -245,8 +247,8 @@ public class Camera {
|
||||
* for {@link Projection#ORTHO}.
|
||||
*
|
||||
*/
|
||||
public void setLensProjection(double focalLength, double near, double far) {
|
||||
nSetLensProjection(getNativeObject(), focalLength, near, far);
|
||||
public void setLensProjection(double focalLength, double aspect, double near, double far) {
|
||||
nSetLensProjection(getNativeObject(), focalLength, aspect, near, far);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -274,6 +276,39 @@ public class Camera {
|
||||
nSetCustomProjection(getNativeObject(), inMatrix, near, far);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an additional matrix that scales the projection matrix.
|
||||
*
|
||||
* <p>This is useful to adjust the aspect ratio of the camera independent from its projection.
|
||||
* First, pass an aspect of 1.0 to setProjection. Then set the scaling with the desired aspect
|
||||
* ratio:<br>
|
||||
*
|
||||
* <code>
|
||||
* double aspect = width / height;
|
||||
*
|
||||
* // with Fov.HORIZONTAL passed to setProjection:
|
||||
* double[] s = {1.0, aspect, 1.0, 1.0};
|
||||
* camera.setScaling(s);
|
||||
*
|
||||
* // with Fov.VERTICAL passed to setProjection:
|
||||
* double[] s = {1.0 / aspect, 1.0, 1.0, 1.0};
|
||||
* camera.setScaling(s);
|
||||
* </code>
|
||||
*
|
||||
* By default, this is an identity matrix.
|
||||
* </p>
|
||||
*
|
||||
* @param scaling diagonal of the scaling matrix to be applied after the projection matrix.
|
||||
*
|
||||
* @see Camera#setProjection
|
||||
* @see Camera#setLensProjection
|
||||
* @see Camera#setCustomProjection
|
||||
*/
|
||||
public void setScaling(@NonNull @Size(min = 4) double[] inScaling) {
|
||||
Asserts.assertDouble4In(inScaling);
|
||||
nSetScaling(getNativeObject(), inScaling);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the camera's view matrix.
|
||||
* <p>
|
||||
@@ -327,7 +362,9 @@ public class Camera {
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the camera's projection matrix.
|
||||
* Retrieves the camera's projection matrix. The projection matrix used for rendering always has
|
||||
* its far plane set to infinity. This is why it may differ from the matrix set through
|
||||
* setProjection() or setLensProjection().
|
||||
*
|
||||
* @param out A 16-float array where the projection matrix will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
@@ -341,6 +378,36 @@ public class Camera {
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the camera's culling matrix. The culling matrix is the same as the projection
|
||||
* matrix, except the far plane is finite.
|
||||
*
|
||||
* @param out A 16-float array where the projection matrix will be stored, or null in which
|
||||
* case a new array is allocated.
|
||||
*
|
||||
* @return A 16-float array containing the camera's projection as a column-major matrix.
|
||||
*/
|
||||
@NonNull @Size(min = 16)
|
||||
public double[] getCullingProjectionMatrix(@Nullable @Size(min = 16) double[] out) {
|
||||
out = Asserts.assertMat4d(out);
|
||||
nGetCullingProjectionMatrix(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scaling amount used to scale the projection matrix.
|
||||
*
|
||||
* @return the diagonal of the scaling matrix applied after the projection matrix.
|
||||
*
|
||||
* @see Camera#setScaling
|
||||
*/
|
||||
@NonNull @Size(min = 4)
|
||||
public double[] getScaling(@Nullable @Size(min = 4) double[] out) {
|
||||
out = Asserts.assertDouble4(out);
|
||||
nGetScaling(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the camera's model matrix. The model matrix encodes the camera position and
|
||||
* orientation, or pose.
|
||||
@@ -517,13 +584,16 @@ public class Camera {
|
||||
|
||||
private static native void nSetProjection(long nativeCamera, int projection, double left, double right, double bottom, double top, double near, double far);
|
||||
private static native void nSetProjectionFov(long nativeCamera, double fovInDegrees, double aspect, double near, double far, int fov);
|
||||
private static native void nSetLensProjection(long nativeCamera, double focalLength, double near, double far);
|
||||
private static native void nSetLensProjection(long nativeCamera, double focalLength, double aspect, double near, double far);
|
||||
private static native void nSetCustomProjection(long nativeCamera, double[] inMatrix, double near, double far);
|
||||
private static native void nSetScaling(long nativeCamera, double[] inScaling);
|
||||
private static native void nSetModelMatrix(long nativeCamera, float[] 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 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);
|
||||
private static native void nGetModelMatrix(long nativeCamera, float[] out);
|
||||
private static native void nGetViewMatrix(long nativeCamera, float[] out);
|
||||
private static native void nGetPosition(long nativeCamera, float[] out);
|
||||
|
||||
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Size;
|
||||
|
||||
import static com.google.android.filament.Asserts.assertFloat3In;
|
||||
import static com.google.android.filament.Asserts.assertFloat4In;
|
||||
|
||||
/**
|
||||
* <code>ColorGrading</code> is used to transform (either to modify or correct) the colors of the
|
||||
* HDR buffer rendered by Filament. Color grading transforms are applied after lighting, and after any
|
||||
* lens effects (bloom for instance), and include tone mapping.
|
||||
*
|
||||
* <h1>Creation, usage and destruction</h1>
|
||||
*
|
||||
* A ColorGrading object is created using the ColorGrading::Builder and destroyed by calling
|
||||
* Engine::destroy(const ColorGrading*). A ColorGrading object is meant to be set on a View.
|
||||
*
|
||||
* <pre>
|
||||
* Engine engine = Engine.create();
|
||||
*
|
||||
* ColorGrading colorGrading = ColorGrading.Builder()
|
||||
* .toneMapping(ColorGrading.ToneMapping.ACES)
|
||||
* .build(engine);
|
||||
*
|
||||
* myView.setColorGrading(colorGrading);
|
||||
*
|
||||
* engine.destroy(colorGrading);
|
||||
* </pre>
|
||||
*
|
||||
* <h1>Performance</h1>
|
||||
*
|
||||
* Creating a new ColorGrading object may be more expensive than other Filament objects as a
|
||||
* 3D LUT may need to be generated. The generation of a 3D LUT, if necessary, may happen on
|
||||
* the CPU.
|
||||
*
|
||||
* <h1>Ordering</h1>
|
||||
*
|
||||
* The various transforms held by ColorGrading are applied in the following order:
|
||||
* <ul>
|
||||
* <li>White balance</li>
|
||||
* <li>Channel mixer</li>
|
||||
* <li>Shadows/mid-tones/highlights</li>
|
||||
* <li>Slope/offset/power (CDL)</li>
|
||||
* <li>Contrast</li>
|
||||
* <li>Vibrance</li>
|
||||
* <li>Saturation</li>
|
||||
* <li>Curves</li>
|
||||
* <li>Tone mapping</li>
|
||||
* </ul>
|
||||
*
|
||||
* <h1>Defaults</h1>
|
||||
*
|
||||
* Here are the default color grading options:
|
||||
* <ul>
|
||||
* <li>White balance: temperature <code>0.0</code>, and tint <code>0.0</code></li>
|
||||
* <li>Channel mixer: red <code>{1,0,0}</code>, green <code>{0,1,0}</code>, blue <code>{0,0,1}</code></li>
|
||||
* <li>Shadows/mid-tones/highlights: shadows <code>{1,1,1,0}</code>, mid-tones <code>{1,1,1,0}</code>,
|
||||
* highlights <code>{1,1,1,0}</code>, ranges <code>{0,0.333,0.550,1}</code></li>
|
||||
* <li>Slope/offset/power: slope <code>1.0</code>, offset <code>0.0</code>, and power <code>1.0</code></li>
|
||||
* <li>Contrast: <code>1.0</code></li>
|
||||
* <li>Vibrance: <code>1.0</code></li>
|
||||
* <li>Saturation: <code>1.0</code></li>
|
||||
* <li>Curves: gamma <code>{1,1,1}</code>, midPoint <code>{1,1,1}</code>, and scale <code>{1,1,1}</code></li>
|
||||
* <li>Tone mapping: {@link ToneMapping#ACES_LEGACY}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @see View
|
||||
* @see ToneMapping
|
||||
*/
|
||||
public class ColorGrading {
|
||||
long mNativeObject;
|
||||
|
||||
/**
|
||||
* Color grading quality level.
|
||||
*/
|
||||
public enum QualityLevel {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
ULTRA
|
||||
}
|
||||
|
||||
/**
|
||||
* List of available tone-mapping operators.
|
||||
*/
|
||||
public enum ToneMapping {
|
||||
/** Linear tone mapping (i.e. no tone mapping). */
|
||||
LINEAR,
|
||||
/** ACES tone mapping, with a brightness modifier to match Filament's legacy tone mapper. */
|
||||
ACES_LEGACY,
|
||||
/** ACES tone mapping. */
|
||||
ACES,
|
||||
/** Filmic tone mapping, modelled after ACES but applied in sRGB space. */
|
||||
FILMIC,
|
||||
/** Filmic tone mapping, with more contrast and saturation. */
|
||||
UCHIMURA,
|
||||
/** Reinhard luma-based tone mapping. */
|
||||
REINHARD,
|
||||
/** Tone mapping used to validate/debug scene exposure. */
|
||||
DISPLAY_RANGE,
|
||||
}
|
||||
|
||||
ColorGrading(long colorGrading) {
|
||||
mNativeObject = colorGrading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use <code>Builder</code> to construct a <code>ColorGrading</code> object instance.
|
||||
*/
|
||||
public static class Builder {
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"}) // Keep to finalize native resources
|
||||
private final BuilderFinalizer mFinalizer;
|
||||
private final long mNativeBuilder;
|
||||
|
||||
/**
|
||||
* Use <code>Builder</code> to construct a <code>ColorGrading</code> object instance.
|
||||
*/
|
||||
public Builder() {
|
||||
mNativeBuilder = nCreateBuilder();
|
||||
mFinalizer = new BuilderFinalizer(mNativeBuilder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the quality level of the color grading. When color grading is implemented using
|
||||
* a 3D LUT, the quality level may impact the resolution and bit depth of the backing
|
||||
* 3D texture. For instance, a low quality level will use a 16x16x16 10 bit LUT, a medium
|
||||
* quality level will use a 32x32x32 10 bit LUT, a high quality will use a 32x32x32 16 bit
|
||||
* LUT, and a ultra quality will use a 64x64x64 16 bit LUT.
|
||||
*
|
||||
* The default quality is {@link QualityLevel#MEDIUM}.
|
||||
*
|
||||
* @param qualityLevel The desired quality of the color grading process
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
public Builder quality(QualityLevel qualityLevel) {
|
||||
nBuilderQuality(mNativeBuilder, qualityLevel.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Selects the tone mapping operator to apply to the HDR color buffer as the last
|
||||
* operation of the color grading post-processing step.
|
||||
*
|
||||
* The default tone mapping operator is {@link ToneMapping#ACES_LEGACY}.
|
||||
*
|
||||
* @param toneMapping The tone mapping operator to apply to the HDR color buffer
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
public Builder toneMapping(ToneMapping toneMapping) {
|
||||
nBuilderToneMapping(mNativeBuilder, toneMapping.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the while balance of the image. This can be used to remove color casts
|
||||
* and correct the appearance of the white point in the scene, or to alter the
|
||||
* overall chromaticity of the image for artistic reasons (to make the image appear
|
||||
* cooler or warmer for instance).
|
||||
*
|
||||
* The while balance adjustment is defined with two values:
|
||||
* <ul>
|
||||
* <li>Temperature, to modify the color temperature. This value will modify the colors
|
||||
* on a blue/yellow axis. Lower values apply a cool color temperature, and higher
|
||||
* values apply a warm color temperature. The lowest value, -1.0f, is equivalent to
|
||||
* a temperature of 50,000K. The highest value, 1.0f, is equivalent to a temperature
|
||||
* of 2,000K.</li>
|
||||
* <li>Tint, to modify the colors on a green/magenta axis. The lowest value, -1.0f, will
|
||||
* apply a strong green cast, and the highest value, 1.0f, will apply a strong magenta
|
||||
* cast.</li>
|
||||
* </ul>
|
||||
*
|
||||
* Both values are expected to be in the range <code>[-1.0..+1.0]</code>. Values outside
|
||||
* of that range will be clipped to that range.
|
||||
*
|
||||
* @param temperature Modification on the blue/yellow axis, as a value between -1.0 and +1.0.
|
||||
* @param tint Modification on the green/magenta axis, as a value between -1.0 and +1.0.
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
public Builder whiteBalance(float temperature, float tint) {
|
||||
nBuilderWhiteBalance(mNativeBuilder, temperature, tint);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* The channel mixer adjustment modifies each output color channel using the specified
|
||||
* mix of the source color channels.
|
||||
*
|
||||
* By default each output color channel is set to use 100% of the corresponding source
|
||||
* channel and 0% of the other channels. For instance, the output red channel is set to
|
||||
* <code>{1.0, 0.0, 1.0}</code> or 100% red, 0% green and 0% blue.
|
||||
*
|
||||
* Each output channel can add or subtract data from the source channel by using values
|
||||
* in the range <code>[-2.0..+2.0]</code>. Values outside of that range will be clipped
|
||||
* to that range.
|
||||
*
|
||||
* Using the channel mixer adjustment you can for instance create a monochrome output
|
||||
* by setting all 3 output channels to the same mix. For instance:
|
||||
* </code>{0.4, 0.4, 0.2}</code> for all 3 output channels(40% red, 40% green and 20% blue).
|
||||
*
|
||||
* More complex mixes can be used to create more complex effects. For instance, here is
|
||||
* a mix that creates a sepia tone effect:
|
||||
* <ul>
|
||||
* <li><code>outRed = {0.255, 0.858, 0.087}</code></li>
|
||||
* <li><code>outGreen = {0.213, 0.715, 0.072}</code></li>
|
||||
* <li><code>outBlue = {0.170, 0.572, 0.058}</code></li>
|
||||
* </ul>
|
||||
*
|
||||
* @param outRed The mix of source RGB for the output red channel, between -2.0 and +2.0
|
||||
* @param outGreen The mix of source RGB for the output green channel, between -2.0 and +2.0
|
||||
* @param outBlue The mix of source RGB for the output blue channel, between -2.0 and +2.0
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
public Builder channelMixer(
|
||||
@NonNull @Size(min = 3) float[] outRed,
|
||||
@NonNull @Size(min = 3) float[] outGreen,
|
||||
@NonNull @Size(min = 3) float[] outBlue) {
|
||||
|
||||
assertFloat3In(outRed);
|
||||
assertFloat3In(outGreen);
|
||||
assertFloat3In(outBlue);
|
||||
|
||||
nBuilderChannelMixer(mNativeBuilder, outRed, outGreen, outBlue);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the colors separately in 3 distinct tonal ranges or zones: shadows, mid-tones,
|
||||
* and highlights.
|
||||
*
|
||||
* The tonal zones are by the ranges parameter: the x and y components define the beginning
|
||||
* and end of the transition from shadows to mid-tones, and the z and w components define
|
||||
* the beginning and end of the transition from mid-tones to highlights.
|
||||
*
|
||||
* A smooth transition is applied between the zones which means for instance that the
|
||||
* correction color of the shadows range will partially apply to the mid-tones, and the
|
||||
* other way around. This ensure smooth visual transitions in the final image.
|
||||
*
|
||||
* Each correction color is defined as a linear RGB color and a weight. The weight is a
|
||||
* value (which may be positive or negative) that is added to the linear RGB color before
|
||||
* mixing. This can be used to darken or brighten the selected tonal range.
|
||||
*
|
||||
* Shadows/mid-tones/highlights adjustment are performed linear space.
|
||||
*
|
||||
* @param shadows Linear RGB color (.rgb) and weight (.w) to apply to the shadows
|
||||
* @param midtones Linear RGB color (.rgb) and weight (.w) to apply to the mid-tones
|
||||
* @param highlights Linear RGB color (.rgb) and weight (.w) to apply to the highlights
|
||||
* @param ranges Range of the shadows (x and y), and range of the highlights (z and w)
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
Builder shadowsMidtonesHighlights(
|
||||
@NonNull @Size(min = 4) float[] shadows,
|
||||
@NonNull @Size(min = 4) float[] midtones,
|
||||
@NonNull @Size(min = 4) float[] highlights,
|
||||
@NonNull @Size(min = 4) float[] ranges) {
|
||||
|
||||
assertFloat4In(shadows);
|
||||
assertFloat4In(midtones);
|
||||
assertFloat4In(highlights);
|
||||
assertFloat4In(ranges);
|
||||
|
||||
nBuilderShadowsMidtonesHighlights(mNativeBuilder, shadows, midtones, highlights, ranges);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a slope, offset, and power, as defined by the ASC CDL (American Society of
|
||||
* Cinematographers Color Decision List) to the image. The CDL can be used to adjust the
|
||||
* colors of different tonal ranges in the image.
|
||||
*
|
||||
* The ASC CDL is similar to the lift/gamma/gain controls found in many color grading tools.
|
||||
* Lift is equivalent to a combination of offset and slope, gain is equivalent to slope,
|
||||
* and gamma is equivalent to power.
|
||||
*
|
||||
* The slope and power values must be strictly positive. Values less than or equal to 0 will
|
||||
* be clamped to a small positive value, offset can be any positive or negative value.
|
||||
*
|
||||
* Version 1.2 of the ASC CDL adds saturation control, which is here provided as a separate
|
||||
* API. See the saturation() method for more information.
|
||||
*
|
||||
* Slope/offset/power adjustments are performed in log space.
|
||||
*
|
||||
* @param slope Multiplier of the input color, must be a strictly positive number
|
||||
* @param offset Added to the input color, can be a negative or positive number, including 0
|
||||
* @param power Power exponent of the input color, must be a strictly positive number
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
Builder slopeOffsetPower(
|
||||
@NonNull @Size(min = 3) float[] slope,
|
||||
@NonNull @Size(min = 3) float[] offset,
|
||||
@NonNull @Size(min = 3) float[] power) {
|
||||
|
||||
assertFloat3In(slope);
|
||||
assertFloat3In(offset);
|
||||
assertFloat3In(power);
|
||||
|
||||
nBuilderSlopeOffsetPower(mNativeBuilder, slope, offset, power);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the contrast of the image. Lower values decrease the contrast of the image
|
||||
* (the tonal range is narrowed), and higher values increase the contrast of the image
|
||||
* (the tonal range is widened). A value of 1.0 has no effect.
|
||||
*
|
||||
* The contrast is defined as a value in the range <code>[0.0...2.0]</code>. Values
|
||||
* outside of that range will be clipped to that range.
|
||||
*
|
||||
* Contrast adjustment is performed in log space.
|
||||
*
|
||||
* @param contrast Contrast expansion, between 0.0 and 2.0. 1.0 leaves contrast unaffected
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
public Builder contrast(float contrast) {
|
||||
nBuilderContrast(mNativeBuilder, contrast);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the saturation of the image based on the input color's saturation level.
|
||||
* Colors with a high level of saturation are less affected than colors with low saturation
|
||||
* levels.
|
||||
*
|
||||
* Lower vibrance values decrease intensity of the colors present in the image, and
|
||||
* higher values increase the intensity of the colors in the image. A value of 1.0 has
|
||||
* no effect.
|
||||
*
|
||||
* The vibrance is defined as a value in the range <code>[0.0...2.0]</code>. Values outside
|
||||
* of that range will be clipped to that range.
|
||||
*
|
||||
* Vibrance adjustment is performed in linear space.
|
||||
*
|
||||
* @param vibrance Vibrance, between 0.0 and 2.0. 1.0 leaves vibrance unaffected
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
Builder vibrance(float vibrance) {
|
||||
nBuilderVibrance(mNativeBuilder, vibrance);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the saturation of the image. Lower values decrease intensity of the colors
|
||||
* present in the image, and higher values increase the intensity of the colors in the
|
||||
* image. A value of 1.0 has no effect.
|
||||
*
|
||||
* The saturation is defined as a value in the range <code>[0.0...2.0]</code>.
|
||||
* Values outside of that range will be clipped to that range.
|
||||
*
|
||||
* Saturation adjustment is performed in linear space.
|
||||
*
|
||||
* @param saturation Saturation, between 0.0 and 2.0. 1.0 leaves saturation unaffected
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
public Builder saturation(float saturation) {
|
||||
nBuilderSaturation(mNativeBuilder, saturation);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a curve to each RGB channel of the image. Each curve is defined by 3 values:
|
||||
* a gamma value applied to the shadows only, a mid-point indicating where shadows stop
|
||||
* and highlights start, and a scale factor for the highlights.
|
||||
*
|
||||
* The gamma and mid-point must be strictly positive values. If they are not, they will be
|
||||
* clamped to a small positive value. The scale can be any negative of positive value.
|
||||
*
|
||||
* Curves are applied in linear space.
|
||||
*
|
||||
* @param shadowGamma Power value to apply to the shadows, must be strictly positive
|
||||
* @param midPoint Mid-point defining where shadows stop and highlights start, must be strictly positive
|
||||
* @param highlightScale Scale factor for the highlights, can be any negative or positive value
|
||||
*
|
||||
* @return This Builder, for chaining calls
|
||||
*/
|
||||
public Builder curves(
|
||||
@NonNull @Size(min = 3) float[] shadowGamma,
|
||||
@NonNull @Size(min = 3) float[] midPoint,
|
||||
@NonNull @Size(min = 3) float[] highlightScale) {
|
||||
|
||||
assertFloat3In(shadowGamma);
|
||||
assertFloat3In(midPoint);
|
||||
assertFloat3In(highlightScale);
|
||||
|
||||
nBuilderCurves(mNativeBuilder, shadowGamma, midPoint, highlightScale);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the IndirectLight object and returns a pointer to it.
|
||||
*
|
||||
* @param engine The {@link Engine} to associate this <code>IndirectLight</code> with.
|
||||
*
|
||||
* @return A newly created <code>IndirectLight</code>
|
||||
*
|
||||
* @exception IllegalStateException if a parameter to a builder function was invalid.
|
||||
*/
|
||||
@NonNull
|
||||
public ColorGrading build(@NonNull Engine engine) {
|
||||
long nativeColorGrading = nBuilderBuild(mNativeBuilder, engine.getNativeObject());
|
||||
if (nativeColorGrading == 0) throw new IllegalStateException("Couldn't create ColorGrading");
|
||||
return new ColorGrading(nativeColorGrading);
|
||||
}
|
||||
|
||||
private static class BuilderFinalizer {
|
||||
private final long mNativeObject;
|
||||
|
||||
BuilderFinalizer(long nativeObject) { mNativeObject = nativeObject; }
|
||||
|
||||
@Override
|
||||
public void finalize() {
|
||||
try {
|
||||
super.finalize();
|
||||
} catch (Throwable t) { // Ignore
|
||||
} finally {
|
||||
nDestroyBuilder(mNativeObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed ColorGrading");
|
||||
}
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
void clearNativeObject() {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native long nCreateBuilder();
|
||||
private static native void nDestroyBuilder(long nativeBuilder);
|
||||
|
||||
private static native void nBuilderQuality(long nativeBuilder, int quality);
|
||||
private static native void nBuilderToneMapping(long nativeBuilder, int toneMapper);
|
||||
private static native void nBuilderWhiteBalance(long nativeBuilder, float temperature, float tint);
|
||||
private static native void nBuilderChannelMixer(long nativeBuilder, float[] outRed, float[] outGreen, float[] outBlue);
|
||||
private static native void nBuilderShadowsMidtonesHighlights(long nativeBuilder, float[] shadows, float[] midtones, float[] highlights, float[] ranges);
|
||||
private static native void nBuilderSlopeOffsetPower(long nativeBuilder, float[] slope, float[] offset, float[] power);
|
||||
private static native void nBuilderContrast(long nativeBuilder, float contrast);
|
||||
private static native void nBuilderVibrance(long nativeBuilder, float vibrance);
|
||||
private static native void nBuilderSaturation(long nativeBuilder, float saturation);
|
||||
private static native void nBuilderCurves(long nativeBuilder, float[] gamma, float[] midPoint, float[] scale);
|
||||
|
||||
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.google.android.filament;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
@@ -344,7 +345,7 @@ public class Engine {
|
||||
* @param swapChain the {@link SwapChain} to destroy
|
||||
*/
|
||||
public void destroySwapChain(@NonNull SwapChain swapChain) {
|
||||
nDestroySwapChain(getNativeObject(), swapChain.getNativeObject());
|
||||
assertDestroy(nDestroySwapChain(getNativeObject(), swapChain.getNativeObject()));
|
||||
swapChain.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -367,7 +368,7 @@ public class Engine {
|
||||
* @param view the {@link View} to destroy
|
||||
*/
|
||||
public void destroyView(@NonNull View view) {
|
||||
nDestroyView(getNativeObject(), view.getNativeObject());
|
||||
assertDestroy(nDestroyView(getNativeObject(), view.getNativeObject()));
|
||||
view.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -390,7 +391,7 @@ public class Engine {
|
||||
* @param renderer the {@link Renderer} to destroy
|
||||
*/
|
||||
public void destroyRenderer(@NonNull Renderer renderer) {
|
||||
nDestroyRenderer(getNativeObject(), renderer.getNativeObject());
|
||||
assertDestroy(nDestroyRenderer(getNativeObject(), renderer.getNativeObject()));
|
||||
renderer.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -423,6 +424,20 @@ public class Engine {
|
||||
return new Camera(nativeCamera);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Camera component of the given <code>entity</code>.
|
||||
*
|
||||
* @param entity An <code>entity</code>.
|
||||
* @return the Camera component for this entity or null if the entity doesn't have a Camera
|
||||
* component
|
||||
*/
|
||||
@Nullable
|
||||
public Camera getCameraComponent(@Entity int entity) {
|
||||
long nativeCamera = nGetCameraComponent(getNativeObject(), entity);
|
||||
if (nativeCamera == 0) return null;
|
||||
return new Camera(nativeCamera);
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Camera} component and frees all its associated resources.
|
||||
* @param camera the {@link Camera} to destroy
|
||||
@@ -451,7 +466,7 @@ public class Engine {
|
||||
* @param scene the {@link Scene} to destroy
|
||||
*/
|
||||
public void destroyScene(@NonNull Scene scene) {
|
||||
nDestroyScene(getNativeObject(), scene.getNativeObject());
|
||||
assertDestroy(nDestroyScene(getNativeObject(), scene.getNativeObject()));
|
||||
scene.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -462,7 +477,7 @@ public class Engine {
|
||||
* @param stream the {@link Stream} to destroy
|
||||
*/
|
||||
public void destroyStream(@NonNull Stream stream) {
|
||||
nDestroyStream(getNativeObject(), stream.getNativeObject());
|
||||
assertDestroy(nDestroyStream(getNativeObject(), stream.getNativeObject()));
|
||||
stream.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -485,7 +500,7 @@ public class Engine {
|
||||
* @param fence the {@link Fence} to destroy
|
||||
*/
|
||||
public void destroyFence(@NonNull Fence fence) {
|
||||
nDestroyFence(getNativeObject(), fence.getNativeObject());
|
||||
assertDestroy(nDestroyFence(getNativeObject(), fence.getNativeObject()));
|
||||
fence.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -496,7 +511,7 @@ public class Engine {
|
||||
* @param indexBuffer the {@link IndexBuffer} to destroy
|
||||
*/
|
||||
public void destroyIndexBuffer(@NonNull IndexBuffer indexBuffer) {
|
||||
nDestroyIndexBuffer(getNativeObject(), indexBuffer.getNativeObject());
|
||||
assertDestroy(nDestroyIndexBuffer(getNativeObject(), indexBuffer.getNativeObject()));
|
||||
indexBuffer.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -505,7 +520,7 @@ public class Engine {
|
||||
* @param vertexBuffer the {@link VertexBuffer} to destroy
|
||||
*/
|
||||
public void destroyVertexBuffer(@NonNull VertexBuffer vertexBuffer) {
|
||||
nDestroyVertexBuffer(getNativeObject(), vertexBuffer.getNativeObject());
|
||||
assertDestroy(nDestroyVertexBuffer(getNativeObject(), vertexBuffer.getNativeObject()));
|
||||
vertexBuffer.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -514,7 +529,7 @@ public class Engine {
|
||||
* @param ibl the {@link IndirectLight} to destroy
|
||||
*/
|
||||
public void destroyIndirectLight(@NonNull IndirectLight ibl) {
|
||||
nDestroyIndirectLight(getNativeObject(), ibl.getNativeObject());
|
||||
assertDestroy(nDestroyIndirectLight(getNativeObject(), ibl.getNativeObject()));
|
||||
ibl.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -527,7 +542,7 @@ public class Engine {
|
||||
* @param material the {@link Material} to destroy
|
||||
*/
|
||||
public void destroyMaterial(@NonNull Material material) {
|
||||
nDestroyMaterial(getNativeObject(), material.getNativeObject());
|
||||
assertDestroy(nDestroyMaterial(getNativeObject(), material.getNativeObject()));
|
||||
material.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -536,7 +551,7 @@ public class Engine {
|
||||
* @param materialInstance the {@link MaterialInstance} to destroy
|
||||
*/
|
||||
public void destroyMaterialInstance(@NonNull MaterialInstance materialInstance) {
|
||||
nDestroyMaterialInstance(getNativeObject(), materialInstance.getNativeObject());
|
||||
assertDestroy(nDestroyMaterialInstance(getNativeObject(), materialInstance.getNativeObject()));
|
||||
materialInstance.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -545,16 +560,25 @@ public class Engine {
|
||||
* @param skybox the {@link Skybox} to destroy
|
||||
*/
|
||||
public void destroySkybox(@NonNull Skybox skybox) {
|
||||
nDestroySkybox(getNativeObject(), skybox.getNativeObject());
|
||||
assertDestroy(nDestroySkybox(getNativeObject(), skybox.getNativeObject()));
|
||||
skybox.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link ColorGrading} and frees all its associated resources.
|
||||
* @param colorGrading the {@link ColorGrading} to destroy
|
||||
*/
|
||||
public void destroySkybox(@NonNull ColorGrading colorGrading) {
|
||||
assertDestroy(nDestroyColorGrading(getNativeObject(), colorGrading.getNativeObject()));
|
||||
colorGrading.clearNativeObject();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a {@link Texture} and frees all its associated resources.
|
||||
* @param texture the {@link Texture} to destroy
|
||||
*/
|
||||
public void destroyTexture(@NonNull Texture texture) {
|
||||
nDestroyTexture(getNativeObject(), texture.getNativeObject());
|
||||
assertDestroy(nDestroyTexture(getNativeObject(), texture.getNativeObject()));
|
||||
texture.clearNativeObject();
|
||||
}
|
||||
|
||||
@@ -634,33 +658,41 @@ public class Engine {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static void assertDestroy(boolean success) {
|
||||
if (!success) {
|
||||
throw new IllegalStateException("Object couldn't be destoyed (double destroy()?)");
|
||||
}
|
||||
}
|
||||
|
||||
private static native long nCreateEngine(long backend, long sharedContext);
|
||||
private static native void nDestroyEngine(long nativeEngine);
|
||||
private static native long nGetBackend(long nativeEngine);
|
||||
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 void nDestroySwapChain(long nativeEngine, long nativeSwapChain);
|
||||
private static native boolean nDestroySwapChain(long nativeEngine, long nativeSwapChain);
|
||||
private static native long nCreateView(long nativeEngine);
|
||||
private static native void nDestroyView(long nativeEngine, long nativeView);
|
||||
private static native boolean nDestroyView(long nativeEngine, long nativeView);
|
||||
private static native long nCreateRenderer(long nativeEngine);
|
||||
private static native void nDestroyRenderer(long nativeEngine, long nativeRenderer);
|
||||
private static native boolean nDestroyRenderer(long nativeEngine, long nativeRenderer);
|
||||
private static native long nCreateCamera(long nativeEngine);
|
||||
private static native long nCreateCameraWithEntity(long nativeEngine, int entity);
|
||||
private static native long nGetCameraComponent(long nativeEngine, int entity);
|
||||
private static native void nDestroyCamera(long nativeEngine, long nativeCamera);
|
||||
private static native long nCreateScene(long nativeEngine);
|
||||
private static native void nDestroyScene(long nativeEngine, long nativeScene);
|
||||
private static native boolean nDestroyScene(long nativeEngine, long nativeScene);
|
||||
private static native long nCreateFence(long nativeEngine);
|
||||
private static native void nDestroyFence(long nativeEngine, long nativeFence);
|
||||
private static native void nDestroyStream(long nativeEngine, long nativeStream);
|
||||
private static native void nDestroyIndexBuffer(long nativeEngine, long nativeIndexBuffer);
|
||||
private static native void nDestroyVertexBuffer(long nativeEngine, long nativeVertexBuffer);
|
||||
private static native void nDestroyIndirectLight(long nativeEngine, long nativeIndirectLight);
|
||||
private static native void nDestroyMaterial(long nativeEngine, long nativeMaterial);
|
||||
private static native void nDestroyMaterialInstance(long nativeEngine, long nativeMaterialInstance);
|
||||
private static native void nDestroySkybox(long nativeEngine, long nativeSkybox);
|
||||
private static native void nDestroyTexture(long nativeEngine, long nativeTexture);
|
||||
private static native void nDestroyRenderTarget(long nativeEngine, long nativeTarget);
|
||||
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);
|
||||
private static native boolean nDestroyVertexBuffer(long nativeEngine, long nativeVertexBuffer);
|
||||
private static native boolean nDestroyIndirectLight(long nativeEngine, long nativeIndirectLight);
|
||||
private static native boolean nDestroyMaterial(long nativeEngine, long nativeMaterial);
|
||||
private static native boolean nDestroyMaterialInstance(long nativeEngine, long nativeMaterialInstance);
|
||||
private static native boolean nDestroySkybox(long nativeEngine, long nativeSkybox);
|
||||
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 void nDestroyEntity(long nativeEngine, int entity);
|
||||
private static native void nFlushAndWait(long nativeEngine);
|
||||
private static native long nGetTransformManager(long nativeEngine);
|
||||
|
||||
@@ -86,7 +86,11 @@ import com.google.android.filament.proguard.UsedByReflection;
|
||||
public class IndirectLight {
|
||||
long mNativeObject;
|
||||
|
||||
public IndirectLight(long indirectLight) {
|
||||
public IndirectLight(Engine engine, long indirectLight) {
|
||||
mNativeObject = indirectLight;
|
||||
}
|
||||
|
||||
IndirectLight(long indirectLight) {
|
||||
mNativeObject = indirectLight;
|
||||
}
|
||||
|
||||
@@ -475,6 +479,18 @@ public class IndirectLight {
|
||||
return colorIntensity;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Texture getReflectionsTexture() {
|
||||
long nativeTexture = nGetReflectionsTexture(getNativeObject());
|
||||
return nativeTexture == 0 ? null : new Texture(nativeTexture);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Texture getIrradianceTexture() {
|
||||
long nativeTexture = nGetIrradianceTexture(getNativeObject());
|
||||
return nativeTexture == 0 ? null : new Texture(nativeTexture);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed IndirectLight");
|
||||
@@ -504,6 +520,9 @@ public class IndirectLight {
|
||||
private static native void nGetDirectionEstimate(long nativeIndirectLight, float[] outDirection);
|
||||
private static native void nGetColorEstimate(long nativeIndirectLight, float[] outColor, float x, float y, float z);
|
||||
|
||||
private static native long nGetReflectionsTexture(long nativeIndirectLight);
|
||||
private static native long nGetIrradianceTexture(long nativeIndirectLight);
|
||||
|
||||
private static native void nGetDirectionEstimateStatic(float[] sh, float[] direction);
|
||||
private static native void nGetColorEstimateStatic(float[] colorIntensity, float[] sh, float x, float y, float z);
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -230,8 +230,10 @@ public class Material {
|
||||
MAT3,
|
||||
MAT4,
|
||||
SAMPLER_2D,
|
||||
SAMPLER_2D_ARRAY,
|
||||
SAMPLER_CUBEMAP,
|
||||
SAMPLER_EXTERNAL
|
||||
SAMPLER_EXTERNAL,
|
||||
SAMPLER_3D
|
||||
}
|
||||
|
||||
public enum Precision {
|
||||
@@ -326,6 +328,21 @@ public class Material {
|
||||
return new MaterialInstance(this, nativeInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance of this material with a specified name. Material instances should be
|
||||
* freed using {@link Engine#destroyMaterialInstance(MaterialInstance)}.
|
||||
*
|
||||
* @param name arbitrary label to associate with the given material instance
|
||||
*
|
||||
* @return the new instance
|
||||
*/
|
||||
@NonNull
|
||||
public MaterialInstance createInstance(@NonNull String name) {
|
||||
long nativeInstance = nCreateInstanceWithName(getNativeObject(), name);
|
||||
if (nativeInstance == 0) throw new IllegalStateException("Couldn't create MaterialInstance");
|
||||
return new MaterialInstance(this, nativeInstance);
|
||||
}
|
||||
|
||||
/** Returns the material's default instance. */
|
||||
@NonNull
|
||||
public MaterialInstance getDefaultInstance() {
|
||||
@@ -422,7 +439,7 @@ public class Material {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this material will write to the color buffer.
|
||||
* Indicates whether instances of this material will, by default, write to the color buffer.
|
||||
*
|
||||
* @see
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:colorwrite">
|
||||
@@ -433,7 +450,7 @@ public class Material {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this material will write to the depth buffer.
|
||||
* Indicates whether instances of this material will, by default, write to the depth buffer.
|
||||
*
|
||||
* @see
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:depthwrite">
|
||||
@@ -444,7 +461,7 @@ public class Material {
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether this material will use depth testing.
|
||||
* Indicates whether instances of this material will, by default, use depth testing.
|
||||
*
|
||||
* @see
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:depthculling">
|
||||
@@ -879,6 +896,7 @@ public class Material {
|
||||
|
||||
private static native long nBuilderBuild(long nativeEngine, @NonNull Buffer buffer, int size);
|
||||
private static native long nCreateInstance(long nativeMaterial);
|
||||
private static native long nCreateInstanceWithName(long nativeMaterial, @NonNull String name);
|
||||
private static native long nGetDefaultInstance(long nativeMaterial);
|
||||
|
||||
private static native String nGetName(long nativeMaterial);
|
||||
|
||||
@@ -22,6 +22,7 @@ import androidx.annotation.Size;
|
||||
|
||||
public class MaterialInstance {
|
||||
private Material mMaterial;
|
||||
private String mName;
|
||||
private long mNativeObject;
|
||||
private long mNativeMaterial;
|
||||
|
||||
@@ -48,14 +49,19 @@ public class MaterialInstance {
|
||||
MAT4
|
||||
}
|
||||
|
||||
public MaterialInstance(Engine engine, long nativeMaterialInstance) {
|
||||
mNativeObject = nativeMaterialInstance;
|
||||
mNativeMaterial = nGetMaterial(mNativeObject);
|
||||
}
|
||||
|
||||
MaterialInstance(@NonNull Material material, long nativeMaterialInstance) {
|
||||
mMaterial = material;
|
||||
mNativeObject = nativeMaterialInstance;
|
||||
}
|
||||
|
||||
MaterialInstance(long nativeMaterial, long nativeMaterialInstance) {
|
||||
mNativeMaterial = nativeMaterial;
|
||||
MaterialInstance(long nativeMaterialInstance) {
|
||||
mNativeObject = nativeMaterialInstance;
|
||||
mNativeMaterial = nGetMaterial(mNativeObject);
|
||||
}
|
||||
|
||||
/** @return the {@link Material} associated with this instance */
|
||||
@@ -67,6 +73,15 @@ public class MaterialInstance {
|
||||
return mMaterial;
|
||||
}
|
||||
|
||||
/** @return the name associated with this instance */
|
||||
@NonNull
|
||||
public String getName() {
|
||||
if (mName == null) {
|
||||
mName = nGetName(getNativeObject());
|
||||
}
|
||||
return mName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the value of a bool parameter.
|
||||
*
|
||||
@@ -430,6 +445,39 @@ public class MaterialInstance {
|
||||
nSetCullingMode(getNativeObject(), mode.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default color-buffer write state that was set on the material.
|
||||
*
|
||||
* @see
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:colorWrite">
|
||||
* Rasterization: colorWrite</a>
|
||||
*/
|
||||
void setColorWrite(boolean enable) {
|
||||
nSetColorWrite(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default depth-buffer write state that was set on the material.
|
||||
*
|
||||
* @see
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:depthWrite">
|
||||
* Rasterization: depthWrite</a>
|
||||
*/
|
||||
void setDepthWrite(boolean enable) {
|
||||
nSetDepthWrite(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides the default depth testing state that was set on the material.
|
||||
*
|
||||
* @see
|
||||
* <a href="https://google.github.io/filament/Materials.html#materialdefinitions/materialblock/rasterization:depthCulling">
|
||||
* Rasterization: depthCulling</a>
|
||||
*/
|
||||
void setDepthCulling(boolean enable) {
|
||||
nSetDepthCulling(getNativeObject(), enable);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed MaterialInstance");
|
||||
@@ -499,6 +547,11 @@ public class MaterialInstance {
|
||||
float threshold);
|
||||
|
||||
private static native void nSetDoubleSided(long nativeMaterialInstance, boolean doubleSided);
|
||||
|
||||
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 nSetDepthCulling(long nativeMaterialInstance, boolean enable);
|
||||
|
||||
private static native String nGetName(long nativeMaterialInstance);
|
||||
private static native long nGetMaterial(long nativeMaterialInstance);
|
||||
}
|
||||
|
||||
@@ -206,11 +206,11 @@ public class RenderTarget {
|
||||
}
|
||||
|
||||
private static native long nCreateBuilder();
|
||||
private static native long nDestroyBuilder(long nativeBuilder);
|
||||
private static native long nBuilderTexture(long nativeBuilder, int attachment, long nativeTexture);
|
||||
private static native long nBuilderMipLevel(long nativeBuilder, int attachment, int level);
|
||||
private static native long nBuilderFace(long nativeBuilder, int attachment, int face);
|
||||
private static native long nBuilderLayer(long nativeBuilder, int attachment, int layer);
|
||||
private static native void nDestroyBuilder(long nativeBuilder);
|
||||
private static native void nBuilderTexture(long nativeBuilder, int attachment, long nativeTexture);
|
||||
private static native void nBuilderMipLevel(long nativeBuilder, int attachment, int level);
|
||||
private static native void nBuilderFace(long nativeBuilder, int attachment, int face);
|
||||
private static native void nBuilderLayer(long nativeBuilder, int attachment, int layer);
|
||||
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
|
||||
|
||||
private static native int nGetMipLevel(long nativeRenderTarget, int attachment);
|
||||
|
||||
@@ -284,6 +284,17 @@ public class RenderableManager {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if this renderable uses screen-space contact shadows. This is more
|
||||
* expensive but can improve the quality of shadows, especially in large scenes.
|
||||
* (off by default).
|
||||
*/
|
||||
@NonNull
|
||||
public Builder screenSpaceContactShadows(boolean enabled) {
|
||||
nBuilderScreenSpaceContactShadows(mNativeBuilder, enabled);
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder skinning(@IntRange(from = 0, to = 255) int boneCount) {
|
||||
nBuilderSkinning(mNativeBuilder, boneCount);
|
||||
@@ -442,6 +453,15 @@ public class RenderableManager {
|
||||
nSetPriority(mNativeObject, i, priority);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes whether or not frustum culling is on.
|
||||
*
|
||||
* @see Builder#culling
|
||||
*/
|
||||
public void setCulling(@EntityInstance int i, boolean enabled) {
|
||||
nSetCulling(mNativeObject, i, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes whether or not the renderable casts shadows.
|
||||
*
|
||||
@@ -460,6 +480,16 @@ public class RenderableManager {
|
||||
nSetReceiveShadows(mNativeObject, i, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes whether or not the renderable can use screen-space contact shadows.
|
||||
|
||||
*
|
||||
* @see Builder#screenSpaceContactShadows
|
||||
*/
|
||||
public void setScreenSpaceContactShadows(@EntityInstance int i, boolean enabled) {
|
||||
nSetScreenSpaceContactShadows(mNativeObject, i, enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the renderable can cast shadows.
|
||||
*
|
||||
@@ -523,8 +553,7 @@ public class RenderableManager {
|
||||
public @NonNull MaterialInstance getMaterialInstanceAt(@EntityInstance int i,
|
||||
@IntRange(from = 0) int primitiveIndex) {
|
||||
long nativeMatInstance = nGetMaterialInstanceAt(mNativeObject, i, primitiveIndex);
|
||||
long nativeMaterial = nGetMaterialAt(mNativeObject, i, primitiveIndex);
|
||||
return new MaterialInstance(nativeMaterial, nativeMatInstance);
|
||||
return new MaterialInstance(nativeMatInstance);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -614,6 +643,7 @@ public class RenderableManager {
|
||||
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);
|
||||
private static native void nBuilderScreenSpaceContactShadows(long nativeBuilder, boolean enabled);
|
||||
private static native void nBuilderSkinning(long nativeBuilder, int boneCount);
|
||||
private static native int nBuilderSkinningBones(long nativeBuilder, int boneCount, Buffer bones, int remaining);
|
||||
private static native void nBuilderMorphing(long nativeBuilder, boolean enabled);
|
||||
@@ -624,8 +654,10 @@ public class RenderableManager {
|
||||
private static native void nSetAxisAlignedBoundingBox(long nativeRenderableManager, int i, float cx, float cy, float cz, float ex, float ey, float ez);
|
||||
private static native void nSetLayerMask(long nativeRenderableManager, int i, int select, int value);
|
||||
private static native void nSetPriority(long nativeRenderableManager, int i, int priority);
|
||||
private static native void nSetCulling(long nativeRenderableManager, int i, boolean enabled);
|
||||
private static native void nSetCastShadows(long nativeRenderableManager, int i, boolean enabled);
|
||||
private static native void nSetReceiveShadows(long nativeRenderableManager, int i, boolean enabled);
|
||||
private static native void nSetScreenSpaceContactShadows(long nativeRenderableManager, int i, boolean enabled);
|
||||
private static native boolean nIsShadowCaster(long nativeRenderableManager, int i);
|
||||
private static native boolean nIsShadowReceiver(long nativeRenderableManager, int i);
|
||||
private static native void nGetAxisAlignedBoundingBox(long nativeRenderableManager, int i, float[] center, float[] halfExtent);
|
||||
|
||||
@@ -44,6 +44,100 @@ import java.nio.ReadOnlyBufferException;
|
||||
public class Renderer {
|
||||
private final Engine mEngine;
|
||||
private long mNativeObject;
|
||||
private DisplayInfo mDisplayInfo;
|
||||
private FrameRateOptions mFrameRateOptions;
|
||||
private ClearOptions mClearOptions;
|
||||
|
||||
/**
|
||||
* Information about the display this renderer is associated to
|
||||
*/
|
||||
public static class DisplayInfo {
|
||||
/**
|
||||
* Refresh rate of the display in Hz. Set to 0 for offscreen or turn off frame-pacing.
|
||||
* On Android you can use {@link android.view.Display#getRefreshRate()}.
|
||||
*/
|
||||
public float refreshRate = 60.0f;
|
||||
|
||||
/**
|
||||
* How far in advance a buffer must be queued for presentation at a given time in ns
|
||||
* On Android you can use {@link android.view.Display#getPresentationDeadlineNanos()}.
|
||||
*/
|
||||
public long presentationDeadlineNanos = 0;
|
||||
|
||||
/**
|
||||
* Offset by which vsyncSteadyClockTimeNano provided in beginFrame() is offset in ns
|
||||
* On Android you can use {@link android.view.Display#getAppVsyncOffsetNanos()}.
|
||||
*/
|
||||
public long vsyncOffsetNanos = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* Use FrameRateOptions to set the desired frame rate and control how quickly the system
|
||||
* reacts to GPU load changes.
|
||||
*
|
||||
* interval: desired frame interval in multiple of the refresh period, set in DisplayInfo
|
||||
* (as 1 / DisplayInfo.refreshRate)
|
||||
*
|
||||
* The parameters below are relevant when some Views are using dynamic resolution scaling:
|
||||
*
|
||||
* headRoomRatio: additional headroom for the GPU as a ratio of the targetFrameTime.
|
||||
* Useful for taking into account constant costs like post-processing or
|
||||
* GPU drivers on different platforms.
|
||||
* history: History size. higher values, tend to filter more (clamped to 30)
|
||||
* scaleRate: rate at which the gpu load is adjusted to reach the target frame rate
|
||||
* This value can be computed as 1 / N, where N is the number of frames
|
||||
* needed to reach 64% of the target scale factor.
|
||||
* Higher values make the dynamic resolution react faster.
|
||||
*
|
||||
* @see View.DynamicResolutionOptions
|
||||
* @see Renderer.DisplayInfo
|
||||
*
|
||||
*/
|
||||
public static class FrameRateOptions {
|
||||
/**
|
||||
* Desired frame interval in unit of 1 / DisplayInfo.refreshRate.
|
||||
*/
|
||||
public float interval = 1.0f / 60.0f;
|
||||
|
||||
/**
|
||||
* Additional headroom for the GPU as a ratio of the targetFrameTime.
|
||||
*/
|
||||
public float headRoomRatio = 0.0f;
|
||||
|
||||
/**
|
||||
* Rate at which the scale will change to reach the target frame rate.
|
||||
*/
|
||||
public float scaleRate = 0.125f;
|
||||
|
||||
/**
|
||||
* History size. higher values, tend to filter more (clamped to 30).
|
||||
*/
|
||||
public int history = 9;
|
||||
}
|
||||
|
||||
/**
|
||||
* ClearOptions are used at the beginning of a frame to clear or retain the SwapChain content.
|
||||
*/
|
||||
public static class ClearOptions {
|
||||
/**
|
||||
* Color to use to clear the SwapChain
|
||||
*/
|
||||
@NonNull
|
||||
public float[] clearColor = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
|
||||
/**
|
||||
* Whether the SwapChain should be cleared using the clearColor. Use this if translucent
|
||||
* View will be drawn, for instance.
|
||||
*/
|
||||
public boolean clear = false;
|
||||
|
||||
/**
|
||||
* Whether the SwapChain content should be discarded. clear implies discard. Set this
|
||||
* to false (along with clear to false as well) if the SwapChain already has content that
|
||||
* needs to be preserved
|
||||
*/
|
||||
public boolean discard = true;
|
||||
};
|
||||
|
||||
/**
|
||||
* Indicates that the <code>dstSwapChain</code> passed into {@link #copyFrame} should be
|
||||
@@ -75,6 +169,74 @@ public class Renderer {
|
||||
mNativeObject = nativeRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Information about the display this Renderer is associated to. This information is needed
|
||||
* to accurately compute dynamic-resolution scaling and for frame-pacing.
|
||||
*/
|
||||
public void setDisplayInfo(@NonNull DisplayInfo info) {
|
||||
mDisplayInfo = info;
|
||||
nSetDisplayInfo(getNativeObject(),
|
||||
info.refreshRate, info.presentationDeadlineNanos, info.vsyncOffsetNanos);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the DisplayInfo object set in {@link #setDisplayInfo} or a new instance otherwise.
|
||||
* @return a DisplayInfo instance
|
||||
*/
|
||||
@NonNull
|
||||
public DisplayInfo getDisplayInfo() {
|
||||
if (mDisplayInfo == null) {
|
||||
mDisplayInfo = new DisplayInfo();
|
||||
}
|
||||
return mDisplayInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set options controlling the desired frame-rate.
|
||||
*/
|
||||
public void setFrameRateOptions(@NonNull FrameRateOptions options) {
|
||||
mFrameRateOptions = options;
|
||||
nSetFrameRateOptions(getNativeObject(),
|
||||
options.interval, options.headRoomRatio, options.scaleRate, options.history);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the FrameRateOptions object set in {@link #setFrameRateOptions} or a new instance
|
||||
* otherwise.
|
||||
* @return a FrameRateOptions instance
|
||||
*/
|
||||
@NonNull
|
||||
public FrameRateOptions getFrameRateOptions() {
|
||||
if (mFrameRateOptions == null) {
|
||||
mFrameRateOptions = new FrameRateOptions();
|
||||
}
|
||||
return mFrameRateOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set ClearOptions which are used at the beginning of a frame to clear or retain the
|
||||
* SwapChain content.
|
||||
*/
|
||||
public void setClearOptions(@NonNull ClearOptions options) {
|
||||
mClearOptions = options;
|
||||
nSetClearOptions(getNativeObject(),
|
||||
options.clearColor[0], options.clearColor[1], options.clearColor[2], options.clearColor[3],
|
||||
options.clear, options.discard);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ClearOptions object set in {@link #setClearOptions} or a new instance
|
||||
* otherwise.
|
||||
* @return a ClearOptions instance
|
||||
*/
|
||||
@NonNull
|
||||
public ClearOptions getClearOptions() {
|
||||
if (mClearOptions == null) {
|
||||
mClearOptions = new ClearOptions();
|
||||
}
|
||||
return mClearOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link Engine} that created this <code>Renderer</code>.
|
||||
*
|
||||
@@ -100,16 +262,24 @@ public class Renderer {
|
||||
* <p>All calls to render() must happen <b>after</b> beginFrame().</p>
|
||||
*
|
||||
* @param swapChain the {@link SwapChain} instance to use
|
||||
* @param frameTimeNanos The time in nanoseconds when the frame started being rendered,
|
||||
* in the {@link System#nanoTime()} timebase. Divide this value by 1000000 to
|
||||
* convert it to the {@link android.os.SystemClock#uptimeMillis()}
|
||||
* time base. This typically comes from
|
||||
* {@link android.view.Choreographer.FrameCallback}.
|
||||
*
|
||||
* @return <code>false</code> if the current frame must be skipped<br>
|
||||
* When skipping a frame, the whole frame is canceled, and {@link #endFrame} must not
|
||||
* be called.
|
||||
* @return <code>true</code>: the current frame must be drawn, and {@link #endFrame} must be called<br>
|
||||
* <code>false</code>: the current frame should be skipped, when skipping a frame,
|
||||
* the whole frame is canceled, and {@link #endFrame} must not
|
||||
* be called. However, the user can choose to proceed as though <code>true</code> was
|
||||
* returned and produce a frame anyways, by making calls to {@link #render(View)},
|
||||
* in which case {@link #endFrame} must be called.
|
||||
*
|
||||
* @see #endFrame
|
||||
* @see #render
|
||||
*/
|
||||
public boolean beginFrame(@NonNull SwapChain swapChain) {
|
||||
return nBeginFrame(getNativeObject(), swapChain.getNativeObject());
|
||||
public boolean beginFrame(@NonNull SwapChain swapChain, long frameTimeNanos) {
|
||||
return nBeginFrame(getNativeObject(), swapChain.getNativeObject(), frameTimeNanos);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -462,7 +632,7 @@ public class Renderer {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native boolean nBeginFrame(long nativeRenderer, long nativeSwapChain);
|
||||
private static native boolean nBeginFrame(long nativeRenderer, long nativeSwapChain, long frameTimeNanos);
|
||||
private static native void nEndFrame(long nativeRenderer);
|
||||
private static native void nRender(long nativeRenderer, long nativeView);
|
||||
private static native void nCopyFrame(long nativeRenderer, long nativeDstSwapChain,
|
||||
@@ -482,4 +652,10 @@ public class Renderer {
|
||||
Object handler, Runnable callback);
|
||||
private static native double nGetUserTime(long nativeRenderer);
|
||||
private static native void nResetUserTime(long nativeRenderer);
|
||||
private static native void nSetDisplayInfo(long nativeRenderer,
|
||||
float refreshRate, long presentationDeadlineNanos, long vsyncOffsetNanos);
|
||||
private static native void nSetFrameRateOptions(long nativeRenderer,
|
||||
float interval, float headRoomRatio, float scaleRate, int history);
|
||||
private static native void nSetClearOptions(long nativeRenderer,
|
||||
float r, float g, float b, float a, boolean clear, boolean discard);
|
||||
}
|
||||
|
||||
@@ -132,6 +132,18 @@ public class Scene {
|
||||
removeEntity(entity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a list of entities from the <code>Scene</code>.
|
||||
*
|
||||
* This is equivalent to calling remove in a loop.
|
||||
* If any of the specified entities do not exist in the scene, they are skipped.
|
||||
*
|
||||
* @param entities array containing entities to remove from the <code>Scene</code>.
|
||||
*/
|
||||
public void removeEntities(@Entity int[] entities) {
|
||||
nRemoveEntities(getNativeObject(), entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of {@link RenderableManager} components in the <code>Scene</code>.
|
||||
*
|
||||
@@ -166,6 +178,7 @@ public class Scene {
|
||||
private static native void nAddEntity(long nativeScene, int entity);
|
||||
private static native void nAddEntities(long nativeScene, int[] entities);
|
||||
private static native void nRemove(long nativeScene, int entity);
|
||||
private static native void nRemoveEntities(long nativeScene, int[] entities);
|
||||
private static native int nGetRenderableCount(long nativeScene);
|
||||
private static native int nGetLightCount(long nativeScene);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ package com.google.android.filament;
|
||||
|
||||
import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.Size;
|
||||
|
||||
import static com.google.android.filament.Colors.LinearColor;
|
||||
|
||||
import com.google.android.filament.proguard.UsedByReflection;
|
||||
|
||||
@@ -49,10 +53,13 @@ import com.google.android.filament.proguard.UsedByReflection;
|
||||
public class Skybox {
|
||||
private long mNativeObject;
|
||||
|
||||
public Skybox(long nativeSkybox) {
|
||||
public Skybox(Engine engine, long nativeSkybox) {
|
||||
mNativeObject = nativeSkybox;
|
||||
}
|
||||
|
||||
Skybox(long nativeSkybox) {
|
||||
mNativeObject = nativeSkybox;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use <code>Builder</code> to construct a <code>Skybox</code> object instance.
|
||||
@@ -126,6 +133,33 @@ public class Skybox {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>Skybox</code> to a constant color. Default is opaque black.
|
||||
*
|
||||
* Ignored if an environment is set.
|
||||
*
|
||||
* @return This Builder, for chaining calls.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder color(@LinearColor float r, @LinearColor float g, @LinearColor float b, float a) {
|
||||
nBuilderColor(mNativeBuilder, r, g, b, a);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the <code>Skybox</code> to a constant color. Default is opaque black.
|
||||
*
|
||||
* Ignored if an environment is set.
|
||||
*
|
||||
* @param color an array of 4 floats
|
||||
* @return This Builder, for chaining calls.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder color(@NonNull @Size(min = 4) float[] color) {
|
||||
nBuilderColor(mNativeBuilder, color[0], color[1], color[2], color[3]);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a <code>Skybox</code> object
|
||||
*
|
||||
@@ -159,6 +193,25 @@ public class Skybox {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates the <code>Skybox</code>'s constant color.
|
||||
*
|
||||
* Ignored if an environment is set.
|
||||
*/
|
||||
public void setColor(@LinearColor float r, @LinearColor float g, @LinearColor float b, float a) {
|
||||
nSetColor(getNativeObject(), r, g, b, a);
|
||||
}
|
||||
|
||||
/**
|
||||
* Mutates the <code>Skybox</code>'s constant color.
|
||||
* Ignored if an environment is set.
|
||||
*
|
||||
* @param color an array of 4 floats
|
||||
*/
|
||||
public void setColor(@NonNull @Size(min = 4) float[] color) {
|
||||
nSetColor(getNativeObject(), color[0], color[1], color[2], color[3]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bits in a visibility mask. By default, this is <code>0x1</code>.
|
||||
* <p>This provides a simple mechanism for hiding or showing this <code>Skybox</code> in a
|
||||
@@ -188,6 +241,15 @@ public class Skybox {
|
||||
*/
|
||||
public float getIntensity() { return nGetIntensity(getNativeObject()); }
|
||||
|
||||
/**
|
||||
* @return the associated texture, or null if it does not exist
|
||||
*/
|
||||
@Nullable
|
||||
public Texture getTexture() {
|
||||
long nativeTexture = nGetTexture(getNativeObject());
|
||||
return nativeTexture == 0 ? null : new Texture(nativeTexture);
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed Skybox");
|
||||
@@ -204,8 +266,11 @@ public class Skybox {
|
||||
private static native void nBuilderEnvironment(long nativeSkyboxBuilder, long nativeTexture);
|
||||
private static native void nBuilderShowSun(long nativeSkyboxBuilder, boolean show);
|
||||
private static native void nBuilderIntensity(long nativeSkyboxBuilder, float intensity);
|
||||
private static native void nBuilderColor(long nativeSkyboxBuilder, float r, float g, float b, float a);
|
||||
private static native long nBuilderBuild(long nativeSkyboxBuilder, long nativeEngine);
|
||||
private static native void nSetLayerMask(long nativeSkybox, int select, int value);
|
||||
private static native int nGetLayerMask(long nativeSkybox);
|
||||
private static native float nGetIntensity(long nativeSkybox);
|
||||
private static native void nSetColor(long nativeSkybox, float r, float g, float b, float a);
|
||||
private static native long nGetTexture(long nativeSkybox);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,225 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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;
|
||||
|
||||
import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* Helper used to populate <code>TANGENTS</code> buffers.
|
||||
*/
|
||||
public class SurfaceOrientation {
|
||||
private long mNativeObject;
|
||||
|
||||
private SurfaceOrientation(long nativeSurfaceOrientation) {
|
||||
mNativeObject = nativeSurfaceOrientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs an immutable surface orientation helper.
|
||||
*
|
||||
* At a minimum, clients must supply a vertex count.
|
||||
* They can supply data in any of the following combinations:
|
||||
*
|
||||
* <ol>
|
||||
* <li>normals only (not recommended)</li>
|
||||
* <li>normals + tangents (sign of W determines bitangent orientation)</li>
|
||||
* <li>normals + uvs + positions + indices</li>
|
||||
* <li>positions + indices</li>
|
||||
* </ol>
|
||||
*
|
||||
* Additionally, the client-side data has the following type constraints:
|
||||
*
|
||||
* <ol>
|
||||
* <li>Normals must be float3</li>
|
||||
* <li>Tangents must be float4</li>
|
||||
* <li>UVs must be float2</li>
|
||||
* <li>Positions must be float3</li>
|
||||
* <li>Triangles must be uint3 or ushort3</li>
|
||||
* </ol>
|
||||
*/
|
||||
public static class Builder {
|
||||
private int mVertexCount;
|
||||
private int mTriangleCount;
|
||||
|
||||
private Buffer mNormals;
|
||||
private int mNormalsStride;
|
||||
|
||||
private Buffer mTangents;
|
||||
private int mTangentsStride;
|
||||
|
||||
private Buffer mTexCoords;
|
||||
private int mTexCoordsStride;
|
||||
|
||||
private Buffer mPositions;
|
||||
private int mPositionsStride;
|
||||
|
||||
private Buffer mTrianglesUint16;
|
||||
private Buffer mTrianglesUint32;
|
||||
|
||||
@NonNull
|
||||
public Builder vertexCount(@IntRange(from = 1) int vertexCount) {
|
||||
mVertexCount = vertexCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder normals(@NonNull Buffer buffer) {
|
||||
mNormals = buffer;
|
||||
mNormalsStride = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder tangents(@NonNull Buffer buffer) {
|
||||
mTangents = buffer;
|
||||
mTangentsStride = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder uvs(@NonNull Buffer buffer) {
|
||||
mTexCoords = buffer;
|
||||
mTexCoordsStride = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder positions(@NonNull Buffer buffer) {
|
||||
mPositions = buffer;
|
||||
mPositionsStride = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder triangleCount(int triangleCount) {
|
||||
mTriangleCount = triangleCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder triangles_uint16(@NonNull Buffer buffer) {
|
||||
mTrianglesUint16 = buffer;
|
||||
return this;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Builder triangles_uint32(@NonNull Buffer buffer) {
|
||||
mTrianglesUint32 = buffer;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes the input data, produces quaternions, and destroys the native builder.
|
||||
*/
|
||||
@NonNull
|
||||
public SurfaceOrientation build() {
|
||||
|
||||
// The C++ Builder API specifies that the pointers are consumed during build(), not
|
||||
// during the individual daisy-chain methods. Therefore we need to retain the Java
|
||||
// buffers until this point in the code.
|
||||
|
||||
long builder = nCreateBuilder();
|
||||
nBuilderVertexCount(builder, mVertexCount);
|
||||
nBuilderTriangleCount(builder, mTriangleCount);
|
||||
|
||||
if (mNormals != null) {
|
||||
nBuilderNormals(builder, mNormals, mNormals.remaining(), mNormalsStride);
|
||||
}
|
||||
|
||||
if (mTangents != null) {
|
||||
nBuilderTangents(builder, mTangents, mTangents.remaining(), mTangentsStride);
|
||||
}
|
||||
|
||||
if (mTexCoords != null) {
|
||||
nBuilderUVs(builder, mTexCoords, mTexCoords.remaining(), mTexCoordsStride);
|
||||
}
|
||||
|
||||
if (mPositions != null) {
|
||||
nBuilderPositions(builder, mPositions, mPositions.remaining(), mPositionsStride);
|
||||
}
|
||||
|
||||
if (mTrianglesUint16 != null) {
|
||||
nBuilderTriangles16(builder, mTrianglesUint16, mTrianglesUint16.remaining());
|
||||
}
|
||||
|
||||
if (mTrianglesUint32 != null) {
|
||||
nBuilderTriangles32(builder, mTrianglesUint32, mTrianglesUint32.remaining());
|
||||
}
|
||||
|
||||
long nativeSurfaceOrientation = nBuilderBuild(builder);
|
||||
nDestroyBuilder(builder);
|
||||
if (nativeSurfaceOrientation == 0) {
|
||||
throw new IllegalStateException("Could not create SurfaceOrientation");
|
||||
}
|
||||
return new SurfaceOrientation(nativeSurfaceOrientation);
|
||||
}
|
||||
}
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed SurfaceOrientation");
|
||||
}
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
@IntRange(from = 0)
|
||||
public int getVertexCount() {
|
||||
return nGetVertexCount(mNativeObject);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public void getQuatsAsFloat(@NonNull Buffer buffer) {
|
||||
nGetQuatsAsFloat(mNativeObject, buffer, buffer.remaining());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public void getQuatsAsHalf(@NonNull Buffer buffer) {
|
||||
nGetQuatsAsHalf(mNativeObject, buffer, buffer.remaining());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public void getQuatsAsShort(@NonNull Buffer buffer) {
|
||||
nGetQuatsAsShort(mNativeObject, buffer, buffer.remaining());
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
nDestroy(mNativeObject);
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native long nCreateBuilder();
|
||||
private static native void nDestroyBuilder(long nativeBuilder);
|
||||
|
||||
private static native void nBuilderVertexCount(long nativeBuilder, int vertexCount);
|
||||
private static native void nBuilderNormals(long nativeBuilder, Buffer buffer, int remaining, int stride);
|
||||
private static native void nBuilderTangents(long nativeBuilder, Buffer buffer, int remaining, int stride);
|
||||
private static native void nBuilderUVs(long nativeBuilder, Buffer buffer, int remaining, int stride);
|
||||
private static native void nBuilderPositions(long nativeBuilder, Buffer buffer, int remaining, int stride);
|
||||
private static native void nBuilderTriangleCount(long nativeBuilder, int triangleCount);
|
||||
private static native void nBuilderTriangles16(long nativeBuilder, Buffer buffer, int remaining);
|
||||
private static native void nBuilderTriangles32(long nativeBuilder, Buffer buffer, int remaining);
|
||||
private static native long nBuilderBuild(long nativeBuilder);
|
||||
|
||||
private static native int nGetVertexCount(long nativeSurfaceOrientation);
|
||||
private static native void nGetQuatsAsFloat(long nativeSurfaceOrientation, Buffer buffer, int remaining);
|
||||
private static native void nGetQuatsAsHalf(long nativeSurfaceOrientation, Buffer buffer, int remaining);
|
||||
private static native void nGetQuatsAsShort(long nativeSurfaceOrientation, Buffer buffer, int remaining);
|
||||
private static native void nDestroy(long nativeSurfaceOrientation);
|
||||
}
|
||||
@@ -73,7 +73,11 @@ import static com.google.android.filament.Texture.Type.COMPRESSED;
|
||||
public class Texture {
|
||||
private long mNativeObject;
|
||||
|
||||
public Texture(long nativeTexture) {
|
||||
Texture(long nativeTexture) {
|
||||
mNativeObject = nativeTexture;
|
||||
}
|
||||
|
||||
public Texture(Engine engine, long nativeTexture) {
|
||||
mNativeObject = nativeTexture;
|
||||
}
|
||||
|
||||
@@ -83,10 +87,14 @@ public class Texture {
|
||||
public enum Sampler {
|
||||
/** 2D sampler */
|
||||
SAMPLER_2D,
|
||||
/** 2D array sampler */
|
||||
SAMPLER_2D_ARRAY,
|
||||
/** Cubemap sampler */
|
||||
SAMPLER_CUBEMAP,
|
||||
/** External texture sampler */
|
||||
SAMPLER_EXTERNAL
|
||||
SAMPLER_EXTERNAL,
|
||||
/** 3D sampler */
|
||||
SAMPLER_3D,
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -271,26 +279,40 @@ public class Texture {
|
||||
* Pixel data type
|
||||
*/
|
||||
public enum Type {
|
||||
/** unsigned byte, 8-bits */
|
||||
/** unsigned byte, 8-bit */
|
||||
UBYTE,
|
||||
/** signed byte, 8-bits */
|
||||
/** signed byte, 8-bit */
|
||||
BYTE,
|
||||
/** unsigned short, 16-bits */
|
||||
/** unsigned short, 16-bits*/
|
||||
USHORT,
|
||||
/** signed short, 16-bits */
|
||||
/** signed short, 16-bit */
|
||||
SHORT,
|
||||
/** unsigned int, 32-bits */
|
||||
/** unsigned int, 32-bit */
|
||||
UINT,
|
||||
/** signed int, 32-bits */
|
||||
/** signed int, 32-bit */
|
||||
INT,
|
||||
/** half-float, 16-bits float with 10 bits mantissa */
|
||||
/** half-float, 16-bit float with 10 bits mantissa */
|
||||
HALF,
|
||||
/** float, 32-bits float, with 24 bits mantissa */
|
||||
/** float, 32-bit float, with 24 bits mantissa */
|
||||
FLOAT,
|
||||
/** a compessed type */
|
||||
/** a compressed type */
|
||||
COMPRESSED,
|
||||
/** unsigned 5.6 (5.5 for blue) float packed in 32-bits */
|
||||
UINT_10F_11F_11F_REV
|
||||
/** unsigned 5.6 (5.5 for blue) float packed in a 32-bit integer. */
|
||||
UINT_10F_11F_11F_REV,
|
||||
/** unsigned 5/6 bit integers packed in a 16-bit short. */
|
||||
USHORT_565,
|
||||
}
|
||||
|
||||
/**
|
||||
* Texture swizzling channels
|
||||
*/
|
||||
public enum Swizzle {
|
||||
SUBSTITUTE_ZERO, //!< specified component is substituted with 0
|
||||
SUBSTITUTE_ONE, //!< specified component is substituted with 1
|
||||
CHANNEL_0, //!< specified component taken from channel 0
|
||||
CHANNEL_1, //!< specified component taken from channel 1
|
||||
CHANNEL_2, //!< specified component taken from channel 2
|
||||
CHANNEL_3 //!< specified component taken from channel 3
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -341,7 +363,6 @@ public class Texture {
|
||||
*/
|
||||
@Nullable public Runnable callback;
|
||||
|
||||
|
||||
/**
|
||||
* Creates a <code>PixelBufferDescriptor</code>
|
||||
*
|
||||
@@ -581,8 +602,12 @@ public class Texture {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the texture's number of layers. This creates a 3D texture.
|
||||
* @param depth texture number of layer, must be at least 1. Default is 1.
|
||||
* Specifies the texture's number of layers. Values greater than 1 create a 3D texture.
|
||||
*
|
||||
* <p>This <code>Texture</code> instance must use
|
||||
* {@link Sampler#SAMPLER_2D_ARRAY SAMPLER_2D_ARRAY} or it has no effect.</p>
|
||||
*
|
||||
* @param depth texture number of layers. Default is 1.
|
||||
* @return This Builder, for chaining calls.
|
||||
*/
|
||||
@NonNull
|
||||
@@ -638,6 +663,21 @@ public class Texture {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies how a texture's channels map to color components
|
||||
*
|
||||
* @param r texture channel for red component
|
||||
* @param g texture channel for green component
|
||||
* @param b texture channel for blue component
|
||||
* @param a texture channel for alpha component
|
||||
* @return This Builder, for chaining calls.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder swizzle(@NonNull Swizzle r, @NonNull Swizzle g, @NonNull Swizzle b, @NonNull Swizzle a) {
|
||||
nBuilderSwizzle(mNativeBuilder, r.ordinal(), g.ordinal(), b.ordinal(), a.ordinal());
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new <code>Texture</code> instance.
|
||||
* @param engine The {@link Engine} to associate this <code>Texture</code> with.
|
||||
@@ -685,6 +725,8 @@ public class Texture {
|
||||
public static final int UPLOADABLE = 0x8;
|
||||
/** The texture can be read from a shader or blitted from */
|
||||
public static final int SAMPLEABLE = 0x10;
|
||||
/** Texture can be used as a subpass input */
|
||||
public static final int SUBPASS_INPUT = 0x20;
|
||||
/** by default textures are <code>UPLOADABLE</code> and <code>SAMPLEABLE</code>*/
|
||||
public static final int DEFAULT = UPLOADABLE | SAMPLEABLE;
|
||||
}
|
||||
@@ -777,7 +819,7 @@ public class Texture {
|
||||
|
||||
|
||||
/**
|
||||
* <code>setImage</code> is used to modify a sub-region of the texure from a CPU-buffer.
|
||||
* <code>setImage</code> is used to modify a sub-region of the texture 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
|
||||
@@ -828,6 +870,58 @@ public class Texture {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <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} 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()}.
|
||||
* @param level Level to set the image for. Must be less than {@link #getLevels()}.
|
||||
* @param xoffset x-offset in texel of the region to modify
|
||||
* @param yoffset y-offset in texel of the region to modify
|
||||
* @param yoffset z-offset in texel of the region to modify
|
||||
* @param width width in texel of the region to modify
|
||||
* @param height height in texel of the region to modify
|
||||
* @param depth depth in texel or index of the region to modify
|
||||
* @param buffer Client-side buffer containing the image to set.
|
||||
* <code>buffer</code>'s {@link Format format} must match that
|
||||
* of {@link #getFormat()}
|
||||
*
|
||||
* @exception BufferOverflowException if the specified parameters would result in reading
|
||||
* outside of <code>buffer</code>.
|
||||
*
|
||||
* @see Builder#sampler
|
||||
* @see PixelBufferDescriptor
|
||||
*/
|
||||
public void setImage(@NonNull Engine engine,
|
||||
@IntRange(from = 0) int level,
|
||||
@IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset, @IntRange(from = 0) int zoffset,
|
||||
@IntRange(from = 0) int width, @IntRange(from = 0) int height, @IntRange(from = 0) int depth,
|
||||
@NonNull PixelBufferDescriptor buffer) {
|
||||
int result;
|
||||
if (buffer.type == COMPRESSED) {
|
||||
result = nSetImage3DCompressed(getNativeObject(), engine.getNativeObject(), level,
|
||||
xoffset, yoffset, zoffset, width, height, depth,
|
||||
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 = nSetImage3D(getNativeObject(), engine.getNativeObject(), level,
|
||||
xoffset, yoffset, zoffset, width, height, depth,
|
||||
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 specify all six images of a cubemap level and
|
||||
* follows exactly the OpenGL conventions
|
||||
@@ -1054,6 +1148,7 @@ public class Texture {
|
||||
private static native void nBuilderSampler(long nativeBuilder, int sampler);
|
||||
private static native void nBuilderFormat(long nativeBuilder, int format);
|
||||
private static native void nBuilderUsage(long nativeBuilder, int flags);
|
||||
private static native void nBuilderSwizzle(long nativeBuilder, int r, int g, int b, int a);
|
||||
private static native long nBuilderBuild(long nativeBuilder, long nativeEngine);
|
||||
|
||||
private static native int nGetWidth(long nativeTexture, int level);
|
||||
@@ -1075,6 +1170,18 @@ public class Texture {
|
||||
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 bottom, int type, int alignment,
|
||||
int stride, int format,
|
||||
Object handler, Runnable callback);
|
||||
|
||||
private static native int nSetImage3DCompressed(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 bottom, int type, int alignment,
|
||||
int compressedSizeInBytes, int compressedFormat,
|
||||
Object handler, Runnable callback);
|
||||
|
||||
private static native int nSetImageCubemap(long nativeTexture, long nativeEngine,
|
||||
int level, Buffer storage, int remaining, int left, int bottom, int type,
|
||||
int alignment, int stride, int format,
|
||||
|
||||
@@ -416,6 +416,9 @@ public class VertexBuffer {
|
||||
* basis.
|
||||
* </p>
|
||||
*
|
||||
* @deprecated Instead please use SurfaceOrientation since it has additional capabilities and a
|
||||
* builder-style API.
|
||||
*
|
||||
* @param context an initialized QuatTangentContext object
|
||||
*/
|
||||
public static void populateTangentQuaternions(@NonNull QuatTangentContext context) {
|
||||
|
||||
@@ -21,6 +21,10 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.Size;
|
||||
|
||||
import java.util.EnumSet;
|
||||
|
||||
import static com.google.android.filament.Asserts.assertFloat3In;
|
||||
import static com.google.android.filament.Asserts.assertFloat4In;
|
||||
import static com.google.android.filament.Colors.LinearColor;
|
||||
|
||||
/**
|
||||
@@ -62,9 +66,30 @@ public class View {
|
||||
private Viewport mViewport = new Viewport(0, 0, 0, 0);
|
||||
private DynamicResolutionOptions mDynamicResolution;
|
||||
private RenderQuality mRenderQuality;
|
||||
private DepthPrepass mDepthPrepass = DepthPrepass.DEFAULT;
|
||||
private AmbientOcclusionOptions mAmbientOcclusionOptions;
|
||||
private BloomOptions mBloomOptions;
|
||||
private FogOptions mFogOptions;
|
||||
private RenderTarget mRenderTarget;
|
||||
private BlendMode mBlendMode;
|
||||
private DepthOfFieldOptions mDepthOfFieldOptions;
|
||||
private VignetteOptions mVignetteOptions;
|
||||
private ColorGrading mColorGrading;
|
||||
private TemporalAntiAliasingOptions mTemporalAntiAliasingOptions;
|
||||
|
||||
/**
|
||||
* Generic quality level.
|
||||
*/
|
||||
public enum QualityLevel {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
ULTRA
|
||||
}
|
||||
|
||||
public enum BlendMode {
|
||||
OPAQUE,
|
||||
TRANSLUCENT
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic resolution can be used to either reach a desired target frame rate by lowering the
|
||||
@@ -94,21 +119,6 @@ public class View {
|
||||
*/
|
||||
public boolean homogeneousScaling = false;
|
||||
|
||||
/**
|
||||
* Desired frame time in milliseconds.
|
||||
*/
|
||||
public float targetFrameTimeMilli = 1000.0f / 60.0f;
|
||||
|
||||
/**
|
||||
* Additional headroom for the GPU as a ratio of the targetFrameTime.
|
||||
*/
|
||||
public float headRoomRatio = 0.0f;
|
||||
|
||||
/**
|
||||
* Rate at which the scale will change to reach the target frame rate.
|
||||
*/
|
||||
public float scaleRate = 0.125f;
|
||||
|
||||
/**
|
||||
* The minimum scale in X and Y this View should use.
|
||||
*/
|
||||
@@ -120,14 +130,16 @@ public class View {
|
||||
public float maxScale = 1.0f;
|
||||
|
||||
/**
|
||||
* History size. higher values, tend to filter more (clamped to 30).
|
||||
* Upscaling quality. LOW: 1 bilinear tap, MEDIUM: 4 bilinear taps, HIGH: 9 bilinear taps.
|
||||
* If minScale needs to be very low, it might help to use MEDIUM or HIGH here.
|
||||
* The default upscaling quality is set to LOW.
|
||||
*/
|
||||
public int history = 9;
|
||||
@NonNull
|
||||
public QualityLevel quality = QualityLevel.LOW;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for Ambient Occlusion
|
||||
* @see #setAmbientOcclusion
|
||||
* Options for screen space Ambient Occlusion
|
||||
*/
|
||||
public static class AmbientOcclusionOptions {
|
||||
/**
|
||||
@@ -138,15 +150,16 @@ public class View {
|
||||
/**
|
||||
* Self-occlusion bias in meters. Use to avoid self-occlusion. Between 0 and a few mm.
|
||||
*/
|
||||
public float bias = 0.005f;
|
||||
public float bias = 0.0005f;
|
||||
|
||||
/**
|
||||
* Controls ambient occlusion's contrast. Between 0 (linear) and 1 (squared)
|
||||
* Controls ambient occlusion's contrast. Must be positive. Default is 1.
|
||||
* Good values are between 0.5 and 3.
|
||||
*/
|
||||
public float power = 0.0f;
|
||||
public float power = 1.0f;
|
||||
|
||||
/**
|
||||
* How each dimension of the AO buffer is scaled. Must be positive and <= 1.
|
||||
* How each dimension of the AO buffer is scaled. Must be either 0.5 or 1.0.
|
||||
*/
|
||||
public float resolution = 0.5f;
|
||||
|
||||
@@ -154,24 +167,257 @@ public class View {
|
||||
* Strength of the Ambient Occlusion effect. Must be positive.
|
||||
*/
|
||||
public float intensity = 1.0f;
|
||||
|
||||
/**
|
||||
* The quality setting controls the number of samples used for evaluating Ambient
|
||||
* occlusion. The default is QualityLevel.LOW which is sufficient for most mobile
|
||||
* applications.
|
||||
*/
|
||||
@NonNull
|
||||
public QualityLevel quality = QualityLevel.LOW;
|
||||
|
||||
/**
|
||||
* The upsampling setting controls the quality of the ambient occlusion buffer upsampling.
|
||||
* The default is QualityLevel.LOW and uses bilinear filtering, a value of
|
||||
* QualityLevel.HIGH or more enables a better bilateral filter.
|
||||
*/
|
||||
@NonNull
|
||||
public QualityLevel upsampling = QualityLevel.LOW;
|
||||
|
||||
/**
|
||||
* enable or disable screen space ambient occlusion
|
||||
*/
|
||||
public boolean enabled = false;
|
||||
|
||||
/**
|
||||
* Minimal angle to consider in radian. This is used to reduce the creases that can
|
||||
* appear due to insufficiently tessellated geometry.
|
||||
* For e.g. a good values to try could be around 0.2.
|
||||
*/
|
||||
public float minHorizonAngleRad = 0.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the quality of the HDR color buffer.
|
||||
*
|
||||
* <p>
|
||||
* A quality of <code>HIGH</code> or <code>ULTRA</code> means using an RGB16F or RGBA16F color
|
||||
* buffer. This means colors in the LDR range (0..1) have 10 bit precision. A quality of
|
||||
* <code>LOW</code> or <code>MEDIUM</code> means using an R11G11B10F opaque color buffer or an
|
||||
* RGBA16F transparent color buffer. With R11G11B10F colors in the LDR range have a precision of
|
||||
* either 6 bits (red and green channels) or 5 bits (blue channel).
|
||||
* </p>
|
||||
* Options for Temporal Anti-aliasing (TAA)
|
||||
* @see View#setTemporalAntiAliasingOptions()
|
||||
*/
|
||||
public enum QualityLevel {
|
||||
LOW,
|
||||
MEDIUM,
|
||||
HIGH,
|
||||
ULTRA
|
||||
public static class TemporalAntiAliasingOptions {
|
||||
/** reconstruction filter width typically between 0 (sharper, aliased) and 1 (smoother) */
|
||||
public float filterWidth = 1.0f;
|
||||
|
||||
/** history feedback, between 0 (maximum temporal AA) and 1 (no temporal AA). */
|
||||
public float feedback = 0.04f;
|
||||
|
||||
/** enables or disables temporal anti-aliasing */
|
||||
public boolean enabled = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Options for controlling the Bloom effect
|
||||
*
|
||||
* enabled: Enable or disable the bloom post-processing effect. Disabled by default.
|
||||
* levels: Number of successive blurs to achieve the blur effect, the minimum is 3 and the
|
||||
* maximum is 12. This value together with resolution influences the spread of the
|
||||
* blur effect. This value can be silently reduced to accommodate the original
|
||||
* image size.
|
||||
* resolution: Resolution of bloom's minor axis. The minimum value is 2^levels and the
|
||||
* the maximum is lower of the original resolution and 4096. This parameter is
|
||||
* silently clamped to the minimum and maximum.
|
||||
* It is highly recommended that this value be smaller than the target resolution
|
||||
* after dynamic resolution is applied (horizontally and vertically).
|
||||
* strength: how much of the bloom is added to the original image. Between 0 and 1.
|
||||
* blendMode: Whether the bloom effect is purely additive (false) or mixed with the original
|
||||
* image (true).
|
||||
* anamorphism: Bloom's aspect ratio (x/y), for artistic purposes.
|
||||
* threshold: When enabled, a threshold at 1.0 is applied on the source image, this is
|
||||
* useful for artistic reasons and is usually needed when a dirt texture is used.
|
||||
* dirt: A dirt/scratch/smudges texture (that can be RGB), which gets added to the
|
||||
* bloom effect. Smudges are visible where bloom occurs. Threshold must be
|
||||
* enabled for the dirt effect to work properly.
|
||||
* dirtStrength: Strength of the dirt texture.
|
||||
*
|
||||
* @see View#setBloomOptions
|
||||
*/
|
||||
public static class BloomOptions {
|
||||
|
||||
public enum BlendingMode {
|
||||
ADD,
|
||||
INTERPOLATE
|
||||
}
|
||||
|
||||
/**
|
||||
* User provided dirt texture
|
||||
*/
|
||||
@Nullable
|
||||
public Texture dirt = null;
|
||||
|
||||
/**
|
||||
* strength of the dirt texture
|
||||
*/
|
||||
public float dirtStrength = 0.2f;
|
||||
|
||||
/**
|
||||
* Strength of the bloom effect, between 0.0 and 1.0
|
||||
*/
|
||||
public float strength = 0.10f;
|
||||
|
||||
/**
|
||||
* Resolution of minor axis (2^levels to 4096)
|
||||
*/
|
||||
public int resolution = 360;
|
||||
|
||||
/**
|
||||
* Bloom x/y aspect-ratio (1/32 to 32)
|
||||
*/
|
||||
public float anamorphism = 1.0f;
|
||||
|
||||
/**
|
||||
* Number of blur levels (3 to 12)
|
||||
*/
|
||||
public int levels = 6;
|
||||
|
||||
/**
|
||||
* How the bloom effect is applied
|
||||
*/
|
||||
public BlendingMode blendingMode = BlendingMode.ADD;
|
||||
|
||||
/**
|
||||
* Whether to threshold the source
|
||||
*/
|
||||
public boolean threshold = true;
|
||||
|
||||
/**
|
||||
* enable or disable bloom
|
||||
*/
|
||||
public boolean enabled = false;
|
||||
|
||||
/**
|
||||
* limit highlights to this value before bloom. Use +inf for no limiting.
|
||||
* minimum value is 10.0.
|
||||
*/
|
||||
public float highlight = 1000.0f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to control fog in the scene
|
||||
*
|
||||
* @see View#setFogOptions
|
||||
*/
|
||||
public static class FogOptions {
|
||||
/**
|
||||
* distance in world units from the camera where the fog starts ( >= 0.0 )
|
||||
*/
|
||||
public float distance = 0.0f;
|
||||
|
||||
/**
|
||||
* fog's maximum opacity between 0 and 1
|
||||
*/
|
||||
public float maximumOpacity = 1.0f;
|
||||
|
||||
/**
|
||||
* fog's floor in world units
|
||||
*/
|
||||
public float height = 0.0f;
|
||||
|
||||
/**
|
||||
* how fast fog dissipates with altitude
|
||||
*/
|
||||
public float heightFalloff = 1.0f;
|
||||
|
||||
/**
|
||||
* Fog's color as a linear RGB color.
|
||||
*/
|
||||
@NonNull
|
||||
@Size(min = 3)
|
||||
public float[] color = { 0.5f, 0.5f, 0.5f };
|
||||
|
||||
/**
|
||||
* fog's density at altitude given by 'height'
|
||||
*/
|
||||
public float density = 0.1f;
|
||||
|
||||
/**
|
||||
* distance in world units from the camera where in-scattering starts
|
||||
*/
|
||||
public float inScatteringStart = 0.0f;
|
||||
|
||||
/**
|
||||
* size of in-scattering (>0 to activate). Good values are >> 1 (e.g. ~10 - 100)
|
||||
*/
|
||||
public float inScatteringSize = -1.0f;
|
||||
|
||||
/**
|
||||
* fog color will be modulated by the IBL color in the view direction
|
||||
*/
|
||||
public boolean fogColorFromIbl = false;
|
||||
|
||||
/**
|
||||
* enable or disable fog
|
||||
*/
|
||||
public boolean enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to control Depth of Field (DoF) effect in the scene
|
||||
*
|
||||
* @see View#setDepthOfFieldOptions
|
||||
*/
|
||||
public static class DepthOfFieldOptions {
|
||||
|
||||
/** focus distance in world units */
|
||||
public float focusDistance = 10.0f;
|
||||
|
||||
/**
|
||||
* circle of confusion scale factor (amount of blur)
|
||||
*
|
||||
* <p>cocScale can be used to set the depth of field blur independently from the camera
|
||||
* aperture, e.g. for artistic reasons. This can be achieved by setting:</p>
|
||||
* <code>
|
||||
* cocScale = cameraAperture / desiredDoFAperture
|
||||
* </code>
|
||||
*
|
||||
*/
|
||||
public float cocScale = 1.0f;
|
||||
|
||||
/** maximum aperture diameter in meters (zero to disable bokeh rotation) */
|
||||
public float maxApertureDiameter = 0.01f;
|
||||
|
||||
/** enable or disable Depth of field effect */
|
||||
public boolean enabled = false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Options to control the vignetting effect.
|
||||
*/
|
||||
public static class VignetteOptions {
|
||||
/**
|
||||
* High values restrict the vignette closer to the corners, between 0 and 1.
|
||||
*/
|
||||
public float midPoint = 0.5f;
|
||||
|
||||
/**
|
||||
* Controls the shape of the vignette, from a rounded rectangle (0.0), to an oval (0.5),
|
||||
* to a circle (1.0). The value must be between 0 and 1.
|
||||
*/
|
||||
public float roundness = 0.5f;
|
||||
|
||||
/**
|
||||
* Softening amount of the vignette effect, between 0 and 1.
|
||||
*/
|
||||
public float feather = 0.5f;
|
||||
|
||||
/**
|
||||
* Color of the vignette effect as a linear RGBA color. The alpha channel is currently
|
||||
* ignored.
|
||||
*/
|
||||
@NonNull
|
||||
@Size(min = 4)
|
||||
public float[] color = { 0.0f, 0.0f, 0.0f, 1.0f };
|
||||
|
||||
/**
|
||||
* Enables or disables the vignette effect.
|
||||
*/
|
||||
public boolean enabled = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -186,14 +432,24 @@ public class View {
|
||||
* @see #getRenderQuality
|
||||
*/
|
||||
public static class RenderQuality {
|
||||
/**
|
||||
* <p>
|
||||
* A quality of <code>HIGH</code> or <code>ULTRA</code> means using an RGB16F or RGBA16F color
|
||||
* buffer. This means colors in the LDR range (0..1) have 10 bit precision. A quality of
|
||||
* <code>LOW</code> or <code>MEDIUM</code> means using an R11G11B10F opaque color buffer or an
|
||||
* RGBA16F transparent color buffer. With R11G11B10F colors in the LDR range have a precision of
|
||||
* either 6 bits (red and green channels) or 5 bits (blue channel).
|
||||
* </p>
|
||||
*/
|
||||
public QualityLevel hdrColorBuffer = QualityLevel.HIGH;
|
||||
}
|
||||
|
||||
/**
|
||||
* List of available ambient occlusion techniques.
|
||||
*
|
||||
* @deprecated use setAmbientOcclusionOptions instead
|
||||
* @see #setAmbientOcclusion
|
||||
*/
|
||||
*/
|
||||
@Deprecated
|
||||
public enum AmbientOcclusion {
|
||||
NONE,
|
||||
SSAO
|
||||
@@ -219,7 +475,10 @@ public class View {
|
||||
|
||||
/**
|
||||
* List of available tone-mapping operators
|
||||
*
|
||||
* @deprecated Use ColorGrading instead
|
||||
*/
|
||||
@Deprecated
|
||||
public enum ToneMapping {
|
||||
/**
|
||||
* Equivalent to disabling tone-mapping.
|
||||
@@ -240,18 +499,68 @@ public class View {
|
||||
TEMPORAL
|
||||
}
|
||||
|
||||
/** @see #setDepthPrepass */
|
||||
public enum DepthPrepass {
|
||||
DEFAULT(-1),
|
||||
DISABLED(0),
|
||||
ENABLED(1);
|
||||
/**
|
||||
* Used to select buffers.
|
||||
*/
|
||||
public enum TargetBufferFlags {
|
||||
/**
|
||||
* Color 0 buffer selected.
|
||||
*/
|
||||
COLOR0(0x1),
|
||||
/**
|
||||
* Color 1 buffer selected.
|
||||
*/
|
||||
COLOR1(0x2),
|
||||
/**
|
||||
* Color 2 buffer selected.
|
||||
*/
|
||||
COLOR2(0x4),
|
||||
/**
|
||||
* Color 3 buffer selected.
|
||||
*/
|
||||
COLOR3(0x8),
|
||||
/**
|
||||
* Depth buffer selected.
|
||||
*/
|
||||
DEPTH(0x10),
|
||||
/**
|
||||
* Stencil buffer selected.
|
||||
*/
|
||||
STENCIL(0x20);
|
||||
|
||||
final int value;
|
||||
/*
|
||||
* No buffer selected
|
||||
*/
|
||||
public static EnumSet<TargetBufferFlags> NONE = EnumSet.noneOf(TargetBufferFlags.class);
|
||||
|
||||
DepthPrepass(int value) {
|
||||
this.value = value;
|
||||
/*
|
||||
* All color buffers selected
|
||||
*/
|
||||
public static EnumSet<TargetBufferFlags> ALL_COLOR =
|
||||
EnumSet.of(COLOR0, COLOR1, COLOR2, COLOR3);
|
||||
/**
|
||||
* Depth and stencil buffer selected.
|
||||
*/
|
||||
public static EnumSet<TargetBufferFlags> DEPTH_STENCIL = EnumSet.of(DEPTH, STENCIL);
|
||||
/**
|
||||
* All buffers are selected.
|
||||
*/
|
||||
public static EnumSet<TargetBufferFlags> ALL = EnumSet.range(COLOR0, STENCIL);
|
||||
|
||||
private int mFlags;
|
||||
|
||||
TargetBufferFlags(int flags) {
|
||||
mFlags = flags;
|
||||
}
|
||||
};
|
||||
|
||||
static int flags(EnumSet<TargetBufferFlags> flags) {
|
||||
int result = 0;
|
||||
for (TargetBufferFlags flag : flags) {
|
||||
result |= flag.mFlags;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
View(long nativeView) {
|
||||
mNativeObject = nativeView;
|
||||
@@ -367,39 +676,23 @@ public class View {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the color used to clear the Viewport when rendering this View.
|
||||
* Sets the blending mode used to draw the view into the SwapChain.
|
||||
*
|
||||
* <p>This is ignored if a {@link Skybox} is present or if clearing has been disabled
|
||||
* via {@link #setClearTargets}. Defaults to black.</p>
|
||||
*
|
||||
* @see #getClearColor
|
||||
* @param blendMode either {@link BlendMode#OPAQUE} or {@link BlendMode#TRANSLUCENT}
|
||||
* @see #getBlendMode
|
||||
*/
|
||||
public void setClearColor(
|
||||
@LinearColor float r, @LinearColor float g, @LinearColor float b, float a) {
|
||||
nSetClearColor(getNativeObject(), r, g, b, a);
|
||||
public void setBlendMode(BlendMode blendMode) {
|
||||
mBlendMode = blendMode;
|
||||
nSetBlendMode(getNativeObject(), blendMode.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the View clear color in a provided 4-tuple.
|
||||
*
|
||||
* @return A reference to the passed-in array.
|
||||
*
|
||||
* @see #setClearColor
|
||||
* @return blending mode set by setBlendMode
|
||||
* @see #setBlendMode
|
||||
*/
|
||||
@NonNull @Size(min = 4)
|
||||
public float[] getClearColor(@NonNull @Size(min = 4) float[] out) {
|
||||
out = Asserts.assertFloat4(out);
|
||||
nGetClearColor(getNativeObject(), out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets which targets to clear (default: true, true, false)
|
||||
*
|
||||
* @see #setClearColor
|
||||
*/
|
||||
public void setClearTargets(boolean color, boolean depth, boolean stencil) {
|
||||
nSetClearTargets(getNativeObject(), color, depth, stencil);
|
||||
public BlendMode getBlendMode() {
|
||||
return mBlendMode;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -442,6 +735,11 @@ public class View {
|
||||
* SwapChain associated with the engine.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* A view with a custom render target cannot rely on Renderer.ClearOptions, which only applies
|
||||
* to the SwapChain. Such view can use a Skybox instead.
|
||||
* </p>
|
||||
*
|
||||
* @param target render target associated with view, or null for the swap chain
|
||||
*/
|
||||
public void setRenderTarget(@Nullable RenderTarget target) {
|
||||
@@ -513,22 +811,74 @@ public class View {
|
||||
return AntiAliasing.values()[nGetAntiAliasing(getNativeObject())];
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disable temporal anti-aliasing (TAA). Disabled by default.
|
||||
*
|
||||
* @param options temporal anti-aliasing options
|
||||
*/
|
||||
public void setTemporalAntiAliasingOptions(@NonNull TemporalAntiAliasingOptions options) {
|
||||
mTemporalAntiAliasingOptions = options;
|
||||
nSetTemporalAntiAliasingOptions(getNativeObject(),
|
||||
options.feedback, options.filterWidth, options.enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns temporal anti-aliasing options.
|
||||
*
|
||||
* @return temporal anti-aliasing options
|
||||
*/
|
||||
@NonNull
|
||||
public TemporalAntiAliasingOptions getTemporalAntiAliasingOptions() {
|
||||
if (mTemporalAntiAliasingOptions == null) {
|
||||
mTemporalAntiAliasingOptions = new TemporalAntiAliasingOptions();
|
||||
}
|
||||
return mTemporalAntiAliasingOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables or disables tone-mapping in the post-processing stage. Enabled by default.
|
||||
*
|
||||
* @param type Tone-mapping function.
|
||||
*
|
||||
* @deprecated Use {@link #setColorGrading(com.google.android.filament.ColorGrading)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setToneMapping(@NonNull ToneMapping type) {
|
||||
nSetToneMapping(getNativeObject(), type.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tone-mapping function.
|
||||
* @return tone-mapping function.
|
||||
*
|
||||
* @deprecated Use {@link #getColorGrading()}. This always returns {@link ToneMapping#ACES}
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public ToneMapping getToneMapping() {
|
||||
return ToneMapping.values()[nGetToneMapping(getNativeObject())];
|
||||
return ToneMapping.ACES;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets this View's color grading transforms.
|
||||
*
|
||||
* @param colorGrading Associate the specified {@link ColorGrading} to this view. A ColorGrading
|
||||
* can be associated to several View instances. Can be null to dissociate
|
||||
* the currently set ColorGrading from this View. Doing so will revert to
|
||||
* the use of the default color grading transforms.
|
||||
*/
|
||||
public void setColorGrading(@Nullable ColorGrading colorGrading) {
|
||||
nSetColorGrading(getNativeObject(),
|
||||
colorGrading != null ? colorGrading.getNativeObject() : 0);
|
||||
mColorGrading = colorGrading;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ColorGrading} associated to this view.
|
||||
*
|
||||
* @return A {@link ColorGrading} or null if the default {@link ColorGrading} is in use
|
||||
*/
|
||||
public ColorGrading getColorGrading() {
|
||||
return mColorGrading;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -570,12 +920,9 @@ public class View {
|
||||
nSetDynamicResolutionOptions(getNativeObject(),
|
||||
options.enabled,
|
||||
options.homogeneousScaling,
|
||||
options.targetFrameTimeMilli,
|
||||
options.headRoomRatio,
|
||||
options.scaleRate,
|
||||
options.minScale,
|
||||
options.maxScale,
|
||||
options.history);
|
||||
options.quality.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -612,49 +959,6 @@ public class View {
|
||||
return mRenderQuality;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this view is rendered with a depth-only prepass.
|
||||
*
|
||||
* @return the value set by {@link #setDepthPrepass}.
|
||||
*/
|
||||
@NonNull
|
||||
public DepthPrepass getDepthPrepass() {
|
||||
return mDepthPrepass;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether this view is rendered with or without a depth pre-pass.
|
||||
*
|
||||
* <p><b>This setting is ignored and will be removed in future versions of Filament.</b></p>
|
||||
*
|
||||
* <p>
|
||||
* By default, the system picks the most appropriate strategy for your platform; this method
|
||||
* lets you override that strategy.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* When the depth pre-pass is enabled, the renderer will first draw all objects in the
|
||||
* depth buffer from front to back, and then draw the objects again but sorted to minimize
|
||||
* state changes. With the depth pre-pass disabled, objects are drawn only once, but it may
|
||||
* result in more state changes or more overdraw.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* The best strategy may depend on the scene and/or GPU.
|
||||
* </p>
|
||||
*
|
||||
* <ul>
|
||||
* <li>DepthPrepass::DEFAULT uses the most appropriate strategy</li>
|
||||
* <li>DepthPrepass::DISABLED disables the depth pre-pass</li>
|
||||
* <li>DepthPrepass::ENABLE enables the depth pre-pass</li>
|
||||
* </ul>
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDepthPrepass(@NonNull DepthPrepass depthPrepass) {
|
||||
mDepthPrepass = depthPrepass;
|
||||
nSetDepthPrepass(getNativeObject(), depthPrepass.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if post-processing is enabled.
|
||||
*
|
||||
@@ -745,18 +1049,20 @@ public class View {
|
||||
|
||||
/**
|
||||
* Activates or deactivates ambient occlusion.
|
||||
*
|
||||
* @see #setAmbientOcclusionOptions
|
||||
* @param ao Type of ambient occlusion to use.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAmbientOcclusion(@NonNull AmbientOcclusion ao) {
|
||||
nSetAmbientOcclusion(getNativeObject(), ao.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the type of ambient occlusion active for this View.
|
||||
*
|
||||
* @see #getAmbientOcclusionOptions
|
||||
* @return ambient occlusion type.
|
||||
*/
|
||||
@Deprecated
|
||||
@NonNull
|
||||
public AmbientOcclusion getAmbientOcclusion() {
|
||||
return AmbientOcclusion.values()[nGetAmbientOcclusion(getNativeObject())];
|
||||
@@ -770,7 +1076,8 @@ public class View {
|
||||
public void setAmbientOcclusionOptions(@NonNull AmbientOcclusionOptions options) {
|
||||
mAmbientOcclusionOptions = options;
|
||||
nSetAmbientOcclusionOptions(getNativeObject(), options.radius, options.bias, options.power,
|
||||
options.resolution, options.intensity);
|
||||
options.resolution, options.intensity, options.quality.ordinal(), options.upsampling.ordinal(),
|
||||
options.enabled, options.minHorizonAngleRad);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -786,6 +1093,120 @@ public class View {
|
||||
return mAmbientOcclusionOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets bloom options.
|
||||
*
|
||||
* @param options Options for bloom.
|
||||
* @see #getBloomOptions
|
||||
*/
|
||||
public void setBloomOptions(@NonNull BloomOptions options) {
|
||||
mBloomOptions = options;
|
||||
nSetBloomOptions(getNativeObject(), options.dirt != null ? options.dirt.getNativeObject() : 0,
|
||||
options.dirtStrength, options.strength, options.resolution,
|
||||
options.anamorphism, options.levels, options.blendingMode.ordinal(),
|
||||
options.threshold, options.enabled, options.highlight);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the bloom options
|
||||
* @see #setBloomOptions
|
||||
*
|
||||
* @return bloom options currently set.
|
||||
*/
|
||||
@NonNull
|
||||
public BloomOptions getBloomOptions() {
|
||||
if (mBloomOptions == null) {
|
||||
mBloomOptions = new BloomOptions();
|
||||
}
|
||||
return mBloomOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets vignette options.
|
||||
*
|
||||
* @param options Options for vignetting.
|
||||
* @see #getVignetteOptions
|
||||
*/
|
||||
public void setVignetteOptions(@NonNull VignetteOptions options) {
|
||||
assertFloat4In(options.color);
|
||||
mVignetteOptions = options;
|
||||
nSetVignetteOptions(getNativeObject(),
|
||||
options.midPoint, options.roundness, options.feather,
|
||||
options.color[0], options.color[1], options.color[2], options.color[3],
|
||||
options.enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the vignette options
|
||||
* @see #setVignetteOptions
|
||||
*
|
||||
* @return vignetting options currently set.
|
||||
*/
|
||||
@NonNull
|
||||
public VignetteOptions getVignetteOptions() {
|
||||
if (mVignetteOptions == null) {
|
||||
mVignetteOptions = new VignetteOptions();
|
||||
}
|
||||
return mVignetteOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets fog options.
|
||||
*
|
||||
* @param options Options for fog.
|
||||
* @see #getFogOptions
|
||||
*/
|
||||
public void setFogOptions(@NonNull FogOptions options) {
|
||||
assertFloat3In(options.color);
|
||||
mFogOptions = options;
|
||||
nSetFogOptions(getNativeObject(), options.distance, options.maximumOpacity, options.height,
|
||||
options.heightFalloff, options.color[0], options.color[1], options.color[2],
|
||||
options.density, options.inScatteringStart, options.inScatteringSize,
|
||||
options.fogColorFromIbl,
|
||||
options.enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the fog options
|
||||
*
|
||||
* @return fog options currently set.
|
||||
* @see #setFogOptions
|
||||
*/
|
||||
@NonNull
|
||||
public FogOptions getFogOptions() {
|
||||
if (mFogOptions == null) {
|
||||
mFogOptions = new FogOptions();
|
||||
}
|
||||
return mFogOptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets Depth of Field options.
|
||||
*
|
||||
* @param options Options for depth of field effect.
|
||||
* @see #getDepthOfFieldOptions
|
||||
*/
|
||||
public void setDepthOfFieldOptions(@NonNull DepthOfFieldOptions options) {
|
||||
mDepthOfFieldOptions = options;
|
||||
nSetDepthOfFieldOptions(getNativeObject(), options.focusDistance, options.cocScale, options.maxApertureDiameter, options.enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Depth of Field options
|
||||
*
|
||||
* @return Depth of Field options currently set.
|
||||
* @see #setDepthOfFieldOptions
|
||||
*/
|
||||
@NonNull
|
||||
public DepthOfFieldOptions getDepthOfFieldOptions() {
|
||||
if (mDepthOfFieldOptions == null) {
|
||||
mDepthOfFieldOptions = new DepthOfFieldOptions();
|
||||
}
|
||||
return mDepthOfFieldOptions;
|
||||
}
|
||||
|
||||
|
||||
public long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Calling method on destroyed View");
|
||||
@@ -801,9 +1222,6 @@ public class View {
|
||||
private static native void nSetScene(long nativeView, long nativeScene);
|
||||
private static native void nSetCamera(long nativeView, long nativeCamera);
|
||||
private static native void nSetViewport(long nativeView, int left, int bottom, int width, int height);
|
||||
private static native void nSetClearColor(long nativeView, float r, float g, float b, float a);
|
||||
private static native void nGetClearColor(long nativeView, float[] out);
|
||||
private static native void nSetClearTargets(long nativeView, boolean color, boolean depth, boolean stencil);
|
||||
private static native void nSetVisibleLayers(long nativeView, int select, int value);
|
||||
private static native void nSetShadowsEnabled(long nativeView, boolean enabled);
|
||||
private static native void nSetRenderTarget(long nativeView, long nativeRenderTarget);
|
||||
@@ -811,22 +1229,23 @@ public class View {
|
||||
private static native int nGetSampleCount(long nativeView);
|
||||
private static native void nSetAntiAliasing(long nativeView, int type);
|
||||
private static native int nGetAntiAliasing(long nativeView);
|
||||
private static native void nSetToneMapping(long nativeView, int type);
|
||||
private static native int nGetToneMapping(long nativeView);
|
||||
private static native void nSetDithering(long nativeView, int dithering);
|
||||
private static native int nGetDithering(long nativeView);
|
||||
private static native void nSetDynamicResolutionOptions(long nativeView,
|
||||
boolean enabled, boolean homogeneousScaling,
|
||||
float targetFrameTimeMilli, float headRoomRatio, float scaleRate,
|
||||
float minScale, float maxScale, int history);
|
||||
private static native void nSetDynamicResolutionOptions(long nativeView, boolean enabled, boolean homogeneousScaling, float minScale, float maxScale, int quality);
|
||||
private static native void nSetRenderQuality(long nativeView, int hdrColorBufferQuality);
|
||||
private static native void nSetDynamicLightingOptions(long nativeView, float zLightNear, float zLightFar);
|
||||
private static native void nSetDepthPrepass(long nativeView, int value);
|
||||
private static native void nSetColorGrading(long nativeView, long nativeColorGrading);
|
||||
private static native void nSetPostProcessingEnabled(long nativeView, boolean enabled);
|
||||
private static native boolean nIsPostProcessingEnabled(long nativeView);
|
||||
private static native void nSetFrontFaceWindingInverted(long nativeView, boolean inverted);
|
||||
private static native boolean nIsFrontFaceWindingInverted(long nativeView);
|
||||
private static native void nSetAmbientOcclusion(long nativeView, int ordinal);
|
||||
private static native int nGetAmbientOcclusion(long nativeView);
|
||||
private static native void nSetAmbientOcclusionOptions(long nativeView, float radius, float bias, float power, float resolution, float intensity);
|
||||
private static native void nSetAmbientOcclusionOptions(long nativeView, float radius, float bias, float power, float resolution, float intensity, int quality, int upsampling, boolean enabled, float minHorizonAngleRad);
|
||||
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);
|
||||
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 focusDistance, float cocScale, float maxApertureDiameter, boolean enabled);
|
||||
private static native void nSetVignetteOptions(long nativeView, float midPoint, float roundness, float feather, float r, float g, float b, float a, boolean enabled);
|
||||
private static native void nSetTemporalAntiAliasingOptions(long nativeView, float feedback, float filterWidth, boolean enabled);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,204 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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 android.content.Context;
|
||||
import android.hardware.display.DisplayManager;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.view.Display;
|
||||
|
||||
import com.google.android.filament.Renderer;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* DisplayHelper is here to help managing a Display, for instance being notified when its
|
||||
* resolution or refresh rate changes.
|
||||
*/
|
||||
public class DisplayHelper {
|
||||
|
||||
private Handler mHandler = null;
|
||||
private DisplayManager mDisplayManager;
|
||||
private Display mDisplay;
|
||||
private Renderer mRenderer;
|
||||
private DisplayManager.DisplayListener mListener;
|
||||
|
||||
/**
|
||||
* Creates a DisplayHelper which helps managing a {@link Display}.
|
||||
*
|
||||
* The {@link Display} to manage is specified with {@link #attach}
|
||||
*
|
||||
* @param context a {@link Context} to used to retrieve the {@link DisplayManager}
|
||||
*/
|
||||
public DisplayHelper(@NonNull Context context) {
|
||||
mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a DisplayHelper which helps manage a {@link Display} and provides a Handler
|
||||
* where callbacks can execute filament code. Use this method if filament is executing
|
||||
* on another thread.
|
||||
*
|
||||
* @param context a {@link Context} to used to retrieve teh {@link DisplayManager}
|
||||
* @param handler a {@link Handler} used to run callbacks accessing filament
|
||||
*/
|
||||
public DisplayHelper(@NonNull Context context, @NonNull Handler handler) {
|
||||
this(context);
|
||||
mHandler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
try {
|
||||
// just for safety
|
||||
detach();
|
||||
} finally {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the filament {@link Renderer} associated to the {@link Display}, from this point
|
||||
* on, {@link Renderer.DisplayInfo} will be automatically updated when the {@link Display}
|
||||
* properties change.
|
||||
*
|
||||
* This is typically called from {@link UiHelper.RendererCallback#onNativeWindowChanged}.
|
||||
*
|
||||
* @param renderer a filament {@link Renderer} instance
|
||||
* @param display a {@link Display} to be associated with the {@link Renderer}
|
||||
*/
|
||||
public void attach(@NonNull Renderer renderer, @NonNull Display display) {
|
||||
if (renderer == mRenderer && display == mDisplay) {
|
||||
return;
|
||||
}
|
||||
mRenderer = renderer;
|
||||
mDisplay = display;
|
||||
mListener = new DisplayManager.DisplayListener() {
|
||||
@Override
|
||||
public void onDisplayAdded(int displayId) {
|
||||
}
|
||||
@Override
|
||||
public void onDisplayRemoved(int displayId) {
|
||||
}
|
||||
@Override
|
||||
public void onDisplayChanged(int displayId) {
|
||||
if (displayId == display.getDisplayId()) {
|
||||
updateDisplayInfo();
|
||||
}
|
||||
}
|
||||
};
|
||||
mDisplayManager.registerDisplayListener(mListener, mHandler);
|
||||
|
||||
// always invoke the callback when it's registered
|
||||
if (mHandler != null) {
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateDisplayInfo();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
updateDisplayInfo();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect the previously set {@link Renderer} from {@link Display}
|
||||
* This is typically called from {@link UiHelper.RendererCallback#onDetachedFromSurface}.
|
||||
*/
|
||||
public void detach() {
|
||||
if (mListener != null) {
|
||||
mDisplayManager.unregisterDisplayListener(mListener);
|
||||
mListener = null;
|
||||
mDisplay = null;
|
||||
mRenderer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplayInfo() {
|
||||
mRenderer.setDisplayInfo(
|
||||
DisplayHelper.getDisplayInfo(mDisplay, mRenderer.getDisplayInfo()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Display} currently monitored
|
||||
* @return the {@link Display} set in {@link #attach} or null
|
||||
*/
|
||||
public Display getDisplay() {
|
||||
return mDisplay;
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate a {@link Renderer.DisplayInfo} with properties from the given {@link Display}
|
||||
*
|
||||
* @param display {@link Display} to get {@link Renderer.DisplayInfo} from
|
||||
* @param info an instance of {@link Renderer.DisplayInfo} or null
|
||||
* @return an populated instance of {@link Renderer.DisplayInfo}
|
||||
*/
|
||||
@NonNull
|
||||
public static Renderer.DisplayInfo getDisplayInfo(@NonNull Display display, @Nullable Renderer.DisplayInfo info) {
|
||||
if (info == null) {
|
||||
info = new Renderer.DisplayInfo();
|
||||
}
|
||||
info.refreshRate = DisplayHelper.getRefreshRate(display);
|
||||
info.presentationDeadlineNanos = DisplayHelper.getPresentationDeadlineNanos(display);
|
||||
info.vsyncOffsetNanos = DisplayHelper.getAppVsyncOffsetNanos(display);
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link Display} application vsync offset 0 if not supported
|
||||
* @see Display#getAppVsyncOffsetNanos
|
||||
*/
|
||||
public static long getAppVsyncOffsetNanos(@NonNull Display display) {
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
return display.getAppVsyncOffsetNanos();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link Display} presentation deadline before the h/w vsync event in nanoseconds
|
||||
* @see Display#getPresentationDeadlineNanos
|
||||
*/
|
||||
public static long getPresentationDeadlineNanos(@NonNull Display display) {
|
||||
if (Build.VERSION.SDK_INT >= 29) {
|
||||
return display.getPresentationDeadlineNanos();
|
||||
}
|
||||
// not supported, pick something reasonable
|
||||
return 11_600_000;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the {@link Display} refresh rate in Hz
|
||||
* @see Display#getRefreshRate
|
||||
*/
|
||||
public static float getRefreshRate(@NonNull Display display) {
|
||||
return display.getRefreshRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link Display}'s refresh period in nanoseconds
|
||||
* @param display the {@link Display} to get the refresh period from
|
||||
* @return the {@link Display} refresh period in nanoseconds
|
||||
*/
|
||||
public static long getRefreshPeriodNanos(@NonNull Display display) {
|
||||
return (long) (1_000_000_000.0 / display.getRefreshRate());
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,14 @@ public final class TextureHelper {
|
||||
level, 0, 0, texture.getWidth(level), texture.getHeight(level), bitmap);
|
||||
}
|
||||
|
||||
public static void setBitmap(@NonNull Engine engine,
|
||||
@NonNull Texture texture, @IntRange(from = 0) int level, @NonNull Bitmap bitmap,
|
||||
Object handler, Runnable callback) {
|
||||
setBitmap(engine, texture,
|
||||
level, 0, 0, texture.getWidth(level), texture.getHeight(level), bitmap,
|
||||
handler, callback);
|
||||
}
|
||||
|
||||
public static void setBitmap(@NonNull Engine engine,
|
||||
@NonNull Texture texture, @IntRange(from = 0) int level,
|
||||
@IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset,
|
||||
@@ -60,6 +68,23 @@ public final class TextureHelper {
|
||||
bitmap, format);
|
||||
}
|
||||
|
||||
public static void setBitmap(@NonNull Engine engine,
|
||||
@NonNull Texture texture, @IntRange(from = 0) int level,
|
||||
@IntRange(from = 0) int xoffset, @IntRange(from = 0) int yoffset,
|
||||
@IntRange(from = 0) int width, @IntRange(from = 0) int height,
|
||||
@NonNull Bitmap bitmap, Object handler, Runnable callback) {
|
||||
|
||||
int format = toNativeFormat(bitmap.getConfig());
|
||||
if (format == BITMAP_CONFIG_RGBA_4444 || format == BITMAP_CONFIG_HARDWARE) {
|
||||
throw new IllegalArgumentException("Unsupported config: ARGB_4444 or HARDWARE");
|
||||
}
|
||||
|
||||
long nativeTexture = texture.getNativeObject();
|
||||
long nativeEngine = engine.getNativeObject();
|
||||
nSetBitmapWithCallback(nativeTexture, nativeEngine, level, xoffset, yoffset, width, height,
|
||||
bitmap, format, handler, callback);
|
||||
}
|
||||
|
||||
private static int toNativeFormat(Bitmap.Config config) {
|
||||
switch (config) {
|
||||
case ALPHA_8: return BITMAP_CONFIG_ALPHA_8;
|
||||
@@ -74,4 +99,8 @@ public final class TextureHelper {
|
||||
|
||||
private static native void nSetBitmap(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int width, int height, Bitmap bitmap, int format);
|
||||
|
||||
private static native void nSetBitmapWithCallback(long nativeTexture, long nativeEngine,
|
||||
int level, int xoffset, int yoffset, int width, int height, Bitmap bitmap, int format,
|
||||
Object handler, Runnable callback);
|
||||
}
|
||||
|
||||
@@ -454,7 +454,12 @@ public class UiHelper {
|
||||
public void onSurfaceTextureSizeChanged(
|
||||
SurfaceTexture surfaceTexture, int width, int height) {
|
||||
if (LOGGING) Log.d(LOG_TAG, "onSurfaceTextureSizeChanged()");
|
||||
mRenderCallback.onResized(width, height);
|
||||
if (mDesiredWidth > 0 && mDesiredHeight > 0) {
|
||||
surfaceTexture.setDefaultBufferSize(mDesiredWidth, mDesiredHeight);
|
||||
mRenderCallback.onResized(mDesiredWidth, mDesiredHeight);
|
||||
} else {
|
||||
mRenderCallback.onResized(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -2,61 +2,16 @@ cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
|
||||
set(DISABLE_GLTFIO_JNI TRUE)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../gltfio-android ${CMAKE_CURRENT_BINARY_DIR}/gltfio-android)
|
||||
|
||||
add_library(filament STATIC IMPORTED)
|
||||
set_target_properties(filament PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilament.a)
|
||||
|
||||
add_library(backend STATIC IMPORTED)
|
||||
set_target_properties(backend PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbackend.a)
|
||||
|
||||
add_library(camutils STATIC IMPORTED)
|
||||
set_target_properties(camutils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libcamutils.a)
|
||||
|
||||
add_library(utils STATIC IMPORTED)
|
||||
set_target_properties(utils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a)
|
||||
|
||||
add_library(filaflat STATIC IMPORTED)
|
||||
set_target_properties(filaflat PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilaflat.a)
|
||||
|
||||
add_library(image STATIC IMPORTED)
|
||||
set_target_properties(image PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libimage.a)
|
||||
|
||||
add_library(ibl STATIC IMPORTED)
|
||||
set_target_properties(ibl PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libibl.a)
|
||||
|
||||
add_library(geometry STATIC IMPORTED)
|
||||
set_target_properties(geometry PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgeometry.a)
|
||||
|
||||
add_library(filabridge STATIC IMPORTED)
|
||||
set_target_properties(filabridge PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilabridge.a)
|
||||
|
||||
add_library(gltfio STATIC IMPORTED)
|
||||
set_target_properties(gltfio PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_core.a)
|
||||
|
||||
add_library(gltfio_resources STATIC IMPORTED)
|
||||
set_target_properties(gltfio_resources PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_resources.a)
|
||||
|
||||
add_library(bluevk STATIC IMPORTED)
|
||||
set_target_properties(bluevk PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbluevk.a)
|
||||
|
||||
add_library(smol-v STATIC IMPORTED)
|
||||
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
|
||||
|
||||
include_directories(${FILAMENT_DIR}/include
|
||||
..
|
||||
../../libs/utils/include)
|
||||
@@ -70,9 +25,6 @@ add_library(filament-utils-jni SHARED
|
||||
|
||||
../common/CallbackUtils.cpp
|
||||
../common/NioUtils.cpp
|
||||
|
||||
$<TARGET_OBJECTS:gltfio-jni-obj>
|
||||
$<TARGET_OBJECTS:filament-jni-obj>
|
||||
)
|
||||
|
||||
set_target_properties(filament-utils-jni PROPERTIES LINK_DEPENDS
|
||||
@@ -80,25 +32,7 @@ set_target_properties(filament-utils-jni PROPERTIES LINK_DEPENDS
|
||||
|
||||
# The ordering in the following list is important because CMake does not have dependency information.
|
||||
target_link_libraries(filament-utils-jni
|
||||
gltfio
|
||||
filament
|
||||
backend
|
||||
filaflat
|
||||
filabridge
|
||||
gltfio-jni
|
||||
camutils
|
||||
geometry
|
||||
image
|
||||
ibl
|
||||
utils
|
||||
log
|
||||
GLESv3
|
||||
EGL
|
||||
android
|
||||
jnigraphics
|
||||
gltfio_resources
|
||||
m
|
||||
)
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
target_link_libraries(filament-utils-jni bluevk smol-v)
|
||||
endif()
|
||||
|
||||
@@ -1,44 +1,43 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-android-extensions'
|
||||
|
||||
android {
|
||||
buildToolsVersion versions.buildTools
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
minSdkVersion versions.minSdk
|
||||
targetSdkVersion versions.targetSdk
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-${versions.targetSdk}".toString())
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filamentPath}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
if (project.hasProperty('extra_cmake_args')) {
|
||||
arguments.add(extra_cmake_args)
|
||||
}
|
||||
}
|
||||
flavorDimensions "functionality"
|
||||
productFlavors {
|
||||
full {
|
||||
dimension "functionality"
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
lite {
|
||||
dimension "functionality"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
kotlin.srcDirs += "src/main/java"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
// No need to package up the following shared libs, which arise as a side effect of our
|
||||
// externalNativeBuild dependencies. When clients pick and choose from project-level gradle
|
||||
// dependencies, these shared libs already get pulled in, so we need to avoid the error:
|
||||
// "More than one file was found with OS independent path ..."
|
||||
packagingOptions {
|
||||
exclude 'lib/*/libfilament-jni.so'
|
||||
exclude 'lib/*/libgltfio-jni.so'
|
||||
}
|
||||
}
|
||||
|
||||
configurations.all { config ->
|
||||
// Hack to preserve the version of the dependencies
|
||||
if (!config.name.endsWith('Publication')) {
|
||||
resolutionStrategy {
|
||||
dependencySubstitution {
|
||||
substitute(module("com.google.android.filament:gltfio-android:${VERSION_NAME}")).with(project(":gltfio-android"))
|
||||
substitute(module("com.google.android.filament:gltfio-android-lite:${VERSION_NAME}")).with(project(":gltfio-android"))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,17 +45,27 @@ dependencies {
|
||||
implementation deps.kotlin
|
||||
implementation deps.androidx.annotations
|
||||
implementation project(':filament-android')
|
||||
implementation project(':gltfio-android')
|
||||
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.3'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.3'
|
||||
|
||||
fullImplementation module("com.google.android.filament:gltfio-android:${VERSION_NAME}")
|
||||
liteImplementation module("com.google.android.filament:gltfio-android-lite:${VERSION_NAME}")
|
||||
}
|
||||
|
||||
apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
|
||||
|
||||
afterEvaluate { project ->
|
||||
afterEvaluate {
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
artifactId = POM_ARTIFACT_ID
|
||||
from components.release
|
||||
fullRelease(MavenPublication) {
|
||||
artifactId = POM_ARTIFACT_ID_FULL
|
||||
from components.fullRelease
|
||||
}
|
||||
|
||||
liteRelease(MavenPublication) {
|
||||
artifactId = POM_ARTIFACT_ID_LITE
|
||||
from components.liteRelease
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
POM_NAME=Filament Android Utilities
|
||||
POM_ARTIFACT_ID=filament-utils-android
|
||||
POM_ARTIFACT_ID_FULL=filament-utils-android
|
||||
POM_ARTIFACT_ID_LITE=filament-utils-android-lite
|
||||
POM_PACKAGING=aar
|
||||
|
||||
@@ -90,6 +90,36 @@ extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBu
|
||||
builder->mapMinDistance(arg);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBuilderFlightStartPosition(JNIEnv*, jclass, jlong nativeBuilder, jfloat x, jfloat y, jfloat z) {
|
||||
Builder* builder = (Builder*) nativeBuilder;
|
||||
builder->flightStartPosition(x, y, z);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBuilderFlightStartOrientation(JNIEnv*, jclass, jlong nativeBuilder, jfloat pitch, jfloat yaw) {
|
||||
Builder* builder = (Builder*) nativeBuilder;
|
||||
builder->flightStartOrientation(pitch, yaw);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBuilderFlightMaxMoveSpeed(JNIEnv*, jclass, jlong nativeBuilder, jfloat maxSpeed) {
|
||||
Builder* builder = (Builder*) nativeBuilder;
|
||||
builder->flightMaxMoveSpeed(maxSpeed);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBuilderFlightSpeedSteps(JNIEnv*, jclass, jlong nativeBuilder, jint steps) {
|
||||
Builder* builder = (Builder*) nativeBuilder;
|
||||
builder->flightSpeedSteps(steps);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBuilderFlightPanSpeed(JNIEnv*, jclass, jlong nativeBuilder, jfloat x, jfloat y) {
|
||||
Builder* builder = (Builder*) nativeBuilder;
|
||||
builder->flightPanSpeed(x, y);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBuilderFlightMoveDamping(JNIEnv*, jclass, jlong nativeBuilder, jfloat damping) {
|
||||
Builder* builder = (Builder*) nativeBuilder;
|
||||
builder->flightMoveDamping(damping);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void Java_com_google_android_filament_utils_Manipulator_nBuilderGroundPlane(JNIEnv*, jclass, jlong nativeBuilder, jfloat a, jfloat b, jfloat c, jfloat d) {
|
||||
Builder* builder = (Builder*) nativeBuilder;
|
||||
builder->groundPlane(a, b, c, d);
|
||||
@@ -170,9 +200,24 @@ extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_utils_Manipul
|
||||
manip->grabEnd();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_utils_Manipulator_nZoom(JNIEnv*, jclass, jlong nativeManip, jint x, jint y, jfloat scrolldelta) {
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_utils_Manipulator_nKeyDown(JNIEnv*, jclass, jlong nativeManip, jint key) {
|
||||
auto manip = (Manipulator<float>*) nativeManip;
|
||||
manip->zoom(x, y, scrolldelta);
|
||||
manip->keyDown((Manipulator<float>::Key) key);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_utils_Manipulator_nKeyUp(JNIEnv*, jclass, jlong nativeManip, jint key) {
|
||||
auto manip = (Manipulator<float>*) nativeManip;
|
||||
manip->keyUp((Manipulator<float>::Key) key);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_utils_Manipulator_nScroll(JNIEnv*, jclass, jlong nativeManip, jint x, jint y, jfloat scrolldelta) {
|
||||
auto manip = (Manipulator<float>*) nativeManip;
|
||||
manip->scroll(x, y, scrolldelta);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL Java_com_google_android_filament_utils_Manipulator_nUpdate(JNIEnv*, jclass, jlong nativeManip, jfloat deltaTime) {
|
||||
auto manip = (Manipulator<float>*) nativeManip;
|
||||
manip->update(deltaTime);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL Java_com_google_android_filament_utils_Manipulator_nGetCurrentBookmark(JNIEnv*, jclass, jlong nativeManip) {
|
||||
|
||||
@@ -28,23 +28,7 @@ using namespace filament;
|
||||
using namespace filament::math;
|
||||
using namespace image;
|
||||
|
||||
extern void registerCallbackUtils(JNIEnv*);
|
||||
extern void registerNioUtils(JNIEnv*);
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
registerCallbackUtils(env);
|
||||
registerNioUtils(env);
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_utils_KtxLoader_nCreateTexture(JNIEnv* env, jclass,
|
||||
static jlong nCreateTexture(JNIEnv* env, jclass,
|
||||
jlong nativeEngine, jobject javaBuffer, jint remaining, jboolean srgb) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
@@ -55,8 +39,7 @@ Java_com_google_android_filament_utils_KtxLoader_nCreateTexture(JNIEnv* env, jcl
|
||||
}, bundle);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_utils_KtxLoader_nCreateIndirectLight(JNIEnv* env, jclass,
|
||||
static jlong nCreateIndirectLight(JNIEnv* env, jclass,
|
||||
jlong nativeEngine, jobject javaBuffer, jint remaining, jboolean srgb) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
@@ -78,8 +61,7 @@ Java_com_google_android_filament_utils_KtxLoader_nCreateIndirectLight(JNIEnv* en
|
||||
return (jlong) indirectLight;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_utils_KtxLoader_nCreateSkybox(JNIEnv* env, jclass,
|
||||
static jlong nCreateSkybox(JNIEnv* env, jclass,
|
||||
jlong nativeEngine, jobject javaBuffer, jint remaining, jboolean srgb) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
@@ -90,3 +72,24 @@ Java_com_google_android_filament_utils_KtxLoader_nCreateSkybox(JNIEnv* env, jcla
|
||||
}, bundle);
|
||||
return (jlong) Skybox::Builder().environment(cubemap).showSun(true).build(*engine);
|
||||
}
|
||||
|
||||
|
||||
JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
jclass c = env->FindClass("com/google/android/filament/utils/KtxLoader");
|
||||
if (c == nullptr) return JNI_ERR;
|
||||
|
||||
static const JNINativeMethod methods[] = {
|
||||
{"nCreateTexture", "(JLjava/nio/Buffer;IZ)J", reinterpret_cast<void*>(nCreateTexture)},
|
||||
{"nCreateIndirectLight", "(JLjava/nio/Buffer;IZ)J", reinterpret_cast<void*>(nCreateIndirectLight)},
|
||||
{"nCreateSkybox", "(JLjava/nio/Buffer;IZ)J", reinterpret_cast<void*>(nCreateSkybox)},
|
||||
};
|
||||
int rc = env->RegisterNatives(c, methods, sizeof(methods) / sizeof(JNINativeMethod));
|
||||
if (rc != JNI_OK) return rc;
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ class GestureDetector(private val view: View, private val manipulator: Manipulat
|
||||
if (currentGesture == Gesture.ZOOM) {
|
||||
val d0 = previousTouch.separation
|
||||
val d1 = touch.separation
|
||||
manipulator.zoom(touch.x, touch.y, (d0 - d1) * kZoomSpeed)
|
||||
manipulator.scroll(touch.x, touch.y, (d0 - d1) * kZoomSpeed)
|
||||
previousTouch = touch
|
||||
return
|
||||
}
|
||||
|
||||
@@ -42,10 +42,10 @@ object KtxLoader {
|
||||
* @param options Loader options.
|
||||
* @return The resulting Filament texture, or null on failure.
|
||||
*/
|
||||
fun createTexture(engine: Engine, buffer: Buffer, options: Options): Texture {
|
||||
fun createTexture(engine: Engine, buffer: Buffer, options: Options = Options()): Texture {
|
||||
val nativeEngine = engine.nativeObject
|
||||
val nativeTexture = nCreateTexture(nativeEngine, buffer, buffer.remaining(), options.srgb)
|
||||
return Texture(nativeTexture)
|
||||
return Texture(engine, nativeTexture)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,10 +56,10 @@ object KtxLoader {
|
||||
* @param options Loader options.
|
||||
* @return The resulting Filament texture, or null on failure.
|
||||
*/
|
||||
fun createIndirectLight(engine: Engine, buffer: Buffer, options: Options): IndirectLight {
|
||||
fun createIndirectLight(engine: Engine, buffer: Buffer, options: Options = Options()): IndirectLight {
|
||||
val nativeEngine = engine.nativeObject
|
||||
val nativeIndirectLight = nCreateIndirectLight(nativeEngine, buffer, buffer.remaining(), options.srgb)
|
||||
return IndirectLight(nativeIndirectLight)
|
||||
return IndirectLight(engine, nativeIndirectLight)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -70,10 +70,10 @@ object KtxLoader {
|
||||
* @param options Loader options.
|
||||
* @return The resulting Filament texture, or null on failure.
|
||||
*/
|
||||
fun createSkybox(engine: Engine, buffer: Buffer, options: Options): Skybox {
|
||||
fun createSkybox(engine: Engine, buffer: Buffer, options: Options = Options()): Skybox {
|
||||
val nativeEngine = engine.nativeObject
|
||||
val nativeSkybox = nCreateSkybox(nativeEngine, buffer, buffer.remaining(), options.srgb)
|
||||
return Skybox(nativeSkybox)
|
||||
return Skybox(engine, nativeSkybox)
|
||||
}
|
||||
|
||||
private external fun nCreateTexture(nativeEngine: Long, buffer: Buffer, remaining: Int, srgb: Boolean): Long
|
||||
|
||||
@@ -25,8 +25,9 @@ import androidx.annotation.Size;
|
||||
* Helper that enables camera interaction similar to sketchfab or Google Maps.
|
||||
*
|
||||
* Clients notify the camera manipulator of various mouse or touch events, then periodically call
|
||||
* its getLookAt() method so that they can adjust their camera(s). Two modes are supported: ORBIT
|
||||
* and MAP. To construct a manipulator instance, the desired mode is passed into the create method.
|
||||
* its getLookAt() method so that they can adjust their camera(s). Three modes are supported: ORBIT,
|
||||
* MAP, and FREE_FLIGHT. To construct a manipulator instance, the desired mode is passed into the
|
||||
* create method.
|
||||
*
|
||||
* @see Bookmark
|
||||
*/
|
||||
@@ -37,10 +38,24 @@ public class Manipulator {
|
||||
mNativeObject = nativeIndexBuffer;
|
||||
}
|
||||
|
||||
public enum Mode { ORBIT, MAP };
|
||||
public enum Mode { ORBIT, MAP, FREE_FLIGHT };
|
||||
|
||||
public enum Fov { VERTICAL, HORIZONTAL };
|
||||
|
||||
/**
|
||||
* Keys used to translate the camera in FREE_FLIGHT mode.
|
||||
* UP and DOWN dolly the camera forwards and backwards.
|
||||
* LEFT and RIGHT strafe the camera left and right.
|
||||
*/
|
||||
public enum Key {
|
||||
FORWARD,
|
||||
LEFT,
|
||||
BACKWARD,
|
||||
RIGHT,
|
||||
UP,
|
||||
DOWN
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
@SuppressWarnings({"FieldCanBeLocal", "UnusedDeclaration"})
|
||||
// Keep to finalize native resources
|
||||
@@ -178,6 +193,72 @@ public class Manipulator {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the initial eye position in world space for FREE_FLIGHT mode. Defaults to (0,0,0).
|
||||
*
|
||||
* @return this <code>Builder</code> object for chaining calls
|
||||
*/
|
||||
public Builder flightStartPosition(float x, float y, float z) {
|
||||
nFlightStartPosition(mNativeBuilder, x, y, z);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the initial orientation in pitch and yaw for FREE_FLIGHT mode. Defaults to (0,0).
|
||||
*
|
||||
* @return this <code>Builder</code> object for chaining calls
|
||||
*/
|
||||
public Builder flightStartOrientation(float pitch, float yaw) {
|
||||
nFlightStartOrientation(mNativeBuilder, pitch, yaw);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the maximum camera translation speed in world units per second for FREE_FLIGHT mode.
|
||||
* Defaults to 10.
|
||||
*
|
||||
* @return this <code>Builder</code> object for chaining calls
|
||||
*/
|
||||
public Builder flightMaxMoveSpeed(float maxSpeed) {
|
||||
nFlightMaxMoveSpeed(mNativeBuilder, maxSpeed);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the number of speed steps adjustable with scroll wheel for FREE_FLIGHT mode.
|
||||
* Defaults to 80.
|
||||
*
|
||||
* @return this <code>Builder</code> object for chaining calls
|
||||
*/
|
||||
public Builder flightSpeedSteps(int steps) {
|
||||
nFlightSpeedSteps(mNativeBuilder, steps);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the multiplier with viewport delta for FREE_FLIGHT mode.
|
||||
* This defaults to 0.01.
|
||||
*
|
||||
* @return this <code>Builder</code> object for chaining calls
|
||||
*/
|
||||
public Builder flightPanSpeed(float x, float y) {
|
||||
nFlightPanSpeed(mNativeBuilder, x, y);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Applies a deceleration to camera movement in FREE_FLIGHT mode. Defaults to 0 (no damping).
|
||||
*
|
||||
* Lower values give slower damping times. A good default is 15.0. Too high a value may lead
|
||||
* to instability.
|
||||
*
|
||||
* @return this <code>Builder</code> object for chaining calls
|
||||
*/
|
||||
public Builder flightMoveDamping(float damping) {
|
||||
nFlightMoveDamping(mNativeBuilder, damping);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the ground plane equation used for ray casts.
|
||||
* This is a plane equation as in Ax + By + Cz + D = 0.
|
||||
@@ -281,11 +362,13 @@ public class Manipulator {
|
||||
/**
|
||||
* Starts a grabbing session (i.e. the user is dragging around in the viewport).
|
||||
*
|
||||
* This starts a panning session in MAP mode, and start either rotating or strafing in ORBIT.
|
||||
* In MAP mode, this starts a panning session.
|
||||
* In ORBIT mode, this starts either rotating or strafing.
|
||||
* In FREE_FLIGHT mode, this starts a nodal panning session.
|
||||
*
|
||||
* @param x X-coordinate for point of interest in viewport space
|
||||
* @param y Y-coordinate for point of interest in viewport space
|
||||
* @param strafe ORBIT mode only; if true, starts a translation rather than a rotation.
|
||||
* @param strafe ORBIT mode only; if true, starts a translation rather than a rotation
|
||||
*/
|
||||
public void grabBegin(int x, int y, boolean strafe) {
|
||||
nGrabBegin(mNativeObject, x, y, strafe);
|
||||
@@ -308,14 +391,46 @@ public class Manipulator {
|
||||
}
|
||||
|
||||
/**
|
||||
* Dollys the camera along the viewing direction.
|
||||
*
|
||||
* @param x X-coordinate for point of interest in viewport space
|
||||
* @param y Y-coordinate for point of interest in viewport space
|
||||
* @param scrolldelta Positive means "zoom in", negative means "zoom out"
|
||||
* Keys used to translate the camera in FREE_FLIGHT mode.
|
||||
* UP and DOWN dolly the camera forwards and backwards.
|
||||
* LEFT and RIGHT strafe the camera left and right.
|
||||
* UP and DOWN boom the camera upwards and downwards.
|
||||
*/
|
||||
public void zoom(int x, int y, float scrolldelta) {
|
||||
nZoom(mNativeObject, x, y, scrolldelta);
|
||||
public void keyDown(Key key) {
|
||||
nKeyDown(mNativeObject, key.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Signals that a key is now in the up state.
|
||||
*
|
||||
* @see keyDown
|
||||
*/
|
||||
public void keyUp(Key key) {
|
||||
nKeyUp(mNativeObject, key.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* In MAP and ORBIT modes, dollys the camera along the viewing direction.
|
||||
* In FREE_FLIGHT mode, adjusts the move speed of the camera.
|
||||
*
|
||||
* @param x X-coordinate for point of interest in viewport space, ignored in FREE_FLIGHT mode
|
||||
* @param y Y-coordinate for point of interest in viewport space, ignored in FREE_FLIGHT mode
|
||||
* @param scrolldelta In MAP and ORBIT modes, negative means "zoom in", positive means "zoom out"
|
||||
* In FREE_FLIGHT mode, negative means "slower", positive means "faster"
|
||||
*/
|
||||
public void scroll(int x, int y, float scrolldelta) {
|
||||
nScroll(mNativeObject, x, y, scrolldelta);
|
||||
}
|
||||
|
||||
/**
|
||||
* Processes input and updates internal state.
|
||||
*
|
||||
* This must be called once every frame before getLookAt is valid.
|
||||
*
|
||||
* @param deltaTime The amount of time, in seconds, passed since the previous call to update.
|
||||
*/
|
||||
public void update(float deltaTime) {
|
||||
nUpdate(mNativeObject, deltaTime);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -359,6 +474,12 @@ public class Manipulator {
|
||||
private static native void nBuilderFarPlane(long nativeBuilder, float distance);
|
||||
private static native void nBuilderMapExtent(long nativeBuilder, float width, float height);
|
||||
private static native void nBuilderMapMinDistance(long nativeBuilder, float arg);
|
||||
private static native void nFlightStartPosition(long nativeBuilder, float x, float y, float z);
|
||||
private static native void nFlightStartOrientation(long nativeBuilder, float pitch, float yaw);
|
||||
private static native void nFlightMaxMoveSpeed(long nativeBuilder, float maxSpeed);
|
||||
private static native void nFlightSpeedSteps(long nativeBuilder, int steps);
|
||||
private static native void nFlightPanSpeed(long nativeBuilder, float x, float y);
|
||||
private static native void nFlightMoveDamping(long nativeBuilder, float damping);
|
||||
private static native void nBuilderGroundPlane(long nativeBuilder, float a, float b, float c, float d);
|
||||
private static native long nBuilderBuild(long nativeBuilder, int mode);
|
||||
|
||||
@@ -371,7 +492,10 @@ public class Manipulator {
|
||||
private static native void nGrabBegin(long nativeManip, int x, int y, boolean strafe);
|
||||
private static native void nGrabUpdate(long nativeManip, int x, int y);
|
||||
private static native void nGrabEnd(long nativeManip);
|
||||
private static native void nZoom(long nativeManip, int x, int y, float scrolldelta);
|
||||
private static native void nKeyDown(long nativeManip, int key);
|
||||
private static native void nKeyUp(long nativeManip, int key);
|
||||
private static native void nScroll(long nativeManip, int x, int y, float scrolldelta);
|
||||
private static native void nUpdate(long nativeManip, float deltaTime);
|
||||
private static native long nGetCurrentBookmark(long nativeManip);
|
||||
private static native long nGetHomeBookmark(long nativeManip);
|
||||
private static native void nJumpToBookmark(long nativeManip, long nativeBookmark);
|
||||
|
||||
@@ -21,10 +21,19 @@ import android.view.Surface
|
||||
import android.view.SurfaceView
|
||||
import android.view.TextureView
|
||||
import com.google.android.filament.*
|
||||
import com.google.android.filament.android.DisplayHelper
|
||||
import com.google.android.filament.android.UiHelper
|
||||
import com.google.android.filament.gltfio.*
|
||||
import kotlinx.coroutines.*
|
||||
import java.nio.Buffer
|
||||
|
||||
private const val kNearPlane = 0.5
|
||||
private const val kFarPlane = 10000.0
|
||||
private const val kFovDegrees = 45.0
|
||||
private const val kAperture = 16f
|
||||
private const val kShutterSpeed = 1f / 125f
|
||||
private const val kSensitivity = 100f
|
||||
|
||||
/**
|
||||
* Helps render glTF models into a [SurfaceView] or [TextureView] with an orbit controller.
|
||||
*
|
||||
@@ -41,7 +50,8 @@ import java.nio.Buffer
|
||||
* clients still have the responsibility of adding an [IndirectLight] and [Skybox] to the scene.
|
||||
* Additionally, clients should:
|
||||
*
|
||||
* 1. Call [onTouchEvent] from a touch handler.
|
||||
* 1. Pass the model viewer into [SurfaceView.setOnTouchListener] or call its [onTouchEvent]
|
||||
* method from your touch handler.
|
||||
* 2. Call [render] and [Animator.applyAnimation] from a `Choreographer` frame callback.
|
||||
*
|
||||
* NOTE: if its associated SurfaceView or TextureView has become detached from its window, the
|
||||
@@ -49,40 +59,45 @@ import java.nio.Buffer
|
||||
*
|
||||
* See `sample-gltf-viewer` for a usage example.
|
||||
*/
|
||||
class ModelViewer {
|
||||
|
||||
class ModelViewer(val engine: Engine) : android.view.View.OnTouchListener {
|
||||
var asset: FilamentAsset? = null
|
||||
private set
|
||||
|
||||
var animator: Animator? = null
|
||||
private set
|
||||
|
||||
val engine: Engine
|
||||
@Suppress("unused")
|
||||
val progress
|
||||
get() = resourceLoader.asyncGetLoadProgress()
|
||||
|
||||
var normalizeSkinningWeights = true
|
||||
var recomputeBoundingBoxes = false
|
||||
|
||||
val scene: Scene
|
||||
val view: View
|
||||
val camera: Camera
|
||||
@Entity val light: Int
|
||||
|
||||
private val uiHelper: UiHelper = UiHelper(UiHelper.ContextErrorPolicy.DONT_CHECK)
|
||||
private val cameraManipulator: Manipulator
|
||||
private val gestureDetector: GestureDetector
|
||||
private lateinit var displayHelper: DisplayHelper
|
||||
private lateinit var cameraManipulator: Manipulator
|
||||
private lateinit var gestureDetector: GestureDetector
|
||||
private var surfaceView: SurfaceView? = null
|
||||
private var textureView: TextureView? = null
|
||||
|
||||
private var fetchResourcesJob: Job? = null
|
||||
|
||||
private val renderer: Renderer
|
||||
private var swapChain: SwapChain? = null
|
||||
private var assetLoader: AssetLoader
|
||||
private var resourceLoader: ResourceLoader
|
||||
private val readyRenderables = IntArray(128) // add up to 128 entities at a time
|
||||
|
||||
private val eyePos = DoubleArray(3)
|
||||
private val target = DoubleArray(3)
|
||||
private val upward = DoubleArray(3)
|
||||
|
||||
private val kNearPlane = 0.5
|
||||
private val kFarPlane = 10000.0
|
||||
private val kFovDegrees = 45.0
|
||||
private val kAperture = 16f
|
||||
private val kShutterSpeed = 1f / 125f
|
||||
private val kSensitivity = 100f
|
||||
|
||||
init {
|
||||
engine = Engine.create()
|
||||
renderer = engine.createRenderer()
|
||||
scene = engine.createScene()
|
||||
camera = engine.createCamera().apply { setExposure(kAperture, kShutterSpeed, kSensitivity) }
|
||||
@@ -91,6 +106,7 @@ class ModelViewer {
|
||||
view.camera = camera
|
||||
|
||||
assetLoader = AssetLoader(engine, MaterialProvider(engine), EntityManager.get())
|
||||
resourceLoader = ResourceLoader(engine, normalizeSkinningWeights, recomputeBoundingBoxes)
|
||||
|
||||
// Always add a direct light source since it is required for shadowing.
|
||||
// We highly recommend adding an indirect light as well.
|
||||
@@ -100,7 +116,7 @@ class ModelViewer {
|
||||
val (r, g, b) = Colors.cct(6_500.0f)
|
||||
LightManager.Builder(LightManager.Type.DIRECTIONAL)
|
||||
.color(r, g, b)
|
||||
.intensity(300_000.0f)
|
||||
.intensity(100_000.0f)
|
||||
.direction(0.0f, -1.0f, 0.0f)
|
||||
.castShadows(true)
|
||||
.build(engine, light)
|
||||
@@ -108,26 +124,30 @@ class ModelViewer {
|
||||
scene.addEntity(light)
|
||||
}
|
||||
|
||||
constructor(surfaceView: SurfaceView) {
|
||||
cameraManipulator = Manipulator.Builder()
|
||||
.targetPosition(0.0f, 0.0f, -4.0f)
|
||||
constructor(surfaceView: SurfaceView, engine: Engine = Engine.create(), manipulator: Manipulator? = null) : this(engine) {
|
||||
cameraManipulator = manipulator ?: Manipulator.Builder()
|
||||
.targetPosition(kDefaultObjectPosition.x, kDefaultObjectPosition.y, kDefaultObjectPosition.z)
|
||||
.viewport(surfaceView.width, surfaceView.height)
|
||||
.build(Manipulator.Mode.ORBIT)
|
||||
|
||||
this.surfaceView = surfaceView
|
||||
gestureDetector = GestureDetector(surfaceView, cameraManipulator)
|
||||
displayHelper = DisplayHelper(surfaceView.context)
|
||||
uiHelper.renderCallback = SurfaceCallback()
|
||||
uiHelper.attachTo(surfaceView)
|
||||
addDetachListener(surfaceView)
|
||||
}
|
||||
|
||||
@Suppress("unused")
|
||||
constructor(textureView: TextureView) {
|
||||
cameraManipulator = Manipulator.Builder()
|
||||
.targetPosition(0.0f, 0.0f, -4.0f)
|
||||
constructor(textureView: TextureView, engine: Engine = Engine.create(), manipulator: Manipulator? = null) : this(engine) {
|
||||
cameraManipulator = manipulator ?: Manipulator.Builder()
|
||||
.targetPosition(kDefaultObjectPosition.x, kDefaultObjectPosition.y, kDefaultObjectPosition.z)
|
||||
.viewport(textureView.width, textureView.height)
|
||||
.build(Manipulator.Mode.ORBIT)
|
||||
|
||||
this.textureView = textureView
|
||||
gestureDetector = GestureDetector(textureView, cameraManipulator)
|
||||
displayHelper = DisplayHelper(textureView.context)
|
||||
uiHelper.renderCallback = SurfaceCallback()
|
||||
uiHelper.attachTo(textureView)
|
||||
addDetachListener(textureView)
|
||||
@@ -138,48 +158,59 @@ class ModelViewer {
|
||||
*/
|
||||
fun loadModelGlb(buffer: Buffer) {
|
||||
destroyModel()
|
||||
asset = assetLoader.createAssetFromJson(buffer)
|
||||
asset = assetLoader.createAssetFromBinary(buffer)
|
||||
asset?.let { asset ->
|
||||
val resourceLoader = ResourceLoader(engine)
|
||||
resourceLoader.loadResources(asset)
|
||||
resourceLoader.destroy()
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.animator
|
||||
asset.releaseSourceData()
|
||||
scene.addEntities(asset.entities)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a JSON-style glTF file and populates the Filament scene.
|
||||
*
|
||||
* The given callback is triggered for each requested resource.
|
||||
*/
|
||||
fun loadModelGltf(buffer: Buffer, callback: (String) -> Buffer) {
|
||||
destroyModel()
|
||||
asset = assetLoader.createAssetFromJson(buffer)
|
||||
asset?.let { asset ->
|
||||
val resourceLoader = ResourceLoader(engine)
|
||||
for (uri in asset.resourceUris) {
|
||||
resourceLoader.addResourceData(uri, callback(uri))
|
||||
}
|
||||
resourceLoader.loadResources(asset)
|
||||
resourceLoader.destroy()
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.animator
|
||||
asset.releaseSourceData()
|
||||
scene.addEntities(asset.entities)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a root transform on the current model to make it fit into the viewing frustum.
|
||||
* Loads a JSON-style glTF file and populates the Filament scene.
|
||||
*
|
||||
* The given callback is triggered from a worker thread for each requested resource.
|
||||
*/
|
||||
fun transformToUnitCube() {
|
||||
fun loadModelGltfAsync(buffer: Buffer, callback: (String) -> Buffer) {
|
||||
destroyModel()
|
||||
asset = assetLoader.createAssetFromJson(buffer)
|
||||
fetchResourcesJob = CoroutineScope(Dispatchers.IO).launch {
|
||||
fetchResources(asset!!, callback)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets up a root transform on the current model to make it fit into a unit cube.
|
||||
*
|
||||
* @param centerPoint Coordinate of center point of unit cube, defaults to < 0, 0, -4 >
|
||||
*/
|
||||
fun transformToUnitCube(centerPoint: Float3 = kDefaultObjectPosition) {
|
||||
asset?.let { asset ->
|
||||
val tm = engine.transformManager
|
||||
val center = asset.boundingBox.center.let { v-> Float3(v[0], v[1], v[2]) }
|
||||
var center = asset.boundingBox.center.let { v-> Float3(v[0], v[1], v[2]) }
|
||||
val halfExtent = asset.boundingBox.halfExtent.let { v-> Float3(v[0], v[1], v[2]) }
|
||||
val maxExtent = 2.0f * max(halfExtent)
|
||||
val scaleFactor = 2.0f / maxExtent
|
||||
center.z = center.z + 4.0f / scaleFactor
|
||||
val transform = scale(Float3(scaleFactor)) * translation(Float3(-center))
|
||||
center -= centerPoint / scaleFactor
|
||||
val transform = scale(Float3(scaleFactor)) * translation(-center)
|
||||
tm.setTransform(tm.getInstance(asset.root), transpose(transform).toFloatArray())
|
||||
}
|
||||
}
|
||||
@@ -188,7 +219,9 @@ class ModelViewer {
|
||||
* Frees all entities associated with the most recently-loaded model.
|
||||
*/
|
||||
fun destroyModel() {
|
||||
fetchResourcesJob?.cancel()
|
||||
asset?.let { asset ->
|
||||
this.scene.removeEntities(asset.entities)
|
||||
assetLoader.destroyAsset(asset)
|
||||
this.asset = null
|
||||
this.animator = null
|
||||
@@ -197,24 +230,44 @@ class ModelViewer {
|
||||
|
||||
/**
|
||||
* Renders the model and updates the Filament camera.
|
||||
*
|
||||
* @param frameTimeNanos time in nanoseconds when the frame started being rendered,
|
||||
* typically comes from {@link android.view.Choreographer.FrameCallback}
|
||||
*/
|
||||
fun render() {
|
||||
fun render(frameTimeNanos: Long) {
|
||||
if (!uiHelper.isReadyToRender) {
|
||||
return
|
||||
}
|
||||
|
||||
// Allow the resource loader to finalize textures that have become ready.
|
||||
resourceLoader.asyncUpdateLoad()
|
||||
|
||||
// Add renderable entities to the scene as they become ready.
|
||||
asset?.let { populateScene(it) }
|
||||
|
||||
// Extract the camera basis from the helper and push it to the Filament camera.
|
||||
cameraManipulator.getLookAt(eyePos, target, upward)
|
||||
camera.lookAt(
|
||||
eyePos[0], eyePos[1], eyePos[2],
|
||||
target[0], target[1], target[2],
|
||||
upward[0], upward[1], upward[2])
|
||||
|
||||
if (renderer.beginFrame(swapChain!!)) {
|
||||
// Render the scene, unless the renderer wants to skip the frame.
|
||||
if (renderer.beginFrame(swapChain!!, frameTimeNanos)) {
|
||||
renderer.render(view)
|
||||
renderer.endFrame()
|
||||
}
|
||||
}
|
||||
|
||||
private fun populateScene(asset: FilamentAsset) {
|
||||
var count = 0
|
||||
val popRenderables = {count = asset.popRenderables(readyRenderables); count != 0}
|
||||
while (popRenderables()) {
|
||||
scene.addEntities(readyRenderables.take(count).toIntArray())
|
||||
}
|
||||
scene.addEntities(asset.lightEntities)
|
||||
}
|
||||
|
||||
private fun addDetachListener(view: android.view.View) {
|
||||
view.addOnAttachStateChangeListener(object : android.view.View.OnAttachStateChangeListener {
|
||||
override fun onViewAttachedToWindow(v: android.view.View?) {}
|
||||
@@ -223,6 +276,7 @@ class ModelViewer {
|
||||
|
||||
destroyModel()
|
||||
assetLoader.destroy()
|
||||
resourceLoader.destroy()
|
||||
|
||||
engine.destroyEntity(light)
|
||||
engine.destroyRenderer(renderer)
|
||||
@@ -244,13 +298,39 @@ class ModelViewer {
|
||||
gestureDetector.onTouchEvent(event)
|
||||
}
|
||||
|
||||
@SuppressWarnings("ClickableViewAccessibility")
|
||||
override fun onTouch(view: android.view.View, event: MotionEvent): Boolean {
|
||||
onTouchEvent(event)
|
||||
return true
|
||||
}
|
||||
|
||||
private suspend fun fetchResources(asset: FilamentAsset, callback: (String) -> Buffer) {
|
||||
val items = HashMap<String, Buffer>()
|
||||
val resourceUris = asset.resourceUris
|
||||
for (resourceUri in resourceUris) {
|
||||
items[resourceUri] = callback(resourceUri)
|
||||
}
|
||||
|
||||
withContext(Dispatchers.Main) {
|
||||
for ((uri, buffer) in items) {
|
||||
resourceLoader.addResourceData(uri, buffer)
|
||||
}
|
||||
resourceLoader.asyncBeginLoad(asset)
|
||||
animator = asset.animator
|
||||
asset.releaseSourceData()
|
||||
}
|
||||
}
|
||||
|
||||
inner class SurfaceCallback : UiHelper.RendererCallback {
|
||||
override fun onNativeWindowChanged(surface: Surface) {
|
||||
swapChain?.let { engine.destroySwapChain(it) }
|
||||
swapChain = engine.createSwapChain(surface)
|
||||
surfaceView?.let { displayHelper.attach(renderer, it.display) }
|
||||
textureView?.let { displayHelper.attach(renderer, it.display) }
|
||||
}
|
||||
|
||||
override fun onDetachedFromSurface() {
|
||||
displayHelper.detach()
|
||||
swapChain?.let {
|
||||
engine.destroySwapChain(it)
|
||||
engine.flushAndWait()
|
||||
@@ -265,4 +345,8 @@ class ModelViewer {
|
||||
cameraManipulator.setViewport(width, height)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private val kDefaultObjectPosition = Float3(0.0f, 0.0f, -4.0f)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ private fun format(bitmap: Bitmap) = when (bitmap.config.name) {
|
||||
|
||||
// Not required when SKIP_BITMAP_COPY is true
|
||||
private fun type(bitmap: Bitmap) = when (bitmap.config.name) {
|
||||
"ALPHA_8" -> Texture.Type.UBYTE
|
||||
"RGB_565" -> Texture.Type.UBYTE
|
||||
"ALPHA_8" -> Texture.Type.USHORT
|
||||
"RGB_565" -> Texture.Type.USHORT_565
|
||||
"ARGB_8888" -> Texture.Type.UBYTE
|
||||
"RGBA_F16" -> Texture.Type.HALF
|
||||
else -> throw IllegalArgumentException("Unsupported bitmap configuration")
|
||||
|
||||
@@ -14,13 +14,17 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.google.android.filament.utils;
|
||||
package com.google.android.filament.utils
|
||||
|
||||
import com.google.android.filament.Filament
|
||||
|
||||
object Utils {
|
||||
/**
|
||||
* Initializes the utils JNI layer. Must be called before using any utils functionality.
|
||||
*/
|
||||
fun init() {
|
||||
// Load Filament first to ensure that the NioUtils Java class is available in the JNIEnv.
|
||||
Filament.init()
|
||||
System.loadLibrary("filament-utils-jni")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,104 +1,96 @@
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
set(FILAMENT_DIR ${FILAMENT_DIST_DIR})
|
||||
set(GLTFIO_DIR ../../libs/gltfio)
|
||||
set(DRACO_DIR ../../third_party/draco)
|
||||
|
||||
set(DISABLE_FILAMENT_JNI TRUE)
|
||||
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../filament-android ${CMAKE_CURRENT_BINARY_DIR}/filament-android)
|
||||
|
||||
add_library(filament STATIC IMPORTED)
|
||||
set_target_properties(filament PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilament.a)
|
||||
|
||||
add_library(backend STATIC IMPORTED)
|
||||
set_target_properties(backend PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbackend.a)
|
||||
add_library(dracodec STATIC IMPORTED)
|
||||
set_target_properties(dracodec PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libdracodec.a)
|
||||
|
||||
add_library(utils STATIC IMPORTED)
|
||||
set_target_properties(utils PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libutils.a)
|
||||
|
||||
add_library(filaflat STATIC IMPORTED)
|
||||
set_target_properties(filaflat PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilaflat.a)
|
||||
|
||||
add_library(ibl STATIC IMPORTED)
|
||||
set_target_properties(ibl PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libibl.a)
|
||||
|
||||
add_library(geometry STATIC IMPORTED)
|
||||
set_target_properties(geometry PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgeometry.a)
|
||||
|
||||
add_library(filabridge STATIC IMPORTED)
|
||||
set_target_properties(filabridge PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libfilabridge.a)
|
||||
|
||||
add_library(gltfio STATIC IMPORTED)
|
||||
set_target_properties(gltfio PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_core.a)
|
||||
|
||||
add_library(gltfio_resources STATIC IMPORTED)
|
||||
set_target_properties(gltfio_resources PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_resources.a)
|
||||
|
||||
add_library(bluevk STATIC IMPORTED)
|
||||
set_target_properties(bluevk PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libbluevk.a)
|
||||
add_library(gltfio_resources_lite STATIC IMPORTED)
|
||||
set_target_properties(gltfio_resources_lite PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libgltfio_resources_lite.a)
|
||||
|
||||
add_library(smol-v STATIC IMPORTED)
|
||||
set_target_properties(smol-v PROPERTIES IMPORTED_LOCATION
|
||||
${FILAMENT_DIR}/lib/${ANDROID_ABI}/libsmol-v.a)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.map")
|
||||
|
||||
include_directories(${FILAMENT_DIR}/include
|
||||
..
|
||||
../../libs/utils/include)
|
||||
set(GLTFIO_SRCS
|
||||
${GLTFIO_DIR}/include/gltfio/Animator.h
|
||||
${GLTFIO_DIR}/include/gltfio/AssetLoader.h
|
||||
${GLTFIO_DIR}/include/gltfio/MaterialProvider.h
|
||||
${GLTFIO_DIR}/include/gltfio/ResourceLoader.h
|
||||
${GLTFIO_DIR}/include/gltfio/SimpleViewer.h
|
||||
${GLTFIO_DIR}/include/gltfio/FilamentAsset.h
|
||||
${GLTFIO_DIR}/include/gltfio/FilamentInstance.h
|
||||
|
||||
${GLTFIO_DIR}/src/Animator.cpp
|
||||
${GLTFIO_DIR}/src/AssetLoader.cpp
|
||||
${GLTFIO_DIR}/src/DracoCache.cpp
|
||||
${GLTFIO_DIR}/src/DracoCache.h
|
||||
${GLTFIO_DIR}/src/DependencyGraph.cpp
|
||||
${GLTFIO_DIR}/src/DependencyGraph.h
|
||||
${GLTFIO_DIR}/src/FFilamentAsset.h
|
||||
${GLTFIO_DIR}/src/FilamentAsset.cpp
|
||||
${GLTFIO_DIR}/src/FFilamentInstance.h
|
||||
${GLTFIO_DIR}/src/FilamentInstance.cpp
|
||||
${GLTFIO_DIR}/src/GltfEnums.h
|
||||
${GLTFIO_DIR}/src/MaterialProvider.cpp
|
||||
${GLTFIO_DIR}/src/ResourceLoader.cpp
|
||||
${GLTFIO_DIR}/src/UbershaderLoader.cpp
|
||||
${GLTFIO_DIR}/src/Wireframe.cpp
|
||||
${GLTFIO_DIR}/src/Wireframe.h
|
||||
${GLTFIO_DIR}/src/math.h
|
||||
${GLTFIO_DIR}/src/upcast.h
|
||||
${GLTFIO_DIR}/src/Image.cpp
|
||||
|
||||
add_library(gltfio-jni-obj OBJECT
|
||||
src/main/cpp/Animator.cpp
|
||||
src/main/cpp/AssetLoader.cpp
|
||||
src/main/cpp/FilamentAsset.cpp
|
||||
src/main/cpp/FilamentInstance.cpp
|
||||
src/main/cpp/MaterialProvider.cpp
|
||||
src/main/cpp/ResourceLoader.cpp)
|
||||
src/main/cpp/ResourceLoader.cpp
|
||||
|
||||
if (NOT DISABLE_GLTFIO_JNI)
|
||||
${FILAMENT_DIR}/include/gltfio/resources/gltfresources_lite.h
|
||||
${FILAMENT_DIR}/include/gltfio/resources/gltfresources.h
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.map")
|
||||
../common/NioUtils.cpp
|
||||
)
|
||||
|
||||
add_library(gltfio-jni SHARED
|
||||
$<TARGET_OBJECTS:gltfio-jni-obj>
|
||||
set(GLTFIO_INCLUDE_DIRS
|
||||
..
|
||||
${FILAMENT_DIR}/include
|
||||
${FILAMENT_DIR}/include/gltfio/resources
|
||||
../../third_party/cgltf
|
||||
../../third_party/robin-map
|
||||
../../third_party/hat-trie
|
||||
../../third_party/stb
|
||||
../../libs/utils/include
|
||||
)
|
||||
|
||||
src/main/cpp/Gltfio.cpp
|
||||
add_library(gltfio-jni SHARED ${GLTFIO_SRCS})
|
||||
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)
|
||||
|
||||
../common/CallbackUtils.cpp
|
||||
../common/NioUtils.cpp
|
||||
|
||||
$<TARGET_OBJECTS:filament-jni-obj>
|
||||
)
|
||||
|
||||
set_target_properties(gltfio-jni PROPERTIES LINK_DEPENDS
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/libgltfio-jni.symbols)
|
||||
|
||||
# The ordering in the following list is important because CMake does not have dependency information.
|
||||
target_link_libraries(gltfio-jni
|
||||
gltfio
|
||||
filament
|
||||
backend
|
||||
filaflat
|
||||
filabridge
|
||||
geometry
|
||||
ibl
|
||||
utils
|
||||
log
|
||||
GLESv3
|
||||
EGL
|
||||
android
|
||||
jnigraphics
|
||||
gltfio_resources
|
||||
m
|
||||
)
|
||||
|
||||
if (FILAMENT_SUPPORTS_VULKAN)
|
||||
target_link_libraries(gltfio-jni bluevk smol-v)
|
||||
endif()
|
||||
if(GLTFIO_LITE)
|
||||
target_compile_definitions(gltfio-jni PUBLIC GLTFIO_LITE=1)
|
||||
target_link_libraries(gltfio-jni filament-jni utils log gltfio_resources_lite)
|
||||
else()
|
||||
target_link_libraries(gltfio-jni filament-jni utils log gltfio_resources)
|
||||
|
||||
# Enable Draco in the non-lite variant of gltfio.
|
||||
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)
|
||||
endif()
|
||||
|
||||
@@ -1,41 +1,27 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
buildToolsVersion versions.buildTools
|
||||
compileSdkVersion versions.compileSdk
|
||||
defaultConfig {
|
||||
minSdkVersion versions.minSdk
|
||||
targetSdkVersion versions.targetSdk
|
||||
flavorDimensions "functionality"
|
||||
productFlavors {
|
||||
full {
|
||||
dimension "functionality"
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DANDROID_PIE=ON")
|
||||
arguments.add("-DANDROID_PLATFORM=android-${versions.targetSdk}".toString())
|
||||
arguments.add("-DANDROID_STL=c++_static")
|
||||
arguments.add("-DFILAMENT_DIST_DIR=${filamentPath}".toString())
|
||||
cppFlags.add("-std=c++14")
|
||||
if (project.hasProperty('extra_cmake_args')) {
|
||||
arguments.add(extra_cmake_args)
|
||||
lite {
|
||||
dimension "functionality"
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
arguments.add("-DGLTFIO_LITE=ON")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
externalNativeBuild {
|
||||
cmake {
|
||||
path "CMakeLists.txt"
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jni.srcDirs "src/main/cpp"
|
||||
}
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
// No need to package up the following shared libs, which arise as a side effect of our
|
||||
// externalNativeBuild dependencies. When clients pick and choose from project-level gradle
|
||||
// dependencies, these shared libs already get pulled in, so we need to avoid the error:
|
||||
// "More than one file was found with OS independent path ..."
|
||||
packagingOptions {
|
||||
exclude 'lib/*/libfilament-jni.so'
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,9 +35,14 @@ apply from: rootProject.file('gradle/gradle-mvn-push.gradle')
|
||||
afterEvaluate { project ->
|
||||
publishing {
|
||||
publications {
|
||||
release(MavenPublication) {
|
||||
artifactId = POM_ARTIFACT_ID
|
||||
from components.release
|
||||
fullRelease(MavenPublication) {
|
||||
artifactId = POM_ARTIFACT_ID_FULL
|
||||
from components.fullRelease
|
||||
}
|
||||
|
||||
liteRelease(MavenPublication) {
|
||||
artifactId = POM_ARTIFACT_ID_LITE
|
||||
from components.liteRelease
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
POM_NAME=Filament glTF Loader
|
||||
POM_ARTIFACT_ID=gltfio-android
|
||||
POM_ARTIFACT_ID_FULL=gltfio-android
|
||||
POM_ARTIFACT_ID_LITE=gltfio-android-lite
|
||||
POM_PACKAGING=aar
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
LIBGLTFIO {
|
||||
global: Java_com_google_android_filament_*; JNI*;
|
||||
global: Java_com_google_android_filament_*; *gltfio*; JNI*;
|
||||
local: *;
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <filament/Engine.h>
|
||||
|
||||
#include <utils/EntityManager.h>
|
||||
#include <utils/NameComponentManager.h>
|
||||
|
||||
#include <gltfio/AssetLoader.h>
|
||||
#include <gltfio/MaterialProvider.h>
|
||||
@@ -29,23 +30,23 @@ using namespace filament;
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
extern void registerCallbackUtils(JNIEnv*);
|
||||
extern void registerNioUtils(JNIEnv*);
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetLoader(JNIEnv*, jclass,
|
||||
jlong nativeEngine, jlong nativeProvider, jlong nativeEntities) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
MaterialProvider* materials = (MaterialProvider*) nativeProvider;
|
||||
EntityManager* entities = (EntityManager*) nativeEntities;
|
||||
return (jlong) AssetLoader::create({engine, materials, nullptr, entities});
|
||||
NameComponentManager* names = new NameComponentManager(*entities);
|
||||
return (jlong) AssetLoader::create({engine, materials, names, entities});
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nDestroyAssetLoader(JNIEnv*, jclass,
|
||||
jlong nativeLoader) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
NameComponentManager* names = loader->getNames();
|
||||
AssetLoader::destroy(&loader);
|
||||
delete names;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
@@ -66,6 +67,27 @@ Java_com_google_android_filament_gltfio_AssetLoader_nCreateAssetFromJson(JNIEnv*
|
||||
buffer.getSize());
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nCreateInstancedAsset(JNIEnv* env, jclass,
|
||||
jlong nativeLoader, jobject javaBuffer, jint remaining, jlongArray instances) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
AutoBuffer buffer(env, javaBuffer, remaining);
|
||||
jsize numInstances = env->GetArrayLength(instances);
|
||||
using Handle = FilamentInstance*;
|
||||
Handle* ptrInstances = new Handle[numInstances];
|
||||
jlong asset = (jlong) loader->createInstancedAsset((const uint8_t *) buffer.getData(),
|
||||
buffer.getSize(), ptrInstances, numInstances);
|
||||
if (asset) {
|
||||
jlong* longInstances = env->GetLongArrayElements(instances, nullptr);
|
||||
for (jsize i = 0; i < numInstances; i++) {
|
||||
longInstances[i] = (jlong) ptrInstances[i];
|
||||
}
|
||||
env->ReleaseLongArrayElements(instances, longInstances, 0);
|
||||
}
|
||||
delete[] ptrInstances;
|
||||
return asset;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nEnableDiagnostics(JNIEnv*, jclass,
|
||||
jlong nativeLoader, jboolean enable) {
|
||||
@@ -76,7 +98,7 @@ Java_com_google_android_filament_gltfio_AssetLoader_nEnableDiagnostics(JNIEnv*,
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_AssetLoader_nDestroyAsset(JNIEnv*, jclass,
|
||||
jlong nativeLoader, jlong nativeAsset) {
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
AssetLoader* loader = (AssetLoader*) nativeLoader;
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
loader->destroyAsset(asset);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,24 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetRoot(JNIEnv*, jclass,
|
||||
return asset->getRoot().getId();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nPopRenderable(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return asset->popRenderable().getId();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nPopRenderables(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
size_t retval = asset->popRenderables(entities, available);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
return retval;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetEntityCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
@@ -40,11 +58,114 @@ extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetEntities(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getEntities(), asset->getEntityCount(), entities);
|
||||
std::copy_n(asset->getEntities(),
|
||||
std::min(available, (jsize) asset->getEntityCount()), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetFirstEntityByName(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jstring name) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const char* cname = env->GetStringUTFChars(name, nullptr);
|
||||
Entity result = asset->getFirstEntityByName(cname);
|
||||
env->ReleaseStringUTFChars(name, cname);
|
||||
return result.getId();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetEntitiesByName(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jstring name, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const char* cname = env->GetStringUTFChars(name, nullptr);
|
||||
size_t numEntities = asset->getEntitiesByName(cname, nullptr, 0);
|
||||
if (result == nullptr) {
|
||||
env->ReleaseStringUTFChars(name, cname);
|
||||
return numEntities;
|
||||
}
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
numEntities = asset->getEntitiesByName(cname, entities, env->GetArrayLength(result));
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
env->ReleaseStringUTFChars(name, cname);
|
||||
return numEntities;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetEntitiesByPrefix(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jstring prefix, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const char* cprefix = env->GetStringUTFChars(prefix, nullptr);
|
||||
size_t numEntities = asset->getEntitiesByPrefix(cprefix, nullptr, 0);
|
||||
if (result == nullptr) {
|
||||
env->ReleaseStringUTFChars(prefix, cprefix);
|
||||
return numEntities;
|
||||
}
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
numEntities = asset->getEntitiesByPrefix(cprefix, entities, env->GetArrayLength(result));
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
env->ReleaseStringUTFChars(prefix, cprefix);
|
||||
return numEntities;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetLightEntityCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return asset->getLightEntityCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetLightEntities(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getLightEntities(),
|
||||
std::min(available, (jsize) asset->getLightEntityCount()), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetCameraEntities(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jintArray result) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(asset->getCameraEntities(),
|
||||
std::min(available, (jsize) asset->getCameraEntityCount()), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetCameraEntityCount(JNIEnv*, jclass,
|
||||
jlong nativeAsset) {
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
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) {
|
||||
@@ -65,10 +186,9 @@ Java_com_google_android_filament_gltfio_FilamentAsset_nGetBoundingBox(JNIEnv* en
|
||||
extern "C" JNIEXPORT jstring JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentAsset_nGetName(JNIEnv* env, jclass,
|
||||
jlong nativeAsset, jint entityId) {
|
||||
uint32_t id = static_cast<uint32_t>(entityId);
|
||||
Entity* entity = (Entity*) &id;
|
||||
Entity entity = Entity::import(entityId);
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
const char* val = asset->getName(*entity);
|
||||
const char* val = asset->getName(entity);
|
||||
return val ? env->NewStringUTF(val) : nullptr;
|
||||
}
|
||||
|
||||
|
||||
56
android/gltfio-android/src/main/cpp/FilamentInstance.cpp
Normal file
56
android/gltfio-android/src/main/cpp/FilamentInstance.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include <gltfio/FilamentInstance.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using namespace gltfio;
|
||||
using namespace utils;
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetRoot(JNIEnv*, jclass,
|
||||
jlong nativeInstance) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
return instance->getRoot().getId();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetEntityCount(JNIEnv*, jclass,
|
||||
jlong nativeInstance) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
return instance->getEntityCount();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetEntities(JNIEnv* env, jclass,
|
||||
jlong nativeInstance, jintArray result) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
jsize available = env->GetArrayLength(result);
|
||||
Entity* entities = (Entity*) env->GetIntArrayElements(result, nullptr);
|
||||
std::copy_n(instance->getEntities(),
|
||||
std::min(available, (jsize) instance->getEntityCount()), entities);
|
||||
env->ReleaseIntArrayElements(result, (jint*) entities, 0);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jlong JNICALL
|
||||
Java_com_google_android_filament_gltfio_FilamentInstance_nGetAnimator(JNIEnv* , jclass,
|
||||
jlong nativeInstance) {
|
||||
FilamentInstance* instance = (FilamentInstance*) nativeInstance;
|
||||
return (jlong) instance->getAnimator();
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#include "common/NioUtils.h"
|
||||
|
||||
extern void registerCallbackUtils(JNIEnv*);
|
||||
extern void registerNioUtils(JNIEnv*);
|
||||
|
||||
jint JNI_OnLoad(JavaVM* vm, void*) {
|
||||
JNIEnv* env;
|
||||
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
registerCallbackUtils(env);
|
||||
registerNioUtils(env);
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
@@ -35,9 +35,10 @@ 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) {
|
||||
jlong nativeEngine, jboolean normalizeSkinningWeights, jboolean recomputeBoundingBoxes) {
|
||||
Engine* engine = (Engine*) nativeEngine;
|
||||
return (jlong) new ResourceLoader({ engine, utils::Path(), true, true });
|
||||
return (jlong) new ResourceLoader({ engine, {}, (bool) normalizeSkinningWeights,
|
||||
(bool) recomputeBoundingBoxes });
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -52,10 +53,21 @@ Java_com_google_android_filament_gltfio_ResourceLoader_nAddResourceData(JNIEnv*
|
||||
jlong nativeLoader, jstring url, jobject javaBuffer, jint remaining) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
AutoBuffer* buffer = new AutoBuffer(env, javaBuffer, remaining);
|
||||
const char* curl = env->GetStringUTFChars(url, nullptr);
|
||||
loader->addResourceData(curl,
|
||||
const char* cstring = env->GetStringUTFChars(url, nullptr);
|
||||
loader->addResourceData(cstring,
|
||||
ResourceLoader::BufferDescriptor(buffer->getData(), buffer->getSize(), &destroy,
|
||||
buffer));
|
||||
env->ReleaseStringUTFChars(url, cstring);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nHasResourceData(JNIEnv* env, jclass,
|
||||
jlong nativeLoader, jstring url) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
const char* cstring = env->GetStringUTFChars(url, nullptr);
|
||||
bool status = loader->hasResourceData(cstring);
|
||||
env->ReleaseStringUTFChars(url, cstring);
|
||||
return status;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
@@ -65,3 +77,25 @@ Java_com_google_android_filament_gltfio_ResourceLoader_nLoadResources(JNIEnv*, j
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
loader->loadResources(asset);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jboolean JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nAsyncBeginLoad(JNIEnv*, jclass,
|
||||
jlong nativeLoader, jlong nativeAsset) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
FilamentAsset* asset = (FilamentAsset*) nativeAsset;
|
||||
return loader->asyncBeginLoad(asset);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jfloat JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nAsyncGetLoadProgress(JNIEnv*, jclass,
|
||||
jlong nativeLoader) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
return loader->asyncGetLoadProgress();
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_com_google_android_filament_gltfio_ResourceLoader_nAsyncUpdateLoad(JNIEnv*, jclass,
|
||||
jlong nativeLoader) {
|
||||
ResourceLoader* loader = (ResourceLoader*) nativeLoader;
|
||||
loader->asyncUpdateLoad();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.nio.Buffer;
|
||||
/**
|
||||
* Updates matrices according to glTF <code>animation</code> and <code>skin</code> definitions.
|
||||
*
|
||||
* <p>Animator can be used for two things:
|
||||
* <p>Animator is owned by <code>FilamentAsset</code> and can be used for two things:
|
||||
* <ul>
|
||||
* <li>Updating matrices in <code>TransformManager</code> components according to glTF <code>animation</code> definitions.</li>
|
||||
* <li>Updating bone matrices in <code>RenderableManager</code> components according to glTF <code>skin</code> definitions.</li>
|
||||
@@ -52,7 +52,7 @@ public class Animator {
|
||||
* @see #getAnimationCount
|
||||
*/
|
||||
public void applyAnimation(@IntRange(from = 0) int animationIndex, float time) {
|
||||
nApplyAnimation(mNativeObject, animationIndex, time);
|
||||
nApplyAnimation(getNativeObject(), animationIndex, time);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,14 +63,14 @@ public class Animator {
|
||||
* <p>NOTE: this operation is independent of <code>animation</code>.</p>
|
||||
*/
|
||||
public void updateBoneMatrices() {
|
||||
nUpdateBoneMatrices(mNativeObject);
|
||||
nUpdateBoneMatrices(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of <code>animation</code> definitions in the glTF asset.
|
||||
*/
|
||||
public int getAnimationCount() {
|
||||
return nGetAnimationCount(mNativeObject);
|
||||
return nGetAnimationCount(getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -81,7 +81,7 @@ public class Animator {
|
||||
* @see #getAnimationCount
|
||||
* */
|
||||
public float getAnimationDuration(@IntRange(from = 0) int animationIndex) {
|
||||
return nGetAnimationDuration(mNativeObject, animationIndex);
|
||||
return nGetAnimationDuration(getNativeObject(), animationIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,18 @@ public class Animator {
|
||||
* @see #getAnimationCount
|
||||
*/
|
||||
public String getAnimationName(@IntRange(from = 0) int animationIndex) {
|
||||
return nGetAnimationName(mNativeObject, animationIndex);
|
||||
return nGetAnimationName(getNativeObject(), animationIndex);
|
||||
}
|
||||
|
||||
long getNativeObject() {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Using Animator on destroyed asset");
|
||||
}
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
void clearNativeObject() {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native void nApplyAnimation(long nativeAnimator, int index, float time);
|
||||
|
||||
@@ -47,7 +47,7 @@ import java.nio.Buffer;
|
||||
*
|
||||
* assetLoader = AssetLoader(engine, MaterialProvider(engine), EntityManager.get())
|
||||
*
|
||||
* filamentAsset = assets.open("models/lucy.gltf").use { input ->
|
||||
* filamentAsset = assets.open("models/lucy.gltf").use { input ->
|
||||
* val bytes = ByteArray(input.available())
|
||||
* input.read(bytes)
|
||||
* assetLoader.createAssetFromJson(ByteBuffer.wrap(bytes))!!
|
||||
@@ -77,6 +77,7 @@ import java.nio.Buffer;
|
||||
*/
|
||||
public class AssetLoader {
|
||||
private long mNativeObject;
|
||||
private Engine mEngine;
|
||||
|
||||
/**
|
||||
* Constructs an <code>AssetLoader </code>that can be used to create and destroy instances of
|
||||
@@ -97,6 +98,8 @@ public class AssetLoader {
|
||||
if (mNativeObject == 0) {
|
||||
throw new IllegalStateException("Unable to parse glTF asset.");
|
||||
}
|
||||
|
||||
mEngine = engine;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,7 +116,7 @@ public class AssetLoader {
|
||||
@Nullable
|
||||
public FilamentAsset createAssetFromBinary(@NonNull Buffer buffer) {
|
||||
long nativeAsset = nCreateAssetFromBinary(mNativeObject, buffer, buffer.remaining());
|
||||
return nativeAsset != 0 ? new FilamentAsset(nativeAsset) : null;
|
||||
return nativeAsset != 0 ? new FilamentAsset(mEngine, nativeAsset) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -122,12 +125,37 @@ public class AssetLoader {
|
||||
@Nullable
|
||||
public FilamentAsset createAssetFromJson(@NonNull Buffer buffer) {
|
||||
long nativeAsset = nCreateAssetFromJson(mNativeObject, buffer, buffer.remaining());
|
||||
return nativeAsset != 0 ? new FilamentAsset(nativeAsset) : null;
|
||||
return nativeAsset != 0 ? new FilamentAsset(mEngine, nativeAsset) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Consumes the contents of a glTF 2.0 file and produces a primary asset with one or more
|
||||
* instances.
|
||||
*
|
||||
* The given instance array must be sized to the desired number of instances. If successful,
|
||||
* this method will populate the array with secondary instances whose resources are shared with
|
||||
* the primary asset.
|
||||
*/
|
||||
@Nullable
|
||||
@SuppressWarnings("unused")
|
||||
public FilamentAsset createInstancedAsset(@NonNull Buffer buffer,
|
||||
@NonNull FilamentInstance[] instances) {
|
||||
long[] nativeInstances = new long[instances.length];
|
||||
long nativeAsset = nCreateInstancedAsset(mNativeObject, buffer, buffer.remaining(),
|
||||
nativeInstances);
|
||||
if (nativeAsset == 0) {
|
||||
return null;
|
||||
}
|
||||
for (int i = 0; i < nativeInstances.length; i++) {
|
||||
instances[i] = new FilamentInstance(nativeInstances[i]);
|
||||
}
|
||||
return new FilamentAsset(mEngine, nativeAsset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows clients to enable diagnostic shading on newly-loaded assets.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public void enableDiagnostics(boolean enable) {
|
||||
nEnableDiagnostics(mNativeObject, enable);
|
||||
}
|
||||
@@ -145,6 +173,8 @@ public class AssetLoader {
|
||||
private static native void nDestroyAssetLoader(long nativeLoader);
|
||||
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 void nEnableDiagnostics(long nativeLoader, boolean enable);
|
||||
private static native void nDestroyAsset(long nativeLoader, long nativeAsset);
|
||||
}
|
||||
|
||||
@@ -17,9 +17,12 @@
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
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>.
|
||||
@@ -44,8 +47,10 @@ import com.google.android.filament.Entity;
|
||||
public class FilamentAsset {
|
||||
private long mNativeObject;
|
||||
private Animator mAnimator;
|
||||
private Engine mEngine;
|
||||
|
||||
FilamentAsset(long nativeObject) {
|
||||
FilamentAsset(Engine engine, long nativeObject) {
|
||||
mEngine = engine;
|
||||
mNativeObject = nativeObject;
|
||||
mAnimator = null;
|
||||
}
|
||||
@@ -61,11 +66,36 @@ public class FilamentAsset {
|
||||
return nGetRoot(mNativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops a ready renderable off the queue, or returns 0 if no renderables have become ready.
|
||||
*
|
||||
* NOTE: To determine the progress percentage or completion status, please use
|
||||
* ResourceLoader#asyncGetLoadProgress.
|
||||
*
|
||||
* This helper method allows clients to progressively add renderables to the scene as textures
|
||||
* gradually become ready through asynchronous loading.
|
||||
*
|
||||
* See also ResourceLoader#asyncBeginLoad.
|
||||
*/
|
||||
public @Entity int popRenderable() {
|
||||
return nPopRenderable(mNativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops one or more renderables off the queue, or returns the available number.
|
||||
*
|
||||
* Returns the number of entities written into the given array. If the given array
|
||||
* is null, returns the number of available renderables.
|
||||
*/
|
||||
public int popRenderables(@Nullable @Entity int[] entities) {
|
||||
return nPopRenderables(mNativeObject, entities);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of entities, one for each glTF node.
|
||||
*
|
||||
* <p>All of these have a transform component. Some of the returned entities may also have a
|
||||
* renderable component.</p>
|
||||
* renderable or light component.</p>
|
||||
*/
|
||||
public @NonNull @Entity int[] getEntities() {
|
||||
int[] result = new int[nGetEntityCount(mNativeObject)];
|
||||
@@ -73,6 +103,73 @@ public class FilamentAsset {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets only the entities that have light components.
|
||||
*/
|
||||
public @NonNull @Entity int[] getLightEntities() {
|
||||
int[] result = new int[nGetLightEntityCount(mNativeObject)];
|
||||
nGetLightEntities(mNativeObject, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets only the entities that have camera components.
|
||||
*
|
||||
* <p>
|
||||
* Note about aspect ratios:<br>
|
||||
*
|
||||
* gltfio always uses an aspect ratio of 1.0 when setting the projection matrix for perspective
|
||||
* cameras. gltfio then sets the camera's scaling matrix with the aspect ratio specified in the
|
||||
* glTF file (if present).<br>
|
||||
*
|
||||
* The camera's scaling matrix allows clients to adjust the aspect ratio independently from the
|
||||
* camera's projection.
|
||||
* </p>
|
||||
*
|
||||
* @see com.google.android.filament.Camera#setScaling
|
||||
*/
|
||||
public @NonNull @Entity int[] getCameraEntities() {
|
||||
int[] result = new int[nGetCameraEntityCount(mNativeObject)];
|
||||
nGetCameraEntities(mNativeObject, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first entity with the given name, or 0 if none exist.
|
||||
*/
|
||||
public @Entity int getFirstEntityByName(String name) {
|
||||
return nGetFirstEntityByName(mNativeObject, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of entities with the given name.
|
||||
*/
|
||||
public @NonNull @Entity int[] getEntitiesByName(String name) {
|
||||
int[] result = new int[nGetEntitiesByName(mNativeObject, name, null)];
|
||||
nGetEntitiesByName(mNativeObject, name, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of entities whose names start with the given prefix.
|
||||
*/
|
||||
public @NonNull @Entity int[] getEntitiesByPrefix(String prefix) {
|
||||
int[] result = new int[nGetEntitiesByPrefix(mNativeObject, prefix, null)];
|
||||
nGetEntitiesByPrefix(mNativeObject, prefix, result);
|
||||
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.
|
||||
*/
|
||||
@@ -90,10 +187,11 @@ public class FilamentAsset {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates or retrieves the <code>Animator</code> for this asset.
|
||||
* Creates or 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}.</p>
|
||||
* {@link ResourceLoader#loadResources}. When the asset is destroyed, its
|
||||
* animator becomes invalid.</p>
|
||||
*/
|
||||
public @NonNull Animator getAnimator() {
|
||||
if (mAnimator != null) {
|
||||
@@ -123,12 +221,30 @@ public class FilamentAsset {
|
||||
}
|
||||
|
||||
void clearNativeObject() {
|
||||
if (mAnimator != null) mAnimator.clearNativeObject();
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
private static native int nGetRoot(long nativeAsset);
|
||||
private static native int nPopRenderable(long nativeAsset);
|
||||
private static native int nPopRenderables(long nativeAsset, int[] result);
|
||||
|
||||
private static native int nGetEntityCount(long nativeAsset);
|
||||
private static native void nGetEntities(long nativeAsset, int[] result);
|
||||
|
||||
private static native int nGetFirstEntityByName(long nativeAsset, String name);
|
||||
private static native int nGetEntitiesByName(long nativeAsset, String name, int[] result);
|
||||
private static native int nGetEntitiesByPrefix(long nativeAsset, String prefix, int[] result);
|
||||
|
||||
private static native int nGetLightEntityCount(long nativeAsset);
|
||||
private static native void nGetLightEntities(long nativeAsset, int[] result);
|
||||
|
||||
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 void nGetBoundingBox(long nativeAsset, float[] box);
|
||||
private static native String nGetName(long nativeAsset, int entity);
|
||||
private static native long nGetAnimator(long nativeAsset);
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2020 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.gltfio;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.google.android.filament.Entity;
|
||||
|
||||
/**
|
||||
* Provides access to a hierarchy of entities that have been instanced from a glTF asset.
|
||||
*
|
||||
* @see FilamentAsset
|
||||
* @see Animator
|
||||
* @see AssetLoader
|
||||
*/
|
||||
public class FilamentInstance {
|
||||
private long mNativeObject;
|
||||
private Animator mAnimator;
|
||||
|
||||
FilamentInstance(long nativeObject) {
|
||||
mNativeObject = nativeObject;
|
||||
mAnimator = null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
long getNativeObject() {
|
||||
return mNativeObject;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
void clearNativeObject() {
|
||||
mNativeObject = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the transform root for the asset, which has no matching glTF node.
|
||||
*/
|
||||
@SuppressWarnings("unused")
|
||||
public @Entity int getRoot() {
|
||||
return nGetRoot(mNativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the list of entities for this instance, one for each glTF node.
|
||||
*
|
||||
* <p>All of these have a transform component. Some of the returned entities may also have a
|
||||
* renderable component.</p>
|
||||
*/
|
||||
public @NonNull @Entity int[] getEntities() {
|
||||
int[] result = new int[nGetEntityCount(mNativeObject)];
|
||||
nGetEntities(mNativeObject, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates or retrieves the <code>Animator</code> for this instance.
|
||||
*
|
||||
* <p>When calling this for the first time, this must be called after
|
||||
* {@link ResourceLoader#loadResources}.</p>
|
||||
*/
|
||||
public @NonNull Animator getAnimator() {
|
||||
if (mAnimator != null) {
|
||||
return mAnimator;
|
||||
}
|
||||
mAnimator = new Animator(nGetAnimator(mNativeObject));
|
||||
return mAnimator;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -16,11 +16,15 @@
|
||||
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import com.google.android.filament.Filament;
|
||||
|
||||
public class Gltfio {
|
||||
/**
|
||||
* Initializes the gltfio JNI layer. Must be called before using any gltfio functionality.
|
||||
*/
|
||||
public static void init() {
|
||||
// Load Filament first to ensure that the NioUtils Java class is available in the JNIEnv.
|
||||
Filament.init();
|
||||
System.loadLibrary("gltfio-jni");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package com.google.android.filament.gltfio;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import com.google.android.filament.Engine;
|
||||
|
||||
@@ -26,9 +25,10 @@ import java.lang.reflect.Method;
|
||||
import java.nio.Buffer;
|
||||
|
||||
/**
|
||||
* Uploads vertex buffers and textures to the GPU and computes tangents.
|
||||
* Prepares and uploads vertex buffers and textures to the GPU.
|
||||
*
|
||||
* <p>For a usage example, see the documentation for {@link AssetLoader}.</p>
|
||||
* <p>For a usage example, see the documentation for {@link AssetLoader}.
|
||||
* All methods should be called from the main thread.</p>
|
||||
*
|
||||
* @see AssetLoader
|
||||
* @see FilamentAsset
|
||||
@@ -45,7 +45,23 @@ public class ResourceLoader {
|
||||
*/
|
||||
public ResourceLoader(@NonNull Engine engine) {
|
||||
long nativeEngine = engine.getNativeObject();
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine);
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine, false, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a resource loader tied to the given Filament engine.
|
||||
*
|
||||
* @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
|
||||
* @throws IllegalAccessException
|
||||
* @throws InvocationTargetException
|
||||
*/
|
||||
public ResourceLoader(@NonNull Engine engine, boolean normalizeSkinningWeights,
|
||||
boolean recomputeBoundingBoxes) {
|
||||
long nativeEngine = engine.getNativeObject();
|
||||
mNativeObject = nCreateResourceLoader(nativeEngine, normalizeSkinningWeights,
|
||||
recomputeBoundingBoxes);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,12 +74,15 @@ public class ResourceLoader {
|
||||
/**
|
||||
* Feeds the binary content of an external resource into the loader's URI cache.
|
||||
*
|
||||
* <p><code>ResourceLoader</code> does not know how to download external resources on its own
|
||||
* (for example, external resources might come from a filesystem, a database, or the internet)
|
||||
* so this method allows clients to download external resources and push them to the loader.</p>
|
||||
* On some platforms, `ResourceLoader` does not know how to download external resources on its
|
||||
* own (external resources might come from a filesystem, a database, or the internet) so this
|
||||
* method allows clients to download external resources and push them to the loader.
|
||||
*
|
||||
* <p>When loading GLB files (as opposed to JSON-based glTF files), clients typically do not
|
||||
* need to call this method.</p>
|
||||
* Every resource should be passed in before calling [loadResources] or [asyncBeginLoad]. See
|
||||
* also [FilamentAsset#getResourceUris].
|
||||
*
|
||||
* When loading GLB files (as opposed to JSON-based glTF files), clients typically do not
|
||||
* need to call this method.
|
||||
*
|
||||
* @param uri the string path that matches an image URI or buffer URI in the glTF
|
||||
* @param buffer the binary blob corresponding to the given URI
|
||||
@@ -75,12 +94,18 @@ public class ResourceLoader {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given resource has already been added to the URI cache.
|
||||
*/
|
||||
public boolean hasResourceData(@NonNull String uri) {
|
||||
return nHasResourceData(mNativeObject, uri);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through all external buffers and images and creates corresponding Filament objects
|
||||
* (vertex buffers, textures, etc), which become owned by the asset.
|
||||
*
|
||||
* <p>This is the main entry point for <code>ResourceLoader</code>, and only needs to be called
|
||||
* once.</p>
|
||||
* NOTE: this is a synchronous API, please see [asyncBeginLoad] as an alternative.
|
||||
*
|
||||
* @param asset the Filament asset that contains URI-based resources
|
||||
* @return self (for daisy chaining)
|
||||
@@ -91,9 +116,44 @@ public class ResourceLoader {
|
||||
return this;
|
||||
}
|
||||
|
||||
private static native long nCreateResourceLoader(long nativeEngine);
|
||||
/**
|
||||
* Starts an asynchronous resource load.
|
||||
*
|
||||
* Returns false if the loading process was unable to start.
|
||||
*
|
||||
* This is an alternative to #loadResources and requires periodic calls to #asyncUpdateLoad.
|
||||
* On multi-threaded systems this creates threads for texture decoding.
|
||||
*/
|
||||
public boolean asyncBeginLoad(@NonNull FilamentAsset asset) {
|
||||
return nAsyncBeginLoad(mNativeObject, asset.getNativeObject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the status of an asynchronous resource load as a percentage in [0,1].
|
||||
*/
|
||||
public float asyncGetLoadProgress() {
|
||||
return nAsyncGetLoadProgress(mNativeObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates an asynchronous load by performing any pending work that must take place
|
||||
* on the main thread.
|
||||
*
|
||||
* Clients must periodically call this until #asyncGetLoadProgress returns 100%.
|
||||
* After progress reaches 100%, calling this is harmless; it just does nothing.
|
||||
*/
|
||||
public void asyncUpdateLoad() {
|
||||
nAsyncUpdateLoad(mNativeObject);
|
||||
}
|
||||
|
||||
private static native long nCreateResourceLoader(long nativeEngine,
|
||||
boolean normalizeSkinningWeights, boolean recomputeBoundingBoxes);
|
||||
private static native void nDestroyResourceLoader(long nativeLoader);
|
||||
private static native void nAddResourceData(long nativeLoader, String url, Buffer buffer,
|
||||
int remaining);
|
||||
private static native boolean nHasResourceData(long nativeLoader, String url);
|
||||
private static native void nLoadResources(long nativeLoader, long nativeAsset);
|
||||
private static native boolean nAsyncBeginLoad(long nativeLoader, long nativeAsset);
|
||||
private static native float nAsyncGetLoadProgress(long nativeLoader);
|
||||
private static native void nAsyncUpdateLoad(long nativeLoader);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
GROUP=com.google.android.filament
|
||||
VERSION_NAME=1.4.4
|
||||
VERSION_NAME=1.9.2
|
||||
|
||||
POM_DESCRIPTION=Real-time physically based rendering engine for Android.
|
||||
|
||||
|
||||
@@ -92,6 +92,7 @@ afterEvaluate { project ->
|
||||
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) {
|
||||
|
||||
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
|
||||
|
||||
16
android/proguard-rules.pro
vendored
Normal file
16
android/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
|
||||
# Keep the annotations that proguard needs to process.
|
||||
-keep class com.google.android.filament.proguard.UsedBy*
|
||||
|
||||
# Just because native code accesses members of a class, does not mean that the
|
||||
# class itself needs to be annotated - only annotate classes that are
|
||||
# referenced themselves in native code.
|
||||
-keep @com.google.android.filament.proguard.UsedBy* class * {
|
||||
<init>();
|
||||
}
|
||||
-keepclassmembers class * {
|
||||
@com.google.android.filament.proguard.UsedBy* *;
|
||||
}
|
||||
@@ -41,8 +41,8 @@ Demonstrates how to render into a `TextureView` instead of a `SurfaceView`:
|
||||
|
||||
### `material-builder`
|
||||
|
||||
Demonstrates how to programatically generate Filament materials, as opposed to compiling them on the
|
||||
host machine:
|
||||
Demonstrates how to programmatically generate Filament materials, as opposed to compiling them on
|
||||
the host machine:
|
||||
|
||||

|
||||
|
||||
@@ -52,18 +52,20 @@ Demonstrates how to load glTF models and use the camera manipulator:
|
||||
|
||||

|
||||
|
||||
### `gltf-bloom`
|
||||
|
||||
Demonstrates how to load glb models and use the RenderTarget API:
|
||||
|
||||

|
||||
|
||||
### `hello-camera`
|
||||
|
||||
Demonstrates how to use `Stream` with Android's Camera2 API:
|
||||
|
||||

|
||||
|
||||
### `page-curl`
|
||||
|
||||
Pure Java app that demonstrates custom vertex shader animation and two-sided texturing.
|
||||
Applies the deformation described in "Deforming Pages of Electronic Books" by Hong et al.
|
||||
Users can drag horizontally to turn the page.
|
||||
|
||||

|
||||
|
||||
### `stream-test`
|
||||
|
||||
Tests the various ways to interact with `Stream` by drawing into an external texture using Canvas.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user