render-zig

A 3D rendering engine written in Zig
git clone git://git.christianermann.dev/render-zig
Log | Files | Refs

commit 39c5ff0b24c0f512c4ab7a65225501c8c37759f4
parent 8c123b66956a53e705b9cc050751d0850a69ffd4
Author: Christian Ermann <christianermann@gmail.com>
Date:   Mon, 20 May 2024 19:49:28 -0400

Add textured objects

Diffstat:
Aalps_field_4k/nx.png | 0
Aalps_field_4k/ny.png | 0
Aalps_field_4k/nz.png | 0
Aalps_field_4k/px.png | 0
Aalps_field_4k/py.png | 0
Aalps_field_4k/pz.png | 0
Acottage/cottage-fixed.obj | 1476+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Acottage/cottage_diffuse.png | 0
Msrc/main.zig | 55++++++++++++++++++++++++++++++++++++++++---------------
Asrc/material.zig | 21+++++++++++++++++++++
Msrc/render_pipeline.zig | 51++++++++++++++++++++++++++++++++++++++++++++++-----
Asrc/textures.zig | 81+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
12 files changed, 1664 insertions(+), 20 deletions(-)

diff --git a/alps_field_4k/nx.png b/alps_field_4k/nx.png Binary files differ. diff --git a/alps_field_4k/ny.png b/alps_field_4k/ny.png Binary files differ. diff --git a/alps_field_4k/nz.png b/alps_field_4k/nz.png Binary files differ. diff --git a/alps_field_4k/px.png b/alps_field_4k/px.png Binary files differ. diff --git a/alps_field_4k/py.png b/alps_field_4k/py.png Binary files differ. diff --git a/alps_field_4k/pz.png b/alps_field_4k/pz.png Binary files differ. diff --git a/cottage/cottage-fixed.obj b/cottage/cottage-fixed.obj @@ -0,0 +1,1476 @@ +# Blender 3.4.0 +# www.blender.org +mtllib cottage-fixed.mtl +o Cube_Cube.002 +v -18.223083 9.349227 -6.876913 +v 12.564275 14.635716 -1.045097 +v -17.652161 14.635716 1.113808 +v -17.490023 13.161090 3.383131 +v 12.405021 13.161092 -3.274046 +v 12.726414 13.161091 1.224226 +v 12.759602 9.349226 1.688738 +v -17.773594 0.064116 -0.585771 +v -17.523201 0.064116 2.918775 +v -17.523201 9.349226 2.918777 +v 12.564637 14.635716 -1.040023 +v 12.565000 14.635716 -1.034949 +v -17.651436 14.635716 1.123956 +v -17.651798 14.635716 1.118882 +v 12.465355 12.797903 -2.429407 +v 12.666434 12.797903 0.384938 +v -17.548832 10.149796 2.559862 +v 12.466284 10.149796 -2.416441 +v 12.667582 10.149796 0.400959 +v -17.523201 1.319650 2.918775 +v -17.773594 1.319650 -0.585771 +v -17.773594 9.349226 -0.585769 +v -17.751053 12.797903 -0.270504 +v -17.811415 13.161091 -1.115141 +v -17.750130 10.149796 -0.257538 +v -18.062685 10.834428 -4.631978 +v 11.993354 9.349228 -9.035817 +v -17.901073 0.064116 -2.370034 +v 12.153749 10.834428 -6.790883 +v 13.147573 9.349225 7.051435 +v 12.565362 14.635716 -1.029875 +v 12.980520 10.834426 4.780748 +v -17.549974 12.797903 2.543841 +v 13.147573 0.064115 7.051433 +v -18.223083 0.064117 -6.876914 +v 12.759602 0.064116 1.688736 +v 11.993354 0.064117 -9.035819 +v -17.901073 2.820832 -2.370034 +v -18.143003 2.820833 -5.756124 +v -17.153522 2.820831 8.092840 +v -17.395849 2.820831 4.701199 +v -17.523201 8.192228 2.918777 +v -17.773594 8.192228 -0.585770 +v 12.376478 9.349227 -3.673541 +v -17.901073 8.192228 -2.370033 +v -18.143003 8.192229 -5.756124 +v -17.153522 8.218716 8.092841 +v -17.395849 8.192227 4.701200 +v -17.320583 1.319650 2.904298 +v -17.570976 1.319650 -0.600248 +v -17.320583 8.192228 2.904299 +v -17.570976 8.192228 -0.600247 +v -17.773594 0.665788 -0.585771 +v -17.523201 0.677450 2.918775 +v -19.169174 0.064116 -0.486060 +v -18.918781 0.064116 3.018486 +v -18.918781 0.677450 3.018486 +v -19.169174 0.665788 -0.486060 +v -18.319582 1.319650 2.975675 +v -18.569975 1.319650 -0.528871 +v -18.569975 0.665788 -0.528871 +v -18.319582 0.677450 2.975675 +v -12.179797 0.064117 -7.308695 +v 5.950066 0.064117 -8.604038 +v -12.179797 8.192229 -7.308693 +v -7.727202 8.192229 -7.626822 +v 1.497471 8.192229 -8.285907 +v 5.950066 8.192229 -8.604037 +v -12.179797 9.349227 -7.308693 +v -7.727202 9.349227 -7.626822 +v 1.497471 9.349227 -8.285906 +v 5.950066 9.349227 -8.604036 +v -12.179797 2.820833 -7.308694 +v -7.727202 2.820833 -7.626822 +v 1.497471 2.820833 -8.285908 +v 5.950066 2.820833 -8.604038 +v -17.068863 9.349224 9.210340 +v -17.068863 0.064115 9.210338 +v -17.395849 0.064115 4.701198 +v -17.235916 10.834426 6.939653 +v -17.651073 14.635716 1.129029 +v 12.376478 0.064117 -3.673542 +v -7.727202 0.064118 -7.626823 +v 1.497471 0.064118 -8.285908 +v 12.759602 5.319118 1.688737 +v 12.376478 5.321033 -3.673541 +v 10.265352 0.064115 7.258129 +v 10.265352 7.581104 7.258131 +v 10.265352 9.349225 7.258131 +v -11.020725 9.349225 8.778978 +v -11.020725 2.236660 8.778976 +v 6.874008 9.349225 7.500433 +v -11.020725 7.581104 8.778977 +v 10.265352 0.940049 7.258129 +v -11.020725 0.064115 8.778976 +v 6.874008 0.940049 7.500432 +v 6.874008 0.064116 7.500433 +v -6.568130 0.064116 8.460846 +v -6.568131 7.581104 8.460847 +v -6.568131 9.349225 8.460848 +v -6.568131 2.236660 8.460846 +v 10.248719 7.581104 7.025322 +v 10.248719 0.940049 7.025321 +v 6.857374 7.581104 7.267626 +v 6.857374 0.940049 7.267625 +v 6.874008 0.482586 7.500432 +v 10.265352 0.491577 7.258129 +v 6.874008 7.581104 7.500433 +v 6.233222 0.453863 7.546214 +v 10.326803 0.064116 8.118205 +v 6.935459 0.064116 8.360510 +v 10.326803 0.491577 8.118205 +v 6.935458 0.482586 8.360508 +v 6.900082 0.940050 7.865362 +v 10.291426 0.940050 7.623059 +v 6.900082 0.482586 7.865364 +v 10.291426 0.491577 7.623059 +v 12.955835 6.083644 2.460784 +v 12.504873 6.083646 -4.522348 +v 14.156281 6.083645 -3.079941 +v 14.408002 6.083645 0.817951 +v 12.516963 6.083644 2.489126 +v 12.066000 6.083646 -4.494007 +v 14.486510 6.083645 -1.144193 +v 13.681919 6.083644 1.639368 +v 13.330576 6.083645 -3.801145 +v 12.481948 7.798086 -0.897715 +v 12.466896 7.798086 -1.130793 +v 12.522016 7.798086 -1.082650 +v 12.530417 7.798086 -0.952548 +v 12.467299 7.798086 -0.896769 +v 12.452247 7.798086 -1.129847 +v 12.533038 7.798086 -1.018039 +v 12.506183 7.798086 -0.925131 +v 12.494456 7.798086 -1.106721 +v 14.315139 5.681017 -3.315829 +v 14.595881 5.681017 1.031448 +v 13.394239 5.681017 -4.120180 +v 14.683440 5.681017 -1.156910 +v 13.786089 5.681016 1.947565 +v 11.983871 5.681018 -4.892922 +v 12.473340 5.681018 -4.924531 +v 12.976295 5.681016 2.863683 +v 12.486825 5.681016 2.895292 +v 14.315139 5.832798 -3.315829 +v 14.595881 5.832798 1.031448 +v 13.394239 5.832798 -4.120180 +v 14.683440 5.832798 -1.156910 +v 13.786089 5.832798 1.947565 +v 11.983871 5.832799 -4.892922 +v 12.473340 5.832799 -4.924531 +v 12.976295 5.832798 2.863683 +v 12.486825 5.832798 2.895292 +v 14.057830 5.681017 -2.678333 +v 14.258716 5.681017 0.432342 +v 13.398884 5.681017 -3.253883 +v 14.321367 5.681017 -1.133528 +v 13.679269 5.681017 1.087866 +v 12.389701 5.681017 -3.806815 +v 12.739939 5.681017 -3.829433 +v 13.099825 5.681016 1.743390 +v 12.749588 5.681016 1.766008 +v 13.137595 5.804492 1.937724 +v 12.752399 5.804492 -4.027008 +v 14.371156 5.804492 -2.285628 +v 14.162971 5.804492 -2.794956 +v 14.377982 5.804492 0.534477 +v 14.518928 5.804492 0.002602 +v 12.762728 5.804492 1.961932 +v 12.377531 0.073082 -4.002800 +v 12.377531 5.804492 -4.002799 +v 13.137595 1.517180 1.937723 +v 13.137595 5.132815 1.937724 +v 12.752399 5.132816 -4.027008 +v 14.162971 1.517180 -2.794957 +v 14.162971 5.132816 -2.794956 +v 14.518928 1.517180 0.002601 +v 14.518928 5.132816 0.002602 +v 13.005652 1.647940 1.729629 +v 13.005652 5.002056 1.729630 +v 12.670440 5.002057 -3.805100 +v 12.670440 1.647941 -3.805101 +v 14.322503 1.698788 -2.167073 +v 13.978984 1.647941 -2.662164 +v 13.978984 5.002057 -2.662163 +v 14.455430 1.698788 -0.108712 +v 14.455430 4.951208 -0.108711 +v 14.371156 0.073081 -2.285629 +v 14.445043 5.804492 -1.141513 +v 14.371156 1.517180 -2.285629 +v 14.371156 5.132816 -2.285628 +v 14.322503 4.951209 -2.167072 +v 14.377982 0.073081 0.534476 +v 13.757789 5.804492 1.236100 +v 14.377982 1.517180 0.534476 +v 14.377982 5.132816 0.534477 +v 14.156323 5.002056 0.427879 +v 12.752399 0.073082 -4.027009 +v 13.457684 5.804492 -3.410982 +v 12.752399 1.517181 -4.027009 +v 13.137595 0.073081 1.937723 +v 14.162971 0.073081 -2.794957 +v 14.518928 0.073081 0.002601 +v 12.762728 0.073081 1.961931 +v 14.156323 1.647940 0.427878 +v 10.638232 7.899085 6.867024 +v 10.640646 7.996586 6.900813 +v 10.756496 7.322557 8.522255 +v 10.758910 7.420060 8.556043 +v 6.493643 7.899085 7.163148 +v 6.496057 7.996586 7.196937 +v 6.611906 7.322557 8.818377 +v 6.614320 7.420060 8.852165 +v 6.833436 7.322557 8.802549 +v 10.534967 7.322557 8.538082 +v 10.537381 7.420060 8.571870 +v 6.835850 7.420060 8.836337 +v 10.416703 7.899085 6.882853 +v 6.715172 7.899085 7.147320 +v 6.717586 7.996586 7.181108 +v 10.419117 7.996586 6.916640 +v 10.739331 7.406230 8.282027 +v 10.741745 7.503732 8.315815 +v 6.594743 7.406230 8.578151 +v 6.597157 7.503732 8.611939 +v 6.818685 7.503732 8.596110 +v 10.520217 7.503732 8.331642 +v 10.517803 7.406230 8.297855 +v 6.816271 7.406230 8.562323 +v 10.659694 7.090041 7.167399 +v 10.651922 7.437432 7.058631 +v 6.728862 7.437431 7.338926 +v 6.507333 7.437431 7.354754 +v 10.430394 7.437432 7.074460 +v 10.438166 7.090041 7.183228 +v 6.736633 7.090041 7.447695 +v 6.515104 7.090041 7.463523 +v -17.116049 8.626936 3.225055 +v -17.149836 8.724438 3.227468 +v -18.771278 8.050410 3.343318 +v -18.805065 8.147911 3.345731 +v -17.412172 8.626937 -0.919536 +v -17.445959 8.724439 -0.917122 +v -19.067402 8.050411 -0.801273 +v -19.101189 8.147912 -0.798859 +v -19.051573 8.050411 -0.579744 +v -18.787106 8.050410 3.121788 +v -18.820892 8.147911 3.124202 +v -19.085360 8.147912 -0.577330 +v -17.131876 8.626936 3.003525 +v -17.396343 8.626937 -0.698007 +v -17.430130 8.724439 -0.695593 +v -17.165663 8.724438 3.005939 +v -18.531052 8.134082 3.326154 +v -18.564838 8.231584 3.328568 +v -18.827175 8.134083 -0.818437 +v -18.860962 8.231585 -0.816023 +v -18.845133 8.231585 -0.594494 +v -18.580666 8.231584 3.107038 +v -18.546879 8.134082 3.104623 +v -18.811346 8.134083 -0.596908 +v -17.416424 7.817894 3.246515 +v -17.307655 8.165284 3.238744 +v -17.587950 8.165285 -0.684317 +v -17.603779 8.165285 -0.905846 +v -17.323483 8.165284 3.017215 +v -17.432251 7.817894 3.024985 +v -17.696718 7.817894 -0.676546 +v -17.712545 7.817894 -0.898075 +v -0.361134 9.703708 6.751926 +v -0.304536 9.703708 7.544087 +v -2.774844 14.103484 7.720587 +v -5.301750 9.703708 7.104923 +v -5.245152 9.703708 7.897086 +v -0.630015 12.033154 2.988624 +v -0.304536 12.033154 7.544088 +v -5.245152 12.033154 7.897086 +v -5.570631 12.033154 3.341621 +v -3.277872 14.238723 0.680118 +v -2.774844 14.238722 7.720587 +v -5.245152 12.168392 7.897086 +v -5.570631 12.168392 3.341621 +v -2.748280 14.103484 8.092384 +v -0.277972 12.033154 7.915886 +v -5.218587 12.033154 8.268883 +v -2.748280 14.238722 8.092384 +v -0.277972 12.168392 7.915886 +v -5.218587 12.168392 8.268883 +v -5.706741 11.638499 7.930065 +v -5.993761 11.638499 3.912880 +v -0.129967 11.638499 3.493924 +v 0.157053 11.638499 7.511109 +v -5.706741 11.773738 7.930065 +v -5.993761 11.773738 3.912880 +v -0.129967 11.773738 3.493924 +v 0.157053 11.773738 7.511109 +v -5.680177 11.773738 8.301863 +v -5.680177 11.638499 8.301863 +v 0.183617 11.773738 7.882907 +v 0.183617 11.638499 7.882907 +v -0.304536 9.703708 7.544087 +v -2.770002 14.103484 7.720242 +v -5.245152 9.703708 7.897086 +v -2.779686 14.103484 7.720933 +v -0.304536 12.033154 7.544088 +v -5.245152 12.033154 7.897086 +v -3.598280 9.703708 7.779419 +v -1.951408 9.703708 7.661754 +v -2.773230 14.103484 7.720471 +v -2.776458 14.103484 7.720702 +v -1.839461 11.075171 7.653756 +v -3.710227 11.075171 7.787418 +v -1.537269 13.068319 7.632165 +v -4.012419 13.068319 7.809009 +v -1.836064 12.817445 7.653513 +v -3.713624 12.817445 7.787661 +v -0.630015 12.168392 2.988624 +v -3.277872 14.238723 0.680118 +v -2.774844 14.238722 7.720587 +v -0.304536 12.168392 7.544088 +v -2.748280 14.238722 8.092384 +v -0.277972 12.168392 7.915886 +v -0.129967 11.773738 3.493924 +v 0.157053 11.773738 7.511109 +v 0.183617 11.773738 7.882907 +v 12.861259 8.780826 -10.300345 +v 14.178860 8.780823 8.141031 +v -19.247341 8.780825 -8.006249 +v -17.929741 8.780822 10.435127 +v 13.520060 14.737866 -1.079657 +v -18.588541 14.737866 1.214439 +v 12.878120 8.631657 -10.064357 +v 14.161999 8.631654 7.905040 +v -19.230480 8.631656 -7.770260 +v -17.946602 8.631653 10.199137 +v 13.520060 14.525741 -1.079657 +v -18.588541 14.525741 1.214439 +vn -0.0713 -0.0000 -0.9975 +vn 0.9974 0.0019 -0.0722 +vn 0.9975 -0.0000 -0.0713 +vn -0.9975 -0.0000 0.0713 +vn -0.9975 0.0001 0.0712 +vn 0.0713 -0.0000 0.9975 +vn 0.9975 -0.0000 -0.0712 +vn 0.9975 0.0002 -0.0712 +vn -0.9975 0.0043 0.0712 +vn -0.9975 -0.0000 0.0712 +vn -0.9975 -0.0007 0.0712 +vn -0.9974 -0.0013 0.0723 +vn 0.9974 -0.0000 -0.0722 +vn -0.9971 -0.0000 0.0755 +vn -0.0000 -1.0000 -0.0000 +vn -0.0000 1.0000 -0.0000 +vn -0.0002 1.0000 -0.0033 +vn 0.0711 -0.0000 0.9975 +vn 0.0715 -0.0000 0.9974 +vn -0.0026 1.0000 0.0002 +vn 0.4371 0.7474 -0.5004 +vn 0.4978 0.7474 0.4400 +vn 0.6515 0.7505 -0.1111 +vn 0.4147 0.8328 0.3666 +vn -0.0291 0.8919 -0.4512 +vn 0.3641 0.8328 -0.4169 +vn 0.0291 0.8919 0.4512 +vn 0.6604 0.7505 0.0264 +vn 0.7492 -0.0000 0.6623 +vn -0.0644 -0.0000 -0.9979 +vn 0.6578 -0.0000 -0.7532 +vn 0.0644 -0.0000 0.9979 +vn 0.9992 -0.0000 0.0400 +vn 0.9858 -0.0000 -0.1682 +vn 0.7870 0.6162 0.0315 +vn -0.0340 0.8492 -0.5270 +vn 0.0340 0.8492 0.5270 +vn 0.7764 0.6162 -0.1324 +vn 0.9533 -0.2956 -0.0616 +vn -1.0000 -0.0000 -0.0000 +vn 1.0000 -0.0000 -0.0000 +vn 0.9979 -0.0000 -0.0644 +vn -0.4334 -0.0000 0.9012 +vn 0.3623 -0.8753 0.3203 +vn 0.9381 -0.0000 0.3465 +vn 0.9251 -0.0000 0.3797 +vn 0.3349 -0.8607 -0.3835 +vn 0.9533 0.2956 -0.0616 +vn 0.3623 0.8753 0.3203 +vn 0.3349 0.8607 -0.3835 +vn -0.5852 -0.0000 -0.8109 +vn 0.8686 -0.0000 -0.4955 +vn -0.0000 -0.0000 1.0000 +vn 0.8445 -0.0000 -0.5355 +vn 0.9666 -0.0000 0.2562 +vn 0.9257 -0.0000 -0.3784 +vn 0.0673 -0.3282 0.9422 +vn 0.0234 0.9446 0.3273 +vn -0.0234 -0.9446 -0.3273 +vn 0.0194 -0.9622 0.2716 +vn -0.9422 -0.3282 0.0673 +vn -0.3273 0.9446 0.0234 +vn 0.3273 -0.9446 -0.0234 +vn -0.2716 -0.9622 0.0194 +vn -0.6397 0.7672 0.0457 +vn 0.6472 -0.7609 -0.0462 +vn -0.6397 -0.7672 0.0457 +vn 0.6397 -0.7672 -0.0457 +vn -0.6472 -0.7609 0.0462 +vn -0.6472 0.7609 0.0462 +vn 0.6397 0.7672 -0.0457 +vn 0.6472 0.7609 -0.0462 +vn -0.0386 0.8406 -0.5403 +vn 0.0386 0.8406 0.5403 +vn 0.0390 -0.8368 0.5461 +vn -0.0390 -0.8368 -0.5462 +vn 0.0380 -0.8459 0.5320 +vn -0.0380 -0.8459 -0.5320 +vn 0.9975 -0.0002 -0.0712 +vn -0.9974 0.0012 0.0720 +vn -0.9974 -0.0021 0.0720 +vn 0.4148 0.8328 0.3666 +vn -0.0291 0.8920 -0.4512 +vn 0.7869 0.6162 0.0315 +vn -0.0234 -0.9446 -0.3274 +vn -0.9422 -0.3281 0.0673 +vn 0.0715 -0.0001 0.9974 +vn 0.0711 -0.0002 0.9975 +vn 0.0710 -0.0000 0.9975 +vt 0.013989 0.874156 +vt 0.465114 0.677529 +vt 0.438271 0.976985 +vt 0.149070 0.977760 +vt 0.187432 0.948860 +vt 0.475861 0.948156 +vt 0.400001 0.948156 +vt 0.392168 0.873631 +vt 0.120339 0.692189 +vt 0.064315 0.353402 +vt 0.153291 0.296428 +vt 0.179582 0.692189 +vt 0.179582 0.874156 +vt 0.438186 0.976985 +vt 0.438100 0.976985 +vt 0.149241 0.977760 +vt 0.149155 0.977760 +vt 0.461616 0.941055 +vt 0.414155 0.941055 +vt 0.173515 0.889846 +vt 0.461398 0.889283 +vt 0.413885 0.889283 +vt 0.185903 0.717829 +vt 0.179582 0.716795 +vt 0.285033 0.249236 +vt 0.061601 0.353599 +vt 0.120339 0.716795 +vt 0.010917 0.353616 +vt 0.117817 0.719001 +vt 0.285033 0.353779 +vt 0.120339 0.874156 +vt 0.125668 0.941743 +vt 0.111390 0.948860 +vt 0.125887 0.889846 +vt 0.051939 0.903263 +vt 0.573027 0.873631 +vt 0.012336 0.677529 +vt 0.090176 0.692189 +vt 0.535169 0.902668 +vt 0.301725 0.873631 +vt 0.464555 0.519200 +vt 0.438015 0.976985 +vt 0.340024 0.902668 +vt 0.173244 0.941743 +vt 0.301725 0.692101 +vt 0.464555 0.372380 +vt 0.013989 0.692189 +vt 0.465114 0.530709 +vt 0.392168 0.692101 +vt 0.012336 0.530709 +vt 0.573027 0.692101 +vt 0.090176 0.746215 +vt 0.032935 0.746215 +vt 0.267048 0.746215 +vt 0.209714 0.746215 +vt 0.369634 0.493505 +vt 0.185903 0.847161 +vt 0.179582 0.851482 +vt 0.117817 0.848334 +vt 0.120339 0.851482 +vt 0.421769 0.493505 +vt 0.482598 0.873631 +vt 0.090176 0.851482 +vt 0.032935 0.851482 +vt 0.267048 0.852001 +vt 0.209714 0.851482 +vt 0.179582 0.716795 +vt 0.182654 0.717829 +vt 0.288624 0.249236 +vt 0.120339 0.716795 +vt 0.114568 0.719001 +vt 0.288624 0.353779 +vt 0.182654 0.847161 +vt 0.179582 0.851482 +vt 0.369634 0.496694 +vt 0.120339 0.851482 +vt 0.421769 0.496694 +vt 0.114568 0.848334 +vt 0.120339 0.703980 +vt 0.064315 0.296386 +vt 0.270918 0.353781 +vt 0.010917 0.292972 +vt 0.061601 0.293105 +vt 0.179582 0.704209 +vt 0.270918 0.249236 +vt 0.153291 0.353313 +vt 0.246184 0.249236 +vt 0.153134 0.353402 +vt 0.064472 0.296428 +vt 0.246184 0.353780 +vt 0.064472 0.353313 +vt 0.203128 0.353780 +vt 0.246184 0.249236 +vt 0.203947 0.249236 +vt 0.153134 0.296386 +vt 0.246184 0.353781 +vt 0.010917 0.353599 +vt 0.157228 0.353780 +vt 0.270918 0.249236 +vt 0.157228 0.249236 +vt 0.270918 0.353779 +vt 0.061601 0.353616 +vt 0.203128 0.249236 +vt 0.061601 0.292972 +vt 0.010917 0.293105 +vt 0.202310 0.353780 +vt 0.374559 0.530709 +vt 0.102892 0.530709 +vt 0.374559 0.659234 +vt 0.307839 0.659234 +vt 0.169611 0.659234 +vt 0.102892 0.659234 +vt 0.374559 0.677529 +vt 0.307839 0.677529 +vt 0.169611 0.677529 +vt 0.102892 0.677529 +vt 0.374559 0.574299 +vt 0.307839 0.574299 +vt 0.169611 0.574299 +vt 0.102892 0.574299 +vt 0.285945 0.874156 +vt 0.011777 0.519200 +vt 0.285945 0.692189 +vt 0.011777 0.372380 +vt 0.209714 0.692189 +vt 0.247554 0.903263 +vt 0.149327 0.977760 +vt 0.482598 0.692101 +vt 0.307839 0.530709 +vt 0.169611 0.530709 +vt 0.392168 0.794840 +vt 0.482598 0.794877 +vt 0.421366 0.372380 +vt 0.099463 0.200274 +vt 0.364280 0.489662 +vt 0.428152 0.510327 +vt 0.421366 0.491242 +vt 0.421366 0.519200 +vt 0.102404 0.519200 +vt 0.102404 0.406733 +vt 0.370548 0.519200 +vt 0.102404 0.491242 +vt 0.421366 0.386230 +vt 0.364280 0.386348 +vt 0.138195 0.242703 +vt 0.273417 0.243464 +vt 0.102404 0.372380 +vt 0.424564 0.386887 +vt 0.138401 0.198656 +vt 0.370548 0.386230 +vt 0.273417 0.147144 +vt 0.370548 0.372380 +vt 0.099090 0.242105 +vt 0.169124 0.372380 +vt 0.169124 0.491242 +vt 0.169124 0.519200 +vt 0.169124 0.406733 +vt 0.428152 0.505073 +vt 0.421366 0.491242 +vt 0.367481 0.489662 +vt 0.421366 0.386230 +vt 0.367481 0.386348 +vt 0.263413 0.243464 +vt 0.359676 0.505073 +vt 0.370548 0.491242 +vt 0.427765 0.490200 +vt 0.370548 0.386230 +vt 0.263413 0.147144 +vt 0.427765 0.386887 +vt 0.099091 0.200351 +vt 0.370548 0.378997 +vt 0.226455 0.147144 +vt 0.138401 0.242756 +vt 0.421366 0.379139 +vt 0.138195 0.198833 +vt 0.099463 0.242089 +vt 0.226455 0.243468 +vt 0.359676 0.510327 +vt 0.424564 0.490200 +vt 0.370548 0.491242 +vt 0.360946 0.378542 +vt 0.226455 0.243465 +vt 0.018901 0.200274 +vt 0.226455 0.147144 +vt 0.018529 0.242105 +vt 0.185327 0.243465 +vt 0.018901 0.242089 +vt 0.263413 0.243468 +vt 0.018529 0.200351 +vt 0.186192 0.147144 +vt 0.263413 0.147144 +vt 0.104219 0.198656 +vt 0.185327 0.243465 +vt 0.289098 0.147144 +vt 0.185327 0.147144 +vt 0.104013 0.242703 +vt 0.289098 0.243464 +vt 0.141313 0.243465 +vt 0.104219 0.242756 +vt 0.142178 0.147144 +vt 0.104013 0.198833 +vt 0.634650 0.965297 +vt 0.944165 0.965297 +vt 0.875791 0.896517 +vt 0.703024 0.896517 +vt 0.634650 0.984749 +vt 0.944165 0.984749 +vt 0.789407 0.887459 +vt 0.668837 0.930907 +vt 0.909978 0.930907 +vt 0.784242 0.976641 +vt 0.794573 0.976641 +vt 0.792290 0.974345 +vt 0.786524 0.974345 +vt 0.784242 0.977290 +vt 0.794573 0.977290 +vt 0.789407 0.974043 +vt 0.785383 0.975493 +vt 0.793432 0.975493 +vt 0.719634 0.874405 +vt 0.974704 0.502116 +vt 0.858900 0.874405 +vt 0.974712 0.332266 +vt 0.665394 0.874405 +vt 0.940893 0.535724 +vt 0.789267 0.874405 +vt 0.983613 0.417191 +vt 0.913137 0.874405 +vt 0.940904 0.298655 +vt 0.887958 0.569331 +vt 0.584586 0.874405 +vt 0.611155 0.874405 +vt 0.907082 0.569332 +vt 0.967374 0.874404 +vt 0.907097 0.265043 +vt 0.993942 0.874404 +vt 0.887973 0.265043 +vt 0.885750 0.888833 +vt 0.719634 0.869425 +vt 0.858900 0.869425 +vt 0.693065 0.888833 +vt 0.923878 0.927188 +vt 0.665395 0.869425 +vt 0.789267 0.869425 +vt 0.789407 0.878730 +vt 0.913137 0.869425 +vt 0.654936 0.927188 +vt 0.962007 0.987237 +vt 0.584586 0.869425 +vt 0.611155 0.869425 +vt 0.962007 0.965542 +vt 0.967374 0.869425 +vt 0.616808 0.965542 +vt 0.993942 0.869425 +vt 0.616808 0.987237 +vt 0.963092 0.477958 +vt 0.963098 0.356423 +vt 0.938899 0.502006 +vt 0.969467 0.417191 +vt 0.938907 0.332372 +vt 0.901021 0.526053 +vt 0.914705 0.526054 +vt 0.914716 0.308322 +vt 0.901032 0.308321 +vt 0.580579 0.571495 +vt 0.616796 0.860216 +vt 0.966788 0.859594 +vt 0.580579 0.571495 +vt 0.848312 0.859632 +vt 0.580579 0.571495 +vt 0.875145 0.859586 +vt 0.873840 0.859632 +vt 0.580579 0.571495 +vt 0.708494 0.860217 +vt 0.710583 0.859632 +vt 0.580579 0.571495 +vt 0.736111 0.859632 +vt 0.602571 0.860216 +vt 0.979985 0.579043 +vt 0.979985 0.859504 +vt 0.616796 0.649437 +vt 0.580579 0.571495 +vt 0.616796 0.827195 +vt 0.966788 0.826726 +vt 0.875145 0.649790 +vt 0.580579 0.571495 +vt 0.875145 0.826718 +vt 0.736111 0.649843 +vt 0.580579 0.571495 +vt 0.736111 0.826765 +vt 0.622252 0.655865 +vt 0.622251 0.820766 +vt 0.960952 0.820251 +vt 0.960953 0.656121 +vt 0.842677 0.658730 +vt 0.879941 0.656113 +vt 0.879941 0.820244 +vt 0.741747 0.658730 +vt 0.741747 0.817878 +vt 0.580579 0.571495 +vt 0.848312 0.579180 +vt 0.792212 0.859632 +vt 0.848312 0.649843 +vt 0.580579 0.571495 +vt 0.848312 0.826765 +vt 0.842677 0.817878 +vt 0.580579 0.571495 +vt 0.708494 0.578440 +vt 0.710583 0.579180 +vt 0.662645 0.860217 +vt 0.708494 0.649437 +vt 0.580579 0.571495 +vt 0.708494 0.827195 +vt 0.702283 0.820766 +vt 0.966788 0.579133 +vt 0.920966 0.859590 +vt 0.966788 0.649798 +vt 0.580579 0.571495 +vt 0.616796 0.578439 +vt 0.580579 0.571495 +vt 0.875145 0.579125 +vt 0.873840 0.579180 +vt 0.580579 0.571495 +vt 0.736111 0.579180 +vt 0.602572 0.578439 +vt 0.702283 0.655865 +vt 0.346412 0.026548 +vt 0.297277 0.126067 +vt 0.337224 0.026580 +vt 0.298358 0.009374 +vt 0.297702 0.023507 +vt 0.346953 0.182910 +vt 0.337766 0.182942 +vt 0.298358 0.015756 +vt 0.297277 0.023496 +vt 0.346347 0.026381 +vt 0.337160 0.026413 +vt 0.040444 0.126067 +vt 0.346888 0.182744 +vt 0.039642 0.009374 +vt 0.040870 0.023507 +vt 0.040444 0.023495 +vt 0.039642 0.015756 +vt 0.337701 0.182776 +vt 0.053471 0.009374 +vt 0.054597 0.023507 +vt 0.284529 0.009374 +vt 0.283975 0.023507 +vt 0.284529 0.015756 +vt 0.283549 0.023496 +vt 0.053471 0.015756 +vt 0.054172 0.023495 +vt 0.283975 0.126079 +vt 0.340258 0.190661 +vt 0.340258 0.190661 +vt 0.054597 0.126079 +vt 0.054172 0.126067 +vt 0.283549 0.126067 +vt 0.297702 0.038393 +vt 0.324723 0.125554 +vt 0.346874 0.160217 +vt 0.297277 0.038382 +vt 0.337687 0.160249 +vt 0.040870 0.038393 +vt 0.007720 0.125788 +vt 0.346810 0.160051 +vt 0.040444 0.038382 +vt 0.337623 0.160082 +vt 0.054172 0.038382 +vt 0.283549 0.038382 +vt 0.283975 0.038393 +vt 0.304955 0.125637 +vt 0.340203 0.343043 +vt 0.027488 0.125705 +vt 0.340203 0.343043 +vt 0.054597 0.038393 +vt 0.324305 0.026211 +vt 0.405807 0.075294 +vt 0.379717 0.056069 +vt 0.378097 0.224459 +vt 0.379653 0.055902 +vt 0.378097 0.224459 +vt 0.407755 0.246489 +vt 0.304537 0.026294 +vt 0.407755 0.246489 +vt 0.027070 0.026362 +vt 0.405742 0.075128 +vt 0.007302 0.026445 +vt 0.346412 0.026548 +vt 0.297277 0.126067 +vt 0.337224 0.026580 +vt 0.346953 0.182910 +vt 0.298358 0.009374 +vt 0.297702 0.023507 +vt 0.337766 0.182942 +vt 0.298358 0.015756 +vt 0.297277 0.023496 +vt 0.346347 0.026381 +vt 0.337160 0.026413 +vt 0.040444 0.126067 +vt 0.346888 0.182744 +vt 0.039642 0.009374 +vt 0.040870 0.023507 +vt 0.040444 0.023495 +vt 0.039642 0.015756 +vt 0.337701 0.182776 +vt 0.053471 0.009374 +vt 0.054597 0.023507 +vt 0.284529 0.009374 +vt 0.283975 0.023507 +vt 0.284529 0.015756 +vt 0.283549 0.023496 +vt 0.053471 0.015756 +vt 0.054172 0.023495 +vt 0.283975 0.126079 +vt 0.340258 0.190661 +vt 0.340258 0.190661 +vt 0.054597 0.126079 +vt 0.054172 0.126067 +vt 0.283549 0.126067 +vt 0.324723 0.125554 +vt 0.297702 0.038393 +vt 0.346874 0.160217 +vt 0.297277 0.038382 +vt 0.337687 0.160249 +vt 0.040870 0.038393 +vt 0.007720 0.125788 +vt 0.346810 0.160051 +vt 0.040444 0.038382 +vt 0.337623 0.160082 +vt 0.054172 0.038382 +vt 0.283549 0.038382 +vt 0.283975 0.038393 +vt 0.304955 0.125637 +vt 0.340203 0.343043 +vt 0.340203 0.343043 +vt 0.054597 0.038393 +vt 0.027488 0.125705 +vt 0.324305 0.026211 +vt 0.405807 0.075294 +vt 0.379717 0.056069 +vt 0.378097 0.224459 +vt 0.379653 0.055902 +vt 0.378097 0.224459 +vt 0.407755 0.246489 +vt 0.304537 0.026294 +vt 0.027070 0.026362 +vt 0.407755 0.246489 +vt 0.405742 0.075128 +vt 0.007302 0.026445 +vt 0.928975 0.036017 +vt 0.928976 0.009986 +vt 0.934284 0.123048 +vt 0.934621 0.123310 +vt 0.929194 0.036177 +vt 0.929195 0.010146 +vt 0.981774 0.159684 +vt 0.767092 0.233866 +vt 0.981782 0.009989 +vt 0.934284 0.233866 +vt 0.982001 0.010149 +vt 0.934621 0.234128 +vt 0.767429 0.234128 +vt 0.981993 0.159845 +vt 0.693831 0.109857 +vt 0.886877 0.109857 +vt 0.886859 0.021579 +vt 0.761971 0.021579 +vt 0.947930 0.123048 +vt 0.541354 0.254807 +vt 0.948267 0.123310 +vt 0.947930 0.233866 +vt 0.654121 0.160342 +vt 0.428587 0.160342 +vt 0.948267 0.234128 +vt 0.541354 0.260978 +vt 0.897072 0.109857 +vt 0.654121 0.166512 +vt 0.897052 0.021579 +vt 0.428587 0.166513 +vt 0.934621 0.255032 +vt 0.989757 0.162796 +vt 0.989756 0.009662 +vt 0.787185 0.255032 +vt 0.986226 0.009410 +vt 0.786847 0.254770 +vt 0.986217 0.162544 +vt 0.934284 0.254770 +vt 0.986200 0.162796 +vt 0.886786 0.004986 +vt 0.986200 0.009662 +vt 0.776727 0.004986 +vt 0.989782 0.009410 +vt 0.989774 0.162544 +vt 0.986200 0.176968 +vt 0.407516 0.148505 +vt 0.896972 0.004986 +vt 0.407516 0.142334 +vt 0.989757 0.176968 +vt 0.948267 0.255032 +vt 0.989773 0.176717 +vt 0.675193 0.148505 +vt 0.947930 0.254770 +vt 0.986217 0.176716 +vt 0.675193 0.142334 +vt 0.673440 0.010110 +vt 0.543421 0.241548 +vt 0.412891 0.010110 +vt 0.542910 0.241548 +vt 0.673440 0.132644 +vt 0.412891 0.132644 +vt 0.499741 0.010110 +vt 0.586590 0.010110 +vt 0.543251 0.241548 +vt 0.543080 0.241548 +vt 0.592494 0.082252 +vt 0.493837 0.082252 +vt 0.608431 0.187096 +vt 0.477900 0.187096 +vt 0.592673 0.173899 +vt 0.493658 0.173899 +vt 0.763273 0.202785 +vt 0.694431 0.115093 +vt 0.887460 0.114908 +vt 0.886359 0.202613 +vt 0.897643 0.114899 +vt 0.896398 0.202599 +vt 0.777932 0.218969 +vt 0.886078 0.218809 +vt 0.896082 0.218795 +vt 0.814030 0.417808 +vt 0.813981 0.268314 +vt 0.832137 0.531580 +vt 0.815161 0.290216 +vt 0.813676 0.433914 +vt 0.832137 0.303348 +vt 0.489512 0.268314 +vt 0.489561 0.417808 +vt 0.823012 0.524651 +vt 0.489206 0.433914 +vt 0.489684 0.290216 +vt 0.823012 0.312654 +vt 0.814030 0.296382 +vt 0.813676 0.554734 +vt 0.905675 0.417464 +vt 0.489561 0.296382 +vt 0.489206 0.554734 +vt 0.891319 0.418653 +vt 0.830296 0.528659 +vt 0.813975 0.296733 +vt 0.813981 0.290407 +vt 0.813975 0.554968 +vt 0.815161 0.268549 +vt 0.830296 0.306269 +vt 0.489505 0.296733 +vt 0.489512 0.290408 +vt 0.821302 0.521938 +vt 0.489505 0.554968 +vt 0.821302 0.315367 +vt 0.489684 0.268549 +vt 0.813975 0.417631 +vt 0.813975 0.434070 +vt 0.903056 0.417464 +vt 0.489505 0.417631 +vt 0.489505 0.434070 +vt 0.888887 0.418653 +s 0 +usemtl cottage_texture +f 68/112/1 72/116/1 27/37/1 +f 7/8/2 32/43/2 30/40/2 +f 44/62/3 19/22/3 7/8/3 +f 22/31/4 17/20/4 25/34/4 +f 19/22/3 6/7/3 32/43/3 +f 16/19/3 31/42/3 6/7/3 +f 15/18/3 12/15/3 16/19/3 +f 23/32/5 13/16/5 14/17/5 +f 48/66/4 10/13/4 42/58/4 +f 10/13/4 43/60/4 42/58/4 +f 54/86/6 56/89/6 9/11/6 +f 79/125/4 20/24/4 54/84/4 +f 8/9/4 53/79/4 28/38/4 +f 23/32/4 3/4/4 24/33/4 +f 25/34/4 24/33/4 26/35/4 +f 22/31/4 26/35/4 1/1/4 +f 44/62/3 29/39/3 18/21/3 +f 18/21/7 5/6/7 15/18/7 +f 15/18/8 2/3/8 11/14/8 +f 43/60/4 22/31/4 45/63/4 +f 45/63/4 1/1/4 46/64/4 +f 77/121/9 48/66/9 47/65/9 +f 10/13/4 80/126/4 17/20/4 +f 17/20/10 4/5/10 33/44/10 +f 33/44/11 81/127/11 13/16/11 +f 40/54/12 79/125/12 78/123/12 +f 28/38/4 39/53/4 35/47/4 +f 21/27/4 38/52/4 28/38/4 +f 79/125/4 41/55/4 20/24/4 +f 64/108/1 76/120/1 37/50/1 +f 85/131/13 34/45/13 36/49/13 +f 77/121/14 40/54/14 78/123/14 +f 43/60/4 38/52/4 21/27/4 +f 37/51/3 86/132/3 82/128/3 +f 42/57/1 49/68/1 20/23/1 +f 41/55/4 42/58/4 20/24/4 +f 76/120/1 27/37/1 37/50/1 +f 39/53/4 1/1/4 35/47/4 +f 25/34/4 33/44/4 23/32/4 +f 51/74/4 50/70/4 49/67/4 +f 43/61/15 51/75/15 42/56/15 +f 21/29/6 52/78/6 43/59/6 +f 20/25/16 50/72/16 21/30/16 +f 20/26/6 62/105/6 54/83/6 +f 54/84/4 9/12/4 79/125/4 +f 28/38/4 53/79/4 21/27/4 +f 56/90/4 58/94/4 55/87/4 +f 8/10/1 58/95/1 53/80/1 +f 53/81/17 57/93/17 54/85/17 +f 62/106/4 60/100/4 61/103/4 +f 21/30/16 59/99/16 20/25/16 +f 53/82/1 60/102/1 21/28/1 +f 1/2/1 73/117/1 35/48/1 +f 66/110/1 75/119/1 74/118/1 +f 35/48/1 73/117/1 63/107/1 +f 73/117/1 83/129/1 63/107/1 +f 74/118/1 84/130/1 83/129/1 +f 84/130/1 76/120/1 64/108/1 +f 1/2/1 69/113/1 65/109/1 +f 69/113/1 66/110/1 65/109/1 +f 70/114/1 67/111/1 66/110/1 +f 71/115/1 68/112/1 67/111/1 +f 74/118/1 65/109/1 66/110/1 +f 76/120/1 67/111/1 68/112/1 +f 86/132/3 7/8/3 85/131/3 +f 30/40/13 85/131/13 7/8/13 +f 86/132/3 27/36/3 44/62/3 +f 104/164/15 88/136/15 108/178/15 +f 109/181/6 96/150/6 108/180/6 +f 98/154/6 109/181/6 101/157/6 +f 91/140/18 77/122/18 78/124/18 +f 34/46/19 88/137/19 94/143/19 +f 78/124/18 95/147/18 91/140/18 +f 98/154/6 91/140/6 95/147/6 +f 88/137/6 92/141/6 108/180/6 +f 77/122/18 93/142/18 90/139/18 +f 99/155/6 90/139/6 93/142/6 +f 88/137/19 30/41/19 89/138/19 +f 101/157/6 93/142/6 91/140/6 +f 97/153/4 113/189/4 106/170/4 +f 98/154/6 97/152/6 109/181/6 +f 87/133/19 34/46/19 107/174/19 +f 103/161/6 104/165/6 105/167/6 +f 102/160/4 94/144/4 88/135/4 +f 94/146/16 105/168/16 96/151/16 +f 105/169/3 108/179/3 96/148/3 +f 106/173/4 114/192/4 96/149/4 +f 34/46/19 94/143/19 107/174/19 +f 108/180/6 100/156/6 99/155/6 +f 101/157/6 108/180/6 99/155/6 +f 106/171/6 96/150/6 109/181/6 +f 97/152/6 106/171/6 109/181/6 +f 110/182/6 113/190/6 111/184/6 +f 107/176/3 110/183/3 87/134/3 +f 113/191/20 107/177/20 106/172/20 +f 117/200/6 114/193/6 116/198/6 +f 94/145/3 117/201/3 107/175/3 +f 114/194/16 94/146/16 96/151/16 +f 45/63/4 39/53/4 38/52/4 +f 40/54/4 48/66/4 41/55/4 +f 16/19/3 18/21/3 15/18/3 +f 126/210/21 145/238/21 147/242/21 +f 119/203/21 147/242/21 151/251/21 +f 118/202/22 149/247/22 125/209/22 +f 124/208/23 129/213/23 133/217/23 +f 121/205/24 134/218/24 125/209/24 +f 125/209/24 127/211/24 118/202/24 +f 123/207/25 128/212/25 119/203/25 +f 120/204/26 135/219/26 129/213/26 +f 126/210/26 128/212/26 135/219/26 +f 122/206/27 127/211/27 131/215/27 +f 124/208/28 130/214/28 121/205/28 +f 137/222/29 149/246/29 140/228/29 +f 140/228/29 152/252/29 143/234/29 +f 141/231/30 151/250/30 142/232/30 +f 138/224/31 145/239/31 136/220/31 +f 142/232/31 147/243/31 138/224/31 +f 143/234/32 153/254/32 144/236/32 +f 139/226/33 146/240/33 137/222/33 +f 136/220/34 148/244/34 139/226/34 +f 121/205/35 148/245/35 124/208/35 +f 125/209/22 146/241/22 121/205/22 +f 123/207/36 151/251/36 150/248/36 +f 122/206/37 152/253/37 118/202/37 +f 120/204/38 148/245/38 145/238/38 +f 140/229/15 161/263/15 158/260/15 +f 142/233/15 159/261/15 141/230/15 +f 136/221/15 156/258/15 138/225/15 +f 139/227/15 155/257/15 157/259/15 +f 138/225/15 160/262/15 142/233/15 +f 143/235/15 162/264/15 161/263/15 +f 137/223/15 158/260/15 155/257/15 +f 139/227/15 154/256/15 136/221/15 +f 194/310/29 173/283/29 196/313/29 +f 163/266/32 204/325/32 201/319/32 +f 178/290/39 192/306/39 191/305/39 +f 199/316/31 176/287/31 174/284/31 +f 188/300/40 165/268/40 191/304/40 +f 193/307/41 167/273/41 196/312/41 +f 189/302/42 178/290/42 191/305/42 +f 196/313/43 205/326/43 193/308/43 +f 196/313/44 180/292/44 197/314/44 +f 174/284/45 182/294/45 198/315/45 +f 191/305/46 183/295/46 188/301/46 +f 176/287/47 181/293/47 174/284/47 +f 190/303/48 186/298/48 177/288/48 +f 165/269/42 189/302/42 191/305/42 +f 188/301/42 177/288/42 203/324/42 +f 195/311/49 179/291/49 172/281/49 +f 193/308/29 172/281/29 201/319/29 +f 167/274/29 194/310/29 196/313/29 +f 198/315/31 175/285/31 202/321/31 +f 164/267/31 199/316/31 174/284/31 +f 175/285/50 182/294/50 184/296/50 +f 176/287/51 184/296/51 185/297/51 +f 178/290/52 186/298/52 187/299/52 +f 163/265/40 201/318/40 173/282/40 +f 168/276/53 203/323/53 178/289/53 +f 173/283/54 179/291/54 180/292/54 +f 198/315/30 171/280/30 164/267/30 +f 193/309/55 168/277/55 167/275/55 +f 188/301/56 166/272/56 165/269/56 +f 166/270/40 202/320/40 176/286/40 +f 192/306/42 186/298/42 183/295/42 +f 197/314/29 179/291/29 205/326/29 +f 181/293/31 184/296/31 182/294/31 +f 223/363/3 208/332/3 222/361/3 +f 217/351/57 212/340/57 214/345/57 +f 224/366/4 211/337/4 210/336/4 +f 227/370/58 207/328/58 221/358/58 +f 226/369/58 211/338/58 225/367/58 +f 226/369/58 221/358/58 220/357/58 +f 229/375/3 232/380/3 219/355/3 +f 229/376/59 218/353/59 228/371/59 +f 209/334/57 215/347/57 208/330/57 +f 216/349/57 214/345/57 215/347/57 +f 214/346/59 228/371/59 215/348/59 +f 215/348/59 222/359/59 208/331/59 +f 216/350/58 226/369/58 217/352/58 +f 217/352/58 225/367/58 213/342/58 +f 216/350/58 223/362/58 227/370/58 +f 212/341/59 229/376/59 214/346/59 +f 213/344/4 224/366/4 212/339/4 +f 207/329/3 222/361/3 206/327/3 +f 224/365/60 236/386/60 229/374/60 +f 224/366/4 233/381/4 237/387/4 +f 222/360/60 235/384/60 230/377/60 +f 222/361/3 231/379/3 206/327/3 +f 228/373/4 234/382/4 235/383/4 +f 254/423/6 241/395/6 240/392/6 +f 249/413/61 244/402/61 246/407/61 +f 257/430/1 242/398/1 256/428/1 +f 259/432/62 239/390/62 253/420/62 +f 258/431/62 243/400/62 257/429/62 +f 259/432/62 252/419/62 258/431/62 +f 261/436/6 264/442/6 251/417/6 +f 261/437/63 250/415/63 260/433/63 +f 241/396/61 247/409/61 240/393/61 +f 248/411/61 246/407/61 247/409/61 +f 246/408/63 260/433/63 247/410/63 +f 247/410/63 254/422/63 240/394/63 +f 248/412/62 258/431/62 249/414/62 +f 249/414/62 257/429/62 245/404/62 +f 241/397/62 259/432/62 248/412/62 +f 244/403/63 261/437/63 246/408/63 +f 245/406/1 256/428/1 244/401/1 +f 238/389/6 255/425/6 254/423/6 +f 261/438/64 269/450/64 268/447/64 +f 256/428/1 265/443/1 269/449/1 +f 260/434/64 262/439/64 254/421/64 +f 254/423/6 263/441/6 238/389/6 +f 260/435/1 266/444/1 267/445/1 +f 277/461/4 273/455/4 274/456/4 +f 270/451/3 276/459/3 271/452/3 +f 280/466/65 282/468/65 281/467/65 +f 277/462/66 290/484/66 278/463/66 +f 283/470/6 288/480/6 285/474/6 +f 283/470/6 287/478/6 286/476/6 +f 272/453/67 284/472/67 283/469/67 +f 281/467/65 286/477/65 280/466/65 +f 272/454/68 285/475/68 277/462/68 +f 291/485/3 296/494/3 292/487/3 +f 289/482/4 294/491/4 290/483/4 +f 289/482/4 297/495/4 293/489/4 +f 296/494/3 300/504/3 292/487/3 +f 285/474/6 297/496/6 298/498/6 +f 284/472/69 292/488/69 300/503/69 +f 284/473/6 299/502/6 287/478/6 +f 281/467/70 297/497/70 288/479/70 +f 276/460/69 291/486/69 292/488/69 +f 281/467/70 294/492/70 293/490/70 +f 277/462/66 298/500/66 289/481/66 +f 316/521/6 304/509/6 314/519/6 +f 312/517/6 303/508/6 307/512/6 +f 301/506/6 311/516/6 308/513/6 +f 311/516/6 307/512/6 308/513/6 +f 302/507/6 315/520/6 313/518/6 +f 315/520/6 310/515/6 316/521/6 +f 305/510/6 315/520/6 311/516/6 +f 316/521/6 306/511/6 312/517/6 +f 311/516/6 316/521/6 312/517/6 +f 317/522/71 319/524/71 320/525/71 +f 322/527/72 324/529/72 320/525/72 +f 319/524/71 322/527/71 320/525/71 +f 320/525/72 323/528/72 317/522/72 +f 328/538/73 330/543/73 326/531/73 +f 327/535/74 331/547/74 329/540/74 +f 332/550/75 337/564/75 334/555/75 +f 337/565/76 333/552/76 335/558/76 +f 329/541/77 333/553/77 327/534/77 +f 326/532/78 334/556/78 328/537/78 +f 329/542/4 337/566/4 335/559/4 +f 327/536/3 336/563/3 330/545/3 +f 326/533/3 336/563/3 332/549/3 +f 328/539/4 337/566/4 331/548/4 +f 7/8/3 19/22/3 32/43/3 +f 44/62/3 18/21/3 19/22/3 +f 22/31/4 10/13/4 17/20/4 +f 19/22/3 16/19/3 6/7/3 +f 16/19/79 12/15/79 31/42/79 +f 15/18/79 11/14/79 12/15/79 +f 23/32/4 33/44/4 13/16/4 +f 10/13/4 22/31/4 43/60/4 +f 54/86/6 57/91/6 56/89/6 +f 23/32/5 14/17/5 3/4/5 +f 25/34/4 23/32/4 24/33/4 +f 22/31/4 25/34/4 26/35/4 +f 44/62/3 27/36/3 29/39/3 +f 18/21/3 29/39/3 5/6/3 +f 15/18/3 5/6/3 2/3/3 +f 45/63/4 22/31/4 1/1/4 +f 77/121/80 10/13/80 48/66/80 +f 10/13/81 77/121/81 80/126/81 +f 17/20/4 80/126/4 4/5/4 +f 33/44/4 4/5/4 81/127/4 +f 40/54/4 41/55/4 79/125/4 +f 28/38/4 38/52/4 39/53/4 +f 85/131/13 30/40/13 34/45/13 +f 77/121/14 47/65/14 40/54/14 +f 43/60/4 45/63/4 38/52/4 +f 37/51/3 27/36/3 86/132/3 +f 42/57/1 51/73/1 49/68/1 +f 41/55/4 48/66/4 42/58/4 +f 76/120/1 68/112/1 27/37/1 +f 39/53/4 46/64/4 1/1/4 +f 25/34/4 17/20/4 33/44/4 +f 51/74/4 52/76/4 50/70/4 +f 43/61/15 52/77/15 51/75/15 +f 21/29/6 50/71/6 52/78/6 +f 20/25/16 49/69/16 50/72/16 +f 20/26/6 59/97/6 62/105/6 +f 56/90/4 57/92/4 58/94/4 +f 8/10/1 55/88/1 58/95/1 +f 53/81/17 58/96/17 57/93/17 +f 62/106/4 59/98/4 60/100/4 +f 21/30/16 60/101/16 59/99/16 +f 53/82/1 61/104/1 60/102/1 +f 1/2/1 65/109/1 73/117/1 +f 66/110/1 67/111/1 75/119/1 +f 73/117/1 74/118/1 83/129/1 +f 74/118/1 75/119/1 84/130/1 +f 84/130/1 75/119/1 76/120/1 +f 69/113/1 70/114/1 66/110/1 +f 70/114/1 71/115/1 67/111/1 +f 71/115/1 72/116/1 68/112/1 +f 74/118/1 73/117/1 65/109/1 +f 76/120/1 75/119/1 67/111/1 +f 86/132/3 44/62/3 7/8/3 +f 104/164/15 102/158/15 88/136/15 +f 91/140/18 93/142/18 77/122/18 +f 34/46/19 30/41/19 88/137/19 +f 98/154/6 101/157/6 91/140/6 +f 88/137/6 89/138/6 92/141/6 +f 99/155/6 100/156/6 90/139/6 +f 101/157/6 99/155/6 93/142/6 +f 97/153/4 111/185/4 113/189/4 +f 103/161/6 102/159/6 104/165/6 +f 102/160/4 103/162/4 94/144/4 +f 94/146/16 103/163/16 105/168/16 +f 105/169/3 104/166/3 108/179/3 +f 106/173/4 116/199/4 114/192/4 +f 108/180/6 92/141/6 100/156/6 +f 101/157/6 109/181/6 108/180/6 +f 110/182/6 112/186/6 113/190/6 +f 107/176/3 112/187/3 110/183/3 +f 113/191/20 112/188/20 107/177/20 +f 117/200/6 115/195/6 114/193/6 +f 94/145/3 115/196/3 117/201/3 +f 114/194/16 115/197/16 94/146/16 +f 45/63/4 46/64/4 39/53/4 +f 40/54/4 47/65/4 48/66/4 +f 16/19/3 19/22/3 18/21/3 +f 126/210/21 120/204/21 145/238/21 +f 119/203/21 126/210/21 147/242/21 +f 118/202/22 152/253/22 149/247/22 +f 124/208/23 120/204/23 129/213/23 +f 121/205/82 130/214/82 134/218/82 +f 125/209/24 134/218/24 127/211/24 +f 123/207/83 132/216/83 128/212/83 +f 120/204/26 126/210/26 135/219/26 +f 126/210/26 119/203/26 128/212/26 +f 122/206/27 118/202/27 127/211/27 +f 124/208/28 133/217/28 130/214/28 +f 137/222/29 146/240/29 149/246/29 +f 140/228/29 149/246/29 152/252/29 +f 141/231/30 150/249/30 151/250/30 +f 138/224/31 147/243/31 145/239/31 +f 142/232/31 151/250/31 147/243/31 +f 143/234/32 152/252/32 153/254/32 +f 139/226/33 148/244/33 146/240/33 +f 136/220/34 145/239/34 148/244/34 +f 121/205/84 146/241/84 148/245/84 +f 125/209/22 149/247/22 146/241/22 +f 123/207/36 119/203/36 151/251/36 +f 122/206/37 153/255/37 152/253/37 +f 120/204/38 124/208/38 148/245/38 +f 140/229/15 143/235/15 161/263/15 +f 142/233/15 160/262/15 159/261/15 +f 136/221/15 154/256/15 156/258/15 +f 139/227/15 137/223/15 155/257/15 +f 138/225/15 156/258/15 160/262/15 +f 143/235/15 144/237/15 162/264/15 +f 137/223/15 140/229/15 158/260/15 +f 139/227/15 157/259/15 154/256/15 +f 194/310/29 163/266/29 173/283/29 +f 163/266/32 169/278/32 204/325/32 +f 178/290/39 187/299/39 192/306/39 +f 199/316/31 166/271/31 176/287/31 +f 189/302/42 168/277/42 178/290/42 +f 196/313/43 197/314/43 205/326/43 +f 196/313/44 173/283/44 180/292/44 +f 174/284/45 181/293/45 182/294/45 +f 191/305/46 192/306/46 183/295/46 +f 176/287/47 185/297/47 181/293/47 +f 190/303/48 183/295/48 186/298/48 +f 188/301/42 190/303/42 177/288/42 +f 195/311/49 205/326/49 179/291/49 +f 193/308/29 195/311/29 172/281/29 +f 198/315/31 200/317/31 175/285/31 +f 175/285/50 200/317/50 182/294/50 +f 176/287/51 202/321/51 184/296/51 +f 178/290/52 203/324/52 186/298/52 +f 173/283/54 201/319/54 179/291/54 +f 198/315/30 170/279/30 171/280/30 +f 193/309/55 203/324/55 168/277/55 +f 188/301/56 202/322/56 166/272/56 +f 192/306/42 187/299/42 186/298/42 +f 197/314/29 180/292/29 179/291/29 +f 181/293/31 185/297/31 184/296/31 +f 223/363/3 209/333/3 208/332/3 +f 217/351/57 213/343/57 212/340/57 +f 224/366/4 225/368/4 211/337/4 +f 227/370/58 223/362/58 207/328/58 +f 226/369/58 220/357/58 211/338/58 +f 226/369/58 227/370/58 221/358/58 +f 229/375/3 236/385/3 232/380/3 +f 229/376/59 219/356/59 218/353/59 +f 209/334/57 216/349/57 215/347/57 +f 216/349/57 217/351/57 214/345/57 +f 214/346/85 229/376/85 228/371/85 +f 215/348/59 228/371/59 222/359/59 +f 216/350/58 227/370/58 226/369/58 +f 217/352/58 226/369/58 225/367/58 +f 216/350/58 209/335/58 223/362/58 +f 212/341/59 224/364/59 229/376/59 +f 213/344/4 225/368/4 224/366/4 +f 207/329/3 223/363/3 222/361/3 +f 224/365/60 237/388/60 236/386/60 +f 224/366/4 210/336/4 233/381/4 +f 222/360/60 228/372/60 235/384/60 +f 222/361/3 230/378/3 231/379/3 +f 228/373/4 218/354/4 234/382/4 +f 254/423/6 255/425/6 241/395/6 +f 249/413/86 245/405/86 244/402/86 +f 257/430/1 243/399/1 242/398/1 +f 259/432/62 255/424/62 239/390/62 +f 258/431/62 252/419/62 243/400/62 +f 259/432/62 253/420/62 252/419/62 +f 261/436/6 268/448/6 264/442/6 +f 261/437/63 251/418/63 250/415/63 +f 241/396/61 248/411/61 247/409/61 +f 248/411/61 249/413/61 246/407/61 +f 246/408/63 261/437/63 260/433/63 +f 247/410/63 260/433/63 254/422/63 +f 248/412/62 259/432/62 258/431/62 +f 249/414/62 258/431/62 257/429/62 +f 241/397/62 255/424/62 259/432/62 +f 244/403/63 256/426/63 261/437/63 +f 245/406/1 257/430/1 256/428/1 +f 238/389/6 239/391/6 255/425/6 +f 261/438/64 256/427/64 269/450/64 +f 256/428/1 242/398/1 265/443/1 +f 260/434/64 267/446/64 262/439/64 +f 254/423/6 262/440/6 263/441/6 +f 260/435/1 250/416/1 266/444/1 +f 277/461/4 278/464/4 273/455/4 +f 270/451/3 275/457/3 276/459/3 +f 280/466/65 279/465/65 282/468/65 +f 277/462/66 289/481/66 290/484/66 +f 283/470/6 286/476/6 288/480/6 +f 283/470/6 284/473/6 287/478/6 +f 272/453/67 276/460/67 284/472/67 +f 281/467/65 288/479/65 286/477/65 +f 272/454/68 283/471/68 285/475/68 +f 291/485/3 295/493/3 296/494/3 +f 289/482/4 293/489/4 294/491/4 +f 289/482/4 298/499/4 297/495/4 +f 296/494/3 299/501/3 300/504/3 +f 285/474/6 288/480/6 297/496/6 +f 284/472/69 276/460/69 292/488/69 +f 284/473/6 300/505/6 299/502/6 +f 281/467/70 293/490/70 297/497/70 +f 276/460/69 275/458/69 291/486/69 +f 281/467/70 282/468/70 294/492/70 +f 277/462/66 285/475/66 298/500/66 +f 316/521/87 310/515/87 304/509/87 +f 312/517/6 306/511/6 303/508/6 +f 301/506/6 305/510/6 311/516/6 +f 311/516/6 312/517/6 307/512/6 +f 302/507/88 309/514/88 315/520/88 +f 315/520/89 309/514/89 310/515/89 +f 305/510/6 313/518/6 315/520/6 +f 316/521/6 314/519/6 306/511/6 +f 311/516/6 315/520/6 316/521/6 +f 317/522/71 318/523/71 319/524/71 +f 322/527/72 325/530/72 324/529/72 +f 319/524/71 321/526/71 322/527/71 +f 320/525/72 324/529/72 323/528/72 +f 328/538/73 331/546/73 330/543/73 +f 327/535/74 330/544/74 331/547/74 +f 332/550/75 336/561/75 337/564/75 +f 337/565/76 336/562/76 333/552/76 +f 329/541/77 335/560/77 333/553/77 +f 326/532/78 332/551/78 334/556/78 +f 329/542/4 331/548/4 337/566/4 +f 327/536/3 333/554/3 336/563/3 +f 326/533/3 330/545/3 336/563/3 +f 328/539/4 334/557/4 337/566/4 diff --git a/cottage/cottage_diffuse.png b/cottage/cottage_diffuse.png Binary files differ. diff --git a/src/main.zig b/src/main.zig @@ -9,6 +9,8 @@ const RenderPipeline = @import("render_pipeline.zig").RenderPipeline; const MeshRenderPipeline = @import("render_pipeline.zig").MeshRenderPipeline; const SkyBoxRenderPipeline = @import("render_pipeline.zig").SkyBoxRenderPipeline; const CubeMap = @import("cubemap.zig"); +const Textures = @import("textures.zig"); +const Material = @import("material.zig"); const Camera = @import("camera.zig"); const input = @import("input.zig"); @@ -286,6 +288,7 @@ pub const mat4 = [4]@Vector(4, f32); const InstanceData = struct { model_matrix: mat4, + material: Material, }; pub const UniformData = struct { @@ -497,12 +500,15 @@ pub const Mesh = struct { offset: f32x3 = .{ 0.0, 0.0, 0.0 }, pub fn instanceData(self: *const Mesh) InstanceData { - return InstanceData{ .model_matrix = .{ - .{ self.scale, 0, 0, 0 }, - .{ 0, self.scale, 0, 0 }, - .{ 0, 0, self.scale, 0 }, - .{ self.offset[0], self.offset[1], self.offset[2], 1 }, - } }; + return InstanceData{ + .model_matrix = .{ + .{ self.scale, 0, 0, 0 }, + .{ 0, self.scale, 0, 0 }, + .{ 0, 0, self.scale, 0 }, + .{ self.offset[0], self.offset[1], self.offset[2], 1 }, + }, + .material = .{ .albedo = 0, .normal = 0 }, + }; } }; @@ -514,13 +520,23 @@ pub fn main() !void { try app.init(allocator); defer app.deinit(); + var textures = Textures.init(allocator, app.device); + + //const images = .{ + // .pos_x = "cube/cube-pos-x.png", + // .neg_x = "cube/cube-neg-x.png", + // .pos_y = "cube/cube-pos-y.png", + // .neg_y = "cube/cube-neg-y.png", + // .pos_z = "cube/cube-pos-z.png", + // .neg_z = "cube/cube-neg-z.png", + //}; const images = .{ - .pos_x = "cube/cube-pos-x.png", - .neg_x = "cube/cube-neg-x.png", - .pos_y = "cube/cube-pos-y.png", - .neg_y = "cube/cube-neg-y.png", - .pos_z = "cube/cube-pos-z.png", - .neg_z = "cube/cube-neg-z.png", + .pos_x = "alps_field_4k/px.png", + .neg_x = "alps_field_4k/nx.png", + .pos_y = "alps_field_4k/py.png", + .neg_y = "alps_field_4k/ny.png", + .pos_z = "alps_field_4k/pz.png", + .neg_z = "alps_field_4k/nz.png", }; const cube_map = try CubeMap.init(images, allocator, &app); @@ -539,8 +555,9 @@ pub fn main() !void { _ = try load_obj.loadFile(.{ .allocator = allocator, .mesh_buffer = &mesh_buffer, - .path = "bunny-fixed.obj", - .scale = 1.5, + .path = "cottage/cottage-fixed.obj", + .scale = 1, + .offset = .{ 0, -5, 15 }, }); _ = try load_obj.loadFile(.{ .allocator = allocator, @@ -550,7 +567,14 @@ pub fn main() !void { .offset = .{ 0, -0.5, 0 }, }); - var rp = try MeshRenderPipeline.init(&app, &mesh_buffer, allocator); + var rp = try MeshRenderPipeline.init(&app, &mesh_buffer, &textures); + + _ = try Material.init( + &textures, + "cottage/cottage_diffuse.png", + app.queue, + ); + var skybox = SkyBoxRenderPipeline.init(&app, cube_map); var fp = ForwardScreenPass.init(.{ @@ -571,6 +595,7 @@ pub fn main() !void { .inv_view = undefined, .inv_proj = undefined, }; + while (!app.window.shouldClose()) { glfw.pollEvents(); diff --git a/src/material.zig b/src/material.zig @@ -0,0 +1,21 @@ +const std = @import("std"); +const gpu = @import("mach_gpu"); +const Textures = @import("textures.zig"); + +albedo: u32, +normal: u32, + +const Self = @This(); + +pub fn init( + textures: *Textures, + albedo_path: []const u8, + queue: *gpu.Queue, +) !Self { + const albedo = try textures.loadFile(albedo_path, queue); + + return .{ + .albedo = albedo, + .normal = 0, + }; +} diff --git a/src/render_pipeline.zig b/src/render_pipeline.zig @@ -7,6 +7,7 @@ const UniformData = @import("main.zig").UniformData; const f32x4 = @import("main.zig").f32x4; const mat4 = @import("main.zig").mat4; const CubeMap = @import("cubemap.zig"); +const Textures = @import("textures.zig"); pub const RenderPipeline = struct { ptr: *anyopaque, @@ -96,22 +97,34 @@ pub const MeshRenderPipeline = struct { bind_group: *gpu.BindGroup, uniform_buffer: *gpu.Buffer, - pub fn init(app: *App, mesh_buffer: *const MeshBuffer, _: std.mem.Allocator) !MeshRenderPipeline { + pub fn init( + app: *App, + mesh_buffer: *const MeshBuffer, + textures: *const Textures, + ) !MeshRenderPipeline { const vs = \\ struct VertexInput { \\ @location(0) position: vec4<f32>, \\ @location(1) normal: vec3<f32>, + \\ @location(2) tex_coord: vec3<f32>, \\ }; \\ \\ struct VertexOutput { \\ @builtin(position) clip_position: vec4<f32>, \\ @location(0) normal: vec3<f32>, + \\ @location(1) tex_coord: vec3<f32>, + \\ @location(2) @interpolate(flat) instance_id: u32, \\ }; \\ \\ @group(0) @binding(0) \\ var<storage, read> instances: array<Instance>; \\ struct Instance { \\ model_matrix: mat4x4<f32>, + \\ material: Material, + \\ }; + \\ struct Material { + \\ albedo: u32, + \\ normal: u32, \\ }; \\ \\ @group(0) @binding(1) @@ -128,7 +141,7 @@ pub const MeshRenderPipeline = struct { \\ let model_matrix = instances[idx].model_matrix; \\ let camera_matrix = uniform_data.proj_matrix * uniform_data.view_matrix; \\ let matrix = camera_matrix * model_matrix; - \\ return VertexOutput(matrix * in.position, in.normal); + \\ return VertexOutput(matrix * in.position, in.normal, in.tex_coord, idx); \\ } ; const vs_module = app.device.createShaderModuleWGSL("default vertex shader", vs); @@ -145,11 +158,29 @@ pub const MeshRenderPipeline = struct { \\ struct VertexOutput { \\ @builtin(position) position: vec4<f32>, \\ @location(0) normal: vec3<f32>, + \\ @location(1) tex_coord: vec3<f32>, + \\ @location(2) @interpolate(flat) instance_id: u32, \\ }; \\ + \\ @group(0) @binding(0) + \\ var<storage, read> instances: array<Instance>; + \\ struct Instance { + \\ model_matrix: mat4x4<f32>, + \\ material: Material, + \\ }; + \\ struct Material { + \\ albedo: u32, + \\ normal: u32, + \\ }; + \\ + \\ @group(0) @binding(2) var material_sampler: sampler; + \\ @group(0) @binding(3) var material_texture: texture_2d_array<f32>; + \\ \\ @fragment fn main(in: VertexOutput) -> @location(0) vec4<f32> { - \\ let color = (in.normal + 1.0) * 0.5; - \\ return vec4<f32>(color, 1.0); + \\ let material = instances[in.instance_id].material; + \\ let uv = vec2<f32>(in.tex_coord.x, 1 - in.tex_coord.y); + \\ let sample = textureSample(material_texture, material_sampler, uv, material.albedo); + \\ return sample; \\ } ; const fs_module = app.device.createShaderModuleWGSL("default fragment shader", fs); @@ -180,6 +211,8 @@ pub const MeshRenderPipeline = struct { .entries = &.{ gpu.BindGroup.Entry.buffer(0, mesh_buffer.instances.data, 0, mesh_buffer.instances.size), gpu.BindGroup.Entry.buffer(1, uniform_buffer, 0, @sizeOf(UniformData)), + gpu.BindGroup.Entry.sampler(2, textures.sampler), + gpu.BindGroup.Entry.textureView(3, textures.view), }, }); const bind_group = app.device.createBindGroup(&bind_group_descriptor); @@ -246,12 +279,20 @@ pub const MeshRenderPipeline = struct { .entries = &.{ gpu.BindGroupLayout.Entry.buffer(0, .{ .vertex = true, - .fragment = false, + .fragment = true, }, .read_only_storage, false, 0), gpu.BindGroupLayout.Entry.buffer(1, .{ .vertex = true, .fragment = false, }, .uniform, false, 0), + gpu.BindGroupLayout.Entry.sampler(2, .{ + .vertex = false, + .fragment = true, + }, .filtering), + gpu.BindGroupLayout.Entry.texture(3, .{ + .vertex = false, + .fragment = true, + }, .float, .dimension_2d_array, false), }, }); return device.createBindGroupLayout(&descriptor); diff --git a/src/textures.zig b/src/textures.zig @@ -0,0 +1,81 @@ +const std = @import("std"); +const gpu = @import("mach_gpu"); +const Image = @import("zigimg").Image; + +allocator: std.mem.Allocator, +texture: *gpu.Texture, +view: *gpu.TextureView, +sampler: *gpu.Sampler, +offset: u32 = 0, + +const Self = @This(); + +pub fn init(allocator: std.mem.Allocator, device: *gpu.Device) Self { + const tex_size = gpu.Extent3D{ + .width = 2048, + .height = 2048, + .depth_or_array_layers = 128, + }; + const texture = device.createTexture(&.{ + .size = tex_size, + .format = .rgba8_unorm, + .dimension = .dimension_2d, + .usage = .{ + .texture_binding = true, + .copy_dst = true, + .render_attachment = false, + }, + }); + const view = texture.createView( + &gpu.TextureView.Descriptor{ + .dimension = .dimension_2d_array, + }, + ); + const sampler = device.createSampler(&.{ + .mag_filter = .linear, + .min_filter = .linear, + }); + + return .{ + .allocator = allocator, + .texture = texture, + .view = view, + .sampler = sampler, + }; +} + +pub fn loadFile( + self: *Self, + path: []const u8, + queue: *gpu.Queue, +) !u32 { + var image = try Image.fromFilePath(self.allocator, path); + defer image.deinit(); + + const tex_width = 2048; + const tex_height = 2048; + const tex_size = gpu.Extent3D{ .width = tex_width, .height = tex_height }; + + const data_layout = gpu.Texture.DataLayout{ + .bytes_per_row = tex_width * 4, + .rows_per_image = tex_height, + }; + const destination = gpu.ImageCopyTexture{ + .texture = self.texture, + .origin = gpu.Origin3D{ .x = 0, .y = 0, .z = self.offset }, + }; + defer self.offset += 1; + + switch (image.pixels) { + .rgba32 => |pixels| { + queue.writeTexture( + &destination, + &data_layout, + &tex_size, + pixels, + ); + }, + else => @panic("unsupported image color format"), + } + return self.offset; +}