implementing shaders

This commit is contained in:
STP
2023-11-13 00:41:49 -05:00
parent 15c39e3c05
commit 29e22a0afa
5 changed files with 407 additions and 262 deletions

565
Cargo.lock generated
View File

@@ -2,22 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "ab_glyph"
version = "0.2.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "80179d7dd5d7e8c285d67c4a1e652972a92de7475beddfb92028c76463b13225"
dependencies = [
"ab_glyph_rasterizer",
"owned_ttf_parser",
]
[[package]]
name = "ab_glyph_rasterizer"
version = "0.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046"
[[package]] [[package]]
name = "addr2line" name = "addr2line"
version = "0.21.0" version = "0.21.0"
@@ -60,30 +44,6 @@ version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5" checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"
[[package]]
name = "android-activity"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64529721f27c2314ced0890ce45e469574a73e5e6fdd6e9da1860eb29285f5e0"
dependencies = [
"android-properties",
"bitflags 1.3.2",
"cc",
"jni-sys",
"libc",
"log",
"ndk",
"ndk-context",
"ndk-sys",
"num_enum 0.6.1",
]
[[package]]
name = "android-properties"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04"
[[package]] [[package]]
name = "android_system_properties" name = "android_system_properties"
version = "0.1.5" version = "0.1.5"
@@ -120,7 +80,7 @@ version = "0.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4543528550ff5d3fa676742778c61387b2b6db24ab72628ff951a5b1b0f470fe" checksum = "4543528550ff5d3fa676742778c61387b2b6db24ab72628ff951a5b1b0f470fe"
dependencies = [ dependencies = [
"cocoa", "cocoa 0.15.0",
"failure", "failure",
"lazy_static", "lazy_static",
"objc", "objc",
@@ -133,6 +93,12 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545" checksum = "6b4930d2cb77ce62f89ee5d5289b4ac049559b1c45539271f5ed4fdc7db34545"
[[package]]
name = "arrayvec"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23b62fc65de8e4e7f52534fb52b0f3ed04746ae267519eef2a83941e8085068b"
[[package]] [[package]]
name = "arrayvec" name = "arrayvec"
version = "0.7.4" version = "0.7.4"
@@ -211,25 +177,6 @@ version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a"
[[package]]
name = "block-sys"
version = "0.1.0-beta.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fa55741ee90902547802152aaf3f8e5248aab7e21468089560d4c8840561146"
dependencies = [
"objc-sys",
]
[[package]]
name = "block2"
version = "0.2.0-alpha.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8dd9e63c1744f755c2f60332b88de39d341e5e86239014ad839bd71c106dec42"
dependencies = [
"block-sys",
"objc2-encode",
]
[[package]] [[package]]
name = "bumpalo" name = "bumpalo"
version = "3.14.0" version = "3.14.0"
@@ -282,7 +229,6 @@ version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0" checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [ dependencies = [
"jobserver",
"libc", "libc",
] ]
@@ -292,12 +238,6 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cfg_aliases"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]] [[package]]
name = "cloudabi" name = "cloudabi"
version = "0.0.3" version = "0.0.3"
@@ -307,6 +247,15 @@ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
] ]
[[package]]
name = "cmake"
version = "0.1.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130"
dependencies = [
"cc",
]
[[package]] [[package]]
name = "cocoa" name = "cocoa"
version = "0.15.0" version = "0.15.0"
@@ -320,6 +269,36 @@ dependencies = [
"objc", "objc",
] ]
[[package]]
name = "cocoa"
version = "0.24.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f425db7937052c684daec3bd6375c8abe2d146dca4b8b143d6db777c39138f3a"
dependencies = [
"bitflags 1.3.2",
"block",
"cocoa-foundation",
"core-foundation 0.9.3",
"core-graphics 0.22.3",
"foreign-types 0.3.2",
"libc",
"objc",
]
[[package]]
name = "cocoa-foundation"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c6234cbb2e4c785b456c0644748b1ac416dd045799740356f8363dfe00c93f7"
dependencies = [
"bitflags 1.3.2",
"block",
"core-foundation 0.9.3",
"core-graphics-types",
"libc",
"objc",
]
[[package]] [[package]]
name = "codespan-reporting" name = "codespan-reporting"
version = "0.11.1" version = "0.11.1"
@@ -410,6 +389,18 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "core-text"
version = "19.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d74ada66e07c1cefa18f8abfba765b486f250de2e4a999e5727fc0dd4b4a25"
dependencies = [
"core-foundation 0.9.3",
"core-graphics 0.22.3",
"foreign-types 0.3.2",
"libc",
]
[[package]] [[package]]
name = "crc32fast" name = "crc32fast"
version = "1.3.2" version = "1.3.2"
@@ -419,6 +410,35 @@ dependencies = [
"cfg-if", "cfg-if",
] ]
[[package]]
name = "crossfont"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21fd3add36ea31aba1520aa5288714dd63be506106753226d0eb387a93bc9c45"
dependencies = [
"cocoa 0.24.1",
"core-foundation 0.9.3",
"core-foundation-sys 0.8.4",
"core-graphics 0.22.3",
"core-text",
"dwrote",
"foreign-types 0.5.0",
"freetype-rs",
"libc",
"log",
"objc",
"once_cell",
"pkg-config",
"servo-fontconfig",
"winapi",
]
[[package]]
name = "cty"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b365fabc795046672053e29c954733ec3b05e4be654ab130fe8f1f94d7051f35"
[[package]] [[package]]
name = "d3d12" name = "d3d12"
version = "0.6.0" version = "0.6.0"
@@ -441,6 +461,41 @@ dependencies = [
"winapi", "winapi",
] ]
[[package]]
name = "darling"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a01d95850c592940db9b8194bc39f4bc0e89dee5c4265e4b1807c34a9aba453c"
dependencies = [
"darling_core",
"darling_macro",
]
[[package]]
name = "darling_core"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "859d65a907b6852c9361e3185c862aae7fafd2887876799fa55f5f99dc40d610"
dependencies = [
"fnv",
"ident_case",
"proc-macro2",
"quote",
"strsim",
"syn 1.0.109",
]
[[package]]
name = "darling_macro"
version = "0.13.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c972679f83bdf9c42bd905396b6c3588a843a17f0f16dfcfa3e2c5d57441835"
dependencies = [
"darling_core",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "dispatch" name = "dispatch"
version = "0.2.0" version = "0.2.0"
@@ -462,6 +517,20 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650"
[[package]]
name = "dwrote"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "439a1c2ba5611ad3ed731280541d36d2e9c4ac5e7fb818a27b604bdc5a6aa65b"
dependencies = [
"lazy_static",
"libc",
"serde",
"serde_derive",
"winapi",
"wio",
]
[[package]] [[package]]
name = "env_logger" name = "env_logger"
version = "0.10.1" version = "0.10.1"
@@ -491,6 +560,16 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "expat-sys"
version = "2.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "658f19728920138342f68408b7cf7644d90d4784353d8ebc32e7e8663dbe45fa"
dependencies = [
"cmake",
"pkg-config",
]
[[package]] [[package]]
name = "failure" name = "failure"
version = "0.1.8" version = "0.1.8"
@@ -544,6 +623,12 @@ dependencies = [
"spin", "spin",
] ]
[[package]]
name = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]] [[package]]
name = "foreign-types" name = "foreign-types"
version = "0.3.2" version = "0.3.2"
@@ -586,6 +671,28 @@ version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b"
[[package]]
name = "freetype-rs"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "74eadec9d0a5c28c54bb9882e54787275152a4e36ce206b45d7451384e5bf5fb"
dependencies = [
"bitflags 1.3.2",
"freetype-sys",
"libc",
]
[[package]]
name = "freetype-sys"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a37d4011c0cc628dfa766fcc195454f4b068d7afdc2adfd28861191d866e731a"
dependencies = [
"cmake",
"libc",
"pkg-config",
]
[[package]] [[package]]
name = "fuchsia-cprng" name = "fuchsia-cprng"
version = "0.1.1" version = "0.1.1"
@@ -801,6 +908,12 @@ version = "2.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
[[package]]
name = "ident_case"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39"
[[package]] [[package]]
name = "image" name = "image"
version = "0.24.7" version = "0.24.7"
@@ -865,15 +978,6 @@ version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
[[package]]
name = "jobserver"
version = "0.1.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8c37f63953c4c63420ed5fd3d6d398c719489b9f872b9fa683262f8edd363c7d"
dependencies = [
"libc",
]
[[package]] [[package]]
name = "jpeg-decoder" name = "jpeg-decoder"
version = "0.3.0" version = "0.3.0"
@@ -949,17 +1053,6 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "libredox"
version = "0.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3af92c55d7d839293953fcd0fda5ecfe93297cfde6ffbdec13b41d99c0ba6607"
dependencies = [
"bitflags 2.4.1",
"libc",
"redox_syscall 0.4.1",
]
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"
version = "0.4.11" version = "0.4.11"
@@ -1167,8 +1260,8 @@ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"jni-sys", "jni-sys",
"ndk-sys", "ndk-sys",
"num_enum 0.5.11", "num_enum",
"raw-window-handle", "raw-window-handle 0.5.2",
"thiserror", "thiserror",
] ]
@@ -1178,6 +1271,35 @@ version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b"
[[package]]
name = "ndk-glue"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0434fabdd2c15e0aab768ca31d5b7b333717f03cf02037d5a0a3ff3c278ed67f"
dependencies = [
"libc",
"log",
"ndk",
"ndk-context",
"ndk-macro",
"ndk-sys",
"once_cell",
"parking_lot",
]
[[package]]
name = "ndk-macro"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0df7ac00c4672f9d5aece54ee3347520b7e20f158656c7db2e6de01902eb7a6c"
dependencies = [
"darling",
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 1.0.109",
]
[[package]] [[package]]
name = "ndk-sys" name = "ndk-sys"
version = "0.4.1+23.1.7779620" version = "0.4.1+23.1.7779620"
@@ -1267,16 +1389,7 @@ version = "0.5.11"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9" checksum = "1f646caf906c20226733ed5b1374287eb97e3c2a5c227ce668c1f2ce20ae57c9"
dependencies = [ dependencies = [
"num_enum_derive 0.5.11", "num_enum_derive",
]
[[package]]
name = "num_enum"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a015b430d3c108a207fd776d2e2196aaf8b1cf8cf93253e3a097ff3085076a1"
dependencies = [
"num_enum_derive 0.6.1",
] ]
[[package]] [[package]]
@@ -1291,18 +1404,6 @@ dependencies = [
"syn 1.0.109", "syn 1.0.109",
] ]
[[package]]
name = "num_enum_derive"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96667db765a921f7b295ffee8b60472b686a51d4f21c2ee4ffdb94c7013b65a6"
dependencies = [
"proc-macro-crate",
"proc-macro2",
"quote",
"syn 2.0.39",
]
[[package]] [[package]]
name = "objc" name = "objc"
version = "0.2.7" version = "0.2.7"
@@ -1313,32 +1414,6 @@ dependencies = [
"objc_exception", "objc_exception",
] ]
[[package]]
name = "objc-sys"
version = "0.2.0-beta.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df3b9834c1e95694a05a828b59f55fa2afec6288359cda67146126b3f90a55d7"
[[package]]
name = "objc2"
version = "0.3.0-beta.3.patch-leaks.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7e01640f9f2cb1220bbe80325e179e532cb3379ebcd1bf2279d703c19fe3a468"
dependencies = [
"block2",
"objc-sys",
"objc2-encode",
]
[[package]]
name = "objc2-encode"
version = "2.0.0-pre.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "abfcac41015b00a120608fdaa6938c44cb983fee294351cc4bac7638b4e50512"
dependencies = [
"objc-sys",
]
[[package]] [[package]]
name = "objc_exception" name = "objc_exception"
version = "0.1.2" version = "0.1.2"
@@ -1363,24 +1438,6 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d"
[[package]]
name = "orbclient"
version = "0.3.47"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52f0d54bde9774d3a51dcf281a5def240c71996bc6ca05d2c847ec8b2b216166"
dependencies = [
"libredox",
]
[[package]]
name = "owned_ttf_parser"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4586edfe4c648c71797a74c84bacb32b52b212eff5dfe2bb9f2c599844023e7"
dependencies = [
"ttf-parser",
]
[[package]] [[package]]
name = "palette" name = "palette"
version = "0.3.0" version = "0.3.0"
@@ -1411,7 +1468,7 @@ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
dependencies = [ dependencies = [
"cfg-if", "cfg-if",
"libc", "libc",
"redox_syscall 0.4.1", "redox_syscall",
"smallvec", "smallvec",
"windows-targets 0.48.5", "windows-targets 0.48.5",
] ]
@@ -1474,7 +1531,7 @@ checksum = "8ba8189b31db4f12fbf0d4a8eab2d7d7343a504a8d8a7ea4b14ffb2e6129136a"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"pollster", "pollster",
"raw-window-handle", "raw-window-handle 0.5.2",
"thiserror", "thiserror",
"ultraviolet", "ultraviolet",
"wgpu 0.16.3", "wgpu 0.16.3",
@@ -1657,6 +1714,15 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab"
[[package]]
name = "raw-window-handle"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b800beb9b6e7d2df1fe337c9e3d04e3af22a124460fb4c30fcc22c9117cefb41"
dependencies = [
"cty",
]
[[package]] [[package]]
name = "raw-window-handle" name = "raw-window-handle"
version = "0.5.2" version = "0.5.2"
@@ -1678,15 +1744,6 @@ dependencies = [
"rand_core 0.3.1", "rand_core 0.3.1",
] ]
[[package]]
name = "redox_syscall"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
dependencies = [
"bitflags 1.3.2",
]
[[package]] [[package]]
name = "redox_syscall" name = "redox_syscall"
version = "0.4.1" version = "0.4.1"
@@ -1782,6 +1839,15 @@ dependencies = [
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]
[[package]]
name = "safe_arch"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1ff3d6d9696af502cc3110dacce942840fb06ff4514cad92236ecc455f2ce05"
dependencies = [
"bytemuck",
]
[[package]] [[package]]
name = "safe_arch" name = "safe_arch"
version = "0.7.1" version = "0.7.1"
@@ -1805,17 +1871,57 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "sctk-adwaita" name = "sctk-adwaita"
version = "0.5.4" version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cda4e97be1fd174ccc2aae81c8b694e803fa99b34e8fd0f057a9d70698e3ed09" checksum = "61270629cc6b4d77ec1907db1033d5c2e1a404c412743621981a871dc9c12339"
dependencies = [ dependencies = [
"ab_glyph", "crossfont",
"log", "log",
"memmap2",
"smithay-client-toolkit", "smithay-client-toolkit",
"tiny-skia", "tiny-skia",
] ]
[[package]]
name = "serde"
version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
version = "1.0.192"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.39",
]
[[package]]
name = "servo-fontconfig"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7e3e22fe5fd73d04ebf0daa049d3efe3eae55369ce38ab16d07ddd9ac5c217c"
dependencies = [
"libc",
"servo-fontconfig-sys",
]
[[package]]
name = "servo-fontconfig-sys"
version = "5.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e36b879db9892dfa40f95da1c38a835d41634b825fbd8c4c418093d53c24b388"
dependencies = [
"expat-sys",
"freetype-sys",
"pkg-config",
]
[[package]] [[package]]
name = "simba" name = "simba"
version = "0.8.1" version = "0.8.1"
@@ -1901,10 +2007,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f"
[[package]] [[package]]
name = "strict-num" name = "strsim"
version = "0.1.1" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
@@ -1971,27 +2077,27 @@ dependencies = [
[[package]] [[package]]
name = "tiny-skia" name = "tiny-skia"
version = "0.8.4" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df8493a203431061e901613751931f047d1971337153f96d0e5e363d6dbf6a67" checksum = "642680569bb895b16e4b9d181c60be1ed136fa0c9c7f11d004daf053ba89bf82"
dependencies = [ dependencies = [
"arrayref", "arrayref",
"arrayvec", "arrayvec 0.5.2",
"bytemuck", "bytemuck",
"cfg-if", "cfg-if",
"png", "png",
"safe_arch 0.5.2",
"tiny-skia-path", "tiny-skia-path",
] ]
[[package]] [[package]]
name = "tiny-skia-path" name = "tiny-skia-path"
version = "0.8.4" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adbfb5d3f3dd57a0e11d12f4f13d4ebbbc1b5c15b7ab0a156d030b21da5f677c" checksum = "c114d32f0c2ee43d585367cb013dfaba967ab9f62b90d9af0d696e955e70fa6c"
dependencies = [ dependencies = [
"arrayref", "arrayref",
"bytemuck", "bytemuck",
"strict-num",
] ]
[[package]] [[package]]
@@ -2011,12 +2117,6 @@ dependencies = [
"winnow", "winnow",
] ]
[[package]]
name = "ttf-parser"
version = "0.20.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "17f77d76d837a7830fe1d4f12b7b4ba4192c1888001c7164257e4bc6d21d96b4"
[[package]] [[package]]
name = "typenum" name = "typenum"
version = "1.17.0" version = "1.17.0"
@@ -2223,14 +2323,14 @@ version = "0.16.3"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "480c965c9306872eb6255fa55e4b4953be55a8b64d57e61d7ff840d3dcc051cd" checksum = "480c965c9306872eb6255fa55e4b4953be55a8b64d57e61d7ff840d3dcc051cd"
dependencies = [ dependencies = [
"arrayvec", "arrayvec 0.7.4",
"cfg-if", "cfg-if",
"js-sys", "js-sys",
"log", "log",
"naga 0.12.3", "naga 0.12.3",
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle 0.5.2",
"smallvec", "smallvec",
"static_assertions", "static_assertions",
"wasm-bindgen", "wasm-bindgen",
@@ -2247,7 +2347,7 @@ version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30e7d227c9f961f2061c26f4cb0fbd4df0ef37e056edd0931783599d6c94ef24" checksum = "30e7d227c9f961f2061c26f4cb0fbd4df0ef37e056edd0931783599d6c94ef24"
dependencies = [ dependencies = [
"arrayvec", "arrayvec 0.7.4",
"cfg-if", "cfg-if",
"flume", "flume",
"js-sys", "js-sys",
@@ -2255,7 +2355,7 @@ dependencies = [
"naga 0.14.0", "naga 0.14.0",
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle 0.5.2",
"smallvec", "smallvec",
"static_assertions", "static_assertions",
"wasm-bindgen", "wasm-bindgen",
@@ -2272,7 +2372,7 @@ version = "0.16.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f478237b4bf0d5b70a39898a66fa67ca3a007d79f2520485b8b0c3dfc46f8c2" checksum = "8f478237b4bf0d5b70a39898a66fa67ca3a007d79f2520485b8b0c3dfc46f8c2"
dependencies = [ dependencies = [
"arrayvec", "arrayvec 0.7.4",
"bit-vec", "bit-vec",
"bitflags 2.4.1", "bitflags 2.4.1",
"codespan-reporting", "codespan-reporting",
@@ -2280,7 +2380,7 @@ dependencies = [
"naga 0.12.3", "naga 0.12.3",
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle 0.5.2",
"rustc-hash", "rustc-hash",
"smallvec", "smallvec",
"thiserror", "thiserror",
@@ -2295,7 +2395,7 @@ version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "837e02ddcdc6d4a9b56ba4598f7fd4202a7699ab03f6ef4dcdebfad2c966aea6" checksum = "837e02ddcdc6d4a9b56ba4598f7fd4202a7699ab03f6ef4dcdebfad2c966aea6"
dependencies = [ dependencies = [
"arrayvec", "arrayvec 0.7.4",
"bit-vec", "bit-vec",
"bitflags 2.4.1", "bitflags 2.4.1",
"codespan-reporting", "codespan-reporting",
@@ -2303,7 +2403,7 @@ dependencies = [
"naga 0.14.0", "naga 0.14.0",
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle", "raw-window-handle 0.5.2",
"rustc-hash", "rustc-hash",
"smallvec", "smallvec",
"thiserror", "thiserror",
@@ -2319,7 +2419,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ecb3258078e936deee14fd4e0febe1cfe9bbb5ffef165cb60218d2ee5eb4448" checksum = "1ecb3258078e936deee14fd4e0febe1cfe9bbb5ffef165cb60218d2ee5eb4448"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec 0.7.4",
"ash", "ash",
"bit-set", "bit-set",
"bitflags 2.4.1", "bitflags 2.4.1",
@@ -2343,7 +2443,7 @@ dependencies = [
"parking_lot", "parking_lot",
"profiling", "profiling",
"range-alloc", "range-alloc",
"raw-window-handle", "raw-window-handle 0.5.2",
"renderdoc-sys", "renderdoc-sys",
"rustc-hash", "rustc-hash",
"smallvec", "smallvec",
@@ -2361,7 +2461,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e30b9a8155c83868e82a8c5d3ce899de6c3961d2ef595de8fc168a1677fc2d8" checksum = "1e30b9a8155c83868e82a8c5d3ce899de6c3961d2ef595de8fc168a1677fc2d8"
dependencies = [ dependencies = [
"android_system_properties", "android_system_properties",
"arrayvec", "arrayvec 0.7.4",
"ash", "ash",
"bit-set", "bit-set",
"bitflags 2.4.1", "bitflags 2.4.1",
@@ -2386,7 +2486,7 @@ dependencies = [
"parking_lot", "parking_lot",
"profiling", "profiling",
"range-alloc", "range-alloc",
"raw-window-handle", "raw-window-handle 0.5.2",
"renderdoc-sys", "renderdoc-sys",
"rustc-hash", "rustc-hash",
"smallvec", "smallvec",
@@ -2426,7 +2526,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242" checksum = "c68938b57b33da363195412cfc5fc37c9ed49aa9cfe2156fde64b8d2c9498242"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"safe_arch", "safe_arch 0.7.1",
] ]
[[package]] [[package]]
@@ -2496,11 +2596,15 @@ dependencies = [
[[package]] [[package]]
name = "windows-sys" name = "windows-sys"
version = "0.45.0" version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2"
dependencies = [ dependencies = [
"windows-targets 0.42.2", "windows_aarch64_msvc 0.36.1",
"windows_i686_gnu 0.36.1",
"windows_i686_msvc 0.36.1",
"windows_x86_64_gnu 0.36.1",
"windows_x86_64_msvc 0.36.1",
] ]
[[package]] [[package]]
@@ -2554,6 +2658,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
[[package]]
name = "windows_aarch64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47"
[[package]] [[package]]
name = "windows_aarch64_msvc" name = "windows_aarch64_msvc"
version = "0.42.2" version = "0.42.2"
@@ -2566,6 +2676,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
[[package]]
name = "windows_i686_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6"
[[package]] [[package]]
name = "windows_i686_gnu" name = "windows_i686_gnu"
version = "0.42.2" version = "0.42.2"
@@ -2578,6 +2694,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
[[package]]
name = "windows_i686_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024"
[[package]] [[package]]
name = "windows_i686_msvc" name = "windows_i686_msvc"
version = "0.42.2" version = "0.42.2"
@@ -2590,6 +2712,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
[[package]]
name = "windows_x86_64_gnu"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1"
[[package]] [[package]]
name = "windows_x86_64_gnu" name = "windows_x86_64_gnu"
version = "0.42.2" version = "0.42.2"
@@ -2614,6 +2742,12 @@ version = "0.48.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
[[package]]
name = "windows_x86_64_msvc"
version = "0.36.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680"
[[package]] [[package]]
name = "windows_x86_64_msvc" name = "windows_x86_64_msvc"
version = "0.42.2" version = "0.42.2"
@@ -2628,13 +2762,12 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
[[package]] [[package]]
name = "winit" name = "winit"
version = "0.28.7" version = "0.27.5"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9596d90b45384f5281384ab204224876e8e8bf7d58366d9b795ad99aa9894b94" checksum = "bb796d6fbd86b2fd896c9471e6f04d39d750076ebe5680a3958f00f5ab97657c"
dependencies = [ dependencies = [
"android-activity",
"bitflags 1.3.2", "bitflags 1.3.2",
"cfg_aliases", "cocoa 0.24.1",
"core-foundation 0.9.3", "core-foundation 0.9.3",
"core-graphics 0.22.3", "core-graphics 0.22.3",
"dispatch", "dispatch",
@@ -2643,21 +2776,20 @@ dependencies = [
"log", "log",
"mio", "mio",
"ndk", "ndk",
"objc2", "ndk-glue",
"objc",
"once_cell", "once_cell",
"orbclient", "parking_lot",
"percent-encoding", "percent-encoding",
"raw-window-handle", "raw-window-handle 0.4.3",
"redox_syscall 0.3.5", "raw-window-handle 0.5.2",
"sctk-adwaita", "sctk-adwaita",
"smithay-client-toolkit", "smithay-client-toolkit",
"wasm-bindgen", "wasm-bindgen",
"wayland-client", "wayland-client",
"wayland-commons",
"wayland-protocols", "wayland-protocols",
"wayland-scanner",
"web-sys", "web-sys",
"windows-sys 0.45.0", "windows-sys 0.36.1",
"x11-dl", "x11-dl",
] ]
@@ -2670,6 +2802,15 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "wio"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d129932f4644ac2396cb456385cbf9e63b5b30c6e8dc4820bdca4eb082037a5"
dependencies = [
"winapi",
]
[[package]] [[package]]
name = "x11-dl" name = "x11-dl"
version = "2.21.0" version = "2.21.0"

View File

@@ -9,9 +9,12 @@ version = "0.24"
default-features = false default-features = false
features = ["png", "jpeg"] features = ["png", "jpeg"]
[dependencies.winit]
version = "0.27"
features = ["x11"]
[dependencies] [dependencies]
cfg-if = "1" cfg-if = "1"
winit = "0.28"
env_logger = "0.10" env_logger = "0.10"
log = "0.4" log = "0.4"
wgpu = "0.18" wgpu = "0.18"

View File

@@ -10,6 +10,7 @@ mod display;
mod light; mod light;
mod primitive; mod primitive;
mod ray; mod ray;
mod raytracer;
mod scene; mod scene;
// mod state; // mod state;
// mod texture; // mod texture;

View File

@@ -13,9 +13,9 @@ lazy_static! {
// MATERIAL ----------------------------------------------------------------- // MATERIAL -----------------------------------------------------------------
pub struct Material { pub struct Material {
kd: Vector3<f32>, pub kd: Vector3<f32>,
ks: Vector3<f32>, pub ks: Vector3<f32>,
shininess: f32, pub shininess: f32,
} }
impl Material { impl Material {
pub fn new(kd: Vector3<f32>, ks: Vector3<f32>, shininess: f32) -> Self { pub fn new(kd: Vector3<f32>, ks: Vector3<f32>, shininess: f32) -> Self {
@@ -29,17 +29,27 @@ impl Material {
} }
} }
// INTERSECTION ----------------------------------------------------------------- // INTERSECTION -----------------------------------------------------------------
pub struct Intersection { pub struct Intersection<'a> {
point: Point3<f32>,
normal: Vector3<f32>,
distance: f32,
// Information about an intersection // Information about an intersection
pub primitive: &'a dyn Primitive<'a>,
pub point: Point3<f32>,
pub normal: Vector3<f32>,
pub incidence: Vector3<f32>,
pub distance: f32,
} }
impl Intersection { impl<'a> Intersection<'a> {
pub fn new(point: Point3<f32>, normal: Vector3<f32>, t: f32) -> Self { pub fn new(
primitive: &'a dyn Primitive<'a>,
point: Point3<f32>,
normal: Vector3<f32>,
incidence: Vector3<f32>,
t: f32,
) -> Self {
Intersection { Intersection {
primitive,
point, point,
normal, normal,
incidence,
distance: t, distance: t,
} }
} }
@@ -71,8 +81,8 @@ impl BoundingBox {
// PRIMITIVE TRAIT ----------------------------------------------------------------- // PRIMITIVE TRAIT -----------------------------------------------------------------
pub trait Primitive<'a> { pub trait Primitive<'a> {
fn intersect_ray(&self, ray: &Ray) -> Option<Intersection>; fn intersect_ray(&self, ray: &Ray) -> Option<Intersection>;
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>>; fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>>;
fn get_material(self) -> &'a Material; fn get_material(&self) -> &'a Material;
} }
// SPHERE ----------------------------------------------------------------- // SPHERE -----------------------------------------------------------------
@@ -133,17 +143,19 @@ impl<'a> Primitive<'a> for Sphere<'a> {
let intersect = ray.at_t(t); let intersect = ray.at_t(t);
let normal = (intersect - self.position).normalize(); let normal = (intersect - self.position).normalize();
Some(Intersection { Some(Intersection {
primitive: self,
point: intersect, point: intersect,
normal, normal,
incidence: ray.b,
distance: t, distance: t,
}) })
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
self.material self.material
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
return self.bounding_box.intersect_bounding_box(ray); return self.bounding_box.intersect_bounding_box(ray);
} }
} }
@@ -211,19 +223,21 @@ impl<'a> Primitive<'a> for Circle<'a> {
true => return None, true => return None,
false => { false => {
return Some(Intersection { return Some(Intersection {
primitive: self,
point: intersect, point: intersect,
normal: self.normal, normal: self.normal,
incidence: ray.b,
distance: t, distance: t,
}) })
} }
} }
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
self.material self.material
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
self.bounding_box.intersect_bounding_box(ray) self.bounding_box.intersect_bounding_box(ray)
} }
} }
@@ -245,11 +259,11 @@ impl<'a> Primitive<'a> for Cylinder<'a> {
todo!() todo!()
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
todo!() todo!()
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
todo!() todo!()
} }
} }
@@ -331,8 +345,10 @@ impl<'a> Primitive<'a> for Cone<'a> {
let intersect = ray.at_t(t); let intersect = ray.at_t(t);
match intersect.y >= self.base && intersect.y <= self.height { match intersect.y >= self.base && intersect.y <= self.height {
true => Some(Intersection { true => Some(Intersection {
primitive: self,
point: intersect, point: intersect,
normal: self.get_normal(intersect), normal: self.get_normal(intersect),
incidence: ray.b,
distance: t, distance: t,
}), }),
false => None, false => None,
@@ -357,11 +373,11 @@ impl<'a> Primitive<'a> for Cone<'a> {
} }
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
self.material self.material
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
self.bounding_box.intersect_bounding_box(ray) self.bounding_box.intersect_bounding_box(ray)
} }
} }
@@ -434,19 +450,21 @@ impl<'a> Primitive<'a> for Rectangle<'a> {
if pi_dot_r1 >= -w2 && pi_dot_r1 <= w2 && pi_dot_r2 >= -h2 && pi_dot_r2 <= h2 { if pi_dot_r1 >= -w2 && pi_dot_r1 <= w2 && pi_dot_r2 >= -h2 && pi_dot_r2 <= h2 {
return Some(Intersection { return Some(Intersection {
primitive: self,
point: intersect, point: intersect,
normal: self.normal, normal: self.normal,
incidence: ray.b,
distance: t, distance: t,
}); });
} }
None None
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
self.material self.material
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
self.bounding_box.intersect_bounding_box(ray) self.bounding_box.intersect_bounding_box(ray)
} }
} }
@@ -519,8 +537,10 @@ impl<'a> Primitive<'a> for Box<'a> {
}; };
Some(Intersection { Some(Intersection {
primitive: self,
point: intersect, point: intersect,
normal, normal,
incidence: ray.b,
distance: tmin, distance: tmin,
}) })
} else { } else {
@@ -528,11 +548,11 @@ impl<'a> Primitive<'a> for Box<'a> {
} }
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
self.bounding_box.intersect_bounding_box(ray) self.bounding_box.intersect_bounding_box(ray)
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
self.material self.material
} }
} }
@@ -602,8 +622,10 @@ impl<'a> Primitive<'a> for Triangle<'a> {
if u_cross.dot(&normal) >= 0.0 && v_cross.dot(&normal) >= 0.0 && w_cross.dot(&normal) >= 0.0 if u_cross.dot(&normal) >= 0.0 && v_cross.dot(&normal) >= 0.0 && w_cross.dot(&normal) >= 0.0
{ {
Some(Intersection { Some(Intersection {
primitive: self,
point: intersect, point: intersect,
normal, normal,
incidence: ray.b,
distance: t, distance: t,
}) })
} else { } else {
@@ -611,11 +633,11 @@ impl<'a> Primitive<'a> for Triangle<'a> {
} }
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
self.material self.material
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
self.bounding_box.intersect_bounding_box(ray) self.bounding_box.intersect_bounding_box(ray)
} }
} }
@@ -725,11 +747,11 @@ impl<'a> Primitive<'a> for Mesh<'a> {
closest_intersect closest_intersect
} }
fn get_material(self) -> &'a Material { fn get_material(&self) -> &'a Material {
self.material self.material
} }
fn interesct_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> { fn intersect_bounding_box(&self, ray: &Ray) -> Option<Point3<f32>> {
self.bounding_box.intersect_bounding_box(ray) self.bounding_box.intersect_bounding_box(ray)
} }
} }

View File

@@ -1,22 +0,0 @@
#[repr(C)]
#[derive(Copy, Clone, Debug, bytemuck::Pod, bytemuck::Zeroable)]
pub struct Vertex {
pub position: [f32; 3],
pub tex_coords: [f32; 2], // NEW!
}
impl Vertex {
//Attributes of the vertexes
const ATTRIBS: [wgpu::VertexAttribute; 2] =
wgpu::vertex_attr_array![0 => Float32x3, 1 => Float32x2];
pub fn desc() -> wgpu::VertexBufferLayout<'static> {
use std::mem;
wgpu::VertexBufferLayout {
array_stride: mem::size_of::<Self>() as wgpu::BufferAddress,
step_mode: wgpu::VertexStepMode::Vertex,
attributes: &Self::ATTRIBS,
}
}
}