Browse Source

Added basic environment mapping

Jef Belmans 2 years ago
parent
commit
08b8c60ced

+ 47 - 28
.idea/workspace.xml

@@ -32,11 +32,30 @@
   </component>
   <component name="ChangeListManager">
     <list default="true" id="e2ea9cb6-a6b7-419f-9266-e5263673b6e6" name="Changes" comment="Fixed MaterialUBO memory alignment. All variables are now correctly aligned and read in the shader.">
+      <change afterPath="$PROJECT_DIR$/assets/textures/cubemap/negx.jpg" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/assets/textures/cubemap/negy.jpg" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/assets/textures/cubemap/negz.jpg" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/assets/textures/cubemap/posx.jpg" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/assets/textures/cubemap/posy.jpg" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/assets/textures/cubemap/posz.jpg" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/coral_renderer/coral_cubemap.cpp" afterDir="false" />
+      <change afterPath="$PROJECT_DIR$/coral_renderer/coral_cubemap.h" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/coral_renderer/coral_frame_info.h" beforeDir="false" afterPath="$PROJECT_DIR$/coral_renderer/coral_frame_info.h" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/build/debug/CMakeFiles/clion-Debug-log.txt" beforeDir="false" afterPath="$PROJECT_DIR$/build/debug/CMakeFiles/clion-Debug-log.txt" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/build/debug/build.ninja" beforeDir="false" afterPath="$PROJECT_DIR$/build/debug/build.ninja" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/build/release/.ninja_log" beforeDir="false" afterPath="$PROJECT_DIR$/build/release/.ninja_log" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/build/release/CMakeFiles/clion-Release-log.txt" beforeDir="false" afterPath="$PROJECT_DIR$/build/release/CMakeFiles/clion-Release-log.txt" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/build/release/assets/shaders/compiled/simple_shader.vert.spv" beforeDir="false" afterPath="$PROJECT_DIR$/build/release/assets/shaders/compiled/simple_shader.vert.spv" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/build/release/build.ninja" beforeDir="false" afterPath="$PROJECT_DIR$/build/release/build.ninja" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/coral_renderer/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/coral_renderer/CMakeLists.txt" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/coral_renderer/coral_mesh.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/coral_renderer/coral_mesh.cpp" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/coral_renderer/coral_mesh.h" beforeDir="false" afterPath="$PROJECT_DIR$/coral_renderer/coral_mesh.h" afterDir="false" />
       <change beforePath="$PROJECT_DIR$/coral_renderer/first_app.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/coral_renderer/first_app.cpp" afterDir="false" />
-      <change beforePath="$PROJECT_DIR$/coral_renderer/point_light_system.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/coral_renderer/point_light_system.cpp" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/coral_renderer/first_app.h" beforeDir="false" afterPath="$PROJECT_DIR$/coral_renderer/first_app.h" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/shaders/compiled/simple_shader.frag.spv" beforeDir="false" afterPath="$PROJECT_DIR$/shaders/compiled/simple_shader.frag.spv" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/shaders/compiled/simple_shader.vert.spv" beforeDir="false" afterPath="$PROJECT_DIR$/shaders/compiled/simple_shader.vert.spv" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/shaders/simple_shader.frag" beforeDir="false" afterPath="$PROJECT_DIR$/shaders/simple_shader.frag" afterDir="false" />
+      <change beforePath="$PROJECT_DIR$/shaders/simple_shader.vert" beforeDir="false" afterPath="$PROJECT_DIR$/shaders/simple_shader.vert" afterDir="false" />
     </list>
     <option name="SHOW_DIALOG" value="false" />
     <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -46,7 +65,7 @@
   <component name="ClangdSettings">
     <option name="formatViaClangd" value="false" />
   </component>
-  <component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Debug" />
+  <component name="ExecutionTargetManager" SELECTED_TARGET="CMakeBuildProfile:Release" />
   <component name="Git.Settings">
     <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
   </component>
@@ -90,32 +109,32 @@
     <option name="hideEmptyMiddlePackages" value="true" />
     <option name="showLibraryContents" value="true" />
   </component>
-  <component name="PropertiesComponent">{
-  &quot;keyToString&quot;: {
-    &quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
-    &quot;ASKED_MARK_IGNORED_FILES_AS_EXCLUDED&quot;: &quot;true&quot;,
-    &quot;ASKED_SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
-    &quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
-    &quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
-    &quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
-    &quot;SHARE_PROJECT_CONFIGURATION_FILES&quot;: &quot;true&quot;,
-    &quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
-    &quot;cf.advertisement.text.has.clang-format&quot;: &quot;true&quot;,
-    &quot;cf.advertisement.text.overridden&quot;: &quot;true&quot;,
-    &quot;cf.first.check.clang-format&quot;: &quot;false&quot;,
-    &quot;cidr.known.project.marker&quot;: &quot;true&quot;,
-    &quot;git-widget-placeholder&quot;: &quot;point-lights&quot;,
-    &quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
-    &quot;last_opened_file_path&quot;: &quot;E:/Game Development/Visual Studio Solutions/Coral3D/coral_renderer&quot;,
-    &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
-    &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
-    &quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
-    &quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
-    &quot;settings.editor.selected.configurable&quot;: &quot;CPPToolchains&quot;,
-    &quot;structure.view.defaults.are.configured&quot;: &quot;true&quot;,
-    &quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
+  <component name="PropertiesComponent"><![CDATA[{
+  "keyToString": {
+    "ASKED_ADD_EXTERNAL_FILES": "true",
+    "ASKED_MARK_IGNORED_FILES_AS_EXCLUDED": "true",
+    "ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
+    "RunOnceActivity.OpenProjectViewOnStart": "true",
+    "RunOnceActivity.ShowReadmeOnStart": "true",
+    "RunOnceActivity.cidr.known.project.marker": "true",
+    "SHARE_PROJECT_CONFIGURATION_FILES": "true",
+    "WebServerToolWindowFactoryState": "false",
+    "cf.advertisement.text.has.clang-format": "true",
+    "cf.advertisement.text.overridden": "true",
+    "cf.first.check.clang-format": "false",
+    "cidr.known.project.marker": "true",
+    "git-widget-placeholder": "cubemap",
+    "ignore.virus.scanning.warn.message": "true",
+    "last_opened_file_path": "E:/Game Development/Visual Studio Solutions/Coral3D/coral_renderer",
+    "node.js.detected.package.eslint": "true",
+    "node.js.detected.package.tslint": "true",
+    "node.js.selected.package.eslint": "(autodetect)",
+    "node.js.selected.package.tslint": "(autodetect)",
+    "settings.editor.selected.configurable": "CPPToolchains",
+    "structure.view.defaults.are.configured": "true",
+    "vue.rearranger.settings.migration": "true"
   }
-}</component>
+}]]></component>
   <component name="RecentsManager">
     <key name="CopyFile.RECENT_KEYS">
       <recent name="E:\Game Development\Visual Studio Solutions\Coral3D\coral_renderer" />

BIN
assets/textures/cubemap/negx.jpg


BIN
assets/textures/cubemap/negy.jpg


BIN
assets/textures/cubemap/negz.jpg


BIN
assets/textures/cubemap/posx.jpg


BIN
assets/textures/cubemap/posy.jpg


BIN
assets/textures/cubemap/posz.jpg


+ 1 - 27
build/debug/CMakeFiles/clion-Debug-log.txt

@@ -1,17 +1,4 @@
 "C:\Program Files\JetBrains\CLion 2023.2\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.2/bin/ninja/win/x64/ninja.exe" -G Ninja -S "E:\Game Development\Visual Studio Solutions\Coral3D" -B "E:\Game Development\Visual Studio Solutions\Coral3D\build\debug"
--- The C compiler identification is GNU 13.1.0
--- The CXX compiler identification is GNU 13.1.0
--- Detecting C compiler ABI info
--- Detecting C compiler ABI info - done
--- Check for working C compiler: C:/Program Files/JetBrains/CLion 2023.2/bin/mingw/bin/gcc.exe - skipped
--- Detecting C compile features
--- Detecting C compile features - done
--- Detecting CXX compiler ABI info
--- Detecting CXX compiler ABI info - done
--- Check for working CXX compiler: C:/Program Files/JetBrains/CLion 2023.2/bin/mingw/bin/g++.exe - skipped
--- Detecting CXX compile features
--- Detecting CXX compile features - done
--- Found Vulkan: C:/VulkanSDK/1.3.250.0/Lib/vulkan-1.lib (found version "1.3.250") found components: glslc glslangValidator 
 -- BUILDING SHADER
 -- E:/Game Development/Visual Studio Solutions/Coral3D/shaders/point_light.frag
 -- BUILDING SHADER
@@ -20,20 +7,7 @@
 -- E:/Game Development/Visual Studio Solutions/Coral3D/shaders/simple_shader.frag
 -- BUILDING SHADER
 -- E:/Game Development/Visual Studio Solutions/Coral3D/shaders/simple_shader.vert
--- Performing Test CMAKE_HAVE_LIBC_PTHREAD
--- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
--- Found Threads: TRUE  
--- Looking for dinput.h
--- Looking for dinput.h - found
--- Looking for xinput.h
--- Looking for xinput.h - found
--- Performing Test _GLFW_HAS_DEP
--- Performing Test _GLFW_HAS_DEP - Success
--- Performing Test _GLFW_HAS_ASLR
--- Performing Test _GLFW_HAS_ASLR - Success
--- Performing Test _GLFW_HAS_64ASLR
--- Performing Test _GLFW_HAS_64ASLR - Success
 -- Using Win32 for window creation
--- Configuring done (2.6s)
+-- Configuring done (0.1s)
 -- Generating done (0.0s)
 -- Build files have been written to: E:/Game Development/Visual Studio Solutions/Coral3D/build/debug

File diff suppressed because it is too large
+ 14 - 79
build/debug/build.ninja


BIN
build/release/.ninja_deps


+ 69 - 1
build/release/.ninja_log

@@ -39,10 +39,78 @@
 4	1988	7183296086591942	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
 4739	4785	7183022367622250	third_party/libvkbootstrap.a	c71ed427a7b8907
 174	3650	7183263104275051	coral_renderer/CMakeFiles/coral_renderer.dir/coral_buffer.cpp.obj	8b51063e5bc12069
-3	552	7183818343868502	build.ninja	fa936e3b47cbade3
+3	552	7183820684973347	build.ninja	fa936e3b47cbade3
 0	1430	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
 22	4062	7183022360380247	third_party/CMakeFiles/tinyobjloader.dir/tinyobjloader/tiny_obj_loader.cc.obj	fd1983a21fbb7956
 9	93	7183272486981321	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.vert.spv	3c7e702a8a128f67
 4062	4108	7183022360855718	third_party/libtinyobjloader.a	99fa9adb75ddfe5c
 15	129	7183263068966629	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.frag.spv	f376e2cf516c4f9c
 0	1430	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	100	7183858143702629	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/point_light.frag.spv	6d3a602ccc13fa0e
+11	108	7183858143785593	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.frag.spv	f376e2cf516c4f9c
+8	108	7183858143785593	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/point_light.vert.spv	87717d1f7db06f5d
+14	108	7183858143795595	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.vert.spv	3c7e702a8a128f67
+121	1050	7183858153237435	coral_renderer/CMakeFiles/coral_renderer.dir/vk_initializers.cpp.obj	c70ea6a045b04a90
+153	1792	7183858160639569	coral_renderer/CMakeFiles/coral_renderer.dir/coral_cubemap.cpp.obj	66bbab00cb591c37
+149	1824	7183858160951519	coral_renderer/CMakeFiles/coral_renderer.dir/coral_texture.cpp.obj	c0771ce2d8c57d44
+127	1835	7183858161067273	coral_renderer/CMakeFiles/coral_renderer.dir/coral_renderer.cpp.obj	cb2e4f201849c024
+130	2044	7183858163181753	coral_renderer/CMakeFiles/coral_renderer.dir/coral_gameobject.cpp.obj	3e1fca21fb1049ab
+145	2060	7183858163342437	coral_renderer/CMakeFiles/coral_renderer.dir/coral_descriptors.cpp.obj	976f54a312d4fda
+115	2088	7183858163621939	coral_renderer/CMakeFiles/coral_renderer.dir/main.cpp.obj	2b1afc763cc7fd7d
+138	2088	7183858163621939	coral_renderer/CMakeFiles/coral_renderer.dir/render_system.cpp.obj	3426bcb39c57484b
+108	2194	7183858164675610	coral_renderer/CMakeFiles/coral_renderer.dir/coral_pipeline.cpp.obj	c97492ac4e9c2f4f
+157	2230	7183858165042179	coral_renderer/CMakeFiles/coral_renderer.dir/point_light_system.cpp.obj	9032090700129b1a
+117	2234	7183858165082435	coral_renderer/CMakeFiles/coral_renderer.dir/coral_swapchain.cpp.obj	9f4b5b8fbef6fb7c
+124	2636	7183858169102355	coral_renderer/CMakeFiles/coral_renderer.dir/coral_device.cpp.obj	f22c3ebb3984eea4
+112	3016	7183858172905343	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+141	4147	7183858184210293	coral_renderer/CMakeFiles/coral_renderer.dir/coral_buffer.cpp.obj	8b51063e5bc12069
+134	16881	7183858311519092	coral_renderer/CMakeFiles/coral_renderer.dir/coral_mesh.cpp.obj	ec9b9c950c06d57a
+16881	17026	7183858312969827	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1466	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1466	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	1946	7183858769780104	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+1946	2091	7183858771186944	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1525	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1525	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	1946	7183858972209442	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+1946	2093	7183858973639093	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1503	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1503	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+5	90	7183859539012929	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.frag.spv	f376e2cf516c4f9c
+0	1550	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1550	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	1932	7183859871318693	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+1932	2073	7183859872684199	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1687	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1687	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+5	1931	7183860359787520	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+1931	2073	7183860361170205	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1420	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1420	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	88	7183865888080520	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.frag.spv	f376e2cf516c4f9c
+88	1542	7183865902638356	coral_renderer/CMakeFiles/coral_renderer.dir/main.cpp.obj	2b1afc763cc7fd7d
+91	2370	7183865910916072	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+5	1081	7183865988806190	coral_renderer/CMakeFiles/coral_renderer.dir/coral_cubemap.cpp.obj	66bbab00cb591c37
+1081	1225	7183865990215893	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1509	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1509	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	92	7183867946711710	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.vert.spv	3c7e702a8a128f67
+8	94	7183867946731731	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.frag.spv	f376e2cf516c4f9c
+103	1585	7183867961658051	coral_renderer/CMakeFiles/coral_renderer.dir/coral_gameobject.cpp.obj	3e1fca21fb1049ab
+109	1665	7183867962466742	coral_renderer/CMakeFiles/coral_renderer.dir/render_system.cpp.obj	3426bcb39c57484b
+98	1674	7183867962552077	coral_renderer/CMakeFiles/coral_renderer.dir/main.cpp.obj	2b1afc763cc7fd7d
+112	1734	7183867963157293	coral_renderer/CMakeFiles/coral_renderer.dir/point_light_system.cpp.obj	9032090700129b1a
+94	1773	7183867963538306	coral_renderer/CMakeFiles/coral_renderer.dir/coral_pipeline.cpp.obj	c97492ac4e9c2f4f
+100	2555	7183867971365827	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+106	16564	7183868111426663	coral_renderer/CMakeFiles/coral_renderer.dir/coral_mesh.cpp.obj	ec9b9c950c06d57a
+16564	16706	7183868112841373	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1487	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1487	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	90	7183868570642168	E:/Game Development/Visual Studio Solutions/Coral3D/shaders/compiled/simple_shader.frag.spv	f376e2cf516c4f9c
+0	1477	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1477	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+4	2312	7183869346597571	coral_renderer/CMakeFiles/coral_renderer.dir/first_app.cpp.obj	db0c627bbb247e94
+8	16393	7183869487376989	coral_renderer/CMakeFiles/coral_renderer.dir/coral_mesh.cpp.obj	ec9b9c950c06d57a
+16393	16535	7183869488794476	coral_renderer/coral_renderer.exe	1a0c68274d1f4cc0
+0	1500	0	coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866
+0	1500	0	E:/Game Development/Visual Studio Solutions/Coral3D/build/release/coral_renderer/CMakeFiles/copy_assets	66424d61a55ca866

+ 1 - 27
build/release/CMakeFiles/clion-Release-log.txt

@@ -1,17 +1,4 @@
 "C:\Program Files\JetBrains\CLion 2023.2\bin\cmake\win\x64\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Release "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2023.2/bin/ninja/win/x64/ninja.exe" -G Ninja -S "E:\Game Development\Visual Studio Solutions\Coral3D" -B "E:\Game Development\Visual Studio Solutions\Coral3D\build\release"
--- The C compiler identification is GNU 13.1.0
--- The CXX compiler identification is GNU 13.1.0
--- Detecting C compiler ABI info
--- Detecting C compiler ABI info - done
--- Check for working C compiler: C:/Program Files/JetBrains/CLion 2023.2/bin/mingw/bin/gcc.exe - skipped
--- Detecting C compile features
--- Detecting C compile features - done
--- Detecting CXX compiler ABI info
--- Detecting CXX compiler ABI info - done
--- Check for working CXX compiler: C:/Program Files/JetBrains/CLion 2023.2/bin/mingw/bin/g++.exe - skipped
--- Detecting CXX compile features
--- Detecting CXX compile features - done
--- Found Vulkan: C:/VulkanSDK/1.3.250.0/Lib/vulkan-1.lib (found version "1.3.250") found components: glslc glslangValidator 
 -- BUILDING SHADER
 -- E:/Game Development/Visual Studio Solutions/Coral3D/shaders/point_light.frag
 -- BUILDING SHADER
@@ -20,20 +7,7 @@
 -- E:/Game Development/Visual Studio Solutions/Coral3D/shaders/simple_shader.frag
 -- BUILDING SHADER
 -- E:/Game Development/Visual Studio Solutions/Coral3D/shaders/simple_shader.vert
--- Performing Test CMAKE_HAVE_LIBC_PTHREAD
--- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
--- Found Threads: TRUE  
--- Looking for dinput.h
--- Looking for dinput.h - found
--- Looking for xinput.h
--- Looking for xinput.h - found
--- Performing Test _GLFW_HAS_DEP
--- Performing Test _GLFW_HAS_DEP - Success
--- Performing Test _GLFW_HAS_ASLR
--- Performing Test _GLFW_HAS_ASLR - Success
--- Performing Test _GLFW_HAS_64ASLR
--- Performing Test _GLFW_HAS_64ASLR - Success
 -- Using Win32 for window creation
--- Configuring done (2.6s)
+-- Configuring done (0.1s)
 -- Generating done (0.0s)
 -- Build files have been written to: E:/Game Development/Visual Studio Solutions/Coral3D/build/release

+ 2 - 2
build/release/Testing/Temporary/LastTest.log

@@ -1,3 +1,3 @@
-Start testing: Oct 06 23:11 Romance Daylight Time
+Start testing: Oct 07 15:02 Romance Daylight Time
 ----------------------------------------------------------
-End testing: Oct 06 23:11 Romance Daylight Time
+End testing: Oct 07 15:02 Romance Daylight Time

BIN
build/release/assets/shaders/compiled/simple_shader.vert.spv


File diff suppressed because it is too large
+ 14 - 79
build/release/build.ninja


+ 35 - 33
coral_renderer/CMakeLists.txt

@@ -1,39 +1,41 @@
 add_executable(coral_renderer
-    "main.cpp"
-    "coral_window.h"
-    "coral_window.cpp"
-    "first_app.h"
-    "first_app.cpp"
-    "coral_pipeline.h"
-    "coral_pipeline.cpp"
-    "coral_device.h"
-    "coral_device.cpp"
-    "vk_initializers.h"
-    "vk_initializers.cpp"
-    "vk_types.h"
-    "coral_swapchain.h"
-    "coral_swapchain.cpp"
-    "coral_mesh.h"
-    "coral_mesh.cpp"
-    "coral_gameobject.h"
+        "main.cpp"
+        "coral_window.h"
+        "coral_window.cpp"
+        "first_app.h"
+        "first_app.cpp"
+        "coral_pipeline.h"
+        "coral_pipeline.cpp"
+        "coral_device.h"
+        "coral_device.cpp"
+        "vk_initializers.h"
+        "vk_initializers.cpp"
+        "vk_types.h"
+        "coral_swapchain.h"
+        "coral_swapchain.cpp"
+        "coral_mesh.h"
+        "coral_mesh.cpp"
+        "coral_gameobject.h"
+        "coral_gameobject.cpp"
         "coral_renderer.h"
-    "coral_renderer.cpp"
-    "render_system.h"
-    "render_system.cpp"
-    "coral_camera.h"
-    "coral_camera.cpp"
-    "coral_utils.h"
-    "coral_utils.cpp"
-    "coral_texture.h"
-    "coral_texture.cpp"
-    "coral_buffer.h"
-    "coral_buffer.cpp"
-    "coral_frame_info.h"
+        "coral_renderer.cpp"
+        "render_system.h"
+        "render_system.cpp"
+        "coral_camera.h"
+        "coral_camera.cpp"
+        "coral_utils.h"
+        "coral_utils.cpp"
+        "coral_texture.h"
+        "coral_texture.cpp"
+        "coral_buffer.h"
+        "coral_buffer.cpp"
+        "coral_frame_info.h"
         "coral_descriptors.h"
-    "coral_descriptors.cpp"
-        point_light_system.cpp
-        point_light_system.h
-        coral_gameobject.cpp
+        "coral_descriptors.cpp"
+        "point_light_system.cpp"
+        "point_light_system.h"
+        "coral_cubemap.cpp"
+        "coral_cubemap.h"
 )
 
 if(MSVC)

+ 141 - 0
coral_renderer/coral_cubemap.cpp

@@ -0,0 +1,141 @@
+#include "coral_cubemap.h"
+#include "coral_buffer.h"
+#include "vk_initializers.h"
+
+#include "stb_image.h"
+
+// STD
+#include <iostream>
+
+namespace coral_3d
+{
+    coral_cubemap::coral_cubemap(coral_device &device, bool nearest_filter)
+    : device_(device), file_names_({""}), width_(0), height_(0)
+    , bytes_per_pixel_(0), mip_levels_(1), nearest_filter_(nearest_filter), sRGB_(false)
+    {}
+
+    coral_cubemap::~coral_cubemap()
+    {
+        vkDestroyImageView(device_.device(), image_view_, nullptr);
+        vkDestroySampler(device_.device(), sampler_, nullptr);
+        vmaDestroyImage(device_.allocator(), cubemap_image_.image, cubemap_image_.allocation);
+    }
+
+    bool coral_cubemap::init(const std::vector<std::string> &file_names, bool sRGB, bool flip)
+    {
+        stbi_set_flip_vertically_on_load(flip);
+        file_names_ = file_names;
+        sRGB_ = sRGB;
+        return create();
+    }
+
+    bool coral_cubemap::create()
+    {
+        stbi_uc* pixels;
+
+        // Load first face to get size
+        pixels = stbi_load(file_names_[0].c_str(), &width_, &height_, &bytes_per_pixel_, STBI_rgb_alpha);
+        if (!pixels)
+        {
+            std::cout << "Failed to load texture file " << file_names_[0] << std::endl;
+            return false;
+        }
+
+        VkDeviceSize layer_size = width_ * height_ * 4;
+        VkDeviceSize image_size = layer_size * NUMBER_OF_CUBEMAP_IMAGES;
+
+        coral_buffer staging_buffer
+        {
+            device_,image_size,1,
+            VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
+            VMA_MEMORY_USAGE_AUTO,
+            VMA_ALLOCATION_CREATE_HOST_ACCESS_SEQUENTIAL_WRITE_BIT
+        };
+        staging_buffer.map();
+        staging_buffer.write_to_buffer(pixels, layer_size);
+
+        stbi_image_free(pixels);
+
+        // Load other 5 faces
+        for (int i = 1; i < NUMBER_OF_CUBEMAP_IMAGES; ++i)
+        {
+            pixels = stbi_load(file_names_[i].c_str(), &width_, &height_, &bytes_per_pixel_, STBI_rgb_alpha);
+            if (!pixels)
+            {
+                std::cout << "Failed to load texture file " << file_names_[i] << std::endl;
+                return false;
+            }
+            staging_buffer.write_to_buffer(pixels, layer_size, layer_size * i);
+            stbi_image_free(pixels);
+        }
+
+        // CREATE IMAGE
+        image_format_ = sRGB_ ? VK_FORMAT_R8G8B8A8_SRGB : VK_FORMAT_R8G8B8A8_UNORM;
+        create_image(image_format_);
+
+        // Transition and copy image to buffer
+        device_.transition_image_layout(cubemap_image_.image, image_format_, VK_IMAGE_LAYOUT_UNDEFINED,
+                                        VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, NUMBER_OF_CUBEMAP_IMAGES, mip_levels_);
+        device_.copy_buffer_to_image(staging_buffer.get_buffer(), cubemap_image_, width_, height_,
+                                     NUMBER_OF_CUBEMAP_IMAGES);
+        device_.transition_image_layout(cubemap_image_.image, image_format_, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL,
+                                        VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, NUMBER_OF_CUBEMAP_IMAGES, mip_levels_);
+        image_layout_ = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
+
+        create_image_sampler();
+        create_image_view();
+
+        descriptor_image_info_.sampler = sampler_;
+        descriptor_image_info_.imageLayout = image_layout_;
+        descriptor_image_info_.imageView = image_view_;
+
+        return true;
+    }
+
+    bool coral_cubemap::create_image(VkFormat format)
+    {
+        VkExtent3D img_extent;
+        img_extent.width = static_cast<uint32_t>(width_);
+        img_extent.height = static_cast<uint32_t>(height_);
+        img_extent.depth = 1;
+
+        VkImageCreateInfo create_info{vkinit::image_ci(format, VK_IMAGE_USAGE_TRANSFER_DST_BIT |
+        VK_IMAGE_USAGE_SAMPLED_BIT, img_extent)};
+        create_info.mipLevels = mip_levels_;
+        create_info.arrayLayers = NUMBER_OF_CUBEMAP_IMAGES;
+        create_info.flags = VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT;
+
+        VmaAllocationCreateInfo alloc_create_info{};
+        alloc_create_info.usage = VMA_MEMORY_USAGE_GPU_ONLY;
+
+        vmaCreateImage(device_.allocator(), &create_info, &alloc_create_info,
+                       &cubemap_image_.image, &cubemap_image_.allocation, nullptr);
+
+        return true;
+    }
+
+    bool coral_cubemap::create_image_view()
+    {
+        VkImageViewCreateInfo image_info{ vkinit::image_view_ci(image_format_, cubemap_image_.image, VK_IMAGE_ASPECT_COLOR_BIT) };
+        image_info.subresourceRange.levelCount = mip_levels_;
+        image_info.subresourceRange.layerCount = NUMBER_OF_CUBEMAP_IMAGES;
+        image_info.viewType = VK_IMAGE_VIEW_TYPE_CUBE;
+
+        if (vkCreateImageView(device_.device(), &image_info, nullptr, &image_view_) != VK_SUCCESS)
+            throw std::runtime_error("ERROR! coral_cubemap::create_inage_view() >> Failed to create image view!");
+
+        return true;
+    }
+
+    bool coral_cubemap::create_image_sampler()
+    {
+        VkFilter filter = nearest_filter_ ? VK_FILTER_NEAREST : VK_FILTER_LINEAR;
+        VkSamplerCreateInfo sampler_info{ vkinit::sampler_ci(filter, device_.properties.limits.maxSamplerAnisotropy) };
+        sampler_info.maxLod = static_cast<float>(mip_levels_);
+
+        if (vkCreateSampler(device_.device(), &sampler_info, nullptr, &sampler_) != VK_SUCCESS)
+            throw std::runtime_error("ERROR!  coral_cubemap::create_image_sampler() >> Failed to create texture sampler!");
+
+        return true;
+    }
+} // coral_3d

+ 52 - 0
coral_renderer/coral_cubemap.h

@@ -0,0 +1,52 @@
+#ifndef CORAL_CUBEMAP_H
+#define CORAL_CUBEMAP_H
+
+// STD
+#include <vector>
+#include <string>
+
+#include "coral_device.h"
+
+namespace coral_3d
+{
+    class coral_cubemap final
+    {
+    public:
+        explicit coral_cubemap(coral_device &device, bool nearest_filter);
+        ~coral_cubemap();
+
+        bool init(const std::vector<std::string>& file_names, bool sRGB, bool flip = false);
+
+        // GETTERS
+        int get_width() const {return width_;};
+        int get_height() const { return height_; }
+        const VkDescriptorImageInfo get_descriptor_image_info() const { return descriptor_image_info_; }
+
+    private:
+        bool create();
+        bool create_image(VkFormat format);
+        bool create_image_view();
+        bool create_image_sampler();
+
+        static constexpr int NUMBER_OF_CUBEMAP_IMAGES = 6;
+
+        coral_device& device_;
+
+        std::vector<std::string> file_names_;
+        int width_, height_, bytes_per_pixel_;
+        int mip_levels_;
+
+        bool nearest_filter_, sRGB_;
+
+        VkFormat image_format_;
+        AllocatedImage cubemap_image_;
+        VkImageLayout image_layout_;
+        VkImageView image_view_;
+        VkSampler sampler_;
+
+        VkDescriptorImageInfo descriptor_image_info_;
+
+    };
+} // coral_3d
+
+#endif //CORAL_CUBEMAP_H

+ 2 - 1
coral_renderer/coral_mesh.cpp

@@ -416,7 +416,8 @@ std::unique_ptr<coral_mesh> coral_mesh::create_mesh_from_file(coral_device& devi
     return std::make_unique<coral_mesh>(device, builder, parent);
 }
 
-void coral_mesh::load_materials(coral_descriptor_set_layout& material_set_layout, coral_descriptor_pool& material_set_pool)
+void coral_mesh::load_materials(coral_descriptor_set_layout& material_set_layout,
+                                coral_descriptor_pool& material_set_pool, VkDescriptorImageInfo)
 {
     for(auto& material : materials_)
     {

+ 2 - 1
coral_renderer/coral_mesh.h

@@ -123,7 +123,8 @@ namespace coral_3d
 
 		static std::unique_ptr<coral_mesh> create_mesh_from_file(coral_device& device, const std::string& file_path, coral_gameobject* parent);
 
-        void load_materials(coral_descriptor_set_layout& material_set_layout, coral_descriptor_pool& material_set_pool);
+        void load_materials(coral_descriptor_set_layout& material_set_layout,
+                            coral_descriptor_pool& material_set_pool, VkDescriptorImageInfo cubemap_descriptor);
         void create_pipelines(
                 const std::string &vert_file_path,
                 const std::string &frag_file_path,

+ 28 - 12
coral_renderer/first_app.cpp

@@ -14,12 +14,24 @@
 using namespace coral_3d;
 
 first_app::first_app()
+ : cubemap_{device_, true}
 {
-   descriptor_pool_ = coral_descriptor_pool::Builder(device_)
-        .set_max_sets(MAX_MATERIAL_SETS)
-        .add_pool_size(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, coral_swapchain::MAX_FRAMES_IN_FLIGHT)
-        .add_pool_size(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_MATERIAL_SETS)
-        .build();
+    std::vector<std::string> file_names
+    {
+      "assets/textures/cubemap/posx.jpg",
+      "assets/textures/cubemap/negx.jpg",
+      "assets/textures/cubemap/negy.jpg",
+      "assets/textures/cubemap/posy.jpg",
+      "assets/textures/cubemap/posz.jpg",
+      "assets/textures/cubemap/negz.jpg"
+    };
+    cubemap_.init(file_names,true, true);
+
+    descriptor_pool_ = coral_descriptor_pool::Builder(device_)
+            .set_max_sets(MAX_MATERIAL_SETS)
+            .add_pool_size(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, coral_swapchain::MAX_FRAMES_IN_FLIGHT)
+            .add_pool_size(VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, MAX_MATERIAL_SETS)
+            .build();
 }
 
 void first_app::run()
@@ -129,10 +141,14 @@ void first_app::run()
 
 void first_app::load_gameobjects(coral_descriptor_set_layout& material_set_layout, VkPipelineLayout pipeline_layout)
 {
+    // MESHES
     auto sponza_scene{std::make_shared<coral_gameobject>(coral_gameobject::create_gameobject()) };
 
-    std::shared_ptr<coral_mesh> sponza_mesh{ coral_mesh::create_mesh_from_file(device_, "assets/meshes/Sponza/Sponza.gltf", sponza_scene.get()) };
-    sponza_mesh->load_materials(material_set_layout, *descriptor_pool_);
+    std::shared_ptr<coral_mesh> sponza_mesh
+    {
+        coral_mesh::create_mesh_from_file(device_,"assets/meshes/Sponza/Sponza.gltf", sponza_scene.get())
+    };
+    sponza_mesh->load_materials(material_set_layout, *descriptor_pool_, cubemap_.get_descriptor_image_info());
     sponza_mesh->create_pipelines(
             "assets/shaders/simple_shader.vert.spv",
             "assets/shaders/simple_shader.frag.spv",
@@ -144,22 +160,22 @@ void first_app::load_gameobjects(coral_descriptor_set_layout& material_set_layou
 
     // LIGHTS
     auto point_light = std::make_shared<coral_gameobject>(coral_gameobject::create_point_light(1.f, 0.1f, {1.f, 0.2f, 0.2f}));
-    point_light->transform_.translation = glm::vec3(-4.f, 1.f, 0.f);
+    point_light->transform_.translation = glm::vec3(-4.f, 0.f, 0.f);
     gameobjects_.emplace(point_light->get_id(), point_light);
 
     point_light = std::make_shared<coral_gameobject>(coral_gameobject::create_point_light(1.f, 0.1f, {0.2f, 1.f, 0.2f}));
-    point_light->transform_.translation = glm::vec3(-2.f, 1.f, 0.f);
+    point_light->transform_.translation = glm::vec3(-2.f, 0.f, 0.f);
     gameobjects_.emplace(point_light->get_id(), point_light);
 
     point_light = std::make_shared<coral_gameobject>(coral_gameobject::create_point_light(1.f));
-    point_light->transform_.translation = glm::vec3(0.f, 1.f, 0.f);
+    point_light->transform_.translation = glm::vec3(0.f, 0.f, 0.f);
     gameobjects_.emplace(point_light->get_id(), point_light);
 
     point_light = std::make_shared<coral_gameobject>(coral_gameobject::create_point_light(1.f, 0.1f, {0.2f, 0.2f, 1.f}));
-    point_light->transform_.translation = glm::vec3(2.f, 1.f, 0.f);
+    point_light->transform_.translation = glm::vec3(2.f, 0.f, 0.f);
     gameobjects_.emplace(point_light->get_id(), point_light);
 
     point_light = std::make_shared<coral_gameobject>(coral_gameobject::create_point_light(1.f, 0.1f, {1.f, 0.2f, 1.f}));
-    point_light->transform_.translation = glm::vec3(4.f, 1.f, 0.f);
+    point_light->transform_.translation = glm::vec3(4.f, 0.f, 0.f);
     gameobjects_.emplace(point_light->get_id(), point_light);
 }

+ 3 - 0
coral_renderer/first_app.h

@@ -6,6 +6,7 @@
 #include "coral_renderer.h"
 #include "coral_descriptors.h"
 #include "coral_texture.h"
+#include "coral_cubemap.h"
 
 // STD
 #include <memory>
@@ -33,6 +34,8 @@ namespace coral_3d
 		coral_device device_{ window_ };
 		coral_renderer renderer_{ window_, device_ };
 
+        coral_cubemap cubemap_;
+
 		std::unique_ptr<coral_descriptor_pool> descriptor_pool_{};
 		coral_gameobject::Map gameobjects_;
 	};

BIN
shaders/compiled/simple_shader.frag.spv


BIN
shaders/compiled/simple_shader.vert.spv


+ 9 - 7
shaders/simple_shader.frag

@@ -3,6 +3,7 @@
 // SAMPLERS
 layout (set = 1, binding = 0) uniform sampler2D samplerColorMap;
 layout (set = 1, binding = 1) uniform sampler2D samplerNormalMap;
+layout (set = 1, binding = 2) uniform samplerCube samplerCubeMap;
 
 // CONSTANTS
 layout (constant_id = 0) const bool ALPHA_MASK = false;
@@ -12,7 +13,6 @@ layout (constant_id = 1) const float ALPHA_MASK_CUTOFF = 0.0f;
 layout (location = 0) in struct FS_IN
 {
 	vec3 fragPos;
-	vec3 normal;
 	vec2 texcoord;
 	mat3 TBN;
 } fs_in;
@@ -77,16 +77,17 @@ void main()
 		if (color.a < ALPHA_MASK_CUTOFF) discard;
 
 	// SAMPLE NORMAL
-	vec3 normal = texture(samplerNormalMap, fs_in.texcoord).rgb;
-	normal = normalize(fs_in.TBN * (normal * 2.f - 1.f));
+	vec3 N = texture(samplerNormalMap, fs_in.texcoord).rgb;
+	N = normalize(fs_in.TBN * (N * 2.f - 1.f));
 
 	// VECTORS
 	vec3 V = normalize(ubo.viewInverse[3].xyz - fs_in.fragPos);
+	vec3 R = reflect(V, N);
 
 	// GLOBAL LIGHT
 	vec3 ambient = ubo.ambientLighting.xyz * ubo.ambientLighting.w;
-	vec3 diffuse = calculate_diffuse(normal, ubo.globalLightDirection.xyz, color.rgb * ubo.globalLightDirection.w);
-	vec3 specular = calculate_specular(normal, V,  ubo.globalLightDirection.xyz, vec3(1,1,1) *  ubo.globalLightDirection.w);
+	vec3 diffuse = calculate_diffuse(N, ubo.globalLightDirection.xyz, color.rgb * ubo.globalLightDirection.w);
+	vec3 specular = calculate_specular(N, V,  ubo.globalLightDirection.xyz, vec3(1,1,1) *  ubo.globalLightDirection.w);
 
 	// POINT LIGHTS
 	for(int i = 0; i < ubo.numLights; i++)
@@ -96,9 +97,10 @@ void main()
 		float attenuation = 1.f / dot(directionToLight, directionToLight);
 		vec3 lightColor = light.color.xyz * color.rgb * light.color.w * attenuation;
 
-		diffuse += calculate_diffuse(normal, directionToLight, lightColor);
-		specular += calculate_specular(normal, V, directionToLight, lightColor);
+		diffuse += calculate_diffuse(N, directionToLight, lightColor);
+		specular += calculate_specular(N, V, directionToLight, lightColor);
 	}
 
+	vec3 environment = texture(samplerCubeMap, R).rgb * 0.2f;
 	outFragColor = vec4(ambient + diffuse + specular, color.a);
 }

+ 1 - 3
shaders/simple_shader.vert

@@ -8,7 +8,6 @@ layout (location = 3) in vec2 inTexcoord;
 layout (location = 0) out struct VS_OUT
 {
 	vec3 fragPos;
-	vec3 normal;
 	vec2 texcoord;
 	mat3 TBN;
 } vs_out;
@@ -45,7 +44,7 @@ void main()
 	vec4 worldPos = primitive.model * vec4(inPosition, 1.0f);
 	gl_Position = ubo.viewProjection * worldPos;
 
-	vs_out.normal = inNormal;
+	vs_out.fragPos  = worldPos.xyz;
 	vs_out.texcoord = inTexcoord;
 
 	// TBN
@@ -55,5 +54,4 @@ void main()
 	vec3 B = cross(N, T) * inTangent.w;
 
 	vs_out.TBN = mat3(T, B, N);
-	vs_out.fragPos  = worldPos.xyz;
 }

Some files were not shown because too many files changed in this diff