Compare commits
784 Commits
GPU_data_r
...
temp-ghash
Author | SHA1 | Date | |
---|---|---|---|
58d6cbba6d | |||
295d0c52a2 | |||
e35a26fbef | |||
6654ec7de7 | |||
827ccc343f | |||
e6f7f36e40 | |||
e245a57640 | |||
68478aea01 | |||
b506f3d328 | |||
d9ef528d05 | |||
9f48aa45ad | |||
c5c2883ce0 | |||
32319dd106 | |||
2ef3c43c5d | |||
3d616ccba8 | |||
aac5485fca | |||
008da0ff5e | |||
3d7329950e | |||
4d74180b9f | |||
09dc470982 | |||
17f12fc71a | |||
9260c0c2ba | |||
48ef0501b7 | |||
e2d3e36ca7 | |||
c68322c7e5 | |||
e170d6be7f | |||
ecb6a6df52 | |||
ff7a46cfad | |||
4d043c99dc | |||
e78b03f9e9 | |||
ab85c5f980 | |||
851d7535d9 | |||
ddeb8c595f | |||
c58b5acefd | |||
79c106705a | |||
8690ea611e | |||
09e89f01a6 | |||
c74255181e | |||
2cdcb1c171 | |||
0e83b0854f | |||
284d294f2c | |||
c0ea3099c5 | |||
ef57051e9c | |||
8e95303414 | |||
c40205738b | |||
ba98e6148b | |||
42314b32f2 | |||
![]() |
6f17fb8630 | ||
![]() |
fc668df245 | ||
![]() |
49aa7b1261 | ||
1676fcded0 | |||
c40759e678 | |||
a09af2dc7b | |||
9ce738e0f6 | |||
a33b1ce500 | |||
![]() |
227aefc18b | ||
0d4cca6593 | |||
f1bad1d16b | |||
40a345a9c7 | |||
04e9a707f4 | |||
b318795c3b | |||
90b4131d16 | |||
57065a6df5 | |||
1c251d7cb6 | |||
72e812de7c | |||
ec8e0336a9 | |||
7ecb199d86 | |||
cb5aecdae9 | |||
91fde2891c | |||
cd7853be22 | |||
4e8092e2e4 | |||
f1917a2188 | |||
d6e180e75a | |||
74f7ef1240 | |||
e2fa6663d3 | |||
80192b5391 | |||
![]() |
f0c5ed39ee | ||
211a95b538 | |||
a1609791ca | |||
4faccf0a78 | |||
d979ac4cc9 | |||
5e241e3028 | |||
7119a0f67d | |||
3044e9fd31 | |||
b5b8599342 | |||
63c9f51133 | |||
c119187be0 | |||
63f62cd757 | |||
857c9e14f7 | |||
43f6ed908f | |||
6057548058 | |||
8be4d76204 | |||
9ddb624a88 | |||
8d752141ce | |||
e3d6269ec4 | |||
cdb0cf3ec7 | |||
aeda4dca77 | |||
a95b0e0e9d | |||
5e2835037a | |||
34d665a4a4 | |||
63dd554ff1 | |||
5a4b51992e | |||
845854959f | |||
2a305580b2 | |||
6b3a43ccb4 | |||
b6820c9522 | |||
e019d8fb8c | |||
e3fe56d9d1 | |||
72a2d22f03 | |||
5a69b93f57 | |||
973afa0172 | |||
f6c661a38f | |||
e807520a1e | |||
74b32a23f7 | |||
4addabaed8 | |||
2de34ba31d | |||
51188ecbf1 | |||
8e1ba0b805 | |||
1d6c025c42 | |||
037181cf1c | |||
27eb2b1017 | |||
e9406256d0 | |||
ae0ed5e9d5 | |||
![]() |
9affa8450a | ||
9d796df4f6 | |||
0d3555fe2e | |||
0f171d4a25 | |||
1cf1f48893 | |||
52e95ad3d3 | |||
d4aeec9204 | |||
9b3722b414 | |||
d8cef42a14 | |||
![]() |
a1e01fda24 | ||
e1fd7b9ca9 | |||
7e529c2a64 | |||
4ed6605d65 | |||
28c34d332f | |||
03efc37a6e | |||
7165d979ae | |||
3468038ed5 | |||
7fbf264c67 | |||
530034511c | |||
18f228d593 | |||
![]() |
a62392dea7 | ||
3ce4a58aa9 | |||
937ecaf77e | |||
da61c36f2a | |||
fc35b758ad | |||
e96d1c7965 | |||
0dcda51836 | |||
37fd262805 | |||
bd5ea70a75 | |||
01f21f8026 | |||
42d5df448c | |||
0119c63405 | |||
bcc4957877 | |||
0b79c5ed29 | |||
e1ce9220d6 | |||
3b57f075a8 | |||
e0ae59f5d8 | |||
aee4527101 | |||
ae3e37b899 | |||
364d934951 | |||
a1c6b73de7 | |||
5b833de521 | |||
c03dcc5421 | |||
810f8928d6 | |||
81b37f5e92 | |||
ecdbe3cc63 | |||
2689247f98 | |||
770dfead86 | |||
aab2da9e65 | |||
fbff0e68a4 | |||
5ca3f3d811 | |||
c55cf743cd | |||
94eb2647d5 | |||
b986f955e9 | |||
173c1133a8 | |||
fa823dc828 | |||
b1a92f2b3a | |||
532e29cd76 | |||
291152e127 | |||
6d63446710 | |||
53e3e46332 | |||
888ed6b7f1 | |||
099aaea447 | |||
6c23497185 | |||
1c707a2392 | |||
124b25cf9d | |||
a44a0cf443 | |||
b633c2857f | |||
3f7ea7489e | |||
bf57c91ead | |||
473d46263b | |||
05b2ab1109 | |||
9090d64544 | |||
d7cd8ff891 | |||
5b8af1d1f1 | |||
edfe2d6691 | |||
fd629d2fb8 | |||
644e2250ce | |||
d8e994b35f | |||
3efc0aca54 | |||
7f3dcbe17f | |||
e464cbae3b | |||
9cefd5612d | |||
eb0310950c | |||
1862991862 | |||
b9fe261255 | |||
91b23992ce | |||
208a917b73 | |||
52997272aa | |||
1e9348efdc | |||
424e5be046 | |||
a2d4c26aa2 | |||
b1ed12bfec | |||
1c81bcffde | |||
75a86d6a8e | |||
a1ac42f5eb | |||
4835fe06f1 | |||
![]() |
9326820a1b | ||
![]() |
e944af67f7 | ||
41d5ff6fe9 | |||
d3e16df4f1 | |||
1cbf748e0c | |||
0f42b8aee0 | |||
097aa852cf | |||
![]() |
54b824106b | ||
0bf0aa6625 | |||
0b51e7d991 | |||
38a60418f7 | |||
60ddaf045a | |||
02a496c61c | |||
7bac8348bf | |||
![]() |
7182677620 | ||
1b8a785d83 | |||
07562a4afb | |||
9e91313a97 | |||
6f36e1f872 | |||
efe4af8fcb | |||
a9d3f663d3 | |||
e2e414218b | |||
0d95b41f9e | |||
7823ca06da | |||
4fae3620d0 | |||
850bb80aef | |||
69e96509a6 | |||
f2bd6d73e6 | |||
6c44265bc9 | |||
34c3beb339 | |||
520fb5c8cd | |||
4ab47a7670 | |||
5893a3445e | |||
37b8153afe | |||
![]() |
7ca40c1061 | ||
![]() |
2205950274 | ||
6a33d13ae7 | |||
596eadf0e1 | |||
b3cc602adc | |||
f6748183a2 | |||
7dae8e54cc | |||
774e034d40 | |||
9c5995c062 | |||
b496819fcc | |||
b666593775 | |||
96d9801423 | |||
b4446b505f | |||
5114637967 | |||
8c2619a11a | |||
![]() |
939948c233 | ||
356afe0085 | |||
6a0a205cb4 | |||
af4d10703b | |||
102e18d05c | |||
2bd6de5bbb | |||
3438130a94 | |||
abc9c26ec8 | |||
a6803bf564 | |||
bb5e46f105 | |||
41564a402e | |||
ee37de75e6 | |||
867cd2048e | |||
b8b57d2da9 | |||
958c20872a | |||
![]() |
087c82e392 | ||
f167f434d9 | |||
8e0ab3d42f | |||
825892ae7a | |||
3560e36ee9 | |||
ec3c2d3be9 | |||
91e767c99c | |||
ab417f31f4 | |||
73a104b8e8 | |||
9f911f62dc | |||
6e844da9da | |||
0446c73c4a | |||
bc69eafa98 | |||
08687ee380 | |||
45d4fadebd | |||
7b0c327b94 | |||
9a83e112be | |||
3092e1031d | |||
af980a20a4 | |||
6c8f2049f6 | |||
cb9bd23d0c | |||
![]() |
e1b8ed8dd4 | ||
962f764d58 | |||
f8385de5ed | |||
![]() |
ffdeba49e6 | ||
![]() |
4f94947157 | ||
bcfe38aa03 | |||
303c912093 | |||
ec0ba4095f | |||
d63615272c | |||
07d51141ae | |||
87629b2a74 | |||
546a0e2d96 | |||
0589a814ba | |||
2ebaa69676 | |||
8c2750bc82 | |||
c6c06285a7 | |||
27ed75271c | |||
267c7b098d | |||
7c5944137e | |||
b54e95a5c8 | |||
22a4fcb146 | |||
99fba34b8d | |||
9927849708 | |||
b79a33e2d4 | |||
de953bf7b8 | |||
86bb0d1a35 | |||
404f9ddc37 | |||
bf010c4a15 | |||
5aade17bdf | |||
c5748f3cc7 | |||
60621940d0 | |||
![]() |
4ee2ae97c3 | ||
50a1ad5bb3 | |||
94e7ac5b97 | |||
68cdd2b361 | |||
e708042aa0 | |||
28f798f86e | |||
d5bca524d5 | |||
304ee9af8d | |||
907f804ad8 | |||
fb92c553f1 | |||
ffaf271ab9 | |||
aca40295e8 | |||
b2e5c017a1 | |||
f3434e5f82 | |||
2cbe60b476 | |||
455ca1b28f | |||
c64f491f9f | |||
![]() |
91d424b82a | ||
4a26f3b569 | |||
06f4bac104 | |||
cf7a5e93f8 | |||
3eb38a79d8 | |||
061b59a1d4 | |||
81e3deadea | |||
7a0f57cd01 | |||
896f08bde8 | |||
451a077511 | |||
e4ab526ad1 | |||
b9c563061c | |||
43913fe212 | |||
b07be730b2 | |||
6fbb580e51 | |||
1dbcccf5f9 | |||
ebebc4ded1 | |||
2517f5c97c | |||
e695b34505 | |||
52795932a7 | |||
2c7cb8ce59 | |||
b3d2b035c4 | |||
23f1c6835f | |||
c07a11b83b | |||
4056253627 | |||
c0ca70a3b2 | |||
2be3ebd15d | |||
fd8b6021c4 | |||
469c0695ac | |||
fd1ea5e3db | |||
9454377c71 | |||
7724b26ab2 | |||
95b9d6d9c2 | |||
5f5e05b3eb | |||
89025958af | |||
23b068ce8a | |||
660234bfba | |||
aa2bdcccfc | |||
c67abff7f0 | |||
abc4a3d455 | |||
33a7b72678 | |||
b53836d2c9 | |||
9e850addae | |||
32cf18d9a2 | |||
27c1262e21 | |||
a73d4b859a | |||
bec3131112 | |||
2d8880643d | |||
7173069cbe | |||
893677a76a | |||
a6101cde06 | |||
b10bc3a6ec | |||
3127d47029 | |||
9d4d55e78b | |||
f0a0b1eaac | |||
ecd4ee75af | |||
c0235da53c | |||
399a27b261 | |||
f45f2ac687 | |||
4d8cf1329d | |||
36ef6d1532 | |||
14251e8b45 | |||
1fc6563917 | |||
c8711b6f6f | |||
07a6d4ed75 | |||
bfa7586ba3 | |||
565faadd8e | |||
668f1f9554 | |||
b147473f02 | |||
4b4695223a | |||
a8d6c69d76 | |||
3ca0870023 | |||
![]() |
3100fbef5e | ||
f5a471ef86 | |||
67bebc42f4 | |||
28ef76d0f0 | |||
71dcaa7744 | |||
a5a1d4aa3a | |||
0a4bf5317f | |||
0187356613 | |||
1d34d3ee06 | |||
36d47ce203 | |||
8b494e03be | |||
![]() |
1a0c961746 | ||
9755986637 | |||
51bec8e22e | |||
9876d1f299 | |||
dea3f7f5ff | |||
2f2f7c0e87 | |||
1bede8644a | |||
52cfd0eef8 | |||
7b743defd4 | |||
166408cfe2 | |||
af434fea71 | |||
3511e2d6ae | |||
![]() |
d3556268d5 | ||
![]() |
23c7d14afd | ||
18208c8ad9 | |||
bdf242fa21 | |||
3b158d2e05 | |||
8dc6fabc34 | |||
eb476c2816 | |||
f777983d5b | |||
d9b6768521 | |||
f3161c97a6 | |||
4be7258f00 | |||
3dd346c2a1 | |||
89c56f6e47 | |||
56f6aa977a | |||
2480bbff56 | |||
dc1586063b | |||
3e0c6a8ca2 | |||
46d8bcb617 | |||
20f6a0f2d7 | |||
930bf58478 | |||
07def553d2 | |||
9aea98d33c | |||
c5a8a4e9d8 | |||
![]() |
be4d34ca86 | ||
9fc1033429 | |||
b52af946cd | |||
c449d4e336 | |||
4bf64e841c | |||
0e00072ff0 | |||
0e02ad8b64 | |||
4c1efcc829 | |||
1fd2e6232a | |||
e665a60a85 | |||
92022218c2 | |||
da192fb3a7 | |||
77f0f3c54e | |||
c3810c596e | |||
84ad20acef | |||
4ffcc6ff56 | |||
6245f4a39c | |||
cf19012fb0 | |||
b90c7dd730 | |||
d45c4af469 | |||
89b6c72f8d | |||
6973e26bf9 | |||
a23fbc71a1 | |||
a64cb4185e | |||
8299284389 | |||
3c9da38e7e | |||
7487a4d4ac | |||
d20fd2da72 | |||
bfe0ea4069 | |||
ded0004f8b | |||
718bc078a8 | |||
de68066c1c | |||
e5fbeba0b3 | |||
569a2035c7 | |||
de0c269c28 | |||
2c3c477223 | |||
9b1ca19396 | |||
e4dc44d7ab | |||
abf7378e44 | |||
8715fd0925 | |||
9ce20d3341 | |||
eb799dc350 | |||
de21604cf4 | |||
1ac0fef345 | |||
e092a58fb5 | |||
5e66827029 | |||
6b5f3f5fef | |||
![]() |
3a7691b73f | ||
2464395b6d | |||
0b9a65b2ae | |||
a80c1e50bc | |||
39b85e452f | |||
62f2d9b566 | |||
153cebd95b | |||
a5a648c7c6 | |||
7fd93dc8dc | |||
fe9ce6603c | |||
7b60a0f64b | |||
a3ef51bba5 | |||
c3ab5b3089 | |||
025a646114 | |||
78918e761f | |||
a28adf1b35 | |||
febf8cb01d | |||
7f89bc8e85 | |||
f9b6f5756c | |||
0305e9604b | |||
7456f06097 | |||
4737722968 | |||
2da9a39418 | |||
78250f1d1d | |||
f01c6e185f | |||
f340595dba | |||
bc83076355 | |||
25f5d2b4d7 | |||
e529882be0 | |||
cd9dc3143c | |||
2c503d8303 | |||
7f4d5850fe | |||
be6479c9ea | |||
ed2cb8de2f | |||
476feb622c | |||
a934730368 | |||
53eab562b4 | |||
8843a09df3 | |||
e8014352c6 | |||
f6062638c1 | |||
a39efae03d | |||
d3c67bc81e | |||
069adb8104 | |||
25bedeca9b | |||
389564c711 | |||
03eee4dce7 | |||
4b8dcfc0f5 | |||
7938bd1877 | |||
329f704601 | |||
e37c4e5819 | |||
6ee653352b | |||
6b40a4bcb1 | |||
d4c676e81b | |||
f18d77b874 | |||
aa54d93a29 | |||
2c000cc9fc | |||
9bfea67751 | |||
1aa1a53115 | |||
2b0613b948 | |||
148ed4e05e | |||
6f48df45ee | |||
093d11df35 | |||
2c5d5a9feb | |||
![]() |
8dd9b7cc5f | ||
b5bf5b36f1 | |||
24e1d7f4f4 | |||
8edfcf653a | |||
44a6109ca9 | |||
77ef3f9041 | |||
eb6bab25ba | |||
8c6a9b9edc | |||
f4d064a5b2 | |||
28b2977be9 | |||
5d30c23c35 | |||
922d5ed939 | |||
f0c143ca72 | |||
a1e8547877 | |||
377822729c | |||
fccf253e36 | |||
150a4b23ba | |||
158c891520 | |||
df0a1fa3c5 | |||
07e9fb8ec6 | |||
d3cc7419a3 | |||
78411dc7d7 | |||
dc3533030a | |||
e8561e966d | |||
ac636a3c97 | |||
293df68ebd | |||
eb05e87e16 | |||
da34136de1 | |||
f868be6295 | |||
ddb1a068e9 | |||
e698299e4f | |||
d5a85f87b0 | |||
3d70a04a8a | |||
183b643774 | |||
65328fadc3 | |||
![]() |
598c2dffe9 | ||
192fddb324 | |||
5fa0b8778b | |||
![]() |
947b756d5e | ||
cecd1f98a4 | |||
45afc02f11 | |||
61f9f508a4 | |||
8540907d60 | |||
40091ff83a | |||
b88597c218 | |||
17388794ce | |||
bf93316c52 | |||
5dfe88adba | |||
3dfce097e4 | |||
924f31e54f | |||
662746fdd4 | |||
88acb3c599 | |||
29aae4db38 | |||
3ed009af96 | |||
0b5bf9d419 | |||
![]() |
d1230ca723 | ||
105b87a3f7 | |||
dae566894a | |||
14c2bc53c0 | |||
4139686817 | |||
3cff7768d5 | |||
43ee3f4040 | |||
48ed2b6309 | |||
a622cdaad8 | |||
2b9d806432 | |||
206f29c12c | |||
30b45d5591 | |||
b68fa820d6 | |||
3b359f1fea | |||
4d45f47920 | |||
effb912061 | |||
dad2850cc5 | |||
347843f6fe | |||
f51fef63aa | |||
847ec075eb | |||
02cbc3c1e0 | |||
daeb3069cf | |||
6ba128129d | |||
60f60ed496 | |||
6c15f3044b | |||
dcacc54e07 | |||
4c0f0eb338 | |||
a49534ae48 | |||
dddb4f655c | |||
3aa4a0e787 | |||
05c4c2409e | |||
5cc55486ee | |||
1bb3d0d485 | |||
eeadd19eb5 | |||
80c0097210 | |||
b931afe55e | |||
08f30ef31c | |||
2d479421af | |||
5dc22fbbfb | |||
ce0d3112e4 | |||
3d658bf7a7 | |||
371e5f25a0 | |||
f4e8e70b5d | |||
31e96cbf96 | |||
2fa4a48bce | |||
7c06190882 | |||
e4c93dc7db | |||
c86a6f3efb | |||
c2b9f78415 | |||
2ab909a88c | |||
c9e8888f87 | |||
960d7df56f | |||
650fbd09f7 | |||
03f9d5a4cf | |||
ba9dbaae64 | |||
547b676181 | |||
cfe54245a8 | |||
bc371030a7 | |||
![]() |
a92d8a34a8 | ||
![]() |
7549ec7301 | ||
3c10ec96b5 | |||
03565218d5 | |||
f6c6dd44de | |||
5c34266383 | |||
0a60c7d8ee | |||
3d3d805b64 | |||
5a63edb929 | |||
33439626f1 | |||
79aa50dc53 | |||
e7f2aec81b | |||
1ccc417477 | |||
7aa74dfe5e | |||
057a8c6250 | |||
8bf9e1412f | |||
687f6a9752 | |||
434086dc53 | |||
9207c8d669 | |||
0e80eb82e0 | |||
67eb2c7897 | |||
da1038c768 | |||
fc31bae66f | |||
93867ae549 | |||
51a6bc8faa | |||
0a6e32173e | |||
730e61b446 | |||
0d64e26740 | |||
38eab96f9b | |||
ae9e38c5ad | |||
1a0fb7e9ae | |||
a050d6063c | |||
3e782756e3 | |||
7969b238db | |||
7742a8f09c | |||
![]() |
c78df8f9ee | ||
abb80abf8a | |||
08bbea9362 | |||
898b6491ed | |||
91ec8d8d1e | |||
bbadc3aecd | |||
![]() |
274b0838c7 | ||
b3334d936f | |||
ee3dde2d49 | |||
![]() |
3e519860e5 | ||
e4cd4c383f | |||
3160740421 | |||
b01dd748b6 | |||
f097453006 | |||
![]() |
15016e1497 | ||
f0f481031c | |||
7c2905b8ec | |||
8697c19e91 | |||
909d3228b1 | |||
615a7aea55 | |||
29529d2ac3 | |||
bac7353801 | |||
a09341469e | |||
051688b34c | |||
08d87514d3 | |||
31f0c27ae7 | |||
87fd166654 | |||
dbbe721c2a | |||
ae00e42bc2 | |||
20e561dd6a | |||
f6dc0e918b | |||
34c78a659b | |||
f727df6076 | |||
311f6cac92 | |||
8a231185aa | |||
8478c71a7b | |||
ce504cffad | |||
c7bccb30bf | |||
1bf685488c | |||
2c4736e6db | |||
4fc3188112 | |||
d30f664c04 | |||
e38f914421 | |||
cc1883468d | |||
5588a51c9c | |||
94549adec4 | |||
77a4d705c7 | |||
f808f36c12 | |||
b6f0c9e25a | |||
ecc9fe9945 | |||
4e3bc21492 | |||
88ae44a363 | |||
df587b03c3 | |||
1df3713365 | |||
23b42a5e69 |
@@ -53,7 +53,9 @@ if(NOT (${CMAKE_VERSION} VERSION_LESS 3.0))
|
||||
endif()
|
||||
|
||||
if(NOT EXECUTABLE_OUTPUT_PATH)
|
||||
set(FIRST_RUN "TRUE")
|
||||
set(FIRST_RUN TRUE)
|
||||
else()
|
||||
set(FIRST_RUN FALSE)
|
||||
endif()
|
||||
|
||||
# this starts out unset
|
||||
@@ -71,7 +73,6 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELEASE NDEBU
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_MINSIZEREL NDEBUG)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_RELWITHDEBINFO NDEBUG)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set policy
|
||||
|
||||
@@ -129,7 +130,7 @@ macro(option_defaults_init)
|
||||
set(${_var} ON)
|
||||
list(APPEND _init_vars "${_var}")
|
||||
endforeach()
|
||||
unset(_INC)
|
||||
unset(_var)
|
||||
endmacro()
|
||||
|
||||
# remove from namespace
|
||||
@@ -197,7 +198,6 @@ option(WITH_PYTHON "Enable Embedded Python API (only disable for develop
|
||||
option(WITH_PYTHON_SECURITY "Disables execution of scripts within blend files by default" ON)
|
||||
mark_as_advanced(WITH_PYTHON) # dont want people disabling this unless they really know what they are doing.
|
||||
mark_as_advanced(WITH_PYTHON_SECURITY) # some distributions see this as a security issue, rather than have them patch it, make a build option.
|
||||
set(WITH_PYTHON_SECURITY ON CACHE BOOL "ON" FORCE) # temp force on.
|
||||
|
||||
option(WITH_PYTHON_SAFETY "Enable internal API error checking to track invalid data to prevent crash on access (at the expense of some effeciency, only enable for development)." OFF)
|
||||
mark_as_advanced(WITH_PYTHON_SAFETY)
|
||||
@@ -449,6 +449,10 @@ endif()
|
||||
option(WITH_CPP11 "Build with C++11 standard enabled, for development use only!" OFF)
|
||||
mark_as_advanced(WITH_CPP11)
|
||||
|
||||
# Dependency graph
|
||||
option(WITH_LEGACY_DEPSGRAPH "Build Blender with legacy dependency graph" ON)
|
||||
mark_as_advanced(WITH_LEGACY_DEPSGRAPH)
|
||||
|
||||
# avoid using again
|
||||
option_defaults_clear()
|
||||
|
||||
@@ -652,6 +656,13 @@ endif()
|
||||
# auto enable openimageio for cycles
|
||||
if(WITH_CYCLES)
|
||||
set(WITH_OPENIMAGEIO ON)
|
||||
|
||||
# auto enable llvm for cycles_osl
|
||||
if(WITH_CYCLES_OSL)
|
||||
set(WITH_LLVM ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_CYCLES_OSL OFF)
|
||||
endif()
|
||||
|
||||
# auto enable openimageio linking dependencies
|
||||
@@ -660,11 +671,6 @@ if(WITH_OPENIMAGEIO)
|
||||
set(WITH_IMAGE_TIFF ON)
|
||||
endif()
|
||||
|
||||
# auto enable llvm for cycles_osl
|
||||
if(WITH_CYCLES_OSL)
|
||||
set(WITH_LLVM ON CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
# don't store paths to libs for portable distribution
|
||||
if(WITH_INSTALL_PORTABLE)
|
||||
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||
@@ -1842,14 +1848,14 @@ elseif(APPLE)
|
||||
if(NOT WITH_PYTHON_MODULE AND NOT WITH_PYTHON_FRAMEWORK)
|
||||
# normally cached but not since we include them with blender
|
||||
set(PYTHON_INCLUDE_DIR "${LIBDIR}/python/include/python${PYTHON_VERSION}m")
|
||||
# set(PYTHON_BINARY "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
|
||||
# set(PYTHON_EXECUTABLE "${LIBDIR}/python/bin/python${PYTHON_VERSION}") # not used yet
|
||||
set(PYTHON_LIBRARY python${PYTHON_VERSION}m)
|
||||
set(PYTHON_LIBPATH "${LIBDIR}/python/lib/python${PYTHON_VERSION}")
|
||||
# set(PYTHON_LINKFLAGS "-u _PyMac_Error") # won't build with this enabled
|
||||
else()
|
||||
# module must be compiled against Python framework
|
||||
set(PYTHON_INCLUDE_DIR "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/include/python${PYTHON_VERSION}m")
|
||||
set(PYTHON_BINARY "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
|
||||
set(PYTHON_EXECUTABLE "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/bin/python${PYTHON_VERSION}")
|
||||
#set(PYTHON_LIBRARY python${PYTHON_VERSION})
|
||||
set(PYTHON_LIBPATH "/Library/Frameworks/Python.framework/Versions/${PYTHON_VERSION}/lib/python${PYTHON_VERSION}/config-${PYTHON_VERSION}m")
|
||||
#set(PYTHON_LINKFLAGS "-u _PyMac_Error -framework Python") # won't build with this enabled
|
||||
@@ -2756,25 +2762,29 @@ include(build_files/cmake/packaging.cmake)
|
||||
# Print Final Configuration
|
||||
|
||||
if(FIRST_RUN)
|
||||
set(_config_msg "\n* Blender Configuration *")
|
||||
macro(info_cfg_option
|
||||
_setting)
|
||||
set(_msg " * ${_setting}")
|
||||
|
||||
set(_config_msg "\nBlender Configuration\n=====================")
|
||||
|
||||
function(info_cfg_option
|
||||
_setting
|
||||
)
|
||||
|
||||
set(_msg " - ${_setting}")
|
||||
string(LENGTH "${_msg}" _len)
|
||||
while("32" GREATER "${_len}")
|
||||
set(_msg "${_msg} ")
|
||||
math(EXPR _len "${_len} + 1")
|
||||
endwhile()
|
||||
|
||||
set(_config_msg "${_config_msg}\n${_msg}${${_setting}}")
|
||||
endmacro()
|
||||
set(_config_msg "${_config_msg}\n${_msg}${${_setting}}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
macro(info_cfg_text
|
||||
_text)
|
||||
set(_config_msg "${_config_msg}\n\n ${_text}")
|
||||
function(info_cfg_text
|
||||
_text
|
||||
)
|
||||
|
||||
|
||||
endmacro()
|
||||
set(_config_msg "${_config_msg}\n\n ${_text}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
message(STATUS "C Compiler: \"${CMAKE_C_COMPILER_ID}\"")
|
||||
message(STATUS "C++ Compiler: \"${CMAKE_CXX_COMPILER_ID}\"")
|
||||
|
88
GNUmakefile
88
GNUmakefile
@@ -43,6 +43,11 @@ ifndef BUILD_DIR
|
||||
BUILD_DIR:=$(shell dirname "$(BLENDER_DIR)")/build_$(OS_NCASE)
|
||||
endif
|
||||
|
||||
# Allow to use alternative binary (pypy3, etc)
|
||||
ifndef PYTHON
|
||||
PYTHON:=python3
|
||||
endif
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# additional targets for the build configuration
|
||||
@@ -76,18 +81,20 @@ endif
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Get the number of cores for threaded build
|
||||
NPROCS:=1
|
||||
ifeq ($(OS), Linux)
|
||||
NPROCS:=$(shell nproc)
|
||||
endif
|
||||
ifeq ($(OS), Darwin)
|
||||
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f3)
|
||||
endif
|
||||
ifeq ($(OS), FreeBSD)
|
||||
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
|
||||
endif
|
||||
ifeq ($(OS), NetBSD)
|
||||
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
|
||||
ifndef NPROCS
|
||||
NPROCS:=1
|
||||
ifeq ($(OS), Linux)
|
||||
NPROCS:=$(shell nproc)
|
||||
endif
|
||||
ifeq ($(OS), Darwin)
|
||||
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f3)
|
||||
endif
|
||||
ifeq ($(OS), FreeBSD)
|
||||
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
|
||||
endif
|
||||
ifeq ($(OS), NetBSD)
|
||||
NPROCS:=$(shell sysctl -a | grep "hw.ncpu" | cut -d" " -f2 )
|
||||
endif
|
||||
endif
|
||||
|
||||
|
||||
@@ -117,12 +124,12 @@ all: FORCE
|
||||
@echo
|
||||
@echo Configuring Blender ...
|
||||
|
||||
# if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
|
||||
# $(CMAKE_CONFIG); \
|
||||
# fi
|
||||
# # if test ! -f $(BUILD_DIR)/CMakeCache.txt ; then \
|
||||
# # $(CMAKE_CONFIG); \
|
||||
# # fi
|
||||
|
||||
# do this always incase of failed initial build, could be smarter here...
|
||||
$(CMAKE_CONFIG)
|
||||
# # do this always incase of failed initial build, could be smarter here...
|
||||
@$(CMAKE_CONFIG)
|
||||
|
||||
@echo
|
||||
@echo Building Blender ...
|
||||
@@ -201,6 +208,12 @@ help: FORCE
|
||||
@echo " * tgz - create a compressed archive of the source code."
|
||||
@echo " * update - updates git and all submodules"
|
||||
@echo ""
|
||||
@echo "Environment Variables"
|
||||
@echo " * BUILD_CMAKE_ARGS - arguments passed to CMake."
|
||||
@echo " * BUILD_DIR - override default build path."
|
||||
@echo " * PYTHON - use this for the Python command (used for checking tools)."
|
||||
@echo " * NPROCS - number of processes to use building (auto-detect when omitted)."
|
||||
@echo ""
|
||||
@echo "Documentation Targets (not associated with building blender)"
|
||||
@echo " * doc_py - generate sphinx python api docs"
|
||||
@echo " * doc_doxy - generate doxygen C/C++ docs"
|
||||
@@ -210,6 +223,7 @@ help: FORCE
|
||||
@echo "Information"
|
||||
@echo " * help - this help message"
|
||||
@echo " * help_features - show a list of optional features when building"
|
||||
@echo ""
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Packages
|
||||
@@ -233,21 +247,21 @@ test: FORCE
|
||||
|
||||
# run pep8 check check on scripts we distribute.
|
||||
test_pep8: FORCE
|
||||
python3 tests/python/pep8.py > test_pep8.log 2>&1
|
||||
$(PYTHON) tests/python/pep8.py > test_pep8.log 2>&1
|
||||
@echo "written: test_pep8.log"
|
||||
|
||||
# run some checks on our cmakefiles.
|
||||
test_cmake: FORCE
|
||||
python3 build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
|
||||
$(PYTHON) build_files/cmake/cmake_consistency_check.py > test_cmake_consistency.log 2>&1
|
||||
@echo "written: test_cmake_consistency.log"
|
||||
|
||||
# run deprecation tests, see if we have anything to remove.
|
||||
test_deprecated: FORCE
|
||||
python3 tests/check_deprecated.py
|
||||
$(PYTHON) tests/check_deprecated.py
|
||||
|
||||
test_style_c: FORCE
|
||||
# run our own checks on C/C++ style
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
|
||||
"$(BLENDER_DIR)/source/blender" \
|
||||
"$(BLENDER_DIR)/source/creator" \
|
||||
@@ -256,7 +270,7 @@ test_style_c: FORCE
|
||||
test_style_c_qtc: FORCE
|
||||
# run our own checks on C/C++ style
|
||||
USE_QTC_TASK=1 \
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
|
||||
"$(BLENDER_DIR)/source/blender" \
|
||||
"$(BLENDER_DIR)/source/creator" \
|
||||
@@ -268,7 +282,7 @@ test_style_c_qtc: FORCE
|
||||
|
||||
test_style_osl: FORCE
|
||||
# run our own checks on C/C++ style
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
|
||||
"$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
|
||||
"$(BLENDER_DIR)/release/scripts/templates_osl"
|
||||
@@ -277,7 +291,7 @@ test_style_osl: FORCE
|
||||
test_style_osl_qtc: FORCE
|
||||
# run our own checks on C/C++ style
|
||||
USE_QTC_TASK=1 \
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_style_c.py" \
|
||||
"$(BLENDER_DIR)/intern/cycles/kernel/shaders" \
|
||||
"$(BLENDER_DIR)/release/scripts/templates_osl" \
|
||||
@@ -290,10 +304,10 @@ test_style_osl_qtc: FORCE
|
||||
#
|
||||
|
||||
project_qtcreator: FORCE
|
||||
python3 build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
|
||||
$(PYTHON) build_files/cmake/cmake_qtcreator_project.py "$(BUILD_DIR)"
|
||||
|
||||
project_netbeans: FORCE
|
||||
python3 build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
|
||||
$(PYTHON) build_files/cmake/cmake_netbeans_project.py "$(BUILD_DIR)"
|
||||
|
||||
project_eclipse: FORCE
|
||||
cmake -G"Eclipse CDT4 - Unix Makefiles" -H"$(BLENDER_DIR)" -B"$(BUILD_DIR)"
|
||||
@@ -306,39 +320,39 @@ project_eclipse: FORCE
|
||||
check_cppcheck: FORCE
|
||||
$(CMAKE_CONFIG)
|
||||
cd "$(BUILD_DIR)" ; \
|
||||
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
|
||||
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_cppcheck.py" 2> \
|
||||
"$(BLENDER_DIR)/check_cppcheck.txt"
|
||||
@echo "written: check_cppcheck.txt"
|
||||
|
||||
check_clang_array: FORCE
|
||||
$(CMAKE_CONFIG)
|
||||
cd "$(BUILD_DIR)" ; \
|
||||
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
|
||||
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_clang_array.py"
|
||||
|
||||
check_splint: FORCE
|
||||
$(CMAKE_CONFIG)
|
||||
cd "$(BUILD_DIR)" ; \
|
||||
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
|
||||
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_splint.py"
|
||||
|
||||
check_sparse: FORCE
|
||||
$(CMAKE_CONFIG)
|
||||
cd "$(BUILD_DIR)" ; \
|
||||
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
|
||||
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_sparse.py"
|
||||
|
||||
check_smatch: FORCE
|
||||
$(CMAKE_CONFIG)
|
||||
cd "$(BUILD_DIR)" ; \
|
||||
python3 "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
|
||||
$(PYTHON) "$(BLENDER_DIR)/build_files/cmake/cmake_static_check_smatch.py"
|
||||
|
||||
check_spelling_py: FORCE
|
||||
cd "$(BUILD_DIR)" ; \
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
|
||||
"$(BLENDER_DIR)/release/scripts"
|
||||
|
||||
check_spelling_c: FORCE
|
||||
cd "$(BUILD_DIR)" ; \
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
|
||||
"$(BLENDER_DIR)/source" \
|
||||
"$(BLENDER_DIR)/intern/cycles" \
|
||||
@@ -347,7 +361,7 @@ check_spelling_c: FORCE
|
||||
|
||||
check_spelling_c_qtc: FORCE
|
||||
cd "$(BUILD_DIR)" ; USE_QTC_TASK=1 \
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
|
||||
"$(BLENDER_DIR)/source" \
|
||||
"$(BLENDER_DIR)/intern/cycles" \
|
||||
@@ -358,7 +372,7 @@ check_spelling_c_qtc: FORCE
|
||||
|
||||
check_spelling_osl: FORCE
|
||||
cd "$(BUILD_DIR)" ;\
|
||||
PYTHONIOENCODING=utf_8 python3 \
|
||||
PYTHONIOENCODING=utf_8 $(PYTHON) \
|
||||
"$(BLENDER_DIR)/source/tools/check_source/check_spelling.py" \
|
||||
"$(BLENDER_DIR)/intern/cycles/kernel/shaders"
|
||||
|
||||
@@ -404,10 +418,10 @@ doc_dna: FORCE
|
||||
@echo "docs written into: '$(BLENDER_DIR)/doc/blender_file_format/dna.html'"
|
||||
|
||||
doc_man: FORCE
|
||||
python3 doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
|
||||
$(PYTHON) doc/manpage/blender.1.py "$(BUILD_DIR)/bin/blender"
|
||||
|
||||
help_features: FORCE
|
||||
@python3 -c \
|
||||
@$(PYTHON) -c \
|
||||
"import re; \
|
||||
print('\n'.join([ \
|
||||
w for l in open('"$(BLENDER_DIR)"/CMakeLists.txt', 'r').readlines() \
|
||||
|
27
SConstruct
27
SConstruct
@@ -470,6 +470,14 @@ if env['OURPLATFORM']=='darwin':
|
||||
################### End Automatic configuration for OSX ##################
|
||||
#############################################################################
|
||||
|
||||
if env['OURPLATFORM'] == 'linux' and not env['C_COMPILER_ID']:
|
||||
command = ["%s"%env['CC'], "--version"]
|
||||
line = btools.get_command_output(command)
|
||||
if line.startswith('gcc'):
|
||||
env['C_COMPILER_ID'] = 'gcc'
|
||||
elif 'clang' in line[0]:
|
||||
env['C_COMPILER_ID'] = 'clang'
|
||||
|
||||
if env['WITH_BF_OPENMP'] == 1:
|
||||
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc'):
|
||||
env['CCFLAGS'].append('/openmp')
|
||||
@@ -1020,14 +1028,16 @@ if env['OURPLATFORM']!='darwin':
|
||||
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel')
|
||||
source=os.listdir('intern/cycles/kernel')
|
||||
if '__pycache__' in source: source.remove('__pycache__')
|
||||
source.remove('kernel.cpp')
|
||||
source.remove('CMakeLists.txt')
|
||||
source.remove('SConscript')
|
||||
source.remove('svm')
|
||||
source.remove('closure')
|
||||
source.remove('geom')
|
||||
source.remove('shaders')
|
||||
source.remove('osl')
|
||||
source.remove('split')
|
||||
source=['intern/cycles/kernel/'+s for s in source]
|
||||
source.append('intern/cycles/util/util_atomic.h')
|
||||
source.append('intern/cycles/util/util_color.h')
|
||||
source.append('intern/cycles/util/util_half.h')
|
||||
source.append('intern/cycles/util/util_math.h')
|
||||
@@ -1053,6 +1063,12 @@ if env['OURPLATFORM']!='darwin':
|
||||
if '__pycache__' in source: source.remove('__pycache__')
|
||||
source=['intern/cycles/kernel/geom/'+s for s in source]
|
||||
scriptinstall.append(env.Install(dir=dir,source=source))
|
||||
# split
|
||||
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'kernel', 'split')
|
||||
source=os.listdir('intern/cycles/kernel/split')
|
||||
if '__pycache__' in source: source.remove('__pycache__')
|
||||
source=['intern/cycles/kernel/split/'+s for s in source]
|
||||
scriptinstall.append(env.Install(dir=dir,source=source))
|
||||
|
||||
# licenses
|
||||
dir=os.path.join(env['BF_INSTALLDIR'], VERSION, 'scripts', 'addons','cycles', 'license')
|
||||
@@ -1284,6 +1300,15 @@ if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'win64-vc', 'linuxcross'):
|
||||
windlls = env.Install(dir=env['BF_INSTALLDIR'], source = dllsources)
|
||||
allinstall += windlls
|
||||
|
||||
# TODO(sergey): For unti we've got better way to deal with python binary
|
||||
if env['WITH_BF_PYTHON']:
|
||||
py_target = os.path.join(env['BF_INSTALLDIR'], VERSION, 'python', 'bin')
|
||||
if env['BF_DEBUG']:
|
||||
allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}_d.dll'])
|
||||
else:
|
||||
allinstall += env.Install(dir=py_target, source = ['${BF_PYTHON_LIBPATH}/${BF_PYTHON_DLL}.dll'])
|
||||
|
||||
|
||||
if env['OURPLATFORM'] == 'win64-mingw':
|
||||
dllsources = []
|
||||
|
||||
|
@@ -1374,7 +1374,7 @@ EOF
|
||||
cmake_d="$cmake_d -D CMAKE_INSTALL_PREFIX=$_inst"
|
||||
cmake_d="$cmake_d -D LLVM_ENABLE_FFI=ON"
|
||||
cmake_d="$cmake_d -D LLVM_TARGETS_TO_BUILD=X86"
|
||||
cmake_d="$cmake_d -D -DLLVM_ENABLE_TERMINFO=OFF"
|
||||
cmake_d="$cmake_d -D LLVM_ENABLE_TERMINFO=OFF"
|
||||
|
||||
if [ -d $_FFI_INCLUDE_DIR ]; then
|
||||
cmake_d="$cmake_d -D FFI_INCLUDE_DIR=$_FFI_INCLUDE_DIR"
|
||||
@@ -2287,7 +2287,7 @@ install_RPM() {
|
||||
OGG_DEV="libogg-devel"
|
||||
THEORA_DEV="libtheora-devel"
|
||||
|
||||
_packages="gcc gcc-c++ make scons libtiff-devel freetype-devel libjpeg-devel\
|
||||
_packages="gcc gcc-c++ make scons libtiff-devel libjpeg-devel\
|
||||
libpng-devel libX11-devel libXi-devel wget ncurses-devel \
|
||||
readline-devel $OPENJPEG_DEV openal-soft-devel \
|
||||
glew-devel yasm $THEORA_DEV $VORBIS_DEV $OGG_DEV patch \
|
||||
@@ -2301,7 +2301,7 @@ install_RPM() {
|
||||
if [ $RPM = "FEDORA" -o $RPM = "RHEL" ]; then
|
||||
OPENEXR_DEV="openexr-devel"
|
||||
|
||||
_packages="$_packages libsqlite3x-devel fftw-devel SDL-devel"
|
||||
_packages="$_packages freetype-devel libsqlite3x-devel fftw-devel SDL-devel"
|
||||
|
||||
if $WITH_ALL; then
|
||||
_packages="$_packages jack-audio-connection-kit-devel"
|
||||
@@ -2339,7 +2339,7 @@ install_RPM() {
|
||||
elif [ $RPM = "SUSE" ]; then
|
||||
OPENEXR_DEV="libopenexr-devel"
|
||||
|
||||
_packages="$_packages cmake sqlite3-devel fftw3-devel libSDL-devel"
|
||||
_packages="$_packages cmake freetype2-devel sqlite3-devel fftw3-devel libSDL-devel"
|
||||
|
||||
PRINT ""
|
||||
install_packages_RPM $_packages
|
||||
|
@@ -124,10 +124,12 @@ else:
|
||||
directory = 'public_html/download'
|
||||
|
||||
try:
|
||||
filename = os.path.join(directory, packagename)
|
||||
zf = z.open(package)
|
||||
f = file(os.path.join(directory, packagename), "wb")
|
||||
f = file(filename, "wb")
|
||||
|
||||
shutil.copyfileobj(zf, f)
|
||||
os.chmod(filename, 0644)
|
||||
|
||||
zf.close()
|
||||
z.close()
|
||||
|
@@ -59,7 +59,8 @@ FIND_LIBRARY(OPENIMAGEIO_LIBRARY
|
||||
FIND_FILE(OPENIMAGEIO_IDIFF
|
||||
NAMES
|
||||
idiff
|
||||
${OPENIMAGEIO_ROOT_DIR}
|
||||
HINTS
|
||||
${OPENIMAGEIO_ROOT_DIR}
|
||||
PATH_SUFFIXES
|
||||
bin
|
||||
)
|
||||
|
@@ -66,6 +66,14 @@ IF(DEFINED PYTHON_LIBPATH)
|
||||
SET(_IS_LIB_PATH_DEF ON)
|
||||
ENDIF()
|
||||
|
||||
STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
|
||||
|
||||
SET(_python_SEARCH_DIRS
|
||||
${PYTHON_ROOT_DIR}
|
||||
"$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
|
||||
"/opt/py${_PYTHON_VERSION_NO_DOTS}"
|
||||
"/opt/lib/python-${PYTHON_VERSION}"
|
||||
)
|
||||
|
||||
# only search for the dirs if we havn't already
|
||||
IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_LIB_PATH_DEF))
|
||||
@@ -75,14 +83,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
|
||||
"dm;dmu;du;d" # debug
|
||||
)
|
||||
|
||||
STRING(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})
|
||||
|
||||
SET(_python_SEARCH_DIRS
|
||||
${PYTHON_ROOT_DIR}
|
||||
"$ENV{HOME}/py${_PYTHON_VERSION_NO_DOTS}"
|
||||
"/opt/py${_PYTHON_VERSION_NO_DOTS}"
|
||||
"/opt/lib/python-${PYTHON_VERSION}"
|
||||
)
|
||||
|
||||
FOREACH(_CURRENT_ABI_FLAGS ${_python_ABI_FLAGS})
|
||||
#IF(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
@@ -147,6 +148,7 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
|
||||
ENDIF()
|
||||
|
||||
IF(PYTHON_LIBRARY AND PYTHON_LIBPATH AND PYTHON_INCLUDE_DIR AND PYTHON_INCLUDE_CONFIG_DIR)
|
||||
SET(_PYTHON_ABI_FLAGS "${_CURRENT_ABI_FLAGS}")
|
||||
break()
|
||||
ELSE()
|
||||
# ensure we dont find values from 2 different ABI versions
|
||||
@@ -169,7 +171,6 @@ IF((NOT _IS_INC_DEF) OR (NOT _IS_INC_CONF_DEF) OR (NOT _IS_LIB_DEF) OR (NOT _IS_
|
||||
UNSET(_CURRENT_PATH)
|
||||
|
||||
UNSET(_python_ABI_FLAGS)
|
||||
UNSET(_python_SEARCH_DIRS)
|
||||
ENDIF()
|
||||
|
||||
UNSET(_IS_INC_DEF)
|
||||
@@ -201,14 +202,28 @@ IF(PYTHONLIBSUNIX_FOUND)
|
||||
# XXX No more valid with debian-like py3.4 packages...
|
||||
# GET_FILENAME_COMPONENT(PYTHON_LIBPATH ${PYTHON_LIBRARY} PATH)
|
||||
|
||||
# not used
|
||||
# SET(PYTHON_BINARY ${PYTHON_EXECUTABLE} CACHE STRING "")
|
||||
# not required for build, just used when bundling Python.
|
||||
FIND_PROGRAM(
|
||||
PYTHON_EXECUTABLE
|
||||
NAMES
|
||||
"python${PYTHON_VERSION}${_PYTHON_ABI_FLAGS}"
|
||||
"python${PYTHON_VERSION}"
|
||||
"python"
|
||||
HINTS
|
||||
${_python_SEARCH_DIRS}
|
||||
PATH_SUFFIXES bin
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
UNSET(_PYTHON_VERSION_NO_DOTS)
|
||||
UNSET(_PYTHON_ABI_FLAGS)
|
||||
UNSET(_python_SEARCH_DIRS)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
PYTHON_INCLUDE_DIR
|
||||
PYTHON_INCLUDE_CONFIG_DIR
|
||||
PYTHON_LIBRARY
|
||||
PYTHON_LIBPATH
|
||||
PYTHON_SITE_PACKAGES
|
||||
PYTHON_EXECUTABLE
|
||||
)
|
||||
|
@@ -28,13 +28,17 @@ if not sys.version.startswith("3"):
|
||||
sys.version.partition(" ")[0])
|
||||
sys.exit(1)
|
||||
|
||||
from cmake_consistency_check_config import IGNORE, UTF8_CHECK, SOURCE_DIR
|
||||
from cmake_consistency_check_config import (
|
||||
IGNORE,
|
||||
UTF8_CHECK,
|
||||
SOURCE_DIR,
|
||||
BUILD_DIR,
|
||||
)
|
||||
|
||||
|
||||
import os
|
||||
from os.path import join, dirname, normpath, splitext
|
||||
|
||||
print("Scanning:", SOURCE_DIR)
|
||||
|
||||
global_h = set()
|
||||
global_c = set()
|
||||
global_refs = {}
|
||||
@@ -134,6 +138,7 @@ def cmake_get_src(f):
|
||||
|
||||
if found:
|
||||
cmake_base = dirname(f)
|
||||
cmake_base_bin = os.path.join(BUILD_DIR, os.path.relpath(cmake_base, SOURCE_DIR))
|
||||
|
||||
while it is not None:
|
||||
i += 1
|
||||
@@ -154,6 +159,8 @@ def cmake_get_src(f):
|
||||
|
||||
# replace dirs
|
||||
l = l.replace("${CMAKE_CURRENT_SOURCE_DIR}", cmake_base)
|
||||
l = l.replace("${CMAKE_CURRENT_BINARY_DIR}", cmake_base_bin)
|
||||
l = l.strip('"')
|
||||
|
||||
if not l:
|
||||
pass
|
||||
@@ -193,13 +200,16 @@ def cmake_get_src(f):
|
||||
raise Exception("unknown file type - not c or h %s -> %s" % (f, new_file))
|
||||
|
||||
elif context_name == "INC":
|
||||
if os.path.isdir(new_file):
|
||||
if new_file.startswith(BUILD_DIR):
|
||||
# assume generated path
|
||||
pass
|
||||
elif os.path.isdir(new_file):
|
||||
new_path_rel = os.path.relpath(new_file, cmake_base)
|
||||
|
||||
if new_path_rel != l:
|
||||
print("overly relative path:\n %s:%d\n %s\n %s" % (f, i, l, new_path_rel))
|
||||
|
||||
## Save time. just replace the line
|
||||
# # Save time. just replace the line
|
||||
# replace_line(f, i - 1, new_path_rel)
|
||||
|
||||
else:
|
||||
@@ -230,10 +240,6 @@ def cmake_get_src(f):
|
||||
filen.close()
|
||||
|
||||
|
||||
for cmake in source_list(SOURCE_DIR, is_cmake):
|
||||
cmake_get_src(cmake)
|
||||
|
||||
|
||||
def is_ignore(f):
|
||||
for ig in IGNORE:
|
||||
if ig in f:
|
||||
@@ -241,73 +247,83 @@ def is_ignore(f):
|
||||
return False
|
||||
|
||||
|
||||
# First do stupid check, do these files exist?
|
||||
print("\nChecking for missing references:")
|
||||
is_err = False
|
||||
errs = []
|
||||
for f in (global_h | global_c):
|
||||
if f.endswith("dna.c"):
|
||||
continue
|
||||
def main():
|
||||
|
||||
if not os.path.exists(f):
|
||||
refs = global_refs[f]
|
||||
if refs:
|
||||
for cf, i in refs:
|
||||
errs.append((cf, i))
|
||||
else:
|
||||
raise Exception("CMake referenecs missing, internal error, aborting!")
|
||||
is_err = True
|
||||
print("Scanning:", SOURCE_DIR)
|
||||
|
||||
errs.sort()
|
||||
errs.reverse()
|
||||
for cf, i in errs:
|
||||
print("%s:%d" % (cf, i))
|
||||
# Write a 'sed' script, useful if we get a lot of these
|
||||
# print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
|
||||
for cmake in source_list(SOURCE_DIR, is_cmake):
|
||||
cmake_get_src(cmake)
|
||||
|
||||
# First do stupid check, do these files exist?
|
||||
print("\nChecking for missing references:")
|
||||
is_err = False
|
||||
errs = []
|
||||
for f in (global_h | global_c):
|
||||
if f.startswith(BUILD_DIR):
|
||||
continue
|
||||
|
||||
if not os.path.exists(f):
|
||||
refs = global_refs[f]
|
||||
if refs:
|
||||
for cf, i in refs:
|
||||
errs.append((cf, i))
|
||||
else:
|
||||
raise Exception("CMake referenecs missing, internal error, aborting!")
|
||||
is_err = True
|
||||
|
||||
errs.sort()
|
||||
errs.reverse()
|
||||
for cf, i in errs:
|
||||
print("%s:%d" % (cf, i))
|
||||
# Write a 'sed' script, useful if we get a lot of these
|
||||
# print("sed '%dd' '%s' > '%s.tmp' ; mv '%s.tmp' '%s'" % (i, cf, cf, cf, cf))
|
||||
|
||||
|
||||
if is_err:
|
||||
raise Exception("CMake referenecs missing files, aborting!")
|
||||
del is_err
|
||||
del errs
|
||||
if is_err:
|
||||
raise Exception("CMake referenecs missing files, aborting!")
|
||||
del is_err
|
||||
del errs
|
||||
|
||||
# now check on files not accounted for.
|
||||
print("\nC/C++ Files CMake doesnt know about...")
|
||||
for cf in sorted(source_list(SOURCE_DIR, is_c)):
|
||||
if not is_ignore(cf):
|
||||
if cf not in global_c:
|
||||
print("missing_c: ", cf)
|
||||
# now check on files not accounted for.
|
||||
print("\nC/C++ Files CMake doesnt know about...")
|
||||
for cf in sorted(source_list(SOURCE_DIR, is_c)):
|
||||
if not is_ignore(cf):
|
||||
if cf not in global_c:
|
||||
print("missing_c: ", cf)
|
||||
|
||||
# check if automake builds a corrasponding .o file.
|
||||
'''
|
||||
if cf in global_c:
|
||||
out1 = os.path.splitext(cf)[0] + ".o"
|
||||
out2 = os.path.splitext(cf)[0] + ".Po"
|
||||
out2_dir, out2_file = out2 = os.path.split(out2)
|
||||
out2 = os.path.join(out2_dir, ".deps", out2_file)
|
||||
if not os.path.exists(out1) and not os.path.exists(out2):
|
||||
print("bad_c: ", cf)
|
||||
'''
|
||||
# check if automake builds a corrasponding .o file.
|
||||
'''
|
||||
if cf in global_c:
|
||||
out1 = os.path.splitext(cf)[0] + ".o"
|
||||
out2 = os.path.splitext(cf)[0] + ".Po"
|
||||
out2_dir, out2_file = out2 = os.path.split(out2)
|
||||
out2 = os.path.join(out2_dir, ".deps", out2_file)
|
||||
if not os.path.exists(out1) and not os.path.exists(out2):
|
||||
print("bad_c: ", cf)
|
||||
'''
|
||||
|
||||
print("\nC/C++ Headers CMake doesnt know about...")
|
||||
for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
|
||||
if not is_ignore(hf):
|
||||
if hf not in global_h:
|
||||
print("missing_h: ", hf)
|
||||
print("\nC/C++ Headers CMake doesnt know about...")
|
||||
for hf in sorted(source_list(SOURCE_DIR, is_c_header)):
|
||||
if not is_ignore(hf):
|
||||
if hf not in global_h:
|
||||
print("missing_h: ", hf)
|
||||
|
||||
if UTF8_CHECK:
|
||||
# test encoding
|
||||
import traceback
|
||||
for files in (global_c, global_h):
|
||||
for f in sorted(files):
|
||||
if os.path.exists(f):
|
||||
# ignore outside of our source tree
|
||||
if "extern" not in f:
|
||||
i = 1
|
||||
try:
|
||||
for l in open(f, "r", encoding="utf8"):
|
||||
i += 1
|
||||
except UnicodeDecodeError:
|
||||
print("Non utf8: %s:%d" % (f, i))
|
||||
if i > 1:
|
||||
traceback.print_exc()
|
||||
if UTF8_CHECK:
|
||||
# test encoding
|
||||
import traceback
|
||||
for files in (global_c, global_h):
|
||||
for f in sorted(files):
|
||||
if os.path.exists(f):
|
||||
# ignore outside of our source tree
|
||||
if "extern" not in f:
|
||||
i = 1
|
||||
try:
|
||||
for l in open(f, "r", encoding="utf8"):
|
||||
i += 1
|
||||
except UnicodeDecodeError:
|
||||
print("Non utf8: %s:%d" % (f, i))
|
||||
if i > 1:
|
||||
traceback.print_exc()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
@@ -74,3 +74,6 @@ IGNORE = (
|
||||
UTF8_CHECK = True
|
||||
|
||||
SOURCE_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(os.path.dirname(__file__), "..", ".."))))
|
||||
|
||||
# doesn't have to exist, just use as reference
|
||||
BUILD_DIR = os.path.normpath(os.path.abspath(os.path.normpath(os.path.join(SOURCE_DIR, "..", "build"))))
|
||||
|
@@ -40,6 +40,7 @@ from project_info import (
|
||||
# is_py,
|
||||
cmake_advanced_info,
|
||||
cmake_compiler_defines,
|
||||
cmake_cache_var,
|
||||
project_name_get,
|
||||
)
|
||||
|
||||
@@ -71,6 +72,10 @@ def create_nb_project_main():
|
||||
# be tricky, get the project name from git if we can!
|
||||
PROJECT_NAME = project_name_get()
|
||||
|
||||
|
||||
make_exe = cmake_cache_var("CMAKE_MAKE_PROGRAM")
|
||||
make_exe_basename = os.path.basename(make_exe)
|
||||
|
||||
# --------------- NB spesific
|
||||
defines = [("%s=%s" % cdef) if cdef[1] else cdef[0] for cdef in defines]
|
||||
defines += [cdef.replace("#define", "").strip() for cdef in cmake_compiler_defines()]
|
||||
@@ -131,9 +136,9 @@ def create_nb_project_main():
|
||||
f = open(join(PROJECT_DIR_NB, "configurations.xml"), 'w')
|
||||
|
||||
f.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
f.write('<configurationDescriptor version="94">\n')
|
||||
f.write('<configurationDescriptor version="95">\n')
|
||||
f.write(' <logicalFolder name="root" displayName="root" projectFiles="true" kind="ROOT">\n')
|
||||
f.write(' <df name="0" root="%s">\n' % SOURCE_DIR) # base_root_rel
|
||||
f.write(' <df root="%s" name="0">\n' % SOURCE_DIR) # base_root_rel
|
||||
|
||||
# write files!
|
||||
files_rel_local = [normpath(relpath(join(CMAKE_DIR, path), SOURCE_DIR)) for path in files_rel]
|
||||
@@ -185,16 +190,27 @@ def create_nb_project_main():
|
||||
|
||||
f.write(' <toolsSet>\n')
|
||||
f.write(' <compilerSet>default</compilerSet>\n')
|
||||
f.write(' <dependencyChecking>false</dependencyChecking>\n')
|
||||
f.write(' <rebuildPropChanged>false</rebuildPropChanged>\n')
|
||||
f.write(' </toolsSet>\n')
|
||||
f.write(' <dependencyChecking>false</dependencyChecking>\n')
|
||||
f.write(' <rebuildPropChanged>false</rebuildPropChanged>\n')
|
||||
f.write(' <codeAssistance>\n')
|
||||
f.write(' </codeAssistance>\n')
|
||||
f.write(' <makefileType>\n')
|
||||
|
||||
f.write(' <makeTool>\n')
|
||||
f.write(' <buildCommandWorkingDir>.</buildCommandWorkingDir>\n')
|
||||
f.write(' <buildCommand>${MAKE} -f Makefile</buildCommand>\n')
|
||||
f.write(' <cleanCommand>${MAKE} -f Makefile clean</cleanCommand>\n')
|
||||
|
||||
if make_exe_basename == "ninja":
|
||||
build_cmd = "ninja"
|
||||
clean_cmd = "ninja -t clean"
|
||||
else:
|
||||
build_cmd = "${MAKE} -f Makefile"
|
||||
clean_cmd = "${MAKE} -f Makefile clean"
|
||||
|
||||
f.write(' <buildCommand>%s</buildCommand>\n' % build_cmd)
|
||||
f.write(' <cleanCommand>%s</cleanCommand>\n' % clean_cmd)
|
||||
f.write(' <executablePath>./bin/blender</executablePath>\n')
|
||||
del build_cmd, clean_cmd
|
||||
|
||||
def write_toolinfo():
|
||||
f.write(' <incDir>\n')
|
||||
@@ -221,10 +237,11 @@ def create_nb_project_main():
|
||||
f.write(' \n')
|
||||
|
||||
for path in files_rel_local:
|
||||
is_c = path.endswith(".c")
|
||||
f.write(' <item path="%s"\n' % path)
|
||||
f.write(' ex="false"\n')
|
||||
f.write(' tool="1"\n')
|
||||
f.write(' flavor2="0">\n')
|
||||
f.write(' tool="%d"\n' % (0 if is_c else 1))
|
||||
f.write(' flavor2="%d">\n' % (3 if is_c else 0))
|
||||
f.write(' </item>\n')
|
||||
|
||||
f.write(' <runprofile version="9">\n')
|
||||
|
@@ -16,6 +16,7 @@ set(WITH_CODEC_SNDFILE OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_CYCLES OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_FFTW3 OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_LIBMV OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_LLVM OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_GAMEENGINE OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_COMPOSITOR OFF CACHE BOOL "" FORCE)
|
||||
set(WITH_FREESTYLE OFF CACHE BOOL "" FORCE)
|
||||
|
@@ -104,21 +104,31 @@ macro(file_list_suffix
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(target_link_libraries_optimized TARGET LIBS)
|
||||
function(target_link_libraries_optimized
|
||||
TARGET
|
||||
LIBS
|
||||
)
|
||||
|
||||
foreach(_LIB ${LIBS})
|
||||
target_link_libraries(${TARGET} optimized "${_LIB}")
|
||||
endforeach()
|
||||
unset(_LIB)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
function(target_link_libraries_debug
|
||||
TARGET
|
||||
LIBS
|
||||
)
|
||||
|
||||
macro(target_link_libraries_debug TARGET LIBS)
|
||||
foreach(_LIB ${LIBS})
|
||||
target_link_libraries(${TARGET} debug "${_LIB}")
|
||||
endforeach()
|
||||
unset(_LIB)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
function(target_link_libraries_decoupled
|
||||
target
|
||||
libraries_var
|
||||
)
|
||||
|
||||
macro(target_link_libraries_decoupled target libraries_var)
|
||||
if(NOT MSVC)
|
||||
target_link_libraries(${target} ${${libraries_var}})
|
||||
else()
|
||||
@@ -127,14 +137,15 @@ macro(target_link_libraries_decoupled target libraries_var)
|
||||
file_list_suffix(_libraries_debug "${${libraries_var}}" "_d")
|
||||
target_link_libraries_debug(${target} "${_libraries_debug}")
|
||||
target_link_libraries_optimized(${target} "${${libraries_var}}")
|
||||
unset(_libraries_debug)
|
||||
endif()
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
# Nicer makefiles with -I/1/foo/ instead of -I/1/2/3/../../foo/
|
||||
# use it instead of include_directories()
|
||||
macro(blender_include_dirs
|
||||
includes)
|
||||
function(blender_include_dirs
|
||||
includes
|
||||
)
|
||||
|
||||
set(_ALL_INCS "")
|
||||
foreach(_INC ${ARGV})
|
||||
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
|
||||
@@ -145,13 +156,12 @@ macro(blender_include_dirs
|
||||
##endif()
|
||||
endforeach()
|
||||
include_directories(${_ALL_INCS})
|
||||
unset(_INC)
|
||||
unset(_ABS_INC)
|
||||
unset(_ALL_INCS)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
function(blender_include_dirs_sys
|
||||
includes
|
||||
)
|
||||
|
||||
macro(blender_include_dirs_sys
|
||||
includes)
|
||||
set(_ALL_INCS "")
|
||||
foreach(_INC ${ARGV})
|
||||
get_filename_component(_ABS_INC ${_INC} ABSOLUTE)
|
||||
@@ -161,13 +171,11 @@ macro(blender_include_dirs_sys
|
||||
##endif()
|
||||
endforeach()
|
||||
include_directories(SYSTEM ${_ALL_INCS})
|
||||
unset(_INC)
|
||||
unset(_ABS_INC)
|
||||
unset(_ALL_INCS)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
macro(blender_source_group
|
||||
sources)
|
||||
function(blender_source_group
|
||||
sources
|
||||
)
|
||||
|
||||
# Group by location on disk
|
||||
source_group("Source Files" FILES CMakeLists.txt)
|
||||
@@ -177,23 +185,23 @@ macro(blender_source_group
|
||||
if((${_SRC_EXT} MATCHES ".h") OR
|
||||
(${_SRC_EXT} MATCHES ".hpp") OR
|
||||
(${_SRC_EXT} MATCHES ".hh"))
|
||||
source_group("Header Files" FILES ${_SRC})
|
||||
else()
|
||||
source_group("Source Files" FILES ${_SRC})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
unset(_SRC)
|
||||
unset(_SRC_EXT)
|
||||
endmacro()
|
||||
set(GROUP_ID "Header Files")
|
||||
else()
|
||||
set(GROUP_ID "Source Files")
|
||||
endif()
|
||||
source_group("${GROUP_ID}" FILES ${_SRC})
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
|
||||
# only MSVC uses SOURCE_GROUP
|
||||
macro(blender_add_lib_nolist
|
||||
function(blender_add_lib_nolist
|
||||
name
|
||||
sources
|
||||
includes
|
||||
includes_sys)
|
||||
includes_sys
|
||||
)
|
||||
|
||||
# message(STATUS "Configuring library ${name}")
|
||||
|
||||
@@ -213,22 +221,24 @@ macro(blender_add_lib_nolist
|
||||
# Not for system includes because they can resolve to the same path
|
||||
# list_assert_duplicates("${includes_sys}")
|
||||
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(blender_add_lib
|
||||
function(blender_add_lib
|
||||
name
|
||||
sources
|
||||
includes
|
||||
includes_sys)
|
||||
includes_sys
|
||||
)
|
||||
|
||||
blender_add_lib_nolist(${name} "${sources}" "${includes}" "${includes_sys}")
|
||||
|
||||
set_property(GLOBAL APPEND PROPERTY BLENDER_LINK_LIBS ${name})
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(SETUP_LIBDIRS)
|
||||
function(SETUP_LIBDIRS)
|
||||
|
||||
link_directories(${JPEG_LIBPATH} ${PNG_LIBPATH} ${ZLIB_LIBPATH} ${FREETYPE_LIBPATH})
|
||||
|
||||
if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs
|
||||
@@ -288,24 +298,27 @@ macro(SETUP_LIBDIRS)
|
||||
if(WIN32 AND NOT UNIX)
|
||||
link_directories(${PTHREADS_LIBPATH})
|
||||
endif()
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
macro(setup_liblinks
|
||||
target)
|
||||
function(setup_liblinks
|
||||
target
|
||||
)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
|
||||
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
|
||||
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${PLATFORM_LINKFLAGS}" PARENT_SCOPE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_DEBUG "${CMAKE_MODULE_LINKER_FLAGS_DEBUG} ${PLATFORM_LINKFLAGS_DEBUG}" PARENT_SCOPE)
|
||||
|
||||
target_link_libraries(${target}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${FREETYPE_LIBRARY})
|
||||
target_link_libraries(
|
||||
${target}
|
||||
${PNG_LIBRARIES}
|
||||
${ZLIB_LIBRARIES}
|
||||
${FREETYPE_LIBRARY}
|
||||
)
|
||||
|
||||
# since we are using the local libs for python when compiling msvc projects, we need to add _d when compiling debug versions
|
||||
if(WITH_PYTHON) # AND NOT WITH_PYTHON_MODULE # WIN32 needs
|
||||
@@ -402,11 +415,13 @@ macro(setup_liblinks
|
||||
unset(EXPAT_LIB_DEBUG)
|
||||
endif()
|
||||
else()
|
||||
target_link_libraries(${target}
|
||||
${OPENCOLLADA_LIBRARIES}
|
||||
${PCRE_LIBRARIES}
|
||||
${XML2_LIBRARIES}
|
||||
${EXPAT_LIB})
|
||||
target_link_libraries(
|
||||
${target}
|
||||
${OPENCOLLADA_LIBRARIES}
|
||||
${PCRE_LIBRARIES}
|
||||
${XML2_LIBRARIES}
|
||||
${EXPAT_LIB}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_MEM_JEMALLOC)
|
||||
@@ -436,9 +451,11 @@ macro(setup_liblinks
|
||||
${BLENDER_GL_LIBRARIES})
|
||||
|
||||
target_link_libraries(${target} ${PLATFORM_LINKLIBS} ${CMAKE_DL_LIBS})
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
|
||||
function(SETUP_BLENDER_SORTED_LIBS)
|
||||
|
||||
macro(SETUP_BLENDER_SORTED_LIBS)
|
||||
get_property(BLENDER_LINK_LIBS GLOBAL PROPERTY BLENDER_LINK_LIBS)
|
||||
|
||||
list(APPEND BLENDER_LINK_LIBS
|
||||
@@ -524,6 +541,7 @@ macro(SETUP_BLENDER_SORTED_LIBS)
|
||||
bf_blenloader
|
||||
bf_imbuf
|
||||
bf_blenlib
|
||||
bf_depsgraph
|
||||
bf_intern_ghost
|
||||
bf_intern_string
|
||||
bf_avi
|
||||
@@ -673,14 +691,12 @@ macro(SETUP_BLENDER_SORTED_LIBS)
|
||||
message(STATUS "Blender Skipping: (${REM_MSG})")
|
||||
endif()
|
||||
|
||||
unset(SEARCHLIB)
|
||||
unset(SORTLIB)
|
||||
unset(REMLIB)
|
||||
unset(REM_MSG)
|
||||
|
||||
set(BLENDER_SORTED_LIBS ${BLENDER_SORTED_LIBS} PARENT_SCOPE)
|
||||
|
||||
# for top-level tests
|
||||
set_property(GLOBAL PROPERTY BLENDER_SORTED_LIBS_PROP ${BLENDER_SORTED_LIBS})
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
macro(TEST_SSE_SUPPORT
|
||||
_sse_flags
|
||||
@@ -902,19 +918,22 @@ endmacro()
|
||||
|
||||
# utility macro
|
||||
macro(remove_cc_flag
|
||||
flag)
|
||||
_flag)
|
||||
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
foreach(flag ${ARGV})
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
|
||||
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL}")
|
||||
string(REGEX REPLACE ${flag} "" CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO}")
|
||||
endforeach()
|
||||
unset(flag)
|
||||
|
||||
endmacro()
|
||||
|
||||
@@ -928,28 +947,34 @@ endmacro()
|
||||
macro(remove_strict_flags)
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
remove_cc_flag("-Wstrict-prototypes")
|
||||
remove_cc_flag("-Wmissing-prototypes")
|
||||
remove_cc_flag("-Wunused-parameter")
|
||||
remove_cc_flag("-Wunused-macros")
|
||||
remove_cc_flag("-Wwrite-strings")
|
||||
remove_cc_flag("-Wredundant-decls")
|
||||
remove_cc_flag("-Wundef")
|
||||
remove_cc_flag("-Wshadow")
|
||||
remove_cc_flag("-Wdouble-promotion")
|
||||
remove_cc_flag("-Wold-style-definition")
|
||||
remove_cc_flag("-Werror=[^ ]+")
|
||||
remove_cc_flag("-Werror")
|
||||
remove_cc_flag(
|
||||
"-Wstrict-prototypes"
|
||||
"-Wmissing-prototypes"
|
||||
"-Wmissing-format-attribute"
|
||||
"-Wunused-local-typedefs"
|
||||
"-Wunused-macros"
|
||||
"-Wunused-parameter"
|
||||
"-Wwrite-strings"
|
||||
"-Wredundant-decls"
|
||||
"-Wundef"
|
||||
"-Wshadow"
|
||||
"-Wdouble-promotion"
|
||||
"-Wold-style-definition"
|
||||
"-Werror=[^ ]+"
|
||||
"-Werror"
|
||||
)
|
||||
|
||||
# negate flags implied by '-Wall'
|
||||
add_cc_flag("${CC_REMOVE_STRICT_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
remove_cc_flag("-Wunused-parameter")
|
||||
remove_cc_flag("-Wunused-variable")
|
||||
remove_cc_flag("-Werror=[^ ]+")
|
||||
remove_cc_flag("-Werror")
|
||||
remove_cc_flag(
|
||||
"-Wunused-parameter"
|
||||
"-Wunused-variable"
|
||||
"-Werror=[^ ]+"
|
||||
"-Werror"
|
||||
)
|
||||
|
||||
# negate flags implied by '-Wall'
|
||||
add_cc_flag("${CC_REMOVE_STRICT_FLAGS}")
|
||||
@@ -963,11 +988,15 @@ endmacro()
|
||||
|
||||
macro(remove_extra_strict_flags)
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
remove_cc_flag("-Wunused-parameter")
|
||||
remove_cc_flag(
|
||||
"-Wunused-parameter"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
remove_cc_flag("-Wunused-parameter")
|
||||
remove_cc_flag(
|
||||
"-Wunused-parameter"
|
||||
)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
@@ -1003,37 +1032,39 @@ macro(remove_strict_flags_file
|
||||
endmacro()
|
||||
|
||||
|
||||
macro(ADD_CHECK_C_COMPILER_FLAG
|
||||
function(ADD_CHECK_C_COMPILER_FLAG
|
||||
_CFLAGS
|
||||
_CACHE_VAR
|
||||
_FLAG)
|
||||
_FLAG
|
||||
)
|
||||
|
||||
include(CheckCCompilerFlag)
|
||||
|
||||
CHECK_C_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
|
||||
if(${_CACHE_VAR})
|
||||
# message(STATUS "Using CFLAG: ${_FLAG}")
|
||||
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}")
|
||||
set(${_CFLAGS} "${${_CFLAGS}} ${_FLAG}" PARENT_SCOPE)
|
||||
else()
|
||||
message(STATUS "Unsupported CFLAG: ${_FLAG}")
|
||||
endif()
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
macro(ADD_CHECK_CXX_COMPILER_FLAG
|
||||
function(ADD_CHECK_CXX_COMPILER_FLAG
|
||||
_CXXFLAGS
|
||||
_CACHE_VAR
|
||||
_FLAG)
|
||||
_FLAG
|
||||
)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
CHECK_CXX_COMPILER_FLAG("${_FLAG}" "${_CACHE_VAR}")
|
||||
if(${_CACHE_VAR})
|
||||
# message(STATUS "Using CXXFLAG: ${_FLAG}")
|
||||
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}")
|
||||
set(${_CXXFLAGS} "${${_CXXFLAGS}} ${_FLAG}" PARENT_SCOPE)
|
||||
else()
|
||||
message(STATUS "Unsupported CXXFLAG: ${_FLAG}")
|
||||
endif()
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
function(get_blender_version)
|
||||
# extracts header vars and defines them in the parent scope:
|
||||
@@ -1183,7 +1214,7 @@ endmacro()
|
||||
# pair of macros to allow libraries to be specify files to install, but to
|
||||
# only install them at the end so the directories don't get cleared with
|
||||
# the files in them. used by cycles to install addon.
|
||||
macro(delayed_install
|
||||
function(delayed_install
|
||||
base
|
||||
files
|
||||
destination)
|
||||
@@ -1196,8 +1227,7 @@ macro(delayed_install
|
||||
endif()
|
||||
set_property(GLOBAL APPEND PROPERTY DELAYED_INSTALL_DESTINATIONS ${destination})
|
||||
endforeach()
|
||||
unset(f)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
# note this is a function instead of a macro so that ${BUILD_TYPE} in targetdir
|
||||
# does not get expanded in calling but is preserved
|
||||
@@ -1216,16 +1246,17 @@ function(delayed_do_install
|
||||
list(GET destinations ${i} d)
|
||||
install(FILES ${f} DESTINATION ${targetdir}/${d})
|
||||
endforeach()
|
||||
unset(f)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(data_to_c
|
||||
file_from file_to
|
||||
list_to_add)
|
||||
function(data_to_c
|
||||
file_from file_to
|
||||
list_to_add
|
||||
)
|
||||
|
||||
list(APPEND ${list_to_add} ${file_to})
|
||||
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
|
||||
|
||||
get_filename_component(_file_to_path ${file_to} PATH)
|
||||
|
||||
@@ -1236,21 +1267,21 @@ macro(data_to_c
|
||||
DEPENDS ${file_from} datatoc)
|
||||
|
||||
set_source_files_properties(${file_to} PROPERTIES GENERATED TRUE)
|
||||
|
||||
unset(_file_to_path)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
|
||||
# same as above but generates the var name and output automatic.
|
||||
macro(data_to_c_simple
|
||||
file_from
|
||||
list_to_add)
|
||||
function(data_to_c_simple
|
||||
file_from
|
||||
list_to_add
|
||||
)
|
||||
|
||||
# remove ../'s
|
||||
get_filename_component(_file_from ${CMAKE_CURRENT_SOURCE_DIR}/${file_from} REALPATH)
|
||||
get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${file_from}.c REALPATH)
|
||||
|
||||
list(APPEND ${list_to_add} ${_file_to})
|
||||
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
|
||||
|
||||
get_filename_component(_file_to_path ${_file_to} PATH)
|
||||
|
||||
@@ -1261,17 +1292,13 @@ macro(data_to_c_simple
|
||||
DEPENDS ${_file_from} datatoc)
|
||||
|
||||
set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)
|
||||
|
||||
unset(_file_from)
|
||||
unset(_file_to)
|
||||
unset(_file_to_path)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
# macro for converting pixmap directory to a png and then a c file
|
||||
macro(data_to_c_simple_icons
|
||||
path_from
|
||||
list_to_add
|
||||
)
|
||||
function(data_to_c_simple_icons
|
||||
path_from
|
||||
list_to_add
|
||||
)
|
||||
|
||||
# Conversion steps
|
||||
# path_from -> _file_from -> _file_to
|
||||
@@ -1283,6 +1310,7 @@ macro(data_to_c_simple_icons
|
||||
get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${path_from}.png.c REALPATH)
|
||||
|
||||
list(APPEND ${list_to_add} ${_file_to})
|
||||
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
|
||||
|
||||
get_filename_component(_file_to_path ${_file_to} PATH)
|
||||
|
||||
@@ -1304,27 +1332,22 @@ macro(data_to_c_simple_icons
|
||||
)
|
||||
|
||||
set_source_files_properties(${_file_from} ${_file_to} PROPERTIES GENERATED TRUE)
|
||||
|
||||
unset(_path_from_abs)
|
||||
unset(_file_from)
|
||||
unset(_file_to)
|
||||
unset(_file_to_path)
|
||||
unset(_icon_files)
|
||||
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
# XXX Not used for now...
|
||||
macro(svg_to_png
|
||||
file_from
|
||||
file_to
|
||||
dpi
|
||||
list_to_add)
|
||||
function(svg_to_png
|
||||
file_from
|
||||
file_to
|
||||
dpi
|
||||
list_to_add
|
||||
)
|
||||
|
||||
# remove ../'s
|
||||
get_filename_component(_file_from ${CMAKE_CURRENT_SOURCE_DIR}/${file_from} REALPATH)
|
||||
get_filename_component(_file_to ${CMAKE_CURRENT_SOURCE_DIR}/${file_to} REALPATH)
|
||||
|
||||
list(APPEND ${list_to_add} ${_file_to})
|
||||
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
|
||||
|
||||
find_program(INKSCAPE_EXE inkscape)
|
||||
mark_as_advanced(INKSCAPE_EXE)
|
||||
@@ -1347,15 +1370,12 @@ macro(svg_to_png
|
||||
else()
|
||||
message(WARNING "Inkscape not found, could not re-generate ${_file_to} from ${_file_from}!")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
unset(_file_from)
|
||||
unset(_file_to)
|
||||
|
||||
endmacro()
|
||||
|
||||
macro(msgfmt_simple
|
||||
file_from
|
||||
list_to_add)
|
||||
function(msgfmt_simple
|
||||
file_from
|
||||
list_to_add
|
||||
)
|
||||
|
||||
# remove ../'s
|
||||
get_filename_component(_file_from_we ${file_from} NAME_WE)
|
||||
@@ -1364,6 +1384,7 @@ macro(msgfmt_simple
|
||||
get_filename_component(_file_to ${CMAKE_CURRENT_BINARY_DIR}/${_file_from_we}.mo REALPATH)
|
||||
|
||||
list(APPEND ${list_to_add} ${_file_to})
|
||||
set(${list_to_add} ${${list_to_add}} PARENT_SCOPE)
|
||||
|
||||
get_filename_component(_file_to_path ${_file_to} PATH)
|
||||
|
||||
@@ -1374,15 +1395,11 @@ macro(msgfmt_simple
|
||||
DEPENDS msgfmt ${_file_from})
|
||||
|
||||
set_source_files_properties(${_file_to} PROPERTIES GENERATED TRUE)
|
||||
endfunction()
|
||||
|
||||
unset(_file_from_we)
|
||||
unset(_file_from)
|
||||
unset(_file_to)
|
||||
unset(_file_to_path)
|
||||
endmacro()
|
||||
|
||||
macro(find_python_package
|
||||
package)
|
||||
function(find_python_package
|
||||
package
|
||||
)
|
||||
|
||||
string(TOUPPER ${package} _upper_package)
|
||||
|
||||
@@ -1420,25 +1437,17 @@ macro(find_python_package
|
||||
"'${PYTHON_LIBPATH}/python${PYTHON_VERSION}/dist-packages/${package}', "
|
||||
"'${PYTHON_LIBPATH}/python${_PY_VER_MAJOR}/dist-packages/${package}', "
|
||||
"WITH_PYTHON_INSTALL_${_upper_package} option will be ignored when installing python")
|
||||
set(WITH_PYTHON_INSTALL_${_upper_package} OFF)
|
||||
set(WITH_PYTHON_INSTALL_${_upper_package} OFF PARENT_SCOPE)
|
||||
else()
|
||||
message(STATUS "${package} found at '${PYTHON_${_upper_package}_PATH}'")
|
||||
endif()
|
||||
|
||||
unset(_PY_VER_SPLIT)
|
||||
unset(_PY_VER_MAJOR)
|
||||
endif()
|
||||
|
||||
unset(_upper_package)
|
||||
endmacro()
|
||||
endfunction()
|
||||
|
||||
# like Python's 'print(dir())'
|
||||
macro(print_all_vars)
|
||||
function(print_all_vars)
|
||||
get_cmake_property(_vars VARIABLES)
|
||||
foreach(_var ${_vars})
|
||||
message("${_var}=${${_var}}")
|
||||
endforeach()
|
||||
unset(_vars)
|
||||
unset(_var)
|
||||
endmacro()
|
||||
|
||||
endfunction()
|
||||
|
@@ -112,3 +112,9 @@ elseif(UNIX)
|
||||
"tar.bz2")
|
||||
endif()
|
||||
|
||||
unset(MAJOR_VERSION)
|
||||
unset(MINOR_VERSION)
|
||||
unset(PATCH_VERSION)
|
||||
|
||||
unset(BUILD_REV)
|
||||
|
||||
|
@@ -130,7 +130,7 @@ def is_project_file(filename):
|
||||
|
||||
|
||||
def cmake_advanced_info():
|
||||
""" Extracr includes and defines from cmake.
|
||||
""" Extract includes and defines from cmake.
|
||||
"""
|
||||
|
||||
make_exe = cmake_cache_var("CMAKE_MAKE_PROGRAM")
|
||||
|
@@ -206,7 +206,7 @@ WITH_BF_CYCLES = WITH_BF_OIIO and WITH_BF_BOOST
|
||||
|
||||
WITH_BF_CYCLES_CUDA_BINARIES = False
|
||||
BF_CYCLES_CUDA_NVCC = '/usr/local/cuda/bin/nvcc'
|
||||
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
|
||||
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
|
||||
|
||||
WITH_BF_OPENMP = True
|
||||
|
||||
|
@@ -145,7 +145,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib/opencollada'
|
||||
WITH_BF_CYCLES = True
|
||||
WITH_BF_CYCLES_CUDA_BINARIES = False
|
||||
BF_CYCLES_CUDA_NVCC = "" # Path to the NVIDIA CUDA compiler
|
||||
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
|
||||
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
|
||||
|
||||
WITH_BF_OIIO = True
|
||||
BF_OIIO = LIBDIR + '/openimageio'
|
||||
|
@@ -144,7 +144,7 @@ BF_OPENCOLLADA_LIBPATH = '${BF_OPENCOLLADA}/lib/opencollada'
|
||||
WITH_BF_CYCLES = True
|
||||
WITH_BF_CYCLES_CUDA_BINARIES = False
|
||||
BF_CYCLES_CUDA_NVCC = "" # Path to the NVIDIA CUDA compiler
|
||||
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50']
|
||||
BF_CYCLES_CUDA_BINARIES_ARCH = ['sm_20', 'sm_21', 'sm_30', 'sm_35', 'sm_50', 'sm_52']
|
||||
|
||||
WITH_BF_OIIO = True
|
||||
BF_OIIO = LIBDIR + '/openimageio'
|
||||
|
@@ -372,7 +372,7 @@ def propose_priorities():
|
||||
def creator(env):
|
||||
sources = ['creator.c']# + Blender.buildinfo(env, "dynamic") + Blender.resources
|
||||
|
||||
incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', env['BF_OPENGL_INC']]
|
||||
incs = ['#/intern/guardedalloc', '#/source/blender/blenlib', '#/source/blender/blenkernel', '#/source/blender/depsgraph', '#/source/blender/editors/include', '#/source/blender/blenloader', '#/source/blender/imbuf', '#/source/blender/renderconverter', '#/source/blender/render/extern/include', '#/source/blender/windowmanager', '#/source/blender/makesdna', '#/source/blender/makesrna', '#/source/gameengine/BlenderRoutines', '#/extern/glew/include', '#/source/blender/gpu', env['BF_OPENGL_INC']]
|
||||
|
||||
defs = []
|
||||
|
||||
@@ -630,7 +630,7 @@ def WinPyBundle(target=None, source=None, env=None):
|
||||
py_tar+= '/release/python' + env['BF_PYTHON_VERSION'].replace('.','') + '.tar.gz'
|
||||
|
||||
py_target = env.subst(env['BF_INSTALLDIR']).lstrip("#")
|
||||
py_target = os.path.join(py_target, VERSION, 'python', 'lib')
|
||||
py_target = os.path.join(py_target, VERSION, 'python')
|
||||
def printexception(func,path,ex):
|
||||
if os.path.exists(path): #do not report if path does not exist. eg on a fresh build.
|
||||
print str(func) + ' failed on ' + str(path)
|
||||
@@ -764,7 +764,7 @@ def AppIt(target=None, source=None, env=None):
|
||||
commands.getoutput(cmd)
|
||||
cmd = 'cp -R %s/kernel/*.h %s/kernel/*.cl %s/kernel/*.cu %s/kernel/' % (croot, croot, croot, cinstalldir)
|
||||
commands.getoutput(cmd)
|
||||
cmd = 'cp -R %s/kernel/svm %s/kernel/closure %s/kernel/geom %s/util/util_color.h %s/util/util_half.h %s/util/util_math.h %s/util/util_math_fast.h %s/util/util_transform.h %s/util/util_types.h %s/kernel/' % (croot, croot, croot, croot, croot, croot, croot, croot, croot, cinstalldir)
|
||||
cmd = 'cp -R %s/kernel/svm %s/kernel/closure %s/kernel/geom %s/kernel/split %s/kernel/kernels %s/util/util_color.h %s/util/util_half.h %s/util/util_math.h %s/util/util_math_fast.h %s/util/util_transform.h %s/util/util_types.h %s/util/util_atomic.h %s/kernel/' % (croot, croot, croot, croot, croot, croot, croot, croot, croot, croot, croot, croot, cinstalldir)
|
||||
commands.getoutput(cmd)
|
||||
cmd = 'cp -R %s/../intern/cycles/kernel/*.cubin %s/lib/' % (builddir, cinstalldir)
|
||||
commands.getoutput(cmd)
|
||||
@@ -843,6 +843,7 @@ def UnixPyBundle(target=None, source=None, env=None):
|
||||
|
||||
py_src = env.subst( env['BF_PYTHON_LIBPATH'] + '/python'+env['BF_PYTHON_VERSION'] )
|
||||
py_target = env.subst( dir + '/python/' + target_lib + '/python'+env['BF_PYTHON_VERSION'] )
|
||||
py_target_bin = env.subst(dir + '/python/bin')
|
||||
|
||||
# This is a bit weak, but dont install if its been installed before, makes rebuilds quite slow.
|
||||
if os.path.exists(py_target):
|
||||
@@ -862,6 +863,11 @@ def UnixPyBundle(target=None, source=None, env=None):
|
||||
except:
|
||||
pass
|
||||
|
||||
# install the executable
|
||||
run("rm -rf '%s'" % py_target_bin)
|
||||
os.makedirs(py_target_bin)
|
||||
run("cp '%s' '%s'" % (env.subst(env['BF_PYTHON_BINARY']), py_target_bin))
|
||||
|
||||
run("cp -R '%s' '%s'" % (py_src, os.path.dirname(py_target)))
|
||||
run("rm -rf '%s/distutils'" % py_target)
|
||||
run("rm -rf '%s/lib2to3'" % py_target)
|
||||
|
@@ -199,7 +199,7 @@ def validate_arguments(args, bc):
|
||||
'LLIBS', 'PLATFORM_LINKFLAGS', 'MACOSX_ARCHITECTURE', 'MACOSX_SDK', 'XCODE_CUR_VER', 'C_COMPILER_ID',
|
||||
'BF_CYCLES_CUDA_BINARIES_ARCH', 'BF_PROGRAM_LINKFLAGS', 'MACOSX_DEPLOYMENT_TARGET',
|
||||
'WITH_BF_CYCLES_DEBUG', 'WITH_BF_CYCLES_LOGGING',
|
||||
'WITH_BF_CPP11'
|
||||
'WITH_BF_CPP11', 'WITH_BF_LEGACY_DEPSGRAPH',
|
||||
]
|
||||
|
||||
|
||||
@@ -657,6 +657,8 @@ def read_opts(env, cfg, args):
|
||||
('BF_PROGRAM_LINKFLAGS', 'Link flags applied only to final binaries (blender and blenderplayer, not makesrna/makesdna)', ''),
|
||||
|
||||
(BoolVariable('WITH_BF_CPP11', '"Build with C++11 standard enabled, for development use only!', False)),
|
||||
|
||||
(BoolVariable('WITH_BF_LEGACY_DEPSGRAPH', 'Build Blender with legacy dependency graph', True)),
|
||||
) # end of opts.AddOptions()
|
||||
|
||||
return localopts
|
||||
|
2382
doc/doxygen/Doxyfile
2382
doc/doxygen/Doxyfile
File diff suppressed because it is too large
Load Diff
@@ -10,26 +10,14 @@
|
||||
* \ingroup intern
|
||||
*/
|
||||
|
||||
/** \defgroup boolop boolop
|
||||
* \ingroup intern
|
||||
*/
|
||||
|
||||
/** \defgroup ctr container
|
||||
* \ingroup intern
|
||||
*/
|
||||
|
||||
/** \defgroup decimation decimation
|
||||
* \ingroup intern
|
||||
*/
|
||||
|
||||
/** \defgroup elbeem elbeem
|
||||
* \ingroup intern
|
||||
*/
|
||||
|
||||
/** \defgroup bsp bsp
|
||||
* \ingroup intern
|
||||
*/
|
||||
|
||||
/** \defgroup iksolver iksolver
|
||||
* \ingroup intern
|
||||
*/
|
@@ -93,36 +93,44 @@
|
||||
|
||||
/* ================================ */
|
||||
|
||||
/** \defgroup blender blender */
|
||||
/** \defgroup blender Blender */
|
||||
|
||||
/** \defgroup blf blenfont
|
||||
/** \defgroup blf BlenFont
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup bke blenkernel
|
||||
/** \defgroup bke BlenKernel
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup bli blenlib
|
||||
/** \defgroup bli BlenLib
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup nodes nodes
|
||||
/** \defgroup depsgraph Dependency Graph
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup cmpnodes cmpnodes
|
||||
/** \defgroup bph Physics
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup nodes Nodes
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup cmpnodes Nodes (Compositor)
|
||||
* \ingroup nodes
|
||||
*/
|
||||
|
||||
/** \defgroup shdnodes shdnodes
|
||||
/** \defgroup shdnodes Nodes (Shader)
|
||||
* \ingroup nodes
|
||||
*/
|
||||
|
||||
/** \defgroup texnodes texnodes
|
||||
/** \defgroup texnodes Nodes (Texture)
|
||||
* \ingroup nodes
|
||||
*/
|
||||
/** \defgroup modifiers modifiers
|
||||
/** \defgroup modifiers Object Modifiers
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
@@ -132,29 +140,29 @@
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup ikplugin ikplugin
|
||||
/** \defgroup ikplugin IK Plugin
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
||||
/** \defgroup DNA sDNA
|
||||
/** \defgroup DNA Struct DNA (File Format)
|
||||
* \ingroup blender data
|
||||
*/
|
||||
/** \defgroup RNA RNA
|
||||
/** \defgroup RNA RNA (Data API)
|
||||
* \ingroup blender data
|
||||
*/
|
||||
|
||||
/** \defgroup blenloader .blend read and write functions
|
||||
/** \defgroup blenloader Blend file IO
|
||||
* \ingroup blender data
|
||||
* \todo check if \ref blo and \ref blenloader groups can be
|
||||
* merged in docs.
|
||||
*/
|
||||
|
||||
/** \defgroup quicktime quicktime
|
||||
/** \defgroup quicktime QuickTime
|
||||
* \ingroup blender
|
||||
|
||||
/** \defgroup gui GUI */
|
||||
|
||||
/** \defgroup wm windowmanager
|
||||
/** \defgroup wm Window Manager
|
||||
* \ingroup blender gui
|
||||
*/
|
||||
|
||||
@@ -324,7 +332,7 @@
|
||||
* \ingroup externformats
|
||||
*/
|
||||
|
||||
/** \defgroup imbuf IMage Buffer
|
||||
/** \defgroup imbuf Image Buffer (ImBuf)
|
||||
* \ingroup blender
|
||||
*/
|
||||
|
@@ -1,6 +1,6 @@
|
||||
"""
|
||||
.. _operator-execution_context:
|
||||
|
||||
"""
|
||||
Execution Context
|
||||
-----------------
|
||||
|
||||
|
47
doc/python_api/rst/bge.app.rst
Normal file
47
doc/python_api/rst/bge.app.rst
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
Application Data (bge.app)
|
||||
==========================
|
||||
|
||||
Module to access application values that remain unchanged during runtime.
|
||||
|
||||
.. module:: bge.app
|
||||
|
||||
.. data:: version
|
||||
|
||||
The Blender/BGE version as a tuple of 3 ints, eg. (2, 75, 1).
|
||||
|
||||
.. note:: Version tuples can be compared simply with (in)equality symbols;
|
||||
for example, ``(2, 74, 5) <= (2, 75, 0)`` returns True (lexical order).
|
||||
|
||||
:type: tuple of three ints
|
||||
|
||||
.. data:: version_string
|
||||
|
||||
The Blender/BGE version formatted as a string, eg. "2.75 (sub 1)".
|
||||
|
||||
:type: str
|
||||
|
||||
.. data:: version_char
|
||||
|
||||
The Blender/BGE version character (for minor releases).
|
||||
|
||||
:type: str
|
||||
|
||||
.. data:: has_texture_ffmpeg
|
||||
|
||||
True if the BGE has been built with FFmpeg support, enabling use of :class:`~bge.texture.ImageFFmpeg` and :class:`~bge.texture.VideoFFmpeg`.
|
||||
|
||||
:type: bool
|
||||
|
||||
.. data:: has_joystick
|
||||
|
||||
True if the BGE has been built with joystick support.
|
||||
|
||||
:type: bool
|
||||
|
||||
.. data:: has_physics
|
||||
|
||||
True if the BGE has been built with physics support.
|
||||
|
||||
:type: bool
|
||||
|
@@ -4,73 +4,84 @@ Physics Constraints (bge.constraints)
|
||||
|
||||
.. module:: bge.constraints
|
||||
|
||||
.. literalinclude:: ../examples/bge.constraints.py
|
||||
:language: rest
|
||||
:lines: 2-4
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. include:: ../examples/bge.constraints.py
|
||||
:start-line: 1
|
||||
:end-line: 4
|
||||
|
||||
.. literalinclude:: ../examples/bge.constraints.py
|
||||
:lines: 6-
|
||||
|
||||
.. function:: createConstraint(physicsid_1, physicsid_2, constraint_type, pivot_X, pivot_y, pivot_z, axis_x, axis_y, axis_z, flag)
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
.. function:: createConstraint( \
|
||||
physicsid_1, physicsid_2, constraint_type, \
|
||||
pivot_x=0.0, pivot_y=0.0, pivot_z=0.0, \
|
||||
axis_x=0.0, axis_y=0.0, axis_z=0.0, flag=0)
|
||||
|
||||
Creates a constraint.
|
||||
|
||||
:arg physicsid_1: the physics id of the first object in constraint
|
||||
:type physicsid: int
|
||||
:arg physicsid_1: The physics id of the first object in constraint.
|
||||
:type physicsid_1: int
|
||||
|
||||
:arg physicsid_2: the physics id of the second object in constraint
|
||||
:type physicsid2: int
|
||||
:arg physicsid_2: The physics id of the second object in constraint.
|
||||
:type physicsid_2: int
|
||||
|
||||
:arg constrainttype: the type of the constraint. The constraint types are:
|
||||
:type constrainttype: int
|
||||
- :class:`POINTTOPOINT_CONSTRAINT`
|
||||
- :class:`LINEHINGE_CONSTRAINT`
|
||||
- :class:`ANGULAR_CONSTRAINT`
|
||||
- :class:`CONETWIST_CONSTRAINT`
|
||||
- :class:`VEHICLE_CONSTRAINT`
|
||||
- :class:`GENERIC_6DOF_CONSTRAINT`
|
||||
|
||||
:arg pivot_X: pivot X position
|
||||
:type pivot_X: float (optional)
|
||||
:arg constraint_type: The type of the constraint, one of...
|
||||
|
||||
:arg pivot_Y: pivot Y position
|
||||
:type pivot_Y: float (optional)
|
||||
- :class:`POINTTOPOINT_CONSTRAINT`
|
||||
- :class:`LINEHINGE_CONSTRAINT`
|
||||
- :class:`ANGULAR_CONSTRAINT`
|
||||
- :class:`CONETWIST_CONSTRAINT`
|
||||
- :class:`VEHICLE_CONSTRAINT`
|
||||
- :class:`GENERIC_6DOF_CONSTRAINT`
|
||||
|
||||
:arg pivot_Z: pivot Z position
|
||||
:type pivot_Z: float (optional)
|
||||
:type constraint_type: int
|
||||
|
||||
:arg axis_X: X axis angle in degrees
|
||||
:type axis_X: float (optional)
|
||||
:arg pivot_x: Pivot X position. (optional)
|
||||
:type pivot_x: float
|
||||
|
||||
:arg axis_Y: Y axis angle in degrees
|
||||
:type axis_Y: float (optional)
|
||||
:arg pivot_y: Pivot Y position. (optional)
|
||||
:type pivot_y: float
|
||||
|
||||
:arg axis_Z: Z axis angle in degrees
|
||||
:type axis_Z: float (optional)
|
||||
:arg pivot_z: Pivot Z position. (optional)
|
||||
:type pivot_z: float
|
||||
|
||||
:arg flag: 128 to disable collision between linked bodies
|
||||
:type flag: int (optional)
|
||||
:arg axis_x: X axis angle in degrees. (optional)
|
||||
:type axis_x: float
|
||||
|
||||
:return: a constraint wrapper.
|
||||
:rtype: :class:`bge.types.KX_ConstraintWrapper`
|
||||
:arg axis_y: Y axis angle in degrees. (optional)
|
||||
:type axis_y: float
|
||||
|
||||
.. attribute:: error
|
||||
:arg axis_z: Z axis angle in degrees. (optional)
|
||||
:type axis_z: float
|
||||
|
||||
Symbolic constant string that indicates error.
|
||||
:arg flag: 128 to disable collision between linked bodies. (optional)
|
||||
:type flag: int
|
||||
|
||||
:return: A constraint wrapper.
|
||||
:rtype: :class:`~bge.types.KX_ConstraintWrapper`
|
||||
|
||||
.. function:: exportBulletFile(filename)
|
||||
|
||||
export a .bullet file
|
||||
Exports a file representing the dynamics world (usually using ``.bullet`` extension).
|
||||
|
||||
:arg filename: File name
|
||||
:type filename: string
|
||||
See `Bullet binary serialization <http://bulletphysics.org/mediawiki-1.5.8/index.php/Bullet_binary_serialization>`__.
|
||||
|
||||
:arg filename: File path.
|
||||
:type filename: str
|
||||
|
||||
.. function:: getAppliedImpulse(constraintId)
|
||||
|
||||
:arg constraintId: The id of the constraint.
|
||||
:type constraintId: int
|
||||
|
||||
:return: the most recent applied impulse.
|
||||
:return: The most recent applied impulse.
|
||||
:rtype: float
|
||||
|
||||
.. function:: getVehicleConstraint(constraintId)
|
||||
@@ -78,16 +89,16 @@ Physics Constraints (bge.constraints)
|
||||
:arg constraintId: The id of the vehicle constraint.
|
||||
:type constraintId: int
|
||||
|
||||
:return: a vehicle constraint object.
|
||||
:rtype: :class:`bge.types.KX_VehicleWrapper`
|
||||
:return: A vehicle constraint object.
|
||||
:rtype: :class:`~bge.types.KX_VehicleWrapper`
|
||||
|
||||
.. function:: getCharacter(gameobj)
|
||||
|
||||
:arg gameobj: The game object with the character physics.
|
||||
:type gameobj: :class:`bge.types.KX_GameObject`
|
||||
:type gameobj: :class:`~bge.types.KX_GameObject`
|
||||
|
||||
:return: character wrapper
|
||||
:rtype: :class:`bge.types.KX_CharacterWrapper`
|
||||
:return: Character wrapper.
|
||||
:rtype: :class:`~bge.types.KX_CharacterWrapper`
|
||||
|
||||
.. function:: removeConstraint(constraintId)
|
||||
|
||||
@@ -141,7 +152,8 @@ Physics Constraints (bge.constraints)
|
||||
|
||||
Sets the debug mode.
|
||||
|
||||
Debug modes:
|
||||
:arg mode: The new debug mode.
|
||||
|
||||
- :class:`DBG_NODEBUG`
|
||||
- :class:`DBG_DRAWWIREFRAME`
|
||||
- :class:`DBG_DRAWAABB`
|
||||
@@ -157,7 +169,6 @@ Physics Constraints (bge.constraints)
|
||||
- :class:`DBG_DRAWCONSTRAINTLIMITS`
|
||||
- :class:`DBG_FASTWIREFRAME`
|
||||
|
||||
:arg mode: The new debug mode.
|
||||
:type mode: int
|
||||
|
||||
.. function:: setGravity(x, y, z)
|
||||
@@ -176,7 +187,8 @@ Physics Constraints (bge.constraints)
|
||||
.. function:: setLinearAirDamping(damping)
|
||||
|
||||
.. note::
|
||||
Not implemented.
|
||||
|
||||
Not implemented
|
||||
|
||||
Sets the linear air damping for rigidbodies.
|
||||
|
||||
@@ -236,144 +248,111 @@ Physics Constraints (bge.constraints)
|
||||
|
||||
.. function:: setUseEpa(epa)
|
||||
|
||||
Not implemented.
|
||||
.. note::
|
||||
|
||||
Not implemented
|
||||
|
||||
|
||||
Constants
|
||||
+++++++++
|
||||
|
||||
.. attribute:: error
|
||||
|
||||
Symbolic constant string that indicates error.
|
||||
|
||||
:type: str
|
||||
|
||||
|
||||
Debug Mode Constants
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Debug mode to be used with :func:`setDebugMode`.
|
||||
|
||||
|
||||
.. data:: DBG_NODEBUG
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
No debug.
|
||||
|
||||
.. data:: DBG_DRAWWIREFRAME
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw wireframe in debug.
|
||||
|
||||
.. data:: DBG_DRAWAABB
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw Axis Aligned Bounding Box in debug.
|
||||
|
||||
.. data:: DBG_DRAWFREATURESTEXT
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw freatures text in debug.
|
||||
Draw features text in debug.
|
||||
|
||||
.. data:: DBG_DRAWCONTACTPOINTS
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw contact points in debug.
|
||||
|
||||
.. data:: DBG_NOHELPTEXT
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Debug without help text.
|
||||
|
||||
.. data:: DBG_DRAWTEXT
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw text in debug.
|
||||
|
||||
.. data:: DBG_PROFILETIMINGS
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw profile timings in debug.
|
||||
|
||||
.. data:: DBG_ENABLESATCOMPARISION
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Enable sat comparision in debug.
|
||||
|
||||
.. data:: DBG_DISABLEBULLETLCP
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Disable Bullet LCP.
|
||||
|
||||
.. data:: DBG_ENABLECCD
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Enable Continous Colision Detection in debug.
|
||||
Enable Continous Collision Detection in debug.
|
||||
|
||||
.. data:: DBG_DRAWCONSTRAINTS
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw constraints in debug.
|
||||
|
||||
.. data:: DBG_DRAWCONSTRAINTLIMITS
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw constraint limits in debug.
|
||||
|
||||
.. data:: DBG_FASTWIREFRAME
|
||||
|
||||
.. note::
|
||||
Debug mode to be used with function :class:`setDebugMode`
|
||||
|
||||
Draw a fast wireframe in debug.
|
||||
|
||||
.. data:: POINTTOPOINT_CONSTRAINT
|
||||
|
||||
.. note::
|
||||
Constraint type to be used with function :class:`createConstraint`
|
||||
Create Constraint Constants
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Constraint type to be used with :func:`createConstraint`.
|
||||
|
||||
|
||||
.. data:: POINTTOPOINT_CONSTRAINT
|
||||
|
||||
.. to do
|
||||
|
||||
.. data:: LINEHINGE_CONSTRAINT
|
||||
|
||||
.. note::
|
||||
Constraint type to be used with function :class:`createConstraint`
|
||||
|
||||
.. to do
|
||||
|
||||
.. data:: ANGULAR_CONSTRAINT
|
||||
|
||||
.. note::
|
||||
Constraint type to be used with function :class:`createConstraint`
|
||||
|
||||
.. to do
|
||||
|
||||
.. data:: CONETWIST_CONSTRAINT
|
||||
|
||||
.. note::
|
||||
Constraint type to be used with function :class:`createConstraint`
|
||||
|
||||
.. to do
|
||||
|
||||
.. data:: VEHICLE_CONSTRAINT
|
||||
|
||||
.. note::
|
||||
Constraint type to be used with function :class:`createConstraint`
|
||||
|
||||
.. to do
|
||||
|
||||
.. data:: GENERIC_6DOF_CONSTRAINT
|
||||
|
||||
.. note::
|
||||
Constraint type to be used with function :class:`createConstraint`
|
||||
|
||||
.. to do
|
||||
|
||||
|
@@ -894,6 +894,8 @@ Various
|
||||
2D Filter
|
||||
---------
|
||||
|
||||
.. _Two-D-FilterActuator-mode:
|
||||
|
||||
.. data:: RAS_2DFILTER_BLUR
|
||||
|
||||
:value: 2
|
||||
@@ -1288,5 +1290,3 @@ See :class:`bge.types.KX_StateActuator.operation`
|
||||
Add bits to state mask
|
||||
|
||||
:value: 3
|
||||
|
||||
.. _Two-D-FilterActuator-mode:
|
||||
|
@@ -218,6 +218,8 @@ When the texture object is deleted, the new texture is deleted and the old textu
|
||||
|
||||
background color
|
||||
|
||||
:type: int or float list [r, g, b, a] in [0.0, 255.0]
|
||||
|
||||
.. attribute:: capsize
|
||||
|
||||
size of render area
|
||||
@@ -315,6 +317,8 @@ When the texture object is deleted, the new texture is deleted and the old textu
|
||||
|
||||
background color
|
||||
|
||||
:type: int or float list [r, g, b, a] in [0.0, 255.0]
|
||||
|
||||
.. attribute:: capsize
|
||||
|
||||
size of render area
|
||||
|
@@ -7,11 +7,66 @@ base class --- :class:`PyObjectPlus`
|
||||
|
||||
.. class:: KX_BlenderMaterial(PyObjectPlus)
|
||||
|
||||
KX_BlenderMaterial
|
||||
This is the interface to materials in the game engine.
|
||||
|
||||
Materials define the render state to be applied to mesh objects.
|
||||
|
||||
The example below shows a simple GLSL shader setup allowing to dynamically mix two texture channels
|
||||
in a material. All materials of the object executing this script should have two textures using
|
||||
separate UV maps in the two first texture channels.
|
||||
|
||||
The code works for both Multitexture and GLSL rendering modes.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from bge import logic
|
||||
|
||||
vertex_shader = """
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// simple projection of the vertex position to view space
|
||||
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
|
||||
// coordinate of the 1st texture channel
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
// coordinate of the 2nd texture channel
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
}
|
||||
"""
|
||||
|
||||
fragment_shader ="""
|
||||
|
||||
uniform sampler2D texture_0;
|
||||
uniform sampler2D texture_1;
|
||||
uniform float factor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color_0 = texture2D(texture_0, gl_TexCoord[0].st);
|
||||
vec4 color_1 = texture2D(texture_1, gl_TexCoord[1].st);
|
||||
gl_FragColor = mix(color_0, color_1, factor);
|
||||
}
|
||||
"""
|
||||
|
||||
object = logic.getCurrentController().owner
|
||||
|
||||
for mesh in object.meshes:
|
||||
for material in mesh.materials:
|
||||
shader = material.getShader()
|
||||
if shader is not None:
|
||||
if not shader.isValid():
|
||||
shader.setSource(vertex_shader, fragment_shader, True)
|
||||
|
||||
# get the first texture channel of the material
|
||||
shader.setSampler('texture_0', 0)
|
||||
# get the second texture channel of the material
|
||||
shader.setSampler('texture_1', 1)
|
||||
# pass another uniform to the shader
|
||||
shader.setUniform1f('factor', 0.3)
|
||||
|
||||
.. attribute:: shader
|
||||
|
||||
The materials shader.
|
||||
The material's shader.
|
||||
|
||||
:type: :class:`BL_Shader`
|
||||
|
||||
@@ -38,35 +93,37 @@ base class --- :class:`PyObjectPlus`
|
||||
|
||||
Set the pixel color arithmetic functions.
|
||||
|
||||
:arg src: Specifies how the red, green, blue, and alpha source blending factors are computed.
|
||||
:type src: Value in...
|
||||
:arg src: Specifies how the red, green, blue, and alpha source blending factors are computed, one of...
|
||||
|
||||
* :data:`~bgl.GL_ZERO`
|
||||
* :data:`~bgl.GL_ONE`
|
||||
* :data:`~bgl.GL_SRC_COLOR`
|
||||
* :data:`~bgl.GL_ONE_MINUS_SRC_COLOR`
|
||||
* :data:`~bgl.GL_DST_COLOR`
|
||||
* :data:`~bgl.GL_ONE_MINUS_DST_COLOR`
|
||||
* :data:`~bgl.GL_SRC_ALPHA`
|
||||
* :data:`~bgl.GL_ONE_MINUS_SRC_ALPHA`
|
||||
* :data:`~bgl.GL_DST_ALPHA`
|
||||
* :data:`~bgl.GL_ONE_MINUS_DST_ALPHA`
|
||||
* :data:`~bgl.GL_SRC_ALPHA_SATURATE`
|
||||
|
||||
:type src: int
|
||||
|
||||
* GL_ZERO,
|
||||
* GL_ONE,
|
||||
* GL_SRC_COLOR,
|
||||
* GL_ONE_MINUS_SRC_COLOR,
|
||||
* GL_DST_COLOR,
|
||||
* GL_ONE_MINUS_DST_COLOR,
|
||||
* GL_SRC_ALPHA,
|
||||
* GL_ONE_MINUS_SRC_ALPHA,
|
||||
* GL_DST_ALPHA,
|
||||
* GL_ONE_MINUS_DST_ALPHA,
|
||||
* GL_SRC_ALPHA_SATURATE
|
||||
|
||||
:arg dest: Specifies how the red, green, blue, and alpha destination blending factors are computed.
|
||||
:type dest: Value in...
|
||||
|
||||
* GL_ZERO
|
||||
* GL_ONE
|
||||
* GL_SRC_COLOR
|
||||
* GL_ONE_MINUS_SRC_COLOR
|
||||
* GL_DST_COLOR
|
||||
* GL_ONE_MINUS_DST_COLOR
|
||||
* GL_SRC_ALPHA
|
||||
* GL_ONE_MINUS_SRC_ALPHA
|
||||
* GL_DST_ALPHA
|
||||
* GL_ONE_MINUS_DST_ALPHA
|
||||
* GL_SRC_ALPHA_SATURATE
|
||||
:arg dest: Specifies how the red, green, blue, and alpha destination blending factors are computed, one of...
|
||||
|
||||
* :data:`~bgl.GL_ZERO`
|
||||
* :data:`~bgl.GL_ONE`
|
||||
* :data:`~bgl.GL_SRC_COLOR`
|
||||
* :data:`~bgl.GL_ONE_MINUS_SRC_COLOR`
|
||||
* :data:`~bgl.GL_DST_COLOR`
|
||||
* :data:`~bgl.GL_ONE_MINUS_DST_COLOR`
|
||||
* :data:`~bgl.GL_SRC_ALPHA`
|
||||
* :data:`~bgl.GL_ONE_MINUS_SRC_ALPHA`
|
||||
* :data:`~bgl.GL_DST_ALPHA`
|
||||
* :data:`~bgl.GL_ONE_MINUS_DST_ALPHA`
|
||||
* :data:`~bgl.GL_SRC_ALPHA_SATURATE`
|
||||
|
||||
:type dest: int
|
||||
|
||||
.. method:: getMaterialIndex()
|
||||
|
||||
|
@@ -28,7 +28,8 @@ base class --- :class:`PyObjectPlus`
|
||||
* Lowerlimit > Upperlimit -> axis is free
|
||||
* Lowerlimit < Upperlimit -> axis it limited in that range
|
||||
|
||||
PHY_LINEHINGE_CONSTRAINT = 2 or PHY_ANGULAR_CONSTRAINT = 3:
|
||||
For PHY_LINEHINGE_CONSTRAINT = 2 or PHY_ANGULAR_CONSTRAINT = 3:
|
||||
|
||||
axis = 3 is a constraint limit, with low/high limit value
|
||||
* 3: X axis angle
|
||||
|
||||
@@ -37,7 +38,8 @@ base class --- :class:`PyObjectPlus`
|
||||
:arg value1 (max): Set the maximum limit of the axis
|
||||
:type value1: float
|
||||
|
||||
PHY_CONE_TWIST_CONSTRAINT = 3:
|
||||
For PHY_CONE_TWIST_CONSTRAINT = 4:
|
||||
|
||||
axis = 3..5 are constraint limits, high limit values
|
||||
* 3: X axis angle
|
||||
* 4: Y axis angle
|
||||
@@ -48,7 +50,8 @@ base class --- :class:`PyObjectPlus`
|
||||
:arg value1 (max): Set the maximum limit of the axis
|
||||
:type value1: float
|
||||
|
||||
PHY_GENERIC_6DOF_CONSTRAINT = 12:
|
||||
For PHY_GENERIC_6DOF_CONSTRAINT = 12:
|
||||
|
||||
axis = 0..2 are constraint limits, with low/high limit value
|
||||
* 0: X axis position
|
||||
* 1: Y axis position
|
||||
|
@@ -7,6 +7,26 @@ base class --- :class:`KX_GameObject`
|
||||
|
||||
.. class:: KX_FontObject(KX_GameObject)
|
||||
|
||||
TODO.
|
||||
A Font object.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
# Display a message about the exit key using a Font object.
|
||||
import bge
|
||||
|
||||
co = bge.logic.getCurrentController()
|
||||
font = co.owner
|
||||
|
||||
exit_key = bge.events.EventToString(bge.logic.getExitKey())
|
||||
|
||||
if exit_key.endswith("KEY"):
|
||||
exit_key = exit_key[:-3]
|
||||
|
||||
font.text = "Press key '%s' to quit the game." % exit_key
|
||||
|
||||
.. attribute:: text
|
||||
|
||||
The text displayed by this Font object.
|
||||
|
||||
:type: string
|
||||
|
||||
|
@@ -139,6 +139,29 @@ base class --- :class:`SCA_IObject`
|
||||
|
||||
A value of 0.0 disables this option (rather then setting it stationary).
|
||||
|
||||
.. attribute:: angularVelocityMin
|
||||
|
||||
Enforces the object keeps rotating at a minimum velocity. A value of 0.0 disables this.
|
||||
|
||||
:type: non-negative float
|
||||
|
||||
.. note::
|
||||
|
||||
Applies to dynamic and rigid body objects only.
|
||||
While objects are stationary the minimum velocity will not be applied.
|
||||
|
||||
|
||||
.. attribute:: angularVelocityMax
|
||||
|
||||
Clamp the maximum angular velocity to prevent objects rotating beyond a set speed.
|
||||
A value of 0.0 disables clamping; it does not stop rotation.
|
||||
|
||||
:type: non-negative float
|
||||
|
||||
.. note::
|
||||
|
||||
Applies to dynamic and rigid body objects only.
|
||||
|
||||
.. attribute:: localInertia
|
||||
|
||||
the object's inertia vector in local coordinates. Read only.
|
||||
|
@@ -1,250 +0,0 @@
|
||||
KX_PolygonMaterial(PyObjectPlus)
|
||||
================================
|
||||
|
||||
.. module:: bge.types
|
||||
|
||||
base class --- :class:`PyObjectPlus`
|
||||
|
||||
.. class:: KX_PolygonMaterial(PyObjectPlus)
|
||||
|
||||
This is the interface to materials in the game engine.
|
||||
|
||||
Materials define the render state to be applied to mesh objects.
|
||||
|
||||
.. warning::
|
||||
|
||||
Some of the methods/variables are CObjects. If you mix these up, you will crash blender.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
from bge import logic
|
||||
|
||||
vertex_shader = """
|
||||
|
||||
void main(void)
|
||||
{
|
||||
// original vertex position, no changes
|
||||
gl_Position = ftransform();
|
||||
// coordinate of the 1st texture channel
|
||||
gl_TexCoord[0] = gl_MultiTexCoord0;
|
||||
// coordinate of the 2nd texture channel
|
||||
gl_TexCoord[1] = gl_MultiTexCoord1;
|
||||
}
|
||||
"""
|
||||
|
||||
fragment_shader ="""
|
||||
|
||||
uniform sampler2D color_0;
|
||||
uniform sampler2D color_1;
|
||||
uniform float factor;
|
||||
|
||||
void main(void)
|
||||
{
|
||||
vec4 color_0 = texture2D(color_0, gl_TexCoord[0].st);
|
||||
vec4 color_1 = texture2D(color_1, gl_TexCoord[1].st);
|
||||
gl_FragColor = mix(color_0, color_1, factor);
|
||||
}
|
||||
"""
|
||||
|
||||
object = logic.getCurrentController().owner
|
||||
object = cont.owner
|
||||
for mesh in object.meshes:
|
||||
for material in mesh.materials:
|
||||
shader = material.getShader()
|
||||
if shader != None:
|
||||
if not shader.isValid():
|
||||
shader.setSource(vertex_shader, fragment_shader, True)
|
||||
|
||||
# get the first texture channel of the material
|
||||
shader.setSampler('color_0', 0)
|
||||
# get the second texture channel of the material
|
||||
shader.setSampler('color_1', 1)
|
||||
# pass another uniform to the shader
|
||||
shader.setUniform1f('factor', 0.3)
|
||||
|
||||
|
||||
.. attribute:: texture
|
||||
|
||||
Texture name.
|
||||
|
||||
:type: string (read-only)
|
||||
|
||||
.. attribute:: gl_texture
|
||||
|
||||
OpenGL texture handle (eg for glBindTexture(GL_TEXTURE_2D, gl_texture).
|
||||
|
||||
:type: integer (read-only)
|
||||
|
||||
.. attribute:: material
|
||||
|
||||
Material name.
|
||||
|
||||
:type: string (read-only)
|
||||
|
||||
.. attribute:: tface
|
||||
|
||||
Texture face properties.
|
||||
|
||||
:type: CObject (read-only)
|
||||
|
||||
.. attribute:: tile
|
||||
|
||||
Texture is tiling.
|
||||
|
||||
:type: boolean
|
||||
|
||||
.. attribute:: tilexrep
|
||||
|
||||
Number of tile repetitions in x direction.
|
||||
|
||||
:type: integer
|
||||
|
||||
.. attribute:: tileyrep
|
||||
|
||||
Number of tile repetitions in y direction.
|
||||
|
||||
:type: integer
|
||||
|
||||
.. attribute:: drawingmode
|
||||
|
||||
Drawing mode for the material.
|
||||
- 2 (drawingmode & 4) Textured
|
||||
- 4 (drawingmode & 16) Light
|
||||
- 14 (drawingmode & 16384) 3d Polygon Text.
|
||||
|
||||
:type: bitfield
|
||||
|
||||
.. attribute:: transparent
|
||||
|
||||
This material is transparent. All meshes with this
|
||||
material will be rendered after non transparent meshes from back
|
||||
to front.
|
||||
|
||||
:type: boolean
|
||||
|
||||
.. attribute:: zsort
|
||||
|
||||
Transparent polygons in meshes with this material will be sorted back to
|
||||
front before rendering.
|
||||
Non-Transparent polygons will be sorted front to back before rendering.
|
||||
|
||||
:type: boolean
|
||||
|
||||
.. attribute:: diffuse
|
||||
|
||||
The diffuse color of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
|
||||
|
||||
:type: list [r, g, b]
|
||||
|
||||
.. attribute:: specular
|
||||
|
||||
The specular color of the material. black = [0.0, 0.0, 0.0] white = [1.0, 1.0, 1.0].
|
||||
|
||||
:type: list [r, g, b]
|
||||
|
||||
.. attribute:: shininess
|
||||
|
||||
The shininess (specular exponent) of the material. 0.0 <= shininess <= 128.0.
|
||||
|
||||
:type: float
|
||||
|
||||
.. attribute:: specularity
|
||||
|
||||
The amount of specular of the material. 0.0 <= specularity <= 1.0.
|
||||
|
||||
:type: float
|
||||
|
||||
.. method:: updateTexture(tface, rasty)
|
||||
|
||||
Updates a realtime animation.
|
||||
|
||||
:arg tface: Texture face (eg mat.tface)
|
||||
:type tface: CObject
|
||||
:arg rasty: Rasterizer
|
||||
:type rasty: CObject
|
||||
|
||||
.. method:: setTexture(tface)
|
||||
|
||||
Sets texture render state.
|
||||
|
||||
:arg tface: Texture face
|
||||
:type tface: CObject
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
mat.setTexture(mat.tface)
|
||||
|
||||
.. method:: activate(rasty, cachingInfo)
|
||||
|
||||
Sets material parameters for this object for rendering.
|
||||
|
||||
Material Parameters set:
|
||||
|
||||
#. Texture
|
||||
#. Backface culling
|
||||
#. Line drawing
|
||||
#. Specular Colour
|
||||
#. Shininess
|
||||
#. Diffuse Colour
|
||||
#. Polygon Offset.
|
||||
|
||||
:arg rasty: Rasterizer instance.
|
||||
:type rasty: CObject
|
||||
:arg cachingInfo: Material cache instance.
|
||||
:type cachingInfo: CObject
|
||||
|
||||
.. method:: setCustomMaterial(material)
|
||||
|
||||
Sets the material state setup object.
|
||||
|
||||
Using this method, you can extend or completely replace the gameengine material
|
||||
to do your own advanced multipass effects.
|
||||
|
||||
Use this method to register your material class. Instead of the normal material,
|
||||
your class's activate method will be called just before rendering the mesh.
|
||||
This should setup the texture, material, and any other state you would like.
|
||||
It should return True to render the mesh, or False if you are finished. You should
|
||||
clean up any state Blender does not set before returning False.
|
||||
|
||||
Activate Method Definition:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
def activate(self, rasty, cachingInfo, material):
|
||||
|
||||
:arg material: The material object.
|
||||
:type material: instance
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
class PyMaterial:
|
||||
def __init__(self):
|
||||
self.pass_no = -1
|
||||
|
||||
def activate(self, rasty, cachingInfo, material):
|
||||
# Activate the material here.
|
||||
#
|
||||
# The activate method will be called until it returns False.
|
||||
# Every time the activate method returns True the mesh will
|
||||
# be rendered.
|
||||
#
|
||||
# rasty is a CObject for passing to material.updateTexture()
|
||||
# and material.activate()
|
||||
# cachingInfo is a CObject for passing to material.activate()
|
||||
# material is the KX_PolygonMaterial instance this material
|
||||
# was added to
|
||||
|
||||
# default material properties:
|
||||
self.pass_no += 1
|
||||
if self.pass_no == 0:
|
||||
material.activate(rasty, cachingInfo)
|
||||
# Return True to do this pass
|
||||
return True
|
||||
|
||||
# clean up and return False to finish.
|
||||
self.pass_no = -1
|
||||
return False
|
||||
|
||||
# Create a new Python Material and pass it to the renderer.
|
||||
mat.setCustomMaterial(PyMaterial())
|
||||
|
@@ -25,12 +25,6 @@ base class --- :class:`SCA_IObject`
|
||||
|
||||
:type: Vector((u, v))
|
||||
|
||||
.. attribute:: uvs
|
||||
|
||||
A list of all the texture coordinates of the vertex.
|
||||
|
||||
:type: list of Vector((u, v))
|
||||
|
||||
.. attribute:: normal
|
||||
|
||||
The normal of the vertex.
|
||||
@@ -126,24 +120,18 @@ base class --- :class:`SCA_IObject`
|
||||
|
||||
:arg pos: the new position for this vertex in local coordinates.
|
||||
|
||||
.. method:: getUV(index=0)
|
||||
.. method:: getUV()
|
||||
|
||||
Gets the UV (texture) coordinates of this vertex.
|
||||
|
||||
:arg index: the UV (texture) channel (optional).
|
||||
:type index: integer
|
||||
|
||||
:return: this vertexes UV (texture) coordinates.
|
||||
:rtype: Vector((u, v))
|
||||
|
||||
.. method:: setUV(uv, index=0)
|
||||
.. method:: setUV(uv)
|
||||
|
||||
Sets the UV (texture) coordinates of this vertex.
|
||||
|
||||
:arg uv: the UV (texture) coordinate of this vertex.
|
||||
:type uv: Vector((u, v))
|
||||
:arg index: the UV (texture) channel (optional).
|
||||
:type index: integer
|
||||
:type: Vector((u, v))
|
||||
|
||||
.. method:: getUV2()
|
||||
|
||||
@@ -152,16 +140,14 @@ base class --- :class:`SCA_IObject`
|
||||
:return: this vertexes UV (texture) coordinates.
|
||||
:rtype: Vector((u, v))
|
||||
|
||||
.. deprecated:: use :meth:`getUV`
|
||||
|
||||
.. method:: setUV2(uv)
|
||||
.. method:: setUV2(uv, unit)
|
||||
|
||||
Sets the 2nd UV (texture) coordinates of this vertex.
|
||||
|
||||
:arg uv: the 2nd (texture) UV coordinate of this vertex.
|
||||
:type uv: Vector((u, v))
|
||||
:type: Vector((u, v))
|
||||
|
||||
.. deprecated:: use :meth:`setUV`
|
||||
:arg unit: optional argument, FLAT==1, SECOND_UV==2, defaults to SECOND_UV
|
||||
:arg unit: integer
|
||||
|
||||
.. method:: getRGBA()
|
||||
|
||||
|
@@ -16,11 +16,7 @@ base class --- :class:`PyObjectPlus`
|
||||
|
||||
sce = bge.logic.getCurrentScene()
|
||||
|
||||
sce.world.mist_color = [1.0, 0.0, 0.0]
|
||||
|
||||
*********
|
||||
Constants
|
||||
*********
|
||||
sce.world.mistColor = [1.0, 0.0, 0.0]
|
||||
|
||||
.. data:: KX_MIST_QUADRATIC
|
||||
|
||||
@@ -34,53 +30,49 @@ Constants
|
||||
|
||||
Type of inverse quadratic attenuation used to fade mist.
|
||||
|
||||
**********
|
||||
Attributes
|
||||
**********
|
||||
|
||||
.. attribute:: mist_enable
|
||||
.. attribute:: mistEnable
|
||||
|
||||
Return the state of the mist.
|
||||
|
||||
:type: bool
|
||||
|
||||
.. attribute:: mist_start
|
||||
.. attribute:: mistStart
|
||||
|
||||
The mist start point.
|
||||
|
||||
:type: float
|
||||
|
||||
.. attribute:: mist_distance
|
||||
.. attribute:: mistDistance
|
||||
|
||||
The mist distance fom the start point to reach 100% mist.
|
||||
|
||||
:type: float
|
||||
|
||||
.. attribute:: mist_intensity
|
||||
.. attribute:: mistIntensity
|
||||
|
||||
The mist intensity.
|
||||
|
||||
:type: float
|
||||
|
||||
.. attribute:: mist_type
|
||||
.. attribute:: mistType
|
||||
|
||||
The type of mist - must be KX_MIST_QUADRATIC, KX_MIST_LINEAR or KX_MIST_INV_QUADRATIC
|
||||
|
||||
.. attribute:: mist_color
|
||||
.. attribute:: mistColor
|
||||
|
||||
The color of the mist. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
|
||||
Mist and background color sould always set to the same color.
|
||||
|
||||
:type: :class:`mathutils.Vector`
|
||||
|
||||
.. attribute:: background_color
|
||||
.. attribute:: backgroundColor
|
||||
|
||||
The color of the background. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
|
||||
Mist and background color sould always set to the same color.
|
||||
|
||||
:type: :class:`mathutils.Vector`
|
||||
|
||||
.. attribute:: ambient_color
|
||||
.. attribute:: ambientColor
|
||||
|
||||
The color of the ambient light. Black = [0.0, 0.0, 0.0], White = [1.0, 1.0, 1.0].
|
||||
|
||||
|
@@ -7,7 +7,7 @@ base class --- :class:`SCA_IActuator`
|
||||
|
||||
.. class:: SCA_2DFilterActuator(SCA_IActuator)
|
||||
|
||||
Create, enable and disable 2D filters
|
||||
Create, enable and disable 2D filters.
|
||||
|
||||
The following properties don't have an immediate effect.
|
||||
You must active the actuator to get the result.
|
||||
@@ -29,7 +29,7 @@ base class --- :class:`SCA_IActuator`
|
||||
|
||||
.. attribute:: mode
|
||||
|
||||
Type of 2D filter, use one of :ref:`these constants <Two-D-FilterActuator-mode>`
|
||||
Type of 2D filter, use one of :ref:`these constants <Two-D-FilterActuator-mode>`.
|
||||
|
||||
:type: integer
|
||||
|
||||
|
@@ -121,7 +121,7 @@ Here are some more complex examples:
|
||||
bpy.context.scene.render.layers["RenderLayer"].samples
|
||||
|
||||
# access to the current weight paint brush size
|
||||
bpy.context.tool_settings.weight_paint.brush.size
|
||||
bpy.context.tool_settings.weight_paint.brush.size
|
||||
|
||||
# check if the window is fullscreen
|
||||
bpy.context.window.screen.show_fullscreen
|
||||
@@ -141,15 +141,16 @@ When starting out scripting you will often run into the problem where you're not
|
||||
|
||||
There are a few ways to do this.
|
||||
|
||||
- Use the Python console's auto-complete to inspect properties. *This can be hit-and-miss but has the advantage
|
||||
- Use the Python console's auto-complete to inspect properties.
|
||||
*This can be hit-and-miss but has the advantage
|
||||
that you can easily see the values of properties and assign them to interactively see the results.*
|
||||
|
||||
- Copy the Data-Path from the user interface. *Explained further in :ref:`Copy Data Path <info_data_path_copy>`*
|
||||
|
||||
- Using the documentation to follow references. *Explained further in :ref:`Indirect Data Access <info_data_path_indirect>`*
|
||||
- Copy the Data-Path from the user interface.
|
||||
*Explained further in :ref:`Copy Data Path <info_data_path_copy>`*
|
||||
- Using the documentation to follow references.
|
||||
*Explained further in :ref:`Indirect Data Access <info_data_path_indirect>`*
|
||||
|
||||
|
||||
.. _info_data_path_copy
|
||||
.. _info_data_path_copy:
|
||||
|
||||
Copy Data Path
|
||||
--------------
|
||||
@@ -172,7 +173,8 @@ you won't be doing collection look-ups on every access and typically you'll want
|
||||
then access each :class:`bpy.types.ID` instance by name.
|
||||
|
||||
|
||||
Type in the ID path into a Python console :mod:`bpy.context.active_object`. Include the trailing dot and don't hit "enter", yet.
|
||||
Type in the ID path into a Python console :mod:`bpy.context.active_object`.
|
||||
Include the trailing dot and don't hit "enter", yet.
|
||||
|
||||
Now right-click on the button and select **Copy Data Path**, then paste the result into the console.
|
||||
|
||||
@@ -191,7 +193,7 @@ Hit "enter" and you'll get the current value of 1. Now try changing the value to
|
||||
You can see the value update in the Subdivision-Surface modifier's UI as well as the cube.
|
||||
|
||||
|
||||
.. _info_data_path_indirect
|
||||
.. _info_data_path_indirect:
|
||||
|
||||
Indirect Data Access
|
||||
--------------------
|
||||
@@ -201,32 +203,24 @@ For this example we'll go over something more involved, showing the steps to acc
|
||||
Lets say we want to access the texture of a brush via Python, to adjust its ``contrast`` for example.
|
||||
|
||||
- Start in the default scene and enable 'Sculpt' mode from the 3D-View header.
|
||||
|
||||
- From the toolbar expand the **Texture** panel and add a new texture.
|
||||
|
||||
*Notice the texture button its self doesn't have very useful links (you can check the tool-tips).*
|
||||
|
||||
- The contrast setting isn't exposed in the sculpt toolbar, so view the texture in the properties panel...
|
||||
|
||||
- In the properties button select the Texture context.
|
||||
|
||||
- Select the Brush icon to show the brush texture.
|
||||
|
||||
- Expand the **Colors** panel to locate the **Contrast** button.
|
||||
|
||||
- Right click on the contrast button and select **Online Python Reference** This takes you to ``bpy.types.Texture.contrast``
|
||||
|
||||
- Now we can see that ``contrast`` is a property of texture, so next we'll check on how to access the texture from the brush.
|
||||
|
||||
- Expand the *Colors* panel to locate the *Contrast* button.
|
||||
- Right click on the contrast button and select **Online Python Reference**
|
||||
This takes you to ``bpy.types.Texture.contrast``
|
||||
- Now we can see that ``contrast`` is a property of texture,
|
||||
so next we'll check on how to access the texture from the brush.
|
||||
- Check on the **References** at the bottom of the page, sometimes there are many references, and it may take
|
||||
some guess work to find the right one, but in this case its obviously ``Brush.texture``.
|
||||
|
||||
*Now we know that the texture can be accessed from* ``bpy.data.brushes["BrushName"].texture``
|
||||
*but normally you won't want to access the brush by name, so we'll see now to access the active brush instead.*
|
||||
|
||||
- So the next step is to check on where brushes are accessed from via the **References**.
|
||||
In this case there is simply ``bpy.context.brush`` which is all we need.
|
||||
|
||||
|
||||
Now you can use the Python console to form the nested properties needed to access brush textures contrast,
|
||||
logically we now know.
|
||||
@@ -282,7 +276,8 @@ are interested to check on the source code.
|
||||
|
||||
.. note::
|
||||
|
||||
Not all operators can be called usefully from Python, for more on this see :ref:`using operators <using_operators>`.
|
||||
Not all operators can be called usefully from Python,
|
||||
for more on this see :ref:`using operators <using_operators>`.
|
||||
|
||||
|
||||
Info View
|
||||
@@ -294,7 +289,8 @@ This is located above the file-menu which can be dragged down to display its con
|
||||
Select the **Script** screen that comes default with Blender to see its output.
|
||||
You can perform some actions and see them show up - delete a vertex for example.
|
||||
|
||||
Each entry can be selected (Right-Mouse-Button), then copied :kbd:`Control-C`, usually to paste in the text editor or python console.
|
||||
Each entry can be selected (Right-Mouse-Button),
|
||||
then copied :kbd:`Control-C`, usually to paste in the text editor or python console.
|
||||
|
||||
.. note::
|
||||
|
||||
|
@@ -1,16 +1,20 @@
|
||||
|
||||
*************
|
||||
Best Practice
|
||||
*************
|
||||
|
||||
When writing your own scripts python is great for new developers to pick up and become productive, but you can also pick up odd habits or at least write scripts that are not easy for others to understand.
|
||||
When writing your own scripts python is great for new developers to pick up and become productive,
|
||||
but you can also pick up odd habits or at least write scripts that are not easy for others to understand.
|
||||
|
||||
For your own work this is of course fine, but if you want to collaborate with others or have your work included with blender there are practices we encourage.
|
||||
For your own work this is of course fine,
|
||||
but if you want to collaborate with others or have your work included with blender there are practices we encourage.
|
||||
|
||||
|
||||
Style Conventions
|
||||
=================
|
||||
|
||||
For Blender/Python development we have chosen to follow python suggested style guide to avoid mixing styles amongst our own scripts and make it easier to use python scripts from other projects.
|
||||
For Blender/Python development we have chosen to follow python suggested style guide to avoid mixing styles
|
||||
amongst our own scripts and make it easier to use python scripts from other projects.
|
||||
|
||||
Using our style guide for your own scripts makes it easier if you eventually want to contribute them to blender.
|
||||
|
||||
@@ -18,22 +22,17 @@ This style guide is known as pep8 and can be found `here <http://www.python.org/
|
||||
|
||||
A brief listing of pep8 criteria.
|
||||
|
||||
* camel caps for class names: MyClass
|
||||
|
||||
* all lower case underscore separated module names: my_module
|
||||
|
||||
* indentation of 4 spaces (no tabs)
|
||||
|
||||
* spaces around operators. ``1 + 1``, not ``1+1``
|
||||
|
||||
* only use explicit imports, (no importing '*')
|
||||
|
||||
* don't use single line: ``if val: body``, separate onto 2 lines instead.
|
||||
- camel caps for class names: MyClass
|
||||
- all lower case underscore separated module names: my_module
|
||||
- indentation of 4 spaces (no tabs)
|
||||
- spaces around operators. ``1 + 1``, not ``1+1``
|
||||
- only use explicit imports, (no importing ``*``)
|
||||
- don't use single line: ``if val: body``, separate onto 2 lines instead.
|
||||
|
||||
|
||||
As well as pep8 we have other conventions used for blender python scripts.
|
||||
|
||||
* Use single quotes for enums, and double quotes for strings.
|
||||
- Use single quotes for enums, and double quotes for strings.
|
||||
|
||||
Both are of course strings but in our internal API enums are unique items from a limited set. eg.
|
||||
|
||||
@@ -42,9 +41,11 @@ As well as pep8 we have other conventions used for blender python scripts.
|
||||
bpy.context.scene.render.image_settings.file_format = 'PNG'
|
||||
bpy.context.scene.render.filepath = "//render_out"
|
||||
|
||||
* pep8 also defines that lines should not exceed 79 characters, we felt this is too restrictive so this is optional per script.
|
||||
- pep8 also defines that lines should not exceed 79 characters,
|
||||
we felt this is too restrictive so this is optional per script.
|
||||
|
||||
Periodically we run checks for pep8 compliance on blender scripts, for scripts to be included in this check add this line as a comment at the top of the script.
|
||||
Periodically we run checks for pep8 compliance on blender scripts,
|
||||
for scripts to be included in this check add this line as a comment at the top of the script.
|
||||
|
||||
``# <pep8 compliant>``
|
||||
|
||||
@@ -58,72 +59,75 @@ User Interface Layout
|
||||
|
||||
Some notes to keep in mind when writing UI layouts:
|
||||
|
||||
* UI code is quite simple. Layout declarations are there to easily create a decent layout.
|
||||
- UI code is quite simple. Layout declarations are there to easily create a decent layout.
|
||||
|
||||
General rule here: If you need more code for the layout declaration,
|
||||
then for the actual properties, you do it wrong.
|
||||
|
||||
General rule here: If you need more code for the layout declaration, then for the actual properties, you do it wrong.
|
||||
|
||||
Example layouts:
|
||||
|
||||
* layout()
|
||||
- layout()
|
||||
|
||||
The basic layout is a simple Top -> Bottom layout.
|
||||
|
||||
The basic layout is a simple Top -> Bottom layout.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
layout.prop()
|
||||
layout.prop()
|
||||
layout.prop()
|
||||
layout.prop()
|
||||
|
||||
* layout.row()
|
||||
- layout.row()
|
||||
|
||||
Use row(), when you want more than 1 property in one line.
|
||||
|
||||
Use row(), when you want more than 1 property in one line.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
row = layout.row()
|
||||
row.prop()
|
||||
row.prop()
|
||||
|
||||
* layout.column()
|
||||
row = layout.row()
|
||||
row.prop()
|
||||
row.prop()
|
||||
|
||||
- layout.column()
|
||||
|
||||
Use column(), when you want your properties in a column.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
col = layout.column()
|
||||
col.prop()
|
||||
col.prop()
|
||||
|
||||
* layout.split()
|
||||
col = layout.column()
|
||||
col.prop()
|
||||
col.prop()
|
||||
|
||||
This can be used to create more complex layouts. For example you can split the layout and create two column() layouts next to each other.
|
||||
- layout.split()
|
||||
|
||||
This can be used to create more complex layouts.
|
||||
For example you can split the layout and create two column() layouts next to each other.
|
||||
Don't use split, when you simply want two properties in a row. Use row() for that.
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.prop()
|
||||
col.prop()
|
||||
|
||||
col = split.column()
|
||||
col.prop()
|
||||
col.prop()
|
||||
|
||||
|
||||
split = layout.split()
|
||||
|
||||
col = split.column()
|
||||
col.prop()
|
||||
col.prop()
|
||||
|
||||
col = split.column()
|
||||
col.prop()
|
||||
col.prop()
|
||||
|
||||
Declaration names:
|
||||
|
||||
Try to only use these variable names for layout declarations:
|
||||
|
||||
* row for a row() layout
|
||||
* col for a column() layout
|
||||
* split for a split() layout
|
||||
* flow for a column_flow() layout
|
||||
* sub for a sub layout (a column inside a column for example)
|
||||
- row for a row() layout
|
||||
- col for a column() layout
|
||||
- split for a split() layout
|
||||
- flow for a column_flow() layout
|
||||
- sub for a sub layout (a column inside a column for example)
|
||||
|
||||
|
||||
Script Efficiency
|
||||
=================
|
||||
|
||||
|
||||
List Manipulation (General Python Tips)
|
||||
---------------------------------------
|
||||
|
||||
@@ -133,7 +137,8 @@ Searching for list items
|
||||
|
||||
In Python there are some handy list functions that save you having to search through the list.
|
||||
|
||||
Even though you're not looping on the list data **python is**, so you need to be aware of functions that will slow down your script by searching the whole list.
|
||||
Even though you're not looping on the list data **python is**,
|
||||
so you need to be aware of functions that will slow down your script by searching the whole list.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -145,11 +150,16 @@ Even though you're not looping on the list data **python is**, so you need to be
|
||||
|
||||
Modifying Lists
|
||||
^^^^^^^^^^^^^^^
|
||||
In python we can add and remove from a list, this is slower when the list length is modified, especially at the start of the list, since all the data after the index of modification needs to be moved up or down 1 place.
|
||||
In python we can add and remove from a list, this is slower when the list length is modified,
|
||||
especially at the start of the list, since all the data after the index of
|
||||
modification needs to be moved up or down 1 place.
|
||||
|
||||
The most simple way to add onto the end of the list is to use ``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and the fastest way to remove an item is ``my_list.pop()`` or ``del my_list[-1]``.
|
||||
The most simple way to add onto the end of the list is to use
|
||||
``my_list.append(list_item)`` or ``my_list.extend(some_list)`` and the fastest way to
|
||||
remove an item is ``my_list.pop()`` or ``del my_list[-1]``.
|
||||
|
||||
To use an index you can use ``my_list.insert(index, list_item)`` or ``list.pop(index)`` for list removal, but these are slower.
|
||||
To use an index you can use ``my_list.insert(index, list_item)`` or ``list.pop(index)``
|
||||
for list removal, but these are slower.
|
||||
|
||||
Sometimes its faster (but more memory hungry) to just rebuild the list.
|
||||
|
||||
@@ -193,7 +203,8 @@ Use...
|
||||
my_list.extend([a, b, c...])
|
||||
|
||||
|
||||
Note that insert can be used when needed, but it is slower than append especially when inserting at the start of a long list.
|
||||
Note that insert can be used when needed,
|
||||
but it is slower than append especially when inserting at the start of a long list.
|
||||
|
||||
This example shows a very sub-optimal way of making a reversed list.
|
||||
|
||||
@@ -205,7 +216,8 @@ This example shows a very sub-optimal way of making a reversed list.
|
||||
reverse_list.insert(0, list_item)
|
||||
|
||||
|
||||
Python provides more convenient ways to reverse a list using the slice method, but you may want to time this before relying on it too much:
|
||||
Python provides more convenient ways to reverse a list using the slice method,
|
||||
but you may want to time this before relying on it too much:
|
||||
|
||||
|
||||
.. code-block:: python
|
||||
@@ -220,7 +232,8 @@ Use ``my_list.pop(index)`` rather than ``my_list.remove(list_item)``
|
||||
|
||||
This requires you to have the index of the list item but is faster since ``remove()`` will search the list.
|
||||
|
||||
Here is an example of how to remove items in 1 loop, removing the last items first, which is faster (as explained above).
|
||||
Here is an example of how to remove items in 1 loop,
|
||||
removing the last items first, which is faster (as explained above).
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -232,7 +245,9 @@ Here is an example of how to remove items in 1 loop, removing the last items fir
|
||||
my_list.pop(list_index)
|
||||
|
||||
|
||||
This example shows a fast way of removing items, for use in cases where you can alter the list order without breaking the scripts functionality. This works by swapping 2 list items, so the item you remove is always last.
|
||||
This example shows a fast way of removing items,
|
||||
for use in cases where you can alter the list order without breaking the scripts functionality.
|
||||
This works by swapping 2 list items, so the item you remove is always last.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -251,7 +266,9 @@ When removing many items in a large list this can provide a good speedup.
|
||||
Avoid Copying Lists
|
||||
^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When passing a list/dictionary to a function, it is faster to have the function modify the list rather than returning a new list so python doesn't have to duplicate the list in memory.
|
||||
When passing a list/dictionary to a function,
|
||||
it is faster to have the function modify the list rather than returning
|
||||
a new list so python doesn't have to duplicate the list in memory.
|
||||
|
||||
Functions that modify a list in-place are more efficient than functions that create new lists.
|
||||
|
||||
@@ -296,20 +313,26 @@ Python’s string joining function. To join a list of strings
|
||||
>>> file.write(" ".join([str1, str2, str3, "\n"]))
|
||||
|
||||
|
||||
join is fastest on many strings, `string formatting <http://docs.python.org/py3k/library/string.html#string-formatting>`_ is quite fast too (better for converting data types). String arithmetic is slowest.
|
||||
join is fastest on many strings,
|
||||
`string formatting <http://docs.python.org/py3k/library/string.html#string-formatting>`__
|
||||
is quite fast too (better for converting data types). String arithmetic is slowest.
|
||||
|
||||
|
||||
Parsing Strings (Import/Exporting)
|
||||
----------------------------------
|
||||
|
||||
Since many file formats are ASCII, the way you parse/export strings can make a large difference in how fast your script runs.
|
||||
Since many file formats are ASCII,
|
||||
the way you parse/export strings can make a large difference in how fast your script runs.
|
||||
|
||||
There are a few ways to parse strings when importing them into Blender.
|
||||
|
||||
|
||||
Parsing Numbers
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``, float() will work for an int too but it's faster to read ints with int().
|
||||
Use ``float(string)`` rather than ``eval(string)``, if you know the value will be an int then ``int(string)``,
|
||||
float() will work for an int too but it's faster to read ints with int().
|
||||
|
||||
|
||||
Checking String Start/End
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@@ -322,7 +345,8 @@ Use...
|
||||
|
||||
>>> if line.startswith("vert "):
|
||||
|
||||
Using ``startswith()`` is slightly faster (approx 5%) and also avoids a possible error with the slice length not matching the string length.
|
||||
Using ``startswith()`` is slightly faster (approx 5%) and also avoids a possible
|
||||
error with the slice length not matching the string length.
|
||||
|
||||
my_string.endswith("foo_bar") can be used for line endings too.
|
||||
|
||||
@@ -336,15 +360,19 @@ Use try/except Sparingly
|
||||
|
||||
The **try** statement is useful to save time writing error checking code.
|
||||
|
||||
However **try** is significantly slower than an **if** since an exception has to be set each time, so avoid using **try** in areas of your code that execute in a loop and runs many times.
|
||||
However **try** is significantly slower than an **if** since an exception has to be set each time,
|
||||
so avoid using **try** in areas of your code that execute in a loop and runs many times.
|
||||
|
||||
There are cases where using **try** is faster than checking whether the condition will raise an error, so it is worth experimenting.
|
||||
There are cases where using **try** is faster than checking whether the condition will raise an error,
|
||||
so it is worth experimenting.
|
||||
|
||||
|
||||
Value Comparison
|
||||
----------------
|
||||
|
||||
Python has two ways to compare values ``a == b`` and ``a is b``, the difference is that ``==`` may run the objects comparison function ``__cmp__()`` whereas ``is`` compares identity, that both variables reference the same item in memory.
|
||||
Python has two ways to compare values ``a == b`` and ``a is b``,
|
||||
the difference is that ``==`` may run the objects comparison function ``__cmp__()`` whereas ``is`` compares identity,
|
||||
that both variables reference the same item in memory.
|
||||
|
||||
In cases where you know you are checking for the same value which is referenced from multiple places, ``is`` is faster.
|
||||
|
||||
@@ -362,3 +390,4 @@ While developing a script it's good to time it to be aware of any changes in per
|
||||
# do something...
|
||||
|
||||
print("My Script Finished: %.4f sec" % time.time() - time_start)
|
||||
|
||||
|
@@ -1,18 +1,25 @@
|
||||
|
||||
.. _info_overview:
|
||||
|
||||
*******************
|
||||
Python API Overview
|
||||
*******************
|
||||
|
||||
This document is to give an understanding of how python and blender fit together, covering some of the functionality that isn't obvious from reading the API reference and example scripts.
|
||||
This document is to give an understanding of how Python and Blender fit together,
|
||||
covering some of the functionality that isn't obvious from reading the API reference and example scripts.
|
||||
|
||||
|
||||
Python in Blender
|
||||
=================
|
||||
|
||||
Blender embeds a python interpreter which is started with blender and stays active. This interpreter runs scripts to draw the user interface and is used for some of Blender's internal tools too.
|
||||
Blender embeds a Python interpreter which is started with Blender and stays active.
|
||||
This interpreter runs scripts to draw the user interface and is used for some of Blender's internal tools too.
|
||||
|
||||
This is a typical python environment so tutorials on how to write python scripts will work running the scripts in blender too. Blender provides the :mod:`bpy` module to the python interpreter. This module can be imported in a script and gives access to blender data, classes, and functions. Scripts that deal with blender data will need to import this module.
|
||||
This is a typical Python environment so tutorials on how to write Python scripts
|
||||
will work running the scripts in Blender too.
|
||||
Blender provides the :mod:`bpy` module to the Python interpreter.
|
||||
This module can be imported in a script and gives access to Blender data, classes, and functions.
|
||||
Scripts that deal with Blender data will need to import this module.
|
||||
|
||||
Here is a simple example of moving a vertex of the object named **Cube**:
|
||||
|
||||
@@ -21,84 +28,96 @@ Here is a simple example of moving a vertex of the object named **Cube**:
|
||||
import bpy
|
||||
bpy.data.objects["Cube"].data.vertices[0].co.x += 1.0
|
||||
|
||||
This modifies Blender's internal data directly. When you run this in the interactive console you will see the 3D viewport update.
|
||||
This modifies Blender's internal data directly.
|
||||
When you run this in the interactive console you will see the 3D viewport update.
|
||||
|
||||
|
||||
The Default Environment
|
||||
=======================
|
||||
|
||||
When developing your own scripts it may help to understand how blender sets up its python environment. Many python scripts come bundled with blender and can be used as a reference because they use the same API that script authors write tools in. Typical usage for scripts include: user interface, import/export, scene manipulation, automation, defining your own toolset and customization.
|
||||
When developing your own scripts it may help to understand how Blender sets up its Python environment.
|
||||
Many Python scripts come bundled with Blender and can be used as a reference
|
||||
because they use the same API that script authors write tools in.
|
||||
Typical usage for scripts include: user interface, import/export,
|
||||
scene manipulation, automation, defining your own toolset and customization.
|
||||
|
||||
On startup blender scans the ``scripts/startup/`` directory for python modules and imports them. The exact location of this directory depends on your installation. `See the directory layout docs <http://wiki.blender.org/index.php/Doc:2.6/Manual/Introduction/Installing_Blender/DirectoryLayout>`_
|
||||
On startup Blender scans the ``scripts/startup/`` directory for Python modules and imports them.
|
||||
The exact location of this directory depends on your installation.
|
||||
`See the directory layout docs
|
||||
<https://www.blender.org/manual/getting_started/installing_blender/directorylayout.html>`__
|
||||
|
||||
|
||||
Script Loading
|
||||
==============
|
||||
|
||||
This may seem obvious but it's important to note the difference between executing a script directly or importing it as a module.
|
||||
This may seem obvious but it's important to note the difference
|
||||
between executing a script directly or importing it as a module.
|
||||
|
||||
Scripts that extend blender - define classes that exist beyond the scripts execution, this makes future access to these classes (to unregister for example) more difficult than importing as a module where class instance is kept in the module and can be accessed by importing that module later on.
|
||||
Scripts that extend Blender - define classes that exist beyond the scripts execution,
|
||||
this makes future access to these classes (to unregister for example)
|
||||
more difficult than importing as a module where class instance is kept
|
||||
in the module and can be accessed by importing that module later on.
|
||||
|
||||
For this reason it's preferable to only use directly execute scripts that don't extend blender by registering classes.
|
||||
For this reason it's preferable to only use directly execute scripts that don't extend Blender by registering classes.
|
||||
|
||||
|
||||
Here are some ways to run scripts directly in blender.
|
||||
Here are some ways to run scripts directly in Blender.
|
||||
|
||||
* Loaded in the text editor and press **Run Script**.
|
||||
- Loaded in the text editor and press **Run Script**.
|
||||
- Typed or pasted into the interactive console.
|
||||
- Execute a Python file from the command line with Blender, eg:
|
||||
|
||||
* Typed or pasted into the interactive console.
|
||||
.. code-block:: sh
|
||||
|
||||
* Execute a python file from the command line with blender, eg:
|
||||
|
||||
``blender --python /home/me/my_script.py``
|
||||
blender --python /home/me/my_script.py
|
||||
|
||||
|
||||
To run as modules:
|
||||
|
||||
* The obvious way, ``import some_module`` command from the text window or interactive console.
|
||||
|
||||
* Open as a text block and tick "Register" option, this will load with the blend file.
|
||||
|
||||
* copy into one of the directories ``scripts/startup``, where they will be automatically imported on startup.
|
||||
|
||||
* define as an addon, enabling the addon will load it as a python module.
|
||||
- The obvious way, ``import some_module`` command from the text window or interactive console.
|
||||
- Open as a text block and tick "Register" option, this will load with the blend file.
|
||||
- copy into one of the directories ``scripts/startup``, where they will be automatically imported on startup.
|
||||
- define as an addon, enabling the addon will load it as a Python module.
|
||||
|
||||
|
||||
Addons
|
||||
------
|
||||
|
||||
Some of blenders functionality is best kept optional, alongside scripts loaded at startup we have addons which are kept in their own directory ``scripts/addons``, and only load on startup if selected from the user preferences.
|
||||
Some of Blenders functionality is best kept optional,
|
||||
alongside scripts loaded at startup we have addons which are kept in their own directory ``scripts/addons``,
|
||||
and only load on startup if selected from the user preferences.
|
||||
|
||||
The only difference between addons and built-in python modules is that addons must contain a **bl_info** variable which blender uses to read metadata such as name, author, category and URL.
|
||||
The only difference between addons and built-in Python modules is that addons must contain a ``bl_info``
|
||||
variable which Blender uses to read metadata such as name, author, category and URL.
|
||||
|
||||
The user preferences addon listing uses **bl_info** to display information about each addon.
|
||||
|
||||
`See Addons <http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons>`_ for details on the **bl_info** dictionary.
|
||||
`See Addons <http://wiki.blender.org/index.php/Dev:2.5/Py/Scripts/Guidelines/Addons>`__
|
||||
for details on the ``bl_info`` dictionary.
|
||||
|
||||
|
||||
Integration through Classes
|
||||
===========================
|
||||
|
||||
Running python scripts in the text editor is useful for testing but you’ll want to extend blender to make tools accessible like other built-in functionality.
|
||||
Running Python scripts in the text editor is useful for testing but you'll
|
||||
want to extend Blender to make tools accessible like other built-in functionality.
|
||||
|
||||
The blender python api allows integration for:
|
||||
The Blender Python api allows integration for:
|
||||
|
||||
* :class:`bpy.types.Panel`
|
||||
|
||||
* :class:`bpy.types.Menu`
|
||||
|
||||
* :class:`bpy.types.Operator`
|
||||
|
||||
* :class:`bpy.types.PropertyGroup`
|
||||
|
||||
* :class:`bpy.types.KeyingSet`
|
||||
|
||||
* :class:`bpy.types.RenderEngine`
|
||||
- :class:`bpy.types.Panel`
|
||||
- :class:`bpy.types.Menu`
|
||||
- :class:`bpy.types.Operator`
|
||||
- :class:`bpy.types.PropertyGroup`
|
||||
- :class:`bpy.types.KeyingSet`
|
||||
- :class:`bpy.types.RenderEngine`
|
||||
|
||||
|
||||
This is intentionally limited. Currently, for more advanced features such as mesh modifiers, object types, or shader nodes, C/C++ must be used.
|
||||
This is intentionally limited. Currently, for more advanced features such as mesh modifiers,
|
||||
object types, or shader nodes, C/C++ must be used.
|
||||
|
||||
For python intergration Blender defines methods which are common to all types. This works by creating a python subclass of a Blender class which contains variables and functions specified by the parent class which are pre-defined to interface with Blender.
|
||||
For Python integration Blender defines methods which are common to all types.
|
||||
This works by creating a Python subclass of a Blender class which contains variables and functions
|
||||
specified by the parent class which are pre-defined to interface with Blender.
|
||||
|
||||
For example:
|
||||
|
||||
@@ -115,15 +134,20 @@ For example:
|
||||
|
||||
bpy.utils.register_class(SimpleOperator)
|
||||
|
||||
First note that we subclass a member of :mod:`bpy.types`, this is common for all classes which can be integrated with blender and used so we know if this is an Operator and not a Panel when registering.
|
||||
First note that we subclass a member of :mod:`bpy.types`,
|
||||
this is common for all classes which can be integrated with Blender and
|
||||
used so we know if this is an Operator and not a Panel when registering.
|
||||
|
||||
Both class properties start with a **bl_** prefix. This is a convention used to distinguish blender properties from those you add yourself.
|
||||
Both class properties start with a ``bl_`` prefix.
|
||||
This is a convention used to distinguish Blender properties from those you add yourself.
|
||||
|
||||
Next see the execute function, which takes an instance of the operator and the current context. A common prefix is not used for functions.
|
||||
Next see the execute function, which takes an instance of the operator and the current context.
|
||||
A common prefix is not used for functions.
|
||||
|
||||
Lastly the register function is called, this takes the class and loads it into blender. See `Class Registration`_.
|
||||
Lastly the register function is called, this takes the class and loads it into Blender. See `Class Registration`_.
|
||||
|
||||
Regarding inheritance, blender doesn't impose restrictions on the kinds of class inheritance used, the registration checks will use attributes and functions defined in parent classes.
|
||||
Regarding inheritance, Blender doesn't impose restrictions on the kinds of class inheritance used,
|
||||
the registration checks will use attributes and functions defined in parent classes.
|
||||
|
||||
class mix-in example:
|
||||
|
||||
@@ -141,11 +165,20 @@ class mix-in example:
|
||||
|
||||
bpy.utils.register_class(SimpleOperator)
|
||||
|
||||
Notice these classes don't define an ``__init__(self)`` function. While ``__init__()`` and ``__del__()`` will be called if defined, the class instances lifetime only spans the execution. So a panel for example will have a new instance for every redraw, for this reason there is rarely a cause to store variables in the panel instance. Instead, persistent variables should be stored in Blenders data so that the state can be restored when blender is restarted.
|
||||
Notice these classes don't define an ``__init__(self)`` function.
|
||||
While ``__init__()`` and ``__del__()`` will be called if defined,
|
||||
the class instances lifetime only spans the execution.
|
||||
So a panel for example will have a new instance for every redraw,
|
||||
for this reason there is rarely a cause to store variables in the panel instance.
|
||||
Instead, persistent variables should be stored in Blenders
|
||||
ata so that the state can be restored when Blender is restarted.
|
||||
|
||||
.. note:: Modal operators are an exception, keeping their instance variable as blender runs, see modal operator template.
|
||||
.. note::
|
||||
|
||||
So once the class is registered with blender, instancing the class and calling the functions is left up to blender. In fact you cannot instance these classes from the script as you would expect with most python API's.
|
||||
Modal operators are an exception, keeping their instance variable as Blender runs, see modal operator template.
|
||||
|
||||
So once the class is registered with Blender, instancing the class and calling the functions is left up to Blender.
|
||||
In fact you cannot instance these classes from the script as you would expect with most Python API's.
|
||||
|
||||
To run operators you can call them through the operator api, eg:
|
||||
|
||||
@@ -154,7 +187,8 @@ To run operators you can call them through the operator api, eg:
|
||||
import bpy
|
||||
bpy.ops.object.simple_operator()
|
||||
|
||||
User interface classes are given a context in which to draw, buttons window, file header, toolbar etc, then they are drawn when that area is displayed so they are never called by python scripts directly.
|
||||
User interface classes are given a context in which to draw, buttons window, file header, toolbar etc,
|
||||
then they are drawn when that area is displayed so they are never called by Python scripts directly.
|
||||
|
||||
|
||||
Registration
|
||||
@@ -164,9 +198,10 @@ Registration
|
||||
Module Registration
|
||||
-------------------
|
||||
|
||||
Blender modules loaded at startup require ``register()`` and ``unregister()`` functions. These are the *only* functions that blender calls from your code, which is otherwise a regular python module.
|
||||
Blender modules loaded at startup require ``register()`` and ``unregister()`` functions.
|
||||
These are the *only* functions that Blender calls from your code, which is otherwise a regular Python module.
|
||||
|
||||
A simple blender/python module can look like this:
|
||||
A simple Blender/Python module can look like this:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -184,12 +219,16 @@ A simple blender/python module can look like this:
|
||||
if __name__ == "__main__":
|
||||
register()
|
||||
|
||||
These functions usually appear at the bottom of the script containing class registration sometimes adding menu items. You can also use them for internal purposes setting up data for your own tools but take care since register won't re-run when a new blend file is loaded.
|
||||
These functions usually appear at the bottom of the script containing class registration sometimes adding menu items.
|
||||
You can also use them for internal purposes setting up data for your own tools but take care
|
||||
since register won't re-run when a new blend file is loaded.
|
||||
|
||||
The register/unregister calls are used so it's possible to toggle addons and reload scripts while blender runs.
|
||||
If the register calls were placed in the body of the script, registration would be called on import, meaning there would be no distinction between importing a module or loading its classes into blender.
|
||||
The register/unregister calls are used so it's possible to toggle addons and reload scripts while Blender runs.
|
||||
If the register calls were placed in the body of the script, registration would be called on import,
|
||||
meaning there would be no distinction between importing a module or loading its classes into Blender.
|
||||
|
||||
This becomes problematic when a script imports classes from another module making it difficult to manage which classes are being loaded and when.
|
||||
This becomes problematic when a script imports classes from another module
|
||||
making it difficult to manage which classes are being loaded and when.
|
||||
|
||||
The last 2 lines are only for testing:
|
||||
|
||||
@@ -199,19 +238,24 @@ The last 2 lines are only for testing:
|
||||
register()
|
||||
|
||||
This allows the script to be run directly in the text editor to test changes.
|
||||
This ``register()`` call won't run when the script is imported as a module since ``__main__`` is reserved for direct execution.
|
||||
This ``register()`` call won't run when the script is imported as a module
|
||||
since ``__main__`` is reserved for direct execution.
|
||||
|
||||
|
||||
Class Registration
|
||||
------------------
|
||||
|
||||
Registering a class with blender results in the class definition being loaded into blender, where it becomes available alongside existing functionality.
|
||||
Registering a class with Blender results in the class definition being loaded into Blender,
|
||||
where it becomes available alongside existing functionality.
|
||||
|
||||
Once this class is loaded you can access it from :mod:`bpy.types`, using the bl_idname rather than the classes original name.
|
||||
Once this class is loaded you can access it from :mod:`bpy.types`,
|
||||
using the bl_idname rather than the classes original name.
|
||||
|
||||
When loading a class, blender performs sanity checks making sure all required properties and functions are found, that properties have the correct type, and that functions have the right number of arguments.
|
||||
When loading a class, Blender performs sanity checks making sure all required properties and functions are found,
|
||||
that properties have the correct type, and that functions have the right number of arguments.
|
||||
|
||||
Mostly you will not need concern yourself with this but if there is a problem with the class definition it will be raised on registering:
|
||||
Mostly you will not need concern yourself with this but if there is a problem
|
||||
with the class definition it will be raised on registering:
|
||||
|
||||
Using the function arguments ``def execute(self, context, spam)``, will raise an exception:
|
||||
|
||||
@@ -225,9 +269,13 @@ Using ``bl_idname = 1`` will raise.
|
||||
Multiple-Classes
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
Loading classes into blender is described above, for simple cases calling :mod:`bpy.utils.register_class` (SomeClass) is sufficient, but when there are many classes or a packages submodule has its own classes it can be tedious to list them all for registration.
|
||||
Loading classes into Blender is described above,
|
||||
for simple cases calling :mod:`bpy.utils.register_class` (SomeClass) is sufficient,
|
||||
but when there are many classes or a packages submodule has its own
|
||||
classes it can be tedious to list them all for registration.
|
||||
|
||||
For more convenient loading/unloading :mod:`bpy.utils.register_module` (module) and :mod:`bpy.utils.unregister_module` (module) functions exist.
|
||||
For more convenient loading/unloading :mod:`bpy.utils.register_module` (module)
|
||||
and :mod:`bpy.utils.unregister_module` (module) functions exist.
|
||||
|
||||
A script which defines many of its own operators, panels menus etc. you only need to write:
|
||||
|
||||
@@ -239,13 +287,19 @@ A script which defines many of its own operators, panels menus etc. you only nee
|
||||
def unregister():
|
||||
bpy.utils.unregister_module(__name__)
|
||||
|
||||
Internally blender collects subclasses on registrable types, storing them by the module in which they are defined. By passing the module name to :mod:`bpy.utils.register_module` blender can register all classes created by this module and its submodules.
|
||||
Internally Blender collects subclasses on registrable types, storing them by the module in which they are defined.
|
||||
By passing the module name to :mod:`bpy.utils.register_module`
|
||||
Blender can register all classes created by this module and its submodules.
|
||||
|
||||
|
||||
Inter Classes Dependencies
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When customizing blender you may want to group your own settings together, after all, they will likely have to co-exist with other scripts. To group these properties classes need to be defined, for groups within groups or collections within groups you can find yourself having to deal with order of registration/unregistration.
|
||||
When customizing Blender you may want to group your own settings together,
|
||||
after all, they will likely have to co-exist with other scripts.
|
||||
To group these properties classes need to be defined,
|
||||
for groups within groups or collections within groups
|
||||
you can find yourself having to deal with order of registration/unregistration.
|
||||
|
||||
Custom properties groups are themselves classes which need to be registered.
|
||||
|
||||
@@ -311,7 +365,9 @@ Say you want to store material settings for a custom engine.
|
||||
Manipulating Classes
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Properties can be added and removed as blender runs, normally happens on register or unregister but for some special cases it may be useful to modify types as the script runs.
|
||||
Properties can be added and removed as Blender runs,
|
||||
normally happens on register or unregister but for some
|
||||
special cases it may be useful to modify types as the script runs.
|
||||
|
||||
For example:
|
||||
|
||||
@@ -341,7 +397,8 @@ This works just as well for PropertyGroup subclasses you define yourself.
|
||||
Dynamic Defined-Classes (Advanced)
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
In some cases the specifier for data may not be in blender, renderman shader definitions for example and it may be useful to define types and remove them on the fly.
|
||||
In some cases the specifier for data may not be in Blender,
|
||||
renderman shader definitions for example and it may be useful to define types and remove them on the fly.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -360,7 +417,8 @@ In some cases the specifier for data may not be in blender, renderman shader def
|
||||
|
||||
.. note::
|
||||
|
||||
Notice ``type()`` is called to define the class. This is an alternative syntax for class creation in python, better suited to constructing classes dynamically.
|
||||
``type()`` is called to define the class.
|
||||
This is an alternative syntax for class creation in Python, better suited to constructing classes dynamically.
|
||||
|
||||
|
||||
Calling these operators:
|
||||
|
@@ -1,3 +1,4 @@
|
||||
|
||||
.. _info_quickstart:
|
||||
|
||||
***********************
|
||||
@@ -32,13 +33,15 @@ The Blender/Python API **can't** (yet)...
|
||||
Before Starting
|
||||
===============
|
||||
|
||||
This document isn't intended to fully cover each topic. Rather, its purpose is to familiarize you with Blender Python API.
|
||||
This document isn't intended to fully cover each topic.
|
||||
Rather, its purpose is to familiarize you with Blender Python API.
|
||||
|
||||
|
||||
A quick list of helpful things to know before starting:
|
||||
|
||||
- Blender uses Python 3.x; some online documentation still assumes 2.x.
|
||||
- The interactive console is great for testing one-liners, It also has autocompletion so you can inspect the API quickly.
|
||||
- The interactive console is great for testing one-liners.
|
||||
It also has autocompletion so you can inspect the API quickly.
|
||||
- Button tool tips show Python attributes and operator names.
|
||||
- Right clicking on buttons and menu items directly links to API documentation.
|
||||
- For more examples, the text menu has a templates section where some example operators can be found.
|
||||
@@ -51,15 +54,19 @@ A quick list of helpful things to know before starting:
|
||||
Running Scripts
|
||||
---------------
|
||||
|
||||
The two most common ways to execute Python scripts are using the built-in text editor or entering commands in the Python console.
|
||||
The two most common ways to execute Python scripts are using the built-in
|
||||
text editor or entering commands in the Python console.
|
||||
|
||||
Both the **Text Editor** and **Python Console** are space types you can select from the view header.
|
||||
Both the *Text Editor* and *Python Console* are space types you can select from the view header.
|
||||
|
||||
Rather then manually configuring your spaces for Python development, you may prefer to use the **Scripting** screen, included default with Blender, accessible from the top headers screen selector.
|
||||
Rather then manually configuring your spaces for Python development,
|
||||
you may prefer to use the *Scripting* screen, included default with Blender,
|
||||
accessible from the top headers screen selector.
|
||||
|
||||
From the text editor you can open ``.py`` files or paste then from the clipboard, then test using **Run Script**.
|
||||
From the text editor you can open ``.py`` files or paste then from the clipboard, then test using *Run Script*.
|
||||
|
||||
The Python Console is typically used for typing in snippets and for testing to get immediate feedback, but can also have entire scripts pasted into it.
|
||||
The Python Console is typically used for typing in snippets and for testing to get immediate feedback,
|
||||
but can also have entire scripts pasted into it.
|
||||
|
||||
Scripts can also run from the command line with Blender but to learn Blender/Python this isn't essential.
|
||||
|
||||
@@ -73,9 +80,11 @@ Data Access
|
||||
Accessing DataBlocks
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Python accesses Blender's data in the same way as the animation system and user interface; this implies that any setting that can be changed via a button can also be changed from Python.
|
||||
Python accesses Blender's data in the same way as the animation system and user interface;
|
||||
this implies that any setting that can be changed via a button can also be changed from Python.
|
||||
|
||||
Accessing data from the currently loaded blend file is done with the module :mod:`bpy.data`. This gives access to library data. For example:
|
||||
Accessing data from the currently loaded blend file is done with the module :mod:`bpy.data`.
|
||||
This gives access to library data. For example:
|
||||
|
||||
>>> bpy.data.objects
|
||||
<bpy_collection[3], BlendDataObjects>
|
||||
@@ -92,7 +101,8 @@ About Collections
|
||||
|
||||
You'll notice that an index as well as a string can be used to access members of the collection.
|
||||
|
||||
Unlike Python's dictionaries, both methods are acceptable; however, the index of a member may change while running Blender.
|
||||
Unlike Python's dictionaries, both methods are acceptable;
|
||||
however, the index of a member may change while running Blender.
|
||||
|
||||
>>> list(bpy.data.objects)
|
||||
[bpy.data.objects["Cube"], bpy.data.objects["Plane"]]
|
||||
@@ -107,7 +117,10 @@ Unlike Python's dictionaries, both methods are acceptable; however, the index of
|
||||
Accessing Attributes
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Once you have a data block, such as a material, object, groups etc., its attributes can be accessed much like you would change a setting using the graphical interface. In fact, the tooltip for each button also displays the Python attribute which can help in finding what settings to change in a script.
|
||||
Once you have a data block, such as a material, object, groups etc.,
|
||||
its attributes can be accessed much like you would change a setting using the graphical interface.
|
||||
In fact, the tooltip for each button also displays the Python attribute
|
||||
which can help in finding what settings to change in a script.
|
||||
|
||||
>>> bpy.data.objects[0].name
|
||||
'Camera'
|
||||
@@ -119,7 +132,8 @@ Once you have a data block, such as a material, object, groups etc., its attribu
|
||||
bpy.data.materials['MyMaterial']
|
||||
|
||||
|
||||
For testing what data to access it's useful to use the "Console", which is its own space type. This supports auto-complete, giving you a fast way to dig into different data in your file.
|
||||
For testing what data to access it's useful to use the "Console", which is its own space type.
|
||||
This supports auto-complete, giving you a fast way to dig into different data in your file.
|
||||
|
||||
Example of a data path that can be quickly found via the console:
|
||||
|
||||
@@ -132,7 +146,8 @@ Example of a data path that can be quickly found via the console:
|
||||
Data Creation/Removal
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Those of you familiar with other Python API's may be surprised that new datablocks in the bpy API can't be created by calling the class:
|
||||
Those of you familiar with other Python API's may be surprised that
|
||||
new datablocks in the bpy API can't be created by calling the class:
|
||||
|
||||
>>> bpy.types.Mesh()
|
||||
Traceback (most recent call last):
|
||||
@@ -141,7 +156,8 @@ Those of you familiar with other Python API's may be surprised that new databloc
|
||||
|
||||
|
||||
This is an intentional part of the API design.
|
||||
The Blender/Python API can't create Blender data that exists outside the main Blender database (accessed through :mod:`bpy.data`), because this data is managed by Blender (save/load/undo/append... etc).
|
||||
The Blender/Python API can't create Blender data that exists outside the main Blender database
|
||||
(accessed through :mod:`bpy.data`), because this data is managed by Blender (save/load/undo/append... etc).
|
||||
|
||||
Data is added and removed via methods on the collections in :mod:`bpy.data`, eg:
|
||||
|
||||
@@ -155,8 +171,10 @@ Data is added and removed via methods on the collections in :mod:`bpy.data`, eg:
|
||||
Custom Properties
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
Python can access properties on any datablock that has an ID (data that can be linked in and accessed from :mod:`bpy.data`.
|
||||
When assigning a property, you can make up your own names, these will be created when needed or overwritten if they exist.
|
||||
Python can access properties on any datablock that has an ID
|
||||
(data that can be linked in and accessed from :mod:`bpy.data`.
|
||||
When assigning a property, you can make up your own names,
|
||||
these will be created when needed or overwritten if they exist.
|
||||
|
||||
This data is saved with the blend file and copied with objects.
|
||||
|
||||
@@ -192,8 +210,10 @@ These properties are valid outside of Python. They can be animated by curves or
|
||||
Context
|
||||
-------
|
||||
|
||||
While it's useful to be able to access data directly by name or as a list, it's more common to operate on the user's selection.
|
||||
The context is always available from ``bpy.context`` and can be used to get the active object, scene, tool settings along with many other attributes.
|
||||
While it's useful to be able to access data directly by name or as a list,
|
||||
it's more common to operate on the user's selection.
|
||||
The context is always available from ``bpy.context`` and can be used to get the active object, scene,
|
||||
tool settings along with many other attributes.
|
||||
|
||||
Common-use cases:
|
||||
|
||||
@@ -201,7 +221,9 @@ Common-use cases:
|
||||
>>> bpy.context.selected_objects
|
||||
>>> bpy.context.visible_bones
|
||||
|
||||
Note that the context is read-only. These values cannot be modified directly, though they may be changed by running API functions or by using the data API.
|
||||
Note that the context is read-only.
|
||||
These values cannot be modified directly,
|
||||
though they may be changed by running API functions or by using the data API.
|
||||
|
||||
So ``bpy.context.object = obj`` will raise an error.
|
||||
|
||||
@@ -209,7 +231,8 @@ But ``bpy.context.scene.objects.active = obj`` will work as expected.
|
||||
|
||||
|
||||
The context attributes change depending on where they are accessed.
|
||||
The 3D view has different context members than the console, so take care when accessing context attributes that the user state is known.
|
||||
The 3D view has different context members than the console,
|
||||
so take care when accessing context attributes that the user state is known.
|
||||
|
||||
See :mod:`bpy.context` API reference.
|
||||
|
||||
@@ -217,7 +240,9 @@ See :mod:`bpy.context` API reference.
|
||||
Operators (Tools)
|
||||
-----------------
|
||||
|
||||
Operators are tools generally accessed by the user from buttons, menu items or key shortcuts. From the user perspective they are a tool but Python can run these with its own settings through the :mod:`bpy.ops` module.
|
||||
Operators are tools generally accessed by the user from buttons, menu items or key shortcuts.
|
||||
From the user perspective they are a tool but Python can run these with its own settings
|
||||
through the :mod:`bpy.ops` module.
|
||||
|
||||
Examples:
|
||||
|
||||
@@ -230,14 +255,16 @@ Examples:
|
||||
|
||||
.. note::
|
||||
|
||||
The menu item: :menuselection:`Help --> Operator Cheat Sheet` gives a list of all operators and their default values in Python syntax, along with the generated docs.
|
||||
The menu item: :menuselection:`Help --> Operator Cheat Sheet`
|
||||
gives a list of all operators and their default values in Python syntax, along with the generated docs.
|
||||
This is a good way to get an overview of all Blender's operators.
|
||||
|
||||
|
||||
Operator Poll()
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
Many operators have a "poll" function which may check that the mouse is in a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc).
|
||||
Many operators have a "poll" function which may check that the cursor
|
||||
is in a valid area or that the object is in the correct mode (Edit Mode, Weight Paint etc).
|
||||
When an operator's poll function fails within Python, an exception is raised.
|
||||
|
||||
For example, calling ``bpy.ops.view3d.render_border()`` from the console raises the following error:
|
||||
@@ -248,7 +275,8 @@ For example, calling ``bpy.ops.view3d.render_border()`` from the console raises
|
||||
|
||||
In this case the context must be the 3d view with an active camera.
|
||||
|
||||
To avoid using try/except clauses wherever operators are called you can call the operators own .poll() function to check if it can run in the current context.
|
||||
To avoid using try/except clauses wherever operators are called you can call the operators
|
||||
own ``poll()`` function to check if it can run in the current context.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -275,7 +303,8 @@ Example Operator
|
||||
|
||||
.. literalinclude:: ../../../release/scripts/templates_py/operator_simple.py
|
||||
|
||||
Once this script runs, ``SimpleOperator`` is registered with Blender and can be called from the operator search popup or added to the toolbar.
|
||||
Once this script runs, ``SimpleOperator`` is registered with Blender
|
||||
and can be called from the operator search popup or added to the toolbar.
|
||||
|
||||
To run the script:
|
||||
|
||||
@@ -285,19 +314,23 @@ To run the script:
|
||||
#. Click the button labeled ``New`` and the confirmation pop up in order to create a new text block.
|
||||
#. Press :kbd:`Ctrl-V` to paste the code into the text panel (the upper left frame).
|
||||
#. Click on the button **Run Script**.
|
||||
#. Move your mouse into the 3D view, press spacebar for the operator search menu, and type "Simple".
|
||||
#. Move your cursor into the 3D view, press spacebar for the operator search menu, and type "Simple".
|
||||
#. Click on the "Simple Operator" item found in search.
|
||||
|
||||
|
||||
.. seealso:: The class members with the ``bl_`` prefix are documented in the API
|
||||
reference :class:`bpy.types.Operator`
|
||||
|
||||
.. note:: The output from the ``main`` function is sent to the terminal; in order to see this, be sure to :ref:`use the terminal <use_the_terminal>`.
|
||||
.. note::
|
||||
|
||||
The output from the ``main`` function is sent to the terminal;
|
||||
in order to see this, be sure to :ref:`use the terminal <use_the_terminal>`.
|
||||
|
||||
Example Panel
|
||||
-------------
|
||||
|
||||
Panels register themselves as a class, like an operator. Notice the extra ``bl_`` variables used to set the context they display in.
|
||||
Panels register themselves as a class, like an operator.
|
||||
Notice the extra ``bl_`` variables used to set the context they display in.
|
||||
|
||||
.. literalinclude:: ../../../release/scripts/templates_py/ui_panel_simple.py
|
||||
|
||||
@@ -334,7 +367,8 @@ Blender's Python API can be split up into 3 categories.
|
||||
Native Types
|
||||
------------
|
||||
|
||||
In simple cases returning a number or a string as a custom type would be cumbersome, so these are accessed as normal Python types.
|
||||
In simple cases returning a number or a string as a custom type would be cumbersome,
|
||||
so these are accessed as normal Python types.
|
||||
|
||||
- Blender float/int/boolean -> float/int/boolean
|
||||
- Blender enumerator -> string
|
||||
@@ -359,7 +393,8 @@ Used for Blender datablocks and collections: :class:`bpy.types.bpy_struct`
|
||||
|
||||
For data that contains its own attributes groups/meshes/bones/scenes... etc.
|
||||
|
||||
There are 2 main types that wrap Blenders data, one for datablocks (known internally as ``bpy_struct``), another for properties.
|
||||
There are 2 main types that wrap Blenders data, one for datablocks
|
||||
(known internally as ``bpy_struct``), another for properties.
|
||||
|
||||
>>> bpy.context.object
|
||||
bpy.data.objects['Cube']
|
||||
@@ -375,7 +410,9 @@ Mathutils Types
|
||||
|
||||
Used for vectors, quaternion, eulers, matrix and color types, accessible from :mod:`mathutils`
|
||||
|
||||
Some attributes such as :class:`bpy.types.Object.location`, :class:`bpy.types.PoseBone.rotation_euler` and :class:`bpy.types.Scene.cursor_location` can be accessed as special math types which can be used together and manipulated in various useful ways.
|
||||
Some attributes such as :class:`bpy.types.Object.location`,
|
||||
:class:`bpy.types.PoseBone.rotation_euler` and :class:`bpy.types.Scene.cursor_location`
|
||||
can be accessed as special math types which can be used together and manipulated in various useful ways.
|
||||
|
||||
Example of a matrix, vector multiplication:
|
||||
|
||||
@@ -410,7 +447,9 @@ Animation
|
||||
|
||||
There are 2 ways to add keyframes through Python.
|
||||
|
||||
The first is through key properties directly, which is similar to inserting a keyframe from the button as a user. You can also manually create the curves and keyframe data, then set the path to the property. Here are examples of both methods.
|
||||
The first is through key properties directly, which is similar to inserting a keyframe from the button as a user.
|
||||
You can also manually create the curves and keyframe data, then set the path to the property.
|
||||
Here are examples of both methods.
|
||||
|
||||
Both examples insert a keyframe on the active object's Z axis.
|
||||
|
||||
|
@@ -1,10 +1,12 @@
|
||||
|
||||
***************
|
||||
Tips and Tricks
|
||||
***************
|
||||
|
||||
Here are various suggestions that you might find useful when writing scripts.
|
||||
|
||||
Some of these are just python features that scripters may not have thought to use with blender, others are blender specific.
|
||||
Some of these are just Python features that scripters may not have thought to use with Blender,
|
||||
others are Blender specific.
|
||||
|
||||
|
||||
.. _use_the_terminal:
|
||||
@@ -12,18 +14,21 @@ Some of these are just python features that scripters may not have thought to us
|
||||
Use The Terminal
|
||||
================
|
||||
|
||||
When writing python scripts, it's useful to have a terminal open, this is not the built-in python console but a terminal application which is used to start blender.
|
||||
When writing Python scripts, it's useful to have a terminal open,
|
||||
this is not the built-in Python console but a terminal application which is used to start Blender.
|
||||
|
||||
There are 3 main uses for the terminal, these are:
|
||||
|
||||
* You can see the output of ``print()`` as your script runs, which is useful to view debug info.
|
||||
|
||||
* The error trace-back is printed in full to the terminal which won't always generate an error popup in blender's user interface (depending on how the script is executed).
|
||||
|
||||
* If the script runs for too long or you accidentally enter an infinite loop, Ctrl+C in the terminal (Ctrl+Break on Windows) will quit the script early.
|
||||
- You can see the output of ``print()`` as your script runs, which is useful to view debug info.
|
||||
- The error trace-back is printed in full to the terminal which won't always generate an error popup in
|
||||
Blender's user interface (depending on how the script is executed).
|
||||
- If the script runs for too long or you accidentally enter an infinite loop,
|
||||
:kbd:`Ctrl-C` in the terminal (:kbd:`Ctrl-Break` on Windows) will quit the script early.
|
||||
|
||||
.. note::
|
||||
For Linux and OSX users this means starting the terminal first, then running blender from within it. On Windows the terminal can be enabled from the help menu.
|
||||
|
||||
For Linux and OSX users this means starting the terminal first, then running Blender from within it.
|
||||
On Windows the terminal can be enabled from the help menu.
|
||||
|
||||
|
||||
Interface Tricks
|
||||
@@ -33,43 +38,56 @@ Interface Tricks
|
||||
Access Operator Commands
|
||||
------------------------
|
||||
|
||||
You may have noticed that the tooltip for menu items and buttons includes the ``bpy.ops``... command to run that button, a handy (hidden) feature is that you can press Ctrl+C over any menu item/button to copy this command into the clipboard.
|
||||
You may have noticed that the tooltip for menu items and buttons includes the ``bpy.ops.[...])`` command
|
||||
to run that button, a handy (hidden) feature is that you can press :kbd:`Ctrl-C` over
|
||||
any menu item/button to copy this command into the clipboard.
|
||||
|
||||
|
||||
Access Data Path
|
||||
----------------
|
||||
|
||||
To find the path from an :class:`ID` datablock to its setting isn't always so simple since it may be nested away. To get this quickly you can right click on the setting and select select **Copy Data Path**,
|
||||
To find the path from an :class:`ID` datablock to its setting isn't always so simple since it may be nested away.
|
||||
To get this quickly you can right click on the setting and select select **Copy Data Path**,
|
||||
if this can't be generated, only the property name is copied.
|
||||
|
||||
.. note::
|
||||
|
||||
This uses the same method for creating the animation path used by :class:`bpy.types.FCurve.data_path` and :class:`bpy.types.DriverTarget.data_path` drivers.
|
||||
This uses the same method for creating the animation path used by
|
||||
:class:`bpy.types.FCurve.data_path` and
|
||||
:class:`bpy.types.DriverTarget.data_path` drivers.
|
||||
|
||||
|
||||
.. _info_show_all_operators
|
||||
.. _info_show_all_operators:
|
||||
|
||||
Show All Operators
|
||||
==================
|
||||
|
||||
While blender logs operators in the Info space, this only reports operators with the ``REGISTER`` option enabeld so as not to flood the Info view with calls to ``bpy.ops.view3d.smoothview`` and ``bpy.ops.view3d.zoom``.
|
||||
While Blender logs operators in the Info space,
|
||||
this only reports operators with the ``REGISTER`` option enabeld so as not to flood the *Info* view
|
||||
with calls to ``bpy.ops.view3d.smoothview`` and ``bpy.ops.view3d.zoom``.
|
||||
|
||||
However, for testing it can be useful to see **every** operator called in a terminal, do this by enabling the debug option either by passing the ``--debug-wm`` argument when starting blender or by setting :mod:`bpy.app.debug_wm` to True while blender is running.
|
||||
However, for testing it can be useful to see **every** operator called in a terminal,
|
||||
do this by enabling the debug option either by passing the ``--debug-wm`` argument when starting Blender
|
||||
or by setting :mod:`bpy.app.debug_wm` to ``True`` while Blender is running.
|
||||
|
||||
|
||||
Use an External Editor
|
||||
======================
|
||||
|
||||
Blenders text editor is fine for small changes and writing tests but its not full featured, for larger projects you'll probably want to use a standalone editor or python IDE.
|
||||
Blenders text editor is fine for small changes and writing tests but its not full featured,
|
||||
for larger projects you'll probably want to use a standalone editor or Python IDE.
|
||||
|
||||
Editing a text file externally and having the same text open in blender does work but isn't that optimal so here are 2 ways you can easily use an external file from blender.
|
||||
Editing a text file externally and having the same text open in Blender does work but isn't that optimal
|
||||
so here are 2 ways you can easily use an external file from Blender.
|
||||
|
||||
Using the following examples you'll still need textblock in Blender to execute,
|
||||
but reference an external file rather then including it directly.
|
||||
|
||||
Using the following examples you'll still need textblock in blender to execute, but reference an external file rather then including it directly.
|
||||
|
||||
Executing External Scripts
|
||||
--------------------------
|
||||
|
||||
This is the equivalent to running the script directly, referencing a scripts path from a 2 line textblock.
|
||||
This is the equivalent to running the script directly, referencing a scripts path from a 2 line text-block.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -102,12 +120,17 @@ This example shows loading a script in as a module and executing a module functi
|
||||
myscript.main()
|
||||
|
||||
|
||||
Notice that the script is reloaded every time, this forces use of the modified version, otherwise the cached one in ``sys.modules`` would be used until blender was restarted.
|
||||
Notice that the script is reloaded every time, this forces use of the modified version,
|
||||
otherwise the cached one in ``sys.modules`` would be used until Blender was restarted.
|
||||
|
||||
The important difference between this and executing the script directly is it has to call a function in the module, in this case ``main()`` but it can be any function, an advantage with this is you can pass arguments to the function from this small script which is often useful for testing different settings quickly.
|
||||
The important difference between this and executing the script directly is it
|
||||
has to call a function in the module, in this case ``main()`` but it can be any function,
|
||||
an advantage with this is you can pass arguments to the function from this
|
||||
small script which is often useful for testing different settings quickly.
|
||||
|
||||
The other issue with this is the script has to be in pythons module search path.
|
||||
While this is not best practice - for testing you can extend the search path, this example adds the current blend files directory to the search path, then loads the script as a module.
|
||||
The other issue with this is the script has to be in Pythons module search path.
|
||||
While this is not best practice - for testing you can extend the search path,
|
||||
this example adds the current blend files directory to the search path, then loads the script as a module.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -128,71 +151,86 @@ While this is not best practice - for testing you can extend the search path, th
|
||||
Don't Use Blender!
|
||||
==================
|
||||
|
||||
While developing your own scripts blenders interface can get in the way, manually reloading, running the scripts, opening file import etc. adds overhead.
|
||||
While developing your own scripts Blenders interface can get in the way,
|
||||
manually reloading, running the scripts, opening file import etc. adds overhead.
|
||||
|
||||
For scripts that are not interactive it can end up being more efficient not to use blenders interface at all and instead execute the script on the command line.
|
||||
For scripts that are not interactive it can end up being more efficient not to use
|
||||
Blenders interface at all and instead execute the script on the command line.
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: sh
|
||||
|
||||
blender --background --python myscript.py
|
||||
|
||||
|
||||
You might want to run this with a blend file so the script has some data to operate on.
|
||||
|
||||
.. code-block:: python
|
||||
.. code-block:: sh
|
||||
|
||||
blender myscene.blend --background --python myscript.py
|
||||
|
||||
|
||||
.. note::
|
||||
|
||||
Depending on your setup you might have to enter the full path to the blender executable.
|
||||
Depending on your setup you might have to enter the full path to the Blender executable.
|
||||
|
||||
|
||||
Once the script is running properly in background mode, you'll want to check the output of the script, this depends completely on the task at hand however here are some suggestions.
|
||||
Once the script is running properly in background mode, you'll want to check the output of the script,
|
||||
this depends completely on the task at hand however here are some suggestions.
|
||||
|
||||
* render the output to an image, use an image viewer and keep writing over the same image each time.
|
||||
|
||||
* save a new blend file, or export the file using one of blenders exporters.
|
||||
|
||||
* if the results can be displayed as text - print them or write them to a file.
|
||||
- render the output to an image, use an image viewer and keep writing over the same image each time.
|
||||
- save a new blend file, or export the file using one of Blenders exporters.
|
||||
- if the results can be displayed as text - print them or write them to a file.
|
||||
|
||||
|
||||
This can take a little time to setup, but it can be well worth the effort to reduce the time it takes to test changes - you can even have blender running the script ever few seconds with a viewer updating the results, so no need to leave your text editor to see changes.
|
||||
While this can take a little time to setup, it can be well worth the effort
|
||||
to reduce the time it takes to test changes - you can even have
|
||||
Blender running the script every few seconds with a viewer updating the results,
|
||||
so no need to leave your text editor to see changes.
|
||||
|
||||
|
||||
Use External Tools
|
||||
==================
|
||||
|
||||
When there are no readily available python modules to perform specific tasks it's worth keeping in mind you may be able to have python execute an external command on your data and read the result back in.
|
||||
When there are no readily available Python modules to perform specific tasks it's
|
||||
worth keeping in mind you may be able to have Python execute an external command
|
||||
on your data and read the result back in.
|
||||
|
||||
Using external programs adds an extra dependency and may limit who can use the script but to quickly setup your own custom pipeline or writing one-off scripts this can be handy.
|
||||
Using external programs adds an extra dependency and may limit who can use the script
|
||||
but to quickly setup your own custom pipeline or writing one-off scripts this can be handy.
|
||||
|
||||
Examples include:
|
||||
|
||||
* Run The Gimp in batch mode to execute custom scripts for advanced image processing.
|
||||
|
||||
* Write out 3D models to use external mesh manipulation tools and read back in the results.
|
||||
|
||||
* Convert files into recognizable formats before reading.
|
||||
- Run The Gimp in batch mode to execute custom scripts for advanced image processing.
|
||||
- Write out 3D models to use external mesh manipulation tools and read back in the results.
|
||||
- Convert files into recognizable formats before reading.
|
||||
|
||||
|
||||
Bundled Python & Extensions
|
||||
===========================
|
||||
|
||||
The Blender releases distributed from blender.org include a complete python installation on all platforms, this has the disadvantage that any extensions you have installed in your systems python wont be found by blender.
|
||||
The Blender releases distributed from blender.org include a complete Python installation on all platforms,
|
||||
this has the disadvantage that any extensions you have installed in your systems Python wont be found by Blender.
|
||||
|
||||
There are 2 ways around this:
|
||||
|
||||
* remove blender python sub-directory, blender will then fallback on the systems python and use that instead **python version must match the one that blender comes with**.
|
||||
- remove Blender Python sub-directory, Blender will then fallback on the systems Python and use that instead
|
||||
.. warning::
|
||||
|
||||
* copy the extensions into blender's python sub-directory so blender can access them, you could also copy the entire python installation into blenders sub-directory, replacing the one blender comes with. This works as long as the python versions match and the paths are created in the same relative locations. Doing this has the advantage that you can redistribute this bundle to others with blender and/or the game player, including any extensions you rely on.
|
||||
The Python version must match the one that Blender comes with.
|
||||
|
||||
- copy the extensions into Blender's Python sub-directory so Blender can access them,
|
||||
you could also copy the entire Python installation into Blenders sub-directory,
|
||||
replacing the one Blender comes with.
|
||||
This works as long as the Python versions match and the paths are created in the same relative locations.
|
||||
Doing this has the advantage that you can redistribute this bundle to others with Blender and/or the game player,
|
||||
including any extensions you rely on.
|
||||
|
||||
|
||||
Drop Into a Python Interpreter in Your Script
|
||||
=============================================
|
||||
|
||||
In the middle of a script you may want to inspect some variables, run some function and generally dig about to see whats going on.
|
||||
In the middle of a script you may want to inspect some variables,
|
||||
run some function and generally dig about to see whats going on.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -217,10 +255,13 @@ The next example is an equivalent single line version of the script above which
|
||||
__import__('code').interact(local=dict(globals(), **locals()))
|
||||
|
||||
|
||||
``code.interact`` can be added at any line in the script and will pause the script an launch an interactive interpreter in the terminal, when you're done you can quit the interpreter and the script will continue execution.
|
||||
``code.interact`` can be added at any line in the script
|
||||
and will pause the script an launch an interactive interpreter in the terminal,
|
||||
when you're done you can quit the interpreter and the script will continue execution.
|
||||
|
||||
|
||||
If you have **IPython** installed you can use their ``embed()`` function which will implicitly use the current namespace, this has autocomplete and some useful features that the standard python eval-loop doesn't have.
|
||||
If you have **IPython** installed you can use its ``embed()`` function which uses the current namespace.
|
||||
The IPython prompt has auto-complete and some useful features that the standard Python eval-loop doesn't have.
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
@@ -228,7 +269,7 @@ If you have **IPython** installed you can use their ``embed()`` function which w
|
||||
IPython.embed()
|
||||
|
||||
|
||||
Admittedly this highlights the lack of any python debugging support built into blender, but its still handy to know.
|
||||
Admittedly this highlights the lack of any Python debugging support built into Blender, but its still handy to know.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -242,27 +283,32 @@ Advanced
|
||||
Blender as a module
|
||||
-------------------
|
||||
|
||||
From a python perspective it's nicer to have everything as an extension which lets the python script combine many components.
|
||||
From a Python perspective it's nicer to have everything as an extension
|
||||
which lets the Python script combine many components.
|
||||
|
||||
Advantages include:
|
||||
|
||||
* you can use external editors/IDE's with blenders python API and execute scripts within the IDE (step over code, inspect variables as the script runs).
|
||||
|
||||
* editors/IDE's can auto complete blender modules & variables.
|
||||
|
||||
* existing scripts can import blender API's without having to run inside blender.
|
||||
- you can use external editors/IDE's with Blenders Python API and execute scripts within the IDE
|
||||
(step over code, inspect variables as the script runs).
|
||||
- editors/IDE's can auto complete Blender modules & variables.
|
||||
- existing scripts can import Blender API's without having to run inside Blender.
|
||||
|
||||
|
||||
This is marked advanced because to run blender as a python module requires a special build option.
|
||||
This is marked advanced because to run Blender as a Python module requires a special build option.
|
||||
|
||||
For instructions on building see `Building blender as a python module <http://wiki.blender.org/index.php/User:Ideasman42/BlenderAsPyModule>`_
|
||||
For instructions on building see
|
||||
`Building Blender as a Python module <http://wiki.blender.org/index.php/User:Ideasman42/BlenderAsPyModule>`_
|
||||
|
||||
|
||||
Python Safety (Build Option)
|
||||
----------------------------
|
||||
|
||||
Since it's possible to access data which has been removed (see Gotcha's), this can be hard to track down the cause of crashes.
|
||||
Since it's possible to access data which has been removed (see Gotcha's),
|
||||
this can be hard to track down the cause of crashes.
|
||||
|
||||
To raise python exceptions on accessing freed data (rather then crashing), enable the CMake build option WITH_PYTHON_SAFETY.
|
||||
To raise Python exceptions on accessing freed data (rather then crashing),
|
||||
enable the CMake build option WITH_PYTHON_SAFETY.
|
||||
|
||||
This enables data tracking which makes data access about 2x slower
|
||||
which is why the option isn't enabled in release builds.
|
||||
|
||||
This enables data tracking which makes data access about 2x slower which is why the option is not enabled in release builds.
|
||||
|
@@ -208,6 +208,7 @@ The objects should move as before.
|
||||
|
||||
*Keep this addon open in Blender for the next step - Installing.*
|
||||
|
||||
|
||||
Install The Addon
|
||||
-----------------
|
||||
|
||||
@@ -221,10 +222,11 @@ restrictions that apply to Python modules and end with a ``.py`` extension.
|
||||
|
||||
Once the file is on disk, you can install it as you would for an addon downloaded online.
|
||||
|
||||
Open the user **File -> User Preferences**, Select the **Addon** section, press **Install Addon...** and select the file.
|
||||
Open the user :menuselection:`File -> User Preferences`,
|
||||
Select the *Addon* section, press *Install Addon...* and select the file.
|
||||
|
||||
Now the addon will be listed and you can enable it by pressing the check-box, if you want it to be enabled on restart,
|
||||
press **Save as Default**.
|
||||
Now the addon will be listed and you can enable it by pressing the check-box,
|
||||
if you want it to be enabled on restart, press *Save as Default*.
|
||||
|
||||
.. note::
|
||||
|
||||
@@ -238,7 +240,7 @@ press **Save as Default**.
|
||||
print(addon_utils.paths())
|
||||
|
||||
More is written on this topic here:
|
||||
`Directory Layout <http://wiki.blender.org/index.php/Doc:2.6/Manual/Introduction/Installing_Blender/DirectoryLayout>`_
|
||||
`Directory Layout <https://www.blender.org/manual/getting_started/installing_blender/directorylayout.html>`_
|
||||
|
||||
|
||||
Your Second Addon
|
||||
|
@@ -234,6 +234,7 @@ else:
|
||||
EXCLUDE_MODULES = [
|
||||
"aud",
|
||||
"bge",
|
||||
"bge.app"
|
||||
"bge.constraints",
|
||||
"bge.events",
|
||||
"bge.logic",
|
||||
@@ -257,6 +258,7 @@ else:
|
||||
"bpy.props",
|
||||
"bpy.types", # supports filtering
|
||||
"bpy.utils",
|
||||
"bpy.utils.previews",
|
||||
"bpy_extras",
|
||||
"gpu",
|
||||
"mathutils",
|
||||
@@ -454,9 +456,11 @@ ClassMethodDescriptorType = type(dict.__dict__['fromkeys'])
|
||||
MethodDescriptorType = type(dict.get)
|
||||
GetSetDescriptorType = type(int.real)
|
||||
StaticMethodType = type(staticmethod(lambda: None))
|
||||
from types import (MemberDescriptorType,
|
||||
MethodType,
|
||||
)
|
||||
from types import (
|
||||
MemberDescriptorType,
|
||||
MethodType,
|
||||
FunctionType,
|
||||
)
|
||||
|
||||
_BPY_STRUCT_FAKE = "bpy_struct"
|
||||
_BPY_PROP_COLLECTION_FAKE = "bpy_prop_collection"
|
||||
@@ -633,19 +637,26 @@ def pyfunc2sphinx(ident, fw, module_name, type_name, identifier, py_func, is_cla
|
||||
func_type = "function"
|
||||
|
||||
# ther rest are class methods
|
||||
elif arg_str.startswith("(self, "):
|
||||
arg_str = "(" + arg_str[7:]
|
||||
elif arg_str.startswith("(self, ") or arg_str == "(self)":
|
||||
arg_str = "()" if (arg_str == "(self)") else ("(" + arg_str[7:])
|
||||
func_type = "method"
|
||||
elif arg_str.startswith("(cls, "):
|
||||
arg_str = "(" + arg_str[6:]
|
||||
arg_str = "()" if (arg_str == "(cls)") else ("(" + arg_str[6:])
|
||||
func_type = "classmethod"
|
||||
else:
|
||||
func_type = "staticmethod"
|
||||
|
||||
fw(ident + ".. %s:: %s%s\n\n" % (func_type, identifier, arg_str))
|
||||
if py_func.__doc__:
|
||||
write_indented_lines(ident + " ", fw, py_func.__doc__)
|
||||
doc = py_func.__doc__
|
||||
if (not doc) or (not doc.startswith(".. %s:: " % func_type)):
|
||||
fw(ident + ".. %s:: %s%s\n\n" % (func_type, identifier, arg_str))
|
||||
ident_temp = ident + " "
|
||||
else:
|
||||
ident_temp = ident
|
||||
|
||||
if doc:
|
||||
write_indented_lines(ident_temp, fw, doc)
|
||||
fw("\n")
|
||||
del doc, ident_temp
|
||||
|
||||
if is_class:
|
||||
write_example_ref(ident + " ", fw, module_name + "." + type_name + "." + identifier)
|
||||
@@ -861,7 +872,7 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
||||
module_dir_value_type.sort(key=lambda triple: str(triple[2]))
|
||||
|
||||
for attribute, value, value_type in module_dir_value_type:
|
||||
if value_type == types.FunctionType:
|
||||
if value_type == FunctionType:
|
||||
pyfunc2sphinx("", fw, module_name, None, attribute, value, is_class=False)
|
||||
elif value_type in {types.BuiltinMethodType, types.BuiltinFunctionType}: # both the same at the moment but to be future proof
|
||||
# note: can't get args from these, so dump the string as is
|
||||
@@ -916,19 +927,24 @@ def pymodule2sphinx(basepath, module_name, module, title):
|
||||
fw(value.__doc__)
|
||||
else:
|
||||
fw(".. class:: %s\n\n" % type_name)
|
||||
write_indented_lines(" ", fw, value.__doc__, False)
|
||||
write_indented_lines(" ", fw, value.__doc__, True)
|
||||
else:
|
||||
fw(".. class:: %s\n\n" % type_name)
|
||||
fw("\n")
|
||||
|
||||
write_example_ref(" ", fw, module_name + "." + type_name)
|
||||
|
||||
descr_items = [(key, descr) for key, descr in sorted(value.__dict__.items()) if not key.startswith("__")]
|
||||
descr_items = [(key, descr) for key, descr in sorted(value.__dict__.items()) if not key.startswith("_")]
|
||||
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == ClassMethodDescriptorType:
|
||||
py_descr2sphinx(" ", fw, descr, module_name, type_name, key)
|
||||
|
||||
# needed for pure python classes
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == FunctionType:
|
||||
pyfunc2sphinx(" ", fw, module_name, type_name, key, descr, is_class=True)
|
||||
|
||||
for key, descr in descr_items:
|
||||
if type(descr) == MethodDescriptorType:
|
||||
py_descr2sphinx(" ", fw, descr, module_name, type_name, key)
|
||||
@@ -1239,6 +1255,7 @@ def pyrna2sphinx(basepath):
|
||||
fw("\n\n")
|
||||
|
||||
subclass_ids = [s.identifier for s in structs.values() if s.base is struct if not rna_info.rna_id_ignore(s.identifier)]
|
||||
subclass_ids.sort()
|
||||
if subclass_ids:
|
||||
fw("subclasses --- \n" + ", ".join((":class:`%s`" % s) for s in subclass_ids) + "\n\n")
|
||||
|
||||
@@ -1607,6 +1624,7 @@ def write_rst_contents(basepath):
|
||||
|
||||
# py modules
|
||||
"bpy.utils",
|
||||
"bpy.utils.previews",
|
||||
"bpy.path",
|
||||
"bpy.app",
|
||||
"bpy.app.handlers",
|
||||
@@ -1652,6 +1670,7 @@ def write_rst_contents(basepath):
|
||||
fw(" bge.texture.rst\n\n")
|
||||
fw(" bge.events.rst\n\n")
|
||||
fw(" bge.constraints.rst\n\n")
|
||||
fw(" bge.app.rst\n\n")
|
||||
|
||||
# rna generated change log
|
||||
fw(title_string("API Info", "=", double=True))
|
||||
@@ -1808,6 +1827,7 @@ def copy_handwritten_rsts(basepath):
|
||||
"bge.texture",
|
||||
"bge.events",
|
||||
"bge.constraints",
|
||||
"bge.app",
|
||||
"bgl", # "Blender OpenGl wrapper"
|
||||
"gpu", # "GPU Shader Module"
|
||||
|
||||
|
1
extern/bullet2/src/Bullet-C-Api.h
vendored
1
extern/bullet2/src/Bullet-C-Api.h
vendored
@@ -171,6 +171,7 @@ extern "C" {
|
||||
/* Convex Hull */
|
||||
PL_DECLARE_HANDLE(plConvexHull);
|
||||
plConvexHull plConvexHullCompute(float (*coords)[3], int count);
|
||||
void plConvexHullDelete(plConvexHull hull);
|
||||
int plConvexHullNumVertices(plConvexHull hull);
|
||||
int plConvexHullNumFaces(plConvexHull hull);
|
||||
void plConvexHullGetVertex(plConvexHull hull, int n, float coords[3], int *original_index);
|
||||
|
@@ -15,7 +15,7 @@ subject to the following restrictions:
|
||||
|
||||
|
||||
/**
|
||||
* @mainpage Bullet Documentation
|
||||
* @page Bullet Documentation
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
* Bullet is a Collision Detection and Rigid Body Dynamics Library. The Library is Open Source and free for commercial use, under the ZLib license ( http://opensource.org/licenses/zlib-license.php ).
|
||||
|
@@ -413,6 +413,12 @@ plConvexHull plConvexHullCompute(float (*coords)[3], int count)
|
||||
return reinterpret_cast<plConvexHull>(computer);
|
||||
}
|
||||
|
||||
void plConvexHullDelete(plConvexHull hull)
|
||||
{
|
||||
btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
|
||||
delete computer;
|
||||
}
|
||||
|
||||
int plConvexHullNumVertices(plConvexHull hull)
|
||||
{
|
||||
btConvexHullComputer *computer(reinterpret_cast< btConvexHullComputer* >(hull));
|
||||
|
24
extern/clew/include/clew.h
vendored
24
extern/clew/include/clew.h
vendored
@@ -2751,6 +2751,30 @@ CLEW_FUN_EXPORT PFNCLGETGLCONTEXTINFOKHR __clewGetGLContextInfoKH
|
||||
#endif
|
||||
#define clGetGLContextInfoKHR CLEW_GET_FUN(__clewGetGLContextInfoKHR )
|
||||
|
||||
/* cl_ext */
|
||||
|
||||
/******************************************
|
||||
* cl_nv_device_attribute_query extension *
|
||||
******************************************/
|
||||
/* cl_nv_device_attribute_query extension - no extension #define since it has no functions */
|
||||
#define CL_DEVICE_COMPUTE_CAPABILITY_MAJOR_NV 0x4000
|
||||
#define CL_DEVICE_COMPUTE_CAPABILITY_MINOR_NV 0x4001
|
||||
#define CL_DEVICE_REGISTERS_PER_BLOCK_NV 0x4002
|
||||
#define CL_DEVICE_WARP_SIZE_NV 0x4003
|
||||
#define CL_DEVICE_GPU_OVERLAP_NV 0x4004
|
||||
#define CL_DEVICE_KERNEL_EXEC_TIMEOUT_NV 0x4005
|
||||
#define CL_DEVICE_INTEGRATED_MEMORY_NV 0x4006
|
||||
|
||||
/*********************************
|
||||
* cl_amd_device_attribute_query *
|
||||
*********************************/
|
||||
#define CL_DEVICE_PROFILING_TIMER_OFFSET_AMD 0x4036
|
||||
|
||||
/*********************************
|
||||
* cl_arm_printf extension
|
||||
*********************************/
|
||||
#define CL_PRINTF_CALLBACK_ARM 0x40B0
|
||||
#define CL_PRINTF_BUFFERSIZE_ARM 0x40B1
|
||||
|
||||
#define CLEW_SUCCESS 0 //!< Success error code
|
||||
#define CLEW_ERROR_OPEN_FAILED -1 //!< Error code for failing to open the dynamic library
|
||||
|
7
extern/gtest/CMakeLists.txt
vendored
7
extern/gtest/CMakeLists.txt
vendored
@@ -21,6 +21,13 @@
|
||||
#
|
||||
# ***** END GPL LICENSE BLOCK *****
|
||||
|
||||
# avoid noisy warnings
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
remove_cc_flag(
|
||||
"-Wmissing-declarations"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(INC
|
||||
.
|
||||
include
|
||||
|
@@ -77,6 +77,27 @@
|
||||
# define LG_SIZEOF_INT 2
|
||||
#endif
|
||||
|
||||
/************************/
|
||||
/* Function prototypes. */
|
||||
|
||||
#if (LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3)
|
||||
ATOMIC_INLINE uint64_t atomic_add_uint64(uint64_t *p, uint64_t x);
|
||||
ATOMIC_INLINE uint64_t atomic_sub_uint64(uint64_t *p, uint64_t x);
|
||||
ATOMIC_INLINE uint64_t atomic_cas_uint64(uint64_t *v, uint64_t old, uint64_t _new);
|
||||
#endif
|
||||
|
||||
ATOMIC_INLINE uint32_t atomic_add_uint32(uint32_t *p, uint32_t x);
|
||||
ATOMIC_INLINE uint32_t atomic_sub_uint32(uint32_t *p, uint32_t x);
|
||||
ATOMIC_INLINE uint32_t atomic_cas_uint32(uint32_t *v, uint32_t old, uint32_t _new);
|
||||
|
||||
ATOMIC_INLINE size_t atomic_add_z(size_t *p, size_t x);
|
||||
ATOMIC_INLINE size_t atomic_sub_z(size_t *p, size_t x);
|
||||
ATOMIC_INLINE size_t atomic_cas_z(size_t *v, size_t old, size_t _new);
|
||||
|
||||
ATOMIC_INLINE unsigned atomic_add_u(unsigned *p, unsigned x);
|
||||
ATOMIC_INLINE unsigned atomic_sub_u(unsigned *p, unsigned x);
|
||||
ATOMIC_INLINE unsigned atomic_cas_u(unsigned *v, unsigned old, unsigned _new);
|
||||
|
||||
/******************************************************************************/
|
||||
/* 64-bit operations. */
|
||||
#if (LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3)
|
||||
|
@@ -33,16 +33,7 @@
|
||||
#include "AUD_Space.h"
|
||||
|
||||
#include <cstring>
|
||||
#ifdef _MSC_VER
|
||||
#if (_MSC_VER <= 1500)
|
||||
typedef short int16_t;
|
||||
typedef int int32_t;
|
||||
#else
|
||||
# include <stdint.h>
|
||||
#endif
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
typedef void (*AUD_convert_f)(data_t* target, data_t* source, int length);
|
||||
|
||||
|
@@ -34,12 +34,8 @@ cycles.Depends('../../source/blender/makesrna/intern/RNA_blender_cpp.h', 'makesr
|
||||
|
||||
sources = cycles.Glob('bvh/*.cpp') + cycles.Glob('device/*.cpp') + cycles.Glob('kernel/*.cpp') + cycles.Glob('render/*.cpp') + cycles.Glob('subd/*.cpp') + cycles.Glob('util/*.cpp') + cycles.Glob('blender/*.cpp')
|
||||
|
||||
sources.append(path.join('kernel', 'kernels', 'cpu', 'kernel.cpp'))
|
||||
sources.remove(path.join('util', 'util_view.cpp'))
|
||||
sources.remove(path.join('kernel', 'kernel_sse2.cpp'))
|
||||
sources.remove(path.join('kernel', 'kernel_sse3.cpp'))
|
||||
sources.remove(path.join('kernel', 'kernel_sse41.cpp'))
|
||||
sources.remove(path.join('kernel', 'kernel_avx.cpp'))
|
||||
sources.remove(path.join('kernel', 'kernel_avx2.cpp'))
|
||||
|
||||
incs = []
|
||||
defs = []
|
||||
@@ -146,7 +142,7 @@ for kernel_type in kernel_flags.keys():
|
||||
defs.append('WITH_KERNEL_' + kernel_type.upper())
|
||||
|
||||
for kernel_type in kernel_flags.keys():
|
||||
kernel_source = path.join('kernel', 'kernel_' + kernel_type + '.cpp')
|
||||
kernel_source = path.join('kernel', 'kernels', 'cpu', 'kernel_' + kernel_type + '.cpp')
|
||||
kernel_cxxflags = Split(env['CXXFLAGS'])
|
||||
kernel_cxxflags.append(kernel_flags[kernel_type].split())
|
||||
kernel_defs = defs[:]
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "device.h"
|
||||
#include "scene.h"
|
||||
#include "session.h"
|
||||
#include "integrator.h"
|
||||
|
||||
#include "util_args.h"
|
||||
#include "util_foreach.h"
|
||||
@@ -272,6 +273,7 @@ static void keyboard(unsigned char key)
|
||||
else if(key == 'i')
|
||||
options.interactive = !(options.interactive);
|
||||
|
||||
/* Navigation */
|
||||
else if(options.interactive && (key == 'w' || key == 'a' || key == 's' || key == 'd')) {
|
||||
Transform matrix = options.session->scene->camera->matrix;
|
||||
float3 translate;
|
||||
@@ -294,6 +296,25 @@ static void keyboard(unsigned char key)
|
||||
|
||||
options.session->reset(session_buffer_params(), options.session_params.samples);
|
||||
}
|
||||
|
||||
/* Set Max Bounces */
|
||||
else if(options.interactive && (key == '0' || key == '1' || key == '2' || key == '3')) {
|
||||
int bounce;
|
||||
switch(key) {
|
||||
case '0': bounce = 0; break;
|
||||
case '1': bounce = 1; break;
|
||||
case '2': bounce = 2; break;
|
||||
case '3': bounce = 3; break;
|
||||
default: bounce = 0; break;
|
||||
}
|
||||
|
||||
options.session->scene->integrator->max_bounce = bounce;
|
||||
|
||||
/* Update and Reset */
|
||||
options.session->scene->integrator->need_update = true;
|
||||
|
||||
options.session->reset(session_buffer_params(), options.session_params.samples);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -377,7 +398,8 @@ static void options_parse(int argc, const char **argv)
|
||||
printf("Devices:\n");
|
||||
|
||||
foreach(DeviceInfo& info, devices) {
|
||||
printf(" %s%s\n",
|
||||
printf(" %-10s%s%s\n",
|
||||
Device::string_from_type(info.type).c_str(),
|
||||
info.description.c_str(),
|
||||
(info.display_device)? " (display)": "");
|
||||
}
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
|
||||
#include "background.h"
|
||||
#include "camera.h"
|
||||
#include "film.h"
|
||||
#include "graph.h"
|
||||
@@ -391,6 +392,10 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
for(pugi::xml_node node = graph_node.first_child(); node; node = node.next_sibling()) {
|
||||
ShaderNode *snode = NULL;
|
||||
|
||||
/* ToDo: Add missing nodes
|
||||
* RGBCurvesNode, VectorCurvesNode, RGBRampNode and ConvertNode (RGB -> BW).
|
||||
*/
|
||||
|
||||
if(string_iequals(node.name(), "image_texture")) {
|
||||
ImageTextureNode *img = new ImageTextureNode();
|
||||
|
||||
@@ -401,6 +406,8 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
xml_read_enum(&img->projection, ImageTextureNode::projection_enum, node, "projection");
|
||||
xml_read_float(&img->projection_blend, node, "projection_blend");
|
||||
|
||||
/* ToDo: Interpolation */
|
||||
|
||||
snode = img;
|
||||
}
|
||||
else if(string_iequals(node.name(), "environment_texture")) {
|
||||
@@ -513,6 +520,11 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
xml_read_float3(&normal->direction, node, "direction");
|
||||
snode = normal;
|
||||
}
|
||||
else if(string_iequals(node.name(), "bump")) {
|
||||
BumpNode *bump = new BumpNode();
|
||||
xml_read_bool(&bump->invert, node, "invert");
|
||||
snode = bump;
|
||||
}
|
||||
else if(string_iequals(node.name(), "mapping")) {
|
||||
snode = new MappingNode();
|
||||
}
|
||||
@@ -567,6 +579,9 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
else if(string_iequals(node.name(), "background")) {
|
||||
snode = new BackgroundNode();
|
||||
}
|
||||
else if(string_iequals(node.name(), "holdout")) {
|
||||
snode = new HoldoutNode();
|
||||
}
|
||||
else if(string_iequals(node.name(), "absorption_volume")) {
|
||||
snode = new AbsorptionVolumeNode();
|
||||
}
|
||||
@@ -575,7 +590,14 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
}
|
||||
else if(string_iequals(node.name(), "subsurface_scattering")) {
|
||||
SubsurfaceScatteringNode *sss = new SubsurfaceScatteringNode();
|
||||
//xml_read_enum(&sss->falloff, SubsurfaceScatteringNode::falloff_enum, node, "falloff");
|
||||
|
||||
string falloff;
|
||||
xml_read_string(&falloff, node, "falloff");
|
||||
if(falloff == "cubic")
|
||||
sss->closure = CLOSURE_BSSRDF_CUBIC_ID;
|
||||
else
|
||||
sss->closure = CLOSURE_BSSRDF_GAUSSIAN_ID;
|
||||
|
||||
snode = sss;
|
||||
}
|
||||
else if(string_iequals(node.name(), "geometry")) {
|
||||
@@ -619,6 +641,7 @@ static void xml_read_shader_graph(const XMLReadState& state, Shader *shader, pug
|
||||
snode = new InvertNode();
|
||||
}
|
||||
else if(string_iequals(node.name(), "mix")) {
|
||||
/* ToDo: Tag Mix case for optimization */
|
||||
MixNode *mix = new MixNode();
|
||||
xml_read_enum(&mix->type, MixNode::type_enum, node, "type");
|
||||
xml_read_bool(&mix->use_clamp, node, "use_clamp");
|
||||
@@ -828,6 +851,15 @@ static void xml_read_shader(const XMLReadState& state, pugi::xml_node node)
|
||||
|
||||
static void xml_read_background(const XMLReadState& state, pugi::xml_node node)
|
||||
{
|
||||
/* Background Settings */
|
||||
Background *bg = state.scene->background;
|
||||
|
||||
xml_read_float(&bg->ao_distance, node, "ao_distance");
|
||||
xml_read_float(&bg->ao_factor, node, "ao_factor");
|
||||
|
||||
xml_read_bool(&bg->transparent, node, "transparent");
|
||||
|
||||
/* Background Shader */
|
||||
Shader *shader = state.scene->shaders[state.scene->default_background];
|
||||
|
||||
xml_read_bool(&shader->heterogeneous_volume, node, "heterogeneous_volume");
|
||||
@@ -874,6 +906,7 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
|
||||
|
||||
/* read vertices and polygons, RIB style */
|
||||
vector<float3> P;
|
||||
vector<float> UV;
|
||||
vector<int> verts, nverts;
|
||||
|
||||
xml_read_float3_array(P, node, "P");
|
||||
@@ -945,6 +978,31 @@ static void xml_read_mesh(const XMLReadState& state, pugi::xml_node node)
|
||||
|
||||
index_offset += nverts[i];
|
||||
}
|
||||
|
||||
if(xml_read_float_array(UV, node, "UV")) {
|
||||
ustring name = ustring("UVMap");
|
||||
Attribute *attr = mesh->attributes.add(ATTR_STD_UV, name);
|
||||
float3 *fdata = attr->data_float3();
|
||||
|
||||
/* loop over the triangles */
|
||||
index_offset = 0;
|
||||
for(size_t i = 0; i < nverts.size(); i++) {
|
||||
for(int j = 0; j < nverts[i]-2; j++) {
|
||||
int v0 = verts[index_offset];
|
||||
int v1 = verts[index_offset + j + 1];
|
||||
int v2 = verts[index_offset + j + 2];
|
||||
|
||||
assert(v0*2+1 < (int)UV.size());
|
||||
assert(v1*2+1 < (int)UV.size());
|
||||
assert(v2*2+1 < (int)UV.size());
|
||||
|
||||
fdata[0] = make_float3(UV[v0*2], UV[v0*2+1], 0.0);
|
||||
fdata[1] = make_float3(UV[v1*2], UV[v1*2+1], 0.0);
|
||||
fdata[2] = make_float3(UV[v2*2], UV[v2*2+1], 0.0);
|
||||
fdata += 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* temporary for test compatibility */
|
||||
@@ -1034,13 +1092,28 @@ static void xml_read_light(const XMLReadState& state, pugi::xml_node node)
|
||||
xml_read_float(&light->sizev, node, "sizev");
|
||||
xml_read_float3(&light->axisu, node, "axisu");
|
||||
xml_read_float3(&light->axisv, node, "axisv");
|
||||
|
||||
|
||||
/* Portal? (Area light only) */
|
||||
xml_read_bool(&light->is_portal, node, "is_portal");
|
||||
|
||||
/* Generic */
|
||||
xml_read_float(&light->size, node, "size");
|
||||
xml_read_float3(&light->dir, node, "dir");
|
||||
xml_read_float3(&light->co, node, "P");
|
||||
light->co = transform_point(&state.tfm, light->co);
|
||||
|
||||
/* Settings */
|
||||
xml_read_bool(&light->cast_shadow, node, "cast_shadow");
|
||||
xml_read_bool(&light->use_mis, node, "use_mis");
|
||||
xml_read_int(&light->samples, node, "samples");
|
||||
xml_read_int(&light->max_bounces, node, "max_bounces");
|
||||
|
||||
/* Ray Visibility */
|
||||
xml_read_bool(&light->use_diffuse, node, "use_diffuse");
|
||||
xml_read_bool(&light->use_glossy, node, "use_glossy");
|
||||
xml_read_bool(&light->use_transmission, node, "use_transmission");
|
||||
xml_read_bool(&light->use_scatter, node, "use_scatter");
|
||||
|
||||
state.scene->lights.push_back(light);
|
||||
}
|
||||
|
||||
@@ -1184,7 +1257,8 @@ static void xml_read_include(const XMLReadState& state, const string& src)
|
||||
XMLReadState substate = state;
|
||||
substate.base = path_dirname(path);
|
||||
|
||||
xml_read_scene(substate, doc);
|
||||
pugi::xml_node cycles = doc.child("cycles");
|
||||
xml_read_scene(substate, cycles);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "%s read error: %s\n", src.c_str(), parse_result.description());
|
||||
|
@@ -30,8 +30,10 @@ bl_info = {
|
||||
|
||||
import bpy
|
||||
|
||||
from . import engine
|
||||
from . import version_update
|
||||
from . import (
|
||||
engine,
|
||||
version_update,
|
||||
)
|
||||
|
||||
|
||||
class CyclesRender(bpy.types.RenderEngine):
|
||||
|
@@ -394,6 +394,12 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
|
||||
default=0,
|
||||
)
|
||||
|
||||
cls.use_animated_seed = BoolProperty(
|
||||
name="Use Animated Seed",
|
||||
description="Use different seed values (and hence noise patterns) at different frames",
|
||||
default=False,
|
||||
)
|
||||
|
||||
cls.sample_clamp_direct = FloatProperty(
|
||||
name="Clamp Direct",
|
||||
description="If non-zero, the maximum value for a direct sample, "
|
||||
|
@@ -18,7 +18,11 @@
|
||||
|
||||
import bpy
|
||||
|
||||
from bpy.types import Panel, Menu, Operator, UIList
|
||||
from bpy.types import (
|
||||
Panel,
|
||||
Menu,
|
||||
Operator,
|
||||
)
|
||||
|
||||
|
||||
class CYCLES_MT_sampling_presets(Menu):
|
||||
@@ -55,6 +59,7 @@ def use_cpu(context):
|
||||
|
||||
return (device_type == 'NONE' or cscene.device == 'CPU')
|
||||
|
||||
|
||||
def use_branched_path(context):
|
||||
cscene = context.scene.cycles
|
||||
device_type = context.user_preferences.system.compute_device_type
|
||||
@@ -135,7 +140,11 @@ class CyclesRender_PT_sampling(CyclesButtonsPanel, Panel):
|
||||
col = split.column()
|
||||
sub = col.column(align=True)
|
||||
sub.label("Settings:")
|
||||
sub.prop(cscene, "seed")
|
||||
|
||||
seed_sub = sub.row(align=True)
|
||||
seed_sub.prop(cscene, "seed")
|
||||
seed_sub.prop(cscene, "use_animated_seed", text="", icon="TIME")
|
||||
|
||||
sub.prop(cscene, "sample_clamp_direct")
|
||||
sub.prop(cscene, "sample_clamp_indirect")
|
||||
|
||||
@@ -422,6 +431,9 @@ class CyclesRender_PT_layer_passes(CyclesButtonsPanel, Panel):
|
||||
col.prop(rl, "use_pass_emit", text="Emission")
|
||||
col.prop(rl, "use_pass_environment")
|
||||
|
||||
if hasattr(rd, "debug_pass_type"):
|
||||
layout.prop(rd, "debug_pass_type")
|
||||
|
||||
|
||||
class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
|
||||
bl_label = "Views"
|
||||
@@ -438,7 +450,6 @@ class CyclesRender_PT_views(CyclesButtonsPanel, Panel):
|
||||
rd = scene.render
|
||||
rv = rd.views.active
|
||||
|
||||
|
||||
layout.active = rd.use_multiview
|
||||
basic_stereo = (rd.views_format == 'STEREO_3D')
|
||||
|
||||
@@ -514,12 +525,12 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
|
||||
sub = col.column(align=True)
|
||||
sub.label("Viewport:")
|
||||
subhq = sub.column()
|
||||
subhq.active = hq_support;
|
||||
subhq.active = hq_support
|
||||
subhq.prop(dof_options, "use_high_quality")
|
||||
sub.prop(dof_options, "fstop")
|
||||
if dof_options.use_high_quality and hq_support:
|
||||
sub.prop(dof_options, "blades")
|
||||
|
||||
|
||||
col = split.column()
|
||||
|
||||
col.label("Aperture:")
|
||||
@@ -552,11 +563,16 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
|
||||
ob = context.object
|
||||
slot = context.material_slot
|
||||
space = context.space_data
|
||||
is_sortable = len(ob.material_slots) > 1
|
||||
|
||||
if ob:
|
||||
rows = 1
|
||||
if (is_sortable):
|
||||
rows = 4
|
||||
|
||||
row = layout.row()
|
||||
|
||||
row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=1)
|
||||
row.template_list("MATERIAL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
|
||||
|
||||
col = row.column(align=True)
|
||||
col.operator("object.material_slot_add", icon='ZOOMIN', text="")
|
||||
@@ -564,6 +580,12 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
|
||||
|
||||
col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="")
|
||||
|
||||
if is_sortable:
|
||||
col.separator()
|
||||
|
||||
col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
|
||||
col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
|
||||
|
||||
if ob.mode == 'EDIT':
|
||||
row = layout.row(align=True)
|
||||
row.operator("object.material_slot_assign", text="Assign")
|
||||
@@ -625,7 +647,13 @@ class CyclesObject_PT_motion_blur(CyclesButtonsPanel, Panel):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
ob = context.object
|
||||
return CyclesButtonsPanel.poll(context) and ob and ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}
|
||||
if CyclesButtonsPanel.poll(context) and ob:
|
||||
if ob.type in {'MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META'}:
|
||||
return True
|
||||
if ob.dupli_type == 'GROUP' and ob.dupli_group:
|
||||
return True
|
||||
# TODO(sergey): More duplicator types here?
|
||||
return False
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
@@ -668,8 +696,8 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
|
||||
def poll(cls, context):
|
||||
ob = context.object
|
||||
return (CyclesButtonsPanel.poll(context) and
|
||||
ob and ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'} or
|
||||
ob and ob.dupli_type == 'GROUP' and ob.dupli_group)
|
||||
ob and ((ob.type in {'MESH', 'CURVE', 'SURFACE', 'FONT', 'META', 'LAMP'}) or
|
||||
(ob.dupli_type == 'GROUP' and ob.dupli_group)))
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -714,9 +742,14 @@ def find_node(material, nodetype):
|
||||
if material and material.node_tree:
|
||||
ntree = material.node_tree
|
||||
|
||||
active_output_node = None
|
||||
for node in ntree.nodes:
|
||||
if getattr(node, "type", None) == nodetype:
|
||||
return node
|
||||
if getattr(node, "is_active_output", True):
|
||||
return node
|
||||
if not active_output_node:
|
||||
active_output_node = node
|
||||
return active_output_node
|
||||
|
||||
return None
|
||||
|
||||
|
@@ -207,19 +207,34 @@ static void blender_camera_from_object(BlenderCamera *bcam, BL::RenderEngine b_e
|
||||
}
|
||||
}
|
||||
|
||||
static Transform blender_camera_matrix(const Transform& tfm, CameraType type)
|
||||
static Transform blender_camera_matrix(const Transform& tfm,
|
||||
const CameraType type,
|
||||
const PanoramaType panorama_type)
|
||||
{
|
||||
Transform result;
|
||||
|
||||
if(type == CAMERA_PANORAMA) {
|
||||
/* make it so environment camera needs to be pointed in the direction
|
||||
* of the positive x-axis to match an environment texture, this way
|
||||
* it is looking at the center of the texture */
|
||||
result = tfm *
|
||||
make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
-1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
if(panorama_type == PANORAMA_MIRRORBALL) {
|
||||
/* Mirror ball camera is looking into the negative Y direction
|
||||
* which matches texture mirror ball mapping.
|
||||
*/
|
||||
result = tfm *
|
||||
make_transform(1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
0.0f, 1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
else {
|
||||
/* Make it so environment camera needs to be pointed in the direction
|
||||
* of the positive x-axis to match an environment texture, this way
|
||||
* it is looking at the center of the texture
|
||||
*/
|
||||
result = tfm *
|
||||
make_transform( 0.0f, -1.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 1.0f, 0.0f,
|
||||
-1.0f, 0.0f, 0.0f, 0.0f,
|
||||
0.0f, 0.0f, 0.0f, 1.0f);
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* note the blender camera points along the negative z-axis */
|
||||
@@ -365,7 +380,9 @@ static void blender_camera_sync(Camera *cam, BlenderCamera *bcam, int width, int
|
||||
cam->bladesrotation = bcam->aperturerotation;
|
||||
|
||||
/* transform */
|
||||
cam->matrix = blender_camera_matrix(bcam->matrix, bcam->type);
|
||||
cam->matrix = blender_camera_matrix(bcam->matrix,
|
||||
bcam->type,
|
||||
bcam->panorama_type);
|
||||
cam->motion.pre = cam->matrix;
|
||||
cam->motion.post = cam->matrix;
|
||||
cam->use_motion = false;
|
||||
@@ -424,7 +441,7 @@ void BlenderSync::sync_camera_motion(BL::Object b_ob, float motion_time)
|
||||
BL::Array<float, 16> b_ob_matrix;
|
||||
b_engine.camera_model_matrix(b_ob, b_ob_matrix);
|
||||
Transform tfm = get_transform(b_ob_matrix);
|
||||
tfm = blender_camera_matrix(tfm, cam->type);
|
||||
tfm = blender_camera_matrix(tfm, cam->type, cam->panorama_type);
|
||||
|
||||
if(tfm != cam->matrix) {
|
||||
VLOG(1) << "Camera " << b_ob.name() << " motion detected.";
|
||||
|
@@ -261,7 +261,9 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
|
||||
if(motion) {
|
||||
object = object_map.find(key);
|
||||
|
||||
if(object && (scene->need_motion() == Scene::MOTION_PASS || object_use_motion(b_ob))) {
|
||||
if(object && (scene->need_motion() == Scene::MOTION_PASS ||
|
||||
object_use_motion(b_parent, b_ob)))
|
||||
{
|
||||
/* object transformation */
|
||||
if(tfm != object->tfm) {
|
||||
VLOG(1) << "Object " << b_ob.name() << " motion detected.";
|
||||
@@ -342,8 +344,8 @@ Object *BlenderSync::sync_object(BL::Object b_parent, int persistent_id[OBJECT_P
|
||||
|
||||
mesh->use_motion_blur = false;
|
||||
|
||||
if(object_use_motion(b_ob)) {
|
||||
if(object_use_deform_motion(b_ob)) {
|
||||
if(object_use_motion(b_parent, b_ob)) {
|
||||
if(object_use_deform_motion(b_parent, b_ob)) {
|
||||
mesh->motion_steps = object_motion_steps(b_ob);
|
||||
mesh->use_motion_blur = true;
|
||||
}
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "util_color.h"
|
||||
#include "util_foreach.h"
|
||||
#include "util_function.h"
|
||||
#include "util_logging.h"
|
||||
#include "util_progress.h"
|
||||
#include "util_time.h"
|
||||
|
||||
@@ -271,6 +272,10 @@ static PassType get_pass_type(BL::RenderPass b_pass)
|
||||
{
|
||||
if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSAL_STEPS)
|
||||
return PASS_BVH_TRAVERSAL_STEPS;
|
||||
if(b_pass.debug_type() == BL::RenderPass::debug_type_BVH_TRAVERSED_INSTANCES)
|
||||
return PASS_BVH_TRAVERSED_INSTANCES;
|
||||
if(b_pass.debug_type() == BL::RenderPass::debug_type_RAY_BOUNCES)
|
||||
return PASS_RAY_BOUNCES;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
@@ -439,6 +444,7 @@ void BlenderSession::render()
|
||||
Pass::add(PASS_COMBINED, passes);
|
||||
#ifdef WITH_CYCLES_DEBUG
|
||||
Pass::add(PASS_BVH_TRAVERSAL_STEPS, passes);
|
||||
/* Pass::add(PASS_RAY_BOUNCES, passes); */
|
||||
#endif
|
||||
|
||||
if(session_params.device.advanced_shading) {
|
||||
@@ -497,6 +503,11 @@ void BlenderSession::render()
|
||||
break;
|
||||
}
|
||||
|
||||
double total_time, render_time;
|
||||
session->progress.get_time(total_time, render_time);
|
||||
VLOG(1) << "Total render time: " << total_time;
|
||||
VLOG(1) << "Render time (without synchronization): " << render_time;
|
||||
|
||||
/* clear callback */
|
||||
session->write_render_tile_cb = function_null;
|
||||
session->update_render_tile_cb = function_null;
|
||||
@@ -1020,18 +1031,19 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name, void *buil
|
||||
|
||||
unsigned char *image_pixels;
|
||||
image_pixels = image_get_pixels_for_frame(b_image, frame);
|
||||
size_t num_pixels = ((size_t)width) * height;
|
||||
|
||||
if(image_pixels) {
|
||||
memcpy(pixels, image_pixels, width * height * channels * sizeof(unsigned char));
|
||||
memcpy(pixels, image_pixels, num_pixels * channels * sizeof(unsigned char));
|
||||
MEM_freeN(image_pixels);
|
||||
}
|
||||
else {
|
||||
if(channels == 1) {
|
||||
memset(pixels, 0, width * height * sizeof(unsigned char));
|
||||
memset(pixels, 0, num_pixels * sizeof(unsigned char));
|
||||
}
|
||||
else {
|
||||
unsigned char *cp = pixels;
|
||||
for(int i = 0; i < width * height; i++, cp += channels) {
|
||||
for(size_t i = 0; i < num_pixels; i++, cp += channels) {
|
||||
cp[0] = 255;
|
||||
cp[1] = 0;
|
||||
cp[2] = 255;
|
||||
@@ -1043,7 +1055,7 @@ bool BlenderSession::builtin_image_pixels(const string &builtin_name, void *buil
|
||||
|
||||
/* premultiply, byte images are always straight for blender */
|
||||
unsigned char *cp = pixels;
|
||||
for(int i = 0; i < width * height; i++, cp += channels) {
|
||||
for(size_t i = 0; i < num_pixels; i++, cp += channels) {
|
||||
cp[0] = (cp[0] * cp[3]) >> 8;
|
||||
cp[1] = (cp[1] * cp[3]) >> 8;
|
||||
cp[2] = (cp[2] * cp[3]) >> 8;
|
||||
@@ -1072,18 +1084,19 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
|
||||
|
||||
float *image_pixels;
|
||||
image_pixels = image_get_float_pixels_for_frame(b_image, frame);
|
||||
size_t num_pixels = ((size_t)width) * height;
|
||||
|
||||
if(image_pixels) {
|
||||
memcpy(pixels, image_pixels, width * height * channels * sizeof(float));
|
||||
memcpy(pixels, image_pixels, num_pixels * channels * sizeof(float));
|
||||
MEM_freeN(image_pixels);
|
||||
}
|
||||
else {
|
||||
if(channels == 1) {
|
||||
memset(pixels, 0, width * height * sizeof(float));
|
||||
memset(pixels, 0, num_pixels * sizeof(float));
|
||||
}
|
||||
else {
|
||||
float *fp = pixels;
|
||||
for(int i = 0; i < width * height; i++, fp += channels) {
|
||||
for(int i = 0; i < num_pixels; i++, fp += channels) {
|
||||
fp[0] = 1.0f;
|
||||
fp[1] = 0.0f;
|
||||
fp[2] = 1.0f;
|
||||
@@ -1109,11 +1122,12 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
|
||||
int width = resolution.x * amplify;
|
||||
int height = resolution.y * amplify;
|
||||
int depth = resolution.z * amplify;
|
||||
size_t num_pixels = ((size_t)width) * height * depth;
|
||||
|
||||
if(builtin_name == Attribute::standard_name(ATTR_STD_VOLUME_DENSITY)) {
|
||||
SmokeDomainSettings_density_grid_get_length(&b_domain.ptr, &length);
|
||||
|
||||
if(length == width*height*depth) {
|
||||
if(length == num_pixels) {
|
||||
SmokeDomainSettings_density_grid_get(&b_domain.ptr, pixels);
|
||||
return true;
|
||||
}
|
||||
@@ -1123,7 +1137,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
|
||||
* as 1500..3000 K with the first part faded to zero density */
|
||||
SmokeDomainSettings_flame_grid_get_length(&b_domain.ptr, &length);
|
||||
|
||||
if(length == width*height*depth) {
|
||||
if(length == num_pixels) {
|
||||
SmokeDomainSettings_flame_grid_get(&b_domain.ptr, pixels);
|
||||
return true;
|
||||
}
|
||||
@@ -1132,7 +1146,7 @@ bool BlenderSession::builtin_image_float_pixels(const string &builtin_name, void
|
||||
/* the RGB is "premultiplied" by density for better interpolation results */
|
||||
SmokeDomainSettings_color_grid_get_length(&b_domain.ptr, &length);
|
||||
|
||||
if(length == width*height*depth*4) {
|
||||
if(length == num_pixels*4) {
|
||||
SmokeDomainSettings_color_grid_get(&b_domain.ptr, pixels);
|
||||
return true;
|
||||
}
|
||||
|
@@ -897,7 +897,7 @@ static void add_nodes(Scene *scene,
|
||||
output_map[b_output->ptr.data] = proxy->outputs[0];
|
||||
}
|
||||
|
||||
if (b_group_ntree) {
|
||||
if(b_group_ntree) {
|
||||
add_nodes(scene,
|
||||
b_engine,
|
||||
b_data,
|
||||
|
@@ -36,6 +36,7 @@
|
||||
#include "util_debug.h"
|
||||
#include "util_foreach.h"
|
||||
#include "util_opengl.h"
|
||||
#include "util_hash.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
@@ -195,6 +196,9 @@ void BlenderSync::sync_integrator()
|
||||
integrator->filter_glossy = get_float(cscene, "blur_glossy");
|
||||
|
||||
integrator->seed = get_int(cscene, "seed");
|
||||
if(get_boolean(cscene, "use_animated_seed"))
|
||||
integrator->seed = hash_int_2d(b_scene.frame_current(), get_int(cscene, "seed"));
|
||||
|
||||
integrator->sampling_pattern = (SamplingPattern)RNA_enum_get(&cscene, "sampling_pattern");
|
||||
|
||||
integrator->layer_flag = render_layer.layer;
|
||||
|
@@ -354,11 +354,20 @@ static inline void mesh_texture_space(BL::Mesh b_mesh, float3& loc, float3& size
|
||||
}
|
||||
|
||||
/* object used for motion blur */
|
||||
static inline bool object_use_motion(BL::Object b_ob)
|
||||
static inline bool object_use_motion(BL::Object b_parent, BL::Object b_ob)
|
||||
{
|
||||
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
|
||||
bool use_motion = get_boolean(cobject, "use_motion_blur");
|
||||
|
||||
/* If motion blur is enabled for the object we also check
|
||||
* whether it's enabled for the parent object as well.
|
||||
*
|
||||
* This way we can control motion blur from the dupligroup
|
||||
* duplicator much easier.
|
||||
*/
|
||||
if(use_motion && b_parent.ptr.data != b_ob.ptr.data) {
|
||||
PointerRNA parent_cobject = RNA_pointer_get(&b_parent.ptr, "cycles");
|
||||
use_motion &= get_boolean(parent_cobject, "use_motion_blur");
|
||||
}
|
||||
return use_motion;
|
||||
}
|
||||
|
||||
@@ -375,11 +384,20 @@ static inline uint object_motion_steps(BL::Object b_ob)
|
||||
}
|
||||
|
||||
/* object uses deformation motion blur */
|
||||
static inline bool object_use_deform_motion(BL::Object b_ob)
|
||||
static inline bool object_use_deform_motion(BL::Object b_parent, BL::Object b_ob)
|
||||
{
|
||||
PointerRNA cobject = RNA_pointer_get(&b_ob.ptr, "cycles");
|
||||
bool use_deform_motion = get_boolean(cobject, "use_deform_motion");
|
||||
|
||||
/* If motion blur is enabled for the object we also check
|
||||
* whether it's enabled for the parent object as well.
|
||||
*
|
||||
* This way we can control motion blur from the dupligroup
|
||||
* duplicator much easier.
|
||||
*/
|
||||
if(use_deform_motion && b_parent.ptr.data != b_ob.ptr.data) {
|
||||
PointerRNA parent_cobject = RNA_pointer_get(&b_parent.ptr, "cycles");
|
||||
use_deform_motion &= get_boolean(parent_cobject, "use_deform_motion");
|
||||
}
|
||||
return use_deform_motion;
|
||||
}
|
||||
|
||||
|
@@ -190,11 +190,12 @@ void BVH::build(Progress& progress)
|
||||
}
|
||||
|
||||
/* build nodes */
|
||||
vector<int> prim_type;
|
||||
vector<int> prim_index;
|
||||
vector<int> prim_object;
|
||||
|
||||
BVHBuild bvh_build(objects, prim_type, prim_index, prim_object, params, progress);
|
||||
BVHBuild bvh_build(objects,
|
||||
pack.prim_type,
|
||||
pack.prim_index,
|
||||
pack.prim_object,
|
||||
params,
|
||||
progress);
|
||||
BVHNode *root = bvh_build.run();
|
||||
|
||||
if(progress.get_cancel()) {
|
||||
@@ -202,14 +203,6 @@ void BVH::build(Progress& progress)
|
||||
return;
|
||||
}
|
||||
|
||||
/* todo: get rid of this copy */
|
||||
pack.prim_type = prim_type;
|
||||
pack.prim_index = prim_index;
|
||||
pack.prim_object = prim_object;
|
||||
prim_type.free_memory();
|
||||
prim_index.free_memory();
|
||||
prim_object.free_memory();
|
||||
|
||||
/* compute SAH */
|
||||
if(!params.top_level)
|
||||
pack.SAH = root->computeSubtreeSAHCost(params);
|
||||
|
@@ -65,15 +65,18 @@ public:
|
||||
/* Constructor / Destructor */
|
||||
|
||||
BVHBuild::BVHBuild(const vector<Object*>& objects_,
|
||||
vector<int>& prim_type_, vector<int>& prim_index_, vector<int>& prim_object_,
|
||||
const BVHParams& params_, Progress& progress_)
|
||||
: objects(objects_),
|
||||
prim_type(prim_type_),
|
||||
prim_index(prim_index_),
|
||||
prim_object(prim_object_),
|
||||
params(params_),
|
||||
progress(progress_),
|
||||
progress_start_time(0.0)
|
||||
array<int>& prim_type_,
|
||||
array<int>& prim_index_,
|
||||
array<int>& prim_object_,
|
||||
const BVHParams& params_,
|
||||
Progress& progress_)
|
||||
: objects(objects_),
|
||||
prim_type(prim_type_),
|
||||
prim_index(prim_index_),
|
||||
prim_object(prim_object_),
|
||||
params(params_),
|
||||
progress(progress_),
|
||||
progress_start_time(0.0)
|
||||
{
|
||||
spatial_min_overlap = 0.0f;
|
||||
}
|
||||
@@ -446,18 +449,10 @@ BVHNode *BVHBuild::create_object_leaf_nodes(const BVHReference *ref, int start,
|
||||
return new LeafNode(bounds, 0, 0, 0);
|
||||
}
|
||||
else if(num == 1) {
|
||||
if(start == prim_index.size()) {
|
||||
assert(params.use_spatial_split);
|
||||
|
||||
prim_type.push_back(ref->prim_type());
|
||||
prim_index.push_back(ref->prim_index());
|
||||
prim_object.push_back(ref->prim_object());
|
||||
}
|
||||
else {
|
||||
prim_type[start] = ref->prim_type();
|
||||
prim_index[start] = ref->prim_index();
|
||||
prim_object[start] = ref->prim_object();
|
||||
}
|
||||
assert(start < prim_type.size());
|
||||
prim_type[start] = ref->prim_type();
|
||||
prim_index[start] = ref->prim_index();
|
||||
prim_object[start] = ref->prim_object();
|
||||
|
||||
uint visibility = objects[ref->prim_object()]->visibility;
|
||||
return new LeafNode(ref->bounds(), visibility, start, start+1);
|
||||
@@ -484,17 +479,9 @@ BVHNode *BVHBuild::create_primitive_leaf_node(const int *p_type,
|
||||
int num)
|
||||
{
|
||||
for(int i = 0; i < num; ++i) {
|
||||
if(start + i == prim_index.size()) {
|
||||
assert(params.use_spatial_split);
|
||||
prim_type.push_back(p_type[i]);
|
||||
prim_index.push_back(p_index[i]);
|
||||
prim_object.push_back(p_object[i]);
|
||||
}
|
||||
else {
|
||||
prim_type[start + i] = p_type[i];
|
||||
prim_index[start + i] = p_index[i];
|
||||
prim_object[start + i] = p_object[i];
|
||||
}
|
||||
prim_type[start + i] = p_type[i];
|
||||
prim_index[start + i] = p_index[i];
|
||||
prim_object[start + i] = p_object[i];
|
||||
}
|
||||
return new LeafNode(bounds, visibility, start, start + num);
|
||||
}
|
||||
@@ -535,6 +522,19 @@ BVHNode* BVHBuild::create_leaf_node(const BVHRange& range)
|
||||
}
|
||||
}
|
||||
|
||||
/* Extend an array when needed. */
|
||||
if(prim_type.size() < range.end()) {
|
||||
assert(params.use_spatial_split);
|
||||
/* TODO(sergey): We might want to look into different policies of
|
||||
* re-allocation here, so on the one hand we would not do as much
|
||||
* re-allocations and on the other hand will have small memory
|
||||
* overhead.
|
||||
*/
|
||||
prim_type.resize(range.end());
|
||||
prim_index.resize(range.end());
|
||||
prim_object.resize(range.end());
|
||||
}
|
||||
|
||||
/* Create leaf nodes for every existing primitive. */
|
||||
BVHNode *leaves[PRIMITIVE_NUM_TOTAL + 1] = {NULL};
|
||||
int num_leaves = 0;
|
||||
|
@@ -42,13 +42,12 @@ class BVHBuild
|
||||
{
|
||||
public:
|
||||
/* Constructor/Destructor */
|
||||
BVHBuild(
|
||||
const vector<Object*>& objects,
|
||||
vector<int>& prim_type,
|
||||
vector<int>& prim_index,
|
||||
vector<int>& prim_object,
|
||||
const BVHParams& params,
|
||||
Progress& progress);
|
||||
BVHBuild(const vector<Object*>& objects,
|
||||
array<int>& prim_type,
|
||||
array<int>& prim_index,
|
||||
array<int>& prim_object,
|
||||
const BVHParams& params,
|
||||
Progress& progress);
|
||||
~BVHBuild();
|
||||
|
||||
BVHNode *run();
|
||||
@@ -99,9 +98,9 @@ protected:
|
||||
int num_original_references;
|
||||
|
||||
/* output primitive indexes and objects */
|
||||
vector<int>& prim_type;
|
||||
vector<int>& prim_index;
|
||||
vector<int>& prim_object;
|
||||
array<int>& prim_type;
|
||||
array<int>& prim_index;
|
||||
array<int>& prim_object;
|
||||
|
||||
/* build parameters */
|
||||
BVHParams params;
|
||||
|
@@ -33,6 +33,13 @@ CCL_NAMESPACE_BEGIN
|
||||
|
||||
/* Device */
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
if(!background && vertex_buffer != 0) {
|
||||
glDeleteBuffers(1, &vertex_buffer);
|
||||
}
|
||||
}
|
||||
|
||||
void Device::pixels_alloc(device_memory& mem)
|
||||
{
|
||||
mem_alloc(mem, MEM_READ_WRITE);
|
||||
@@ -51,7 +58,7 @@ void Device::pixels_free(device_memory& mem)
|
||||
mem_free(mem);
|
||||
}
|
||||
|
||||
void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int width, int height, bool transparent,
|
||||
void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dx, int dy, int width, int height, bool transparent,
|
||||
const DeviceDrawParams &draw_params)
|
||||
{
|
||||
pixels_copy_from(rgba, y, w, h);
|
||||
@@ -67,6 +74,9 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
|
||||
/* for multi devices, this assumes the inefficient method that we allocate
|
||||
* all pixels on the device even though we only render to a subset */
|
||||
GLhalf *data_pointer = (GLhalf*)rgba.data_pointer;
|
||||
float vbuffer[16], *basep;
|
||||
float *vp = NULL;
|
||||
|
||||
data_pointer += 4*y*w;
|
||||
|
||||
/* draw half float texture, GLSL shader for display transform assumed to be bound */
|
||||
@@ -83,23 +93,63 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
|
||||
draw_params.bind_display_space_shader_cb();
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0.0f, (float)dy, 0.0f);
|
||||
if(GLEW_VERSION_1_5) {
|
||||
if(!vertex_buffer)
|
||||
glGenBuffers(1, &vertex_buffer);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(0.0f, 0.0f);
|
||||
glTexCoord2f(1.0f, 0.0f);
|
||||
glVertex2f((float)width, 0.0f);
|
||||
glTexCoord2f(1.0f, 1.0f);
|
||||
glVertex2f((float)width, (float)height);
|
||||
glTexCoord2f(0.0f, 1.0f);
|
||||
glVertex2f(0.0f, (float)height);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||
/* invalidate old contents - avoids stalling if buffer is still waiting in queue to be rendered */
|
||||
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
|
||||
|
||||
glEnd();
|
||||
vp = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
|
||||
glPopMatrix();
|
||||
basep = NULL;
|
||||
}
|
||||
else {
|
||||
basep = vbuffer;
|
||||
vp = vbuffer;
|
||||
}
|
||||
|
||||
if(vp) {
|
||||
/* texture coordinate - vertex pair */
|
||||
vp[0] = 0.0f;
|
||||
vp[1] = 0.0f;
|
||||
vp[2] = dx;
|
||||
vp[3] = dy;
|
||||
|
||||
vp[4] = 1.0f;
|
||||
vp[5] = 0.0f;
|
||||
vp[6] = (float)width + dx;
|
||||
vp[7] = dy;
|
||||
|
||||
vp[8] = 1.0f;
|
||||
vp[9] = 1.0f;
|
||||
vp[10] = (float)width + dx;
|
||||
vp[11] = (float)height + dy;
|
||||
|
||||
vp[12] = 0.0f;
|
||||
vp[13] = 1.0f;
|
||||
vp[14] = dx;
|
||||
vp[15] = (float)height + dy;
|
||||
|
||||
if(vertex_buffer)
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
}
|
||||
|
||||
glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), basep);
|
||||
glVertexPointer(2, GL_FLOAT, 4 * sizeof(float), ((char *)basep) + 2 * sizeof(float));
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
if(vertex_buffer) {
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
}
|
||||
|
||||
if(draw_params.unbind_display_space_shader_cb) {
|
||||
draw_params.unbind_display_space_shader_cb();
|
||||
@@ -113,7 +163,7 @@ void Device::draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int w
|
||||
/* fallback for old graphics cards that don't support GLSL, half float,
|
||||
* and non-power-of-two textures */
|
||||
glPixelZoom((float)width/(float)w, (float)height/(float)h);
|
||||
glRasterPos2f(0, dy);
|
||||
glRasterPos2f(dx, dy);
|
||||
|
||||
uint8_t *pixels = (uint8_t*)rgba.data_pointer;
|
||||
|
||||
@@ -277,13 +327,10 @@ string Device::device_capabilities()
|
||||
#endif
|
||||
|
||||
#ifdef WITH_OPENCL
|
||||
/* TODO(sergey): Needs proper usable implementation. */
|
||||
/*
|
||||
if(device_opencl_init()) {
|
||||
capabilities += "\nOpenCL device capabilities:\n";
|
||||
capabilities += device_opencl_capabilities();
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
return capabilities;
|
||||
|
@@ -92,6 +92,11 @@ public:
|
||||
*/
|
||||
int nodes_features;
|
||||
|
||||
/* BVH/sampling kernel features. */
|
||||
bool use_hair;
|
||||
bool use_object_motion;
|
||||
bool use_camera_motion;
|
||||
|
||||
DeviceRequestedFeatures()
|
||||
{
|
||||
/* TODO(sergey): Find more meaningful defaults. */
|
||||
@@ -99,6 +104,9 @@ public:
|
||||
max_closure = 0;
|
||||
max_nodes_group = 0;
|
||||
nodes_features = 0;
|
||||
use_hair = false;
|
||||
use_object_motion = false;
|
||||
use_camera_motion = false;
|
||||
}
|
||||
|
||||
bool modified(const DeviceRequestedFeatures& requested_features)
|
||||
@@ -119,13 +127,16 @@ struct DeviceDrawParams {
|
||||
|
||||
class Device {
|
||||
protected:
|
||||
Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), info(info_), stats(stats_) {}
|
||||
Device(DeviceInfo& info_, Stats &stats_, bool background) : background(background), vertex_buffer(0), info(info_), stats(stats_) {}
|
||||
|
||||
bool background;
|
||||
string error_msg;
|
||||
|
||||
/* used for real time display */
|
||||
unsigned int vertex_buffer;
|
||||
|
||||
public:
|
||||
virtual ~Device() {}
|
||||
virtual ~Device();
|
||||
|
||||
/* info */
|
||||
DeviceInfo info;
|
||||
@@ -178,7 +189,7 @@ public:
|
||||
|
||||
/* opengl drawing */
|
||||
virtual void draw_pixels(device_memory& mem, int y, int w, int h,
|
||||
int dy, int width, int height, bool transparent,
|
||||
int dx, int dy, int width, int height, bool transparent,
|
||||
const DeviceDrawParams &draw_params);
|
||||
|
||||
#ifdef WITH_NETWORK
|
||||
|
@@ -266,7 +266,7 @@ public:
|
||||
printf("CUDA version %d.%d detected, build may succeed but only CUDA 6.5 is officially supported.\n", cuda_version/10, cuda_version%10);
|
||||
|
||||
/* compile */
|
||||
string kernel = path_join(kernel_path, "kernel.cu");
|
||||
string kernel = path_join(kernel_path, path_join("kernels", path_join("cuda", "kernel.cu")));
|
||||
string include = kernel_path;
|
||||
const int machine = system_cpu_bits();
|
||||
|
||||
@@ -281,7 +281,7 @@ public:
|
||||
nvcc, major, minor, machine, kernel.c_str(), cubin.c_str(), include.c_str(), cuda_version);
|
||||
|
||||
if(experimental)
|
||||
command += " -D__KERNEL_CUDA_EXPERIMENTAL__";
|
||||
command += " -D__KERNEL_EXPERIMENTAL__";
|
||||
|
||||
if(getenv("CYCLES_CUDA_EXTRA_CFLAGS")) {
|
||||
command += string(" ") + getenv("CYCLES_CUDA_EXTRA_CFLAGS");
|
||||
@@ -880,11 +880,12 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void draw_pixels(device_memory& mem, int y, int w, int h, int dy, int width, int height, bool transparent,
|
||||
void draw_pixels(device_memory& mem, int y, int w, int h, int dx, int dy, int width, int height, bool transparent,
|
||||
const DeviceDrawParams &draw_params)
|
||||
{
|
||||
if(!background) {
|
||||
PixelMem pmem = pixel_mem_map[mem.device_pointer];
|
||||
float *vpointer;
|
||||
|
||||
cuda_push_context();
|
||||
|
||||
@@ -918,23 +919,52 @@ public:
|
||||
draw_params.bind_display_space_shader_cb();
|
||||
}
|
||||
|
||||
glPushMatrix();
|
||||
glTranslatef(0.0f, (float)dy, 0.0f);
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glTexCoord2f(0.0f, 0.0f);
|
||||
glVertex2f(0.0f, 0.0f);
|
||||
glTexCoord2f((float)w/(float)pmem.w, 0.0f);
|
||||
glVertex2f((float)width, 0.0f);
|
||||
glTexCoord2f((float)w/(float)pmem.w, (float)h/(float)pmem.h);
|
||||
glVertex2f((float)width, (float)height);
|
||||
glTexCoord2f(0.0f, (float)h/(float)pmem.h);
|
||||
glVertex2f(0.0f, (float)height);
|
||||
if(!vertex_buffer)
|
||||
glGenBuffers(1, &vertex_buffer);
|
||||
|
||||
glEnd();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vertex_buffer);
|
||||
/* invalidate old contents - avoids stalling if buffer is still waiting in queue to be rendered */
|
||||
glBufferData(GL_ARRAY_BUFFER, 16 * sizeof(float), NULL, GL_STREAM_DRAW);
|
||||
|
||||
glPopMatrix();
|
||||
vpointer = (float *)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
|
||||
|
||||
if(vpointer) {
|
||||
/* texture coordinate - vertex pair */
|
||||
vpointer[0] = 0.0f;
|
||||
vpointer[1] = 0.0f;
|
||||
vpointer[2] = dx;
|
||||
vpointer[3] = dy;
|
||||
|
||||
vpointer[4] = (float)w/(float)pmem.w;
|
||||
vpointer[5] = 0.0f;
|
||||
vpointer[6] = (float)width + dx;
|
||||
vpointer[7] = dy;
|
||||
|
||||
vpointer[8] = (float)w/(float)pmem.w;
|
||||
vpointer[9] = (float)h/(float)pmem.h;
|
||||
vpointer[10] = (float)width + dx;
|
||||
vpointer[11] = (float)height + dy;
|
||||
|
||||
vpointer[12] = 0.0f;
|
||||
vpointer[13] = (float)h/(float)pmem.h;
|
||||
vpointer[14] = dx;
|
||||
vpointer[15] = (float)height + dy;
|
||||
|
||||
glUnmapBuffer(GL_ARRAY_BUFFER);
|
||||
}
|
||||
|
||||
glTexCoordPointer(2, GL_FLOAT, 4 * sizeof(float), 0);
|
||||
glVertexPointer(2, GL_FLOAT, 4 * sizeof(float), (char *)NULL + 2 * sizeof(float));
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
|
||||
glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
|
||||
|
||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
|
||||
if(draw_params.unbind_display_space_shader_cb) {
|
||||
draw_params.unbind_display_space_shader_cb();
|
||||
@@ -951,7 +981,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
Device::draw_pixels(mem, y, w, h, dy, width, height, transparent, draw_params);
|
||||
Device::draw_pixels(mem, y, w, h, dx, dy, width, height, transparent, draw_params);
|
||||
}
|
||||
|
||||
void thread_run(DeviceTask *task)
|
||||
@@ -1092,14 +1122,20 @@ void device_cuda_info(vector<DeviceInfo>& devices)
|
||||
}
|
||||
|
||||
vector<DeviceInfo> display_devices;
|
||||
|
||||
|
||||
for(int num = 0; num < count; num++) {
|
||||
char name[256];
|
||||
int attr;
|
||||
|
||||
|
||||
if(cuDeviceGetName(name, 256, num) != CUDA_SUCCESS)
|
||||
continue;
|
||||
|
||||
int major, minor;
|
||||
cuDeviceComputeCapability(&major, &minor, num);
|
||||
if(major < 2) {
|
||||
continue;
|
||||
}
|
||||
|
||||
DeviceInfo info;
|
||||
|
||||
info.type = DEVICE_CUDA;
|
||||
@@ -1107,8 +1143,6 @@ void device_cuda_info(vector<DeviceInfo>& devices)
|
||||
info.id = string_printf("CUDA_%d", num);
|
||||
info.num = num;
|
||||
|
||||
int major, minor;
|
||||
cuDeviceComputeCapability(&major, &minor, num);
|
||||
info.advanced_shading = (major >= 2);
|
||||
info.extended_images = (major >= 3);
|
||||
info.pack_images = false;
|
||||
@@ -1133,7 +1167,7 @@ string device_cuda_capabilities(void)
|
||||
if(result != CUDA_ERROR_NO_DEVICE) {
|
||||
return string("Error initializing CUDA: ") + cuewErrorString(result);
|
||||
}
|
||||
return "No CUDA device found";
|
||||
return "No CUDA device found\n";
|
||||
}
|
||||
|
||||
int count;
|
||||
|
@@ -236,7 +236,7 @@ public:
|
||||
mem.device_pointer = tmp;
|
||||
}
|
||||
|
||||
void draw_pixels(device_memory& rgba, int y, int w, int h, int dy, int width, int height, bool transparent,
|
||||
void draw_pixels(device_memory& rgba, int y, int w, int h, int dx, int dy, int width, int height, bool transparent,
|
||||
const DeviceDrawParams &draw_params)
|
||||
{
|
||||
device_ptr tmp = rgba.device_pointer;
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
/* adjust math for w/width */
|
||||
|
||||
rgba.device_pointer = sub.ptr_map[tmp];
|
||||
sub.device->draw_pixels(rgba, sy, w, sh, sdy, width, sheight, transparent, draw_params);
|
||||
sub.device->draw_pixels(rgba, sy, w, sh, dx, sdy, width, sheight, transparent, draw_params);
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
#include "device_network.h"
|
||||
|
||||
#include "util_foreach.h"
|
||||
#include "util_logging.h"
|
||||
|
||||
#if defined(WITH_NETWORK)
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -12,20 +12,20 @@ set(INC_SYS
|
||||
)
|
||||
|
||||
set(SRC
|
||||
kernel.cpp
|
||||
kernel.cl
|
||||
kernel_data_init.cl
|
||||
kernel_queue_enqueue.cl
|
||||
kernel_scene_intersect.cl
|
||||
kernel_lamp_emission.cl
|
||||
kernel_background_buffer_update.cl
|
||||
kernel_shader_eval.cl
|
||||
kernel_holdout_emission_blurring_pathtermination_ao.cl
|
||||
kernel_direct_lighting.cl
|
||||
kernel_shadow_blocked.cl
|
||||
kernel_next_iteration_setup.cl
|
||||
kernel_sum_all_radiance.cl
|
||||
kernel.cu
|
||||
kernels/cpu/kernel.cpp
|
||||
kernels/opencl/kernel.cl
|
||||
kernels/opencl/kernel_data_init.cl
|
||||
kernels/opencl/kernel_queue_enqueue.cl
|
||||
kernels/opencl/kernel_scene_intersect.cl
|
||||
kernels/opencl/kernel_lamp_emission.cl
|
||||
kernels/opencl/kernel_background_buffer_update.cl
|
||||
kernels/opencl/kernel_shader_eval.cl
|
||||
kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl
|
||||
kernels/opencl/kernel_direct_lighting.cl
|
||||
kernels/opencl/kernel_shadow_blocked.cl
|
||||
kernels/opencl/kernel_next_iteration_setup.cl
|
||||
kernels/opencl/kernel_sum_all_radiance.cl
|
||||
kernels/cuda/kernel.cu
|
||||
)
|
||||
|
||||
set(SRC_HEADERS
|
||||
@@ -47,6 +47,7 @@ set(SRC_HEADERS
|
||||
kernel_montecarlo.h
|
||||
kernel_passes.h
|
||||
kernel_path.h
|
||||
kernel_path_branched.h
|
||||
kernel_path_common.h
|
||||
kernel_path_state.h
|
||||
kernel_path_surface.h
|
||||
@@ -57,7 +58,6 @@ set(SRC_HEADERS
|
||||
kernel_shader.h
|
||||
kernel_shaderdata_vars.h
|
||||
kernel_shadow.h
|
||||
kernel_split.h
|
||||
kernel_subsurface.h
|
||||
kernel_textures.h
|
||||
kernel_types.h
|
||||
@@ -154,6 +154,7 @@ set(SRC_GEOM_HEADERS
|
||||
)
|
||||
|
||||
set(SRC_UTIL_HEADERS
|
||||
../util/util_atomic.h
|
||||
../util/util_color.h
|
||||
../util/util_half.h
|
||||
../util/util_math.h
|
||||
@@ -161,6 +162,21 @@ set(SRC_UTIL_HEADERS
|
||||
../util/util_transform.h
|
||||
../util/util_types.h
|
||||
)
|
||||
|
||||
set(SRC_SPLIT_HEADERS
|
||||
split/kernel_background_buffer_update.h
|
||||
split/kernel_data_init.h
|
||||
split/kernel_direct_lighting.h
|
||||
split/kernel_holdout_emission_blurring_pathtermination_ao.h
|
||||
split/kernel_lamp_emission.h
|
||||
split/kernel_next_iteration_setup.h
|
||||
split/kernel_scene_intersect.h
|
||||
split/kernel_shader_eval.h
|
||||
split/kernel_shadow_blocked.h
|
||||
split/kernel_split_common.h
|
||||
split/kernel_sum_all_radiance.h
|
||||
)
|
||||
|
||||
# CUDA module
|
||||
|
||||
if(WITH_CYCLES_CUDA_BINARIES)
|
||||
@@ -186,12 +202,12 @@ if(WITH_CYCLES_CUDA_BINARIES)
|
||||
endif()
|
||||
|
||||
# build for each arch
|
||||
set(cuda_sources kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_GEOM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
|
||||
set(cuda_sources kernels/cuda/kernel.cu ${SRC_HEADERS} ${SRC_SVM_HEADERS} ${SRC_GEOM_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_UTIL_HEADERS})
|
||||
set(cuda_cubins)
|
||||
|
||||
macro(CYCLES_CUDA_KERNEL_ADD arch experimental)
|
||||
if(${experimental})
|
||||
set(cuda_extra_flags "-D__KERNEL_CUDA_EXPERIMENTAL__")
|
||||
set(cuda_extra_flags "-D__KERNEL_EXPERIMENTAL__")
|
||||
set(cuda_cubin kernel_experimental_${arch}.cubin)
|
||||
else()
|
||||
set(cuda_extra_flags "")
|
||||
@@ -212,7 +228,7 @@ if(WITH_CYCLES_CUDA_BINARIES)
|
||||
COMMAND ${CUDA_NVCC_EXECUTABLE}
|
||||
-arch=${arch}
|
||||
-m${CUDA_BITS}
|
||||
--cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernel.cu
|
||||
--cubin ${CMAKE_CURRENT_SOURCE_DIR}/kernels/cuda/kernel.cu
|
||||
-o ${CMAKE_CURRENT_BINARY_DIR}/${cuda_cubin}
|
||||
--ptxas-options="-v"
|
||||
${cuda_arch_flags}
|
||||
@@ -260,28 +276,28 @@ include_directories(SYSTEM ${INC_SYS})
|
||||
|
||||
if(CXX_HAS_SSE)
|
||||
list(APPEND SRC
|
||||
kernel_sse2.cpp
|
||||
kernel_sse3.cpp
|
||||
kernel_sse41.cpp
|
||||
kernels/cpu/kernel_sse2.cpp
|
||||
kernels/cpu/kernel_sse3.cpp
|
||||
kernels/cpu/kernel_sse41.cpp
|
||||
)
|
||||
|
||||
set_source_files_properties(kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
|
||||
set_source_files_properties(kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
|
||||
set_source_files_properties(kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
|
||||
set_source_files_properties(kernels/cpu/kernel_sse2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE2_KERNEL_FLAGS}")
|
||||
set_source_files_properties(kernels/cpu/kernel_sse3.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE3_KERNEL_FLAGS}")
|
||||
set_source_files_properties(kernels/cpu/kernel_sse41.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_SSE41_KERNEL_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(CXX_HAS_AVX)
|
||||
list(APPEND SRC
|
||||
kernel_avx.cpp
|
||||
kernels/cpu/kernel_avx.cpp
|
||||
)
|
||||
set_source_files_properties(kernel_avx.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
|
||||
set_source_files_properties(kernels/cpu/kernel_avx.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX_KERNEL_FLAGS}")
|
||||
endif()
|
||||
|
||||
if(CXX_HAS_AVX2)
|
||||
list(APPEND SRC
|
||||
kernel_avx2.cpp
|
||||
kernels/cpu/kernel_avx2.cpp
|
||||
)
|
||||
set_source_files_properties(kernel_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
|
||||
set_source_files_properties(kernels/cpu/kernel_avx2.cpp PROPERTIES COMPILE_FLAGS "${CYCLES_AVX2_KERNEL_FLAGS}")
|
||||
endif()
|
||||
|
||||
add_library(cycles_kernel ${SRC} ${SRC_HEADERS} ${SRC_CLOSURE_HEADERS} ${SRC_SVM_HEADERS} ${SRC_GEOM_HEADERS})
|
||||
@@ -300,22 +316,23 @@ endif()
|
||||
#add_custom_target(cycles_kernel_preprocess ALL DEPENDS ${KERNEL_PREPROCESSED})
|
||||
#delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${KERNEL_PREPROCESSED}" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_data_init.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_queue_enqueue.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_scene_intersect.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_lamp_emission.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_background_buffer_update.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_shader_eval.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_holdout_emission_blurring_pathtermination_ao.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_direct_lighting.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_shadow_blocked.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_next_iteration_setup.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel_sum_all_radiance.cl" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernel.cu" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_data_init.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_queue_enqueue.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_scene_intersect.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_lamp_emission.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_background_buffer_update.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_shader_eval.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_holdout_emission_blurring_pathtermination_ao.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_direct_lighting.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_shadow_blocked.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_next_iteration_setup.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/opencl/kernel_sum_all_radiance.cl" ${CYCLES_INSTALL_PATH}/kernel/kernels/opencl)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "kernels/cuda/kernel.cu" ${CYCLES_INSTALL_PATH}/kernel/kernels/cuda)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_CLOSURE_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/closure)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SVM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/svm)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_GEOM_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/geom)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_UTIL_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel)
|
||||
delayed_install(${CMAKE_CURRENT_SOURCE_DIR} "${SRC_SPLIT_HEADERS}" ${CYCLES_INSTALL_PATH}/kernel/split)
|
||||
|
||||
|
@@ -57,8 +57,9 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
|
||||
build_dir = os.path.join(root_build_dir, 'intern/cycles/kernel')
|
||||
|
||||
# source directories and files
|
||||
kernel_file_rel = os.path.join("kernels", "cuda", "kernel.cu")
|
||||
source_dir = Dir('.').srcnode().path
|
||||
kernel_file = os.path.join(source_dir, "kernel.cu")
|
||||
kernel_file = os.path.join(source_dir, kernel_file_rel)
|
||||
util_dir = os.path.join(source_dir, "../util")
|
||||
svm_dir = os.path.join(source_dir, "../svm")
|
||||
geom_dir = os.path.join(source_dir, "../geom")
|
||||
@@ -83,11 +84,11 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
|
||||
nvcc_flags += " -D__KERNEL_DEBUG__"
|
||||
|
||||
# dependencies
|
||||
dependencies = ['kernel.cu'] + kernel.Glob('*.h') + kernel.Glob('../util/*.h') + kernel.Glob('svm/*.h') + kernel.Glob('geom/*.h') + kernel.Glob('closure/*.h')
|
||||
dependencies = [kernel_file_rel] + kernel.Glob('*.h') + kernel.Glob('../util/*.h') + kernel.Glob('svm/*.h') + kernel.Glob('geom/*.h') + kernel.Glob('closure/*.h')
|
||||
last_cubin_file = None
|
||||
|
||||
configs = (("kernel_%s.cubin", ''),
|
||||
("kernel_experimental_%s.cubin", ' -D__KERNEL_CUDA_EXPERIMENTAL__'))
|
||||
("kernel_experimental_%s.cubin", ' -D__KERNEL_EXPERIMENTAL__'))
|
||||
|
||||
# add command for each cuda architecture
|
||||
for arch in cuda_archs:
|
||||
@@ -105,7 +106,7 @@ if env['WITH_BF_CYCLES_CUDA_BINARIES']:
|
||||
else:
|
||||
command = "\"%s\" -arch=%s %s \"%s\" -o \"%s\"" % (nvcc, arch, current_flags, kernel_file, cubin_file)
|
||||
|
||||
kernel.Command(cubin_file, 'kernel.cu', command)
|
||||
kernel.Command(cubin_file, kernel_file_rel, command)
|
||||
kernel.Depends(cubin_file, dependencies)
|
||||
|
||||
kernel_binaries.append(cubin_file)
|
||||
|
@@ -107,18 +107,9 @@ ccl_device int volume_absorption_setup(ShaderClosure *sc)
|
||||
|
||||
ccl_device float3 volume_phase_eval(const ShaderData *sd, const ShaderClosure *sc, float3 omega_in, float *pdf)
|
||||
{
|
||||
float3 eval;
|
||||
kernel_assert(sc->type == CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID);
|
||||
|
||||
switch(sc->type) {
|
||||
case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
|
||||
eval = volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
|
||||
break;
|
||||
default:
|
||||
eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
break;
|
||||
}
|
||||
|
||||
return eval;
|
||||
return volume_henyey_greenstein_eval_phase(sc, sd->I, omega_in, pdf);
|
||||
}
|
||||
|
||||
ccl_device int volume_phase_sample(const ShaderData *sd, const ShaderClosure *sc, float randu,
|
||||
|
@@ -76,6 +76,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
|
||||
#if defined(__KERNEL_DEBUG__)
|
||||
isect->num_traversal_steps = 0;
|
||||
isect->num_traversed_instances = 0;
|
||||
#endif
|
||||
|
||||
#if defined(__KERNEL_SSE2__)
|
||||
@@ -362,6 +363,10 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg,
|
||||
traversalStack[stackPtr] = ENTRYPOINT_SENTINEL;
|
||||
|
||||
nodeAddr = kernel_tex_fetch(__object_node, object);
|
||||
|
||||
#if defined(__KERNEL_DEBUG__)
|
||||
isect->num_traversed_instances++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* FEATURE(BVH_INSTANCING) */
|
||||
|
@@ -32,22 +32,22 @@ ccl_device float curve_attribute_float(KernelGlobals *kg, const ShaderData *sd,
|
||||
if(dy) *dy = 0.0f;
|
||||
#endif
|
||||
|
||||
return kernel_tex_fetch(__attributes_float, offset + sd->prim);
|
||||
return kernel_tex_fetch(__attributes_float, offset + ccl_fetch(sd, prim));
|
||||
}
|
||||
else if(elem == ATTR_ELEMENT_CURVE_KEY || elem == ATTR_ELEMENT_CURVE_KEY_MOTION) {
|
||||
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
|
||||
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
|
||||
int k1 = k0 + 1;
|
||||
|
||||
float f0 = kernel_tex_fetch(__attributes_float, offset + k0);
|
||||
float f1 = kernel_tex_fetch(__attributes_float, offset + k1);
|
||||
|
||||
#ifdef __RAY_DIFFERENTIALS__
|
||||
if(dx) *dx = sd->du.dx*(f1 - f0);
|
||||
if(dx) *dx = ccl_fetch(sd, du).dx*(f1 - f0);
|
||||
if(dy) *dy = 0.0f;
|
||||
#endif
|
||||
|
||||
return (1.0f - sd->u)*f0 + sd->u*f1;
|
||||
return (1.0f - ccl_fetch(sd, u))*f0 + ccl_fetch(sd, u)*f1;
|
||||
}
|
||||
else {
|
||||
#ifdef __RAY_DIFFERENTIALS__
|
||||
@@ -71,22 +71,22 @@ ccl_device float3 curve_attribute_float3(KernelGlobals *kg, const ShaderData *sd
|
||||
if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
|
||||
#endif
|
||||
|
||||
return float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + sd->prim));
|
||||
return float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + ccl_fetch(sd, prim)));
|
||||
}
|
||||
else if(elem == ATTR_ELEMENT_CURVE_KEY || elem == ATTR_ELEMENT_CURVE_KEY_MOTION) {
|
||||
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
|
||||
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
|
||||
int k1 = k0 + 1;
|
||||
|
||||
float3 f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + k0));
|
||||
float3 f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + k1));
|
||||
|
||||
#ifdef __RAY_DIFFERENTIALS__
|
||||
if(dx) *dx = sd->du.dx*(f1 - f0);
|
||||
if(dx) *dx = ccl_fetch(sd, du).dx*(f1 - f0);
|
||||
if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f);
|
||||
#endif
|
||||
|
||||
return (1.0f - sd->u)*f0 + sd->u*f1;
|
||||
return (1.0f - ccl_fetch(sd, u))*f0 + ccl_fetch(sd, u)*f1;
|
||||
}
|
||||
else {
|
||||
#ifdef __RAY_DIFFERENTIALS__
|
||||
@@ -104,22 +104,22 @@ ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
|
||||
{
|
||||
float r = 0.0f;
|
||||
|
||||
if(sd->type & PRIMITIVE_ALL_CURVE) {
|
||||
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
|
||||
if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
|
||||
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
|
||||
int k1 = k0 + 1;
|
||||
|
||||
float4 P_curve[2];
|
||||
|
||||
if(sd->type & PRIMITIVE_CURVE) {
|
||||
if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
|
||||
P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
|
||||
P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
|
||||
}
|
||||
else {
|
||||
motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
|
||||
motion_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), k0, k1, P_curve);
|
||||
}
|
||||
|
||||
r = (P_curve[1].w - P_curve[0].w) * sd->u + P_curve[0].w;
|
||||
r = (P_curve[1].w - P_curve[0].w) * ccl_fetch(sd, u) + P_curve[0].w;
|
||||
}
|
||||
|
||||
return r*2.0f;
|
||||
@@ -130,8 +130,8 @@ ccl_device float curve_thickness(KernelGlobals *kg, ShaderData *sd)
|
||||
|
||||
ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd)
|
||||
{
|
||||
float4 curvedata = kernel_tex_fetch(__curves, sd->prim);
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
|
||||
float4 curvedata = kernel_tex_fetch(__curves, ccl_fetch(sd, prim));
|
||||
int k0 = __float_as_int(curvedata.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
|
||||
int k1 = k0 + 1;
|
||||
|
||||
float4 P_curve[2];
|
||||
@@ -139,7 +139,7 @@ ccl_device float3 curve_motion_center_location(KernelGlobals *kg, ShaderData *sd
|
||||
P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
|
||||
P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
|
||||
|
||||
return float4_to_float3(P_curve[1]) * sd->u + float4_to_float3(P_curve[0]) * (1.0f - sd->u);
|
||||
return float4_to_float3(P_curve[1]) * ccl_fetch(sd, u) + float4_to_float3(P_curve[0]) * (1.0f - ccl_fetch(sd, u));
|
||||
}
|
||||
|
||||
/* Curve tangent normal */
|
||||
@@ -148,14 +148,14 @@ ccl_device float3 curve_tangent_normal(KernelGlobals *kg, ShaderData *sd)
|
||||
{
|
||||
float3 tgN = make_float3(0.0f,0.0f,0.0f);
|
||||
|
||||
if(sd->type & PRIMITIVE_ALL_CURVE) {
|
||||
if(ccl_fetch(sd, type) & PRIMITIVE_ALL_CURVE) {
|
||||
|
||||
tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) / len_squared(sd->dPdu)));
|
||||
tgN = -(-ccl_fetch(sd, I) - ccl_fetch(sd, dPdu) * (dot(ccl_fetch(sd, dPdu),-ccl_fetch(sd, I)) / len_squared(ccl_fetch(sd, dPdu))));
|
||||
tgN = normalize(tgN);
|
||||
|
||||
/* need to find suitable scaled gd for corrected normal */
|
||||
#if 0
|
||||
tgN = normalize(tgN - gd * sd->dPdu);
|
||||
tgN = normalize(tgN - gd * ccl_fetch(sd, dPdu));
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -890,7 +890,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
|
||||
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_itfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_itfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
|
||||
#endif
|
||||
@@ -903,7 +903,7 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
|
||||
int prim = kernel_tex_fetch(__prim_index, isect->prim);
|
||||
float4 v00 = kernel_tex_fetch(__curves, prim);
|
||||
|
||||
int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(sd->type);
|
||||
int k0 = __float_as_int(v00.x) + PRIMITIVE_UNPACK_SEGMENT(ccl_fetch(sd, type));
|
||||
int k1 = k0 + 1;
|
||||
|
||||
float3 tg;
|
||||
@@ -914,14 +914,14 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
|
||||
|
||||
float4 P_curve[4];
|
||||
|
||||
if(sd->type & PRIMITIVE_CURVE) {
|
||||
if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
|
||||
P_curve[0] = kernel_tex_fetch(__curve_keys, ka);
|
||||
P_curve[1] = kernel_tex_fetch(__curve_keys, k0);
|
||||
P_curve[2] = kernel_tex_fetch(__curve_keys, k1);
|
||||
P_curve[3] = kernel_tex_fetch(__curve_keys, kb);
|
||||
}
|
||||
else {
|
||||
motion_cardinal_curve_keys(kg, sd->object, sd->prim, sd->time, ka, k0, k1, kb, P_curve);
|
||||
motion_cardinal_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), ka, k0, k1, kb, P_curve);
|
||||
}
|
||||
|
||||
float3 p[4];
|
||||
@@ -933,43 +933,43 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
|
||||
P = P + D*t;
|
||||
|
||||
#ifdef __UV__
|
||||
sd->u = isect->u;
|
||||
sd->v = 0.0f;
|
||||
ccl_fetch(sd, u) = isect->u;
|
||||
ccl_fetch(sd, v) = 0.0f;
|
||||
#endif
|
||||
|
||||
tg = normalize(curvetangent(isect->u, p[0], p[1], p[2], p[3]));
|
||||
|
||||
if(kernel_data.curve.curveflags & CURVE_KN_RIBBONS) {
|
||||
sd->Ng = normalize(-(D - tg * (dot(tg, D))));
|
||||
ccl_fetch(sd, Ng) = normalize(-(D - tg * (dot(tg, D))));
|
||||
}
|
||||
else {
|
||||
/* direction from inside to surface of curve */
|
||||
float3 p_curr = curvepoint(isect->u, p[0], p[1], p[2], p[3]);
|
||||
sd->Ng = normalize(P - p_curr);
|
||||
ccl_fetch(sd, Ng) = normalize(P - p_curr);
|
||||
|
||||
/* adjustment for changing radius */
|
||||
float gd = isect->v;
|
||||
|
||||
if(gd != 0.0f) {
|
||||
sd->Ng = sd->Ng - gd * tg;
|
||||
sd->Ng = normalize(sd->Ng);
|
||||
ccl_fetch(sd, Ng) = ccl_fetch(sd, Ng) - gd * tg;
|
||||
ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
|
||||
}
|
||||
}
|
||||
|
||||
/* todo: sometimes the normal is still so that this is detected as
|
||||
* backfacing even if cull backfaces is enabled */
|
||||
|
||||
sd->N = sd->Ng;
|
||||
ccl_fetch(sd, N) = ccl_fetch(sd, Ng);
|
||||
}
|
||||
else {
|
||||
float4 P_curve[2];
|
||||
|
||||
if(sd->type & PRIMITIVE_CURVE) {
|
||||
if(ccl_fetch(sd, type) & PRIMITIVE_CURVE) {
|
||||
P_curve[0]= kernel_tex_fetch(__curve_keys, k0);
|
||||
P_curve[1]= kernel_tex_fetch(__curve_keys, k1);
|
||||
}
|
||||
else {
|
||||
motion_curve_keys(kg, sd->object, sd->prim, sd->time, k0, k1, P_curve);
|
||||
motion_curve_keys(kg, ccl_fetch(sd, object), ccl_fetch(sd, prim), ccl_fetch(sd, time), k0, k1, P_curve);
|
||||
}
|
||||
|
||||
float l = 1.0f;
|
||||
@@ -980,39 +980,39 @@ ccl_device_inline float3 bvh_curve_refine(KernelGlobals *kg, ShaderData *sd, con
|
||||
float3 dif = P - float4_to_float3(P_curve[0]);
|
||||
|
||||
#ifdef __UV__
|
||||
sd->u = dot(dif,tg)/l;
|
||||
sd->v = 0.0f;
|
||||
ccl_fetch(sd, u) = dot(dif,tg)/l;
|
||||
ccl_fetch(sd, v) = 0.0f;
|
||||
#endif
|
||||
|
||||
if(flag & CURVE_KN_TRUETANGENTGNORMAL) {
|
||||
sd->Ng = -(D - tg * dot(tg, D));
|
||||
sd->Ng = normalize(sd->Ng);
|
||||
ccl_fetch(sd, Ng) = -(D - tg * dot(tg, D));
|
||||
ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
|
||||
}
|
||||
else {
|
||||
float gd = isect->v;
|
||||
|
||||
/* direction from inside to surface of curve */
|
||||
sd->Ng = (dif - tg * sd->u * l) / (P_curve[0].w + sd->u * l * gd);
|
||||
ccl_fetch(sd, Ng) = (dif - tg * ccl_fetch(sd, u) * l) / (P_curve[0].w + ccl_fetch(sd, u) * l * gd);
|
||||
|
||||
/* adjustment for changing radius */
|
||||
if(gd != 0.0f) {
|
||||
sd->Ng = sd->Ng - gd * tg;
|
||||
sd->Ng = normalize(sd->Ng);
|
||||
ccl_fetch(sd, Ng) = ccl_fetch(sd, Ng) - gd * tg;
|
||||
ccl_fetch(sd, Ng) = normalize(ccl_fetch(sd, Ng));
|
||||
}
|
||||
}
|
||||
|
||||
sd->N = sd->Ng;
|
||||
ccl_fetch(sd, N) = ccl_fetch(sd, Ng);
|
||||
}
|
||||
|
||||
#ifdef __DPDU__
|
||||
/* dPdu/dPdv */
|
||||
sd->dPdu = tg;
|
||||
sd->dPdv = cross(tg, sd->Ng);
|
||||
ccl_fetch(sd, dPdu) = tg;
|
||||
ccl_fetch(sd, dPdv) = cross(tg, ccl_fetch(sd, Ng));
|
||||
#endif
|
||||
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_tfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_tfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
|
||||
#endif
|
||||
|
@@ -134,7 +134,7 @@ ccl_device_inline float3 motion_triangle_refine(KernelGlobals *kg, ShaderData *s
|
||||
return P;
|
||||
}
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_itfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_itfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
|
||||
#endif
|
||||
@@ -161,7 +161,7 @@ ccl_device_inline float3 motion_triangle_refine(KernelGlobals *kg, ShaderData *s
|
||||
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_tfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_tfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
|
||||
#endif
|
||||
@@ -187,7 +187,7 @@ ccl_device_inline float3 motion_triangle_refine_subsurface(KernelGlobals *kg, Sh
|
||||
#ifdef __INTERSECTION_REFINE__
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_itfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_itfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
|
||||
#endif
|
||||
@@ -213,7 +213,7 @@ ccl_device_inline float3 motion_triangle_refine_subsurface(KernelGlobals *kg, Sh
|
||||
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_tfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_tfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
|
||||
#endif
|
||||
|
@@ -123,7 +123,7 @@ ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals *kg
|
||||
ccl_device_inline void object_position_transform(KernelGlobals *kg, const ShaderData *sd, float3 *P)
|
||||
{
|
||||
#ifdef __OBJECT_MOTION__
|
||||
*P = transform_point(&ccl_fetch(sd, ob_tfm), *P);
|
||||
*P = transform_point_auto(&ccl_fetch(sd, ob_tfm), *P);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
|
||||
*P = transform_point(&tfm, *P);
|
||||
@@ -135,7 +135,7 @@ ccl_device_inline void object_position_transform(KernelGlobals *kg, const Shader
|
||||
ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, const ShaderData *sd, float3 *P)
|
||||
{
|
||||
#ifdef __OBJECT_MOTION__
|
||||
*P = transform_point(&ccl_fetch(sd, ob_itfm), *P);
|
||||
*P = transform_point_auto(&ccl_fetch(sd, ob_itfm), *P);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
|
||||
*P = transform_point(&tfm, *P);
|
||||
@@ -147,7 +147,7 @@ ccl_device_inline void object_inverse_position_transform(KernelGlobals *kg, cons
|
||||
ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, const ShaderData *sd, float3 *N)
|
||||
{
|
||||
#ifdef __OBJECT_MOTION__
|
||||
*N = normalize(transform_direction_transposed(&ccl_fetch(sd, ob_tfm), *N));
|
||||
*N = normalize(transform_direction_transposed_auto(&ccl_fetch(sd, ob_tfm), *N));
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
|
||||
*N = normalize(transform_direction_transposed(&tfm, *N));
|
||||
@@ -159,7 +159,7 @@ ccl_device_inline void object_inverse_normal_transform(KernelGlobals *kg, const
|
||||
ccl_device_inline void object_normal_transform(KernelGlobals *kg, const ShaderData *sd, float3 *N)
|
||||
{
|
||||
#ifdef __OBJECT_MOTION__
|
||||
*N = normalize(transform_direction_transposed(&ccl_fetch(sd, ob_itfm), *N));
|
||||
*N = normalize(transform_direction_transposed_auto(&ccl_fetch(sd, ob_itfm), *N));
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
|
||||
*N = normalize(transform_direction_transposed(&tfm, *N));
|
||||
@@ -171,7 +171,7 @@ ccl_device_inline void object_normal_transform(KernelGlobals *kg, const ShaderDa
|
||||
ccl_device_inline void object_dir_transform(KernelGlobals *kg, const ShaderData *sd, float3 *D)
|
||||
{
|
||||
#ifdef __OBJECT_MOTION__
|
||||
*D = transform_direction(&ccl_fetch(sd, ob_tfm), *D);
|
||||
*D = transform_direction_auto(&ccl_fetch(sd, ob_tfm), *D);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
|
||||
*D = transform_direction(&tfm, *D);
|
||||
@@ -183,7 +183,7 @@ ccl_device_inline void object_dir_transform(KernelGlobals *kg, const ShaderData
|
||||
ccl_device_inline void object_inverse_dir_transform(KernelGlobals *kg, const ShaderData *sd, float3 *D)
|
||||
{
|
||||
#ifdef __OBJECT_MOTION__
|
||||
*D = transform_direction(&ccl_fetch(sd, ob_itfm), *D);
|
||||
*D = transform_direction_auto(&ccl_fetch(sd, ob_itfm), *D);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
|
||||
*D = transform_direction(&tfm, *D);
|
||||
@@ -453,7 +453,7 @@ ccl_device_inline void bvh_instance_pop_factor(KernelGlobals *kg, int object, co
|
||||
#ifdef __OBJECT_MOTION__
|
||||
/* Transform ray into object space to enter motion blurred object in BVH */
|
||||
|
||||
ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm)
|
||||
ccl_device_inline void bvh_instance_motion_push(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, ccl_addr_space float *t, Transform *tfm)
|
||||
{
|
||||
Transform itfm;
|
||||
*tfm = object_fetch_transform_motion_test(kg, object, ray->time, &itfm);
|
||||
@@ -497,7 +497,7 @@ ccl_device_inline void qbvh_instance_motion_push(KernelGlobals *kg, int object,
|
||||
|
||||
/* Transorm ray to exit motion blurred object in BVH */
|
||||
|
||||
ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, float *t, Transform *tfm)
|
||||
ccl_device_inline void bvh_instance_motion_pop(KernelGlobals *kg, int object, const Ray *ray, float3 *P, float3 *dir, float3 *idir, ccl_addr_space float *t, Transform *tfm)
|
||||
{
|
||||
if(*t != FLT_MAX)
|
||||
*t *= len(transform_direction(tfm, 1.0f/(*idir)));
|
||||
|
@@ -80,6 +80,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
|
||||
#if defined(__KERNEL_DEBUG__)
|
||||
isect->num_traversal_steps = 0;
|
||||
isect->num_traversed_instances = 0;
|
||||
#endif
|
||||
|
||||
ssef tnear(0.0f), tfar(ray->t);
|
||||
@@ -185,6 +186,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
if(traverseChild == 0) {
|
||||
if(d1 < d0) {
|
||||
nodeAddr = c1;
|
||||
nodeDist = d1;
|
||||
++stackPtr;
|
||||
kernel_assert(stackPtr < BVH_QSTACK_SIZE);
|
||||
traversalStack[stackPtr].addr = c0;
|
||||
@@ -193,6 +195,7 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
}
|
||||
else {
|
||||
nodeAddr = c0;
|
||||
nodeDist = d0;
|
||||
++stackPtr;
|
||||
kernel_assert(stackPtr < BVH_QSTACK_SIZE);
|
||||
traversalStack[stackPtr].addr = c1;
|
||||
@@ -377,6 +380,10 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
traversalStack[stackPtr].dist = -FLT_MAX;
|
||||
|
||||
nodeAddr = kernel_tex_fetch(__object_node, object);
|
||||
|
||||
#if defined(__KERNEL_DEBUG__)
|
||||
isect->num_traversed_instances++;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif /* FEATURE(BVH_INSTANCING) */
|
||||
|
@@ -95,10 +95,6 @@ ccl_device bool BVH_FUNCTION_FULL_NAME(QBVH)(KernelGlobals *kg,
|
||||
do {
|
||||
/* Traverse internal nodes. */
|
||||
while(nodeAddr >= 0 && nodeAddr != ENTRYPOINT_SENTINEL) {
|
||||
#if defined(__KERNEL_DEBUG__)
|
||||
isect->num_traversal_steps++;
|
||||
#endif
|
||||
|
||||
ssef dist;
|
||||
int traverseChild = qbvh_node_intersect(kg,
|
||||
tnear,
|
||||
|
@@ -49,16 +49,25 @@ typedef struct IsectPrecalc {
|
||||
float Sx, Sy, Sz;
|
||||
} IsectPrecalc;
|
||||
|
||||
/* Workaround for CUDA toolkit 6.5.16. */
|
||||
#if defined(__KERNEL_CPU__) || !defined(__KERNEL_CUDA_EXPERIMENTAL__) || __CUDA_ARCH__ < 500
|
||||
#if defined(__KERNEL_CUDA__)
|
||||
# if (defined(i386) || defined(_M_IX86))
|
||||
# if __CUDA_ARCH__ > 500
|
||||
ccl_device_noinline
|
||||
# else
|
||||
# else /* __CUDA_ARCH__ > 500 */
|
||||
ccl_device_inline
|
||||
# endif
|
||||
#else
|
||||
# endif /* __CUDA_ARCH__ > 500 */
|
||||
# else /* (defined(i386) || defined(_M_IX86)) */
|
||||
# if defined(__KERNEL_EXPERIMENTAL__) && (__CUDA_ARCH__ >= 500)
|
||||
ccl_device_noinline
|
||||
#endif
|
||||
# else
|
||||
ccl_device_inline
|
||||
# endif
|
||||
# endif /* (defined(i386) || defined(_M_IX86)) */
|
||||
#elif defined(__KERNEL_OPENCL_APPLE__)
|
||||
ccl_device_noinline
|
||||
#else /* defined(__KERNEL_OPENCL_APPLE__) */
|
||||
ccl_device_inline
|
||||
#endif /* defined(__KERNEL_OPENCL_APPLE__) */
|
||||
void triangle_intersect_precalc(float3 dir,
|
||||
IsectPrecalc *isect_precalc)
|
||||
{
|
||||
@@ -306,7 +315,7 @@ ccl_device_inline float3 triangle_refine(KernelGlobals *kg,
|
||||
return P;
|
||||
}
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_itfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_itfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_INVERSE_TRANSFORM);
|
||||
#endif
|
||||
@@ -332,7 +341,7 @@ ccl_device_inline float3 triangle_refine(KernelGlobals *kg,
|
||||
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_tfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_tfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg, isect->object, OBJECT_TRANSFORM);
|
||||
#endif
|
||||
@@ -361,7 +370,7 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg,
|
||||
#ifdef __INTERSECTION_REFINE__
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_itfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_itfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg,
|
||||
isect->object,
|
||||
@@ -389,7 +398,7 @@ ccl_device_inline float3 triangle_refine_subsurface(KernelGlobals *kg,
|
||||
|
||||
if(isect->object != OBJECT_NONE) {
|
||||
#ifdef __OBJECT_MOTION__
|
||||
Transform tfm = sd->ob_tfm;
|
||||
Transform tfm = ccl_fetch(sd, ob_tfm);
|
||||
#else
|
||||
Transform tfm = object_fetch_transform(kg,
|
||||
isect->object,
|
||||
|
@@ -341,12 +341,12 @@ ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
|
||||
|
||||
ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadiance *L)
|
||||
{
|
||||
float3 L_sum, L_direct, L_indirect;
|
||||
float clamp_direct = kernel_data.integrator.sample_clamp_direct;
|
||||
float clamp_indirect = kernel_data.integrator.sample_clamp_indirect;
|
||||
|
||||
float3 L_sum;
|
||||
/* Light Passes are used */
|
||||
#ifdef __PASSES__
|
||||
float3 L_direct, L_indirect;
|
||||
float clamp_direct = kernel_data.integrator.sample_clamp_direct;
|
||||
float clamp_indirect = kernel_data.integrator.sample_clamp_indirect;
|
||||
if(L->use_light_pass) {
|
||||
path_radiance_sum_indirect(L);
|
||||
|
||||
|
@@ -1,282 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Blender Foundation
|
||||
*
|
||||
* 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 "kernel_split.h"
|
||||
|
||||
/*
|
||||
* Note on kernel_ocl_path_trace_background_buffer_update kernel.
|
||||
* This is the fourth kernel in the ray tracing logic, and the third
|
||||
* of the path iteration kernels. This kernel takes care of rays that hit
|
||||
* the background (sceneintersect kernel), and for the rays of
|
||||
* state RAY_UPDATE_BUFFER it updates the ray's accumulated radiance in
|
||||
* the output buffer. This kernel also takes care of rays that have been determined
|
||||
* to-be-regenerated.
|
||||
*
|
||||
* We will empty QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue in this kernel
|
||||
*
|
||||
* Typically all rays that are in state RAY_HIT_BACKGROUND, RAY_UPDATE_BUFFER
|
||||
* will be eventually set to RAY_TO_REGENERATE state in this kernel. Finally all rays of ray_state
|
||||
* RAY_TO_REGENERATE will be regenerated and put in queue QUEUE_ACTIVE_AND_REGENERATED_RAYS.
|
||||
*
|
||||
* The input and output are as follows,
|
||||
*
|
||||
* rng_coop ---------------------------------------------|--- kernel_ocl_path_trace_background_buffer_update --|--- PathRadiance_coop
|
||||
* throughput_coop --------------------------------------| |--- L_transparent_coop
|
||||
* per_sample_output_buffers ----------------------------| |--- per_sample_output_buffers
|
||||
* Ray_coop ---------------------------------------------| |--- ray_state
|
||||
* PathState_coop ---------------------------------------| |--- Queue_data (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
|
||||
* L_transparent_coop -----------------------------------| |--- Queue_data (QUEUE_ACTIVE_AND_REGENERATED_RAYS)
|
||||
* ray_state --------------------------------------------| |--- Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
|
||||
* Queue_data (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS) ----| |--- Queue_index (QUEUE_ACTIVE_AND_REGENERATED_RAYS)
|
||||
* Queue_index (QUEUE_ACTIVE_AND_REGENERATED_RAYS) ------| |--- work_array
|
||||
* parallel_samples -------------------------------------| |--- PathState_coop
|
||||
* end_sample -------------------------------------------| |--- throughput_coop
|
||||
* kg (globals + data) ----------------------------------| |--- rng_coop
|
||||
* rng_state --------------------------------------------| |--- Ray
|
||||
* PathRadiance_coop ------------------------------------| |
|
||||
* sw ---------------------------------------------------| |
|
||||
* sh ---------------------------------------------------| |
|
||||
* sx ---------------------------------------------------| |
|
||||
* sy ---------------------------------------------------| |
|
||||
* stride -----------------------------------------------| |
|
||||
* work_array -------------------------------------------| |--- work_array
|
||||
* queuesize --------------------------------------------| |
|
||||
* start_sample -----------------------------------------| |--- work_pool_wgs
|
||||
* work_pool_wgs ----------------------------------------| |
|
||||
* num_samples ------------------------------------------| |
|
||||
*
|
||||
* note on shader_data : shader_data argument is neither an input nor an output for this kernel. It is just filled and consumed here itself.
|
||||
* Note on Queues :
|
||||
* This kernel fetches rays from QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue.
|
||||
*
|
||||
* State of queues when this kernel is called :
|
||||
* At entry,
|
||||
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE rays
|
||||
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_UPDATE_BUFFER, RAY_HIT_BACKGROUND, RAY_TO_REGENERATE rays
|
||||
* At exit,
|
||||
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE and RAY_REGENERATED rays
|
||||
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be empty
|
||||
*/
|
||||
__kernel void kernel_ocl_path_trace_background_buffer_update(
|
||||
ccl_global char *globals,
|
||||
ccl_constant KernelData *data,
|
||||
ccl_global char *shader_data,
|
||||
ccl_global float *per_sample_output_buffers,
|
||||
ccl_global uint *rng_state,
|
||||
ccl_global uint *rng_coop, /* Required for buffer Update */
|
||||
ccl_global float3 *throughput_coop, /* Required for background hit processing */
|
||||
PathRadiance *PathRadiance_coop, /* Required for background hit processing and buffer Update */
|
||||
ccl_global Ray *Ray_coop, /* Required for background hit processing */
|
||||
ccl_global PathState *PathState_coop, /* Required for background hit processing */
|
||||
ccl_global float *L_transparent_coop, /* Required for background hit processing and buffer Update */
|
||||
ccl_global char *ray_state, /* Stores information on the current state of a ray */
|
||||
int sw, int sh, int sx, int sy, int stride,
|
||||
int rng_state_offset_x,
|
||||
int rng_state_offset_y,
|
||||
int rng_state_stride,
|
||||
ccl_global unsigned int *work_array, /* Denotes work of each ray */
|
||||
ccl_global int *Queue_data, /* Queues memory */
|
||||
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
|
||||
int queuesize, /* Size (capacity) of each queue */
|
||||
int end_sample,
|
||||
int start_sample,
|
||||
#ifdef __WORK_STEALING__
|
||||
ccl_global unsigned int *work_pool_wgs,
|
||||
unsigned int num_samples,
|
||||
#endif
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData *debugdata_coop,
|
||||
#endif
|
||||
int parallel_samples /* Number of samples to be processed in parallel */
|
||||
)
|
||||
{
|
||||
ccl_local unsigned int local_queue_atomics;
|
||||
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
|
||||
local_queue_atomics = 0;
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
|
||||
if(ray_index == 0) {
|
||||
/* We will empty this queue in this kernel */
|
||||
Queue_index[QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS] = 0;
|
||||
}
|
||||
char enqueue_flag = 0;
|
||||
ray_index = get_ray_index(ray_index, QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, Queue_data, queuesize, 1);
|
||||
|
||||
#ifdef __COMPUTE_DEVICE_GPU__
|
||||
/* If we are executing on a GPU device, we exit all threads that are not required.
|
||||
* If we are executing on a CPU device, then we need to keep all threads active
|
||||
* since we have barrier() calls later in the kernel. CPU devices
|
||||
* expect all threads to execute barrier statement.
|
||||
*/
|
||||
if(ray_index == QUEUE_EMPTY_SLOT)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
if(ray_index != QUEUE_EMPTY_SLOT) {
|
||||
#endif
|
||||
/* Load kernel globals structure and ShaderData strucuture */
|
||||
KernelGlobals *kg = (KernelGlobals *)globals;
|
||||
ShaderData *sd = (ShaderData *)shader_data;
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData *debug_data = &debugdata_coop[ray_index];
|
||||
#endif
|
||||
ccl_global PathState *state = &PathState_coop[ray_index];
|
||||
PathRadiance *L = L = &PathRadiance_coop[ray_index];
|
||||
ccl_global Ray *ray = &Ray_coop[ray_index];
|
||||
ccl_global float3 *throughput = &throughput_coop[ray_index];
|
||||
ccl_global float *L_transparent = &L_transparent_coop[ray_index];
|
||||
ccl_global uint *rng = &rng_coop[ray_index];
|
||||
|
||||
#ifdef __WORK_STEALING__
|
||||
unsigned int my_work;
|
||||
ccl_global float *initial_per_sample_output_buffers;
|
||||
ccl_global uint *initial_rng;
|
||||
#endif
|
||||
unsigned int sample;
|
||||
unsigned int tile_x;
|
||||
unsigned int tile_y;
|
||||
unsigned int pixel_x;
|
||||
unsigned int pixel_y;
|
||||
unsigned int my_sample_tile;
|
||||
|
||||
#ifdef __WORK_STEALING__
|
||||
my_work = work_array[ray_index];
|
||||
sample = get_my_sample(my_work, sw, sh, parallel_samples, ray_index) + start_sample;
|
||||
get_pixel_tile_position(&pixel_x, &pixel_y, &tile_x, &tile_y, my_work, sw, sh, sx, sy, parallel_samples, ray_index);
|
||||
my_sample_tile = 0;
|
||||
initial_per_sample_output_buffers = per_sample_output_buffers;
|
||||
initial_rng = rng_state;
|
||||
#else // __WORK_STEALING__
|
||||
sample = work_array[ray_index];
|
||||
int tile_index = ray_index / parallel_samples;
|
||||
/* buffer and rng_state's stride is "stride". Find x and y using ray_index */
|
||||
tile_x = tile_index % sw;
|
||||
tile_y = tile_index / sw;
|
||||
my_sample_tile = ray_index - (tile_index * parallel_samples);
|
||||
#endif
|
||||
rng_state += (rng_state_offset_x + tile_x) + (rng_state_offset_y + tile_y) * rng_state_stride;
|
||||
per_sample_output_buffers += (((tile_x + (tile_y * stride)) * parallel_samples) + my_sample_tile) * kernel_data.film.pass_stride;
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND)) {
|
||||
/* eval background shader if nothing hit */
|
||||
if(kernel_data.background.transparent && (state->flag & PATH_RAY_CAMERA)) {
|
||||
*L_transparent = (*L_transparent) + average((*throughput));
|
||||
#ifdef __PASSES__
|
||||
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
|
||||
#endif
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
|
||||
}
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_HIT_BACKGROUND))
|
||||
{
|
||||
#ifdef __BACKGROUND__
|
||||
/* sample background shader */
|
||||
float3 L_background = indirect_background(kg, state, ray, sd);
|
||||
path_radiance_accum_background(L, (*throughput), L_background, state->bounce);
|
||||
#endif
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
|
||||
}
|
||||
}
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER)) {
|
||||
float3 L_sum = path_radiance_clamp_and_sum(kg, L);
|
||||
kernel_write_light_passes(kg, per_sample_output_buffers, L, sample);
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
kernel_write_debug_passes(kg, per_sample_output_buffers, state, debug_data, sample);
|
||||
#endif
|
||||
float4 L_rad = make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - (*L_transparent));
|
||||
|
||||
/* accumulate result in output buffer */
|
||||
kernel_write_pass_float4(per_sample_output_buffers, sample, L_rad);
|
||||
path_rng_end(kg, rng_state, *rng);
|
||||
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
|
||||
}
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_TO_REGENERATE)) {
|
||||
#ifdef __WORK_STEALING__
|
||||
/* We have completed current work; So get next work */
|
||||
int valid_work = get_next_work(work_pool_wgs, &my_work, sw, sh, num_samples, parallel_samples, ray_index);
|
||||
if(!valid_work) {
|
||||
/* If work is invalid, this means no more work is available and the thread may exit */
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_INACTIVE);
|
||||
}
|
||||
#else
|
||||
if((sample + parallel_samples) >= end_sample) {
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_INACTIVE);
|
||||
}
|
||||
#endif
|
||||
if(IS_STATE(ray_state, ray_index, RAY_TO_REGENERATE)) {
|
||||
#ifdef __WORK_STEALING__
|
||||
work_array[ray_index] = my_work;
|
||||
/* Get the sample associated with the current work */
|
||||
sample = get_my_sample(my_work, sw, sh, parallel_samples, ray_index) + start_sample;
|
||||
/* Get pixel and tile position associated with current work */
|
||||
get_pixel_tile_position(&pixel_x, &pixel_y, &tile_x, &tile_y, my_work, sw, sh, sx, sy, parallel_samples, ray_index);
|
||||
my_sample_tile = 0;
|
||||
|
||||
/* Remap rng_state according to the current work */
|
||||
rng_state = initial_rng + ((rng_state_offset_x + tile_x) + (rng_state_offset_y + tile_y) * rng_state_stride);
|
||||
/* Remap per_sample_output_buffers according to the current work */
|
||||
per_sample_output_buffers = initial_per_sample_output_buffers
|
||||
+ (((tile_x + (tile_y * stride)) * parallel_samples) + my_sample_tile) * kernel_data.film.pass_stride;
|
||||
#else
|
||||
work_array[ray_index] = sample + parallel_samples;
|
||||
sample = work_array[ray_index];
|
||||
|
||||
/* Get ray position from ray index */
|
||||
pixel_x = sx + ((ray_index / parallel_samples) % sw);
|
||||
pixel_y = sy + ((ray_index / parallel_samples) / sw);
|
||||
#endif
|
||||
|
||||
/* initialize random numbers and ray */
|
||||
kernel_path_trace_setup(kg, rng_state, sample, pixel_x, pixel_y, rng, ray);
|
||||
|
||||
if(ray->t != 0.0f) {
|
||||
/* Initialize throughput, L_transparent, Ray, PathState; These rays proceed with path-iteration*/
|
||||
*throughput = make_float3(1.0f, 1.0f, 1.0f);
|
||||
*L_transparent = 0.0f;
|
||||
path_radiance_init(L, kernel_data.film.use_light_pass);
|
||||
path_state_init(kg, state, rng, sample, ray);
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
debug_data_init(debug_data);
|
||||
#endif
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_REGENERATED);
|
||||
enqueue_flag = 1;
|
||||
} else {
|
||||
/*These rays do not participate in path-iteration */
|
||||
float4 L_rad = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
/* accumulate result in output buffer */
|
||||
kernel_write_pass_float4(per_sample_output_buffers, sample, L_rad);
|
||||
path_rng_end(kg, rng_state, *rng);
|
||||
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_TO_REGENERATE);
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enqueue RAY_REGENERATED rays into QUEUE_ACTIVE_AND_REGENERATED_RAYS; These rays
|
||||
* will be made active during next SceneIntersectkernel
|
||||
*/
|
||||
enqueue_ray_index_local(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, enqueue_flag, queuesize, &local_queue_atomics, Queue_data, Queue_index);
|
||||
}
|
@@ -24,6 +24,7 @@
|
||||
*/
|
||||
#if defined(__GNUC__) && defined(NDEBUG)
|
||||
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
# pragma GCC diagnostic ignored "-Wuninitialized"
|
||||
#endif
|
||||
|
||||
/* Selective nodes compilation. */
|
||||
|
@@ -19,6 +19,8 @@ CCL_NAMESPACE_BEGIN
|
||||
ccl_device_inline void debug_data_init(DebugData *debug_data)
|
||||
{
|
||||
debug_data->num_bvh_traversal_steps = 0;
|
||||
debug_data->num_bvh_traversed_instances = 0;
|
||||
debug_data->num_ray_bounces = 0;
|
||||
}
|
||||
|
||||
ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
|
||||
@@ -33,6 +35,16 @@ ccl_device_inline void kernel_write_debug_passes(KernelGlobals *kg,
|
||||
sample,
|
||||
debug_data->num_bvh_traversal_steps);
|
||||
}
|
||||
if(flag & PASS_BVH_TRAVERSED_INSTANCES) {
|
||||
kernel_write_pass_float(buffer + kernel_data.film.pass_bvh_traversed_instances,
|
||||
sample,
|
||||
debug_data->num_bvh_traversed_instances);
|
||||
}
|
||||
if(flag & PASS_RAY_BOUNCES) {
|
||||
kernel_write_pass_float(buffer + kernel_data.film.pass_ray_bounces,
|
||||
sample,
|
||||
debug_data->num_ray_bounces);
|
||||
}
|
||||
}
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Blender Foundation
|
||||
*
|
||||
* 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 "kernel_split.h"
|
||||
|
||||
/*
|
||||
* Note on kernel_ocl_path_trace_direct_lighting kernel.
|
||||
* This is the eighth kernel in the ray tracing logic. This is the seventh
|
||||
* of the path iteration kernels. This kernel takes care of direct lighting
|
||||
* logic. However, the "shadow ray cast" part of direct lighting is handled
|
||||
* in the next kernel.
|
||||
*
|
||||
* This kernels determines the rays for which a shadow_blocked() function associated with direct lighting should be executed.
|
||||
* Those rays for which a shadow_blocked() function for direct-lighting must be executed, are marked with flag RAY_SHADOW_RAY_CAST_DL and
|
||||
* enqueued into the queue QUEUE_SHADOW_RAY_CAST_DL_RAYS
|
||||
*
|
||||
* The input and output are as follows,
|
||||
*
|
||||
* rng_coop -----------------------------------------|--- kernel_ocl_path_trace_direct_lighting --|--- BSDFEval_coop
|
||||
* PathState_coop -----------------------------------| |--- ISLamp_coop
|
||||
* shader_data --------------------------------------| |--- LightRay_coop
|
||||
* ray_state ----------------------------------------| |--- ray_state
|
||||
* Queue_data (QUEUE_ACTIVE_AND_REGENERATED_RAYS) ---| |
|
||||
* kg (globals + data) ------------------------------| |
|
||||
* queuesize ----------------------------------------| |
|
||||
*
|
||||
* note on shader_DL : shader_DL is neither input nor output to this kernel; shader_DL is filled and consumed in this kernel itself.
|
||||
* Note on Queues :
|
||||
* This kernel only reads from the QUEUE_ACTIVE_AND_REGENERATED_RAYS queue and processes
|
||||
* only the rays of state RAY_ACTIVE; If a ray needs to execute the corresponding shadow_blocked
|
||||
* part, after direct lighting, the ray is marked with RAY_SHADOW_RAY_CAST_DL flag.
|
||||
*
|
||||
* State of queues when this kernel is called :
|
||||
* state of queues QUEUE_ACTIVE_AND_REGENERATED_RAYS and QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be same
|
||||
* before and after this kernel call.
|
||||
* QUEUE_SHADOW_RAY_CAST_DL_RAYS queue will be filled with rays for which a shadow_blocked function must be executed, after this
|
||||
* kernel call. Before this kernel call the QUEUE_SHADOW_RAY_CAST_DL_RAYS will be empty.
|
||||
*/
|
||||
__kernel void kernel_ocl_path_trace_direct_lighting(
|
||||
ccl_global char *globals,
|
||||
ccl_constant KernelData *data,
|
||||
ccl_global char *shader_data, /* Required for direct lighting */
|
||||
ccl_global char *shader_DL, /* Required for direct lighting */
|
||||
ccl_global uint *rng_coop, /* Required for direct lighting */
|
||||
ccl_global PathState *PathState_coop, /* Required for direct lighting */
|
||||
ccl_global int *ISLamp_coop, /* Required for direct lighting */
|
||||
ccl_global Ray *LightRay_coop, /* Required for direct lighting */
|
||||
ccl_global BsdfEval *BSDFEval_coop, /* Required for direct lighting */
|
||||
ccl_global char *ray_state, /* Denotes the state of each ray */
|
||||
ccl_global int *Queue_data, /* Queue memory */
|
||||
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
|
||||
int queuesize /* Size (capacity) of each queue */
|
||||
)
|
||||
{
|
||||
ccl_local unsigned int local_queue_atomics;
|
||||
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
|
||||
local_queue_atomics = 0;
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
char enqueue_flag = 0;
|
||||
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
|
||||
ray_index = get_ray_index(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, Queue_data, queuesize, 0);
|
||||
|
||||
#ifdef __COMPUTE_DEVICE_GPU__
|
||||
/* If we are executing on a GPU device, we exit all threads that are not required
|
||||
* If we are executing on a CPU device, then we need to keep all threads active
|
||||
* since we have barrier() calls later in the kernel. CPU devices,
|
||||
* expect all threads to execute barrier statement.
|
||||
*/
|
||||
if(ray_index == QUEUE_EMPTY_SLOT)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
if(ray_index != QUEUE_EMPTY_SLOT) {
|
||||
#endif
|
||||
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
|
||||
/* Load kernel globals structure and ShaderData structure */
|
||||
KernelGlobals *kg = (KernelGlobals *)globals;
|
||||
ShaderData *sd = (ShaderData *)shader_data;
|
||||
ShaderData *sd_DL = (ShaderData *)shader_DL;
|
||||
|
||||
ccl_global PathState *state = &PathState_coop[ray_index];
|
||||
|
||||
/* direct lighting */
|
||||
#ifdef __EMISSION__
|
||||
if((kernel_data.integrator.use_direct_light && (ccl_fetch(sd, flag) & SD_BSDF_HAS_EVAL))) {
|
||||
/* sample illumination from lights to find path contribution */
|
||||
ccl_global RNG* rng = &rng_coop[ray_index];
|
||||
float light_t = path_state_rng_1D(kg, rng, state, PRNG_LIGHT);
|
||||
float light_u, light_v;
|
||||
path_state_rng_2D(kg, rng, state, PRNG_LIGHT_U, &light_u, &light_v);
|
||||
|
||||
#ifdef __OBJECT_MOTION__
|
||||
light_ray.time = sd->time;
|
||||
#endif
|
||||
LightSample ls;
|
||||
light_sample(kg, light_t, light_u, light_v, ccl_fetch(sd, time), ccl_fetch(sd, P), state->bounce, &ls);
|
||||
|
||||
Ray light_ray;
|
||||
BsdfEval L_light;
|
||||
bool is_lamp;
|
||||
if(direct_emission(kg, sd, &ls, &light_ray, &L_light, &is_lamp, state->bounce, state->transparent_bounce, sd_DL)) {
|
||||
/* write intermediate data to global memory to access from the next kernel */
|
||||
LightRay_coop[ray_index] = light_ray;
|
||||
BSDFEval_coop[ray_index] = L_light;
|
||||
ISLamp_coop[ray_index] = is_lamp;
|
||||
/// mark ray state for next shadow kernel
|
||||
ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL);
|
||||
enqueue_flag = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __EMISSION__
|
||||
/* Enqueue RAY_SHADOW_RAY_CAST_DL rays */
|
||||
enqueue_ray_index_local(ray_index, QUEUE_SHADOW_RAY_CAST_DL_RAYS, enqueue_flag, queuesize, &local_queue_atomics, Queue_data, Queue_index);
|
||||
#endif
|
||||
}
|
@@ -71,7 +71,6 @@ ccl_device_noinline float3 direct_emissive_eval(KernelGlobals *kg,
|
||||
return eval;
|
||||
}
|
||||
|
||||
/* The argument sd_DL is meaningful only for split kernel. Other uses can just pass NULL */
|
||||
ccl_device_noinline bool direct_emission(KernelGlobals *kg, ShaderData *sd,
|
||||
LightSample *ls, Ray *ray, BsdfEval *eval, bool *is_lamp,
|
||||
int bounce, int transparent_bounce
|
||||
@@ -192,7 +191,6 @@ ccl_device_noinline float3 indirect_primitive_emission(KernelGlobals *kg, Shader
|
||||
|
||||
/* Indirect Lamp Emission */
|
||||
|
||||
/* The argument sd is meaningful only for split kernel. Other uses can just pass NULL */
|
||||
ccl_device_noinline bool indirect_lamp_emission(KernelGlobals *kg, PathState *state, Ray *ray, float3 *emission
|
||||
#ifdef __SPLIT_KERNEL__
|
||||
,ShaderData *sd
|
||||
|
@@ -1,283 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Blender Foundation
|
||||
*
|
||||
* 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 "kernel_split.h"
|
||||
|
||||
/*
|
||||
* Note on kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_ao kernel.
|
||||
* This is the sixth kernel in the ray tracing logic. This is the fifth
|
||||
* of the path iteration kernels. This kernel takes care of the logic to process
|
||||
* "material of type holdout", indirect primitive emission, bsdf blurring,
|
||||
* probabilistic path termination and AO.
|
||||
*
|
||||
* This kernels determines the rays for which a shadow_blocked() function associated with AO should be executed.
|
||||
* Those rays for which a shadow_blocked() function for AO must be executed are marked with flag RAY_SHADOW_RAY_CAST_ao and
|
||||
* enqueued into the queue QUEUE_SHADOW_RAY_CAST_AO_RAYS
|
||||
*
|
||||
* Ray state of rays that are terminated in this kernel are changed to RAY_UPDATE_BUFFER
|
||||
*
|
||||
* The input and output are as follows,
|
||||
*
|
||||
* rng_coop ---------------------------------------------|--- kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_ao ---|--- Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
|
||||
* throughput_coop --------------------------------------| |--- PathState_coop
|
||||
* PathRadiance_coop ------------------------------------| |--- throughput_coop
|
||||
* Intersection_coop ------------------------------------| |--- L_transparent_coop
|
||||
* PathState_coop ---------------------------------------| |--- per_sample_output_buffers
|
||||
* L_transparent_coop -----------------------------------| |--- PathRadiance_coop
|
||||
* shader_data ------------------------------------------| |--- ShaderData
|
||||
* ray_state --------------------------------------------| |--- ray_state
|
||||
* Queue_data (QUEUE_ACTIVE_AND_REGENERATED_RAYS) -------| |--- Queue_data (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
|
||||
* Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS) ---| |--- AOAlpha_coop
|
||||
* kg (globals + data) ----------------------------------| |--- AOBSDF_coop
|
||||
* parallel_samples -------------------------------------| |--- AOLightRay_coop
|
||||
* per_sample_output_buffers ----------------------------| |
|
||||
* sw ---------------------------------------------------| |
|
||||
* sh ---------------------------------------------------| |
|
||||
* sx ---------------------------------------------------| |
|
||||
* sy ---------------------------------------------------| |
|
||||
* stride -----------------------------------------------| |
|
||||
* work_array -------------------------------------------| |
|
||||
* queuesize --------------------------------------------| |
|
||||
* start_sample -----------------------------------------| |
|
||||
*
|
||||
* Note on Queues :
|
||||
* This kernel fetches rays from the queue QUEUE_ACTIVE_AND_REGENERATED_RAYS and processes only
|
||||
* the rays of state RAY_ACTIVE.
|
||||
* There are different points in this kernel where a ray may terminate and reach RAY_UPDATE_BUFFER
|
||||
* state. These rays are enqueued into QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue. These rays will
|
||||
* still be present in QUEUE_ACTIVE_AND_REGENERATED_RAYS queue, but since their ray-state has been
|
||||
* changed to RAY_UPDATE_BUFFER, there is no problem.
|
||||
*
|
||||
* State of queues when this kernel is called :
|
||||
* At entry,
|
||||
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE and RAY_REGENERATED rays
|
||||
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE rays.
|
||||
* QUEUE_SHADOW_RAY_CAST_AO_RAYS will be empty.
|
||||
* At exit,
|
||||
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE, RAY_REGENERATED and RAY_UPDATE_BUFFER rays
|
||||
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE and RAY_UPDATE_BUFFER rays
|
||||
* QUEUE_SHADOW_RAY_CAST_AO_RAYS will be filled with rays marked with flag RAY_SHADOW_RAY_CAST_AO
|
||||
*/
|
||||
|
||||
__kernel void kernel_ocl_path_trace_holdout_emission_blurring_pathtermination_ao(
|
||||
ccl_global char *globals,
|
||||
ccl_constant KernelData *data,
|
||||
ccl_global char *shader_data, /* Required throughout the kernel except probabilistic path termination and AO */
|
||||
ccl_global float *per_sample_output_buffers,
|
||||
ccl_global uint *rng_coop, /* Required for "kernel_write_data_passes" and AO */
|
||||
ccl_global float3 *throughput_coop, /* Required for handling holdout material and AO */
|
||||
ccl_global float *L_transparent_coop, /* Required for handling holdout material */
|
||||
PathRadiance *PathRadiance_coop, /* Required for "kernel_write_data_passes" and indirect primitive emission */
|
||||
ccl_global PathState *PathState_coop, /* Required throughout the kernel and AO */
|
||||
Intersection *Intersection_coop, /* Required for indirect primitive emission */
|
||||
ccl_global float3 *AOAlpha_coop, /* Required for AO */
|
||||
ccl_global float3 *AOBSDF_coop, /* Required for AO */
|
||||
ccl_global Ray *AOLightRay_coop, /* Required for AO */
|
||||
int sw, int sh, int sx, int sy, int stride,
|
||||
ccl_global char *ray_state, /* Denotes the state of each ray */
|
||||
ccl_global unsigned int *work_array, /* Denotes the work that each ray belongs to */
|
||||
ccl_global int *Queue_data, /* Queue memory */
|
||||
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
|
||||
int queuesize, /* Size (capacity) of each queue */
|
||||
#ifdef __WORK_STEALING__
|
||||
unsigned int start_sample,
|
||||
#endif
|
||||
int parallel_samples /* Number of samples to be processed in parallel */
|
||||
)
|
||||
{
|
||||
ccl_local unsigned int local_queue_atomics_bg;
|
||||
ccl_local unsigned int local_queue_atomics_ao;
|
||||
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
|
||||
local_queue_atomics_bg = 0;
|
||||
local_queue_atomics_ao = 0;
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
char enqueue_flag = 0;
|
||||
char enqueue_flag_AO_SHADOW_RAY_CAST = 0;
|
||||
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
|
||||
ray_index = get_ray_index(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, Queue_data, queuesize, 0);
|
||||
|
||||
#ifdef __COMPUTE_DEVICE_GPU__
|
||||
/* If we are executing on a GPU device, we exit all threads that are not required
|
||||
* If we are executing on a CPU device, then we need to keep all threads active
|
||||
* since we have barrier() calls later in the kernel. CPU devices
|
||||
* expect all threads to execute barrier statement.
|
||||
*/
|
||||
if(ray_index == QUEUE_EMPTY_SLOT)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
if(ray_index != QUEUE_EMPTY_SLOT) {
|
||||
#endif
|
||||
/* Load kernel globals structure and ShaderData structure */
|
||||
KernelGlobals *kg = (KernelGlobals *)globals;
|
||||
ShaderData *sd = (ShaderData *)shader_data;
|
||||
|
||||
#ifdef __WORK_STEALING__
|
||||
unsigned int my_work;
|
||||
unsigned int pixel_x;
|
||||
unsigned int pixel_y;
|
||||
#endif
|
||||
unsigned int tile_x;
|
||||
unsigned int tile_y;
|
||||
int my_sample_tile;
|
||||
unsigned int sample;
|
||||
|
||||
ccl_global RNG *rng = 0x0;
|
||||
ccl_global PathState *state = 0x0;
|
||||
float3 throughput;
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
|
||||
|
||||
throughput = throughput_coop[ray_index];
|
||||
state = &PathState_coop[ray_index];
|
||||
rng = &rng_coop[ray_index];
|
||||
#ifdef __WORK_STEALING__
|
||||
my_work = work_array[ray_index];
|
||||
sample = get_my_sample(my_work, sw, sh, parallel_samples, ray_index) + start_sample;
|
||||
get_pixel_tile_position(&pixel_x, &pixel_y, &tile_x, &tile_y, my_work, sw, sh, sx, sy, parallel_samples, ray_index);
|
||||
my_sample_tile = 0;
|
||||
#else // __WORK_STEALING__
|
||||
sample = work_array[ray_index];
|
||||
/* buffer's stride is "stride"; Find x and y using ray_index */
|
||||
int tile_index = ray_index / parallel_samples;
|
||||
tile_x = tile_index % sw;
|
||||
tile_y = tile_index / sw;
|
||||
my_sample_tile = ray_index - (tile_index * parallel_samples);
|
||||
#endif // __WORK_STEALING__
|
||||
per_sample_output_buffers += (((tile_x + (tile_y * stride)) * parallel_samples) + my_sample_tile) * kernel_data.film.pass_stride;
|
||||
|
||||
/* holdout */
|
||||
#ifdef __HOLDOUT__
|
||||
if((ccl_fetch(sd, flag) & (SD_HOLDOUT|SD_HOLDOUT_MASK)) && (state->flag & PATH_RAY_CAMERA)) {
|
||||
if(kernel_data.background.transparent) {
|
||||
float3 holdout_weight;
|
||||
|
||||
if(ccl_fetch(sd, flag) & SD_HOLDOUT_MASK)
|
||||
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
|
||||
else
|
||||
holdout_weight = shader_holdout_eval(kg, sd);
|
||||
|
||||
/* any throughput is ok, should all be identical here */
|
||||
L_transparent_coop[ray_index] += average(holdout_weight*throughput);
|
||||
}
|
||||
|
||||
if(ccl_fetch(sd, flag) & SD_HOLDOUT_MASK) {
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
|
||||
enqueue_flag = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
|
||||
|
||||
PathRadiance *L = &PathRadiance_coop[ray_index];
|
||||
/* holdout mask objects do not write data passes */
|
||||
kernel_write_data_passes(kg, per_sample_output_buffers, L, sd, sample, state, throughput);
|
||||
|
||||
/* blurring of bsdf after bounces, for rays that have a small likelihood
|
||||
* of following this particular path (diffuse, rough glossy) */
|
||||
if(kernel_data.integrator.filter_glossy != FLT_MAX) {
|
||||
float blur_pdf = kernel_data.integrator.filter_glossy*state->min_ray_pdf;
|
||||
|
||||
if(blur_pdf < 1.0f) {
|
||||
float blur_roughness = sqrtf(1.0f - blur_pdf)*0.5f;
|
||||
shader_bsdf_blur(kg, sd, blur_roughness);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __EMISSION__
|
||||
/* emission */
|
||||
if(ccl_fetch(sd, flag) & SD_EMISSION) {
|
||||
/* todo: is isect.t wrong here for transparent surfaces? */
|
||||
float3 emission = indirect_primitive_emission(kg, sd, Intersection_coop[ray_index].t, state->flag, state->ray_pdf);
|
||||
path_radiance_accum_emission(L, throughput, emission, state->bounce);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* path termination. this is a strange place to put the termination, it's
|
||||
* mainly due to the mixed in MIS that we use. gives too many unneeded
|
||||
* shader evaluations, only need emission if we are going to terminate */
|
||||
float probability = path_state_terminate_probability(kg, state, throughput);
|
||||
|
||||
if(probability == 0.0f) {
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
|
||||
enqueue_flag = 1;
|
||||
}
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
|
||||
if(probability != 1.0f) {
|
||||
float terminate = path_state_rng_1D_for_decision(kg, rng, state, PRNG_TERMINATE);
|
||||
|
||||
if(terminate >= probability) {
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
|
||||
enqueue_flag = 1;
|
||||
} else {
|
||||
throughput_coop[ray_index] = throughput/probability;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __AO__
|
||||
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
|
||||
/* ambient occlusion */
|
||||
if(kernel_data.integrator.use_ambient_occlusion || (ccl_fetch(sd, flag) & SD_AO)) {
|
||||
/* todo: solve correlation */
|
||||
float bsdf_u, bsdf_v;
|
||||
path_state_rng_2D(kg, rng, state, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
|
||||
|
||||
float ao_factor = kernel_data.background.ao_factor;
|
||||
float3 ao_N;
|
||||
AOBSDF_coop[ray_index] = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
|
||||
AOAlpha_coop[ray_index] = shader_bsdf_alpha(kg, sd);
|
||||
|
||||
float3 ao_D;
|
||||
float ao_pdf;
|
||||
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
|
||||
|
||||
if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
|
||||
Ray _ray;
|
||||
_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
|
||||
_ray.D = ao_D;
|
||||
_ray.t = kernel_data.background.ao_distance;
|
||||
#ifdef __OBJECT_MOTION__
|
||||
_ray.time = ccl_fetch(sd, time);
|
||||
#endif
|
||||
_ray.dP = ccl_fetch(sd, dP);
|
||||
_ray.dD = differential3_zero();
|
||||
AOLightRay_coop[ray_index] = _ray;
|
||||
|
||||
ADD_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO);
|
||||
enqueue_flag_AO_SHADOW_RAY_CAST = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enqueue RAY_UPDATE_BUFFER rays */
|
||||
enqueue_ray_index_local(ray_index, QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, queuesize, &local_queue_atomics_bg, Queue_data, Queue_index);
|
||||
#ifdef __AO__
|
||||
/* Enqueue to-shadow-ray-cast rays */
|
||||
enqueue_ray_index_local(ray_index, QUEUE_SHADOW_RAY_CAST_AO_RAYS, enqueue_flag_AO_SHADOW_RAY_CAST, queuesize, &local_queue_atomics_ao, Queue_data, Queue_index);
|
||||
#endif
|
||||
}
|
@@ -249,6 +249,25 @@ float background_map_pdf(KernelGlobals *kg, float3 direction)
|
||||
return (cdf_u.x * cdf_v.x)/(M_2PI_F * M_PI_F * sin_theta * denom);
|
||||
}
|
||||
|
||||
ccl_device_inline bool background_portal_data_fetch_and_check_side(KernelGlobals *kg,
|
||||
float3 P,
|
||||
int index,
|
||||
float3 *lightpos,
|
||||
float3 *dir)
|
||||
{
|
||||
float4 data0 = kernel_tex_fetch(__light_data, (index + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
|
||||
float4 data3 = kernel_tex_fetch(__light_data, (index + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
|
||||
|
||||
*lightpos = make_float3(data0.y, data0.z, data0.w);
|
||||
*dir = make_float3(data3.y, data3.z, data3.w);
|
||||
|
||||
/* Check whether portal is on the right side. */
|
||||
if(dot(*dir, P - *lightpos) > 1e-5f)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ccl_device float background_portal_pdf(KernelGlobals *kg,
|
||||
float3 P,
|
||||
float3 direction,
|
||||
@@ -261,19 +280,9 @@ ccl_device float background_portal_pdf(KernelGlobals *kg,
|
||||
if(p == ignore_portal)
|
||||
continue;
|
||||
|
||||
/* TODO(sergey): Consider moving portal data fetch to a
|
||||
* dedicated function.
|
||||
*/
|
||||
float4 data0 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
|
||||
float4 data3 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
|
||||
|
||||
float3 lightpos = make_float3(data0.y, data0.z, data0.w);
|
||||
float3 dir = make_float3(data3.y, data3.z, data3.w);
|
||||
|
||||
if(dot(dir, P - lightpos) <= 1e-5f) {
|
||||
/* P is on the wrong side or too close. */
|
||||
float3 lightpos, dir;
|
||||
if(!background_portal_data_fetch_and_check_side(kg, P, p, &lightpos, &dir))
|
||||
continue;
|
||||
}
|
||||
|
||||
if(is_possible) {
|
||||
/* There's a portal that could be sampled from this position. */
|
||||
@@ -310,13 +319,8 @@ ccl_device int background_num_possible_portals(KernelGlobals *kg, float3 P)
|
||||
{
|
||||
int num_possible_portals = 0;
|
||||
for(int p = 0; p < kernel_data.integrator.num_portals; p++) {
|
||||
float4 data0 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
|
||||
float4 data3 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
|
||||
float3 lightpos = make_float3(data0.y, data0.z, data0.w);
|
||||
float3 dir = make_float3(data3.y, data3.z, data3.w);
|
||||
|
||||
/* Check whether portal is on the right side. */
|
||||
if(dot(dir, P - lightpos) > 1e-5f)
|
||||
float3 lightpos, dir;
|
||||
if(background_portal_data_fetch_and_check_side(kg, P, p, &lightpos, &dir))
|
||||
num_possible_portals++;
|
||||
}
|
||||
return num_possible_portals;
|
||||
@@ -340,13 +344,8 @@ ccl_device float3 background_portal_sample(KernelGlobals *kg,
|
||||
*/
|
||||
for(int p = 0; p < kernel_data.integrator.num_portals; p++) {
|
||||
/* Search for the sampled portal. */
|
||||
float4 data0 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 0);
|
||||
float4 data3 = kernel_tex_fetch(__light_data, (p + kernel_data.integrator.portal_offset)*LIGHT_SIZE + 3);
|
||||
float3 lightpos = make_float3(data0.y, data0.z, data0.w);
|
||||
float3 dir = make_float3(data3.y, data3.z, data3.w);
|
||||
|
||||
/* Check whether portal is on the right side. */
|
||||
if(dot(dir, P - lightpos) <= 1e-5f)
|
||||
float3 lightpos, dir;
|
||||
if(!background_portal_data_fetch_and_check_side(kg, P, p, &lightpos, &dir))
|
||||
continue;
|
||||
|
||||
if(portal == 0) {
|
||||
@@ -356,16 +355,14 @@ ccl_device float3 background_portal_sample(KernelGlobals *kg,
|
||||
float3 axisu = make_float3(data1.y, data1.z, data1.w);
|
||||
float3 axisv = make_float3(data2.y, data2.z, data2.w);
|
||||
|
||||
float3 lightPoint = lightpos;
|
||||
|
||||
*pdf = area_light_sample(P, &lightPoint,
|
||||
*pdf = area_light_sample(P, &lightpos,
|
||||
axisu, axisv,
|
||||
randu, randv,
|
||||
true);
|
||||
|
||||
*pdf /= num_possible;
|
||||
*sampled_portal = p;
|
||||
return normalize(lightPoint - P);
|
||||
return normalize(lightpos - P);
|
||||
}
|
||||
|
||||
portal--;
|
||||
|
@@ -1,176 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Blender Foundation
|
||||
*
|
||||
* 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 "kernel_split.h"
|
||||
|
||||
/*
|
||||
* Note on kernel_ocl_path_trace_setup_next_iteration kernel.
|
||||
* This is the tenth kernel in the ray tracing logic. This is the ninth
|
||||
* of the path iteration kernels. This kernel takes care of setting up
|
||||
* Ray for the next iteration of path-iteration and accumulating radiance
|
||||
* corresponding to AO and direct-lighting
|
||||
*
|
||||
* Ray state of rays that are terminated in this kernel are changed to RAY_UPDATE_BUFFER
|
||||
*
|
||||
* The input and output are as follows,
|
||||
*
|
||||
* rng_coop ---------------------------------------------|--- kernel_ocl_path_trace_setup_next_iteration -|--- Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS)
|
||||
* throughput_coop --------------------------------------| |--- Queue_data (QUEUE_HITBF_BUFF_UPDATE_TOREGEN_RAYS)
|
||||
* PathRadiance_coop ------------------------------------| |--- throughput_coop
|
||||
* PathState_coop ---------------------------------------| |--- PathRadiance_coop
|
||||
* shader_data ------------------------------------------| |--- PathState_coop
|
||||
* ray_state --------------------------------------------| |--- ray_state
|
||||
* Queue_data (QUEUE_ACTIVE_AND_REGENERATD_RAYS) --------| |--- Ray_coop
|
||||
* Queue_index (QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS) ---| |--- use_queues_flag
|
||||
* Ray_coop ---------------------------------------------| |
|
||||
* kg (globals + data) ----------------------------------| |
|
||||
* LightRay_dl_coop -------------------------------------|
|
||||
* ISLamp_coop ------------------------------------------|
|
||||
* BSDFEval_coop ----------------------------------------|
|
||||
* LightRay_ao_coop -------------------------------------|
|
||||
* AOBSDF_coop ------------------------------------------|
|
||||
* AOAlpha_coop -----------------------------------------|
|
||||
*
|
||||
* Note on queues,
|
||||
* This kernel fetches rays from the queue QUEUE_ACTIVE_AND_REGENERATED_RAYS and processes only
|
||||
* the rays of state RAY_ACTIVE.
|
||||
* There are different points in this kernel where a ray may terminate and reach RAY_UPDATE_BUFF
|
||||
* state. These rays are enqueued into QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS queue. These rays will
|
||||
* still be present in QUEUE_ACTIVE_AND_REGENERATED_RAYS queue, but since their ray-state has been
|
||||
* changed to RAY_UPDATE_BUFF, there is no problem.
|
||||
*
|
||||
* State of queues when this kernel is called :
|
||||
* At entry,
|
||||
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE, RAY_REGENERATED, RAY_UPDATE_BUFFER rays.
|
||||
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE and RAY_UPDATE_BUFFER rays
|
||||
* At exit,
|
||||
* QUEUE_ACTIVE_AND_REGENERATED_RAYS will be filled with RAY_ACTIVE, RAY_REGENERATED and more RAY_UPDATE_BUFFER rays.
|
||||
* QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be filled with RAY_TO_REGENERATE and more RAY_UPDATE_BUFFER rays
|
||||
*/
|
||||
|
||||
__kernel void kernel_ocl_path_trace_setup_next_iteration(
|
||||
ccl_global char *globals,
|
||||
ccl_constant KernelData *data,
|
||||
ccl_global char *shader_data, /* Required for setting up ray for next iteration */
|
||||
ccl_global uint *rng_coop, /* Required for setting up ray for next iteration */
|
||||
ccl_global float3 *throughput_coop, /* Required for setting up ray for next iteration */
|
||||
PathRadiance *PathRadiance_coop, /* Required for setting up ray for next iteration */
|
||||
ccl_global Ray *Ray_coop, /* Required for setting up ray for next iteration */
|
||||
ccl_global PathState *PathState_coop, /* Required for setting up ray for next iteration */
|
||||
ccl_global Ray *LightRay_dl_coop, /* Required for radiance update - direct lighting */
|
||||
ccl_global int *ISLamp_coop, /* Required for radiance update - direct lighting */
|
||||
ccl_global BsdfEval *BSDFEval_coop, /* Required for radiance update - direct lighting */
|
||||
ccl_global Ray *LightRay_ao_coop, /* Required for radiance update - AO */
|
||||
ccl_global float3 *AOBSDF_coop, /* Required for radiance update - AO */
|
||||
ccl_global float3 *AOAlpha_coop, /* Required for radiance update - AO */
|
||||
ccl_global char *ray_state, /* Denotes the state of each ray */
|
||||
ccl_global int *Queue_data, /* Queue memory */
|
||||
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
|
||||
int queuesize, /* Size (capacity) of each queue */
|
||||
ccl_global char *use_queues_flag /* flag to decide if scene_intersect kernel should use queues to fetch ray index */
|
||||
)
|
||||
{
|
||||
|
||||
ccl_local unsigned int local_queue_atomics;
|
||||
if(get_local_id(0) == 0 && get_local_id(1) == 0) {
|
||||
local_queue_atomics = 0;
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
if(get_global_id(0) == 0 && get_global_id(1) == 0) {
|
||||
/* If we are here, then it means that scene-intersect kernel
|
||||
* has already been executed atleast once. From the next time,
|
||||
* scene-intersect kernel may operate on queues to fetch ray index
|
||||
*/
|
||||
use_queues_flag[0] = 1;
|
||||
|
||||
/* Mark queue indices of QUEUE_SHADOW_RAY_CAST_AO_RAYS and QUEUE_SHADOW_RAY_CAST_DL_RAYS
|
||||
* queues that were made empty during the previous kernel
|
||||
*/
|
||||
Queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS] = 0;
|
||||
Queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS] = 0;
|
||||
}
|
||||
|
||||
char enqueue_flag = 0;
|
||||
int ray_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
|
||||
ray_index = get_ray_index(ray_index, QUEUE_ACTIVE_AND_REGENERATED_RAYS, Queue_data, queuesize, 0);
|
||||
|
||||
#ifdef __COMPUTE_DEVICE_GPU__
|
||||
/* If we are executing on a GPU device, we exit all threads that are not required
|
||||
* If we are executing on a CPU device, then we need to keep all threads active
|
||||
* since we have barrier() calls later in the kernel. CPU devices,
|
||||
* expect all threads to execute barrier statement.
|
||||
*/
|
||||
if(ray_index == QUEUE_EMPTY_SLOT)
|
||||
return;
|
||||
#endif
|
||||
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
if(ray_index != QUEUE_EMPTY_SLOT) {
|
||||
#endif
|
||||
/* Load kernel globals structure and ShaderData structure */
|
||||
KernelGlobals *kg = (KernelGlobals *)globals;
|
||||
ShaderData *sd = (ShaderData *)shader_data;
|
||||
PathRadiance *L = 0x0;
|
||||
ccl_global PathState *state = 0x0;
|
||||
|
||||
/* Path radiance update for AO/Direct_lighting's shadow blocked */
|
||||
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL) || IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO)) {
|
||||
state = &PathState_coop[ray_index];
|
||||
L = &PathRadiance_coop[ray_index];
|
||||
float3 _throughput = throughput_coop[ray_index];
|
||||
|
||||
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO)) {
|
||||
float3 shadow = LightRay_ao_coop[ray_index].P;
|
||||
char update_path_radiance = LightRay_ao_coop[ray_index].t;
|
||||
if(update_path_radiance) {
|
||||
path_radiance_accum_ao(L, _throughput, AOAlpha_coop[ray_index], AOBSDF_coop[ray_index], shadow, state->bounce);
|
||||
}
|
||||
REMOVE_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO);
|
||||
}
|
||||
|
||||
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL)) {
|
||||
float3 shadow = LightRay_dl_coop[ray_index].P;
|
||||
char update_path_radiance = LightRay_dl_coop[ray_index].t;
|
||||
if(update_path_radiance) {
|
||||
BsdfEval L_light = BSDFEval_coop[ray_index];
|
||||
path_radiance_accum_light(L, _throughput, &L_light, shadow, 1.0f, state->bounce, ISLamp_coop[ray_index]);
|
||||
}
|
||||
REMOVE_RAY_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL);
|
||||
}
|
||||
}
|
||||
|
||||
if(IS_STATE(ray_state, ray_index, RAY_ACTIVE)) {
|
||||
|
||||
ccl_global float3 *throughput = &throughput_coop[ray_index];
|
||||
ccl_global Ray *ray = &Ray_coop[ray_index];
|
||||
ccl_global RNG* rng = &rng_coop[ray_index];
|
||||
state = &PathState_coop[ray_index];
|
||||
L = &PathRadiance_coop[ray_index];
|
||||
|
||||
/* compute direct lighting and next bounce */
|
||||
if(!kernel_path_surface_bounce(kg, rng, sd, throughput, state, L, ray)) {
|
||||
ASSIGN_RAY_STATE(ray_state, ray_index, RAY_UPDATE_BUFFER);
|
||||
enqueue_flag = 1;
|
||||
}
|
||||
}
|
||||
#ifndef __COMPUTE_DEVICE_GPU__
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enqueue RAY_UPDATE_BUFFER rays */
|
||||
enqueue_ray_index_local(ray_index, QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS, enqueue_flag, queuesize, &local_queue_atomics, Queue_data, Queue_index);
|
||||
}
|
@@ -324,43 +324,6 @@ ccl_device void kernel_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *
|
||||
}
|
||||
}
|
||||
|
||||
ccl_device void kernel_branched_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput)
|
||||
{
|
||||
int num_samples = kernel_data.integrator.ao_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
float ao_factor = kernel_data.background.ao_factor;
|
||||
float3 ao_N;
|
||||
float3 ao_bsdf = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
|
||||
float3 ao_alpha = shader_bsdf_alpha(kg, sd);
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
float bsdf_u, bsdf_v;
|
||||
path_branched_rng_2D(kg, rng, state, j, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
|
||||
|
||||
float3 ao_D;
|
||||
float ao_pdf;
|
||||
|
||||
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
|
||||
|
||||
if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
|
||||
Ray light_ray;
|
||||
float3 ao_shadow;
|
||||
|
||||
light_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
|
||||
light_ray.D = ao_D;
|
||||
light_ray.t = kernel_data.background.ao_distance;
|
||||
#ifdef __OBJECT_MOTION__
|
||||
light_ray.time = ccl_fetch(sd, time);
|
||||
#endif
|
||||
light_ray.dP = ccl_fetch(sd, dP);
|
||||
light_ray.dD = differential3_zero();
|
||||
|
||||
if(!shadow_blocked(kg, state, &light_ray, &ao_shadow))
|
||||
path_radiance_accum_ao(L, throughput*num_samples_inv, ao_alpha, ao_bsdf, ao_shadow, state->bounce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __SUBSURFACE__
|
||||
|
||||
ccl_device bool kernel_path_subsurface_scatter(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, Ray *ray, float3 *throughput)
|
||||
@@ -476,7 +439,9 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
if(state.flag & PATH_RAY_CAMERA) {
|
||||
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
|
||||
debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||
}
|
||||
debug_data.num_ray_bounces++;
|
||||
#endif
|
||||
|
||||
#ifdef __LAMP_MIS__
|
||||
@@ -706,444 +671,6 @@ ccl_device float4 kernel_path_integrate(KernelGlobals *kg, RNG *rng, int sample,
|
||||
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
|
||||
}
|
||||
|
||||
#ifdef __BRANCHED_PATH__
|
||||
|
||||
/* branched path tracing: bounce off surface and integrate indirect light */
|
||||
ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGlobals *kg,
|
||||
RNG *rng, ShaderData *sd, float3 throughput, float num_samples_adjust,
|
||||
PathState *state, PathRadiance *L)
|
||||
{
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
const ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
|
||||
|
||||
if(!CLOSURE_IS_BSDF(sc->type))
|
||||
continue;
|
||||
/* transparency is not handled here, but in outer loop */
|
||||
if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID)
|
||||
continue;
|
||||
|
||||
int num_samples;
|
||||
|
||||
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
|
||||
num_samples = kernel_data.integrator.diffuse_samples;
|
||||
else if(CLOSURE_IS_BSDF_BSSRDF(sc->type))
|
||||
num_samples = 1;
|
||||
else if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
|
||||
num_samples = kernel_data.integrator.glossy_samples;
|
||||
else
|
||||
num_samples = kernel_data.integrator.transmission_samples;
|
||||
|
||||
num_samples = ceil_to_int(num_samples_adjust*num_samples);
|
||||
|
||||
float num_samples_inv = num_samples_adjust/num_samples;
|
||||
RNG bsdf_rng = cmj_hash(*rng, i);
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
PathState ps = *state;
|
||||
float3 tp = throughput;
|
||||
Ray bsdf_ray;
|
||||
|
||||
if(!kernel_branched_path_surface_bounce(kg, &bsdf_rng, sd, sc, j, num_samples, &tp, &ps, L, &bsdf_ray))
|
||||
continue;
|
||||
|
||||
kernel_path_indirect(kg, rng, bsdf_ray, tp*num_samples_inv, num_samples, ps, L);
|
||||
|
||||
/* for render passes, sum and reset indirect light pass variables
|
||||
* for the next samples */
|
||||
path_radiance_sum_indirect(L);
|
||||
path_radiance_reset_indirect(L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __SUBSURFACE__
|
||||
ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
|
||||
ShaderData *sd,
|
||||
PathRadiance *L,
|
||||
PathState *state,
|
||||
RNG *rng,
|
||||
Ray *ray,
|
||||
float3 throughput)
|
||||
{
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
|
||||
|
||||
if(!CLOSURE_IS_BSSRDF(sc->type))
|
||||
continue;
|
||||
|
||||
/* set up random number generator */
|
||||
uint lcg_state = lcg_state_init(rng, state, 0x68bc21eb);
|
||||
int num_samples = kernel_data.integrator.subsurface_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
RNG bssrdf_rng = cmj_hash(*rng, i);
|
||||
|
||||
/* do subsurface scatter step with copy of shader data, this will
|
||||
* replace the BSSRDF with a diffuse BSDF closure */
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
|
||||
float bssrdf_u, bssrdf_v;
|
||||
path_branched_rng_2D(kg, &bssrdf_rng, state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
|
||||
int num_hits = subsurface_scatter_multi_step(kg, sd, bssrdf_sd, state->flag, sc, &lcg_state, bssrdf_u, bssrdf_v, true);
|
||||
#ifdef __VOLUME__
|
||||
Ray volume_ray = *ray;
|
||||
bool need_update_volume_stack = kernel_data.integrator.use_volumes &&
|
||||
ccl_fetch(sd, flag) & SD_OBJECT_INTERSECTS_VOLUME;
|
||||
#endif
|
||||
|
||||
/* compute lighting with the BSDF closure */
|
||||
for(int hit = 0; hit < num_hits; hit++) {
|
||||
PathState hit_state = *state;
|
||||
|
||||
path_state_branch(&hit_state, j, num_samples);
|
||||
|
||||
#ifdef __VOLUME__
|
||||
if(need_update_volume_stack) {
|
||||
/* Setup ray from previous surface point to the new one. */
|
||||
float3 P = ray_offset(bssrdf_sd[hit].P, -bssrdf_sd[hit].Ng);
|
||||
volume_ray.D = normalize_len(P - volume_ray.P,
|
||||
&volume_ray.t);
|
||||
|
||||
kernel_volume_stack_update_for_subsurface(
|
||||
kg,
|
||||
&volume_ray,
|
||||
hit_state.volume_stack);
|
||||
|
||||
/* Move volume ray forward. */
|
||||
volume_ray.P = P;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__EMISSION__) && defined(__BRANCHED_PATH__)
|
||||
/* direct light */
|
||||
if(kernel_data.integrator.use_direct_light) {
|
||||
bool all = kernel_data.integrator.sample_all_lights_direct;
|
||||
kernel_branched_path_surface_connect_light(kg, rng,
|
||||
&bssrdf_sd[hit], &hit_state, throughput, num_samples_inv, L, all);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* indirect light */
|
||||
kernel_branched_path_surface_indirect_light(kg, rng,
|
||||
&bssrdf_sd[hit], throughput, num_samples_inv,
|
||||
&hit_state, L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
|
||||
{
|
||||
/* initialize */
|
||||
PathRadiance L;
|
||||
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
|
||||
float L_transparent = 0.0f;
|
||||
|
||||
path_radiance_init(&L, kernel_data.film.use_light_pass);
|
||||
|
||||
PathState state;
|
||||
path_state_init(kg, &state, rng, sample, &ray);
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData debug_data;
|
||||
debug_data_init(&debug_data);
|
||||
#endif
|
||||
|
||||
for(;;) {
|
||||
/* intersect scene */
|
||||
Intersection isect;
|
||||
uint visibility = path_state_ray_visibility(kg, &state);
|
||||
|
||||
#ifdef __HAIR__
|
||||
float difl = 0.0f, extmax = 0.0f;
|
||||
uint lcg_state = 0;
|
||||
|
||||
if(kernel_data.bvh.have_curves) {
|
||||
if((kernel_data.cam.resolution == 1) && (state.flag & PATH_RAY_CAMERA)) {
|
||||
float3 pixdiff = ray.dD.dx + ray.dD.dy;
|
||||
/*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
|
||||
difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
|
||||
}
|
||||
|
||||
extmax = kernel_data.curve.maximum_width;
|
||||
lcg_state = lcg_state_init(rng, &state, 0x51633e2d);
|
||||
}
|
||||
|
||||
bool hit = scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax);
|
||||
#else
|
||||
bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f, 0.0f);
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
if(state.flag & PATH_RAY_CAMERA) {
|
||||
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __VOLUME__
|
||||
/* volume attenuation, emission, scatter */
|
||||
if(state.volume_stack[0].shader != SHADER_NONE) {
|
||||
Ray volume_ray = ray;
|
||||
volume_ray.t = (hit)? isect.t: FLT_MAX;
|
||||
|
||||
bool heterogeneous = volume_stack_is_heterogeneous(kg, state.volume_stack);
|
||||
|
||||
#ifdef __VOLUME_DECOUPLED__
|
||||
/* decoupled ray marching only supported on CPU */
|
||||
|
||||
/* cache steps along volume for repeated sampling */
|
||||
VolumeSegment volume_segment;
|
||||
ShaderData volume_sd;
|
||||
|
||||
shader_setup_from_volume(kg, &volume_sd, &volume_ray, state.bounce, state.transparent_bounce);
|
||||
kernel_volume_decoupled_record(kg, &state,
|
||||
&volume_ray, &volume_sd, &volume_segment, heterogeneous);
|
||||
|
||||
/* direct light sampling */
|
||||
if(volume_segment.closure_flag & SD_SCATTER) {
|
||||
volume_segment.sampling_method = volume_stack_sampling_method(kg, state.volume_stack);
|
||||
|
||||
bool all = kernel_data.integrator.sample_all_lights_direct;
|
||||
|
||||
kernel_branched_path_volume_connect_light(kg, rng, &volume_sd,
|
||||
throughput, &state, &L, all, &volume_ray, &volume_segment);
|
||||
|
||||
/* indirect light sampling */
|
||||
int num_samples = kernel_data.integrator.volume_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
/* workaround to fix correlation bug in T38710, can find better solution
|
||||
* in random number generator later, for now this is done here to not impact
|
||||
* performance of rendering without volumes */
|
||||
RNG tmp_rng = cmj_hash(*rng, state.rng_offset);
|
||||
|
||||
PathState ps = state;
|
||||
Ray pray = ray;
|
||||
float3 tp = throughput;
|
||||
|
||||
/* branch RNG state */
|
||||
path_state_branch(&ps, j, num_samples);
|
||||
|
||||
/* scatter sample. if we use distance sampling and take just one
|
||||
* sample for direct and indirect light, we could share this
|
||||
* computation, but makes code a bit complex */
|
||||
float rphase = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_PHASE);
|
||||
float rscatter = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_SCATTER_DISTANCE);
|
||||
|
||||
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
|
||||
&ps, &pray, &volume_sd, &tp, rphase, rscatter, &volume_segment, NULL, false);
|
||||
|
||||
(void)result;
|
||||
kernel_assert(result == VOLUME_PATH_SCATTERED);
|
||||
|
||||
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
|
||||
kernel_path_indirect(kg, rng, pray, tp*num_samples_inv, num_samples, ps, &L);
|
||||
|
||||
/* for render passes, sum and reset indirect light pass variables
|
||||
* for the next samples */
|
||||
path_radiance_sum_indirect(&L);
|
||||
path_radiance_reset_indirect(&L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* emission and transmittance */
|
||||
if(volume_segment.closure_flag & SD_EMISSION)
|
||||
path_radiance_accum_emission(&L, throughput, volume_segment.accum_emission, state.bounce);
|
||||
throughput *= volume_segment.accum_transmittance;
|
||||
|
||||
/* free cached steps */
|
||||
kernel_volume_decoupled_free(kg, &volume_segment);
|
||||
#else
|
||||
/* GPU: no decoupled ray marching, scatter probalistically */
|
||||
int num_samples = kernel_data.integrator.volume_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
|
||||
/* todo: we should cache the shader evaluations from stepping
|
||||
* through the volume, for now we redo them multiple times */
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
PathState ps = state;
|
||||
Ray pray = ray;
|
||||
ShaderData volume_sd;
|
||||
float3 tp = throughput * num_samples_inv;
|
||||
|
||||
/* branch RNG state */
|
||||
path_state_branch(&ps, j, num_samples);
|
||||
|
||||
VolumeIntegrateResult result = kernel_volume_integrate(
|
||||
kg, &ps, &volume_sd, &volume_ray, &L, &tp, rng, heterogeneous);
|
||||
|
||||
#ifdef __VOLUME_SCATTER__
|
||||
if(result == VOLUME_PATH_SCATTERED) {
|
||||
/* todo: support equiangular, MIS and all light sampling.
|
||||
* alternatively get decoupled ray marching working on the GPU */
|
||||
kernel_path_volume_connect_light(kg, rng, &volume_sd, tp, &state, &L);
|
||||
|
||||
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
|
||||
kernel_path_indirect(kg, rng, pray, tp, num_samples, ps, &L);
|
||||
|
||||
/* for render passes, sum and reset indirect light pass variables
|
||||
* for the next samples */
|
||||
path_radiance_sum_indirect(&L);
|
||||
path_radiance_reset_indirect(&L);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* todo: avoid this calculation using decoupled ray marching */
|
||||
kernel_volume_shadow(kg, &state, &volume_ray, &throughput);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!hit) {
|
||||
/* eval background shader if nothing hit */
|
||||
if(kernel_data.background.transparent) {
|
||||
L_transparent += average(throughput);
|
||||
|
||||
#ifdef __PASSES__
|
||||
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __BACKGROUND__
|
||||
/* sample background shader */
|
||||
float3 L_background = indirect_background(kg, &state, &ray);
|
||||
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* setup shading */
|
||||
ShaderData sd;
|
||||
shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce, state.transparent_bounce);
|
||||
shader_eval_surface(kg, &sd, 0.0f, state.flag, SHADER_CONTEXT_MAIN);
|
||||
shader_merge_closures(&sd);
|
||||
|
||||
/* holdout */
|
||||
#ifdef __HOLDOUT__
|
||||
if(sd.flag & (SD_HOLDOUT|SD_HOLDOUT_MASK)) {
|
||||
if(kernel_data.background.transparent) {
|
||||
float3 holdout_weight;
|
||||
|
||||
if(sd.flag & SD_HOLDOUT_MASK)
|
||||
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
|
||||
else
|
||||
holdout_weight = shader_holdout_eval(kg, &sd);
|
||||
|
||||
/* any throughput is ok, should all be identical here */
|
||||
L_transparent += average(holdout_weight*throughput);
|
||||
}
|
||||
|
||||
if(sd.flag & SD_HOLDOUT_MASK)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* holdout mask objects do not write data passes */
|
||||
kernel_write_data_passes(kg, buffer, &L, &sd, sample, &state, throughput);
|
||||
|
||||
#ifdef __EMISSION__
|
||||
/* emission */
|
||||
if(sd.flag & SD_EMISSION) {
|
||||
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
|
||||
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* transparency termination */
|
||||
if(state.flag & PATH_RAY_TRANSPARENT) {
|
||||
/* path termination. this is a strange place to put the termination, it's
|
||||
* mainly due to the mixed in MIS that we use. gives too many unneeded
|
||||
* shader evaluations, only need emission if we are going to terminate */
|
||||
float probability = path_state_terminate_probability(kg, &state, throughput);
|
||||
|
||||
if(probability == 0.0f) {
|
||||
break;
|
||||
}
|
||||
else if(probability != 1.0f) {
|
||||
float terminate = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_TERMINATE);
|
||||
|
||||
if(terminate >= probability)
|
||||
break;
|
||||
|
||||
throughput /= probability;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __AO__
|
||||
/* ambient occlusion */
|
||||
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
|
||||
kernel_branched_path_ao(kg, &sd, &L, &state, rng, throughput);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __SUBSURFACE__
|
||||
/* bssrdf scatter to a different location on the same object */
|
||||
if(sd.flag & SD_BSSRDF) {
|
||||
kernel_branched_path_subsurface_scatter(kg, &sd, &L, &state,
|
||||
rng, &ray, throughput);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
|
||||
PathState hit_state = state;
|
||||
|
||||
#ifdef __EMISSION__
|
||||
/* direct light */
|
||||
if(kernel_data.integrator.use_direct_light) {
|
||||
bool all = kernel_data.integrator.sample_all_lights_direct;
|
||||
kernel_branched_path_surface_connect_light(kg, rng,
|
||||
&sd, &hit_state, throughput, 1.0f, &L, all);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* indirect light */
|
||||
kernel_branched_path_surface_indirect_light(kg, rng,
|
||||
&sd, throughput, 1.0f, &hit_state, &L);
|
||||
|
||||
/* continue in case of transparency */
|
||||
throughput *= shader_bsdf_transparency(kg, &sd);
|
||||
|
||||
if(is_zero(throughput))
|
||||
break;
|
||||
}
|
||||
|
||||
path_state_next(kg, &state, LABEL_TRANSPARENT);
|
||||
ray.P = ray_offset(sd.P, -sd.Ng);
|
||||
ray.t -= sd.ray_length; /* clipping works through transparent */
|
||||
|
||||
|
||||
#ifdef __RAY_DIFFERENTIALS__
|
||||
ray.dP = sd.dP;
|
||||
ray.dD.dx = -sd.dI.dx;
|
||||
ray.dD.dy = -sd.dI.dy;
|
||||
#endif
|
||||
|
||||
#ifdef __VOLUME__
|
||||
/* enter/exit volume */
|
||||
kernel_volume_stack_enter_exit(kg, &sd, state.volume_stack);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 L_sum = path_radiance_clamp_and_sum(kg, &L);
|
||||
|
||||
kernel_write_light_passes(kg, buffer, &L, sample);
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
|
||||
#endif
|
||||
|
||||
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ccl_device void kernel_path_trace(KernelGlobals *kg,
|
||||
ccl_global float *buffer, ccl_global uint *rng_state,
|
||||
int sample, int x, int y, int offset, int stride)
|
||||
@@ -1175,38 +702,5 @@ ccl_device void kernel_path_trace(KernelGlobals *kg,
|
||||
path_rng_end(kg, rng_state, rng);
|
||||
}
|
||||
|
||||
#ifdef __BRANCHED_PATH__
|
||||
ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
|
||||
ccl_global float *buffer, ccl_global uint *rng_state,
|
||||
int sample, int x, int y, int offset, int stride)
|
||||
{
|
||||
/* buffer offset */
|
||||
int index = offset + x + y*stride;
|
||||
int pass_stride = kernel_data.film.pass_stride;
|
||||
|
||||
rng_state += index;
|
||||
buffer += index*pass_stride;
|
||||
|
||||
/* initialize random numbers and ray */
|
||||
RNG rng;
|
||||
Ray ray;
|
||||
|
||||
kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray);
|
||||
|
||||
/* integrate */
|
||||
float4 L;
|
||||
|
||||
if(ray.t != 0.0f)
|
||||
L = kernel_branched_path_integrate(kg, &rng, sample, ray, buffer);
|
||||
else
|
||||
L = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
/* accumulate result in output buffer */
|
||||
kernel_write_pass_float4(buffer, sample, L);
|
||||
|
||||
path_rng_end(kg, rng_state, rng);
|
||||
}
|
||||
#endif
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
||||
|
534
intern/cycles/kernel/kernel_path_branched.h
Normal file
534
intern/cycles/kernel/kernel_path_branched.h
Normal file
@@ -0,0 +1,534 @@
|
||||
/*
|
||||
* Copyright 2011-2013 Blender Foundation
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
||||
|
||||
#ifdef __BRANCHED_PATH__
|
||||
|
||||
ccl_device void kernel_branched_path_ao(KernelGlobals *kg, ShaderData *sd, PathRadiance *L, PathState *state, RNG *rng, float3 throughput)
|
||||
{
|
||||
int num_samples = kernel_data.integrator.ao_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
float ao_factor = kernel_data.background.ao_factor;
|
||||
float3 ao_N;
|
||||
float3 ao_bsdf = shader_bsdf_ao(kg, sd, ao_factor, &ao_N);
|
||||
float3 ao_alpha = shader_bsdf_alpha(kg, sd);
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
float bsdf_u, bsdf_v;
|
||||
path_branched_rng_2D(kg, rng, state, j, num_samples, PRNG_BSDF_U, &bsdf_u, &bsdf_v);
|
||||
|
||||
float3 ao_D;
|
||||
float ao_pdf;
|
||||
|
||||
sample_cos_hemisphere(ao_N, bsdf_u, bsdf_v, &ao_D, &ao_pdf);
|
||||
|
||||
if(dot(ccl_fetch(sd, Ng), ao_D) > 0.0f && ao_pdf != 0.0f) {
|
||||
Ray light_ray;
|
||||
float3 ao_shadow;
|
||||
|
||||
light_ray.P = ray_offset(ccl_fetch(sd, P), ccl_fetch(sd, Ng));
|
||||
light_ray.D = ao_D;
|
||||
light_ray.t = kernel_data.background.ao_distance;
|
||||
#ifdef __OBJECT_MOTION__
|
||||
light_ray.time = ccl_fetch(sd, time);
|
||||
#endif
|
||||
light_ray.dP = ccl_fetch(sd, dP);
|
||||
light_ray.dD = differential3_zero();
|
||||
|
||||
if(!shadow_blocked(kg, state, &light_ray, &ao_shadow))
|
||||
path_radiance_accum_ao(L, throughput*num_samples_inv, ao_alpha, ao_bsdf, ao_shadow, state->bounce);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* bounce off surface and integrate indirect light */
|
||||
ccl_device_noinline void kernel_branched_path_surface_indirect_light(KernelGlobals *kg,
|
||||
RNG *rng, ShaderData *sd, float3 throughput, float num_samples_adjust,
|
||||
PathState *state, PathRadiance *L)
|
||||
{
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
const ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
|
||||
|
||||
if(!CLOSURE_IS_BSDF(sc->type))
|
||||
continue;
|
||||
/* transparency is not handled here, but in outer loop */
|
||||
if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID)
|
||||
continue;
|
||||
|
||||
int num_samples;
|
||||
|
||||
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
|
||||
num_samples = kernel_data.integrator.diffuse_samples;
|
||||
else if(CLOSURE_IS_BSDF_BSSRDF(sc->type))
|
||||
num_samples = 1;
|
||||
else if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
|
||||
num_samples = kernel_data.integrator.glossy_samples;
|
||||
else
|
||||
num_samples = kernel_data.integrator.transmission_samples;
|
||||
|
||||
num_samples = ceil_to_int(num_samples_adjust*num_samples);
|
||||
|
||||
float num_samples_inv = num_samples_adjust/num_samples;
|
||||
RNG bsdf_rng = cmj_hash(*rng, i);
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
PathState ps = *state;
|
||||
float3 tp = throughput;
|
||||
Ray bsdf_ray;
|
||||
|
||||
if(!kernel_branched_path_surface_bounce(kg, &bsdf_rng, sd, sc, j, num_samples, &tp, &ps, L, &bsdf_ray))
|
||||
continue;
|
||||
|
||||
kernel_path_indirect(kg, rng, bsdf_ray, tp*num_samples_inv, num_samples, ps, L);
|
||||
|
||||
/* for render passes, sum and reset indirect light pass variables
|
||||
* for the next samples */
|
||||
path_radiance_sum_indirect(L);
|
||||
path_radiance_reset_indirect(L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __SUBSURFACE__
|
||||
ccl_device void kernel_branched_path_subsurface_scatter(KernelGlobals *kg,
|
||||
ShaderData *sd,
|
||||
PathRadiance *L,
|
||||
PathState *state,
|
||||
RNG *rng,
|
||||
Ray *ray,
|
||||
float3 throughput)
|
||||
{
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = &ccl_fetch(sd, closure)[i];
|
||||
|
||||
if(!CLOSURE_IS_BSSRDF(sc->type))
|
||||
continue;
|
||||
|
||||
/* set up random number generator */
|
||||
uint lcg_state = lcg_state_init(rng, state, 0x68bc21eb);
|
||||
int num_samples = kernel_data.integrator.subsurface_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
RNG bssrdf_rng = cmj_hash(*rng, i);
|
||||
|
||||
/* do subsurface scatter step with copy of shader data, this will
|
||||
* replace the BSSRDF with a diffuse BSDF closure */
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
ShaderData bssrdf_sd[BSSRDF_MAX_HITS];
|
||||
float bssrdf_u, bssrdf_v;
|
||||
path_branched_rng_2D(kg, &bssrdf_rng, state, j, num_samples, PRNG_BSDF_U, &bssrdf_u, &bssrdf_v);
|
||||
int num_hits = subsurface_scatter_multi_step(kg, sd, bssrdf_sd, state->flag, sc, &lcg_state, bssrdf_u, bssrdf_v, true);
|
||||
#ifdef __VOLUME__
|
||||
Ray volume_ray = *ray;
|
||||
bool need_update_volume_stack = kernel_data.integrator.use_volumes &&
|
||||
ccl_fetch(sd, flag) & SD_OBJECT_INTERSECTS_VOLUME;
|
||||
#endif
|
||||
|
||||
/* compute lighting with the BSDF closure */
|
||||
for(int hit = 0; hit < num_hits; hit++) {
|
||||
PathState hit_state = *state;
|
||||
|
||||
path_state_branch(&hit_state, j, num_samples);
|
||||
|
||||
#ifdef __VOLUME__
|
||||
if(need_update_volume_stack) {
|
||||
/* Setup ray from previous surface point to the new one. */
|
||||
float3 P = ray_offset(bssrdf_sd[hit].P, -bssrdf_sd[hit].Ng);
|
||||
volume_ray.D = normalize_len(P - volume_ray.P,
|
||||
&volume_ray.t);
|
||||
|
||||
kernel_volume_stack_update_for_subsurface(
|
||||
kg,
|
||||
&volume_ray,
|
||||
hit_state.volume_stack);
|
||||
|
||||
/* Move volume ray forward. */
|
||||
volume_ray.P = P;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __EMISSION__
|
||||
/* direct light */
|
||||
if(kernel_data.integrator.use_direct_light) {
|
||||
bool all = kernel_data.integrator.sample_all_lights_direct;
|
||||
kernel_branched_path_surface_connect_light(kg, rng,
|
||||
&bssrdf_sd[hit], &hit_state, throughput, num_samples_inv, L, all);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* indirect light */
|
||||
kernel_branched_path_surface_indirect_light(kg, rng,
|
||||
&bssrdf_sd[hit], throughput, num_samples_inv,
|
||||
&hit_state, L);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ccl_device float4 kernel_branched_path_integrate(KernelGlobals *kg, RNG *rng, int sample, Ray ray, ccl_global float *buffer)
|
||||
{
|
||||
/* initialize */
|
||||
PathRadiance L;
|
||||
float3 throughput = make_float3(1.0f, 1.0f, 1.0f);
|
||||
float L_transparent = 0.0f;
|
||||
|
||||
path_radiance_init(&L, kernel_data.film.use_light_pass);
|
||||
|
||||
PathState state;
|
||||
path_state_init(kg, &state, rng, sample, &ray);
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
DebugData debug_data;
|
||||
debug_data_init(&debug_data);
|
||||
#endif
|
||||
|
||||
/* Main Loop
|
||||
* Here we only handle transparency intersections from the camera ray.
|
||||
* Indirect bounces are handled in kernel_branched_path_surface_indirect_light().
|
||||
*/
|
||||
for(;;) {
|
||||
/* intersect scene */
|
||||
Intersection isect;
|
||||
uint visibility = path_state_ray_visibility(kg, &state);
|
||||
|
||||
#ifdef __HAIR__
|
||||
float difl = 0.0f, extmax = 0.0f;
|
||||
uint lcg_state = 0;
|
||||
|
||||
if(kernel_data.bvh.have_curves) {
|
||||
if(kernel_data.cam.resolution == 1) {
|
||||
float3 pixdiff = ray.dD.dx + ray.dD.dy;
|
||||
/*pixdiff = pixdiff - dot(pixdiff, ray.D)*ray.D;*/
|
||||
difl = kernel_data.curve.minimum_width * len(pixdiff) * 0.5f;
|
||||
}
|
||||
|
||||
extmax = kernel_data.curve.maximum_width;
|
||||
lcg_state = lcg_state_init(rng, &state, 0x51633e2d);
|
||||
}
|
||||
|
||||
bool hit = scene_intersect(kg, &ray, visibility, &isect, &lcg_state, difl, extmax);
|
||||
#else
|
||||
bool hit = scene_intersect(kg, &ray, visibility, &isect, NULL, 0.0f, 0.0f);
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
debug_data.num_bvh_traversal_steps += isect.num_traversal_steps;
|
||||
debug_data.num_bvh_traversed_instances += isect.num_traversed_instances;
|
||||
debug_data.num_ray_bounces++;
|
||||
#endif
|
||||
|
||||
#ifdef __VOLUME__
|
||||
/* volume attenuation, emission, scatter */
|
||||
if(state.volume_stack[0].shader != SHADER_NONE) {
|
||||
Ray volume_ray = ray;
|
||||
volume_ray.t = (hit)? isect.t: FLT_MAX;
|
||||
|
||||
bool heterogeneous = volume_stack_is_heterogeneous(kg, state.volume_stack);
|
||||
|
||||
#ifdef __VOLUME_DECOUPLED__
|
||||
/* decoupled ray marching only supported on CPU */
|
||||
|
||||
/* cache steps along volume for repeated sampling */
|
||||
VolumeSegment volume_segment;
|
||||
ShaderData volume_sd;
|
||||
|
||||
shader_setup_from_volume(kg, &volume_sd, &volume_ray, state.bounce, state.transparent_bounce);
|
||||
kernel_volume_decoupled_record(kg, &state,
|
||||
&volume_ray, &volume_sd, &volume_segment, heterogeneous);
|
||||
|
||||
/* direct light sampling */
|
||||
if(volume_segment.closure_flag & SD_SCATTER) {
|
||||
volume_segment.sampling_method = volume_stack_sampling_method(kg, state.volume_stack);
|
||||
|
||||
bool all = kernel_data.integrator.sample_all_lights_direct;
|
||||
|
||||
kernel_branched_path_volume_connect_light(kg, rng, &volume_sd,
|
||||
throughput, &state, &L, all, &volume_ray, &volume_segment);
|
||||
|
||||
/* indirect light sampling */
|
||||
int num_samples = kernel_data.integrator.volume_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
/* workaround to fix correlation bug in T38710, can find better solution
|
||||
* in random number generator later, for now this is done here to not impact
|
||||
* performance of rendering without volumes */
|
||||
RNG tmp_rng = cmj_hash(*rng, state.rng_offset);
|
||||
|
||||
PathState ps = state;
|
||||
Ray pray = ray;
|
||||
float3 tp = throughput;
|
||||
|
||||
/* branch RNG state */
|
||||
path_state_branch(&ps, j, num_samples);
|
||||
|
||||
/* scatter sample. if we use distance sampling and take just one
|
||||
* sample for direct and indirect light, we could share this
|
||||
* computation, but makes code a bit complex */
|
||||
float rphase = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_PHASE);
|
||||
float rscatter = path_state_rng_1D_for_decision(kg, &tmp_rng, &ps, PRNG_SCATTER_DISTANCE);
|
||||
|
||||
VolumeIntegrateResult result = kernel_volume_decoupled_scatter(kg,
|
||||
&ps, &pray, &volume_sd, &tp, rphase, rscatter, &volume_segment, NULL, false);
|
||||
|
||||
(void)result;
|
||||
kernel_assert(result == VOLUME_PATH_SCATTERED);
|
||||
|
||||
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
|
||||
kernel_path_indirect(kg, rng, pray, tp*num_samples_inv, num_samples, ps, &L);
|
||||
|
||||
/* for render passes, sum and reset indirect light pass variables
|
||||
* for the next samples */
|
||||
path_radiance_sum_indirect(&L);
|
||||
path_radiance_reset_indirect(&L);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* emission and transmittance */
|
||||
if(volume_segment.closure_flag & SD_EMISSION)
|
||||
path_radiance_accum_emission(&L, throughput, volume_segment.accum_emission, state.bounce);
|
||||
throughput *= volume_segment.accum_transmittance;
|
||||
|
||||
/* free cached steps */
|
||||
kernel_volume_decoupled_free(kg, &volume_segment);
|
||||
#else
|
||||
/* GPU: no decoupled ray marching, scatter probalistically */
|
||||
int num_samples = kernel_data.integrator.volume_samples;
|
||||
float num_samples_inv = 1.0f/num_samples;
|
||||
|
||||
/* todo: we should cache the shader evaluations from stepping
|
||||
* through the volume, for now we redo them multiple times */
|
||||
|
||||
for(int j = 0; j < num_samples; j++) {
|
||||
PathState ps = state;
|
||||
Ray pray = ray;
|
||||
ShaderData volume_sd;
|
||||
float3 tp = throughput * num_samples_inv;
|
||||
|
||||
/* branch RNG state */
|
||||
path_state_branch(&ps, j, num_samples);
|
||||
|
||||
VolumeIntegrateResult result = kernel_volume_integrate(
|
||||
kg, &ps, &volume_sd, &volume_ray, &L, &tp, rng, heterogeneous);
|
||||
|
||||
#ifdef __VOLUME_SCATTER__
|
||||
if(result == VOLUME_PATH_SCATTERED) {
|
||||
/* todo: support equiangular, MIS and all light sampling.
|
||||
* alternatively get decoupled ray marching working on the GPU */
|
||||
kernel_path_volume_connect_light(kg, rng, &volume_sd, tp, &state, &L);
|
||||
|
||||
if(kernel_path_volume_bounce(kg, rng, &volume_sd, &tp, &ps, &L, &pray)) {
|
||||
kernel_path_indirect(kg, rng, pray, tp, num_samples, ps, &L);
|
||||
|
||||
/* for render passes, sum and reset indirect light pass variables
|
||||
* for the next samples */
|
||||
path_radiance_sum_indirect(&L);
|
||||
path_radiance_reset_indirect(&L);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/* todo: avoid this calculation using decoupled ray marching */
|
||||
kernel_volume_shadow(kg, &state, &volume_ray, &throughput);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!hit) {
|
||||
/* eval background shader if nothing hit */
|
||||
if(kernel_data.background.transparent) {
|
||||
L_transparent += average(throughput);
|
||||
|
||||
#ifdef __PASSES__
|
||||
if(!(kernel_data.film.pass_flag & PASS_BACKGROUND))
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __BACKGROUND__
|
||||
/* sample background shader */
|
||||
float3 L_background = indirect_background(kg, &state, &ray);
|
||||
path_radiance_accum_background(&L, throughput, L_background, state.bounce);
|
||||
#endif
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
/* setup shading */
|
||||
ShaderData sd;
|
||||
shader_setup_from_ray(kg, &sd, &isect, &ray, state.bounce, state.transparent_bounce);
|
||||
shader_eval_surface(kg, &sd, 0.0f, state.flag, SHADER_CONTEXT_MAIN);
|
||||
shader_merge_closures(&sd);
|
||||
|
||||
/* holdout */
|
||||
#ifdef __HOLDOUT__
|
||||
if(sd.flag & (SD_HOLDOUT|SD_HOLDOUT_MASK)) {
|
||||
if(kernel_data.background.transparent) {
|
||||
float3 holdout_weight;
|
||||
|
||||
if(sd.flag & SD_HOLDOUT_MASK)
|
||||
holdout_weight = make_float3(1.0f, 1.0f, 1.0f);
|
||||
else
|
||||
holdout_weight = shader_holdout_eval(kg, &sd);
|
||||
|
||||
/* any throughput is ok, should all be identical here */
|
||||
L_transparent += average(holdout_weight*throughput);
|
||||
}
|
||||
|
||||
if(sd.flag & SD_HOLDOUT_MASK)
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* holdout mask objects do not write data passes */
|
||||
kernel_write_data_passes(kg, buffer, &L, &sd, sample, &state, throughput);
|
||||
|
||||
#ifdef __EMISSION__
|
||||
/* emission */
|
||||
if(sd.flag & SD_EMISSION) {
|
||||
float3 emission = indirect_primitive_emission(kg, &sd, isect.t, state.flag, state.ray_pdf);
|
||||
path_radiance_accum_emission(&L, throughput, emission, state.bounce);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* transparency termination */
|
||||
if(state.flag & PATH_RAY_TRANSPARENT) {
|
||||
/* path termination. this is a strange place to put the termination, it's
|
||||
* mainly due to the mixed in MIS that we use. gives too many unneeded
|
||||
* shader evaluations, only need emission if we are going to terminate */
|
||||
float probability = path_state_terminate_probability(kg, &state, throughput);
|
||||
|
||||
if(probability == 0.0f) {
|
||||
break;
|
||||
}
|
||||
else if(probability != 1.0f) {
|
||||
float terminate = path_state_rng_1D_for_decision(kg, rng, &state, PRNG_TERMINATE);
|
||||
|
||||
if(terminate >= probability)
|
||||
break;
|
||||
|
||||
throughput /= probability;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __AO__
|
||||
/* ambient occlusion */
|
||||
if(kernel_data.integrator.use_ambient_occlusion || (sd.flag & SD_AO)) {
|
||||
kernel_branched_path_ao(kg, &sd, &L, &state, rng, throughput);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __SUBSURFACE__
|
||||
/* bssrdf scatter to a different location on the same object */
|
||||
if(sd.flag & SD_BSSRDF) {
|
||||
kernel_branched_path_subsurface_scatter(kg, &sd, &L, &state,
|
||||
rng, &ray, throughput);
|
||||
}
|
||||
#endif
|
||||
|
||||
if(!(sd.flag & SD_HAS_ONLY_VOLUME)) {
|
||||
PathState hit_state = state;
|
||||
|
||||
#ifdef __EMISSION__
|
||||
/* direct light */
|
||||
if(kernel_data.integrator.use_direct_light) {
|
||||
bool all = kernel_data.integrator.sample_all_lights_direct;
|
||||
kernel_branched_path_surface_connect_light(kg, rng,
|
||||
&sd, &hit_state, throughput, 1.0f, &L, all);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* indirect light */
|
||||
kernel_branched_path_surface_indirect_light(kg, rng,
|
||||
&sd, throughput, 1.0f, &hit_state, &L);
|
||||
|
||||
/* continue in case of transparency */
|
||||
throughput *= shader_bsdf_transparency(kg, &sd);
|
||||
|
||||
if(is_zero(throughput))
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update Path State */
|
||||
state.flag |= PATH_RAY_TRANSPARENT;
|
||||
state.transparent_bounce++;
|
||||
|
||||
ray.P = ray_offset(sd.P, -sd.Ng);
|
||||
ray.t -= sd.ray_length; /* clipping works through transparent */
|
||||
|
||||
|
||||
#ifdef __RAY_DIFFERENTIALS__
|
||||
ray.dP = sd.dP;
|
||||
ray.dD.dx = -sd.dI.dx;
|
||||
ray.dD.dy = -sd.dI.dy;
|
||||
#endif
|
||||
|
||||
#ifdef __VOLUME__
|
||||
/* enter/exit volume */
|
||||
kernel_volume_stack_enter_exit(kg, &sd, state.volume_stack);
|
||||
#endif
|
||||
}
|
||||
|
||||
float3 L_sum = path_radiance_clamp_and_sum(kg, &L);
|
||||
|
||||
kernel_write_light_passes(kg, buffer, &L, sample);
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
kernel_write_debug_passes(kg, buffer, &state, &debug_data, sample);
|
||||
#endif
|
||||
|
||||
return make_float4(L_sum.x, L_sum.y, L_sum.z, 1.0f - L_transparent);
|
||||
}
|
||||
|
||||
ccl_device void kernel_branched_path_trace(KernelGlobals *kg,
|
||||
ccl_global float *buffer, ccl_global uint *rng_state,
|
||||
int sample, int x, int y, int offset, int stride)
|
||||
{
|
||||
/* buffer offset */
|
||||
int index = offset + x + y*stride;
|
||||
int pass_stride = kernel_data.film.pass_stride;
|
||||
|
||||
rng_state += index;
|
||||
buffer += index*pass_stride;
|
||||
|
||||
/* initialize random numbers and ray */
|
||||
RNG rng;
|
||||
Ray ray;
|
||||
|
||||
kernel_path_trace_setup(kg, rng_state, sample, x, y, &rng, &ray);
|
||||
|
||||
/* integrate */
|
||||
float4 L;
|
||||
|
||||
if(ray.t != 0.0f)
|
||||
L = kernel_branched_path_integrate(kg, &rng, sample, ray, buffer);
|
||||
else
|
||||
L = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
|
||||
/* accumulate result in output buffer */
|
||||
kernel_write_pass_float4(buffer, sample, L);
|
||||
|
||||
path_rng_end(kg, rng_state, rng);
|
||||
}
|
||||
|
||||
#endif /* __BRANCHED_PATH__ */
|
||||
|
||||
CCL_NAMESPACE_END
|
||||
|
@@ -37,13 +37,13 @@ CCL_NAMESPACE_BEGIN
|
||||
#ifdef __OBJECT_MOTION__
|
||||
ccl_device void shader_setup_object_transforms(KernelGlobals *kg, ShaderData *sd, float time)
|
||||
{
|
||||
if(sd->flag & SD_OBJECT_MOTION) {
|
||||
sd->ob_tfm = object_fetch_transform_motion(kg, sd->object, time);
|
||||
sd->ob_itfm = transform_quick_inverse(sd->ob_tfm);
|
||||
if(ccl_fetch(sd, flag) & SD_OBJECT_MOTION) {
|
||||
ccl_fetch(sd, ob_tfm) = object_fetch_transform_motion(kg, ccl_fetch(sd, object), time);
|
||||
ccl_fetch(sd, ob_itfm) = transform_quick_inverse(ccl_fetch(sd, ob_tfm));
|
||||
}
|
||||
else {
|
||||
sd->ob_tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
||||
sd->ob_itfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
|
||||
ccl_fetch(sd, ob_tfm) = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_TRANSFORM);
|
||||
ccl_fetch(sd, ob_itfm) = object_fetch_transform(kg, ccl_fetch(sd, object), OBJECT_INVERSE_TRANSFORM);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -480,6 +480,7 @@ ccl_device void shader_merge_closures(ShaderData *sd)
|
||||
}
|
||||
|
||||
sd->num_closure--;
|
||||
kernel_assert(sd->num_closure >= 0);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
@@ -493,7 +494,7 @@ ccl_device_inline void _shader_bsdf_multi_eval(KernelGlobals *kg, const ShaderDa
|
||||
{
|
||||
/* this is the veach one-sample model with balance heuristic, some pdf
|
||||
* factors drop out when using balance heuristic weighting */
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
if(i == skip_bsdf)
|
||||
continue;
|
||||
|
||||
@@ -598,7 +599,7 @@ ccl_device int shader_bsdf_sample_closure(KernelGlobals *kg, const ShaderData *s
|
||||
|
||||
ccl_device void shader_bsdf_blur(KernelGlobals *kg, ShaderData *sd, float roughness)
|
||||
{
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BSDF(sc->type))
|
||||
@@ -613,7 +614,7 @@ ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, ShaderData *sd)
|
||||
|
||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(sc->type == CLOSURE_BSDF_TRANSPARENT_ID) // todo: make this work for osl
|
||||
@@ -637,7 +638,7 @@ ccl_device float3 shader_bsdf_diffuse(KernelGlobals *kg, ShaderData *sd)
|
||||
{
|
||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type))
|
||||
@@ -651,7 +652,7 @@ ccl_device float3 shader_bsdf_glossy(KernelGlobals *kg, ShaderData *sd)
|
||||
{
|
||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BSDF_GLOSSY(sc->type))
|
||||
@@ -665,7 +666,7 @@ ccl_device float3 shader_bsdf_transmission(KernelGlobals *kg, ShaderData *sd)
|
||||
{
|
||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BSDF_TRANSMISSION(sc->type))
|
||||
@@ -679,7 +680,7 @@ ccl_device float3 shader_bsdf_subsurface(KernelGlobals *kg, ShaderData *sd)
|
||||
{
|
||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BSSRDF(sc->type) || CLOSURE_IS_BSDF_BSSRDF(sc->type))
|
||||
@@ -694,7 +695,7 @@ ccl_device float3 shader_bsdf_ao(KernelGlobals *kg, ShaderData *sd, float ao_fac
|
||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
float3 N = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
|
||||
@@ -722,7 +723,7 @@ ccl_device float3 shader_bssrdf_sum(ShaderData *sd, float3 *N_, float *texture_b
|
||||
float3 N = make_float3(0.0f, 0.0f, 0.0f);
|
||||
float texture_blur = 0.0f, weight_sum = 0.0f;
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BSSRDF(sc->type)) {
|
||||
@@ -828,7 +829,7 @@ ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int
|
||||
|
||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||
|
||||
for(int i = 0; i< ccl_fetch(sd, num_closure); i++) {
|
||||
for(int i = 0; i < ccl_fetch(sd, num_closure); i++) {
|
||||
const ShaderClosure *sc = ccl_fetch_array(sd, closure, i);
|
||||
|
||||
if(CLOSURE_IS_BACKGROUND(sc->type))
|
||||
@@ -849,7 +850,7 @@ ccl_device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int
|
||||
ccl_device_inline void _shader_volume_phase_multi_eval(const ShaderData *sd, const float3 omega_in, float *pdf,
|
||||
int skip_phase, BsdfEval *result_eval, float sum_pdf, float sum_sample_weight)
|
||||
{
|
||||
for(int i = 0; i< sd->num_closure; i++) {
|
||||
for(int i = 0; i < sd->num_closure; i++) {
|
||||
if(i == skip_phase)
|
||||
continue;
|
||||
|
||||
|
@@ -180,7 +180,6 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *
|
||||
* potentially transparent, and only in that case start marching. this gives
|
||||
* one extra ray cast for the cases were we do want transparency. */
|
||||
|
||||
/* The arguments sd_mem and isect_mem are meaningful only for OpenCL split kernel. Other uses can just pass a NULL */
|
||||
ccl_device_inline bool shadow_blocked(KernelGlobals *kg, ccl_addr_space PathState *state, ccl_addr_space Ray *ray_input, float3 *shadow
|
||||
#ifdef __SPLIT_KERNEL__
|
||||
, ShaderData *sd_mem, Intersection *isect_mem
|
||||
|
@@ -1,126 +0,0 @@
|
||||
/*
|
||||
* Copyright 2011-2015 Blender Foundation
|
||||
*
|
||||
* 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 "kernel_split.h"
|
||||
|
||||
/*
|
||||
* Note on kernel_ocl_path_trace_shadow_blocked kernel.
|
||||
* This is the ninth kernel in the ray tracing logic. This is the eighth
|
||||
* of the path iteration kernels. This kernel takes care of "shadow ray cast"
|
||||
* logic of the direct lighting and AO part of ray tracing.
|
||||
*
|
||||
* The input and output are as follows,
|
||||
*
|
||||
* PathState_coop ----------------------------------|--- kernel_ocl_path_trace_shadow_blocked --|
|
||||
* LightRay_dl_coop --------------------------------| |--- LightRay_dl_coop
|
||||
* LightRay_ao_coop --------------------------------| |--- LightRay_ao_coop
|
||||
* ray_state ---------------------------------------| |--- ray_state
|
||||
* Queue_data(QUEUE_SHADOW_RAY_CAST_AO_RAYS & | |--- Queue_data (QUEUE_SHADOW_RAY_CAST_AO_RAYS & QUEUE_SHADOW_RAY_CAST_AO_RAYS)
|
||||
QUEUE_SHADOW_RAY_CAST_DL_RAYS) -------| |
|
||||
* Queue_index(QUEUE_SHADOW_RAY_CAST_AO_RAYS&
|
||||
QUEUE_SHADOW_RAY_CAST_DL_RAYS) -------| |
|
||||
* kg (globals + data) -----------------------------| |
|
||||
* queuesize ---------------------------------------| |
|
||||
*
|
||||
* Note on shader_shadow : shader_shadow is neither input nor output to this kernel. shader_shadow is filled and consumed in this kernel itself.
|
||||
* Note on queues :
|
||||
* The kernel fetches from QUEUE_SHADOW_RAY_CAST_AO_RAYS and QUEUE_SHADOW_RAY_CAST_DL_RAYS queues. We will empty
|
||||
* these queues this kernel.
|
||||
* State of queues when this kernel is called :
|
||||
* state of queues QUEUE_ACTIVE_AND_REGENERATED_RAYS and QUEUE_HITBG_BUFF_UPDATE_TOREGEN_RAYS will be same
|
||||
* before and after this kernel call.
|
||||
* QUEUE_SHADOW_RAY_CAST_AO_RAYS & QUEUE_SHADOW_RAY_CAST_DL_RAYS will be filled with rays marked with flags RAY_SHADOW_RAY_CAST_AO
|
||||
* and RAY_SHADOW_RAY_CAST_DL respectively, during kernel entry.
|
||||
* QUEUE_SHADOW_RAY_CAST_AO_RAYS and QUEUE_SHADOW_RAY_CAST_DL_RAYS will be empty at kernel exit.
|
||||
*/
|
||||
|
||||
__kernel void kernel_ocl_path_trace_shadow_blocked_direct_lighting(
|
||||
ccl_global char *globals,
|
||||
ccl_constant KernelData *data,
|
||||
ccl_global char *shader_shadow, /* Required for shadow blocked */
|
||||
ccl_global PathState *PathState_coop, /* Required for shadow blocked */
|
||||
ccl_global Ray *LightRay_dl_coop, /* Required for direct lighting's shadow blocked */
|
||||
ccl_global Ray *LightRay_ao_coop, /* Required for AO's shadow blocked */
|
||||
Intersection *Intersection_coop_AO,
|
||||
Intersection *Intersection_coop_DL,
|
||||
ccl_global char *ray_state,
|
||||
ccl_global int *Queue_data, /* Queue memory */
|
||||
ccl_global int *Queue_index, /* Tracks the number of elements in each queue */
|
||||
int queuesize, /* Size (capacity) of each queue */
|
||||
int total_num_rays
|
||||
)
|
||||
{
|
||||
#if 0
|
||||
/* we will make the Queue_index entries '0' in the next kernel */
|
||||
if(get_global_id(0) == 0 && get_global_id(1) == 0) {
|
||||
/* We empty this queue here */
|
||||
Queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS] = 0;
|
||||
Queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS] = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
int lidx = get_local_id(1) * get_local_id(0) + get_local_id(0);
|
||||
|
||||
ccl_local unsigned int ao_queue_length;
|
||||
ccl_local unsigned int dl_queue_length;
|
||||
if(lidx == 0) {
|
||||
ao_queue_length = Queue_index[QUEUE_SHADOW_RAY_CAST_AO_RAYS];
|
||||
dl_queue_length = Queue_index[QUEUE_SHADOW_RAY_CAST_DL_RAYS];
|
||||
}
|
||||
barrier(CLK_LOCAL_MEM_FENCE);
|
||||
|
||||
/* flag determining if the current ray is to process shadow ray for AO or DL */
|
||||
char shadow_blocked_type = -1;
|
||||
/* flag determining if we need to update L */
|
||||
char update_path_radiance = 0;
|
||||
|
||||
int ray_index = QUEUE_EMPTY_SLOT;
|
||||
int thread_index = get_global_id(1) * get_global_size(0) + get_global_id(0);
|
||||
if(thread_index < ao_queue_length + dl_queue_length) {
|
||||
if(thread_index < ao_queue_length) {
|
||||
ray_index = get_ray_index(thread_index, QUEUE_SHADOW_RAY_CAST_AO_RAYS, Queue_data, queuesize, 1);
|
||||
shadow_blocked_type = RAY_SHADOW_RAY_CAST_AO;
|
||||
} else {
|
||||
ray_index = get_ray_index(thread_index - ao_queue_length, QUEUE_SHADOW_RAY_CAST_DL_RAYS, Queue_data, queuesize, 1);
|
||||
shadow_blocked_type = RAY_SHADOW_RAY_CAST_DL;
|
||||
}
|
||||
}
|
||||
|
||||
if(ray_index == QUEUE_EMPTY_SLOT)
|
||||
return;
|
||||
|
||||
if(IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_DL) || IS_FLAG(ray_state, ray_index, RAY_SHADOW_RAY_CAST_AO)) {
|
||||
/* Load kernel global structure */
|
||||
KernelGlobals *kg = (KernelGlobals *)globals;
|
||||
ShaderData *sd_shadow = (ShaderData *)shader_shadow;
|
||||
|
||||
ccl_global PathState *state = &PathState_coop[ray_index];
|
||||
ccl_global Ray *light_ray_dl_global = &LightRay_dl_coop[ray_index];
|
||||
ccl_global Ray *light_ray_ao_global = &LightRay_ao_coop[ray_index];
|
||||
Intersection *isect_ao_global = &Intersection_coop_AO[ray_index];
|
||||
Intersection *isect_dl_global = &Intersection_coop_DL[ray_index];
|
||||
|
||||
ccl_global Ray *light_ray_global = shadow_blocked_type == RAY_SHADOW_RAY_CAST_AO ? light_ray_ao_global : light_ray_dl_global;
|
||||
Intersection *isect_global = RAY_SHADOW_RAY_CAST_AO ? isect_ao_global : isect_dl_global;
|
||||
|
||||
float3 shadow;
|
||||
update_path_radiance = !(shadow_blocked(kg, state, light_ray_global, &shadow, sd_shadow, isect_global));
|
||||
|
||||
/* We use light_ray_global's P and t to store shadow and update_path_radiance */
|
||||
light_ray_global->P = shadow;
|
||||
light_ray_global->t = update_path_radiance;
|
||||
}
|
||||
}
|
@@ -84,7 +84,7 @@ CCL_NAMESPACE_BEGIN
|
||||
#define __VOLUME_SCATTER__
|
||||
|
||||
/* Experimental on GPU */
|
||||
#ifdef __KERNEL_CUDA_EXPERIMENTAL__
|
||||
#ifdef __KERNEL_EXPERIMENTAL__
|
||||
#define __SUBSURFACE__
|
||||
#define __CMJ__
|
||||
#endif
|
||||
@@ -96,58 +96,40 @@ CCL_NAMESPACE_BEGIN
|
||||
/* keep __KERNEL_ADV_SHADING__ in sync with opencl_kernel_use_advanced_shading! */
|
||||
|
||||
#ifdef __KERNEL_OPENCL_NVIDIA__
|
||||
#define __KERNEL_SHADING__
|
||||
/* TODO(sergey): Advanced shading code still requires work
|
||||
* for split kernel.
|
||||
*/
|
||||
# ifndef __SPLIT_KERNEL__
|
||||
# define __KERNEL_ADV_SHADING__
|
||||
# else
|
||||
# define __MULTI_CLOSURE__
|
||||
# define __TRANSPARENT_SHADOWS__
|
||||
# define __PASSES__
|
||||
# define __BACKGROUND_MIS__
|
||||
# define __LAMP_MIS__
|
||||
# define __AO__
|
||||
# define __KERNEL_SHADING__
|
||||
# define __KERNEL_ADV_SHADING__
|
||||
# ifdef __KERNEL_EXPERIMENTAL__
|
||||
# define __CMJ__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL_OPENCL_APPLE__
|
||||
#define __KERNEL_SHADING__
|
||||
# define __KERNEL_SHADING__
|
||||
//#define __KERNEL_ADV_SHADING__
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL_OPENCL_AMD__
|
||||
#define __CL_USE_NATIVE__
|
||||
#define __KERNEL_SHADING__
|
||||
//__KERNEL_ADV_SHADING__
|
||||
#define __MULTI_CLOSURE__
|
||||
//#define __TRANSPARENT_SHADOWS__
|
||||
#define __PASSES__
|
||||
#define __BACKGROUND_MIS__
|
||||
#define __LAMP_MIS__
|
||||
#define __AO__
|
||||
//#define __CAMERA_MOTION__
|
||||
//#define __OBJECT_MOTION__
|
||||
//#define __HAIR__
|
||||
//end __KERNEL_ADV_SHADING__
|
||||
# define __CL_USE_NATIVE__
|
||||
# define __KERNEL_SHADING__
|
||||
# define __MULTI_CLOSURE__
|
||||
# define __PASSES__
|
||||
# define __BACKGROUND_MIS__
|
||||
# define __LAMP_MIS__
|
||||
# define __AO__
|
||||
# define __CAMERA_MOTION__
|
||||
# define __OBJECT_MOTION__
|
||||
# define __HAIR__
|
||||
# ifdef __KERNEL_EXPERIMENTAL__
|
||||
# define __TRANSPARENT_SHADOWS__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef __KERNEL_OPENCL_INTEL_CPU__
|
||||
#define __CL_USE_NATIVE__
|
||||
#define __KERNEL_SHADING__
|
||||
/* TODO(sergey): Advanced shading code still requires work
|
||||
* for split kernel.
|
||||
*/
|
||||
# ifndef __SPLIT_KERNEL__
|
||||
# define __KERNEL_ADV_SHADING__
|
||||
# else
|
||||
# define __MULTI_CLOSURE__
|
||||
# define __TRANSPARENT_SHADOWS__
|
||||
# define __PASSES__
|
||||
# define __BACKGROUND_MIS__
|
||||
# define __LAMP_MIS__
|
||||
# define __AO__
|
||||
# define __CL_USE_NATIVE__
|
||||
# define __KERNEL_SHADING__
|
||||
# define __KERNEL_ADV_SHADING__
|
||||
# ifdef __KERNEL_EXPERIMENTAL__
|
||||
# define __CMJ__
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@@ -190,6 +172,17 @@ CCL_NAMESPACE_BEGIN
|
||||
# define __KERNEL_DEBUG__
|
||||
#endif
|
||||
|
||||
/* Scene-based selective featrues compilation/ */
|
||||
#ifdef __NO_CAMERA_MOTION__
|
||||
# undef __CAMERA_MOTION__
|
||||
#endif
|
||||
#ifdef __NO_OBJECT_MOTION__
|
||||
# undef __OBJECT_MOTION__
|
||||
#endif
|
||||
#ifdef __NO_HAIR__
|
||||
# undef __HAIR__
|
||||
#endif
|
||||
|
||||
/* Random Numbers */
|
||||
|
||||
typedef uint RNG;
|
||||
@@ -346,6 +339,8 @@ typedef enum PassType {
|
||||
PASS_LIGHT = (1 << 25), /* no real pass, used to force use_light_pass */
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
PASS_BVH_TRAVERSAL_STEPS = (1 << 26),
|
||||
PASS_BVH_TRAVERSED_INSTANCES = (1 << 27),
|
||||
PASS_RAY_BOUNCES = (1 << 28),
|
||||
#endif
|
||||
} PassType;
|
||||
|
||||
@@ -471,11 +466,11 @@ typedef struct differential {
|
||||
|
||||
typedef struct Ray {
|
||||
/* TODO(sergey): This is only needed because current AMD
|
||||
* compilet has hard time bulding the kernel with this
|
||||
* compiler has hard time building the kernel with this
|
||||
* reshuffle. And at the same time reshuffle will cause
|
||||
* less optimal CPU code in certain places.
|
||||
*
|
||||
* We'll get rid of this nasty eception once AMD compiler
|
||||
* We'll get rid of this nasty exception once AMD compiler
|
||||
* is fixed.
|
||||
*/
|
||||
#ifndef __KERNEL_OPENCL_AMD__
|
||||
@@ -507,6 +502,7 @@ typedef ccl_addr_space struct Intersection {
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
int num_traversal_steps;
|
||||
int num_traversed_instances;
|
||||
#endif
|
||||
} Intersection;
|
||||
|
||||
@@ -857,7 +853,9 @@ typedef struct KernelFilm {
|
||||
|
||||
#ifdef __KERNEL_DEBUG__
|
||||
int pass_bvh_traversal_steps;
|
||||
int pass_pad3, pass_pad4, pass_pad5;
|
||||
int pass_bvh_traversed_instances;
|
||||
int pass_ray_bounces;
|
||||
int pass_pad3;
|
||||
#endif
|
||||
} KernelFilm;
|
||||
|
||||
@@ -996,6 +994,8 @@ typedef ccl_addr_space struct DebugData {
|
||||
// Total number of BVH node traversal steps and primitives intersections
|
||||
// for the camera rays.
|
||||
int num_bvh_traversal_steps;
|
||||
int num_bvh_traversed_instances;
|
||||
int num_ray_bounces;
|
||||
} DebugData;
|
||||
#endif
|
||||
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "kernel_globals.h"
|
||||
#include "kernel_film.h"
|
||||
#include "kernel_path.h"
|
||||
#include "kernel_path_branched.h"
|
||||
#include "kernel_bake.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
@@ -38,6 +38,7 @@
|
||||
#include "kernel_globals.h"
|
||||
#include "kernel_film.h"
|
||||
#include "kernel_path.h"
|
||||
#include "kernel_path_branched.h"
|
||||
#include "kernel_bake.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
@@ -39,6 +39,7 @@
|
||||
#include "kernel_globals.h"
|
||||
#include "kernel_film.h"
|
||||
#include "kernel_path.h"
|
||||
#include "kernel_path_branched.h"
|
||||
#include "kernel_bake.h"
|
||||
|
||||
CCL_NAMESPACE_BEGIN
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user