first commit

This commit is contained in:
DawidPietrykowski 2021-08-07 23:14:51 +02:00
commit 28286395d0
61 changed files with 8170 additions and 0 deletions

14
.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
.vscode/.browse.c_cpp.db*
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
.vscode
lib
include
test
packages
.vs
bin
obj
build
makeP.bat

162
CMakeLists.txt Normal file
View File

@ -0,0 +1,162 @@
cmake_minimum_required(VERSION 3.10)
# So library linking is more sane.
cmake_policy(SET CMP0003 NEW)
# So syntax problems are errors.
cmake_policy(SET CMP0010 NEW)
# Input directories must have CMakeLists.txt
cmake_policy(SET CMP0014 NEW)
# Compile definitions.
cmake_policy(SET CMP0043 NEW)
# Use ROOT variables in find_package.
cmake_policy(SET CMP0074 NEW)
# Convert relative paths to absolute in target_sources()
cmake_policy(SET CMP0076 NEW)
# Copy files from source directory to destination directory, substituting any
# variables. Create destination directory if it does not exist.
macro(configure_files srcDir destDir)
message(STATUS "Configuring directory ${destDir}")
make_directory(${destDir})
file(GLOB templateFiles RELATIVE ${srcDir} ${srcDir}/*)
foreach(templateFile ${templateFiles})
set(srcTemplatePath ${srcDir}/${templateFile})
if(NOT IS_DIRECTORY ${srcTemplatePath})
message(STATUS "Configuring file ${templateFile}")
configure_file(
${srcTemplatePath}
${destDir}/${templateFile}
@ONLY)
endif(NOT IS_DIRECTORY ${srcTemplatePath})
endforeach(templateFile)
endmacro(configure_files)
# Initialize project
project(GPURayTracer)
# Add executable
add_executable(${PROJECT_NAME})
set(default_build_type "Release")
set(CMAKE_BINARY_DIR ${CMAKE_BINARY_DIR}/bin)
set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Find GLFW
set(GLFW_BUILD_DOCS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(GLFW_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
find_path(GLFW_INCLUDE_DIR GLFW/glfw3.h
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/lib
${GLFW_ROOT}
${GLFW_ROOT}/include)
if(GLFW_INCLUDE_DIR)
message(STATUS "GLFW_INCLUDE_DIR: ${GLFW_INCLUDE_DIR}")
else()
message(FATAL_ERROR "glfw3.h not found")
endif()
find_path(GLFW_LIB_DIR glfw3.lib
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/lib
${GLFW_ROOT}/lib
${GLFW_ROOT}/lib-vc2019
${GLFW_ROOT}/lib-vc2017
${GLFW_ROOT}/lib-vc2015)
if(GLFW_LIB_DIR)
message(STATUS "GLFW_LIB_DIR: ${GLFW_LIB_DIR}")
else()
message(FATAL_ERROR "glfw3.lib not found")
endif()
# Find GLEW
find_package(GLEW REQUIRED)
if(GLEW_FOUND)
set(GLEW_INCLUDE_DIR ${GLEW_INCLUDE_DIRS})
get_filename_component(GLEW_LIBRARIES ${GLEW_LIBRARIES} DIRECTORY)
message(STATUS "GLEW_INCLUDE_DIR: ${GLEW_INCLUDE_DIR}")
message(STATUS "GLEW_LIBRARIES: ${GLEW_LIBRARIES}")
else()
message(FATAL_ERROR "GLEW not found")
endif()
# Find OpenGL
if(NOT WIN32)
find_package(OpenGL REQUIRED)
endif()
# Find stb_image
find_path(stb_image_INCLUDE_DIR stb_image.h
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include/stb
${CMAKE_CURRENT_SOURCE_DIR}/lib
${stb_image_ROOT})
if(stb_image_INCLUDE_DIR)
message(STATUS "stb_image_INCLUDE_DIR: ${stb_image_INCLUDE_DIR}")
else()
message(FATAL_ERROR "stb_image not found")
endif()
# Find stb_image
find_path(ComputeEngine_LIB_DIR ComputeEngine.lib
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/lib
${ComputeEngine_ROOT}
${ComputeEngine_ROOT}/lib
${ComputeEngine_ROOT}/bin
${ComputeEngine_ROOT}/bin/x64/Release)
if(ComputeEngine_LIB_DIR)
message(STATUS "ComputeEngine_LIB_DIR: ${ComputeEngine_LIB_DIR}")
else()
message(FATAL_ERROR "ComputeEngine.lib not found")
endif()
find_path(ComputeEngine_INCLUDE_DIR ComputeEngine.h
HINTS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/lib
${ComputeEngine_ROOT}
${ComputeEngine_ROOT}/src)
if(ComputeEngine_INCLUDE_DIR)
message(STATUS "ComputeEngine_INCLUDE_DIR: ${ComputeEngine_INCLUDE_DIR}")
else()
message(FATAL_ERROR "ComputeEngine not found")
endif()
# Add source
add_subdirectory(src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src
${GLFW_INCLUDE_DIR}
${OPENGL_INCLUDE_DIR}
${stb_image_INCLUDE_DIR}
${ComputeEngine_INCLUDE_DIR}
${GLEW_INCLUDE_DIR})
target_link_directories(${PROJECT_NAME} PUBLIC ${GLFW_LIB_DIR} ${GLEW_LIBRARIES} ${ComputeEngine_LIB_DIR})
target_link_libraries(${PROJECT_NAME} "glfw3.lib" "opengl32.lib" "glew32s.lib" "ComputeEngine.lib")
# Copy shaders, assets and configs for binaries to access
file(COPY shaders DESTINATION ${CMAKE_BINARY_DIR}/Release)
file(COPY assets DESTINATION ${CMAKE_BINARY_DIR}/Release)
file(COPY configs DESTINATION ${CMAKE_BINARY_DIR}/Release)

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2021 Dawid Pietrykowski
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

79
README.md Normal file
View File

@ -0,0 +1,79 @@
# GPU Ray Tracer
GPU Ray Tracing application based on my OpenGL Compute Engine.
<p align="center">
<img src="screenshots/fox2.png">
</p>
## Dependencies
* OpenGL
* GLFW
* GLEW
* [stb_image](https://github.com/nothings/stb)
* [OpenGL Compute Engine](https://github.com/DawidPietrykowski/ComputeEngine)
## Build
Specify these root directories for dependencies in [make.bat](make.bat) script:
* GLFW_ROOT
* GLEW_ROOT
* stb_image_ROOT
* ComputeEngine_ROOT
Run [make.bat](make.bat) script.
## Config files
Each scene/configuration is described in a config file.
Example scenes are located in [/configs](configs) directory.
All available parameters are specified in [config_template.txt](config_template.txt).
## Usage
Pass chosen config file to the generated executable as an argument in command line.
If no argument given, *config.txt* is picked.
## Features
* Wavefront (.obj) file import
* PNG, JPG, HDR texture import
* Object can be an imported triangle mesh, sphere or infinite plane
* Each scene is saved in a separate file
* Specular and diffuse reflections
* Physics based refractions
* Camera movement
* Screenshot saving
## Example images
Mesh | Refraction
:-------------------------:|:-------------------------:
![](screenshots/fox2.png) | ![](screenshots/refraction1.png)
Multiple meshes 1 | Multiple meshes 2
![](screenshots/objects1.png) | ![](screenshots/objects4.jpg)
Solar system 1 | Solar system 2
![](screenshots/solar_system1.png) | ![](screenshots/solar_system2.png)
## Keys
Camera
* UP - SPACE
* DOWN - CTRL
* LEFT - A
* RIGHT - D
* FORWARD - W
* BACKWARD - S
Window
* Screenshot - L
* Disable input to window - P
* Close application - ESC
## License and copyright
© Dawid Pietrykowski
Licensed under the [MIT LICENSE](LICENSE)

14
assets/objects/Tri1.obj Normal file
View File

@ -0,0 +1,14 @@
# Blender v2.93.1 OBJ File: ''
# www.blender.org
mtllib Tri1.mtl
o Triangle1_Plane.001
v 0.000000 0.250000 0.250000
v -0.000000 -0.250000 0.250000
v -0.000000 -0.250000 -0.250000
vt 0.000000 0.000000
vt 0.000000 0.000000
vt 0.000000 0.000000
vn 1.0000 -0.0000 0.0000
usemtl None
s off
f 2/1/1 3/2/1 1/3/1

14
assets/objects/Tri2.obj Normal file
View File

@ -0,0 +1,14 @@
# Blender v2.93.1 OBJ File: ''
# www.blender.org
mtllib Tri2.mtl
o Triangle1_Plane.001
v 0.000000 0.866000 0.000000
v -0.000000 0.000000 0.500000
v -0.000000 0.000000 -0.500000
vt 0.000000 0.000000
vt 0.000000 0.000000
vt 0.000000 0.000000
vn 1.0000 -0.0000 0.0000
usemtl None
s off
f 2/1/1 3/2/1 1/3/1

749
assets/objects/bunny.obj Normal file
View File

@ -0,0 +1,749 @@
# Aspose.3D Wavefront OBJ Exporter
# Copyright 2004-2020 Aspose Pty Ltd.
# File created: 03/29/2021 23:03:24
#
# object obj_49383600
#
v 29.2269916534423828 18.7071514129638672 44.5394935607910156
v 46.1599884033203125 16.62591552734375 49.9615364074707032
v 36.51894378662109376 26.35740280151367188 43.72159194946289056
v 46.75090789794921872 -33.6832923889160156 10.30902957916259764
v 55.25984191894531248 -29.120697021484375 14.60501098632812496
v 55.13576507568359376 -33.8189773559570312 21.71150970458984376
v 31.11716461181640624 26.49944305419921872 112.43421173095703128
v 23.36201286315917968 20.39640235900878904 106.93875885009765632
v 29.54286956787109376 11.76572322845458992 111.69308471679687504
v 13.9773006439208984 -17.52171897888183592 65.43387603759765624
v 12.46042060852050784 -27.63136100769042968 52.31146621704101564
v 27.16110801696777344 -20.2105083465576172 64.58981323242187504
v 21.05088043212890625 14.74404239654541008 31.4851055145263672
v 5.5918617248535156 20.20020103454589844 48.56942749023437504
v 56.67658233642578128 18.93350028991699216 42.7540321350097656
v 63.93592834472656256 15.73615455627441408 34.6951332092285156
v -19.51201629638671872 -24.39798164367675784 57.55654144287109376
v -22.7219352722167968 -26.36110877990722656 64.22136688232421876
v -22.55702209472656248 -7.86387681961059568 60.11608505249023438
v 63.09252166748046876 13.91029834747314448 22.04300689697265625
v 74.1036834716796875 -2.43334007263183592 25.02628326416015625
v 65.3927001953125 1.68511331081390384 12.97910213470458992
v 8.38037967681884768 43.98431015014648432 107.66382598876953128
v 18.30934715270996092 45.19732666015625 97.1142120361328125
v 6.27607679367065428 42.75445175170898432 90.71604156494140624
v 56.4393882751464844 12.56831359863281248 14.20601367950439452
v 49.96049880981445312 21.4942588806152344 29.36673736572265624
v 7.37312126159667968 -20.27310562133789064 19.88604927062988288
v 10.06119537353515625 -10.79148197174072272 10.21739006042480468
v 7.33784532546997072 -24.84254455566406256 15.42577457427978512
v 38.37430191040039064 19.97419738769531248 16.78899765014648432
v 28.56501770019531248 26.42728805541992184 32.5672569274902344
v -1.81486070156097408 -7.4848670959472656 11.85942077636718752
v -0.45687121152877808 -12.88178730010986336 5.25388288497924804
v 10.39310741424560544 6.1247873306274414 14.84242916107177728
v 31.86298942565917968 17.09134864807128906 15.07627010345458984
v 13.46739578247070312 17.5025672912597656 8.85838127136230464
v 4.80457162857055664 10.327667236328125 78.9310302734375
v 9.65761470794677736 7.29352474212646484 79.93582153320312496
v 11.32273197174072264 10.6953716278076172 68.51003265380859376
v 82.99677276611328128 -9.7580680847167968 31.68515968322753904
v 82.0118255615234375 -22.4488468170166016 25.6991024017333984
v 84.232940673828125 -10.80918884277343744 23.27418136596679688
v 16.21977233886718752 41.00417709350585937 112.51364135742187504
v 3.3307161331176758 19.61721611022949216 82.53744506835937504
v 4.80430507659912112 14.35305404663085936 89.171173095703125
v -23.88985443115234368 -7.02867889404296875 67.72207641601562496
v -17.01632499694824218 6.63105201721191408 62.73796463012695312
v 10.39754581451416016 -3.8880867958068848 89.70954132080078128
v 22.6168804168701172 2.45894670486450192 96.78727722167968752
v 7.05195331573486328 -3.02997994422912597 92.85295867919921872
v 19.87436485290527344 -37.05016326904296875 7.22531938552856444
v 31.45262718200683592 -34.74391937255859376 15.3894691467285156
v 17.84795188903808592 -29.94757270812988288 17.25342369079589844
v 28.90240287780761712 20.60258674621582032 94.55020904541015624
v 36.36320877075195312 19.8498458862304688 93.3807373046875
v 59.22303771972656248 11.8868484497070312 63.99115753173828128
v 68.24211883544921876 9.4947519302368164 51.54703521728515624
v 57.81429290771484368 13.20491218566894532 53.83342361450195312
v 77.16011810302734376 -20.24839019775390624 40.03556060791015625
v 64.277557373046875 -29.07714462280273438 17.08965492248535156
v 75.23549652099609376 -20.46164321899414064 30.35824203491210936
v 38.195709228515625 23.46821212768554688 110.77934265136718752
v 35.36323165893554688 30.64352035522460936 105.76884460449218752
v 55.15216064453125 -35.40131378173828128 50.349212646484375
v 71.84775543212890624 -25.79500007629394528 51.51260757446289064
v 62.42802810668945312 -28.38229179382324216 60.18896865844726564
v 76.14128875732421876 -2.21626663208007812 55.11595535278320312
v 77.44384002685546872 -9.29251861572265624 31.786386489868164
v -20.51168060302734376 -9.21454811096191408 46.44171905517578128
v -15.61965370178222656 -19.2349529266357422 41.25363540649414064
v -15.29505920410156248 -17.33992576599121092 55.17271804809570312
v 48.75199890136718752 -10.750253677368164 75.2489013671875
v 63.7695426940917968 -6.07431173324584961 69.47257232666015624
v 50.79566955566406256 1.50849759578704832 72.232696533203125
v -16.08183479309082031 1.18278908729553224 36.27231216430664064
v -7.13561248779296876 -15.08703708648681641 23.83534812927246096
v -10.10804557800292968 -20.98357963562011712 31.13195610046386718
v 13.18477058410644532 0.51076304912567136 81.565673828125
v 16.88176727294921872 -3.67467927932739256 71.50720977783203128
v -7.09630823135375976 11.37934875488281248 82.82804107666015632
v 4.5982027053833008 36.35845565795898436 84.12895965576171876
v -17.36277961730957032 -2.177473783493042 54.5558433532714844
v -5.4625592231750488 11.13649368286132812 58.63687133789062496
v -8.19248962402343752 14.45539283752441408 44.9015007019042968
v -2.56485056877136232 12.45848274230957032 77.94854736328124992
v 1.88036775588989264 37.06636810302734375 110.21144104003906248
v -2.58205103874206544 3.2919635772705078 90.29957580566406248
v 9.67969989776611328 4.9975509643554688 100.12470245361328124
v -4.20537090301513672 -8.04032707214355469 93.7403640747070312
v 6.3861947059631348 8.4257755279541016 90.64358520507812496
v -21.59369850158691408 -5.9087843894958496 86.37941741943359376
v -14.11741065979003906 -16.906991958618164 88.40599822998046872
v -20.01825714111328125 -24.49141311645507816 77.26279449462890624
v -19.34169197082519532 -1.29073989391326904 78.16192626953125
v 74.177459716796875 6.97171211242675776 41.44295501708984376
v 3.63041520118713376 -19.40182685852050784 88.53870391845703128
v -6.77209520339965824 -27.36722183227539064 83.07039642333984375
v -7.55354213714599608 1.5064057111740112 24.98490905761718752
v 16.29630851745605468 -30.71138000488281248 28.90166664123535152
v 8.90513324737548832 5.376802921295166 5.27490663528442384
v 54.83198547363281248 12.99079322814941408 5.35187101364135744
v 54.9233512878417968 -0.2649933695793152 5.37623500823974608
v 22.39579963684082032 18.55037307739257816 5.31186628341674804
v 47.88055801391601568 -23.29201889038085936 72.03797149658203125
v 42.55121994018554688 -31.09136199951171876 64.35157775878906248
v -6.452786922454834 -22.76462936401367184 5.37584447860717776
v -4.46216583251953128 33.056182861328125 103.48020935058593752
v 32.65083694458007816 16.57406425476074216 59.56192779541015624
v 6.2392578125 4.27880477905273436 21.56959152221679688
v -4.71177959442138672 -24.59897804260253904 55.313018798828125
v -1.69332873821258544 -30.4149131774902344 44.65390396118164064
v 74.37795257568359376 -16.98300933837890624 5.28086519241333008
v 67.26598358154296876 -25.76189041137695312 5.33583116531372072
v -5.43409252166748048 1.44832193851470944 7.63063430786132816
v 67.75669097900390624 -19.78534507751464848 64.53250122070312496
v 42.71334838867187504 -41.42763137817382816 30.45937919616699216
v 62.88567733764648432 -34.11768722534179688 37.38273239135742184
v 49.20783233642578124 -39.96623229980468752 41.97236633300781248
v 27.72405433654785152 -39.77682113647460944 41.86899566650390624
v 31.18092536926269532 -41.30659103393554688 27.11434364318847656
v 39.49838638305664064 -40.30412292480468752 46.21828842163085936
v 29.23694992065429688 1.37228035926818848 68.70236968994140624
v -9.31655120849609376 8.58915328979492184 87.90459442138671872
v 1.37167084217071536 -29.63838195800781248 8.03566932678222656
v -4.24593162536621092 23.64100456237792968 94.46986389160156248
v -14.4831504821777344 -32.90485763549804688 70.88102722167968752
v 19.48527145385742184 38.6300697326660156 93.62115478515625
v 17.3737812042236328 15.59567546844482424 62.4346351623535156
v 43.60511398315429688 11.60811328887939456 63.7271766662597656
v 21.24066543579101564 36.32899475097656248 104.2266845703125
v 5.31533336639404296 -16.9998817443847656 80.26005554199218752
v -5.81819772720336912 -33.93497085571289056 62.8038368225097656
v 1.50082623958587648 -25.9176101684570312 65.0045013427734375
v 70.4715576171875 -5.5913705825805664 5.29483366012573244
v 23.54933738708496096 -31.61586570739746096 47.89533233642578128
v -1.42583394050598144 -28.69783210754394528 35.92781066894531248
v 41.233245849609375 26.83197402954101568 32.63880538940429688
v 79.97744750976562496 -3.08799314498901367 21.75872993469238288
v 30.0410614013671875 30.60115051269531248 103.61256408691406248
v 46.4701499938964844 -32.18011856079101562 5.31205368041992188
v 2.11345338821411132 16.71648406982421872 32.44476318359375
v 12.69772148132324216 -28.18157005310058592 5.31037855148315428
v 6.41978120803833008 -6.827970027923584 13.85188674926757808
v 3.26982116699218752 34.31559371948242188 94.0829010009765625
v 10.60813045501708984 28.95355415344238288 101.51660919189453128
v -2.15479731559753418 20.62360763549804688 100.33632659912109376
v 35.53003692626953128 14.81942272186279296 95.24540710449218752
# 148 vertices
vn -0.24970725178718568 0.335138738155365 0.90847581624984736
vn 0.58663380146026608 -0.68023526668548584 -0.43947783112525936
vn -0.58970361948013304 0.02240115590393543 0.8073090314865112
vn -0.11968009173870086 -0.77974206209182736 0.61455595493316648
vn 0.00984428916126489 0.95510029792785648 -0.29611912369728088
vn 0.3422042727470398 0.9374650120735168 -0.06368373334407806
vn -0.88608634471893312 -0.09288705885410308 -0.45411783456802368
vn 0.78809839487075808 0.45536118745803832 -0.41418239474296568
vn -0.17316585779190064 0.9836288690567016 -0.04987861961126328
vn 0.28597408533096312 0.87417888641357424 -0.3924666941165924
vn -0.9808505177497864 0.1398676335811615 -0.1355334222316742
vn 0.17641238868236542 0.944634199142456 -0.27666741609573364
vn -0.13296101987361908 -0.7807365655899048 0.61055040359497072
vn -0.26642125844955444 0.50407081842422488 0.82154262065887456
vn 0.45560252666473392 0.8328297138214112 0.31435805559158324
vn 0.97492736577987664 -0.15222430229187012 0.16230946779251098
vn 0.18393364548683168 0.94179677963256832 0.28140234947204588
vn 0.980362355709076 0.18354213237762452 -0.07212463766336441
vn -0.90259510278701776 0.3811984956264496 -0.20002451539039612
vn 0.19521434605121612 -0.87338674068450928 0.44619157910346984
vn -0.21468737721443176 -0.81695955991744992 0.53524422645568848
vn -0.02623104117810726 0.75605422258377072 -0.65398311614990232
vn 0.34847211837768556 0.93447768688201904 0.07292895019054413
vn 0.70180815458297728 -0.70147013664245608 -0.1241169273853302
vn 0.9511099457740784 0.26676183938980104 -0.15565338730812072
vn 0.43107223510742184 -0.41208776831626896 0.80272060632705696
vn 0.46852850914001464 -0.8453678488731384 0.25658187270164488
vn 0.99857264757156368 0.01312204729765653 0.05177278071641922
vn -0.87739181518554688 -0.47222936153411864 0.08475296199321747
vn 0.30397418141365052 0.17952677607536316 0.93561202287673952
vn -0.87742161750793456 -0.1293361485004425 -0.46195617318153384
vn 0.70160865783691408 0.59344148635864256 0.394426703453064
vn 0.86883020401000976 0.48049768805503848 0.11939853429794312
vn -0.8860017657279968 0.42451477050781248 -0.18651574850082396
vn -0.46557700634002688 0.61207479238510128 -0.6392202377319336
vn -0.4331026375293732 0.85269522666931152 0.29211801290512084
vn 0.23017500340938568 0.3837095499038696 -0.89430779218673712
vn -0.27761799097061156 0.5507288575172424 0.78716325759887696
vn -0.50597679615020752 -0.4822068810462952 0.71516710519790648
vn -0.05731432139873505 0.29756078124046324 0.95298093557357792
vn -0.15161794424057006 0.1999972015619278 0.9679943919181824
vn -0.39843684434890744 -0.10290705412626266 0.91140455007553104
vn -0.91902154684066768 0.01152918674051761 0.39403861761093136
vn 0.97970312833786016 0.20036180317401884 -0.00607372634112834
vn -0.07604511082172394 -0.49492880702018736 0.86559957265853888
vn 0.58766359090805056 0.55032050609588624 -0.59312635660171512
vn -0.61296755075454712 0.6532816290855408 -0.444402813911438
vn -0.25731432437896728 0.84149378538131712 0.47505536675453184
vn -0.69050753116607664 -0.70993500947952272 -0.13853384554386138
vn -0.94031602144241328 0.31791672110557556 0.12138663232326508
vn 0.00091938686091452 -0.00183164933696389 -0.9999979138374328
vn -0.91666120290756224 0.39955899119377136 0.00921220518648624
vn 0.38958337903022768 0.35762888193130492 0.84872043132781984
vn -0.42257112264633176 -0.62938845157623288 0.65215325355529784
vn -0.35814094543457032 -0.20813685655593872 0.91017258167266848
vn 0.96752774715423584 0.23525057733058928 -0.09245149046182632
vn 0.23099730908870696 -0.7584441900253296 0.60942810773849488
vn 0.00077152898302301 -0.00208726129494607 -0.99999749660491936
vn -0.67242550849914552 0.70947641134262088 0.2109196037054062
vn 0.08263169974088669 0.98913156986236576 0.12161709368228912
vn -0.4773918688297272 0.8574798107147216 -0.19189944863319396
vn -0.64278203248977664 -0.73420298099517824 0.21858009696006776
vn -0.43309852480888368 0.8729092478752136 -0.22462211549282072
vn 0.70491415262222288 -0.57367825508117672 -0.41712024807929992
vn 0.65345120429992672 0.36738818883895872 0.66183644533157352
vn 0.3835110664367676 0.83584380149841312 0.39279058575630184
vn -0.18719570338726044 0.09710923582315444 -0.97751092910766608
vn -0.04110484942793846 0.98158979415893552 0.18652568757534028
vn 0.98395121097564704 0.0064542256295681 -0.17832091450691224
vn -0.35631072521209716 -0.52095669507980344 0.77565890550613408
vn 0.75926911830902096 -0.01362873055040836 0.65063405036926272
vn 0.3662022650241852 -0.9262694120407104 -0.08899912238121033
vn -0.07596495002508163 -0.99346333742141728 0.08520513772964478
vn -0.62271571159362792 0.64145410060882568 0.44806453585624696
vn -0.867759108543396 0.49605607986450192 0.03037312813103199
vn -0.24098789691925048 0.83659124374389648 -0.49197551608085632
vn -0.15761986374855042 0.26063117384910584 0.95248484611511232
vn -0.8934364318847656 -0.1040610894560814 0.43696984648704528
vn -0.74617767333984368 0.51857739686965944 -0.4174881875514984
vn 0.42130696773529056 0.6251288056373596 0.65704977512359616
vn -0.37906581163406376 0.39054381847381592 -0.83891874551773072
vn -0.76252144575119024 0.6304311752319336 0.14531882107257844
vn -0.58096396923065184 -0.38351902365684512 0.71790951490402224
vn -0.90442204475402832 0.38492888212203976 -0.18398508429527284
vn -0.97930699586868288 0.05213161930441856 0.19555065035820008
vn -0.03246266394853592 -0.78993684053421024 0.61232829093933104
vn -0.23338073492050172 -0.60974746942520144 0.75745719671249392
vn -0.40711835026741024 -0.70672720670700072 0.57861149311065672
vn 0.29023453593254088 0.70350641012191776 0.64872384071350096
vn 0.24933953583240508 0.94970089197158816 0.18946781754493712
vn -0.93680673837661744 -0.3394310772418976 0.08473329246044159
vn 0.78614675998687744 -0.38708937168121336 -0.48180401325225832
vn -0.21969813108444212 0.85461348295211792 0.47049820423126224
vn -0.4548523724079132 0.28636524081230164 0.84327000379562384
vn -0.1351923793554306 0.58017039299011232 0.80319696664810176
vn 0.84922689199447632 -0.46912801265716552 -0.24234803020954132
vn 0.6859333515167236 -0.6897874474525452 0.2317083328962326
vn 0.81231909990310672 -0.36861407756805416 0.45195287466049192
vn -0.72827202081680304 0.68292677402496336 0.05684136226773262
vn 0.69593769311904904 -0.57742089033126832 0.42691430449485776
vn 0.08928497135639191 -0.93556761741638176 -0.34167444705963136
vn -0.83724951744079584 0.38946789503097536 -0.38383334875106808
vn 0.74938112497329712 0.59438335895538328 0.2917814254760742
vn -0.00062140071531757 -0.00193380715791136 -0.9999979138374328
vn 0.26474756002426148 0.78145855665206912 -0.56500548124313352
vn 0.69879382848739624 -0.71498209238052368 -0.022086001932621
vn -0.07554682344198227 -0.88416182994842528 0.46103197336196896
vn 0.08319604396820068 0.98910063505172736 0.12148407846689224
vn -0.47051095962524416 -0.67786937952041624 0.56490051746368408
vn -0.31242719292640688 -0.759678602218628 -0.57033121585845944
vn -0.4428110122680664 0.87765204906463616 -0.18342643976211548
vn -0.03207950294017791 0.99906057119369504 0.02913457900285721
vn 0.24092940986156464 0.66491419076919552 -0.70699512958526608
vn 0.845348596572876 0.47518694400787352 0.2440965324640274
vn -0.25282615423202516 0.11301334202289582 0.96088862419128416
vn 0.34230560064315796 0.82477170228958128 0.45008721947669984
vn -0.75951063632965088 0.48111817240715024 0.43780001997947696
vn 0.13204924762248992 -0.85053431987762448 0.50907212495803832
vn -0.71592551469802856 -0.6547850966453552 0.2422954887151718
vn 0.3695416748523712 -0.90742516517639168 -0.20004631578922272
vn 0.51897203922271728 -0.78812813758850096 0.33094111084938048
vn 0.20764878392219544 -0.8857771158218384 0.41506728529930112
vn -0.04760785400867462 0.67377614974975584 -0.73740029335021968
vn -0.08264333754777908 0.5271016359329224 0.84577417373657232
vn -0.47727379202842712 -0.6667965650558472 0.57235658168792728
vn 0.11665602028369904 -0.08298873901367188 -0.98969906568527216
vn -0.7406159043312072 0.63651543855667112 0.21525846421718596
vn -0.59942573308944704 -0.78168958425521856 -0.17219233512878418
vn 0.95688569545745856 -0.16917262971401214 0.23611515760421752
vn 0.00732587231323123 -0.12825435400009156 0.99171423912048336
vn 0.86832356452941888 0.49156215786933896 0.06618776917457581
vn -0.76541084051132208 -0.58674436807632448 0.26434314250946044
vn 0.23154971003532408 0.46257615089416504 0.85580843687057488
vn -0.0003464994370006025 0.00482736714184284 -0.999988317489624
vn 0.03126725181937217 0.66377341747283936 -0.74727988243103024
vn -0.31111782789230348 -0.94751060009002688 0.0736844390630722
vn -0.26918122172355652 0.9625107645988464 -0.03338463231921196
vn -0.11666978895664216 -0.96342885494232176 0.241232231259346
vn -0.01139813940972089 0.50898200273513792 -0.86070168018341072
vn -0.52416664361953736 0.09105326980352402 0.84673410654068
vn 0.19841088354587556 -0.0703740194439888 0.97758919000625616
vn -0.25919866561889648 0.96544104814529424 -0.02719704993069172
vn -0.43537938594818112 -0.82428520917892464 -0.36193740367889408
vn -0.18235620856285096 0.88287919759750368 0.43274769186973568
vn -0.58329147100448608 -0.810556709766388 -0.05262040719389915
vn 0.66281384229660032 -0.70260530710220336 0.25888913869857788
vn -0.4590415060520172 0.77249658107757568 0.43878236413002016
vn 0.94158095121383664 0.29038530588150024 -0.17059224843978882
vn 0.1920674741268158 -0.87005656957626336 0.45399516820907592
vn 0.07280475646257401 0.71784144639968872 0.69238942861557008
vn 0.18146096169948576 0.98329883813858032 0.01397569105029106
vn -0.44449236989021304 -0.89380341768264768 0.05951415374875069
vn 0.88266384601593024 -0.2511926293373108 -0.39724907279014584
vn -0.81446379423141472 -0.28465747833251952 -0.50558757781982424
vn -0.3900039196014404 -0.13602347671985626 0.91071099042892464
vn -0.02743688412010669 -0.23214401304721832 -0.97229439020156864
vn -0.00270320149138569 0.00739135965704917 -0.9999690055847168
vn -0.96895503997802736 0.03772541135549545 -0.24434180557727812
vn -0.80084294080734256 0.482166200876236 0.35519900918006896
vn -0.54156059026718136 0.76763302087783808 -0.34271225333213808
vn -0.33642020821571352 0.31739115715026856 0.8866139650344848
vn -0.06564720720052719 -0.81724977493286128 0.57253229618072512
vn 0.18778356909751892 0.94455975294113152 0.26934033632278444
vn 0.07425961643457413 -0.6908647418022156 0.71916025876998904
vn -0.02873853221535682 -0.95765948295593264 -0.28646546602249144
vn -0.42025744915008544 -0.63216543197631832 0.6509612202644348
vn -0.24677959084510804 0.33114317059516908 0.91073817014694208
vn 0.63567203283309936 -0.76634061336517328 -0.0929684340953827
vn 0.42679980397224424 0.89061766862869264 -0.156978040933609
vn 0.07198487967252731 -0.99373155832290656 0.08553241193294525
vn -0.21225672960281372 -0.8563271164894104 0.47079825401306152
vn -0.01990937069058418 0.991133451461792 0.13137024641036988
vn -0.65347522497177128 0.62485998868942264 -0.4272237420082092
vn 0.181496724486351 -0.9831812381744384 0.02033745683729648
vn 0.91251486539840704 -0.4032281935214996 0.0687287226319313
vn -0.70801609754562376 0.47971197962760928 -0.5182563662528992
vn 0.00323506281711161 -0.0005073354113847 -0.99999463558197024
vn 0.61500161886215208 -0.62446051836013792 0.48147901892662048
vn -0.18677607178688048 -0.96281766891479488 -0.19518424570560456
vn -0.84726375341415408 0.29374650120735168 -0.44255745410919192
vn 0.29467985033988952 -0.95493042469024656 0.035660270601511
vn -0.4542710185050964 0.89012598991394048 -0.03624364361166954
vn 0.1536216139793396 -0.82550781965255744 -0.5430812239646912
vn 0.1178147867321968 0.24622704088687896 0.96202492713928224
vn 0.3805832862854004 -0.25408482551574708 0.88915538787841792
vn 0.2119954824447632 -0.88903737068176272 0.40579614043235776
vn 0.54523766040802 0.82186877727508544 0.16506853699684144
vn -0.87479120492935184 -0.19817112386226656 -0.4421182572841644
vn 0.51406896114349368 -0.74190211296081536 -0.43048155307769776
vn 0.40594604611396792 -0.20300176739692688 0.89106571674346928
vn 0.07256699353456497 0.99423390626907344 -0.07894936949014664
vn 0.96768462657928464 -0.1671919971704483 -0.18876777589321136
vn -0.56235808134078976 -0.81748104095458992 0.1244109719991684
vn -0.3534061312675476 0.92720389366149904 -0.12408474087715148
vn 0.96662914752960208 0.23146969079971312 -0.10977175831794738
vn 0.11324802786111832 -0.98250836133956912 0.14782492816448212
vn 0.730815589427948 0.59084439277648928 -0.3417769968509674
vn -0.72052550315856936 0.36794048547744752 -0.587760865688324
vn -0.79797774553298944 0.02162783592939376 -0.6022987365722656
vn -0.86098223924636848 -0.11725813150405884 -0.49493446946144104
vn 0.34074115753173828 -0.71537107229232792 0.61003249883651736
vn 0.314597487449646 -0.2071406841278076 0.92634826898574832
vn 0.58933055400848392 0.03212351724505424 -0.8072530627250672
vn 0.83304929733276368 0.53696709871292112 -0.13302306830883026
vn -0.92414301633834832 0.36888316273689272 0.09942293167114258
vn 0.8962576985359192 -0.22189226746559144 0.3840389549732208
vn -0.50519466400146488 0.3843364715576172 0.77269905805587776
vn 0.0470973514020443 0.42943313717842104 -0.90186971426010128
vn 0.37397915124893192 -0.5923548936843872 0.713621199131012
vn 0.69862163066864016 -0.49630698561668392 -0.51537090539932248
vn -0.7558361887931824 0.58611941337585448 0.2918487787246704
vn -0.30359488725662232 0.56810718774795536 -0.7649080753326416
vn 0.24735680222511292 0.74033153057098384 -0.62507903575897216
vn 0.8039842247962952 -0.5946462154388428 -0.00229078996926546
vn -0.90941148996353152 0.134738489985466 0.39346697926521304
vn 0.02006429806351661 0.98665112257003792 -0.16160748898983002
vn -0.4049139618873596 -0.6234914660453796 -0.66880720853805544
vn -0.77831488847732544 -0.575738787651062 0.25050109624862672
vn 0.65230089426040648 -0.75646907091140752 -0.04751938953995705
vn 0.55365586280822752 -0.79709297418594368 -0.24105605483055116
vn -0.94793128967285152 -0.23128956556320192 0.21893236041069032
vn 0.44380423426628112 0.01548610720783472 -0.89598995447158816
vn -0.00649344967678189 -0.00100055860821157 -0.99997842311859136
vn -0.02935789711773395 -0.99744534492492672 0.0651223435997963
vn -0.66109728813171384 -0.12028507888317108 -0.74059563875198368
vn -0.14275053143501282 -0.49430289864540104 -0.85748875141143792
vn -0.92662185430526736 0.3654223680496216 0.08853521943092346
vn 0.53284692764282224 0.04001355543732643 -0.8452650904655456
vn -0.10722923278808594 -0.72367829084396368 0.68175631761550904
vn 0.46183589100837704 0.46508270502090456 -0.75525206327438352
vn 0.79232209920883184 0.3368428945541382 -0.50868707895278928
vn -0.25137388706207276 0.06059076637029648 -0.96599167585372928
vn 0.70324552059173584 -0.69976836442947384 -0.12557868659496308
vn -0.57037681341171264 -0.40104922652244568 0.7168192267417908
vn 0.29595935344696044 -0.20618622004985808 0.93268179893493648
vn -0.35042396187782288 -0.81379395723342896 -0.46361887454986576
vn 0.0893765464425087 0.96938210725784304 -0.2287142425775528
vn 0.2189742773771286 0.86373382806777952 0.45388776063919064
vn -0.02437883056700229 0.63375842571258544 0.7731467485427856
vn 0.57484298944473264 0.76977801322937008 0.27748396992683412
vn -0.829281747341156 0.42418590188026432 -0.36381044983863832
vn -0.42911335825920104 0.06272477656602859 0.90107011795043952
vn 0.41679540276527408 0.48391243815422056 -0.76948702335357664
vn -0.58530229330062864 -0.80025374889373776 -0.1304420828819275
vn -0.69929701089859008 -0.36175790429115296 0.6165345907211304
vn -0.33860161900520324 -0.84582865238189696 -0.412216991186142
vn 0.19018015265464784 -0.91245865821838384 0.3622853457927704
vn 0.58625453710556032 0.7969778180122376 0.14536863565444946
vn -0.76684629917144768 0.52661973237991336 -0.36690381169319152
vn 0.3967168033123016 -0.89283728599548336 -0.21320721507072448
vn 0.6390816569328308 -0.70578795671463016 -0.30567634105682372
vn 0.81943345069885248 -0.52335655689239504 0.23372355103492736
vn -0.02236813306808471 -0.39762631058692936 0.91727477312088016
vn 0.68345886468887328 -0.68132919073104856 0.26205825805664064
vn 0.662276029586792 0.71120834350585936 -0.23573967814445496
vn -0.94917905330657952 -0.28425881266593932 -0.13511516153812408
vn -0.24385102093219756 0.05513159558176994 -0.9682443737983704
vn 0.92163252830505376 -0.21699032187461852 0.32172766327857972
vn -0.59916043281555176 -0.29900810122489928 0.74269843101501472
vn 0.30421969294548036 -0.68268746137619016 0.6643705368041992
vn -0.14878547191619874 -0.23548351228237152 -0.9604219794273376
vn 0.30264484882354736 0.8722368478775024 -0.38419911265373232
vn -0.10183964669704438 -0.86706489324569696 -0.48767530918121336
vn -0.07060958445072174 -0.45508888363838192 0.88764202594757088
vn -0.34092089533805848 -0.74231290817260736 -0.57684004306793216
vn 0.47806212306022648 -0.85514181852340704 0.20047219097614288
vn -0.53284490108489992 0.03276726603507995 -0.84557825326919552
vn 0.43560233712196352 -0.8834867477416992 0.17234212160110474
vn 0.80032420158386224 0.2750980854034424 -0.53273093700408936
vn -0.37371090054512024 0.92690175771713264 -0.03454373031854629
vn 0.37024173140525816 0.92837828397750848 0.03216942772269249
vn -0.00130573567003011 0.94870293140411376 0.31616625189781188
vn 0.3672155141830444 -0.72098428010940544 0.58765166997909544
vn -0.12668929994106292 -0.61159676313400272 -0.78096044063568112
vn -0.99764347076416016 -0.04934253171086311 0.04767455905675888
vn 0.07933630794286728 0.73581790924072272 0.67251598834991456
vn 0.16893370449543 0.98548865318298336 -0.01653703302145004
vn 0.51867145299911496 0.85223740339279168 0.06834724545478821
vn -0.869807243347168 0.47973987460136416 0.11526080220937728
vn 0.5568217635154724 -0.7862743735313416 -0.26780992746353148
vn -0.58765739202499392 -0.78793954849243168 -0.18387508392333984
vn 0.17885938286781312 -0.93345445394515984 0.31092146039009096
vn 0.24281634390354156 -0.49061292409896848 0.83686268329620368
vn 0.00254566385410726 0.0210823006927967 -0.99977451562881472
vn 0.11186173558235168 0.88735210895538336 0.44731780886650088
vn 0.35582318902015688 -0.89400541782379152 -0.27229419350624084
vn 0.28187409043312072 -0.54387426376342776 0.79040986299514768
vn -0.72130668163299568 0.5902274250984192 0.3624200224876404
vn 0.07440707087516785 -0.9645628929138184 -0.25314417481422424
vn 0.8855117559432984 0.39393779635429384 0.24633708596229552
vn 0.6433589458465576 -0.35749533772468568 -0.67696845531463624
vn 0.98037433624267584 -0.18629010021686552 -0.06451502442359924
# 292 vertex normals
g obj_49383600
s 1
f 1//1 2//1 3//1
f 4//2 5//2 6//2
f 7//3 8//3 9//3
f 10//4 11//4 12//4
f 1//5 13//5 14//5
f 15//6 16//6 3//6
f 17//7 18//7 19//7
f 20//8 21//8 22//8
f 23//9 24//9 25//9
f 26//10 27//10 20//10
f 28//11 29//11 30//11
f 27//12 31//12 32//12
f 33//13 34//13 29//13
f 35//14 36//14 37//14
f 38//15 39//15 40//15
f 41//16 42//16 43//16
f 44//17 24//17 23//17
f 38//18 45//18 46//18
f 47//19 48//19 19//19
f 49//20 50//20 51//20
f 52//21 53//21 54//21
f 55//22 56//22 39//22
f 57//23 58//23 59//23
f 60//24 61//24 62//24
f 63//25 56//25 64//25
f 62//26 42//26 41//26
f 65//27 66//27 67//27
f 68//28 60//28 69//28
f 70//29 71//29 72//29
f 73//30 74//30 75//30
f 76//31 77//31 78//31
f 57//32 68//32 58//32
f 79//33 80//33 39//33
f 81//34 25//34 82//34
f 83//35 48//35 84//35
f 14//36 85//36 84//36
f 45//37 38//37 86//37
f 87//38 44//38 23//38
f 88//39 51//39 89//39
f 90//40 51//40 88//40
f 46//41 88//41 91//41
f 92//42 93//42 90//42
f 47//43 94//43 95//43
f 68//44 69//44 96//44
f 97//45 93//45 98//45
f 20//46 22//46 26//46
f 76//47 85//47 99//47
f 40//48 14//48 84//48
f 100//49 28//49 54//49
f 101//50 35//50 37//50
f 102//51 103//51 104//51
f 83//52 76//52 70//52
f 75//53 74//53 57//53
f 98//54 93//54 94//54
f 105//55 73//55 12//55
f 91//56 38//56 46//56
f 106//57 67//57 105//57
f 104//58 103//58 107//58
f 23//59 108//59 87//59
f 109//60 2//60 1//60
f 13//61 36//61 110//61
f 111//62 71//62 112//62
f 91//63 55//63 39//63
f 113//64 42//64 114//64
f 68//65 57//65 74//65
f 59//66 58//66 15//66
f 115//67 101//67 34//67
f 104//68 37//68 36//68
f 102//69 26//69 103//69
f 106//70 105//70 12//70
f 68//71 74//71 116//71
f 117//72 118//72 119//72
f 120//73 121//73 122//73
f 3//74 32//74 1//74
f 83//75 85//75 76//75
f 36//76 32//76 31//76
f 123//77 73//77 75//77
f 70//78 72//78 83//78
f 32//79 36//79 13//79
f 7//80 63//80 64//80
f 37//81 104//81 101//81
f 124//82 95//82 92//82
f 125//83 30//83 107//83
f 126//84 81//84 124//84
f 18//85 94//85 19//85
f 111//86 11//86 10//86
f 51//87 9//87 89//87
f 94//88 127//88 98//88
f 15//89 3//89 2//89
f 86//90 38//90 40//90
f 34//91 33//91 115//91
f 46//92 45//92 128//92
f 40//93 129//93 14//93
f 107//94 29//94 34//94
f 130//95 123//95 75//95
f 128//96 131//96 46//96
f 132//97 133//97 134//97
f 79//98 10//98 80//98
f 124//99 81//99 95//99
f 132//100 10//100 49//100
f 121//101 4//101 117//101
f 48//102 83//102 19//102
f 68//103 96//103 58//103
f 114//104 107//104 135//104
f 103//105 22//105 135//105
f 66//106 118//106 60//106
f 11//107 111//107 112//107
f 14//108 109//108 1//108
f 12//109 136//109 106//109
f 137//110 28//110 100//110
f 8//111 55//111 91//111
f 138//112 32//112 3//112
f 24//113 82//113 25//113
f 44//114 131//114 24//114
f 124//115 92//115 88//115
f 41//116 139//116 21//116
f 89//117 8//117 91//117
f 65//118 67//118 122//118
f 94//119 18//119 127//119
f 6//120 61//120 118//120
f 132//121 134//121 10//121
f 67//122 106//122 122//122
f 56//123 55//123 140//123
f 109//124 123//124 130//124
f 106//125 136//125 120//125
f 34//126 104//126 107//126
f 81//127 48//127 95//127
f 137//128 112//128 78//128
f 49//129 10//129 79//129
f 62//130 41//130 69//130
f 41//131 43//131 139//131
f 136//132 100//132 120//132
f 123//133 109//133 40//133
f 141//134 107//134 114//134
f 142//135 13//135 110//135
f 100//136 136//136 11//136
f 101//137 115//137 35//137
f 114//138 42//138 62//138
f 138//139 27//139 32//139
f 8//140 89//140 9//140
f 63//141 7//141 9//141
f 86//142 84//142 81//142
f 17//143 133//143 127//143
f 7//144 64//144 140//144
f 121//145 120//145 100//145
f 132//146 98//146 133//146
f 89//147 91//147 88//147
f 96//148 69//148 21//148
f 50//149 9//149 51//149
f 21//150 69//150 41//150
f 26//151 102//151 36//151
f 143//152 54//152 30//152
f 42//153 113//153 43//153
f 28//154 144//154 29//154
f 73//155 123//155 12//155
f 52//156 143//156 141//156
f 103//157 135//157 107//157
f 92//158 95//158 94//158
f 1//159 32//159 13//159
f 108//160 23//160 145//160
f 92//161 90//161 88//161
f 11//162 136//162 12//162
f 109//163 59//163 2//163
f 146//164 44//164 87//164
f 141//165 4//165 53//165
f 54//166 28//166 30//166
f 115//167 33//167 144//167
f 98//168 132//168 97//168
f 16//169 20//169 27//169
f 122//170 117//170 119//170
f 106//171 120//171 122//171
f 57//172 59//172 130//172
f 142//173 99//173 85//173
f 52//174 141//174 53//174
f 132//175 49//175 97//175
f 108//176 145//176 126//176
f 101//177 104//177 34//177
f 116//178 67//178 66//178
f 137//179 100//179 112//179
f 110//180 35//180 144//180
f 5//181 141//181 114//181
f 35//182 110//182 36//182
f 6//183 5//183 61//183
f 40//184 80//184 123//184
f 116//185 73//185 105//185
f 30//186 125//186 143//186
f 16//187 15//187 58//187
f 70//188 78//188 71//188
f 111//189 10//189 134//189
f 73//190 116//190 74//190
f 86//191 40//191 84//191
f 60//192 62//192 69//192
f 72//193 71//193 111//193
f 14//194 142//194 85//194
f 131//195 128//195 24//195
f 100//196 11//196 112//196
f 21//197 16//197 96//197
f 82//198 86//198 81//198
f 76//199 99//199 77//199
f 70//200 76//200 78//200
f 146//201 131//201 44//201
f 49//202 90//202 97//202
f 45//203 86//203 82//203
f 21//204 20//204 16//204
f 145//205 25//205 81//205
f 116//206 66//206 68//206
f 29//207 107//207 30//207
f 31//208 26//208 36//208
f 67//209 116//209 105//209
f 111//210 134//210 133//210
f 84//211 85//211 83//211
f 99//212 142//212 110//212
f 140//213 64//213 56//213
f 50//214 63//214 9//214
f 147//215 126//215 124//215
f 139//216 135//216 21//216
f 78//217 77//217 28//217
f 54//218 143//218 52//218
f 114//219 62//219 61//219
f 49//220 79//220 50//220
f 108//221 126//221 147//221
f 56//222 79//222 39//222
f 113//223 114//223 135//223
f 122//224 121//224 117//224
f 72//225 19//225 83//225
f 125//226 107//226 143//226
f 23//227 25//227 145//227
f 82//228 128//228 45//228
f 29//229 144//229 33//229
f 26//230 22//230 103//230
f 139//231 43//231 135//231
f 99//232 110//232 77//232
f 60//233 118//233 61//233
f 147//234 124//234 88//234
f 123//235 80//235 12//235
f 54//236 53//236 121//236
f 142//237 14//237 13//237
f 130//238 59//238 109//238
f 75//239 57//239 130//239
f 3//240 27//240 138//240
f 55//241 8//241 140//241
f 115//242 144//242 35//242
f 128//243 82//243 24//243
f 121//244 100//244 54//244
f 92//245 94//245 93//245
f 18//246 17//246 127//246
f 65//247 122//247 119//247
f 16//248 58//248 96//248
f 145//249 81//249 126//249
f 118//250 117//250 6//250
f 50//251 79//251 148//251
f 88//252 46//252 146//252
f 80//253 10//253 12//253
f 148//254 63//254 50//254
f 21//255 135//255 22//255
f 94//256 47//256 19//256
f 110//257 28//257 77//257
f 66//258 60//258 68//258
f 147//259 87//259 108//259
f 46//260 131//260 146//260
f 111//261 17//261 72//261
f 27//262 26//262 31//262
f 121//263 53//263 4//263
f 90//264 93//264 97//264
f 78//265 28//265 137//265
f 65//266 118//266 66//266
f 17//267 19//267 72//267
f 65//268 119//268 118//268
f 43//269 113//269 135//269
f 81//270 84//270 48//270
f 16//271 27//271 3//271
f 109//272 14//272 129//272
f 51//273 90//273 49//273
f 111//274 133//274 17//274
f 144//275 28//275 110//275
f 129//276 40//276 109//276
f 36//277 102//277 104//277
f 91//278 39//278 38//278
f 95//279 48//279 47//279
f 4//280 141//280 5//280
f 71//281 78//281 112//281
f 133//282 98//282 127//282
f 147//283 88//283 146//283
f 143//284 107//284 141//284
f 59//285 15//285 2//285
f 4//286 6//286 117//286
f 147//287 146//287 87//287
f 140//288 8//288 7//288
f 5//289 114//289 61//289
f 39//290 80//290 40//290
f 148//291 79//291 56//291
f 63//292 148//292 56//292
#292 polygons

738
assets/objects/bunny1.obj Normal file
View File

@ -0,0 +1,738 @@
# Blender v2.92.0 OBJ File: ''
# www.blender.org
mtllib bunny1.mtl
o Bunny-LowPoly.001
v 0.174007 3.357922 -2.306242
v 1.622921 3.821872 -2.128155
v 0.797961 3.287936 -2.960854
v 1.673485 0.428907 2.176677
v 2.401573 0.796504 1.786267
v 2.390956 1.404589 2.188287
v 0.335745 9.167501 -2.973008
v -0.327844 8.697269 -2.450786
v 0.201036 9.104085 -1.712281
v -1.130870 5.145801 0.793772
v -1.260666 4.022950 1.658828
v -0.002765 5.073577 1.023844
v -0.525602 2.240891 -1.967128
v -1.848391 3.702753 -2.433998
v 2.522799 3.205144 -2.325610
v 3.143963 2.515565 -2.052021
v -3.996466 4.471757 1.382156
v -4.271131 5.042050 1.550136
v -4.257020 4.690771 -0.032626
v 3.071795 1.432954 -1.895787
v 4.013993 1.688226 -0.497303
v 3.268616 0.657379 -0.849709
v -1.609784 8.759312 -4.469144
v -0.760188 7.856608 -4.572939
v -1.789844 7.309132 -4.363908
v 2.502503 0.762363 -1.780957
v 1.948122 2.059628 -2.544727
v -1.695973 1.248389 1.029201
v -1.465961 0.421066 0.217882
v -1.698992 0.866734 1.420196
v 0.956720 0.983382 -2.414660
v 0.117364 2.333488 -2.966834
v -2.482165 0.561570 -0.065057
v -2.365966 -0.003649 0.396744
v -1.437560 0.816819 -1.229600
v 0.399563 0.836828 -2.167981
v -1.174501 0.304779 -2.203168
v -1.915757 6.300719 -1.589230
v -1.500495 6.386696 -1.329606
v -1.358015 5.409020 -1.620694
v 4.774952 2.258009 0.129455
v 4.690672 1.745797 1.215373
v 4.880728 1.538303 0.219397
v -0.938987 9.174298 -4.214142
v -2.041871 6.609310 -2.384113
v -1.915780 7.176942 -1.933672
v -4.371067 5.341597 -0.104091
v -3.782916 4.915119 -1.272920
v -1.437181 7.223009 -0.372824
v -0.391603 7.828633 -0.915924
v -1.723454 7.491983 -0.446250
v -0.626273 0.165042 2.464771
v 0.364450 0.863628 2.267432
v -0.799668 1.023122 1.857020
v 0.146233 7.637212 -2.468429
v 0.784636 7.537144 -2.404019
v 2.740694 5.022351 -1.722645
v 3.512434 3.957539 -1.517960
v 2.620151 4.153180 -1.835429
v 4.275524 2.972532 1.027086
v 3.173196 1.009109 1.782540
v 4.110839 2.144468 1.045333
v 0.941438 9.025899 -2.713633
v 0.699070 8.597163 -3.327606
v 2.392359 3.855045 2.323683
v 3.820959 3.954593 1.501695
v 3.014936 4.697008 1.723083
v 4.188345 4.262923 -0.515877
v 4.299801 2.266671 0.089620
v -4.082005 3.520690 0.082948
v -3.663407 3.076759 0.940369
v -3.635632 4.267780 0.778216
v 1.844713 5.985648 0.214354
v 3.129726 5.491382 -0.185754
v 2.019585 5.727559 -0.834596
v -3.702954 2.650520 -0.806726
v -2.937449 1.586320 0.585442
v -3.191792 2.210673 1.089994
v -1.198685 6.526158 -0.749222
v -0.882342 5.665481 -0.391085
v -2.934086 6.634176 -1.679220
v -1.933416 6.745492 -3.816619
v -3.812562 4.214995 -0.519197
v -2.794290 4.564198 -1.658439
v -3.027883 3.388898 -1.942429
v -2.546340 6.216650 -1.771559
v -2.165974 8.977304 -3.877193
v -2.547812 7.273496 -0.987203
v -1.498605 8.114208 -1.133146
v -2.686715 7.567915 -0.017527
v -1.780422 7.302932 -1.426490
v -4.174591 6.938058 -0.199918
v -3.534863 7.111468 0.741171
v -4.039784 6.157972 1.390151
v -3.981892 6.234908 -0.595072
v 4.020306 3.092959 -1.302070
v -2.016227 7.122823 0.954648
v -2.906343 6.654913 1.636226
v -2.973210 1.684685 -0.834417
v -0.932438 2.019833 1.922377
v -1.564883 -0.001850 -1.165597
v 2.364962 0.004736 -1.817107
v 2.372780 0.006821 -0.682843
v -0.410520 0.001313 -2.292826
v 1.770146 5.710897 1.287521
v 1.314128 5.053192 1.954891
v -2.879021 0.006787 1.242394
v -2.708689 8.401330 -3.534052
v 0.466977 4.643353 -2.123719
v -1.792995 1.392445 -1.071644
v -2.730047 4.279785 1.399355
v -2.471766 3.367712 1.897010
v 4.037461 -0.001340 0.747675
v 3.428908 0.003363 1.498862
v -2.791854 0.199724 -0.829447
v 3.470897 5.068673 0.987464
v 1.328001 2.153122 2.839340
v 3.054096 2.745536 2.213846
v 1.883718 3.138259 2.714292
v 0.045405 3.129414 2.698084
v 0.341201 1.866896 2.828983
v 1.052905 3.501572 2.743204
v 0.174860 5.425478 -0.822940
v -3.124066 7.068564 -1.440470
v -2.209502 0.234382 1.830564
v -2.690186 7.630337 -2.728419
v -3.566159 5.611900 2.110068
v -0.659567 7.557715 -4.010995
v -0.840242 4.889163 -2.040000
v 1.404307 4.999763 -1.698795
v -0.509362 8.465204 -3.814098
v -1.872053 6.414440 0.749119
v -2.824721 4.920755 2.198212
v -2.198450 5.109061 1.512187
v 3.703201 -0.000145 -0.227078
v -0.311815 3.645073 1.999772
v -2.448877 2.621042 1.750083
v 1.201352 2.339610 -3.001462
v 4.516596 1.408629 -0.441286
v 0.243665 8.412656 -3.323981
v 1.649461 0.001329 2.048054
v -2.146029 2.323006 -2.135905
v -1.240360 0.001186 1.705908
v -1.777548 0.732061 -0.121266
v -2.047082 7.597226 -3.641816
v -1.419161 8.233310 -3.183000
v -2.511253 8.132317 -2.470228
v 0.713343 7.696699 -1.973578
vn -0.2497 0.9085 -0.3351
vn 0.5866 -0.4395 0.6802
vn -0.5897 0.8073 -0.0224
vn -0.1197 0.6146 0.7797
vn 0.0098 -0.2961 -0.9551
vn 0.3422 -0.0637 -0.9375
vn -0.8861 -0.4541 0.0929
vn 0.7881 -0.4142 -0.4554
vn -0.1732 -0.0499 -0.9836
vn 0.2860 -0.3925 -0.8742
vn -0.9809 -0.1355 -0.1399
vn 0.1764 -0.2767 -0.9446
vn -0.1330 0.6106 0.7807
vn -0.2664 0.8215 -0.5041
vn 0.4556 0.3144 -0.8328
vn 0.9749 0.1623 0.1522
vn 0.1839 0.2814 -0.9418
vn 0.9804 -0.0721 -0.1835
vn -0.9026 -0.2000 -0.3812
vn 0.1952 0.4462 0.8734
vn -0.2147 0.5352 0.8170
vn -0.0262 -0.6540 -0.7561
vn 0.3485 0.0729 -0.9345
vn 0.7018 -0.1241 0.7015
vn 0.9511 -0.1557 -0.2668
vn 0.4311 0.8027 0.4121
vn 0.4685 0.2566 0.8454
vn 0.9986 0.0518 -0.0131
vn -0.8774 0.0848 0.4722
vn 0.3040 0.9356 -0.1795
vn -0.8774 -0.4620 0.1293
vn 0.7016 0.3944 -0.5934
vn 0.8688 0.1194 -0.4805
vn -0.8860 -0.1865 -0.4245
vn -0.4656 -0.6392 -0.6121
vn -0.4331 0.2921 -0.8527
vn 0.2302 -0.8943 -0.3837
vn -0.2776 0.7872 -0.5507
vn -0.5060 0.7152 0.4822
vn -0.0573 0.9530 -0.2976
vn -0.1516 0.9680 -0.2000
vn -0.3984 0.9114 0.1029
vn -0.9190 0.3940 -0.0115
vn 0.9797 -0.0061 -0.2004
vn -0.0760 0.8656 0.4949
vn 0.5877 -0.5931 -0.5503
vn -0.6130 -0.4444 -0.6533
vn -0.2573 0.4751 -0.8415
vn -0.6905 -0.1385 0.7099
vn -0.9403 0.1214 -0.3179
vn 0.0009 -1.0000 0.0018
vn -0.9167 0.0092 -0.3996
vn 0.3896 0.8487 -0.3576
vn -0.4226 0.6522 0.6294
vn -0.3581 0.9102 0.2081
vn 0.9675 -0.0925 -0.2353
vn 0.2310 0.6094 0.7584
vn 0.0008 -1.0000 0.0021
vn -0.6724 0.2109 -0.7095
vn 0.0826 0.1216 -0.9891
vn -0.4774 -0.1919 -0.8575
vn -0.6428 0.2186 0.7342
vn -0.4331 -0.2246 -0.8729
vn 0.7049 -0.4171 0.5737
vn 0.6535 0.6618 -0.3674
vn 0.3835 0.3928 -0.8358
vn -0.1872 -0.9775 -0.0971
vn -0.0411 0.1865 -0.9816
vn 0.9840 -0.1783 -0.0065
vn -0.3563 0.7757 0.5210
vn 0.7593 0.6506 0.0136
vn 0.3662 -0.0890 0.9263
vn -0.0760 0.0852 0.9935
vn -0.6227 0.4481 -0.6415
vn -0.8678 0.0304 -0.4961
vn -0.2410 -0.4920 -0.8366
vn -0.1576 0.9525 -0.2606
vn -0.8934 0.4370 0.1041
vn -0.7462 -0.4175 -0.5186
vn 0.4213 0.6570 -0.6251
vn -0.3791 -0.8389 -0.3905
vn -0.7625 0.1453 -0.6304
vn -0.5810 0.7179 0.3835
vn -0.9044 -0.1840 -0.3849
vn -0.9793 0.1956 -0.0521
vn -0.0325 0.6123 0.7899
vn -0.2334 0.7575 0.6097
vn -0.4071 0.5786 0.7067
vn 0.2902 0.6487 -0.7035
vn 0.2493 0.1895 -0.9497
vn -0.9368 0.0847 0.3394
vn 0.7861 -0.4818 0.3871
vn -0.2197 0.4705 -0.8546
vn -0.4549 0.8433 -0.2864
vn -0.1352 0.8032 -0.5802
vn 0.8492 -0.2423 0.4691
vn 0.6859 0.2317 0.6898
vn 0.8123 0.4520 0.3686
vn -0.7283 0.0568 -0.6829
vn 0.6959 0.4269 0.5774
vn 0.0893 -0.3417 0.9356
vn -0.8372 -0.3838 -0.3895
vn 0.7494 0.2918 -0.5944
vn -0.0006 -1.0000 0.0019
vn 0.2647 -0.5650 -0.7815
vn 0.6988 -0.0221 0.7150
vn -0.0755 0.4610 0.8842
vn 0.0832 0.1215 -0.9891
vn -0.4705 0.5649 0.6779
vn -0.3124 -0.5703 0.7597
vn -0.4428 -0.1834 -0.8777
vn -0.0321 0.0291 -0.9991
vn 0.2409 -0.7070 -0.6649
vn 0.8453 0.2441 -0.4752
vn -0.2528 0.9609 -0.1130
vn 0.3423 0.4501 -0.8248
vn -0.7595 0.4378 -0.4811
vn 0.1320 0.5091 0.8505
vn -0.7159 0.2423 0.6548
vn 0.3695 -0.2000 0.9074
vn 0.5190 0.3309 0.7881
vn 0.2076 0.4151 0.8858
vn -0.0476 -0.7374 -0.6738
vn -0.0826 0.8458 -0.5271
vn -0.4773 0.5724 0.6668
vn 0.1167 -0.9897 0.0830
vn -0.7406 0.2153 -0.6365
vn -0.5994 -0.1722 0.7817
vn 0.9569 0.2361 0.1692
vn 0.0073 0.9917 0.1283
vn 0.8683 0.0662 -0.4916
vn -0.7654 0.2643 0.5867
vn 0.2315 0.8558 -0.4626
vn -0.0003 -1.0000 -0.0048
vn 0.0313 -0.7473 -0.6638
vn -0.3111 0.0737 0.9475
vn -0.2692 -0.0334 -0.9625
vn -0.1167 0.2412 0.9634
vn -0.0114 -0.8607 -0.5090
vn -0.5242 0.8467 -0.0911
vn 0.1984 0.9776 0.0704
vn -0.2592 -0.0272 -0.9654
vn -0.4354 -0.3619 0.8243
vn -0.1824 0.4327 -0.8829
vn -0.5833 -0.0526 0.8106
vn 0.6628 0.2589 0.7026
vn -0.4590 0.4388 -0.7725
vn 0.9416 -0.1706 -0.2904
vn 0.1921 0.4540 0.8701
vn 0.0728 0.6924 -0.7178
vn 0.1815 0.0140 -0.9833
vn -0.4445 0.0595 0.8938
vn 0.8827 -0.3972 0.2512
vn -0.8145 -0.5056 0.2847
vn -0.3900 0.9107 0.1360
vn -0.0274 -0.9723 0.2321
vn -0.0027 -1.0000 -0.0074
vn -0.9690 -0.2443 -0.0377
vn -0.8008 0.3552 -0.4822
vn -0.5416 -0.3427 -0.7676
vn -0.3364 0.8866 -0.3174
vn -0.0656 0.5725 0.8172
vn 0.1878 0.2693 -0.9446
vn 0.0743 0.7192 0.6909
vn -0.0287 -0.2865 0.9577
vn -0.4203 0.6510 0.6322
vn -0.2468 0.9107 -0.3311
vn 0.6357 -0.0930 0.7663
vn 0.4268 -0.1570 -0.8906
vn 0.0720 0.0855 0.9937
vn -0.2123 0.4708 0.8563
vn -0.0199 0.1314 -0.9911
vn -0.6535 -0.4272 -0.6249
vn 0.1815 0.0203 0.9832
vn 0.9125 0.0687 0.4032
vn -0.7080 -0.5183 -0.4797
vn 0.0032 -1.0000 0.0005
vn 0.6150 0.4815 0.6245
vn -0.1868 -0.1952 0.9628
vn -0.8473 -0.4426 -0.2937
vn 0.2947 0.0357 0.9549
vn -0.4543 -0.0362 -0.8901
vn 0.1536 -0.5431 0.8255
vn 0.1178 0.9620 -0.2462
vn 0.3806 0.8892 0.2541
vn 0.2120 0.4058 0.8890
vn 0.5452 0.1651 -0.8219
vn -0.8748 -0.4421 0.1982
vn 0.5141 -0.4305 0.7419
vn 0.4059 0.8911 0.2030
vn 0.0726 -0.0789 -0.9942
vn 0.9677 -0.1888 0.1672
vn -0.5624 0.1244 0.8175
vn -0.3534 -0.1241 -0.9272
vn 0.9666 -0.1098 -0.2315
vn 0.1132 0.1478 0.9825
vn 0.7308 -0.3418 -0.5908
vn -0.7205 -0.5878 -0.3679
vn -0.7980 -0.6023 -0.0216
vn -0.8610 -0.4949 0.1173
vn 0.3407 0.6100 0.7154
vn 0.3146 0.9263 0.2071
vn 0.5893 -0.8073 -0.0321
vn 0.8330 -0.1330 -0.5370
vn -0.9241 0.0994 -0.3689
vn 0.8963 0.3840 0.2219
vn -0.5052 0.7727 -0.3843
vn 0.0471 -0.9019 -0.4294
vn 0.3740 0.7136 0.5924
vn 0.6986 -0.5154 0.4963
vn -0.7558 0.2918 -0.5861
vn -0.3036 -0.7649 -0.5681
vn 0.2474 -0.6251 -0.7403
vn 0.8040 -0.0023 0.5946
vn -0.9094 0.3935 -0.1347
vn 0.0201 -0.1616 -0.9867
vn -0.4049 -0.6688 0.6235
vn -0.7783 0.2505 0.5757
vn 0.6523 -0.0475 0.7565
vn 0.5537 -0.2411 0.7971
vn -0.9479 0.2189 0.2313
vn 0.4438 -0.8960 -0.0155
vn -0.0065 -1.0000 0.0010
vn -0.0294 0.0651 0.9974
vn -0.6611 -0.7406 0.1203
vn -0.1428 -0.8575 0.4943
vn -0.9266 0.0885 -0.3654
vn 0.5328 -0.8453 -0.0400
vn -0.1072 0.6818 0.7237
vn 0.4618 -0.7553 -0.4651
vn 0.7923 -0.5087 -0.3368
vn -0.2514 -0.9660 -0.0606
vn 0.7032 -0.1256 0.6998
vn -0.5704 0.7168 0.4010
vn 0.2960 0.9327 0.2062
vn -0.3504 -0.4636 0.8138
vn 0.0894 -0.2287 -0.9694
vn 0.2190 0.4539 -0.8637
vn -0.0244 0.7731 -0.6338
vn 0.5748 0.2775 -0.7698
vn -0.8293 -0.3638 -0.4242
vn -0.4291 0.9011 -0.0627
vn 0.4168 -0.7695 -0.4839
vn -0.5853 -0.1304 0.8003
vn -0.6993 0.6165 0.3618
vn -0.3386 -0.4122 0.8458
vn 0.1902 0.3623 0.9125
vn 0.5863 0.1454 -0.7970
vn -0.7668 -0.3669 -0.5266
vn 0.3967 -0.2132 0.8928
vn 0.6391 -0.3057 0.7058
vn 0.8194 0.2337 0.5234
vn -0.0224 0.9173 0.3976
vn 0.6835 0.2621 0.6813
vn 0.6623 -0.2357 -0.7112
vn -0.9492 -0.1351 0.2843
vn -0.2439 -0.9682 -0.0551
vn 0.9216 0.3217 0.2170
vn -0.5992 0.7427 0.2990
vn 0.3042 0.6644 0.6827
vn -0.1488 -0.9604 0.2355
vn 0.3026 -0.3842 -0.8722
vn -0.1018 -0.4877 0.8671
vn -0.0706 0.8876 0.4551
vn -0.3409 -0.5768 0.7423
vn 0.4781 0.2005 0.8551
vn -0.5328 -0.8456 -0.0328
vn 0.4356 0.1723 0.8835
vn 0.8003 -0.5327 -0.2751
vn -0.3737 -0.0345 -0.9269
vn 0.3702 0.0322 -0.9284
vn -0.0013 0.3162 -0.9487
vn 0.3672 0.5877 0.7210
vn -0.1267 -0.7810 0.6116
vn -0.9976 0.0477 0.0493
vn 0.0793 0.6725 -0.7358
vn 0.1689 -0.0165 -0.9855
vn 0.5187 0.0683 -0.8522
vn -0.8698 0.1153 -0.4797
vn 0.5568 -0.2678 0.7863
vn -0.5877 -0.1839 0.7879
vn 0.1789 0.3109 0.9335
vn 0.2428 0.8369 0.4906
vn 0.0025 -0.9998 -0.0211
vn 0.1119 0.4473 -0.8874
vn 0.3558 -0.2723 0.8940
vn 0.2819 0.7904 0.5439
vn -0.7213 0.3624 -0.5902
vn 0.0744 -0.2531 0.9646
vn 0.8855 0.2463 -0.3939
vn 0.6434 -0.6770 0.3575
vn 0.9804 -0.0645 0.1863
usemtl None
s off
f 1//1 2//1 3//1
f 4//2 5//2 6//2
f 7//3 8//3 9//3
f 10//4 11//4 12//4
f 1//5 13//5 14//5
f 15//6 16//6 3//6
f 17//7 18//7 19//7
f 20//8 21//8 22//8
f 23//9 24//9 25//9
f 26//10 27//10 20//10
f 28//11 29//11 30//11
f 27//12 31//12 32//12
f 33//13 34//13 29//13
f 35//14 36//14 37//14
f 38//15 39//15 40//15
f 41//16 42//16 43//16
f 44//17 24//17 23//17
f 38//18 45//18 46//18
f 47//19 48//19 19//19
f 49//20 50//20 51//20
f 52//21 53//21 54//21
f 55//22 56//22 39//22
f 57//23 58//23 59//23
f 60//24 61//24 62//24
f 63//25 56//25 64//25
f 62//26 42//26 41//26
f 65//27 66//27 67//27
f 68//28 60//28 69//28
f 70//29 71//29 72//29
f 73//30 74//30 75//30
f 76//31 77//31 78//31
f 57//32 68//32 58//32
f 79//33 80//33 39//33
f 81//34 25//34 82//34
f 83//35 48//35 84//35
f 14//36 85//36 84//36
f 45//37 38//37 86//37
f 87//38 44//38 23//38
f 88//39 51//39 89//39
f 90//40 51//40 88//40
f 46//41 88//41 91//41
f 92//42 93//42 90//42
f 47//43 94//43 95//43
f 68//44 69//44 96//44
f 97//45 93//45 98//45
f 20//46 22//46 26//46
f 76//47 85//47 99//47
f 40//48 14//48 84//48
f 100//49 28//49 54//49
f 101//50 35//50 37//50
f 102//51 103//51 104//51
f 83//52 76//52 70//52
f 75//53 74//53 57//53
f 98//54 93//54 94//54
f 105//55 73//55 12//55
f 91//56 38//56 46//56
f 106//57 67//57 105//57
f 104//58 103//58 107//58
f 23//59 108//59 87//59
f 109//60 2//60 1//60
f 13//61 36//61 110//61
f 111//62 71//62 112//62
f 91//63 55//63 39//63
f 113//64 42//64 114//64
f 68//65 57//65 74//65
f 59//66 58//66 15//66
f 115//67 101//67 34//67
f 104//68 37//68 36//68
f 102//69 26//69 103//69
f 106//70 105//70 12//70
f 68//71 74//71 116//71
f 117//72 118//72 119//72
f 120//73 121//73 122//73
f 3//74 32//74 1//74
f 83//75 85//75 76//75
f 36//76 32//76 31//76
f 123//77 73//77 75//77
f 70//78 72//78 83//78
f 32//79 36//79 13//79
f 7//80 63//80 64//80
f 37//81 104//81 101//81
f 124//82 95//82 92//82
f 125//83 30//83 107//83
f 126//84 81//84 124//84
f 18//85 94//85 19//85
f 111//86 11//86 10//86
f 51//87 9//87 89//87
f 94//88 127//88 98//88
f 15//89 3//89 2//89
f 86//90 38//90 40//90
f 34//91 33//91 115//91
f 46//92 45//92 128//92
f 40//93 129//93 14//93
f 107//94 29//94 34//94
f 130//95 123//95 75//95
f 128//96 131//96 46//96
f 132//97 133//97 134//97
f 79//98 10//98 80//98
f 124//99 81//99 95//99
f 132//100 10//100 49//100
f 121//101 4//101 117//101
f 48//102 83//102 19//102
f 68//103 96//103 58//103
f 114//104 107//104 135//104
f 103//105 22//105 135//105
f 66//106 118//106 60//106
f 11//107 111//107 112//107
f 14//108 109//108 1//108
f 12//109 136//109 106//109
f 137//110 28//110 100//110
f 8//111 55//111 91//111
f 138//112 32//112 3//112
f 24//113 82//113 25//113
f 44//114 131//114 24//114
f 124//115 92//115 88//115
f 41//116 139//116 21//116
f 89//117 8//117 91//117
f 65//118 67//118 122//118
f 94//119 18//119 127//119
f 6//120 61//120 118//120
f 132//121 134//121 10//121
f 67//122 106//122 122//122
f 56//123 55//123 140//123
f 109//124 123//124 130//124
f 106//125 136//125 120//125
f 34//126 104//126 107//126
f 81//127 48//127 95//127
f 137//128 112//128 78//128
f 49//129 10//129 79//129
f 62//130 41//130 69//130
f 41//131 43//131 139//131
f 136//132 100//132 120//132
f 123//133 109//133 40//133
f 141//134 107//134 114//134
f 142//135 13//135 110//135
f 100//136 136//136 11//136
f 101//137 115//137 35//137
f 114//138 42//138 62//138
f 138//139 27//139 32//139
f 8//140 89//140 9//140
f 63//141 7//141 9//141
f 86//142 84//142 81//142
f 17//143 133//143 127//143
f 7//144 64//144 140//144
f 121//145 120//145 100//145
f 132//146 98//146 133//146
f 89//147 91//147 88//147
f 96//148 69//148 21//148
f 50//149 9//149 51//149
f 21//150 69//150 41//150
f 26//151 102//151 36//151
f 143//152 54//152 30//152
f 42//153 113//153 43//153
f 28//154 144//154 29//154
f 73//155 123//155 12//155
f 52//156 143//156 141//156
f 103//157 135//157 107//157
f 92//158 95//158 94//158
f 1//159 32//159 13//159
f 108//160 23//160 145//160
f 92//161 90//161 88//161
f 11//162 136//162 12//162
f 109//163 59//163 2//163
f 146//164 44//164 87//164
f 141//165 4//165 53//165
f 54//166 28//166 30//166
f 115//167 33//167 144//167
f 98//168 132//168 97//168
f 16//169 20//169 27//169
f 122//170 117//170 119//170
f 106//171 120//171 122//171
f 57//172 59//172 130//172
f 142//173 99//173 85//173
f 52//174 141//174 53//174
f 132//175 49//175 97//175
f 108//176 145//176 126//176
f 101//177 104//177 34//177
f 116//178 67//178 66//178
f 137//179 100//179 112//179
f 110//180 35//180 144//180
f 5//181 141//181 114//181
f 35//182 110//182 36//182
f 6//183 5//183 61//183
f 40//184 80//184 123//184
f 116//185 73//185 105//185
f 30//186 125//186 143//186
f 16//187 15//187 58//187
f 70//188 78//188 71//188
f 111//189 10//189 134//189
f 73//190 116//190 74//190
f 86//191 40//191 84//191
f 60//192 62//192 69//192
f 72//193 71//193 111//193
f 14//194 142//194 85//194
f 131//195 128//195 24//195
f 100//196 11//196 112//196
f 21//197 16//197 96//197
f 82//198 86//198 81//198
f 76//199 99//199 77//199
f 70//200 76//200 78//200
f 146//201 131//201 44//201
f 49//202 90//202 97//202
f 45//203 86//203 82//203
f 21//204 20//204 16//204
f 145//205 25//205 81//205
f 116//206 66//206 68//206
f 29//207 107//207 30//207
f 31//208 26//208 36//208
f 67//209 116//209 105//209
f 111//210 134//210 133//210
f 84//211 85//211 83//211
f 99//212 142//212 110//212
f 140//213 64//213 56//213
f 50//214 63//214 9//214
f 147//215 126//215 124//215
f 139//216 135//216 21//216
f 78//217 77//217 28//217
f 54//218 143//218 52//218
f 114//219 62//219 61//219
f 49//220 79//220 50//220
f 108//221 126//221 147//221
f 56//222 79//222 39//222
f 113//223 114//223 135//223
f 122//224 121//224 117//224
f 72//225 19//225 83//225
f 125//226 107//226 143//226
f 23//227 25//227 145//227
f 82//228 128//228 45//228
f 29//229 144//229 33//229
f 26//230 22//230 103//230
f 139//231 43//231 135//231
f 99//232 110//232 77//232
f 60//233 118//233 61//233
f 147//234 124//234 88//234
f 123//235 80//235 12//235
f 54//236 53//236 121//236
f 142//237 14//237 13//237
f 130//238 59//238 109//238
f 75//239 57//239 130//239
f 3//240 27//240 138//240
f 55//241 8//241 140//241
f 115//242 144//242 35//242
f 128//243 82//243 24//243
f 121//244 100//244 54//244
f 92//245 94//245 93//245
f 18//246 17//246 127//246
f 65//247 122//247 119//247
f 16//248 58//248 96//248
f 145//249 81//249 126//249
f 118//250 117//250 6//250
f 50//251 79//251 148//251
f 88//252 46//252 146//252
f 80//253 10//253 12//253
f 148//254 63//254 50//254
f 21//255 135//255 22//255
f 94//256 47//256 19//256
f 110//257 28//257 77//257
f 66//258 60//258 68//258
f 147//259 87//259 108//259
f 46//260 131//260 146//260
f 111//261 17//261 72//261
f 27//262 26//262 31//262
f 121//263 53//263 4//263
f 90//264 93//264 97//264
f 78//265 28//265 137//265
f 65//266 118//266 66//266
f 17//267 19//267 72//267
f 65//268 119//268 118//268
f 43//269 113//269 135//269
f 81//270 84//270 48//270
f 16//271 27//271 3//271
f 109//272 14//272 129//272
f 51//273 90//273 49//273
f 111//274 133//274 17//274
f 144//275 28//275 110//275
f 129//276 40//276 109//276
f 36//277 102//277 104//277
f 91//278 39//278 38//278
f 95//279 48//279 47//279
f 4//280 141//280 5//280
f 71//281 78//281 112//281
f 133//282 98//282 127//282
f 147//283 88//283 146//283
f 143//284 107//284 141//284
f 59//285 15//285 2//285
f 4//286 6//286 117//286
f 147//287 146//287 87//287
f 140//288 8//288 7//288
f 5//289 114//289 61//289
f 39//290 80//290 40//290
f 148//291 79//291 56//291
f 63//292 148//292 56//292

1115
assets/objects/bunny2.obj Normal file

File diff suppressed because it is too large Load Diff

53
assets/objects/cT.obj Normal file
View File

@ -0,0 +1,53 @@
# Blender v2.92.0 OBJ File: ''
# www.blender.org
mtllib cT.mtl
o Cube
v 1.000000 0.500000 -1.000000
v 1.000000 -0.000031 -1.000000
v 1.000000 0.500000 1.000000
v 1.000000 -0.000031 1.000000
v -1.000000 0.500000 -1.000000
v -1.000000 -0.000031 -1.000000
v -1.000000 0.500000 1.000000
v -1.000000 -0.000031 1.000000
v 0.000000 1.897358 0.000000
vt 0.875000 0.500000
vt 0.750000 0.625000
vt 0.625000 0.500000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 0.5820 -0.8132
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn -0.8132 0.5820 0.0000
vn 0.0000 0.5820 0.8132
vn 0.8132 0.5820 0.0000
usemtl Material
s off
f 5/1/1 9/2/1 1/3/1
f 3/4/2 8/5/2 4/6/2
f 7/7/3 6/8/3 8/9/3
f 2/10/4 8/11/4 6/12/4
f 1/3/5 4/6/5 2/10/5
f 5/13/6 2/10/6 6/8/6
f 5/1/7 7/14/7 9/2/7
f 3/4/2 7/15/2 8/5/2
f 7/7/3 5/13/3 6/8/3
f 2/10/4 4/6/4 8/11/4
f 1/3/5 3/4/5 4/6/5
f 5/13/6 1/3/6 2/10/6
f 9/2/8 7/14/8 3/4/8
f 1/3/9 9/2/9 3/4/9

40
assets/objects/cube.obj Normal file
View File

@ -0,0 +1,40 @@
# Blender v2.92.0 OBJ File: ''
# www.blender.org
mtllib cube.mtl
o Cube
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.625000 0.500000
vt 0.875000 0.500000
vt 0.875000 0.750000
vt 0.625000 0.750000
vt 0.375000 0.750000
vt 0.625000 1.000000
vt 0.375000 1.000000
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.625000 0.250000
vt 0.375000 0.250000
vt 0.125000 0.500000
vt 0.375000 0.500000
vt 0.125000 0.750000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 1/1/1 5/2/1 7/3/1 3/4/1
f 4/5/2 3/4/2 7/6/2 8/7/2
f 8/8/3 7/9/3 5/10/3 6/11/3
f 6/12/4 2/13/4 4/5/4 8/14/4
f 2/13/5 1/1/5 3/4/5 4/5/5
f 6/11/6 5/10/6 1/1/6 2/13/6

46
assets/objects/cubeT.obj Normal file
View File

@ -0,0 +1,46 @@
# Blender v2.92.0 OBJ File: ''
# www.blender.org
mtllib cubeT.mtl
o Cube
v 1.000000 1.000000 -1.000000
v 1.000000 -1.000000 -1.000000
v 1.000000 1.000000 1.000000
v 1.000000 -1.000000 1.000000
v -1.000000 1.000000 -1.000000
v -1.000000 -1.000000 -1.000000
v -1.000000 1.000000 1.000000
v -1.000000 -1.000000 1.000000
vt 0.875000 0.500000
vt 0.625000 0.750000
vt 0.625000 0.500000
vt 0.375000 1.000000
vt 0.375000 0.750000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.375000 0.000000
vt 0.375000 0.500000
vt 0.125000 0.750000
vt 0.125000 0.500000
vt 0.625000 0.250000
vt 0.875000 0.750000
vt 0.625000 1.000000
vn 0.0000 1.0000 0.0000
vn 0.0000 0.0000 1.0000
vn -1.0000 0.0000 0.0000
vn 0.0000 -1.0000 0.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
usemtl Material
s off
f 5/1/1 3/2/1 1/3/1
f 3/2/2 8/4/2 4/5/2
f 7/6/3 6/7/3 8/8/3
f 2/9/4 8/10/4 6/11/4
f 1/3/5 4/5/5 2/9/5
f 5/12/6 2/9/6 6/7/6
f 5/1/1 7/13/1 3/2/1
f 3/2/2 7/14/2 8/4/2
f 7/6/3 5/12/3 6/7/3
f 2/9/4 4/5/4 8/10/4
f 1/3/5 3/2/5 4/5/5
f 5/12/6 1/3/6 2/9/6

46
assets/objects/cubeUV.obj Normal file
View File

@ -0,0 +1,46 @@
# Blender v2.93.1 OBJ File: ''
# www.blender.org
mtllib cubeUV.mtl
o Cube_Cube.001
v -0.250000 0.000000 0.250000
v -0.250000 0.500000 0.250000
v -0.250000 0.000000 -0.250000
v -0.250000 0.500000 -0.250000
v 0.250000 0.000000 0.250000
v 0.250000 0.500000 0.250000
v 0.250000 0.000000 -0.250000
v 0.250000 0.500000 -0.250000
vt 0.999900 0.000100
vt 0.999900 0.999900
vt 0.000100 0.999900
vt 0.000100 0.000100
vt 0.999900 0.000100
vt 0.999900 0.999900
vt 0.000100 0.999900
vt 0.000100 0.000100
vt 0.000100 0.999900
vt 0.000100 0.000100
vt 0.999900 0.000100
vt 0.999900 0.999900
vt 0.000100 0.999900
vt 0.000100 0.000100
vt 0.999900 0.000100
vt 0.999900 0.999900
vt 0.999900 0.000100
vt 0.000100 0.999900
vt 0.999900 0.000100
vt 0.000100 0.999900
vn -1.0000 0.0000 0.0000
vn 0.0000 0.0000 -1.0000
vn 1.0000 0.0000 0.0000
vn 0.0000 0.0000 1.0000
vn 0.0000 -1.0000 0.0000
vn 0.0000 1.0000 0.0000
usemtl Material.001
s off
f 1/1/1 2/2/1 4/3/1 3/4/1
f 3/5/2 4/6/2 8/7/2 7/8/2
f 7/9/3 8/10/3 6/11/3 5/12/3
f 5/13/4 6/14/4 2/15/4 1/16/4
f 3/4/5 7/17/5 5/12/5 1/18/5
f 8/10/6 4/19/6 2/2/6 6/20/6

1013
assets/objects/disco.obj Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl fox_material
Ns 96.078431
Ka 0.000000 0.000000 0.000000
Kd 1.000000 1.000000 1.000000
Ks 0.089804 0.089804 0.089804
Ni 1.000000
d 1.000000
illum 2
map_Kd texture.png

1772
assets/objects/fox/fox.obj Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

16
assets/objects/plane.obj Normal file
View File

@ -0,0 +1,16 @@
# Blender v2.93.1 OBJ File: ''
# www.blender.org
mtllib untitled.mtl
o Plane
v -0.000000 0.000000 1.000000
v 0.000000 2.000000 1.000000
v -0.000000 0.000000 -1.000000
v 0.000000 2.000000 -1.000000
vt 0.000000 0.000000
vt 1.000000 0.000000
vt 1.000000 1.000000
vt 0.000000 1.000000
vn -1.0000 0.0000 0.0000
usemtl Material.001
s off
f 1/1/1 2/2/1 4/3/1 3/4/1

View File

@ -0,0 +1,16 @@
# OBJ file created by ply_to_obj.c
#
g Object001
v 0 0 0
v 1 0 0
v 1 1 0
v 0 1 0
v 0.5 0.5 1.6
f 5 2 3
f 4 5 3
f 6 3 2
f 5 6 2
f 4 6 5
f 6 4 3

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 KiB

BIN
assets/textures/8k_mars.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 MiB

BIN
assets/textures/8k_moon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 MiB

BIN
assets/textures/8k_sun.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.5 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 MiB

BIN
assets/textures/grid.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 781 KiB

Binary file not shown.

BIN
assets/textures/m_way.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 MiB

BIN
assets/textures/m_way2.hdr Normal file

Binary file not shown.

BIN
assets/textures/m_way2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 MiB

BIN
assets/textures/moon.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 MiB

46
config_template.txt Normal file
View File

@ -0,0 +1,46 @@
# config
window_name
window_size
pixel_shader_path
# shader data
iterations
samples
camera_position
camera_rotation
sensitivity
fov
# textures
texture_sky_path
texture_1_path
texture_2_path
texture_3_path
texture_4_path
texture_5_path
# only 5 textures available
# imported models
object_0
object_1
object_2
object_3
object_4
object_5
object_(...)
# object
obj_id
texture_albedo
texture_specular
texture_emission
position
rotation
size
albedo
specular
emission
smoothness
refractive_index
transparency
type

87
configs/config.txt Normal file
View File

@ -0,0 +1,87 @@
# config
window_name Ray Tracing
window_size 1024 512
pixel_shader_path shaders/ray_tracing/RayTracing.compute
object_shader_path
# shader data
reflections 15
samples 1
camera_position 20 10 -40
camera_rotation -7 22 0
sensitivity 10
fov 40
# textures
texture_sky_path assets/textures/kiara_1_dawn_4k.hdr
texture_2_path assets/textures/grid.jpg
texture_3_path assets/textures/moon.jpg
# imported models
object_1 assets/objects/plane.obj
object_2 assets/objects/cube.obj
object_3 assets/objects/cubeUV.obj
# transparent cube 1
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 0 0
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 1
refractive_index 1.1
transparency 0.9
type 2
# transparent cube 2
model
obj_id 3
texture_albedo 0
texture_specular 3
texture_emission 3
position -22.5 0 0
rotation 0 90 0
size 20 20 20
albedo 0 0 0
specular 5 5 5
emission 1 1 1
smoothness 1
refractive_index 1
transparency 1
type 2
# transparent sphere
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 22.5 5 0
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 0.9
refractive_index 1.5
transparency 0.99
type sphere
# plane
model
obj_id 1
texture_albedo 2
texture_specular 2
texture_emission 0
position -50 0 0
rotation 0 0 90
size 1 50 50
albedo 1 1 1
specular 0.1 0.1 0.1
emission 0 0 0
smoothness 1

53
configs/demo_1.txt Normal file
View File

@ -0,0 +1,53 @@
# config
window_name Ray Tracing Refraction Demo 1
window_size 1024 1024
pixel_shader_path shaders/ray_tracing/RayTracing.compute
# shader data
reflections 4
samples 1
camera_position -150 50 -150
camera_rotation -10 -45 0
sensitivity 10
fov 40
# textures
texture_sky_path assets/textures/kiara_1_dawn_4k.hdr
texture_1_path assets/textures/square_floor.png
texture_2_path assets/textures/grid.jpg
texture_3_path assets/objects/fox/texture.png
# imported models
object_0 assets/objects/fox/fox.obj
object_1 assets/objects/plane.obj
object_2 assets/objects/cube.obj
object_3 assets/objects/disco.obj
# fox
model
obj_id 0
texture_albedo 3
texture_specular 0
texture_emission 0
position -5 0 0
rotation 0 70 0
size 0.5 0.5 0.5
albedo 1 1 1
specular 0 0 0
emission 0 0 0
smoothness 1
type 2
# plane
model
obj_id 1
texture_albedo 0
texture_specular 0
texture_emission 0
position -50 0 0
rotation 0 0 90
size 1 50 50
albedo 0 0 0
specular 0.1 0.1 0.1
emission 0 0 0
smoothness 0.9

147
configs/demo_2.txt Normal file
View File

@ -0,0 +1,147 @@
# config
window_name Ray Tracing Refraction Demo 1
window_size 512 512
pixel_shader_path shaders/ray_tracing/RayTracing.compute
# shader data
reflections 10
samples 1
camera_position 30 10 -30
camera_rotation -6 37.5 0
sensitivity 10
fov 40
# textures
texture_sky_path assets/textures/kiara_1_dawn_4k.hdr
texture_1_path assets/textures/square_floor.png
texture_2_path assets/textures/grid.jpg
texture_3_path assets/objects/fox/texture.png
# imported models
object_0 assets/objects/cube.obj
object_1 assets/objects/plane.obj
object_2 assets/objects/cT.obj
object_3 assets/objects/disco.obj
object_4 assets/objects/Tri2.obj
object_5 assets/objects/bunny1.obj
object_6 assets/objects/cubeUV.obj
# bunny
model
obj_id 5
texture_albedo 0
texture_specular 0
texture_emission 0
position 5 0 13
rotation 0 -120 0
size 2 2 2
albedo 0 0 0
specular 0.988 0.76 0.364
emission 0 0 0
smoothness 0.7
type 2
# glowing triangle
model
obj_id 4
texture_albedo 0
texture_specular 0
texture_emission 0
position -5 20 -5
rotation 0 45 90
size 30 30 30
albedo 0.1 0.1 0.1
specular 0.5 0.5 0.5
emission 5 5 5
smoothness 0.2
# pyramid blue
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 8 0 -10
rotation 0 15 0
size 2 1 2
albedo 0.1 0.1 0.1
specular 0 0 1
emission 0 0 0
smoothness 0.8
# pyramid red
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 15 0 -5
rotation 0 0 0
size 2 2 2
albedo 0.1 0.1 0.1
specular 1 0 0
emission 0 0 0
smoothness 0.8
# pink glass rectangle
model
obj_id 0
texture_albedo 0
texture_specular 0
texture_emission 0
position -2 0.25 -2
rotation 0 0 0
size 2 6 2
albedo 0 0 0
specular 1 0.4 0.8
emission 0 0 0
smoothness 0.99
transparency 1
refractive_index 1.8
type 2
# rectangle base
model
obj_id 6
texture_albedo 2
texture_specular 0
texture_emission 0
position -2 0 -2
rotation 0 45 0
size 20 0.5 20
albedo 1 1 1
specular 0 0 0
emission 0 0 0
smoothness 0.99
transparency 0
type 2
# glass sphere
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 10 3 0
rotation 0 45 0
size 3 3 3
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 0.999
refractive_index 1.5
transparency 0.95
type sphere
# plane
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 0 0
rotation 0 0 0
size 5 5 5
albedo 1 1 1
specular 0 0 0
emission 0 0 0
smoothness 1
type plane

View File

@ -0,0 +1,217 @@
# config
window_name Ray Tracing Refraction Demo 1
window_size 1024 512
pixel_shader_path shaders/ray_tracing/RayTracing.compute
# shader data
reflections 18
samples 1
camera_position 60 20 -60
camera_rotation -10 45 0
sensitivity 10
fov 40
# textures
texture_sky_path assets/textures/kiara_1_dawn_4k.hdr
texture_2_path assets/textures/grid.jpg
# imported models
object_0 assets/objects/fox/fox.obj
object_1 assets/objects/plane.obj
object_2 assets/objects/cube.obj
object_3 assets/objects/disco.obj
# transparent cube 1
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 0 22.5
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 0.9 0.9 0.9
emission 0 0 0
smoothness 1
refractive_index 1.2
transparency 1
type 2
# transparent cube 2
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position -22.5 0 22.5
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 0.7 0.7 0.7
emission 0 0 0
smoothness 1
refractive_index 1.4
transparency 0.99
type 2
# transparent cube 3
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 22.5 0 22.5
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 0.8 0.8 0.8
emission 0 0 0
smoothness 0.95
refractive_index 1.1
transparency 0.99
type 2
# transparent sphere
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 5 0
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 1
refractive_index 1.1
transparency 0.99
type sphere
# transparent sphere
model
texture_albedo 0
texture_specular 0
texture_emission 0
position -15 5 0
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 1
refractive_index 1.2
transparency 0.99
type sphere
# transparent sphere
model
texture_albedo 0
texture_specular 0
texture_emission 0
position -30 5 0
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 1
refractive_index 1.3
transparency 0.99
type sphere
# transparent sphere
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 15 5 0
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 0.95
refractive_index 1.5
transparency 0.99
type sphere
# transparent sphere
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 30 5 0
rotation 0 90 0
size 5 5 5
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 0.5
refractive_index 1.5
transparency 0.99
type sphere
# transparent cube in
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 0 -30
rotation 0 0 0
size 10 10 10
albedo 0 0 0
specular 0.8 0.8 0.8
emission 0 0 0
smoothness 1
refractive_index 1.1
transparency 0.99
type 2
# transparent cube in
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 2 -30
rotation 0 0 0
size 8 8 8
albedo 0 0 0
specular 0.8 0.8 0.8
emission 0 0 0
smoothness 1
refractive_index 1.3
transparency 0.99
type 2
# transparent sphere in cube
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 9.5 -30
rotation 0 0 0
size 3 3 3
albedo 0 0 0
specular 0.8 0.8 0.8
emission 0 0 0
smoothness 1
refractive_index 1.4
transparency 0.99
type sphere
# plane
model
obj_id 1
texture_albedo 2
texture_specular 2
texture_emission 0
position -50 0 0
rotation 0 0 90
size 1 50 50
albedo 1 1 1
specular 0.1 0.1 0.1
emission 0 0 0
smoothness 1

View File

@ -0,0 +1,69 @@
# config
window_name Ray Tracing Refraction Demo 2
window_size 512 512
pixel_shader_path shaders/ray_tracing/RayTracing.compute
# shader data
reflections 12
samples 1
camera_position -20 10 -50
camera_rotation -3 -22 0
sensitivity 10
fov 40
# textures
texture_sky_path assets/textures/kiara_1_dawn_4k.hdr
texture_2_path assets/textures/grid.jpg
# imported models
object_1 assets/objects/plane.obj
object_2 assets/objects/cube.obj
object_3 assets/objects/disco.obj
# transparent sphere mesh
model
obj_id 3
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 3.5 0
rotation 0 0 0
size 2 2 2
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 1
refractive_index 1.8
transparency 1
type 2
# transparent sphere mesh
model
obj_id 2
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 0 0
rotation 0 0 0
size 8 8 8
albedo 0 0 0
specular 1 1 1
emission 0 0 0
smoothness 1
refractive_index 1.6
transparency 1
type 2
# plane
model
obj_id 1
texture_albedo 2
texture_specular 2
texture_emission 0
position -50 0 0
rotation 0 0 90
size 1 50 50
albedo 1 1 1
specular 0.1 0.1 0.1
emission 0 0 0
smoothness 1

View File

@ -0,0 +1,96 @@
# config
window_name Ray Tracing
window_size 1024 512
pixel_shader_path shaders/ray_tracing/RayTracing.compute
object_shader_path
# shader data
reflections 15
samples 20
camera_position -92 3 -145
camera_rotation -2 -10 0
sensitivity 10
fov 40
# textures
texture_sky_path assets/textures/m_way2.hdr
texture_1_path assets/textures/8k_earth_nightmap.jpg
texture_2_path assets/textures/8k_moon.jpg
texture_3_path assets/textures/8k_mars.jpg
texture_4_path assets/textures/8k_earth_daymap.jpg
texture_5_path assets/textures/8k_venus_surface.jpg
# imported models
object_1 assets/objects/plane.obj
object_2 assets/objects/cube.obj
object_3 assets/objects/cubeUV.obj
# earth
model
texture_albedo 4
texture_specular 0
texture_emission 1
position -100 0 -120
rotation 0 0 0
size 5 5 5
albedo 1 1 1
specular 0 0 0
emission 0.05 0.05 0.05
smoothness 1
type sphere
# venus
model
texture_albedo 5
texture_specular 0
texture_emission 0
position 30 0 -20
rotation 0 0 0
size 3 3 3
albedo 1 1 1
specular 0 0 0
emission 0 0 0
smoothness 1
type sphere
# moon
model
texture_albedo 2
texture_specular 0
texture_emission 0
position -100 10 -80
rotation 0 -45 0
size 2 2 2
albedo 1 1 1
specular 0.01 0.01 0.01
emission 0 0 0
smoothness 0.3
type sphere
# mars
model
texture_albedo 3
texture_specular 0
texture_emission 0
position -30 0 200
rotation 0 -45 0
size 7 7 7
albedo 1 1 1
specular 0 0 0
emission 0 0 0
transparency 0
type sphere
# sun
model
texture_albedo 0
texture_specular 0
texture_emission 0
position 0 0 0
rotation 0 0 0
size 2 2 2
albedo 1 1 1
specular 1 1 1
emission 2000 1200 800
type sphere

8
make.bat Normal file
View File

@ -0,0 +1,8 @@
@echo off
set GLFW_ROOT=C:/lib/glfw-3.3.4.bin.WIN64
set GLEW_ROOT=C:/lib/glew-2.1.0_x64
set stb_image_ROOT=C:/lib/stb
set ComputeEngine_ROOT=C:/VisualStudioProjects/ComputeEngine
cmake -B build -S . -DGLFW_ROOT=%GLFW_ROOT% -DGLEW_ROOT=%GLEW_ROOT% -Dstb_image_ROOT=%stb_image_ROOT% -DComputeEngine_ROOT=%ComputeEngine_ROOT%

2
remake.bat Normal file
View File

@ -0,0 +1,2 @@
rmdir /s /q build
make.bat

BIN
screenshots/fox1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 MiB

BIN
screenshots/fox2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

BIN
screenshots/objects1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 MiB

BIN
screenshots/objects2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 421 KiB

BIN
screenshots/objects3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
screenshots/objects4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
screenshots/refraction1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

BIN
screenshots/refraction2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 MiB

BIN
screenshots/refraction3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 558 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 916 KiB

View File

@ -0,0 +1,777 @@
#version 430 core
#define PI 3.1415926538f
layout(local_size_x = 8, local_size_y = 8) in;
layout(rgba32f) uniform image2D img_output;
uniform sampler2D u_skybox;
uniform sampler2D u_tex1;
uniform sampler2D u_tex2;
uniform sampler2D u_tex3;
uniform sampler2D u_tex4;
uniform sampler2D u_tex5;
precision highp float;
struct SceneObject{
vec4 position;
vec4 size;
vec4 orientation;
vec4 albedo;
vec4 specular;
vec4 emission;
ivec4 texture_id;
float refractive_index;
float transparency;
float smoothness;
int type;
int offset;
int vert_num;
int obj_id;
int padding;
};
struct Ray{
vec3 origin;
vec3 direction;
vec3 color;
};
layout(std140, binding=2) uniform shader_data{
vec4 _camera_position; // 4 4
vec4 _camera_rotation; // 4 8
vec2 _pixel_offset; // 2 10
ivec2 _screen_size; // 2 12
int _iterations; // 1 13
float _seed; // 1 14
int _object_count; // 1 15
int _sample; // 1 16
int _samples_per_frame; // 1 17
int _fov; // 1 18
vec2 padding; // 2 20
};
layout (std140, binding = 3) uniform object_data{
SceneObject objects[1];
};
layout (std430, binding = 4) buffer index_buffer{
int faces[];
};
layout (std430, binding = 5) buffer vert_buffer{
float vertices[];
};
layout (std430, binding = 6) buffer texture_vert_buffer{
float t_vertices[];
};
uniform float u_gamma;
float distlimit = 10000.0f;
float seed = _seed;
vec2 pixel_id;
vec3 DegToRad(vec3 vect){
return vect * float(PI)/180.0f;
}
float saturate(float value){
return clamp(value,0.0,1.0);
}
float sdot(vec3 x, vec3 y){
float f = 1.0f;
return saturate(dot(x, y) * f);
}
float sdot(vec3 x, vec3 y, float f){
return saturate(dot(x, y) * f);
}
// A single iteration of Bob Jenkins' One-At-A-Time hashing algorithm.
uint hash( uint x ) {
x += ( x << 10u );
x ^= ( x >> 6u );
x += ( x << 3u );
x ^= ( x >> 11u );
x += ( x << 15u );
return x;
}
uint hash( uvec3 v ) { return hash( v.x ^ hash(v.y) ^ hash(v.z) ); }
// Construct a float with half-open range [0:1] using low 23 bits.
// All zeroes yields 0.0, all ones yields the next smallest representable value below 1.0.
float floatConstruct( uint m ) {
const uint ieeeMantissa = 0x007FFFFFu; // binary32 mantissa bitmask
const uint ieeeOne = 0x3F800000u; // 1.0 in IEEE binary32
m &= ieeeMantissa; // Keep only mantissa bits (fractional part)
m |= ieeeOne; // Add fractional part to 1.0
float f = uintBitsToFloat( m ); // Range [1:2]
return f - 1.0; // Range [0:1]
}
// Pseudo-random value in half-open range [0:1].
float Rand() { seed += 1.0f; return floatConstruct(hash(floatBitsToUint(vec3(pixel_id, seed)))); }
float SmoothnessToPhongAlpha(float s){
return pow(1000.0f, s * s);
}
mat3x3 GetTangentSpace(vec3 n){
// Choose a helper vector for the cross product
vec3 helper = vec3(1, 0, 0);
if (abs(n.x) > 0.99f)
helper = vec3(0, 0, 1);
// Generate vectors
vec3 t = normalize(cross(n, helper));
vec3 b = normalize(cross(n, t));
return mat3x3(
t.x, b.x, n.x,
t.y, b.y, n.y,
t.z, b.z, n.z
);
}
vec3 SampleHemisphere(vec3 normal, float alpha){
// Sample the hemisphere, where alpha determines the kind of the sampling
float cosTheta = pow(Rand(), 1.0f / (alpha + 1.0f));
float sinTheta = sqrt(1.0f - cosTheta * cosTheta);
float phi = 2 * PI * Rand();
vec3 tangentSpaceDir = vec3(cos(phi) * sinTheta, sin(phi) * sinTheta, cosTheta);
// Transform direction to world space
return normalize(tangentSpaceDir * GetTangentSpace(normal));
}
vec3 RefractRay(vec3 direction, vec3 n, float n1, float n2){
vec3 new_direction;
direction = normalize(direction);
n = normalize(n);
float dotp = dot(n, -direction);
float ratio = n1/n2;
vec3 e1 = (ratio * direction); // n1/n2 * i
float e2 = (ratio * dotp); // n1/n2 * cosB
float e3 = (ratio * ratio) * (1.0f - (dotp * dotp)); // (n1/n2)^2 * (1 - cosB^2)
new_direction = e1 + ((e2 - sqrt(1.0f - e3)) * n); // n1/n2 * i + (n1/n2 * cosB - /(1 - sinT^2) * n
return normalize(new_direction);
}
float GetReflectance(vec3 direction, vec3 normal, float n1, float n2){
float raycast;
float cosI = dot(-direction, normal);
float ratio = n1/n2;
float sin2T = (ratio * ratio) * (1.0f - (cosI * cosI));
if(sin2T <= 1.0f){
// Reflection or Transmission
float cosT = sqrt(1.0f - sin2T);
float R1 = pow((n1 * cosI - n2 * cosT)/(n1 * cosI + n2 * cosT), 2);
float R2 = pow((n2 * cosI - n1 * cosT)/(n2 * cosI + n1 * cosT), 2);
float Ravg = (R1 + R2) / 2.0f;
raycast = Ravg;
}else{
// Total Internal Reflection
raycast = 1.0f;
}
return raycast;
}
vec3 RotateVector(vec3 vect, vec3 rotation){
rotation = DegToRad(rotation);
float xr = rotation.x;
float yr = rotation.y;
float zr = rotation.z;
mat3x3 Rx = mat3x3(
1, 0, 0,
0, cos(xr), -sin(xr),
0, sin(xr), cos(xr)
);
mat3x3 Ry = mat3x3(
cos(yr), 0, sin(yr),
0, 1, 0,
-sin(yr), 0, cos(yr)
);
mat3x3 Rz = mat3x3(
cos(zr), -sin(zr), 0,
sin(zr), cos(zr), 0,
0, 0, 1
);
return (((Ry*Rx)*Rz)*vect);
}
Ray CreateRay(vec3 origin, vec3 direction){
Ray ray;
ray.origin = origin;
ray.direction = normalize(direction);
return ray;
}
Ray CreateCameraRay(float x, float y){
float n = 0.1f;
float fov_v = (float(_fov)/2.0f) * (PI/180.0f);
float ratio = (float(_screen_size.x)/float(_screen_size.y));
float fov_h = atan( tan(fov_v) * ratio );
x = (x - 0.5f) * 2;
y = (y - 0.5f) * 2;
vec3 plane = vec3(x * tan(fov_h) * n,y * tan(fov_v) * n,n);
vec3 direction = RotateVector(normalize(plane),_camera_rotation.xyz);
return CreateRay(_camera_position.xyz,direction);
}
vec4 CheckIntersectionWithSphere(vec3 r1, vec3 r2, int i){
vec3 oc = r1 - objects[i].position.xyz;
float a = dot(r2,r2);
float b = 2.0f * dot(oc, r2);
float c = dot(oc, oc) - objects[i].size.x * objects[i].size.x;
float p = c/a;
float q = -b/a;
float d = b * b - (4 * a * c);
if(p < 0){
//inside
float val = (-b + sqrt(d)) / (2.0f*a);
vec3 hit = r1 + r2 * val;
return vec4(r1 + r2 * val, val);
}else{
if(q > 0){
//hit
float val = (-b - sqrt(d)) / (2.0f*a);
vec3 hit = r1 + r2 * val;
return vec4(r1 + r2 * val, val);
}else{
//not hit
return vec4(vec3(0,0,0),-1.0f);
}
}
}
vec4 CheckIntersectionWithPlane(vec3 r1, vec3 r2, int i){
vec3 normal = normalize(RotateVector(vec3(0,1,0), objects[i].orientation.xyz));
float dotP = dot(normal, r2);
vec3 pos = objects[i].position.xyz;
int ans = int(abs(dotP) >= 0.001f);
float d = dot((pos - r1),normal)/dotP;
return vec4(r1 + r2 * d, ans * (d + 1) - 1);
if(abs(dotP) >= 0.001f){
float d = dot((pos - r1),normal)/dotP;
if(d < 0)
return vec4(vec3(0,0,0),-1.0f);
return vec4(r1 + r2 * d, d);
}
return vec4(vec3(0,0,0),-1.0f);
}
vec3 GetTriangleVertex(int id, int object_id){
vec3 pos = objects[object_id].position.xyz;
vec3 size = objects[object_id].size.xyz;
vec3 rotation = objects[object_id].orientation.xyz;
id = id * 3;
vec3 vertex_from_array = vec3(vertices[id], vertices[id+1], vertices[id+2]);
vec3 vert = RotateVector(vertex_from_array * size, rotation);
return vert + pos;
}
vec2 GetTriangleUV(int id){
id = id * 2;
vec2 vertex_from_array = vec2(t_vertices[id], t_vertices[id+1]);
return vertex_from_array;
}
vec4 CheckIntersectionWithTriangleUV(vec3 r1, vec3 r2, int face_id, int object_id, inout vec2 uv, inout vec3 normal){
const float EPSILON = 0.0000001;
vec3 pos = objects[object_id].position.xyz;
vec3 size = objects[object_id].size.xyz;
vec3 vertex0 = GetTriangleVertex(faces[(face_id * 6) + 0], object_id);
vec3 vertex1 = GetTriangleVertex(faces[(face_id * 6) + 1], object_id);
vec3 vertex2 = GetTriangleVertex(faces[(face_id * 6) + 2], object_id);
vec3 edge1, edge2, h, s, q;
float a,f;
edge1 = vertex1 - vertex0;
edge2 = vertex2 - vertex0;
h = cross(r2, edge2);
vec3 N = cross(edge1,edge2); // N
bool reverse = dot(N, r2) > 0;
normal = (reverse ? -1 : 1) * normalize(N);
a = dot(edge1, h);
if (a > -EPSILON && a < EPSILON)
return vec4(0.0f, 0.0f, 0.0f, -1.0f); // This ray is parallel to this triangle.
f = 1.0/a;
s = r1 - vertex0;
uv.x = f * dot(s, h);
if (uv.x < 0.0 || uv.x > 1.0)
return vec4(0.0f, 0.0f, 0.0f, -1.0f); // This ray is parallel to this triangle.
q = cross(s, edge1);
uv.y = f * dot(r2, q);
if (uv.y < 0.0 || uv.x + uv.y > 1.0)
return vec4(0.0f, 0.0f, 0.0f, -1.0f); // This ray is parallel to this triangle.
// At this stage we can compute t to find out where the intersection point is on the line.
float t = f * dot(edge2, q);
if (t > EPSILON) // ray intersection
{
// map uv
float u = uv.x;
float v = uv.y;
float w = 1.0 - uv.x - uv.y;
// A(v0) - w
// B(v1) - u
// C(v2) - v
vec2 uv0 = GetTriangleUV(faces[(face_id * 6) + 3]);
vec2 uv1 = GetTriangleUV(faces[(face_id * 6) + 4]);
vec2 uv2 = GetTriangleUV(faces[(face_id * 6) + 5]);
uv = uv0 * w + uv1 * u + uv2 * v;
return vec4(r1 + r2 * t, t); // This ray is parallel to this triangle.
}
else // This means that there is a line intersection but not a ray intersection.
return vec4(0.0f, 0.0f, 0.0f, -1.0f); // This ray is parallel to this triangle.
}
vec4 CheckIntersectionWithMesh(vec3 r1, vec3 r2, int object_id, inout vec3 normal, inout vec2 uv){
vec4 raycast;
float val = 100000.0f;
vec3 hit_point;
vec3 temp_normal;
vec2 temp_uv;
int vert_num = objects[object_id].vert_num;
int offset = objects[object_id].offset;
for(int i = 0; i < vert_num; i++){
raycast = CheckIntersectionWithTriangleUV(r1, r2, offset + i, object_id, temp_uv, temp_normal);
if (raycast.w >= 0 && raycast.w < val){
hit_point = raycast.xyz;
val = raycast.w;
normal = temp_normal;
uv = temp_uv;
}
}
return vec4(hit_point, val);
}
float GetEnergy(vec3 color){
return dot(color, vec3(1.0f / 3.0f));
}
vec3 GetTextureColor(vec2 uv, int object_id, int map){
int id = objects[object_id].texture_id[map];
switch(id){
case 0:
return vec3(1.0f,1.0f,1.0f);
case 1:
return texture(u_tex1, uv).xyz;
case 2:
return texture(u_tex2, uv).xyz;
case 3:
return texture(u_tex3, uv).xyz;
case 4:
return texture(u_tex4, uv).xyz;
case 5:
return texture(u_tex5, uv).xyz;
default:
return vec3(1.0f,1.0f,1.0f);
}
}
vec3 GetNormal_old(vec3 pos, int object_id){
vec3 normal = vec3(0,1,0);
if(objects[object_id].type == 0) //sphere
normal = normalize(pos - objects[object_id].position.xyz);
else if(objects[object_id].type == 1) //plane
normal = normalize(RotateVector(vec3(0,1,0), objects[object_id].orientation.xyz));
else if(objects[object_id].type == 2){ //mesh
int v_offset = objects[object_id].offset;
vec3 v0 = GetTriangleVertex(faces[(v_offset * 6) + 0], object_id);
vec3 v1 = GetTriangleVertex(faces[(v_offset * 6) + 1], object_id);
vec3 v2 = GetTriangleVertex(faces[(v_offset * 6) + 2], object_id);
vec3 A = v1 - v0; // edge 0
vec3 B = v2 - v0; // edge 1
normal = normalize(cross(A, B));
}
return normal;
}
vec3 GetNormal(vec3 pos, vec3 dir, int object_id){
vec3 normal = vec3(0,1,0);
if(objects[object_id].type == 0) //sphere
normal = normalize(pos - objects[object_id].position.xyz);
else if(objects[object_id].type == 1) //plane
normal = normalize(RotateVector(vec3(0,1,0), objects[object_id].orientation.xyz));
else if(objects[object_id].type == 2){ //mesh
int v_offset = objects[object_id].offset;
vec3 v0 = GetTriangleVertex(faces[(v_offset * 6) + 0], object_id);
vec3 v1 = GetTriangleVertex(faces[(v_offset * 6) + 1], object_id);
vec3 v2 = GetTriangleVertex(faces[(v_offset * 6) + 2], object_id);
vec3 A = v1 - v0; // edge 0
vec3 B = v2 - v0; // edge 1
normal = normalize(cross(A, B));
}
bool reverse = dot(normal, dir) > 0;
normal = (reverse ? -1 : 1) * normalize(normal);
return normal;
}
vec3 GetNormal(vec3 pos, vec3 dir, int object_id, inout bool reversed){
vec3 normal = vec3(0,1,0);
if(objects[object_id].type == 0) //sphere
normal = normalize(pos - objects[object_id].position.xyz);
else if(objects[object_id].type == 1) //plane
normal = normalize(RotateVector(vec3(0,1,0), objects[object_id].orientation.xyz));
else if(objects[object_id].type == 2){ //mesh
int v_offset = objects[object_id].offset;
vec3 v0 = GetTriangleVertex(faces[(v_offset * 6) + 0], object_id);
vec3 v1 = GetTriangleVertex(faces[(v_offset * 6) + 1], object_id);
vec3 v2 = GetTriangleVertex(faces[(v_offset * 6) + 2], object_id);
vec3 A = v1 - v0; // edge 0
vec3 B = v2 - v0; // edge 1
normal = normalize(cross(A, B));
}
reversed = dot(normal, dir) > 0;
normal = (reversed ? -1 : 1) * normalize(normal);
return normal;
}
vec4 CastRay(Ray ray, inout vec3 normal, inout vec2 uv){
int object_id = -1;
vec4 raycast;
float val = distlimit;
vec3 hit_point;
vec3 temp_normal;
vec2 temp_uv;
for(int i = 0; i < _object_count; i++){
vec3 r1 = ray.origin;
vec3 r2 = ray.direction;
vec3 op = objects[i].position.xyz;
float r = objects[i].size.x;
if(objects[i].type == 0){
raycast = CheckIntersectionWithSphere(r1,r2,i);
if(raycast.w > 0){
bool reversed;
temp_normal = GetNormal(raycast.xyz,r2,i,reversed);
float theta = 1.0f - (acos((reversed ? -1 : 1) * temp_normal.y) / PI);
float phi = atan((reversed ? -1 : 1) * temp_normal.z, (reversed ? -1 : 1) * temp_normal.x) / (2 * PI) + 0.5f;
temp_uv.x = mod((phi + (objects[i].orientation[1] / (2.0 * PI))), 1);
temp_uv.y = theta;
}
}
else if(objects[i].type == 1){
raycast = CheckIntersectionWithPlane(r1,r2,i);
if(raycast.w > 0)
temp_normal = GetNormal(raycast.xyz,r2, i);
}
else if(objects[i].type == 2){
raycast = CheckIntersectionWithMesh(r1,r2,i, temp_normal, temp_uv);
}
else
raycast = vec4(0,0,0,distlimit);
if (raycast.w >= 0 && raycast.w < val){
hit_point = raycast.xyz;
val = raycast.w;
object_id = i;
normal = temp_normal;
uv = temp_uv;
}
}
return vec4(hit_point,object_id);
}
vec3 GetSkyColor(vec3 direction){
float theta = 1.0f - (acos(direction.y) / PI);
float phi = atan(direction.x, direction.z) / (2 * PI) + 0.5f;
return texture(u_skybox, vec2(phi, theta)).xyz;
}
void main(){
ivec2 id = ivec2(gl_GlobalInvocationID.xy);
vec4 pixel = vec4(0.0f, 0.0f, 0.0f, 1.0f);
vec4 raycast;
vec4 raycast_n;
vec3 color;
vec3 reflection;
vec3 normal;
vec3 albedo;
vec3 specular;
vec3 energy;
vec2 offset = _pixel_offset;
vec2 uv;
Ray reflection_ray;
Ray camera_ray;
float x, y;
float diffuse_chance;
float specular_chance;
float refraction_chance;
float sum;
float roulette;
float f;
float alpha;
float dist;
float air_transparency = 1.0f;
int face_id;
int object_id;
bool inside_object[100];
float refractive_indices_queue[100];
refractive_indices_queue[0] = air_transparency;
int refractive_indices_count = 1;
for(int i = 0; i < 100; i++){
inside_object[i] = false;
}
pixel_id = id;
for(int s = 0; s < _samples_per_frame; s++){
// map x,y to [0,1]
x = (((float(id.x) - 0.5f + offset.x)/_screen_size.x));
y = (((float(id.y) - 0.5f + offset.y)/_screen_size.y));
// new random offset
offset = vec2(1.0f * (abs(Rand()) - 0.5f) ,1.0f * (abs(Rand()) - 0.5f));
color = vec3(0.0f, 0.0f, 0.0f);
// get pixel for random generator
pixel_id = vec2(id) + offset;
// create a ray and cast it
camera_ray = CreateCameraRay(x,y);
raycast = CastRay(camera_ray, normal, uv);
object_id = int(raycast.w);
// if hit any object
if(object_id >= 0){
// calculate distance between rays
dist = length(_camera_position.xyz - raycast.xyz);
// initial energy values
energy = vec3(1.0f, 1.0f, 1.0f);
// add emmission from map
color += objects[object_id].emission.xyz * GetTextureColor(uv, object_id, 3);
//color += normal;
reflection_ray = camera_ray;
// recast ray multiple times
for(int i = 0; i < _iterations; i++){
roulette = Rand();
// get specular and albedo
specular = objects[object_id].specular.xyz * GetTextureColor(uv, object_id, 1);
albedo = min(1.0f - specular, objects[object_id].albedo.xyz * GetTextureColor(uv, object_id, 0));
// check if object is translucent
bool translucent = (objects[object_id].transparency > 0.01f);
if(translucent){
// refractive indicies
float n1;
float n2;
// 0 -> 1
if(!inside_object[object_id]){
// n1 is set to last index
n1 = refractive_indices_queue[refractive_indices_count-1];
// n2 is set to new object
n2 = objects[object_id].refractive_index;
}
else{ // 1 -> 0
// n1 is set to last index
n1 = refractive_indices_queue[refractive_indices_count-1];
// n2 is set to the one before that
n2 = refractive_indices_queue[refractive_indices_count-2];
}
f = 1.0f;
if(objects[object_id].smoothness <= 0.9999f){
alpha = SmoothnessToPhongAlpha(objects[object_id].smoothness);
normal = SampleHemisphere(normal, alpha);
f = (alpha + 2) / (alpha + 1);
}
// calculate reflection and transmission
float val_R = GetReflectance(reflection_ray.direction.xyz, normal, n1, n2);
float val_T = 1.0f - val_R;
bool refract = (roulette < val_T);
bool entering = !inside_object[object_id];
// update queue
if(refract){
inside_object[object_id] = !inside_object[object_id];
reflection = RefractRay(reflection_ray.direction, normal, n1, n2);
if(entering){
// add n2 to queue
refractive_indices_count++;
refractive_indices_queue[refractive_indices_count - 1] = n2;
}else{
// leaving (1 -> 0)
refractive_indices_count--;
}
}
else{
reflection = reflect(reflection_ray.direction, normal);
// no change to queue
}
vec3 ray_normal;
if(refract)
ray_normal = normal * -1;
else
ray_normal = normal;
// create and cast reflection ray
reflection_ray = CreateRay(raycast.xyz + ray_normal * 0.001f, reflection);
// calculate loss due to partial transparency
float transmittance = 1;
if(!entering)
transmittance = pow(10, -1 * (1.0f - objects[object_id].transparency) * dist);
// update energy
energy *= specular * transmittance;
}
else{
// calculate chances
diffuse_chance = GetEnergy(albedo.xyz) + 0.0001f;
specular_chance = GetEnergy(specular.xyz) + 0.0001f;
sum = diffuse_chance + specular_chance;
diffuse_chance /= sum;
specular_chance /= sum;
if(roulette < diffuse_chance){
//diffuse
reflection = SampleHemisphere(normal, 1.0f);
// update energy
energy *= albedo * 2 * sdot(normal, reflection);
}else{
// specular
reflection = normalize(reflection_ray.direction - 2 * dot(reflection_ray.direction, normal) * normal);
f = 1.0f;
if(objects[object_id].smoothness <= 0.9999f){
alpha = SmoothnessToPhongAlpha(objects[object_id].smoothness);
reflection = SampleHemisphere(reflection, alpha);
f = (alpha + 2) / (alpha + 1);
}
// update energy
energy *= specular * 2 * sdot(normal, reflection);
}
//create and cast reflected ray
reflection_ray = CreateRay(raycast.xyz + normal * 0.001f, reflection);
}
// cast new ray
raycast_n = CastRay(reflection_ray, normal, uv);
object_id = int(raycast_n.w);
//if hit sky, break and get color * energy
if(object_id == -1){
color += energy * GetSkyColor(reflection_ray.direction);
break;
}else{
color += energy * objects[object_id].emission.xyz * GetTextureColor(uv, object_id, 3);
dist = length(raycast_n.xyz - raycast.xyz);
}
// if energy is low, no need to keep going
if((energy.x + energy.y + energy.z <= 0.01f && i > 1)){
break;
}
raycast = raycast_n;
}
}
else{
// sample skybox
color = GetSkyColor(camera_ray.direction);
}
// add sample
pixel += vec4(color.xyz, 0.0f);
}
// get average over samples
pixel = vec4(pixel.xyz/float(_samples_per_frame), 1.0f);
// update the new average
vec4 old = imageLoad(img_output, id);
pixel = old + (vec4(pixel) - old)/_sample;
// update pixel in texture
imageStore(img_output, id, pixel);
}

10
src/CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
target_sources(${PROJECT_NAME}
PUBLIC
main.cpp
DataStructures.cpp
DataStructures.h
Utils.cpp
Utils.h
Config.cpp
Config.h
)

270
src/Config.cpp Normal file
View File

@ -0,0 +1,270 @@
#include <Config.h>
Config::Config(std::string path) {
LoadConfigFile(path);
}
std::vector<SceneObject>* Config::GetObjects()
{
return &m_objects;
}
int Config::GetVertexCount()
{
return m_buffer.GetVertexCount();
}
int Config::GetFaceCount()
{
return m_buffer.GetFaceCount();
}
int Config::GetObjectCount()
{
return (int)m_objects.size();
}
Config::Config() {
}
bool Config::LoadConfigFile(std::string path)
{
std::fstream file(path);
std::string line;
std::stringstream str;
std::string prefix;
int vertex_id = 0;
float x, y, z;
int ix, iy, iz;
std::string data;
bool reading_object = false;
while (std::getline(file, line)) {
str.clear();
str.str(line);
str >> prefix;
if (line.length() == 0)
continue;
if (line[0] == '#')
continue;
if (prefix == "window_name") {
m_window_name = line.substr(prefix.length() + 1, line.length() - prefix.length());
}
else if (prefix == "window_size") {
str >> ix >> iy;
m_window_width = ix;
m_window_height = iy;
}
else if (prefix == "start_focused") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
if (data == "true" || data == "1")
m_start_focused = true;
else
m_start_focused = false;
}
else if (prefix == "pixel_shader_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_pixel_shader_path = data;
}
else if (prefix == "object_shader_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_object_shader_path = data;
}
else if (prefix == "texture_sky_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_texture_sky_path = data;
}
else if (prefix == "texture_1_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_texture_1_path = data;
}
else if (prefix == "texture_2_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_texture_2_path = data;
}
else if (prefix == "texture_3_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_texture_3_path = data;
}
else if (prefix == "texture_4_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_texture_4_path = data;
}
else if (prefix == "texture_5_path") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_texture_5_path = data;
}
else if (prefix == "reflections") {
str >> m_iterations;
}
else if (prefix == "samples") {
str >> m_samples_per_frame;
}
else if (prefix == "fov") {
str >> m_fov;
}
else if (prefix == "sensitivity") {
str >> m_camera_sensitivity;
}
else if (prefix == "camera_position") {
str >> x >> y >> z;
m_camera_position = { x, y, z };
}
else if (prefix == "camera_rotation") {
str >> x >> y >> z;
m_camera_rotation = { x, y, z };
}
else if (prefix == "model") {
reading_object = true;
m_objects.push_back(SceneObject());
}
else if (prefix.find("object_") != -1) {
data = prefix.substr(7, prefix.length() - 6 - 1);
int id = stoi(data);
m_models.push_back(Model3D());
m_models.back().SetId(id);
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
m_models.back().Load(data);
}
else if (prefix == "model") {
reading_object = true;
m_objects.push_back(SceneObject());
}
else if (prefix == "obj_id") {
str >> ix;
m_objects.back().type = 2;
m_objects.back().obj_id = ix;
}
else if (prefix == "texture_albedo") {
str >> ix;
m_objects.back().texture_id[0] = ix;
}
else if (prefix == "texture_specular") {
str >> ix;
m_objects.back().texture_id[1] = ix;
}
else if (prefix == "texture_emission") {
str >> ix;
m_objects.back().texture_id[3] = ix;
}
else if (prefix == "position") {
str >> x >> y >> z;
m_objects.back().position = { x, y, z };
}
else if (prefix == "rotation") {
str >> x >> y >> z;
m_objects.back().orientation = { x, y, z };
}
else if (prefix == "size") {
str >> x >> y >> z;
m_objects.back().size = { x, y, z };
}
else if (prefix == "albedo") {
str >> x >> y >> z;
m_objects.back().albedo = { x, y, z };
}
else if (prefix == "specular") {
str >> x >> y >> z;
m_objects.back().specular = { x, y, z };
}
else if (prefix == "emission") {
str >> x >> y >> z;
m_objects.back().emission = { x, y, z };
}
else if (prefix == "smoothness") {
str >> x;
m_objects.back().smoothness = x;
}
else if (prefix == "refractive_index") {
str >> x;
m_objects.back().refractive_index = x;
}
else if (prefix == "transparency") {
str >> x;
m_objects.back().transparency = x;
}
else if (prefix == "type") {
data = line.substr(prefix.length() + 1, line.length() - prefix.length() - 1);
if (data == "sphere")
m_objects.back().type = 0;
else if (data == "plane")
m_objects.back().type = 1;
}
}
for (int i = 0; i < m_models.size(); i++)
m_buffer.AddModel(&m_models[i]);
m_buffer.FillBuffers();
for (int i = 0; i < m_objects.size(); i++) {
if (m_objects[i].type == 2) {
// find object
for (int j = 0; j < m_models.size(); j++)
if (m_models[j].GetId() == m_objects[i].obj_id) {
// set offsets
m_objects[i].offset = m_models[j].GetIndexOffset();
m_objects[i].vert_num = m_models[j].GetFaceCount();
}
}
}
return true;
}
bool Config::BindTextures(Program& program)
{
if (m_texture_sky_path != "") {
m_tex_sky = new Texture("u_skybox", m_texture_sky_path);
}
if (m_texture_1_path != "") {
m_tex_1 = new Texture("u_tex1", m_texture_1_path);
}
if (m_texture_2_path != "") {
m_tex_2 = new Texture("u_tex2", m_texture_2_path);
}
if (m_texture_3_path != "") {
m_tex_3 = new Texture("u_tex3", m_texture_3_path);
}
if (m_texture_4_path != "") {
m_tex_4 = new Texture("u_tex4", m_texture_4_path);
}
if (m_texture_5_path != "") {
m_tex_5 = new Texture("u_tex5", m_texture_5_path);
}
if (m_texture_sky_path != "") {
program.BindTexture(m_tex_sky, 0);
}
if (m_texture_1_path != "") {
program.BindTexture(m_tex_1, 1);
}
if (m_texture_2_path != "") {
program.BindTexture(m_tex_2, 2);
}
if (m_texture_3_path != "") {
program.BindTexture(m_tex_3, 3);
}
if (m_texture_4_path != "") {
program.BindTexture(m_tex_4, 4);
}
if (m_texture_5_path != "") {
program.BindTexture(m_tex_5, 5);
}
return true;
}
std::vector<int>* Config::GetIndexBuffer() {
return m_buffer.GetIndexBuffer();
}
std::vector<float>* Config::GetTextureBuffer() {
return m_buffer.GetTextureBuffer();
}
std::vector<float>* Config::GetVertexBuffer() {
return m_buffer.GetVertexBuffer();
}

54
src/Config.h Normal file
View File

@ -0,0 +1,54 @@
#pragma once
#include "DataStructures.h"
#include "ComputeEngine.h"
class Config {
public:
SceneVertices m_buffer;
std::vector<Model3D> m_models;
std::vector<SceneObject> m_objects;
std::vector<Texture> m_textures;
std::string m_window_name = "Window";
int m_window_width = 512;
int m_window_height = 512;
bool m_start_focused = true;
std::string m_pixel_shader_path = "";
std::string m_object_shader_path = "";
int m_iterations = 5;
int m_samples_per_frame = 1;
int m_fov = 30;
float m_camera_sensitivity = 10.0f;
std::array<float, 3> m_camera_position = { 0, 0, 0 };
std::array<float, 3> m_camera_rotation = { 0, 0, 0 };
std::string m_texture_sky_path = "";
std::string m_texture_1_path = "";
std::string m_texture_2_path = "";
std::string m_texture_3_path = "";
std::string m_texture_4_path = "";
std::string m_texture_5_path = "";
Texture* m_tex_sky = (Texture*)(nullptr);
Texture* m_tex_1 = (Texture*)(nullptr);
Texture* m_tex_2 = (Texture*)(nullptr);
Texture* m_tex_3 = (Texture*)(nullptr);
Texture* m_tex_4 = (Texture*)(nullptr);
Texture* m_tex_5 = (Texture*)(nullptr);
bool LoadConfigFile(std::string path);
bool BindTextures(Program& program);
std::vector<int>* GetIndexBuffer();
std::vector<float>* GetTextureBuffer();
std::vector<float>* GetVertexBuffer();
std::vector<SceneObject>* GetObjects();
int GetVertexCount();
int GetFaceCount();
int GetObjectCount();
Config(std::string path);
Config();
};

128
src/DataStructures.cpp Normal file
View File

@ -0,0 +1,128 @@
#define _USE_MATH_DEFINES
#include <DataStructures.h>
#include <vector>
#include <array>
#include <math.h>
#include <cmath>
#include <string>
#include <iostream>
void CameraData::AccelerateCamera(float acc[3]) {
for (int i = 0; i < 3; i++)
acceleration[i] += acc[i] * acc_mul;
}
void CameraData::RotateCamera(float dx, float dy) {
rotation[1] += dx * sensitivity * (500.0f/m_width);
if (rotation[0] + dy * sensitivity * (500.0f / m_width) < -90)
rotation[0] = -90;
else if (rotation[0] + dy * sensitivity * (500.0f / m_width) > 90)
rotation[0] = 90;
else
rotation[0] += dy * sensitivity * (500.0f / m_width);
rotation[1] = (float)fmod(rotation[1], 360);
if((abs(dx) > 0.0001f) || (abs(dy) > 0.0001f))
m_changed = true;
}
void CameraData::CopyData(ShaderData& shader_data) {
shader_data._camera_position = { position[0], position[1], position[2], 0 };
shader_data._camera_rotation = { rotation[0], rotation[1], rotation[2], 0 };
}
bool CameraData::HasChanged() {
return m_changed;
}
void CameraData::SetChanged(bool ch) {
m_changed = ch;
}
float DegToRad(float deg) {
return (float)(deg * (M_PI / 180.0f));
}
void CameraData::UpdateCameraData(float time) {
std::vector<std::vector<float>> move_vectors;
std::vector<float> forward = { -sin(DegToRad(rotation[1])), sin(DegToRad(rotation[0])), cos(DegToRad(rotation[1])) };
std::vector<float> up = { 0, 1.0f, 0 };
std::vector<float> right = { cos(DegToRad(rotation[1])), 0, sin(DegToRad(rotation[1])) };
move_vectors.push_back(right);
move_vectors.push_back(up);
move_vectors.push_back(forward);
//update position
for (int i = 0; i < 3; i++) {
temp[0] = position[i];
temp[1] = rotation[i];
// calculate accelleration
float accel = 0;
for (int x = 0; x < 3; x++)
accel += acceleration[x] * move_vectors[x][i];
velocity[i] += accel * time;
position[i] += velocity[i] * time;
// apply friction
float sum = abs(velocity[0]) + abs(velocity[1]) + abs(velocity[2]);
float part_friction = abs((velocity[i] / sum)) * friction;
if (sum != 0) {
if (velocity[i] > 0) {
if (part_friction * time > velocity[i])
velocity[i] = 0;
else
velocity[i] -= part_friction * time;
}
else if (velocity[i] < 0) {
if (part_friction * time < velocity[i])
velocity[i] = 0;
else
velocity[i] += part_friction * time;
}
position[i] += velocity[i] * time;
}
if ((temp[0] != position[i]) || (temp[1] != rotation[i]))
m_changed = true;
}
// reset acceleration
for (int i = 0; i < 3; i++)
acceleration[i] = 0;
// scale velocity to max velocity
float length = sqrt(pow(velocity[0], 2) + pow(velocity[1], 2) + pow(velocity[2], 2));
float scaling = 1.0f;
if (length > max_v) {
scaling = ((length - max_v) / max_v) + 1.0f;
for(int i = 0; i < 3; i++)
velocity[i] /= scaling;
}
}
void ShaderData::UpdateSeed() {
_seed = GetRand();
}
void ShaderData::UpdateWindowSize(int width, int height) {
_screen_size[0] = width;
_screen_size[1] = height;
}
void ShaderData::GetWindowSize(int& width, int& height) {
width = _screen_size[0];
height = _screen_size[1];
}
int ShaderData::GetWidth() {
return _screen_size[0];
}
int ShaderData::GetHeight() {
return _screen_size[1];
}
void CameraData::UpdateWindowSize(int width, int height) {
m_width = width;
m_height = height;
}

72
src/DataStructures.h Normal file
View File

@ -0,0 +1,72 @@
#pragma once
#include <array>
#include <string>
#include <Utils.h>
struct ShaderData
{
public:
std::array<float, 4> _camera_position = { 0, 0, 0, 0 };
std::array<float, 4> _camera_rotation = { 0, 0, 0, 0 };
std::array<float, 2> _pixel_offset = { 0.5f, 0.5f };
std::array<int, 2> _screen_size = { 0, 0 };
int _iterations = 5;
float _seed = GetRand();
int _objectcount = 0;
int _sample = 1;
int _samples = 1;
int _fov = 30;
std::array<float, 2> _padding = { 0, 0};
void UpdateSeed();
void UpdateWindowSize(int width, int height);
void GetWindowSize(int& width, int& height);
int GetWidth();
int GetHeight();
};
struct CameraData {
std::array<float, 3> velocity = { 0, 0, 0 };
std::array<float, 3> position = { 0, 0, 0 };
std::array<float, 3> rotation = { 0, 0, 0 };
std::array<float, 3> acceleration = { 0, 0, 0 };
float max_v = 30.0f;
float friction = 30.0f;
float acc_mul = 50.0f;
bool m_changed = false;
bool breakk = false;
float sensitivity = 3.0f;
int m_width = 0, m_height = 0;
void AccelerateCamera(float acc[3]);
void RotateCamera(float dx, float dy);
void CopyData(ShaderData& shader_data);
bool HasChanged();
void SetChanged(bool ch);
float temp[2] = {0, 0};
void UpdateCameraData(float time);
void UpdateWindowSize(int width, int height);
};
struct SceneObject {
std::array<float, 4> position = { 0, 0, 0, 0 };
std::array<float, 4> size = { 1, 1, 1, 1 };
std::array<float, 4> orientation = { 0, 0, 0, 0 };
std::array<float, 4> albedo = { 1, 1, 1, 1 };
std::array<float, 4> specular = { 0, 0, 0, 0 };
std::array<float, 4> emission = { 0, 0, 0, 0 };
//0 - diffuse
//1 - specular
//2 - normal
//3 - emission
std::array<int, 4> texture_id = { 0, 0, 0, 0 };
float refractive_index = 1;
float transparency = 0;
float smoothness = 0;
int type = 0;
int offset = 0;
int vert_num = 0;
int obj_id = 0;
int padding = 0;
};

10
src/Utils.cpp Normal file
View File

@ -0,0 +1,10 @@
#include "Utils.h"
float GetRand() {
return (float)((double)rand() / (RAND_MAX));
}
bool FileExists(const std::string& name) {
struct stat buffer;
return (stat(name.c_str(), &buffer) == 0);
}

8
src/Utils.h Normal file
View File

@ -0,0 +1,8 @@
#pragma once
#include <iostream>
#define LOG_ERROR(msg) \
std::cout << '[' << __TIME__ << "] ERROR: " << msg << std::endl
float GetRand();
bool FileExists(const std::string& name);

196
src/main.cpp Normal file
View File

@ -0,0 +1,196 @@
#include <array>
#include <string>
#include <vector>
#include <iostream>
#include <ComputeEngine.h>
#include "Utils.h"
#include "DataStructures.h"
#include "Config.h"
#define UPDATE_OBJECT_BUFFERS 0
void UpdateKeys(ComputeEngine& renderer, CameraData& camera, std::vector<SceneObject>& objects, ShaderData& shader_data, Texture& tex_output) {
if (renderer.IsKeyClicked(GLFW_KEY_P)) {
renderer.SwitchInput();
}
if (renderer.GetInput()) {
if (renderer.IsKeyPressed(GLFW_KEY_W))
camera.AccelerateCamera(new float[3]{ 0, 0, 1.0f });
if (renderer.IsKeyPressed(GLFW_KEY_A))
camera.AccelerateCamera(new float[3]{ -1.0f, 0, 0 });
if (renderer.IsKeyPressed(GLFW_KEY_S))
camera.AccelerateCamera(new float[3]{ 0, 0, -1.0f });
if (renderer.IsKeyPressed(GLFW_KEY_D))
camera.AccelerateCamera(new float[3]{ 1.0f, 0, 0 });
if (renderer.IsKeyPressed(GLFW_KEY_SPACE))
camera.AccelerateCamera(new float[3]{ 0, 1.0f, 0 });
if (renderer.IsKeyPressed(GLFW_KEY_LEFT_CONTROL))
camera.AccelerateCamera(new float[3]{ 0, -1.0f, 0 });
if (renderer.IsKeyPressed(GLFW_KEY_E)) {
}
if (renderer.IsKeyPressed(GLFW_KEY_Q)) {
}
if (renderer.IsKeyClicked(GLFW_KEY_F11)) {
renderer.SwitchFullScreen();
}
if (renderer.IsKeyClicked(GLFW_KEY_ESCAPE))
renderer.CloseWindow();
if (renderer.IsKeyClicked(GLFW_KEY_L)) {
renderer.SaveScreen("screenshot");
}
}
int width, height;
shader_data.GetWindowSize(width, height);
renderer.GetWindowSize(shader_data._screen_size[0], shader_data._screen_size[1]);
if (width != shader_data.GetWidth() || height != shader_data.GetHeight())
tex_output.Resize(shader_data.GetWidth(), shader_data.GetHeight());
}
void UpdateInput(ComputeEngine& renderer, CameraData& camera, std::vector<SceneObject>& objects, ShaderData& shader_data, Texture& tex_output) {
renderer.PollEvents();
UpdateKeys(renderer, camera, objects, shader_data, tex_output);
double dx, dy;
renderer.GetMouseDelta(dx, dy);
dx *= (renderer.GetFrametime() / 1000.0);
dy *= (renderer.GetFrametime() / 1000.0);
double xp, yp;
int w, h;
renderer.GetWindowSize(w, h);
renderer.GetMousePos(xp, yp);
bool in_window = xp > 0 && yp > 0 && xp < w && yp < h;
if (renderer.IsMouseButtonClicked(GLFW_MOUSE_BUTTON_1) && !renderer.GetInput())
{
renderer.SetInput(true);
}
camera.RotateCamera((float)dx, (float)dy);
camera.UpdateCameraData((float)(renderer.GetFrametime() / 1000.0));
}
int main(int argc, char** argv)
{
srand((unsigned)time(0));
std::string config_filename = "configs/config.txt";
if (argc > 1)
config_filename = argv[1];
if (!FileExists(config_filename)) {
LOG_ERROR(config_filename + " does not exist");
return -1;
}
std::cout << "config file name: " << config_filename << std::endl;
Config config(config_filename);
int width = config.m_window_width;
int height = config.m_window_height;
// init renderer
ComputeEngine renderer(width, height, config.m_window_name, config.m_start_focused, true);
Shader pixel_compute_shader(config.m_pixel_shader_path);
if (!pixel_compute_shader.Compiled()) {
LOG_ERROR("shader compilation fail");
return -1;
}
Program pixel_compute_program(pixel_compute_shader);
// init data for shader
ShaderData shader_data = {};
shader_data._screen_size = { width, height };
shader_data._iterations = config.m_iterations;
shader_data._samples = config.m_samples_per_frame;
shader_data._fov = config.m_fov;
// init textures
Texture tex_output("img_output", width, height);
// bind textures
pixel_compute_program.BindTextureImage(tex_output, 0);
config.BindTextures(pixel_compute_program);
// init buffers
UBO data_buffer(2);
UBO objects_buffer(3);
SSBO index_buffer(4);
SSBO vert_buffer(5);
SSBO texture_vert_buffer(6);
// fill buffers with data
data_buffer.Set(&shader_data);
objects_buffer.Set(config.GetObjects());
index_buffer.Set(config.GetIndexBuffer());
vert_buffer.Set(config.GetVertexBuffer());
texture_vert_buffer.Set(config.GetTextureBuffer());
// init camera
CameraData camera;
camera.position = config.m_camera_position;
camera.rotation = config.m_camera_rotation;
camera.sensitivity = config.m_camera_sensitivity;
camera.m_width = width;
camera.m_height = height;
camera.CopyData(shader_data);
printf("faces: %d\nvertices: %d\nobjects: %d\n", config.GetFaceCount(), config.GetVertexCount(), config.GetObjectCount());
while (!renderer.ShouldClose()) {
// update input
camera.SetChanged(false);
UpdateInput(renderer, camera, *config.GetObjects(), shader_data, tex_output);
// update data for shader
if (camera.HasChanged()) {
shader_data._sample = 1;
shader_data._pixel_offset = { 0.5f, 0.5f };
}
else {
shader_data._sample++;
shader_data._pixel_offset = { (GetRand() - 0.5f), (GetRand() - 0.5f) };
}
shader_data.UpdateSeed();
shader_data._objectcount = config.GetObjectCount();
camera.UpdateWindowSize(shader_data.GetWidth(), shader_data.GetHeight());
camera.CopyData(shader_data);
// update buffers
data_buffer.Update(&shader_data);
#if UPDATE_OBJECT_BUFFERS
objects_buffer.Update(config.GetObjects());
index_buffer.Update(config.GetIndexBuffer());
vert_buffer.Update(config.GetVertexBuffer());
texture_vert_buffer.Update(config.GetTextureBuffer());
#endif
// dispatch compute shader
pixel_compute_program.DispatchCompute(shader_data.GetWidth(), shader_data.GetHeight());
renderer.UpdateFrametime();
// draw rendered image
renderer.DrawTexture(tex_output);
// glFinish call
renderer.Finish();
//print frametime every 50 frames
if(renderer.GetFramecount()%50 == 0)
printf("f:%.2fms w:%d h:%d samples:%d\n", renderer.GetFrametime(), renderer.GetWidth(), renderer.GetHeight(), shader_data._sample * shader_data._samples);
}
//print average frametime
printf("average frametime: %.3fms", renderer.GetAverageFrametime());
return 0;
}