diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0bb3988..010c2a7 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing to Physically Based -Contributions of all kinds are welcome such as pull requests and issues! +Contributions of all kinds are welcome, such as pull requests and issues! If you have any questions or need guidance in addition to the guidelines outlined in this document, feel free to use the contact form at: [https://physicallybased.info/about/](https://physicallybased.info/about/) diff --git a/README.md b/README.md index 79a3a46..b38b443 100644 --- a/README.md +++ b/README.md @@ -1,22 +1,47 @@ +# Physically Based API + +A database of physically based values for CG artists. +

- - Screenshot of the web implementation + + Screenshot of the web implementation - A database of physically based values for CG artists

-## API +## Features + +- Open Database: Access a curated collection of physically based material values +- Lightweight: The entire dataset is optimized for quick loading and integration as presets + - [materials.json](deploy/v2/materials.json) `191 KB` + - [lightsources.json](deploy/v2/lightsources.json) `35 KB` + - [cameras.json](deploy/v2/cameras.json) `222 KB` + - [lenses.json](deploy/v2/lenses.json) (coming in v2) +- API Access: Connect your tools to the API to get the latest updates from the database +- Community-Driven: Contribute new materials or improve existing ones +- Free License: All data is released under [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/legalcode) + +## Getting Started + +Access the API and documentation at [https://api.physicallybased.info](https://api.physicallybased.info) + +### Implementations + +Explore the database through these implementations: -Access the API here: [https://api.physicallybased.info](https://api.physicallybased.info) +- Web [Physically Based](https://physicallybased.info) by [AntonPalmqvist](https://github.com/AntonPalmqvist) +- Web [Three.js GPU Path Tracer](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialDatabase.html) by [gkjohnson](https://github.com/gkjohnson) +- Web [MaterialXLab](https://kwokcb.github.io/MaterialXLab/javascript/PhysicallyBasedMaterialX_out.html) by [kwokcb](https://github.com/kwokcb) -Read about how to contribute here: [CONTRIBUTING.md](CONTRIBUTING.md) +### Contribute -## Implementations +Contributions are welcome! Whether you want to add new entries, corrections, or suggestions, your help is appreciated. See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. -- Web [https://physicallybased.info](https://physicallybased.info) by [AntonPalmqvist](https://github.com/AntonPalmqvist) -- Web [https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialDatabase.html](https://gkjohnson.github.io/three-gpu-pathtracer/example/bundle/materialDatabase.html) by [gkjohnson](https://github.com/gkjohnson) -- Web [https://kwokcb.github.io/MaterialXLab/javascript/PhysicallyBasedMaterialX_out.html](https://kwokcb.github.io/MaterialXLab/javascript/PhysicallyBasedMaterialX_out.html) by [kwokcb](https://github.com/kwokcb) +### License + +The database is made available under the [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/legalcode) license, which means you are free to use, modify, and distribute its content without any restrictions, even for commercial purposes. + +Shader ball used for renders is from [ASWF USD WG](https://github.com/usd-wg/assets/tree/main/full_assets/StandardShaderBall) and is licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) - -## License Information - -The database is made available under the [CC0 1.0](https://creativecommons.org/publicdomain/zero/1.0/legalcode) license, which means you are free to use, modify, and distribute its content without any restrictions, even for commercial purposes. - -Shader ball used for renders is from [ASWF USD WG](https://github.com/usd-wg/assets/tree/main/full_assets/StandardShaderBall) licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) diff --git a/deploy/lightsources.json b/deploy/lightsources.json index 7161d74..679ecd1 100644 --- a/deploy/lightsources.json +++ b/deploy/lightsources.json @@ -63,31 +63,31 @@ "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 65, - "intensity": 61250 + "intensity": 78096 }, { "format": "15º Reflector", "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 15, - "intensity": 600000 + "intensity": 32671 }, { "format": "30º Reflector", "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 30, - "intensity": 250000 + "intensity": 56389 }, { "format": "45º Reflector", "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 45, - "intensity": 125000 + "intensity": 67377 } ], - "unit": ["lx"], + "unit": ["lm"], "type": ["spot"], "category": ["Artificial"], "description": "", @@ -106,31 +106,31 @@ "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 70, - "intensity": 76400 + "intensity": 117678 }, { "format": "15º Reflector", "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 15, - "intensity": 864900 + "intensity": 47095 }, { "format": "30º Reflector", "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 30, - "intensity": 376200 + "intensity": 84854 }, { "format": "45º Reflector", "color": [1.0, 0.859, 0.778], "temperature": 5600, "angle": 45, - "intensity": 202500 + "intensity": 109150 } ], - "unit": ["lx"], + "unit": ["lm"], "type": ["spot"], "category": ["Artificial"], "description": "", @@ -148,21 +148,21 @@ { "format": "Flood", "angle": 60, - "intensity": 41300 + "intensity": 43249 }, { "format": "Medium", "angle": 40, - "intensity": 76100 + "intensity": 31671 }, { "format": "Spot", "angle": 15, - "intensity": 405000 + "intensity": 22053 } ], "sourceSize": [11.5], - "unit": ["lx"], + "unit": ["lm"], "type": ["spot"], "category": ["Artificial"], "description": "", @@ -580,7 +580,8 @@ "https://en.wikipedia.org/wiki/Daylight", "http://stjarnhimlen.se/comp/radfaq.html#10", "https://nssdc.gsfc.nasa.gov/planetary/factsheet/sunfact.html", - "https://www.physics.unlv.edu/~jeffery/astro/moon/sun_moon_angular.html" + "https://www.physics.unlv.edu/~jeffery/astro/moon/sun_moon_angular.html", + "https://jila.colorado.edu/~ajsh/colour/Tspectrum.html" ] } ] diff --git a/deploy/v2/lightsources.json b/deploy/v2/lightsources.json index 916228a..0a69d99 100644 --- a/deploy/v2/lightsources.json +++ b/deploy/v2/lightsources.json @@ -98,7 +98,7 @@ ], "temperature": 5600, "angle": 15, - "intensity": 600000 + "intensity": 32671 }, { "format": "30º Reflector", @@ -110,7 +110,7 @@ ], "temperature": 5600, "angle": 30, - "intensity": 250000 + "intensity": 56389 }, { "format": "45º Reflector", @@ -122,7 +122,7 @@ ], "temperature": 5600, "angle": 45, - "intensity": 125000 + "intensity": 67377 }, { "format": "No Reflector", @@ -134,10 +134,10 @@ ], "temperature": 5600, "angle": 65, - "intensity": 61250 + "intensity": 78096 } ], - "unit": ["lx"], + "unit": ["lm"], "type": ["spot"], "category": ["Artificial"], "references": [ @@ -176,7 +176,7 @@ ], "temperature": 5600, "angle": 15, - "intensity": 864900 + "intensity": 47095 }, { "format": "30º Reflector", @@ -188,7 +188,7 @@ ], "temperature": 5600, "angle": 30, - "intensity": 376200 + "intensity": 84854 }, { "format": "45º Reflector", @@ -200,7 +200,7 @@ ], "temperature": 5600, "angle": 45, - "intensity": 202500 + "intensity": 109150 }, { "format": "No Reflector", @@ -212,10 +212,10 @@ ], "temperature": 5600, "angle": 70, - "intensity": 76400 + "intensity": 117678 } ], - "unit": ["lx"], + "unit": ["lm"], "type": ["spot"], "category": ["Artificial"], "references": [ @@ -253,7 +253,7 @@ ], "temperature": 6000, "angle": 15, - "intensity": 405000 + "intensity": 22053 }, { "format": "Medium", @@ -265,7 +265,7 @@ ], "temperature": 6000, "angle": 40, - "intensity": 76100 + "intensity": 31671 }, { "format": "Flood", @@ -277,11 +277,11 @@ ], "temperature": 6000, "angle": 60, - "intensity": 41300 + "intensity": 43249 } ], "sourceSize": [11.5], - "unit": ["lx"], + "unit": ["lm"], "type": ["spot"], "category": ["Artificial"], "references": [ @@ -1167,6 +1167,12 @@ "author": "Jeffery, D.", "url": "https://www.physics.unlv.edu/~jeffery/astro/moon/sun_moon_angular.html", "accessed": "2025-02-27" + }, + { + "title": "What Colour Is The Sun", + "author": "Hamilton, A.", + "url": "https://jila.colorado.edu/~ajsh/colour/Tspectrum.html", + "accessed": "2025-08-23" } ] } diff --git a/package-lock.json b/package-lock.json index 893c7de..533ce03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,13 +10,13 @@ "devDependencies": { "adm-zip": "^0.5.16", "http-server": "^14.1.1", - "sharp": "^0.33.5" + "sharp": "^0.34.3" } }, "node_modules/@emnapi/runtime": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.3.1.tgz", - "integrity": "sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.5.0.tgz", + "integrity": "sha512-97/BJ3iXHww3djw6hYIfErCZFee7qCtrneuLa20UXFCOTCfBM2cvQHjWJ2EG0s0MtdNwInarqCTz35i4wWXHsQ==", "dev": true, "license": "MIT", "optional": true, @@ -25,9 +25,9 @@ } }, "node_modules/@img/sharp-darwin-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz", - "integrity": "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.34.3.tgz", + "integrity": "sha512-ryFMfvxxpQRsgZJqBd4wsttYQbCxsJksrv9Lw/v798JcQ8+w84mBWuXwl+TT0WJ/WrYOLaYpwQXi3sA9nTIaIg==", "cpu": [ "arm64" ], @@ -44,13 +44,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-arm64": "1.0.4" + "@img/sharp-libvips-darwin-arm64": "1.2.0" } }, "node_modules/@img/sharp-darwin-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.5.tgz", - "integrity": "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.34.3.tgz", + "integrity": "sha512-yHpJYynROAj12TA6qil58hmPmAwxKKC7reUqtGLzsOHfP7/rniNGTL8tjWX6L3CTV4+5P4ypcS7Pp+7OB+8ihA==", "cpu": [ "x64" ], @@ -67,13 +67,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-darwin-x64": "1.0.4" + "@img/sharp-libvips-darwin-x64": "1.2.0" } }, "node_modules/@img/sharp-libvips-darwin-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.4.tgz", - "integrity": "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.2.0.tgz", + "integrity": "sha512-sBZmpwmxqwlqG9ueWFXtockhsxefaV6O84BMOrhtg/YqbTaRdqDE7hxraVE3y6gVM4eExmfzW4a8el9ArLeEiQ==", "cpu": [ "arm64" ], @@ -88,9 +88,9 @@ } }, "node_modules/@img/sharp-libvips-darwin-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.4.tgz", - "integrity": "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.2.0.tgz", + "integrity": "sha512-M64XVuL94OgiNHa5/m2YvEQI5q2cl9d/wk0qFTDVXcYzi43lxuiFTftMR1tOnFQovVXNZJ5TURSDK2pNe9Yzqg==", "cpu": [ "x64" ], @@ -105,9 +105,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.5.tgz", - "integrity": "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.2.0.tgz", + "integrity": "sha512-mWd2uWvDtL/nvIzThLq3fr2nnGfyr/XMXlq8ZJ9WMR6PXijHlC3ksp0IpuhK6bougvQrchUAfzRLnbsen0Cqvw==", "cpu": [ "arm" ], @@ -122,9 +122,9 @@ } }, "node_modules/@img/sharp-libvips-linux-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.4.tgz", - "integrity": "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.2.0.tgz", + "integrity": "sha512-RXwd0CgG+uPRX5YYrkzKyalt2OJYRiJQ8ED/fi1tq9WQW2jsQIn0tqrlR5l5dr/rjqq6AHAxURhj2DVjyQWSOA==", "cpu": [ "arm64" ], @@ -138,10 +138,27 @@ "url": "https://opencollective.com/libvips" } }, + "node_modules/@img/sharp-libvips-linux-ppc64": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-ppc64/-/sharp-libvips-linux-ppc64-1.2.0.tgz", + "integrity": "sha512-Xod/7KaDDHkYu2phxxfeEPXfVXFKx70EAFZ0qyUdOjCcxbjqyJOEUpDe6RIyaunGxT34Anf9ue/wuWOqBW2WcQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "LGPL-3.0-or-later", + "optional": true, + "os": [ + "linux" + ], + "funding": { + "url": "https://opencollective.com/libvips" + } + }, "node_modules/@img/sharp-libvips-linux-s390x": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.4.tgz", - "integrity": "sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.2.0.tgz", + "integrity": "sha512-eMKfzDxLGT8mnmPJTNMcjfO33fLiTDsrMlUVcp6b96ETbnJmd4uvZxVJSKPQfS+odwfVaGifhsB07J1LynFehw==", "cpu": [ "s390x" ], @@ -156,9 +173,9 @@ } }, "node_modules/@img/sharp-libvips-linux-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.4.tgz", - "integrity": "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.2.0.tgz", + "integrity": "sha512-ZW3FPWIc7K1sH9E3nxIGB3y3dZkpJlMnkk7z5tu1nSkBoCgw2nSRTFHI5pB/3CQaJM0pdzMF3paf9ckKMSE9Tg==", "cpu": [ "x64" ], @@ -173,9 +190,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-arm64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.4.tgz", - "integrity": "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.2.0.tgz", + "integrity": "sha512-UG+LqQJbf5VJ8NWJ5Z3tdIe/HXjuIdo4JeVNADXBFuG7z9zjoegpzzGIyV5zQKi4zaJjnAd2+g2nna8TZvuW9Q==", "cpu": [ "arm64" ], @@ -190,9 +207,9 @@ } }, "node_modules/@img/sharp-libvips-linuxmusl-x64": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.4.tgz", - "integrity": "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==", + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.2.0.tgz", + "integrity": "sha512-SRYOLR7CXPgNze8akZwjoGBoN1ThNZoqpOgfnOxmWsklTGVfJiGJoC/Lod7aNMGA1jSsKWM1+HRX43OP6p9+6Q==", "cpu": [ "x64" ], @@ -207,9 +224,9 @@ } }, "node_modules/@img/sharp-linux-arm": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.5.tgz", - "integrity": "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm/-/sharp-linux-arm-0.34.3.tgz", + "integrity": "sha512-oBK9l+h6KBN0i3dC8rYntLiVfW8D8wH+NPNT3O/WBHeW0OQWCjfWksLUaPidsrDKpJgXp3G3/hkmhptAW0I3+A==", "cpu": [ "arm" ], @@ -226,13 +243,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm": "1.0.5" + "@img/sharp-libvips-linux-arm": "1.2.0" } }, "node_modules/@img/sharp-linux-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.5.tgz", - "integrity": "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.34.3.tgz", + "integrity": "sha512-QdrKe3EvQrqwkDrtuTIjI0bu6YEJHTgEeqdzI3uWJOH6G1O8Nl1iEeVYRGdj1h5I21CqxSvQp1Yv7xeU3ZewbA==", "cpu": [ "arm64" ], @@ -249,13 +266,36 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-arm64": "1.0.4" + "@img/sharp-libvips-linux-arm64": "1.2.0" + } + }, + "node_modules/@img/sharp-linux-ppc64": { + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-ppc64/-/sharp-linux-ppc64-0.34.3.tgz", + "integrity": "sha512-GLtbLQMCNC5nxuImPR2+RgrviwKwVql28FWZIW1zWruy6zLgA5/x2ZXk3mxj58X/tszVF69KK0Is83V8YgWhLA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" + }, + "funding": { + "url": "https://opencollective.com/libvips" + }, + "optionalDependencies": { + "@img/sharp-libvips-linux-ppc64": "1.2.0" } }, "node_modules/@img/sharp-linux-s390x": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.5.tgz", - "integrity": "sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.34.3.tgz", + "integrity": "sha512-3gahT+A6c4cdc2edhsLHmIOXMb17ltffJlxR0aC2VPZfwKoTGZec6u5GrFgdR7ciJSsHT27BD3TIuGcuRT0KmQ==", "cpu": [ "s390x" ], @@ -272,13 +312,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-s390x": "1.0.4" + "@img/sharp-libvips-linux-s390x": "1.2.0" } }, "node_modules/@img/sharp-linux-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.5.tgz", - "integrity": "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-linux-x64/-/sharp-linux-x64-0.34.3.tgz", + "integrity": "sha512-8kYso8d806ypnSq3/Ly0QEw90V5ZoHh10yH0HnrzOCr6DKAPI6QVHvwleqMkVQ0m+fc7EH8ah0BB0QPuWY6zJQ==", "cpu": [ "x64" ], @@ -295,13 +335,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linux-x64": "1.0.4" + "@img/sharp-libvips-linux-x64": "1.2.0" } }, "node_modules/@img/sharp-linuxmusl-arm64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.5.tgz", - "integrity": "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.34.3.tgz", + "integrity": "sha512-vAjbHDlr4izEiXM1OTggpCcPg9tn4YriK5vAjowJsHwdBIdx0fYRsURkxLG2RLm9gyBq66gwtWI8Gx0/ov+JKQ==", "cpu": [ "arm64" ], @@ -318,13 +358,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-arm64": "1.0.4" + "@img/sharp-libvips-linuxmusl-arm64": "1.2.0" } }, "node_modules/@img/sharp-linuxmusl-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.5.tgz", - "integrity": "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.34.3.tgz", + "integrity": "sha512-gCWUn9547K5bwvOn9l5XGAEjVTTRji4aPTqLzGXHvIr6bIDZKNTA34seMPgM0WmSf+RYBH411VavCejp3PkOeQ==", "cpu": [ "x64" ], @@ -341,13 +381,13 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-libvips-linuxmusl-x64": "1.0.4" + "@img/sharp-libvips-linuxmusl-x64": "1.2.0" } }, "node_modules/@img/sharp-wasm32": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.33.5.tgz", - "integrity": "sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-wasm32/-/sharp-wasm32-0.34.3.tgz", + "integrity": "sha512-+CyRcpagHMGteySaWos8IbnXcHgfDn7pO2fiC2slJxvNq9gDipYBN42/RagzctVRKgxATmfqOSulgZv5e1RdMg==", "cpu": [ "wasm32" ], @@ -355,8 +395,28 @@ "license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT", "optional": true, "dependencies": { - "@emnapi/runtime": "^1.2.0" + "@emnapi/runtime": "^1.4.4" + }, + "engines": { + "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, + "funding": { + "url": "https://opencollective.com/libvips" + } + }, + "node_modules/@img/sharp-win32-arm64": { + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-arm64/-/sharp-win32-arm64-0.34.3.tgz", + "integrity": "sha512-MjnHPnbqMXNC2UgeLJtX4XqoVHHlZNd+nPt1kRPmj63wURegwBhZlApELdtxM2OIZDRv/DFtLcNhVbd1z8GYXQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND LGPL-3.0-or-later", + "optional": true, + "os": [ + "win32" + ], "engines": { "node": "^18.17.0 || ^20.3.0 || >=21.0.0" }, @@ -365,9 +425,9 @@ } }, "node_modules/@img/sharp-win32-ia32": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.5.tgz", - "integrity": "sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.34.3.tgz", + "integrity": "sha512-xuCdhH44WxuXgOM714hn4amodJMZl3OEvf0GVTm0BEyMeA2to+8HEdRPShH0SLYptJY1uBw+SCFP9WVQi1Q/cw==", "cpu": [ "ia32" ], @@ -385,9 +445,9 @@ } }, "node_modules/@img/sharp-win32-x64": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.5.tgz", - "integrity": "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/@img/sharp-win32-x64/-/sharp-win32-x64-0.34.3.tgz", + "integrity": "sha512-OWwz05d++TxzLEv4VnsTz5CmZ6mI6S05sfQGEMrNrQcOEERbX46332IvE7pO/EUiw7jUrrS40z/M7kPyjfl04g==", "cpu": [ "x64" ], @@ -572,9 +632,9 @@ } }, "node_modules/detect-libc": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.3.tgz", - "integrity": "sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.4.tgz", + "integrity": "sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==", "dev": true, "license": "Apache-2.0", "engines": { @@ -977,9 +1037,9 @@ "license": "MIT" }, "node_modules/semver": { - "version": "7.7.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", - "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "version": "7.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz", + "integrity": "sha512-RF0Fw+rO5AMf9MAyaRXI4AV0Ulj5lMHqVxxdSgiVbixSCXoEmmX/jk0CuJw4+3SqroYO9VoUh+HcuJivvtJemA==", "dev": true, "license": "ISC", "bin": { @@ -990,16 +1050,16 @@ } }, "node_modules/sharp": { - "version": "0.33.5", - "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.33.5.tgz", - "integrity": "sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==", + "version": "0.34.3", + "resolved": "https://registry.npmjs.org/sharp/-/sharp-0.34.3.tgz", + "integrity": "sha512-eX2IQ6nFohW4DbvHIOLRB3MHFpYqaqvXd3Tp5e/T/dSH83fxaNJQRvDMhASmkNTsNTVF2/OOopzRCt7xokgPfg==", "dev": true, "hasInstallScript": true, "license": "Apache-2.0", "dependencies": { "color": "^4.2.3", - "detect-libc": "^2.0.3", - "semver": "^7.6.3" + "detect-libc": "^2.0.4", + "semver": "^7.7.2" }, "engines": { "node": "^18.17.0 || ^20.3.0 || >=21.0.0" @@ -1008,25 +1068,28 @@ "url": "https://opencollective.com/libvips" }, "optionalDependencies": { - "@img/sharp-darwin-arm64": "0.33.5", - "@img/sharp-darwin-x64": "0.33.5", - "@img/sharp-libvips-darwin-arm64": "1.0.4", - "@img/sharp-libvips-darwin-x64": "1.0.4", - "@img/sharp-libvips-linux-arm": "1.0.5", - "@img/sharp-libvips-linux-arm64": "1.0.4", - "@img/sharp-libvips-linux-s390x": "1.0.4", - "@img/sharp-libvips-linux-x64": "1.0.4", - "@img/sharp-libvips-linuxmusl-arm64": "1.0.4", - "@img/sharp-libvips-linuxmusl-x64": "1.0.4", - "@img/sharp-linux-arm": "0.33.5", - "@img/sharp-linux-arm64": "0.33.5", - "@img/sharp-linux-s390x": "0.33.5", - "@img/sharp-linux-x64": "0.33.5", - "@img/sharp-linuxmusl-arm64": "0.33.5", - "@img/sharp-linuxmusl-x64": "0.33.5", - "@img/sharp-wasm32": "0.33.5", - "@img/sharp-win32-ia32": "0.33.5", - "@img/sharp-win32-x64": "0.33.5" + "@img/sharp-darwin-arm64": "0.34.3", + "@img/sharp-darwin-x64": "0.34.3", + "@img/sharp-libvips-darwin-arm64": "1.2.0", + "@img/sharp-libvips-darwin-x64": "1.2.0", + "@img/sharp-libvips-linux-arm": "1.2.0", + "@img/sharp-libvips-linux-arm64": "1.2.0", + "@img/sharp-libvips-linux-ppc64": "1.2.0", + "@img/sharp-libvips-linux-s390x": "1.2.0", + "@img/sharp-libvips-linux-x64": "1.2.0", + "@img/sharp-libvips-linuxmusl-arm64": "1.2.0", + "@img/sharp-libvips-linuxmusl-x64": "1.2.0", + "@img/sharp-linux-arm": "0.34.3", + "@img/sharp-linux-arm64": "0.34.3", + "@img/sharp-linux-ppc64": "0.34.3", + "@img/sharp-linux-s390x": "0.34.3", + "@img/sharp-linux-x64": "0.34.3", + "@img/sharp-linuxmusl-arm64": "0.34.3", + "@img/sharp-linuxmusl-x64": "0.34.3", + "@img/sharp-wasm32": "0.34.3", + "@img/sharp-win32-arm64": "0.34.3", + "@img/sharp-win32-ia32": "0.34.3", + "@img/sharp-win32-x64": "0.34.3" } }, "node_modules/side-channel": { diff --git a/package.json b/package.json index 1df54c5..51b9160 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,8 @@ "http": "http-server -o deploy", "http-v2": "http-server -o deploy/v2", "image-processor": "node scripts/image-processor.js ", - "create-materialx": "node scripts/create-materialx.js " + "create-materialx": "node scripts/create-materialx.js ", + "create-usd": "node scripts/create-usd.js " }, "repository": { "type": "git", @@ -21,6 +22,6 @@ "devDependencies": { "adm-zip": "^0.5.16", "http-server": "^14.1.1", - "sharp": "^0.33.5" + "sharp": "^0.34.3" } } diff --git a/scripts/create-materialx.js b/scripts/create-materialx.js index 2f240b4..0f920fb 100644 --- a/scripts/create-materialx.js +++ b/scripts/create-materialx.js @@ -20,7 +20,7 @@ function createFiles() { ) { const baseColor = JSON.stringify(hit.color[0].color) !== JSON.stringify([0.8, 0.8, 0.8]) && !hit.transmission && !hit.subsurfaceRadius ? ' \n' : ""; const metalness = hit.metalness > 0 ? ' \n' : ""; - const specularColor = hit.specularColor ? ' \n' : ""; + const specularColor = hit.specularColor ? ' \n' : ""; const roughness = hit.roughness != 0.3 ? ' \n' : ""; const specularIor = hit.ior && hit.metalness < 1 && hit.ior != 1.5 ? ' \n' : ""; const transmission = hit.transmission ? ' \n' : ""; diff --git a/scripts/create-usd.js b/scripts/create-usd.js new file mode 100644 index 0000000..0aa0de9 --- /dev/null +++ b/scripts/create-usd.js @@ -0,0 +1,170 @@ +const fs = require("node:fs"); +const AdmZip = require("adm-zip"); + +const usdVersion = "1.0"; +const outputFile = "USD-v" + usdVersion + ".zip"; +const tempFolder = "./tmp/"; + +function createFiles() { + return new Promise((resolve, reject) => { + fs.readFile("./deploy/v2/cameras.json", "utf8", (err, data) => { + if (err) { + console.error(err); + reject(err); + return; + } + + // prettier-ignore + function makeUSD( + hit, i = 0, type="camera", engine + ) { + let usd = ""; + let upAxis = engine == "unreal" || engine == "blender" ? "Z" : "Y"; + switch (type) { + case "camera": { // Curly braces are here so we can scope the "name" variable to only this case + let name = hit.name.replace(/ |-|\./g, "_").replace(/[()]/g, "") + "_" + hit.sensorSize[i].format.replace(/ |-|\./g, "_"); + usd = + '#usda 1.0\n' + + '(\n' + + ' defaultPrim = "' + name +'"\n' + + ' doc = "https://physicallybased.info"\n' + + ' metersPerUnit = 0.01\n' + + ' upAxis = "' + upAxis + '"\n' + + ')\n' + + '\n' + + 'def Camera "'+ name + '"\n' + + '{\n' + + ' float2 clippingRange = (0.1, 1000)\n' + + ' float focalLength = 50\n' + + ' token projection = "perspective"\n' + + ' float horizontalAperture = '+ hit.sensorSize[i].size[0].toFixed(2)+'\n' + + ' float horizontalApertureOffset = 0\n' + + ' float verticalAperture = '+ hit.sensorSize[i].size[1].toFixed(2)+'\n' + + ' float verticalApertureOffset = 0\n' + + '}'; + break; + } + case "light": { // Curly braces are here so we can scope the "name" variable to only this case + let name = hit.variants ? hit.name.replace(/ |-|\./g, "_").replace(/[()]/g, "") + "_" + hit.variants[i].format.replace(/ |-|\./g, "_").replace(/[()]/g, "") : hit.name.replace(/ |-|\./g, "_").replace(/[()]/g, ""); + let type = hit.type == "surface" ? "RectLight" : hit.type == "directional" ? "DistantLight" : hit.type == "dome" ? "DomeLight" : hit.type == "cylinder" ? "CylinderLight" : "SphereLight"; + let apiSchemas = hit.type == "spot" ? + 'def ' + type + ' "'+ name +'" (\n' + + ' prepend apiSchemas = ["ShapingAPI"]\n' + + ')\n' + : + 'def ' + type + ' "'+ name +'"\n'; + let colorTemperature = + hit.variants && hit.variants[i] && hit.variants[i].temperature ? ' float inputs:colorTemperature = ' + hit.variants[i].temperature + '\n' + : hit.temperature && hit.temperature[2] ? ' float inputs:colorTemperature = ' + hit.temperature[2] + '\n' + : hit.temperature && hit.temperature[0] ? ' float inputs:colorTemperature = ' + hit.temperature[0] + '\n' + : ""; + let enableColorTemperature = colorTemperature !== "" && (engine == "unreal" || engine == "blender") ? 1 : 0; + let color = + hit.variants && enableColorTemperature === 0 ? ' color3f inputs:color = ('+ hit.variants[i].color[0].color[0].toFixed(3)+', '+ hit.variants[i].color[0].color[1].toFixed(3)+', '+ hit.variants[i].color[0].color[2].toFixed(3)+')\n' + : enableColorTemperature === 0 ? ' color3f inputs:color = (' + hit.color[0].color[0].toFixed(3)+', '+ hit.color[0].color[1].toFixed(3)+', '+ hit.color[0].color[2].toFixed(3) +')\n' : ' color3f inputs:color = (1.0, 1.0, 1.0)\n'; + let intensity = + hit.intensity && hit.intensity[2] + ? hit.intensity[2] + : hit.intensity && hit.intensity[1] + ? hit.intensity[1] + : hit.intensity && hit.intensity[0] + ? hit.intensity[0] + : hit.variants + ? hit.variants[i].intensity + : hit.intensity + ? hit.intensity + : null; + // console.log(colorTemperature === ""); + let width = hit.variants && hit.variants[i] && hit.variants[i].sourceSize && hit.type == "surface" ? hit.variants[i].sourceSize[0] : hit.sourceSize && hit.type == "surface" ? hit.sourceSize[0] : null; + let height = hit.variants && hit.variants[i] && hit.variants[i].sourceSize && hit.type == "surface" ? hit.variants[i].sourceSize[1] : hit.sourceSize && hit.type == "surface" ? hit.sourceSize[1] : null; + let length = hit.variants && hit.variants[i] && hit.variants[i].sourceSize && hit.type == "cylinder" ? hit.variants[i].sourceSize[1] : hit.sourceSize && hit.type == "cylinder" ? hit.sourceSize[1] : null; + let radius = hit.variants && hit.variants[i] && hit.variants[i].sourceSize && (hit.type == "point" || hit.type == "spot" || hit.type == "cylinder") ? hit.variants[i].sourceSize[0] : hit.sourceSize && (hit.type == "point" || hit.type == "spot" || hit.type == "cylinder") ? hit.sourceSize[0] : 1.00001; // 1.00001 is here to give a number as close as 1 for the conversion to work when no radius is provided, unusual enough to not be ignored if there's a light source with 1 cm radius. Further motivated by "we chose to automatically promote punctual lights to small area lights of 1 cm if the artists specify a luminance unit to control the intensity." on p39 in https://seblagarde.wordpress.com/wp-content/uploads/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf + let treatAsPoint = hit.variants && hit.variants[i] && hit.variants[i].sourceSize > 0 && (hit.type == "point" || hit.type == "spot") ? ' bool treatAsPoint = ' + 0 + '\n' : hit.sourceSize && hit.sourceSize[0] > 0 && (hit.type == "point" || hit.type == "spot") ? ' bool treatAsPoint = ' + 0 + '\n' : ""; + let coneAngle = hit.variants && hit.variants[i] && hit.variants[i].angle && (hit.type == "spot") ? hit.variants[i].angle / 2 : hit.angle && (hit.type == "spot") ? hit.angle / 2 : null; // Divided by 2 because USD uses half-angle, θ, where the API uses beam angle + let angle = hit.variants && hit.variants[i] && hit.variants[i].angle && hit.type == "directional" ? hit.variants[i].angle : hit.angle && hit.type == "directional" ? hit.angle : null; + let convertedIntensity = + hit.type == "directional" ? intensity + : hit.type == "surface" && hit.unit == "cd/m2" ? intensity + : hit.type == "surface" && hit.unit == "lm" ? lumenToNitsRect(intensity, width / 100, height / 100) + : hit.type == "spot" && hit.unit == "lm" ? lumenToNitsSpot(intensity, radius / 100, coneAngle * 2) + : hit.type == "spot" && hit.unit == "lx" ? lumenToNitsSpot(luxToLumen(intensity, 1, coneAngle * 2), radius / 100, coneAngle * 2) + : hit.type == "point" && hit.unit == "lm" ? lumenToNitsPoint(intensity, radius / 100) + : hit.type == "cylinder" && hit.unit == "lm" ? lumenToNitsCylinder(intensity, radius / 100, length / 100) + : hit.type == "dome" ? 1 + : null; + // console.log(radius); + usd = + '#usda 1.0\n' + + '(\n' + + ' defaultPrim = "' + name +'"\n' + + ' doc = "https://physicallybased.info"\n' + + ' metersPerUnit = 0.01\n' + + ' upAxis = "' + upAxis + '"\n' + + ')\n' + + '\n' + + apiSchemas + + '{\n' + + color + + colorTemperature + + ' bool inputs:enableColorTemperature = ' + enableColorTemperature +'\n' + + ' float inputs:intensity = ' + convertedIntensity +'\n' + + (width ? ' float inputs:width = ' + width + '\n' : "") + + (height ? ' float inputs:height = ' + height + '\n' : "") + + (length ? ' float inputs:length = ' + length + '\n' : "") + + (radius != 1.00001 ? ' float inputs:radius = ' + radius + '\n' : "") + + treatAsPoint + + (coneAngle ? ' float inputs:shaping:cone:angle = ' + coneAngle + '\n' : "") + + (coneAngle ? ' float inputs:shaping:cone:softness = 1' + '\n' : "") + + (angle ? ' float inputs:angle = ' + angle + '\n' : "") + + '}'; + // console.log(usd); + break; + } + } + return usd; + } + + JSON.parse(data).forEach((element) => { + if (!fs.existsSync(tempFolder)) { + fs.mkdirSync(tempFolder, { recursive: true }); + } + const fileName = + tempFolder + + element.name.replace(/ |-|\./g, "_").replace(/[()]/g, "") + + ".usda"; + fs.writeFile(fileName, makeUSD(element), (err) => { + if (err) { + console.error(err); + reject(err); + } else { + console.log(fileName + " created"); + resolve(); + } + }); + }); + }); + }); +} + +function zipFiles() { + const zip = new AdmZip(); + zip.addLocalFolder(tempFolder); + zip.writeZip(outputFile); +} + +async function main() { + try { + await createFiles(); + zipFiles(); + console.log("Created " + outputFile + " successfully"); + + if (fs.existsSync(tempFolder)) { + fs.rmSync(tempFolder, { recursive: true, force: true }); + console.log("Deleted " + tempFolder + " folder successfully"); + } + } catch (err) { + console.error("An error occurred:", err); + } +} + +main();