483 Commits

Author SHA1 Message Date
antopilo
1417df96d1 Renderer is now using new buffer management system 2025-05-04 22:33:47 -04:00
antopilo
f57393d354 Fixed validation errors 2025-05-04 12:11:37 -04:00
antopilo
f88c76445f Moved GPU Data structs into its own header and hooked them up in the bindless descriptor management system 2025-05-03 12:13:56 -04:00
antopilo
fe89b84222 Added automated reflection based json serialization for reflected components 2025-05-03 11:56:59 -04:00
Antoine Pilote
2a9b4de5eb Merge branch 'vulkan-dev' of https://github.com/antopilo/nuake into vulkan-dev 2025-05-02 16:50:50 -04:00
Antoine Pilote
70141a7ee6 Added catch2 2025-05-02 16:50:34 -04:00
antopilo
060d5b9c6f Added bindless descriptor management swapping function + hooked it up in current renderer 2025-05-01 23:26:28 -04:00
antopilo
e8e713253e Fixed compilation errors 2025-04-29 22:30:56 -04:00
antopilo
6f9f3a96e2 NEw splash screen + can now see editor cam in camera preview 2025-04-29 22:30:44 -04:00
antopilo
4aa33b6a20 Merge branch 'vulkan-dev' of https://github.com/antopilo/Nuake into vulkan-dev 2025-04-27 23:28:19 -04:00
antopilo
9bd42e1031 Fixed imgui address sanitizer 2025-04-27 23:28:06 -04:00
antopilo
53150dd787 Started proper descriptor management system 2025-04-27 23:26:26 -04:00
antopilo
b77ff499a0 Added ImPlot + GPU Buffer debugger 2025-04-27 23:25:51 -04:00
antopilo
3fc503ee79 Fixed imgui address sanitizer 2025-04-27 12:01:58 -04:00
antopilo
6f9d0f2818 Added alpha scissoring in material editor + shadows 2025-04-27 00:47:45 -04:00
antopilo
958287f6b1 Added debug names and markers to vulkan 2025-04-26 23:07:41 -04:00
antopilo
60819fe1d3 Proper viewport disabling with material editor window 2025-04-26 23:07:20 -04:00
antopilo
7cb7a72630 Added #include processor for default bindings 2025-04-26 19:23:28 -04:00
antopilo
74ee818443 Added cast,receive shadows & unlit flags in the materials 2025-04-26 18:58:03 -04:00
antopilo
90d91feced Bunch of improvements
- Camera preview
- Culling, Sampling in materials
- Per scene lighting now working properly
- Fixed vk validations errors
- Viewport can be enabled/disabled
- Enabled anisotropy in device features
- Scenes now a resource
2025-04-26 17:55:52 -04:00
antopilo
6d7a3a09b1 Better far volumetric handling with sky color 2025-04-25 21:20:36 -04:00
antopilo
67916d0307 Added normal maapping + material preview widget 2025-04-25 20:22:41 -04:00
antopilo
30b5ccc339 Volumetric upscaling + support for other types of lights + CSM 2025-04-24 23:18:14 -04:00
antopilo
4f24372a2f Rendering volumetric at quarter res 2025-04-24 19:56:11 -04:00
antopilo
08be51fc2d Merge branch 'vulkan-dev' of https://github.com/antopilo/Nuake into vulkan-dev
# Conflicts:
#	Nuake/Source/Nuake/Modules/QuakeModule/Module.lua
2025-04-24 18:14:27 -04:00
antopilo
eac8c7aab0 Fixed quake module typo 2025-04-24 18:14:10 -04:00
Antoine Pilote
a82e3dec04 Fixed compilation warning 2025-04-24 12:25:45 -04:00
Antoine Pilote
e8c4af6e5c Merge branch 'vulkan-dev' of https://github.com/antopilo/nuake into vulkan-dev
# Conflicts:
#	Nuake/Source/Nuake/Rendering/Vulkan/VulkanRenderer.cpp
2025-04-24 12:16:14 -04:00
Antoine Pilote
b73caaf8b7 GPU validation 2025-04-24 12:13:05 -04:00
antopilo
aeac3a4e47 Added back volumetric 2025-04-23 20:11:42 -04:00
antopilo
e18298a8cb Editor animations/optimization 2025-04-23 00:47:18 -04:00
antopilo
bef8e3d204 Added escape to unselect 2025-04-21 22:59:59 -04:00
antopilo
8b7bdf6376 Added quake BSP importer module 2025-04-21 11:37:56 -04:00
antopilo
23cf27b120 Re-enabled mesh colliders 2025-04-21 11:36:42 -04:00
antopilo
163c3887ac Cleanup code 2025-04-21 11:36:34 -04:00
antopilo
85062d4de5 Live reloading 2025-04-21 11:36:26 -04:00
antopilo
ce89e8b466 Improved filebrowser 2025-04-21 11:35:42 -04:00
antopilo
4052c14567 Better splash screen 2025-04-17 23:18:11 -04:00
antopilo
5c5289ee73 No more random textures when resizing viewport 2025-04-17 22:50:02 -04:00
antopilo
9a3919d633 Fixed crashen when closing window 2025-04-17 22:33:03 -04:00
antopilo
0c4252be5e Manual GPU resource deletion in desctructor 2025-04-17 22:32:53 -04:00
antopilo
e2fd0644e4 Removed test gizmo drawing 2025-04-17 22:32:40 -04:00
antopilo
54b7c4143f Fixed material being wrongly serialized when baking an asset 2025-04-17 22:23:00 -04:00
antopilo
217a4fbcb6 Fixed weird splash screen when loading a project 2025-04-17 22:22:47 -04:00
antopilo
8125d24926 Fixed crash when resizing viewport 2025-04-17 22:13:57 -04:00
antopilo
d276e875a8 Fixed albedo not working when first importing asset 2025-04-17 20:58:38 -04:00
antopilo
5da09282d0 Added PCF smooth shadows 2025-04-17 20:17:31 -04:00
antopilo
a8c38a5a4e Fixed GPU memory leak when stopping starting + disabled tracy by default 2025-04-17 18:39:24 -04:00
antopilo
a809c5a568 Added color in output window 2025-04-17 18:38:58 -04:00
antopilo
d891762b3f Added GPU resource info count 2025-04-17 18:38:49 -04:00
antopilo
d2b9ef97da GPU Cleanup 2025-04-15 23:34:33 -04:00
antopilo
62fe4b360d Logger now outputs color 2025-04-15 19:34:08 -04:00
antopilo
7f65a80ad0 Removed unsused code 2025-04-15 19:34:01 -04:00
antopilo
a46ee129f0 Fixed most vulkan validation layers 2025-04-15 19:33:46 -04:00
antopilo
710d63ad98 Added mouse picking 2025-04-14 21:11:26 -04:00
antopilo
b8bedd6cb2 Selection now works for all gizmos 2025-04-14 17:43:54 -04:00
antopilo
1af791293d Better outline 2025-04-14 17:29:39 -04:00
antopilo
57564645f2 better outline + gizmo interaction 2025-04-14 17:29:23 -04:00
antopilo
5ce9fb6093 Finished outline selection shader 2025-04-14 14:34:26 -04:00
antopilo
804d147492 Progress towards working selection outline 2025-04-14 13:51:14 -04:00
antopilo
cf80cd3471 Gizmo drawing mode 2025-04-14 13:50:30 -04:00
antopilo
153d7e423e Added option to chose gizmo visiblity during gameplay or not 2025-04-14 13:50:20 -04:00
antopilo
f4fd6e78f3 Added spotlight gizmo + yellow gizmo when selected 2025-04-14 10:38:53 -04:00
antopilo
1f219ba8bc Game viewport now resizing 2025-04-13 20:29:45 -04:00
antopilo
e656c01bda Prevent gizmo shortcut when controlling camera 2025-04-13 20:14:00 -04:00
antopilo
ef29123dec Added back viewport overlay + bold fonts on primary buttons 2025-04-13 20:12:26 -04:00
antopilo
3ceeb3e272 Tabbing 2025-04-13 18:18:28 -04:00
antopilo
54eff5f454 Tabbing in scene render pipeline 2025-04-13 18:17:19 -04:00
antopilo
b2510a4365 Finished SSAO and debug lines rendering 2025-04-13 18:16:12 -04:00
antopilo
ad581b1d4e Fixed double gizmo bug in viewport 2025-04-13 16:37:27 -04:00
antopilo
b959d4abc0 Added blur + clamping to ssao 2025-04-13 12:39:03 -04:00
antopilo
dc8d4c54ee Improved ssao 2025-04-13 12:26:08 -04:00
antopilo
7921723d72 Simplified widget drawer 2025-04-13 10:44:48 -04:00
antopilo
193b64e177 Added back SSAO 2025-04-12 17:57:02 -04:00
antopilo
6037d48210 Added support for modules to specifiy DLLs and Libs to be used by the engine 2025-04-05 16:38:15 -04:00
antopilo
5bb4303eff Now bindings works automatically and is smoooth, aslo strings work now 2025-04-04 19:01:01 -04:00
antopilo
a516f09cf5 Added generator to work with prebuild steps 2025-04-04 17:21:08 -04:00
antopilo
bff8ca2be1 Now bindings between coral and and generatedC# correctly working 2025-04-04 17:11:48 -04:00
antopilo
1668363c4e Turned off vulkan validation by default 2025-04-04 16:10:50 -04:00
antopilo
00367c37c9 Added basics for automatic C# -> C++ Bindings 2025-04-04 00:17:07 -04:00
antopilo
2908429b68 C# generator now working with bindings.json 2025-04-03 23:06:54 -04:00
antopilo
c9dfe2706e Dumping bindings.json on load 2025-04-03 21:27:23 -04:00
antopilo
41dd201128 Added generate bindings.json function 2025-04-03 21:27:15 -04:00
antopilo
709633dce6 Added default widget drawer 2025-04-03 21:26:54 -04:00
antopilo
2df8cdf150 Added component registering to modules 2025-04-03 12:37:20 -04:00
antopilo
d6d9c380c4 Merge branch 'vulkan-dev' of https://github.com/antopilo/Nuake into vulkan-dev 2025-04-03 10:02:15 -04:00
Antoine Pilote
06c6aab24e Now using module param volume 2025-04-02 16:57:07 -04:00
Antoine Pilote
2876ee701b Removed audio from core engine and moved to module only 2025-04-02 16:49:53 -04:00
Antoine Pilote
fff6997dd4 Nowcalling module events 2025-04-02 16:49:28 -04:00
Antoine Pilote
ef70a04da9 Added basic events for modules to register to
OnUpdate, OnFixedUpdate, OnSceneLoad, OnGameStateChanged
2025-04-02 16:27:06 -04:00
Antoine Pilote
729ae9050d Moved game state into its own header 2025-04-02 16:26:33 -04:00
Antoine Pilote
0f7a9ebfba Added widget drawer for module settings 2025-04-02 13:19:30 -04:00
antopilo
13dd209424 Cleaned up project settings window.cpp 2025-04-02 00:47:49 -04:00
antopilo
3037813cf4 Merge branch 'vulkan-dev' of https://github.com/antopilo/Nuake into vulkan-dev 2025-04-02 00:23:49 -04:00
antopilo
5ae981db06 Now drawing registred module settings in project settings 2025-04-02 00:23:40 -04:00
antopilo
a99d793b39 Display a message box when the GPU doesnt support required extensions 2025-03-30 20:00:49 -04:00
antopilo
9dba0d2f4b Added OS API to display message boxes 2025-03-30 20:00:29 -04:00
antopilo
68519dc28b Aded function reflection API 2025-03-26 08:59:51 -04:00
antopilo
e81da93173 Started generic class reflection system 2025-03-25 01:15:24 -04:00
antopilo
155c9a8551 More progress on adding invokation API 2025-03-24 23:49:22 -04:00
antopilo
87ba90a6a0 Module reflection system 2025-03-24 22:55:40 -04:00
antopilo
c2d6a12aa5 Added line rasterization mode 2025-03-23 23:05:49 -04:00
antopilo
6b7a19b5b6 Added Stippled line and debug line API and rendering 2025-03-23 22:50:59 -04:00
antopilo
b30f3192b6 Now properly clearing depth textures 2025-03-23 16:56:57 -04:00
antopilo
e8fda9c544 Added LoadOP to render pass 2025-03-23 01:03:42 -04:00
antopilo
58c2193356 Removed debug gizmo quad 2025-03-23 00:08:40 -04:00
antopilo
eb33b8b241 Added back all icon gizmos for all components type 2025-03-23 00:07:11 -04:00
antopilo
1e0d79e0eb Added textured quad to gizmo api 2025-03-23 00:06:54 -04:00
antopilo
8d41c47a93 Now using alpha blending for gizmo 2025-03-23 00:06:25 -04:00
antopilo
9252264154 Removed Z offset from quad mesh + draw a quad for each light 2025-03-22 23:25:05 -04:00
antopilo
85f0eb2c02 Gizmo api now working with a simple quad in the world 2025-03-22 23:17:25 -04:00
antopilo
0243ef83cb Added Gizmo pass and a OnDebugDraw render pipeline pass 2025-03-22 21:56:07 -04:00
antopilo
e232d06ed3 Minor code cleanup 2025-03-22 19:35:46 -04:00
antopilo
ff50932aa4 Fix crash when closing and reopening the same scene editor. Keep cache of previously created dockspaces 2025-03-22 19:16:47 -04:00
antopilo
c065f12801 Fixed title bar appearing when loading a scene 2025-03-22 18:46:50 -04:00
antopilo
994a5843cf Removed useless namespace 2025-03-03 08:58:46 -05:00
antopilo
f3e0267623 Reusing the same code 2025-03-01 12:27:18 -05:00
antopilo
f491f51d7b Viewport now call onResize on game cameras 2025-02-08 18:46:35 -05:00
antopilo
f0d762b8a1 Camera switching between playmode/editor mode now working properly 2025-02-08 18:38:53 -05:00
antopilo
d0c8e84f50 Improved material parsing 2025-02-08 18:38:28 -05:00
antopilo
7182f4c09b Removed commented opengl code 2025-02-08 18:37:59 -05:00
antopilo
151d0be0f1 Fixed inverted embedded image dumping 2025-02-08 18:37:48 -05:00
antopilo
cede05a309 Viewport now resets to the correct camera after changing scene 2025-02-08 18:32:02 -05:00
antopilo
e09dbb671a GLTFBaker Now works with embedded textures 2025-02-08 14:49:29 -05:00
antopilo
809aea6974 Started handling embedded textures 2025-02-06 12:40:31 -05:00
antopilo
ea503a1c85 Fixed imguizmo aspect ratio 2025-02-06 12:40:21 -05:00
antopilo
ee36f98cdd Added back environment clear color 2025-02-02 21:50:13 -05:00
antopilo
6c3debff41 Started work to reenable play mode 2025-02-02 21:49:54 -05:00
antopilo
b10e437e35 When opening a project without any default scene, open a new one on project load 2025-02-02 13:47:25 -05:00
antopilo
5cc18788f7 Silenced a warning 2025-02-02 13:41:30 -05:00
antopilo
d1523f1b17 Fixed nuake.net not loading 2025-02-02 13:39:35 -05:00
antopilo
80aa334bbc Renabled subprocess 2025-02-02 12:52:33 -05:00
antopilo
4335d0ac9c Fixed editor assimp errors 2025-02-02 12:22:01 -05:00
antopilo
3635e1195c Open a new scene when all scene editors are closed 2025-02-02 12:16:29 -05:00
antopilo
41c05f52a1 Fixed new scene button 2025-02-02 12:12:18 -05:00
antopilo
caa94aeff7 Merge branch 'vulkan-dev' of https://github.com/antopilo/Nuake into vulkan-dev 2025-02-02 12:07:13 -05:00
antopilo
d9c495d0fd Made GBuffer pipeline non static 2025-02-02 12:06:57 -05:00
Antoine Pilote
ce2b29ec1c Added assimp config 2025-02-02 11:58:59 -05:00
antopilo
8d92f68cc6 Added a mapping of viewport -> scene renderer 2025-02-02 10:47:29 -05:00
antopilo
e95787824c Reordered headers in VulkanRenderer.h 2025-02-02 10:34:56 -05:00
antopilo
21647c27cf Reimplemented scene editor window caching to fix crash when closing one during iteration 2025-02-02 10:31:08 -05:00
antopilo
bb7d7aafbc Reverted to tonemapped output 2025-02-02 10:22:53 -05:00
antopilo
e99c8423a6 Started reflection based component serialization 2025-02-01 22:17:15 -05:00
antopilo
c13bd36a78 Made light component use reflection 2025-02-01 22:16:58 -05:00
antopilo
4dd5d2516e Started porting outline pass 2025-02-01 22:16:50 -05:00
antopilo
403446b45d Started reflection based component serialization 2025-02-01 13:22:27 -05:00
antopilo
f3b738758d Added comments to module example 2025-02-01 13:22:15 -05:00
antopilo
17f96f5af2 SceneSystemDB now working properly 2025-02-01 12:06:03 -05:00
antopilo
447fa3cdad Fixed gizmo not working properly 2025-02-01 12:05:22 -05:00
antopilo
d2f36082a9 Moved assimp into its own module 2025-02-01 10:53:37 -05:00
antopilo
2ffe62ee01 Removed debug logging 2025-02-01 10:37:56 -05:00
antopilo
bda0043ede Added example C++ module 2025-02-01 10:37:47 -05:00
antopilo
02c05cf0c1 Removed useless cache copy of scene editors when iterating over them to draw 2025-02-01 01:30:05 -05:00
antopilo
a278d960d1 Removed debug testing window for docking 2025-02-01 01:15:14 -05:00
antopilo
680e5f1651 Automatically dock new scene editors + fixed upside down images in filebrowser widget 2025-02-01 01:02:04 -05:00
antopilo
11490f0f57 Fixed static resources generator with new folder structure 2025-02-01 00:38:33 -05:00
antopilo
9d30f160ba Added per frame in flight deletion queue 2025-01-31 23:30:40 -05:00
antopilo
b51a6b1ccb Fixed aspect ratio of editor camera 2025-01-31 23:30:16 -05:00
antopilo
c28b27f38e Fixed default path of new scene editor filebrowser widget 2025-01-31 23:30:09 -05:00
antopilo
f1e6a10cb1 Fixed swapchain not clearing 2025-01-31 22:53:14 -05:00
antopilo
64edf33622 Editor camera now working again in viewport 2025-01-31 22:49:48 -05:00
antopilo
cd6eb2a682 Added GPUManged interface for resource deletion 2025-01-31 20:56:58 -05:00
antopilo
f54fe85d09 Fixed duplicated static images loading 2025-01-31 19:41:06 -05:00
antopilo
edc4b16ffe Fixed assimp compilation 2025-01-31 18:24:25 -05:00
antopilo
f4a36c9a16 Updated submodules URL to new path 2025-01-31 18:14:20 -05:00
antopilo
25185255cc Removed empty folder 2025-01-31 18:10:22 -05:00
antopilo
74fee28303 Updated readme to point towards Data/ 2025-01-31 18:09:04 -05:00
antopilo
1f3a5e02af Refactored folder structure 2025-01-31 18:04:43 -05:00
antopilo
a4e7e7d530 Removed extra files 2025-01-30 22:49:01 -05:00
antopilo
07f93c0509 Renamed to build scripts 2025-01-30 22:44:19 -05:00
antopilo
16e7819ad8 Fixed compilation issue 2025-01-30 22:43:03 -05:00
antopilo
916d7cf1b4 Removed subprocess 2025-01-30 22:41:55 -05:00
antopilo
92a64f19ea Reworked file structure 2025-01-30 22:41:17 -05:00
antopilo
e8a84c98ec Merge branch 'vulkan-dev' of https://github.com/antopilo/Nuake into vulkan-dev 2025-01-30 19:43:55 -05:00
Antoine Pilote
9cceec7035 Updated readme 2025-01-30 13:26:11 -05:00
Antoine Pilote
85eaa46ee3 Set editor as startup project 2025-01-30 13:23:58 -05:00
Antoine Pilote
e4d276974c Added action to copy deps 2025-01-30 13:19:29 -05:00
Antoine Pilote
3650041051 Added VMA manually 2025-01-30 13:05:45 -05:00
Antoine Pilote
292031dbc2 Bye bye vma 2025-01-30 13:04:52 -05:00
Antoine Pilote
475aceed9b vma 2025-01-30 13:04:10 -05:00
Antoine Pilote
31da43228b Removed VMA submodule 2025-01-30 13:03:07 -05:00
antopilo
f6dd41ed9a Started Vulkan Waster management 🗑️ 2025-01-29 23:20:56 -05:00
antopilo
7d0af312ef Cleaned up a lot of old code 2025-01-29 21:33:17 -05:00
antopilo
ea136b729c Can now render 2 scene at once 2025-01-29 19:43:21 -05:00
antopilo
e5fc760938 Fixed viewport rendering behavior, no longer a black screen. Was missing models in pipeline 2025-01-29 17:57:35 -05:00
antopilo
4d316fe280 Drawing multiple scenes, only need to copy to viewport render targets 2025-01-28 23:08:35 -05:00
antopilo
5347fab0ed Fixed viewport leaks + compilation issues 2025-01-27 21:30:18 -05:00
antopilo
83de729716 Started abstraction for scene viewports 2025-01-27 21:12:25 -05:00
antopilo
faf86c05a7 Request to close window 2025-01-26 21:23:44 -05:00
antopilo
c4e79c61ed Multi-scene editing refactor 2025-01-26 20:21:04 -05:00
antopilo
387b82d385 Reorganized folder structure + using template concepts for security 2025-01-26 11:49:37 -05:00
antopilo
a3dc799692 Started editor windows refactor 2025-01-26 00:07:15 -05:00
antopilo
7a2218824d Added debug draw event 2025-01-25 19:19:01 -05:00
antopilo
b70211ee86 Cleaned up VulkanRenderer 2025-01-25 17:10:31 -05:00
antopilo
81bf61221b Better asset baking + manifest scaning on project load 2025-01-25 17:10:20 -05:00
antopilo
cf8e4cad4d Added onSceneLoaded delegate 2025-01-25 17:09:58 -05:00
Antoine Pilote
8831407da0 Resolve ID 2025-01-23 16:13:45 -05:00
antopilo
ec9cbcf18b Fixed runtime compilation + GLTF material baking 2025-01-22 22:18:12 -05:00
antopilo
8faaef0ec6 Asset bakers now support multiple extensions if necessary 2025-01-21 00:47:18 -05:00
antopilo
1728b20cda Finished basic GLTF asset baking thread safe 2025-01-20 23:31:35 -05:00
antopilo
148a792902 Started path for baking assets 2025-01-19 22:22:03 -05:00
antopilo
ebaf70dfbd Started asset baker abstraction 2025-01-18 19:51:10 -05:00
antopilo
745c6a1f32 Added missing texture 2025-01-18 18:49:13 -05:00
antopilo
89ebc5d012 Resource management refactor - added custom file resolver + RID 2025-01-18 17:51:49 -05:00
antopilo
ab534fe929 Some fixes with coral 2025-01-17 17:59:17 -05:00
antopilo
6b53ab6f8f Fixed some of the crashes with new coral 2025-01-16 21:34:08 -05:00
antopilo
51038f4579 Fixed C# premake scripts 2025-01-16 20:19:27 -05:00
antopilo
6dc7765c70 Updated premake4 to latest 2025-01-16 19:58:36 -05:00
antopilo
476a1d6d95 Bumped coral to latest 2025-01-16 19:57:47 -05:00
antopilo
cae58d8bf5 Started bloom pass 2025-01-16 01:02:03 -05:00
antopilo
333ea73d3a Added tonemapping pass 2025-01-13 20:23:55 -05:00
antopilo
9573eba60b Done with CSM for now 2025-01-13 19:08:43 -05:00
antopilo
d5e987a89d Fix render pass not clearing 2025-01-13 01:45:11 -05:00
antopilo
21150ba091 Deleted old pipeline 2025-01-12 23:05:47 -05:00
antopilo
0ed6e06924 Fixed shading pass with new architecture 2025-01-12 22:54:41 -05:00
antopilo
37fd764248 Switched to bool in shader while sending ints! 2025-01-12 22:34:25 -05:00
antopilo
8c592ba87b Fixed wrong camera being used + materials 2025-01-12 22:33:13 -05:00
antopilo
e52bc15eaa More cleanup with scene renderer 2025-01-12 22:14:30 -05:00
antopilo
c0f8e68daf Made some commandbuffer method const 2025-01-12 22:14:10 -05:00
antopilo
1340d71799 Refactoring 2025-01-12 21:46:19 -05:00
antopilo
64d3cb6e01 Cleaned more 2025-01-12 21:27:02 -05:00
antopilo
0725cafbf3 More cleanup 2025-01-12 21:23:22 -05:00
antopilo
e717cbe68b Major code cleanup 2025-01-12 21:11:10 -05:00
antopilo
28e902b176 moved all descriptor to GPU resource + fixed all validation errors 2025-01-12 20:24:31 -05:00
antopilo
2e95d7d2ad compilation fix with static pipeline object 2025-01-12 12:36:35 -05:00
antopilo
8b3f8aefe9 Continued abstracting command buffer 2025-01-12 12:22:52 -05:00
antopilo
3a97be84b4 Added vulkan shader manager 2025-01-12 11:01:47 -05:00
antopilo
95b0e01f0e Started refactor of the scene renderpipeline to support multiple attachments as inputs 2025-01-12 10:44:38 -05:00
antopilo
e203ac5bd8 Started working towards supporting all the splits 2025-01-12 00:02:56 -05:00
antopilo
890b1c44b2 CSM first cascade working 2025-01-11 21:23:49 -05:00
antopilo
3193ebd062 Starting point for CSM projectiong matrix debugging 2025-01-11 00:12:21 -05:00
antopilo
72440a362d Fixed camera view array 2025-01-10 23:36:25 -05:00
antopilo
d419d6019f Bindless Camera views 2025-01-10 21:12:59 -05:00
antopilo
da6b23cb07 work 2025-01-10 19:44:37 -05:00
Antoine Pilote
2c8de739bd Copy camera 2025-01-10 16:44:38 -05:00
Antoine Pilote
996c3e6e16 Push previous work 2025-01-10 16:09:45 -05:00
Antoine Pilote
7e5a45de52 Manually tracking image layout transitions 2025-01-10 13:20:22 -05:00
Antoine Pilote
c0182293ec bump vma 2025-01-10 12:15:59 -05:00
antopilo
13730be45c Started shadow pipeline 2025-01-10 08:24:14 -05:00
antopilo
95e1c38e0b Point, spot and directional lights now working 2025-01-09 23:14:49 -05:00
antopilo
5a0686bd17 Now PBR directional 2025-01-09 22:40:16 -05:00
antopilo
194b81e114 PBR Directional light working 2025-01-09 19:37:55 -05:00
antopilo
8e8fa1cd6d Fixed color attachments not working 2025-01-09 19:21:53 -05:00
antopilo
a197ab62a6 Started shading pass 2025-01-09 19:08:04 -05:00
antopilo
e5671fd47b Fixed errors with descriptors input 2025-01-08 22:18:46 -05:00
antopilo
b40b0045b9 Started automatic sync + transition for render pass 2025-01-08 21:19:23 -05:00
antopilo
49f9f3bbe0 Bindless textures now working 2025-01-08 20:01:24 -05:00
antopilo
f0325e1ce9 Bindless texture buffer now working 2025-01-08 19:23:40 -05:00
antopilo
e60c114acf Started input system 2025-01-08 00:19:09 -05:00
antopilo
3e92a6c7f4 Started pipeline renderpass inputs 2025-01-07 23:25:16 -05:00
antopilo
d2cd2a542c Deleted old GBuffer 2025-01-07 22:00:20 -05:00
antopilo
2bad2b600a Gbuffer now uses new render pass abstraction + deleted all old rendering code 2025-01-07 21:57:42 -05:00
antopilo
bb4b882ed4 Added attachment resizing + viewport scissoring 2025-01-07 19:49:58 -05:00
antopilo
d69c56bed8 Now render passes have execution order and building process 2025-01-07 19:19:17 -05:00
antopilo
0f5172eb04 Progress on render pipeline and render pass abstraction 2025-01-06 14:53:13 -05:00
antopilo
ab09f8efb5 Started RenderPipeline Absraction 2025-01-05 22:45:37 -05:00
antopilo
0dfa62988b render pipeline stuff 2025-01-05 01:53:26 -05:00
antopilo
3d5ad2e131 Fixed normal TBN matrix 2025-01-04 21:39:46 -05:00
antopilo
1471c2849d All material data now works 2025-01-04 20:37:24 -05:00
antopilo
f3486bc316 Now passing material index + buffer 2025-01-04 20:33:29 -05:00
antopilo
3f6de89262 Now rendering to multiple render target 2025-01-04 18:51:11 -05:00
antopilo
c67b9f18e5 Now renders albedo 2025-01-04 15:13:04 -05:00
antopilo
2d07e3777e Added image GPU resource handling + missing texture 2025-01-04 12:02:39 -05:00
antopilo
8d7f587d7e Display buffer names instead in GPU Resources explorer 2025-01-04 11:24:50 -05:00
antopilo
55901f8603 Fixed imguizmo with reverse-z 2025-01-04 11:07:25 -05:00
antopilo
8548fc8133 vma 2025-01-04 03:51:59 -05:00
antopilo
604da83051 Fixed audio file icon causing editor to crash 2025-01-04 03:38:40 -05:00
antopilo
97ba783644 Filebrowser icons done 2025-01-04 03:31:27 -05:00
antopilo
3e10ee032c Fixed mesh deserialization 2025-01-04 03:17:11 -05:00
antopilo
342513e2e5 Fixed size of minimize button 2025-01-04 03:12:48 -05:00
antopilo
0efc76bfaa Reenabled custom titlebar for Vulkan 2025-01-04 03:07:28 -05:00
antopilo
5f39899981 Added images back to the editor 2025-01-04 03:03:17 -05:00
antopilo
e8ad4be39d Icons are back + Texture can now be created from data 2025-01-04 01:54:13 -05:00
antopilo
90c6652074 Now rendering scene models at correct positions + reverse-z 2025-01-03 23:35:05 -05:00
antopilo
1164bd4b0f Cleaned up pipeline builder code 2024-12-25 17:47:06 -05:00
antopilo
3bf57200af Now using GPUResource manager and updated VkVertex to match real vertex struct 2024-12-25 17:01:37 -05:00
antopilo
1a5a8608fc Moved to VkMesh 2024-12-25 16:36:42 -05:00
antopilo
724459e0dd Started abstraction for VkBuffers 2024-12-25 15:43:34 -05:00
antopilo
34bee233e2 Added missing dxc bin files 2024-12-25 13:14:40 -05:00
antopilo
4ea582ddf7 bump vma 2024-12-25 13:08:08 -05:00
antopilo
679eaa456a Removed vulkan module and modified premake 2024-12-25 13:07:23 -05:00
antopilo
519d54df9b update 2024-12-22 11:59:40 -05:00
antopilo
4897c8fb2c Added 3D camera perspective 2024-12-21 15:11:19 -05:00
antopilo
57c767d659 Fixes for descriptor sets 2024-12-21 14:16:50 -05:00
antopilo
8680107227 Added camera descriptor 2024-12-21 13:15:27 -05:00
antopilo
d40144b9e7 Added DXC error reporting 2024-12-21 13:15:12 -05:00
antopilo
002795d29d Started camera buffer 2024-12-21 11:51:30 -05:00
antopilo
24c41f778e Now drawing quad with vertex pulling 2024-12-21 11:02:38 -05:00
antopilo
dfc5b6fa69 Now using vertex pulling with mesh buffers 2024-12-08 00:30:33 -05:00
antopilo
29130dde7f Triangle in render texture 2024-12-07 21:48:59 -05:00
antopilo
cd2e603733 Added VkImages 2024-12-07 13:28:01 -05:00
antopilo
39a0273595 now displaying viewport texture 2024-12-07 00:59:58 -05:00
antopilo
b2d749244f Editor now displaying in Vulkan 2024-12-04 15:25:08 -05:00
antopilo
5ba897ed46 Vulkan compute shaders 2024-12-04 13:26:03 -05:00
antopilo
fb677f8fe6 Added VMA 2024-12-03 00:54:07 -05:00
antopilo
e5c252629b Added delition queue + removed OGL code 2024-12-02 22:24:31 -05:00
antopilo
84a7d5e248 Now vulkan renderer is clearing the screen 2024-12-02 22:09:54 -05:00
Antoine Pilote
31388612bb Merge pull request #93 from xiaohunqupo/patch-1
Update glfw_p5.lua
2024-12-02 17:04:44 -05:00
antopilo
5b529bd97d Fixed game engine not recompiling + improved prefab instancing from TB 2024-12-02 00:12:42 -05:00
antopilo
d93d69d059 Added controller support 2024-12-01 20:52:34 -05:00
antopilo
82459a6e4c Now instancing prefab from trenchbroom correctly 2024-12-01 13:49:06 -05:00
antopilo
5b4d6d915a Now exports prefabs to trenchbroom automatically 2024-12-01 13:21:58 -05:00
antopilo
ea044a2357 Added GetAllFiles to filesystem 2024-12-01 13:21:44 -05:00
antopilo
b6c3220797 Depth of field no unit accurate 2024-12-01 13:06:13 -05:00
antopilo
15051a4eb7 Improved env setting labels 2024-12-01 13:03:58 -05:00
antopilo
ef25a932b5 Now serializing all environment settings + optimized transform system 2024-12-01 12:15:27 -05:00
antopilo
d7e60cfe96 Fixed runtime 2024-12-01 02:30:06 -05:00
antopilo
a27039d7c5 More blending code + ShapeCastSphere now works 2024-12-01 02:11:05 -05:00
antopilo
18eec6c570 No longer using custom panel for skinned model component 2024-12-01 02:10:49 -05:00
antopilo
699375f1a7 Prefab window no longer crashing 2024-12-01 02:10:31 -05:00
antopilo
c8aa609ab1 Added skeletal animation 1D blending 2024-12-01 02:10:19 -05:00
antopilo
6a96ce497c Capsule and Cylinder now correct height in dynamic world 2024-12-01 02:09:29 -05:00
antopilo
fb217221b7 Added new postfx UI widgets in environment properties 2024-12-01 02:09:06 -05:00
antopilo
9238a59a00 Improved play mode startup time 2024-12-01 02:08:32 -05:00
antopilo
f1b4aaad76 Added lens dirt, posterization and pixelization postfx 2024-12-01 02:07:55 -05:00
Danny许
b32ee08b65 Update glfw_p5.lua
Fix link error.
2024-11-26 10:49:04 +08:00
antopilo
b33bfcab57 Added LookAt to transform C# API 2024-11-24 04:18:55 -05:00
antopilo
6744a58043 Fixed crash when deserializing a skinned mesh if no mesh is set 2024-11-24 00:03:13 -05:00
antopilo
32273eece9 Changed default volumetric strength to 1.0 2024-11-24 00:02:51 -05:00
antopilo
d43c48207c Hide camera speed UI if not controlling camera 2024-11-24 00:02:38 -05:00
antopilo
d714ac0f35 Fixed snapping not working on Z axis 2024-11-24 00:02:14 -05:00
antopilo
dd46e32bee Better SSAO + added shader reloading in debug 2024-11-23 19:46:39 -05:00
antopilo
1782f18f26 Added search feature with text hightlight 2024-11-22 01:08:51 -05:00
antopilo
84b2b63ba9 Added shortcut to open resource in component widgets 2024-11-21 22:14:14 -05:00
antopilo
4ab59bf7e8 Moved environment to a resource and a component 2024-11-21 21:06:14 -05:00
Antoine Pilote
d546228089 Merge pull request #92 from antopilo/develop
Merge develop into main
2024-11-20 22:28:05 -05:00
antopilo
9937d35579 updated readme image 2024-11-20 22:26:41 -05:00
antopilo
1063ffcd58 Removed useless menu items 2024-11-20 01:36:52 -05:00
antopilo
e4c11140e0 Better UI 2024-11-20 01:30:57 -05:00
antopilo
9b853aef7e Added separte settings for gizmo, shape drawing, fixed sky, better UI 2024-11-20 00:07:56 -05:00
antopilo
26ad1507eb Merged static resources 2024-11-19 23:23:38 -05:00
antopilo
3fbb1bd33d Merge branch 'develop' of https://github.com/antopilo/Nuake into develop
# Conflicts:
#	Nuake/src/Resource/StaticResources.cpp
2024-11-19 23:23:16 -05:00
antopilo
2c4d0faf64 Added custom titlebar to the editor 2024-11-19 23:22:41 -05:00
antopilo
0ac0934622 Serialize Sky Component 2024-11-11 11:45:12 -05:00
antopilo
0311862b65 Merge branch 'develop' of https://github.com/antopilo/Nuake into develop 2024-11-06 20:40:58 -05:00
antopilo
89209dc7ba Added support for skyboxes using a new SkyBox resource and component 2024-11-06 20:40:38 -05:00
antopilo
e47142a3e4 Swapped for custom glfw 2024-10-29 20:40:47 -04:00
antopilo
5c2311d7b5 Master volume in project settings now works 2024-10-29 20:37:59 -04:00
antopilo
9647cac48b Disabled thumbnails for now 2024-10-28 20:15:43 -04:00
antopilo
03d785f016 Fixed inverted spatialized audio direction in play mode 2024-10-28 20:14:49 -04:00
antopilo
f1be4f7cef Fixed memory leak + added visibility UI node C# endpoints + size 2024-10-19 23:23:26 -04:00
antopilo
cbf11abcf5 Fixed scene leaking 2024-10-19 15:04:32 -04:00
antopilo
3d630483f6 Added world space UI Input aka doom3 UI 2024-10-19 15:04:07 -04:00
antopilo
c432077328 Added exposed var bool + fixed transform panel 2024-10-19 15:02:36 -04:00
antopilo
39cf28c91e Raycasts now returns the body instance it collided with + serialize spot light cones 2024-10-18 00:21:08 -04:00
Antoine Pilote
4e0817b761 Fixed UI not rendering 2024-10-16 12:28:03 -04:00
antopilo
8ed6a53cf4 Setter and Getter for UIResource on component - Removed useless Environment creation 2024-10-15 20:35:42 -04:00
antopilo
534c35c76f Fixed sprites not working 2024-10-15 19:00:56 -04:00
antopilo
28bbb255c5 Model loader now takes into account submeshes transform 2024-09-27 01:39:40 -04:00
antopilo
e18dbd292f Fixed inverted Y velocity in velocity buffer 2024-09-26 18:47:51 -04:00
antopilo
102ccc530b Finally finished TAA 2024-09-25 22:37:31 -04:00
Antoine Pilote
31c8a2e598 Changed format to gl-float 2024-09-25 13:17:25 -04:00
Antoine Pilote
a37bdd9d7a Added debug display with arrows of velocity buffer 2024-09-25 12:58:53 -04:00
antopilo
6e8f14c5da Added velocity buffer + start of TAA implementation 2024-09-24 21:19:56 -04:00
antopilo
bf75c04a8c Made imgui use another ID for prefab window 2024-09-24 19:29:27 -04:00
antopilo
2dfcb683fc Added imguizo + overlay to prefab editor 2024-09-22 00:01:36 -04:00
antopilo
f1c403f94c Can now delete from prefab editor 2024-09-21 23:49:51 -04:00
antopilo
114adab73f Fixed crash when prefab gets instantiated with C# script 2024-09-21 19:26:20 -04:00
antopilo
0e750bda89 work 2024-09-21 14:02:20 -04:00
antopilo
8079c47832 Instancing prefab through code should instance body and scripts immediatly 2024-09-21 13:18:35 -04:00
antopilo
29b35a6932 Can now reparent prefab with drag n drop 2024-09-21 13:02:36 -04:00
antopilo
ef6e7ac0dc Prevented displaying child of prefab 2024-09-21 13:00:35 -04:00
antopilo
0c784d4462 Stopped display child of prefabs 2024-09-21 12:58:01 -04:00
antopilo
954e2110f1 Fixed prefab serialization and instancing into scene 2024-09-21 12:52:56 -04:00
antopilo
3d9cda2990 Minor improvements with prefab deserialization 2024-09-19 21:36:44 -04:00
antopilo
6ac1ff8386 Work 2024-09-19 21:11:07 -04:00
Antoine Pilote
7791cd9f29 Merge pull request #91 from WiggleWizard/feature/cs-scene-callbacks
Exposed subsystem to scene events
2024-09-19 16:55:31 -04:00
WiggleWizard
a487d31c48 Completed work on exposing subsystems to scene events 2024-09-19 21:43:04 +01:00
WiggleWizard
edce52bb17 Finished up MVP for scene callbacks 2024-09-19 18:50:52 +01:00
WiggleWizard
d0c5ef1a1d Initial infrastructure for C# scene callbacks in subsystems 2024-09-19 17:52:19 +01:00
antopilo
98797e15f8 Prefab editor now somewhat works with live-reload 2024-09-19 12:24:05 -04:00
antopilo
216fa230b6 Saving prefab from prefab editor now works 2024-09-19 10:37:22 -04:00
antopilo
616532e78b Added MVP for prefab editor window and made the whole editor modular to support multi-scene editing 2024-09-19 00:56:22 -04:00
antopilo
a87aebe12b Merge branch 'develop' of https://github.com/antopilo/Nuake into develop 2024-09-18 17:10:18 -04:00
antopilo
7fc10b4e56 Improvements 2024-09-18 17:10:12 -04:00
Antoine Pilote
bd6b4362bc Merge pull request #90 from WiggleWizard/feature/scriptable-subsystems
First pass scriptable subsystems that has the same lifetime of the engine
2024-09-18 16:51:07 -04:00
WiggleWizard
ca645e2026 Fixed a few things 2024-09-18 21:48:14 +01:00
WiggleWizard
066b2998ac Much more stable and simplified subsystem architecture 2024-09-18 21:20:14 +01:00
WiggleWizard
510b577f49 First pass scriptable subsystems that has the same lifetime of the engine 2024-09-18 12:44:46 +01:00
Antoine Pilote
67d7865a20 Merge branch 'develop' of https://github.com/antopilo/nuake into develop 2024-09-17 17:32:13 -04:00
Antoine Pilote
ef0fde5847 Can now drag n drop proejct in project launcher + delete or right click to remove from list 2024-09-17 17:32:05 -04:00
Antoine Pilote
1b2d2985f5 Merge pull request #87 from WiggleWizard/fix/wrenremoval
Removed the last remnants of Wren QQ
2024-09-17 17:20:32 -04:00
Antoine Pilote
07871123cb Fixed runtime linker issues 2024-09-17 12:39:38 -04:00
Antoine Pilote
5f1b9dc65b Merge branch 'develop' of https://github.com/antopilo/nuake into develop 2024-09-17 12:32:48 -04:00
antopilo
c6a2d916a8 Fixed crash when html file is empty and when canvas fails to aprse 2024-09-16 21:42:35 -04:00
antopilo
7ed37d0bbb Fixed crash when canvas parser fails + added resolution settings for worldspace UI 2024-09-16 21:32:17 -04:00
antopilo
f58e09cfc3 Removed overlay when in play mode 2024-09-16 21:31:51 -04:00
antopilo
bd77025ed0 Added script icon in scene hierarchy 2024-09-16 20:55:24 -04:00
antopilo
dd3cc823c0 Improved filesystem browser, color accent, drag n drop, new icons 2024-09-16 20:12:36 -04:00
antopilo
da995b99c8 Renamed textures to Textures 2024-09-16 20:12:02 -04:00
WiggleWizard
1b2abced1e Removed the last remnants of Wren QQ 2024-09-17 00:08:04 +01:00
antopilo
38484415f1 Now displaying camera frustum gizmo 2024-09-16 17:28:01 -04:00
Antoine Pilote
cf9612c5b1 Added a popup to configure trenchbroom when creating a new project 2024-09-16 13:27:22 -04:00
Antoine Pilote
7f92311f12 Fixed crash when ctrl-s in project browser haha 2024-09-16 12:46:15 -04:00
Antoine Pilote
4ac7d1cfc9 Added OpenFolderDialog + now project creation selects folder instead 2024-09-16 12:40:57 -04:00
Antoine Pilote
cff63d71cc Removed glew 2024-09-16 12:18:52 -04:00
Antoine Pilote
4a3d15e7d3 Merge pull request #76 from WiggleWizard/feature/morereflection
Second pass reflection
2024-09-16 11:10:44 -04:00
WiggleWizard
d19ba4f979 Converted last components to new component drawing system 2024-09-16 14:49:25 +01:00
antopilo
ae426f7f17 Added support for SVG images inUI + added a texture flag to flip on load 2024-09-16 08:57:52 -04:00
WiggleWizard
8b2511f995 Better API for binding inspector drawers and added the ability to add whole component drawers 2024-09-16 10:57:22 +01:00
WiggleWizard
d338a98c9b Removed Wren script references in the UI 2024-09-16 10:18:32 +01:00
WiggleWizard
bb43bbe1b8 Fixed rebuild action for quake map component 2024-09-16 10:05:55 +01:00
WiggleWizard
52776186d3 Added the ability to remove components 2024-09-16 00:17:28 +01:00
WiggleWizard
b23d418f23 Compile issues fixed 2024-09-15 23:14:23 +01:00
WiggleWizard
baac971deb A little bit of cleanup 2024-09-15 23:06:06 +01:00
antopilo
24be72b10a Made text calculate proper width with different fonts 2024-09-15 17:29:41 -04:00
WiggleWizard
269533eb03 Particle Emitter Component reflected 2024-09-15 21:34:38 +01:00
WiggleWizard
7846a667a2 Quake Map Component reflected 2024-09-15 21:34:38 +01:00
WiggleWizard
0dcd383dbb Added the ability to add actions (buttons) to the inspector through reflection 2024-09-15 21:34:38 +01:00
WiggleWizard
2b06fe32de Small refactor of trait reflection 2024-09-15 21:34:38 +01:00
WiggleWizard
1d5f578e86 Rigidbody Component reflection 2024-09-15 21:34:38 +01:00
WiggleWizard
6149907576 Skinned Model Component now reflected 2024-09-15 21:34:38 +01:00
WiggleWizard
d8d904b6ba New reflection type DynamicItemList 2024-09-15 21:34:38 +01:00
WiggleWizard
1e570e17fd Made component field type ResourceFile easier to work with 2024-09-15 21:34:38 +01:00
WiggleWizard
d62f241a16 Sphere collider reflection 2024-09-15 21:34:38 +01:00
WiggleWizard
5d0eb4a597 Sprite component reflected 2024-09-15 21:34:37 +01:00
WiggleWizard
dabd9c01a6 Removed trigger zone component 2024-09-15 21:34:37 +01:00
WiggleWizard
aed98dd648 UI system now working well with the new component changes, fixed trait compile issues, fixed inspector rendering issues 2024-09-15 21:34:37 +01:00
WiggleWizard
59505b0664 Fix for audio emitter component not compiling 2024-09-15 21:31:07 +01:00
WiggleWizard
9e94006d2b Added generic ability to (de)serialize ResourceFiles, a templated function to allow easier setting of entt traits and renamed float limits function 2024-09-15 21:31:07 +01:00
WiggleWizard
82771d43da Removed old rubbish from audio emitter component 2024-09-15 21:31:06 +01:00
WiggleWizard
65c8ab79af New component field type to support files
Also fixed Audio System to work with this new supported component field type
2024-09-15 21:31:06 +01:00
WiggleWizard
68ffe1d6b4 Basic inspector reflection working for 2 components 2024-09-15 21:31:06 +01:00
WiggleWizard
90a60e8d87 Initial inspector work to render using reflection 2024-09-15 21:31:06 +01:00
WiggleWizard
56e12c2647 DrawVec3 helper now returns true if changed 2024-09-15 21:31:06 +01:00
WiggleWizard
7d66a19ab2 Architecture rework for components to accomodate for reflection 2024-09-15 21:31:06 +01:00
WiggleWizard
bf6fb0f8b6 Fix for entt update 2024-09-15 21:31:06 +01:00
WiggleWizard
ded6fd2e03 Upgraded entt
Deleted the header only entt lib and added the full and latest library to the dependencies list
2024-09-15 21:31:05 +01:00
antopilo
c2e50822f1 Fixed invalid uniforms in shaders 2024-09-15 16:30:06 -04:00
antopilo
24a4281a3d Added css style propagation + hover propagation from child 2024-09-15 11:08:21 -04:00
Antoine Pilote
c5dca4dc37 Merge pull request #75 from xypherorion/main
FIxed warnings for Premake5 [Issue #74]
2024-09-15 10:28:10 -04:00
Xypher Orion
edc4d43f97 Corrected config 2024-09-15 08:42:27 -04:00
Xypher Orion
a7cbbf2830 Patched for Main Repo Issue #74 2024-09-15 07:31:47 -04:00
antopilo
68ae15594f Started relationional styles 2024-09-14 14:12:08 -04:00
antopilo
79908a12a5 More accurate text size when using px font-size. Added CSS imports to canvas sourceFiles for live reload + started implement descendant css rules 2024-09-14 13:54:23 -04:00
antopilo
fad8b4033b Better default + made root node constraint other nodes 2024-09-13 21:46:21 -04:00
antopilo
efc4b8bae7 Added stylesheet @import into live reload filewatch for a canvas 2024-09-13 21:45:56 -04:00
antopilo
6e92674bba UI hot-reloads if child widgets or stylesheet gets updated 2024-09-13 19:14:46 -04:00
antopilo
ee852f7f3d Prevented abusive resizing when virtual camera is displayed + hide virtual cam in play mode 2024-09-13 18:24:42 -04:00
antopilo
bb0da25682 Fixed newly generated solution not building 2024-09-13 18:24:08 -04:00
antopilo
1b89eaa695 Disabled UI rendering in camera previews 2024-09-13 17:26:21 -04:00
antopilo
89ea32a4b3 Added SceneSwitching, Better font rendering, DOM inspector, Font-family prop 2024-09-13 17:18:09 -04:00
antopilo
4c76e9e493 Can now edit text of text nodes and fetch any other nodes in the DOM from ID 2024-09-13 01:25:41 -04:00
antopilo
3b148b76c4 Started to expose DOM to C# API with support for custom nodes. Currently crash when doing FindNodeByID<T> 2024-09-13 00:51:34 -04:00
Antoine Pilote
9e87dca9ce Set editor viewport dimension for InputManager 2024-09-12 17:01:34 -04:00
Antoine Pilote
5e1483e111 Added mouse position relative to viewport 2024-09-12 13:17:47 -04:00
antopilo
c7621b31e0 Added CustomWidget through C# reflection with callbacks 2024-09-11 22:58:33 -04:00
antopilo
596e4a484c Added C# UIWidget API 2024-09-11 22:58:06 -04:00
antopilo
a5bf5d99c7 Refactor CodeStyle of NuakeUI Renderer 2024-09-11 22:57:36 -04:00
antopilo
8b6991822f Removed NuakeUI FileSystem 2024-09-11 22:57:17 -04:00
antopilo
7ee76a129e Now calls Tick on UI Canvas 2024-09-11 22:57:05 -04:00
antopilo
a75bcc260f Added UI for IsWorldspace 2024-09-11 17:42:04 -04:00
antopilo
f1903de9ab Fixed input manager for UI + WorldSpace UI 2024-09-11 17:41:39 -04:00
Antoine Pilote
40da75eeeb Merge pull request #73 from WiggleWizard/fix/buildoptimizations
Enabled multithreaded compilation and fixed some build warnings
2024-09-11 09:46:12 -04:00
WiggleWizard
7efa69a20d Enabled multithreaded compilation and fixed some build warnings
Enabled MT compilation for all first party TUs and some third party ones too. Disabled specific warnings in third party code, started fixing warnings in first party code as well
2024-09-11 12:03:09 +01:00
Antoine Pilote
706821861b Forgot to push shader source files changes on ui_text.shader 2024-09-11 00:14:46 -04:00
Antoine Pilote
0e78c7d889 Added serialization for UI components 2024-09-10 23:53:29 -04:00
Antoine Pilote
7a5568b513 Removed automatic mipmap generation for texture set from data buffer + exposed subpixel uniforms from text shader 2024-09-10 23:19:32 -04:00
Antoine Pilote
ebedefb6a7 Added UI component, resource & system. Now renders on screen and live reloads 2024-09-10 22:27:15 -04:00
Antoine Pilote
552fe0ee04 Removed annoying debug window 2024-09-10 19:24:24 -04:00
Antoine Pilote
2c48590a4a Added shaders for UI and fixed UI renderer 2024-09-10 19:18:29 -04:00
Antoine Pilote
1949946cdd Removed wrong submodules 2024-09-10 18:10:16 -04:00
Antoine Pilote
dcbd6d0fe3 Merge pull request #72 from WiggleWizard/feature/basiccomponentreflection
Initial reflection for components using the entt reflection API
2024-09-10 12:42:12 -04:00
WiggleWizard
ffc79ccdf4 Initial reflection for components using the entt reflection API
Currently the only system using reflection is the drop down box when clicking "Add Component" in the entity inspector. The other systems and architecture is still designed around concrete compile time typing
2024-09-10 15:53:32 +01:00
Antoine Pilote
7e341b34cf Fixed broken shader uniform caused by automatic casting from uint to int 2024-09-09 21:40:06 -04:00
Antoine Pilote
1051f0cdd3 More work 2024-09-09 21:21:47 -04:00
Antoine Pilote
aef5f65f75 Refactor Shader uniform API + Added back NuakeUI 2024-09-09 20:55:51 -04:00
Antoine Pilote
5a0f7c06f0 Added Yoga 2024-09-09 18:01:05 -04:00
Antoine Pilote
0f14e303b2 Attempt to fix kinematic not generating collision callbacks 2024-09-09 00:09:04 -04:00
Antoine Pilote
22a859b3e1 Prevent .map rebuilding during play mode 2024-09-09 00:08:45 -04:00
Antoine Pilote
e36e33aa9a Renamed exe to Nuake Engine + added C# endpoints i forgot to push 2024-09-08 23:17:51 -04:00
Antoine Pilote
f30e178e87 Added AddComponent C# API + SetGet light intensity 2024-09-08 23:17:28 -04:00
Antoine Pilote
9f09773636 Removed debug window for shadwo maps 2024-09-08 23:17:12 -04:00
Antoine Pilote
73e0498287 Fixed crash in gizmo drawer when selection is invalid 2024-09-08 23:17:02 -04:00
Antoine Pilote
13c0fb414d Fixed crash when trying to generate trenchbroom game config 2024-09-08 23:16:47 -04:00
antopilo
7c123e1c0a Made it possible to open projects directly from the .project file 2024-09-08 15:01:19 -04:00
antopilo
219c9a97cd Made project list in welcome window the same style as template list in new project wizard 2024-09-08 12:32:32 -04:00
antopilo
20ade88fd9 Added a cancel button in new project wizard 2024-09-08 12:32:05 -04:00
Antoine Pilote
6005eb51d3 Merge branch 'develop' of https://github.com/antopilo/Nuake into develop 2024-09-05 21:49:27 -04:00
Antoine Pilote
8d69094cf2 Prevented crash on isValid on entity entity 2024-09-05 21:49:11 -04:00
Antoine Pilote
5034adca8e Now exporting entities to TB on build 2024-09-05 21:48:41 -04:00
Antoine Pilote
81b69749d9 Merge pull request #71 from antopilo/trenchbroom-path-project-settings
Added .project properties to Project Settings
2024-09-05 21:42:40 -04:00
Antoine Pilote
c5563c204c Merge pull request #67 from antopilo/develop
Updated read me
2024-08-16 00:00:58 -04:00
2562 changed files with 613235 additions and 98796 deletions

48
.gitmodules vendored
View File

@@ -1,27 +1,33 @@
[submodule "Nuake/dependencies/glfw"]
path = Nuake/dependencies/glfw
url = https://github.com/glfw/glfw.git
[submodule "Nuake/dependencies/assimp"]
path = Nuake/dependencies/assimp
[submodule "Nuake/Thirdparty/assimp"]
path = Nuake/Thirdparty/assimp
url = https://github.com/assimp/assimp.git
[submodule "Nuake/dependencies/bullet3"]
path = Nuake/dependencies/bullet3
url = https://github.com/bulletphysics/bullet3.git
[submodule "Nuake/dependencies/glew"]
path = Nuake/dependencies/glew
url = https://github.com/nigels-com/glew.git
[submodule "Nuake/dependencies/JoltPhysics"]
path = Nuake/dependencies/JoltPhysics
[submodule "Nuake/Thirdparty/JoltPhysics"]
path = Nuake/Thirdparty/JoltPhysics
url = https://github.com/antopilo/JoltPhysics.git
[submodule "Nuake/dependencies/soloud"]
path = Nuake/dependencies/soloud
[submodule "Nuake/Thirdparty/soloud"]
path = Nuake/Thirdparty/soloud
url = https://github.com/antopilo/soloud.git
[submodule "Nuake/dependencies/Coral"]
path = Nuake/dependencies/Coral
[submodule "Nuake/Thirdparty/Coral"]
path = Nuake/Thirdparty/Coral
url = https://github.com/antopilo/Coral.git
[submodule "Nuake/dependencies/recastnavigation"]
path = Nuake/dependencies/recastnavigation
[submodule "Nuake/Thirdparty/recastnavigation"]
path = Nuake/Thirdparty/recastnavigation
url = https://github.com/antopilo/recastnavigation.git
[submodule "Nuake/dependencies/tracy"]
path = Nuake/dependencies/tracy
[submodule "Nuake/Thirdparty/tracy"]
path = Nuake/Thirdparty/tracy
url = https://github.com/wolfpld/tracy.git
[submodule "Nuake/Thirdparty/msdf-atlas-gen"]
path = Nuake/Thirdparty/msdf-atlas-gen
url = https://github.com/antopilo/msdf-atlas-gen.git
[submodule "Nuake/Thirdparty/yoga"]
path = Nuake/Thirdparty/yoga
url = https://github.com/facebook/yoga.git
[submodule "Nuake/Thirdparty/freetype"]
path = Nuake/Thirdparty/freetype
url = https://github.com/freetype/freetype.git
[submodule "Nuake/Thirdparty/entt"]
path = Nuake/Thirdparty/entt
url = https://github.com/skypjack/entt.git
[submodule "Nuake/Thirdparty/glfw"]
path = Nuake/Thirdparty/glfw
url = https://github.com/antopilo/glfw.git

30
BuildScripts/build.bat Normal file
View File

@@ -0,0 +1,30 @@
@echo off
REM Set default values for configuration and platform
set CONFIG=Debug
set PLATFORM=
REM Get solution file path
set SOLUTION=Nuake.sln
REM Check if Configuration is provided
if not "%~2"=="" (
set CONFIG=%~2
)
REM Check if Platform is provided
if not "%~3"=="" (
set PLATFORM=%~3
)
REM Build the solution
echo Building solution "%SOLUTION%" with Configuration=%CONFIG% and Platform=%PLATFORM%...
"C:\Program Files\Microsoft Visual Studio\2022\Community\Msbuild\Current\Bin\MSBuild.exe" "Nuake.sln" -verbosity:minimal
PAUSE
REM Check if build succeeded
if %ERRORLEVEL%==0 (
echo Build succeeded.
) else (
echo Build failed.
exit /b 1
)

View File

@@ -1,2 +1,3 @@
cd ..
premake5 vs2022
pause

File diff suppressed because it is too large Load Diff

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.9 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

View File

Before

Width:  |  Height:  |  Size: 988 B

After

Width:  |  Height:  |  Size: 988 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

BIN
Data/Images/close-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 849 B

After

Width:  |  Height:  |  Size: 849 B

View File

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
Data/Images/editor-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 985 B

View File

Before

Width:  |  Height:  |  Size: 792 B

After

Width:  |  Height:  |  Size: 792 B

BIN
Data/Images/folder_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 281 B

View File

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 243 B

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 572 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

View File

Before

Width:  |  Height:  |  Size: 626 B

After

Width:  |  Height:  |  Size: 626 B

View File

Before

Width:  |  Height:  |  Size: 1.4 MiB

After

Width:  |  Height:  |  Size: 1.4 MiB

View File

Before

Width:  |  Height:  |  Size: 901 B

After

Width:  |  Height:  |  Size: 901 B

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
Data/Images/sln_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
Data/Images/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@@ -0,0 +1,86 @@
// Transforms
struct ModelData
{
float4x4 model;
};
[[vk::binding(0, 0)]]
StructuredBuffer<ModelData> model : register(t1);
// Vertex
struct Vertex
{
float3 position;
float uv_x;
float3 normal;
float uv_y;
float3 tangent;
float3 bitangent;
};
[[vk::binding(0, 1)]]
StructuredBuffer<Vertex> vertexBuffer : register(t2);
// Samplers
[[vk::binding(0, 2)]]
SamplerState mySampler[2] : register(s0);
// Materials
struct Material
{
bool hasAlbedo;
float3 albedo;
bool hasNormal;
bool hasMetalness;
bool hasRoughness;
bool hasAO;
float metalnessValue;
float roughnessValue;
float aoValue;
int albedoTextureId;
int normalTextureId;
int metalnessTextureId;
int roughnessTextureId;
int aoTextureId;
int samplingType;
int receiveShadow;
int castShadow;
int unlit;
int alphaScissor;
};
[[vk::binding(0, 3)]]
StructuredBuffer<Material> material;
// Textures
[[vk::binding(0, 4)]]
Texture2D textures[];
// Lights
struct Light
{
float3 position;
int type;
float4 color;
float3 direction;
float outerConeAngle;
float innerConeAngle;
bool castShadow;
int shadowMapTextureId[4];
int transformId[4];
};
[[vk::binding(0, 5)]]
StructuredBuffer<Light> lights;
// Cameras
struct CameraView {
float4x4 View;
float4x4 Projection;
float4x4 ViewProjection;
float4x4 InverseView;
float4x4 InverseProjection;
float3 Position;
float Near;
float Far;
};
[[vk::binding(0, 6)]]
StructuredBuffer<CameraView> cameras;

View File

@@ -0,0 +1,28 @@
// HLSL version for Shader Model 6.1
RWTexture2D<float4> image : register(u0);
// Define the size of a thread group
[numthreads(16, 16, 1)]
void main(
uint3 dispatchThreadID : SV_DispatchThreadID,
uint3 groupThreadID : SV_GroupThreadID,
uint3 groupID : SV_GroupID
) {
// Get the size of the image
uint2 size;
image.GetDimensions(size.x, size.y);
// Current texel coordinates
uint2 texelCoord = dispatchThreadID.xy;
if (texelCoord.x < size.x && texelCoord.y < size.y) {
float4 color = float4(0.0, 0.0, 0.0, 1.0);
if (groupThreadID.x != 0 && groupThreadID.y != 0) {
color.x = float(texelCoord.x) / float(size.x);
color.y = float(texelCoord.y) / float(size.y);
}
image[texelCoord] = color;
}
}

View File

@@ -0,0 +1,44 @@
#include "Utils/header.hlsl"
struct PSInput {
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct BlurConstant
{
int blurSourceID;
float2 sourceSize;
};
[[vk::push_constant]]
BlurConstant pushConstants;
float3 SampleTexture(int textureId, float2 uv)
{
return textures[textureId].Sample(mySampler[0], uv).rgb;
}
PSOutput main(PSInput input)
{
float2 texelSize = 1.0 / pushConstants.sourceSize;
float3 result = 0.0;
for (int x = -2; x < 2; x++)
{
for (int y = -2; y < 2; y++)
{
float2 offset = float2(x, y) * texelSize;
result += SampleTexture(pushConstants.blurSourceID, input.UV + offset);
}
}
result = result / (4.0 * 4.0);
PSOutput output;
output.oColor0 = float4(result.rgb, 1.0f);
return output;
}

View File

@@ -0,0 +1,27 @@
#include "Utils/header.hlsl"
struct BlurConstant
{
int blurSourceID;
};
[[vk::push_constant]]
BlurConstant pushConstants;
// Outputs
struct VSOutput {
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -0,0 +1,44 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct CopyPushConstant
{
int SourceTextureID;
int Source2TextureID;
int Mode;
};
[[vk::push_constant]]
CopyPushConstant pushConstants;
PSOutput main(PSInput input)
{
PSOutput output;
int sourceTextureID = pushConstants.SourceTextureID;
int source2TextureID = pushConstants.Source2TextureID;
float2 uv = input.UV;
float4 sampleValue = textures[sourceTextureID].Sample(mySampler[0], input.UV);
float4 sampleValue2 = textures[source2TextureID].Sample(mySampler[0], input.UV);
if(pushConstants.Mode == 0)
{
output.oColor0 = lerp(sampleValue, sampleValue2, 1.0 - sampleValue.a);
}
else if(pushConstants.Mode == 1)
{
output.oColor0 = sampleValue;
output.oColor0 = sampleValue + sampleValue2;
}
return output;
}

View File

@@ -0,0 +1,30 @@
#include "Utils/header.hlsl"
struct CopyPushConstant
{
int SourceTextureID;
int Source2TextureID;
int Mode;
};
[[vk::push_constant]]
CopyPushConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -0,0 +1,80 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct DepthAwareBlurConstant
{
int DepthTextureID;
int VolumetricTextureID;
};
[[vk::push_constant]]
DepthAwareBlurConstant pushConstants;
float2 GetTextureSize(Texture2D tex)
{
uint width, height;
tex.GetDimensions(width, height);
return float2(width, height);
}
float PixelToUV(float2 uv, Texture2D tex)
{
float2 texSize = GetTextureSize(tex);
return uv / texSize;
}
PSOutput main(PSInput input)
{
int depthTexture = pushConstants.DepthTextureID;
float upSampledDepth = textures[depthTexture].Sample(mySampler[0], input.UV).r;
float3 upSampledColor = textures[pushConstants.VolumetricTextureID].Sample(mySampler[1], input.UV).rgb;
float3 color = 0.0f.xxx;
float totalWeight = 0.0f;
int2 screenCoordinates = int2(input.Position.xy);
int xOffset = (screenCoordinates.x % 2 == 0) ? -1 : 1;
int yOffset = (screenCoordinates.y % 2 == 0) ? -1 : 1;
int2 offsets[] = {int2(0, 0),
int2(0, yOffset),
int2(xOffset, 0),
int2(xOffset, yOffset)};
for (int i = 0; i < 4; i ++)
{
float2 uvOffset = float2(offsets[i].x * 4.0, offsets[i].y * 4.0) ;
uvOffset = PixelToUV(uvOffset, textures[pushConstants.DepthTextureID]);
float3 downscaledColor = textures[pushConstants.VolumetricTextureID].Sample(mySampler[1], input.UV + uvOffset).rgb;
float downscaledDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], input.UV + uvOffset).r;
float currentWeight = 1.0f;
if(abs(upSampledDepth - downscaledDepth) > 0.0001)
{
//color = float3(1, 0, 0);
currentWeight *= 0.0f;
}
//currentWeight *= max(0.0f, 1.0f - abs(upSampledDepth - downscaledDepth));
color += downscaledColor * currentWeight;
totalWeight += currentWeight;
}
float3 volumetricLight;
const float epsilon = 0.0001f;
volumetricLight.xyz = color / (totalWeight + epsilon);
PSOutput output;
output.oColor0 = float4(volumetricLight.x, volumetricLight.y, volumetricLight.z, 1.0f);
//output.oColor0 = float4(upSampledColor.x, upSampledColor.y, upSampledColor.z, 1.0f);
return output;
}

View File

@@ -0,0 +1,29 @@
#include "Utils/header.hlsl"
struct DepthAwareBlurConstant
{
int DepthTextureID;
int VolumetricTextureID;
};
[[vk::push_constant]]
DepthAwareBlurConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -0,0 +1,66 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput
{
float4 oColor0 : SV_TARGET;
float4 oEntityID : SV_TARGET1;
};
struct DebugConstant
{
float4 Color;
float4x4 Transform;
int TextureID;
float EntityID;
};
[[vk::push_constant]]
DebugConstant pushConstants;
PSOutput main(PSInput input)
{
PSOutput output;
if(pushConstants.TextureID < 0)
{
output.oColor0 = float4(input.UV.x, input.UV.y, 0, 1);
}
else
{
float2 uv = input.UV;
float4 textureSample = textures[pushConstants.TextureID].Sample(mySampler[0], uv);
// Alpha scisorring
if(textureSample.a < 0.1)
{
//discard;
}
output.oColor0 = textureSample * pushConstants.Color;
if(pushConstants.EntityID != 0.0f)
{
float2 center = float2(0.5, 0.5);
float dist = distance(uv, center);
float radius = 0.5; // You can adjust this as needed
if (dist <= radius)
{
output.oEntityID = float4(pushConstants.EntityID, 0, 0, 1.0f);
}
else
{
output.oEntityID = float4(0, 0, 0, 0); // Or leave it unassigned if default is zero
discard;
}
}
}
return output;
}

View File

@@ -0,0 +1,31 @@
#include "Utils/header.hlsl"
struct DebugConstant
{
float4 Color;
float4x4 Transform;
int TextureID;
float EntityID;
};
[[vk::push_constant]]
DebugConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = mul(pushConstants.Transform, float4(v.position, 1.0f));
return output;
}

View File

@@ -0,0 +1,30 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput
{
float4 oColor0 : SV_TARGET;
};
struct LineConstant
{
float4x4 Transform;
float4 Color;
};
[[vk::push_constant]]
LineConstant pushConstants;
PSOutput main(PSInput input)
{
PSOutput output;
output.oColor0 = pushConstants.Color;
return output;
}

View File

@@ -0,0 +1,29 @@
#include "Utils/header.hlsl"
struct LineConstant
{
float4x4 Transform;
float4 Color;
};
[[vk::push_constant]]
LineConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = mul(pushConstants.Transform, float4(v.position, 1.0f));
return output;
}

View File

@@ -0,0 +1,106 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct OutlinePushConstant
{
float4 Color;
float Thickness;
int SourceTextureID;
int EntityIDTextureID;
int DepthTextureID;
float SelectedEntity;
};
[[vk::push_constant]]
OutlinePushConstant pushConstants;
float2 GetTexelSize(Texture2D tex)
{
uint width, height;
tex.GetDimensions(width, height);
return 1.0 / float2(width, height);
}
float LinearizeDepth(float depth, float nearPlane, float farPlane)
{
return (2.0 * nearPlane) / (farPlane + nearPlane - (1.0 - depth) * (farPlane - nearPlane));
}
PSOutput main(PSInput input)
{
PSOutput output;
float4 outlineColor = pushConstants.Color;
float target = pushConstants.SelectedEntity;
float radius = pushConstants.Thickness;
float2 uv = input.UV;
int entityIDTextureID = pushConstants.EntityIDTextureID;
float hasHit = 0.0f;
float sampleValue = textures[entityIDTextureID].Sample(mySampler[0], uv).r;
float depth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], uv).r;
float4 fragColor = float4(0, 0, 0, 0);
const float TAU = 6.28318530;
const float steps = 64.0;
for(float i = 0.0f; i < TAU; i += TAU / steps)
{
float2 uvOffset = float2(cos(i), sin(i)) * (GetTexelSize(textures[entityIDTextureID])) * radius;
float2 sampleUV = uv + uvOffset;
sampleUV.x = clamp(sampleUV.x, 0.0, 0.999);
sampleUV.y = clamp(sampleUV.y, 0.0, 0.999);
float sample = textures[entityIDTextureID].Sample(mySampler[0], sampleUV).r;
float sampleDepth = textures[pushConstants.DepthTextureID].Sample(mySampler[0], sampleUV).r;
//sampleDepth = LinearizeDepth(sampleDepth, 0.1f, 200.0f);
//depth = LinearizeDepth(depth, 0.1f, 200.0f);
bool passDepthTest = (sampleDepth > depth);
if(sample == target && passDepthTest)
{
hasHit = 1.0f;
if(passDepthTest && sampleValue == target)
{
//hasHit = 0.0f;
}
}
float alpha = smoothstep(0.1, 0.9, hasHit);
float4 outputColor = float4(
lerp(fragColor.r, outlineColor.r, alpha),
lerp(fragColor.g, outlineColor.g, alpha),
lerp(fragColor.b, outlineColor.b, alpha),
lerp(fragColor.a, outlineColor.a, alpha)
);
fragColor = outputColor;
}
if(fragColor.a > 0.1)
{
fragColor.a = 1.0f;
}
float3 sourceTexture = textures[pushConstants.SourceTextureID].Sample(mySampler[0], uv).rgb;
float ratio = float(sampleValue != target && hasHit > 0.0f);
float4 finalColor = float4(
lerp(sourceTexture.r, fragColor.r, ratio),
lerp(sourceTexture.g, fragColor.g, ratio),
lerp(sourceTexture.b, fragColor.b, ratio),
lerp(1.0f, fragColor.a, ratio)
);
output.oColor0 = finalColor;
return output;
}

View File

@@ -0,0 +1,33 @@
#include "Utils/header.hlsl"
struct OutlinePushConstant
{
float4 Color;
float Thickness;
int SourceTextureID;
int EntityIDTextureID;
int DepthTextureID;
float SelectedEntity;
};
[[vk::push_constant]]
OutlinePushConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -0,0 +1,337 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct ShadingPushConstant
{
int AlbedoInputTextureId;
int DepthInputTextureId;
int NormalInputTextureId;
int MaterialInputTextureId;
int LightOffset;
int LightCount;
int CameraID;
float AmbientTerm;
float cascadeDepth[4];
int SSAOTextureId;
int EntityTextureId;
};
[[vk::push_constant]]
ShadingPushConstant pushConstants;
float3 WorldPosFromDepth(float depth, float2 uv, float4x4 invProj, float4x4 invView)
{
float z = depth;
float4 clipSpacePosition = float4(uv.x * 2.0 - 1.0, (uv.y * 2.0 - 1.0), z, 1.0f);
float4 viewSpacePosition = mul(invProj, clipSpacePosition);
viewSpacePosition /= viewSpacePosition.w;
float4 worldSpacePosition = mul(invView, viewSpacePosition);
return worldSpacePosition.xyz;
}
float LinearizeDepth(float depth, float nearPlane, float farPlane, bool reverseDepth)
{
if (reverseDepth)
{
// Reverse depth (near plane = 1.0, far plane = 0.0)
return nearPlane * farPlane / lerp(farPlane, nearPlane, depth);
}
else
{
// Standard depth (near plane = 0.0, far plane = 1.0)
return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - depth * (farPlane - nearPlane));
}
}
float DistributionGGX(float3 N, float3 H, float a)
{
float PI = 3.141592653589793f;
float a2 = a * a;
float NdotH = max(dot(N, H), 0.0);
float NdotH2 = NdotH * NdotH;
float nom = a2;
float denom = (NdotH2 * (a2 - 1.0) + 1.0);
denom = PI * denom * denom;
return nom / denom;
}
float GeometrySchlickGGX(float NdotV, float k)
{
float nom = NdotV;
float denom = NdotV * (1.0 - k) + k;
return nom / denom;
}
float GeometrySmith(float3 N, float3 V, float3 L, float k)
{
float NdotV = max(dot(N, V), 0.0);
float NdotL = max(dot(N, L), 0.0);
float ggx1 = GeometrySchlickGGX(NdotV, k);
float ggx2 = GeometrySchlickGGX(NdotL, k);
return ggx1 * ggx2;
}
float3 fresnelSchlick(float cosTheta, float3 F0)
{
return F0 + (1.0 - F0) * pow(max(1.0 - cosTheta, 0.0), 5.0);
}
float3 fresnelSchlickRoughness(float cosTheta, float3 F0, float roughness)
{
float roughnessTerm = 1.0f - roughness;
return F0 + (max(float3(roughnessTerm, roughnessTerm, roughnessTerm), F0) - F0) * pow(max(1.0 - cosTheta, 0.0), 5.0);
}
float linearDepth(float z, float near, float far) {
return near * far / (far - z * (far - near));
}
int GetCSMSplit(float depth)
{
for(int i = 0; i < 4; i++)
{
float csmSplitDepth = pushConstants.cascadeDepth[i];
if(depth < csmSplitDepth + 0.000001)
{
return i;
}
}
return 0;
}
float SampleShadowMap(int textureId, float2 coords, float compare)
{
return compare > textures[textureId].Sample(mySampler[0], coords.xy).r;
}
float SampleShadowMapLinear(int textureId, float2 coords, float compare, float2 texelSize)
{
float2 pixelPos = coords / texelSize + float2(0.5f, 0.5f);
float2 fracPart = frac(pixelPos);
float2 startTexel = (pixelPos - fracPart) * texelSize;
float blTexel = SampleShadowMap(textureId, startTexel, compare);
float brTexel = SampleShadowMap(textureId, startTexel + float2(texelSize.x, 0.0), compare);
float tlTexel = SampleShadowMap(textureId, startTexel + float2(0.0, texelSize.y), compare);
float trTexel = SampleShadowMap(textureId, startTexel + texelSize, compare);
float mixA = lerp(blTexel, tlTexel, fracPart.y);
float mixB = lerp(brTexel, trTexel, fracPart.y);
return lerp(mixA, mixB, fracPart.x);
}
float ShadowCalculation(Light light, float3 fragPos, float3 normal)
{
// Find correct CSM splits from depth
CameraView camView = cameras[pushConstants.CameraID];
float depth = length(fragPos - camView.Position);
int splitIndex = GetCSMSplit(depth);
// Calculate shadows for found split
CameraView lightView = cameras[light.transformId[splitIndex]];
int shadowMap = light.shadowMapTextureId[0];
float4 fragLightSpace = mul(lightView.Projection, mul(lightView.View, float4(fragPos, 1.0)));
float3 projCoords = fragLightSpace.xyz / fragLightSpace.w;
projCoords.xy = projCoords.xy * 0.5 + 0.5;
if (projCoords.x < 0.0 || projCoords.x > 1.0 || projCoords.y < 0.0 || projCoords.y > 1.0) {
return 1.0;
}
//projCoords.y = 1.0 - projCoords.y;
float currentDepth = projCoords.z;
float bias = max(0.005 * (1.0 - dot(normal, light.direction)), 0.0005);
if(splitIndex < 2)
{
const float NUM_SAMPLES = 4.0f;
const float SAMPLES_START = (NUM_SAMPLES - 1.0f) / 2.0f;
const float NUM_SAMPLES_SQUARED = NUM_SAMPLES * NUM_SAMPLES;
float2 texelSize = 1.0f / float2(4096, 4096);
float result = 0.0f;
for(float y = -SAMPLES_START; y <= SAMPLES_START; y += 1.0f)
{
for (float x = -SAMPLES_START; x <= SAMPLES_START; x += 1.0f)
{
float2 coordsOffset = float2(x, y) * texelSize;
result += SampleShadowMapLinear(light.shadowMapTextureId[splitIndex], projCoords.xy + coordsOffset, currentDepth, texelSize);
}
}
return result /= NUM_SAMPLES_SQUARED;
}
float shadowMapDepth = textures[light.shadowMapTextureId[splitIndex]].Sample(mySampler[0], projCoords.xy).r;
return (currentDepth > shadowMapDepth);//> 0.0 ? 1.0 : 0.0;
}
PSOutput main(PSInput input)
{
PSOutput output;
CameraView camView = cameras[pushConstants.CameraID];
int depthTexture = pushConstants.DepthInputTextureId;
float depth = textures[depthTexture].Sample(mySampler[0], input.UV).r;
if(depth == 0.0f)
{
discard;
}
int albedoTextureId = pushConstants.AlbedoInputTextureId;
float3 albedo = textures[albedoTextureId].Sample(mySampler[0], input.UV).xyz;
int materialId = (int)textures[pushConstants.EntityTextureId].Sample(mySampler[0], input.UV).g;
Material inMaterial = material[materialId];
if(inMaterial.unlit)
{
output.oColor0 = float4(albedo, 1);
return output;
}
float3 worldPos = WorldPosFromDepth(depth, input.UV, camView.InverseProjection, camView.InverseView);
float3 normal = textures[pushConstants.NormalInputTextureId].Sample(mySampler[0], input.UV).rgb;
normal = normal * 2.0f - 1.0f;
float4 materialSample = textures[pushConstants.MaterialInputTextureId].Sample(mySampler[0], input.UV);
float metallic = materialSample.r;
float ao = materialSample.g;
float roughness = materialSample.b;
float ssao = textures[pushConstants.SSAOTextureId].Sample(mySampler[0], input.UV).r;
float3 N = normal;
float3 V = normalize(camView.Position - worldPos);
float3 R = reflect(-V, N);
float3 F0 = float3(0.04, 0.04, 0.04);
F0 = lerp(F0, albedo, metallic);
Light directionalLight;
bool foundDirectional = false;
for(int i = pushConstants.LightOffset; i < pushConstants.LightOffset + pushConstants.LightCount; i++)
{
Light light = lights[i];
if(light.type == 0)
{
directionalLight = light;
foundDirectional = true;
break;
}
}
const float PI = 3.141592653589793f;
float3 Lo = float3(0.0, 0.0, 0.0);
float shadow = 1.0f;
if(foundDirectional == false)
{
shadow = 1.0f;
}
//Directional
if(foundDirectional)
{
Light light = directionalLight;
float3 L = normalize(light.direction);
float attenuation = 1.0f;
if(light.castShadow == true)
{
shadow *= ShadowCalculation(light, worldPos, N);
//output.oColor0 = float4(albedo * 0.1 + float3(shadow, shadow, shadow), 1);
//return output;
}
// TODO: Shadow
float3 radiance = light.color.rgb * attenuation;
float3 H = normalize(V + L);
float NDF = DistributionGGX(N, H, roughness);
float G = GeometrySmith(N, V, L, roughness);
float3 F = fresnelSchlick(max(dot(H, V), 0.0), F0);
float3 nominator = NDF * G * F;
float denominator = 4 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0) + 0.001; // 0.001 to prevent divide by zero.
float3 specular = nominator / denominator;
float3 kS = F;
float3 kD = float3(1.0, 1.0, 1.0) - kS;
kD *= 1.0 - metallic;
float NdotL = max(dot(N, L), 0.0);
if(inMaterial.receiveShadow == 0)
{
shadow = 1.0f;
}
Lo += (kD * albedo / PI + specular) * radiance * NdotL * shadow;
}
// other lights
for(int i = pushConstants.LightOffset; i < pushConstants.LightOffset + pushConstants.LightCount; i++)
{
Light light = lights[i];
float3 L = normalize(light.position - worldPos);
float distance = length(light.position - worldPos);
float attenuation = 1.0 / (distance * distance);
float3 radiance = float3(0, 0, 0);
if(light.type == 1) // point light
{
radiance = light.color * attenuation;
}
else if(light.type == 2)
{
float theta = dot(L, normalize(-light.direction));
float epsilon = light.innerConeAngle - light.outerConeAngle;
float intensity = clamp((theta - light.outerConeAngle) / epsilon, 0.0, 1.0);
radiance = light.color * intensity * attenuation;
}
float3 H = normalize(V + L);
float NDF = DistributionGGX(N, H, roughness);
float G = GeometrySmith(N, V, L, roughness);
float3 F = fresnelSchlick(max(dot(H, V), 0.0), F0);
float3 nominator = NDF * G * F;
float denominator = 4 * max(dot(N, V), 0.0) * max(dot(N, L), 0.0) + 0.001; // 0.001 to prevent divide by zero.
float3 specular = nominator / denominator;
float3 kS = F;
float3 kD = float3(1.0, 1.0, 1.0) - kS;
kD *= 1.0 - metallic;
float NdotL = max(dot(N, L), 0.0);
Lo += (kD * albedo / PI + specular) * radiance * NdotL;
}
float3 F = fresnelSchlickRoughness(max(dot(N, V), 0.0), F0, roughness);
float3 kS = F;
float3 kD = 1.0 - kS;
kD *= 1.0 - metallic;
float3 ambient = (albedo) * ao * ssao * pushConstants.AmbientTerm;
float3 color = (ambient) + Lo;
output.oColor0 = float4(color, 1);
return output;
}

View File

@@ -0,0 +1,39 @@
#include "Utils/header.hlsl"
struct ShadingPushConstant
{
int AlbedoInputTextureId;
int DepthInputTextureId;
int NormalInputTextureId;
int MaterialInputTextureId;
int LightOffset;
int LightCount;
int CameraID;
float AmbientTerm;
float cascadeDepth[4];
int SSAOTextureId;
int EntityTextureId;
};
[[vk::push_constant]]
ShadingPushConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -0,0 +1,31 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct ModelPushConstant
{
int modelIndex; // Push constant data
int materialIndex;
int cameraID;
};
[[vk::push_constant]]
ModelPushConstant pushConstants;
void main(PSInput input)
{
Material inMaterial = material[pushConstants.materialIndex];
if(inMaterial.alphaScissor == 1)
{
SamplerState samplerr = mySampler[inMaterial.samplingType];
float albedoAlpha = textures[inMaterial.albedoTextureId].Sample(samplerr, input.UV).a;
if(albedoAlpha < 0.1f)
{
discard;
}
}
}

View File

@@ -0,0 +1,51 @@
#include "Utils/header.hlsl"
struct ModelPushConstant
{
int modelIndex; // Push constant data
int materialIndex;
int cameraID;
};
[[vk::push_constant]]
ModelPushConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
float LinearizeDepth(float depth, float nearPlane, float farPlane, bool reverseDepth)
{
if (reverseDepth)
{
// Reverse depth (near plane = 1.0, far plane = 0.0)
return nearPlane * farPlane / lerp(farPlane, nearPlane, depth);
}
else
{
// Standard depth (near plane = 0.0, far plane = 1.0)
return (2.0 * nearPlane * farPlane) / (farPlane + nearPlane - depth * (farPlane - nearPlane));
}
}
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
ModelData modelData = model[pushConstants.modelIndex];
CameraView camView = cameras[pushConstants.cameraID];
// Load vertex data from the buffer
Vertex v = vertexBuffer[vertexIndex];
// Output the position of each vertex
output.Position = mul(camView.Projection, mul(camView.View,mul(modelData.model, float4(v.position, 1.0f))));
output.UV = float2(v.uv_x, v.uv_y);
//output.Position.z = LinearizeDepth(output.Position.z, camView.Near, camView.Far, false);
return output;
}

View File

@@ -0,0 +1,143 @@
#include "Utils/header.hlsl"
[[vk::binding(0, 7)]]
StructuredBuffer<float3> ssaoKernels;
struct PSInput {
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct SSAOConstant
{
int noiseTextureID;
int normalTextureID;
int depthTextureID;
int camViewID;
float radius;
float bias;
float2 noiseScale;
float power;
};
[[vk::push_constant]]
SSAOConstant pushConstants;
float3 ViewPosFromDepth(float depth, float2 uv, float4x4 invProj)
{
float z = depth;
float4 clipSpacePosition = float4(uv.x * 2.0 - 1.0, (uv.y * 2.0 - 1.0), z, 1.0f);
float4 viewSpacePosition = mul(invProj, clipSpacePosition);
viewSpacePosition /= viewSpacePosition.w;
return viewSpacePosition.xyz;
}
float3 WorldPosFromDepth(float depth, float2 uv, CameraView camera)
{
float z = depth;
float4 clipSpacePosition = float4(uv.x * 2.0 - 1.0, (uv.y * 2.0 - 1.0), z, 1.0f);
float4 viewSpacePosition = mul(camera.InverseProjection, clipSpacePosition);
viewSpacePosition /= viewSpacePosition.w;
float4 worldSpacePosition = mul(camera.InverseView, viewSpacePosition);
worldSpacePosition /= worldSpacePosition.w;
return worldSpacePosition.xyz;
}
float3 SampleTexture(int textureId, float2 uv)
{
return textures[textureId].Sample(mySampler[0], uv).rgb;
}
float SampleDepth(float2 uv)
{
return textures[pushConstants.depthTextureID].Sample(mySampler[0], uv).r;
}
float3x3 Inverse3x3(float3x3 m)
{
float3 r0 = cross(m[1], m[2]);
float3 r1 = cross(m[2], m[0]);
float3 r2 = cross(m[0], m[1]);
float det = dot(r2, m[2]);
float invDet = 1.0 / det;
return float3x3(
r0 * invDet,
r1 * invDet,
r2 * invDet
);
}
PSOutput main(PSInput input)
{
CameraView camera = cameras[pushConstants.camViewID];
float depth = SampleDepth(input.UV);
// Discard the sky
if(depth < 0.00001)
{
discard;
}
// Calculate TBN
float3x3 normalMatrix = (float3x3)camera.View;
//normalMatrix[0] *= -1.0; // Flip the Z basis vector
float3 normal = SampleTexture(pushConstants.normalTextureID, input.UV).xyz * 2.0 - 1.0;
normal = mul(normalMatrix, normal);
float2 randomVecSample = SampleTexture(pushConstants.noiseTextureID, input.UV * pushConstants.noiseScale).xy * 2.0 - 1.0;
float3 randomVec = float3(randomVecSample.x, -randomVecSample.y, 0);
//randomVec = float3(0, 1, 0);
float3 tangent = normalize(randomVec - normal * dot(randomVec, normal));
float3 bitangent = cross(normal, tangent);
float3x3 TBN = float3x3(tangent, bitangent, normal);
float3 fragPos = ViewPosFromDepth(depth, input.UV, camera.InverseProjection);
// Fix from: https://github.com/JoeyDeVries/LearnOpenGL/issues/364
float4 fragWorldPos = mul(camera.InverseView, float4(fragPos, 1.0));
fragWorldPos.xyz /= fragWorldPos.w;
PSOutput output;
float occlusion = 0.0f;
for(int i = 0; i < 64; i++)
{
float3 samplePos = mul(ssaoKernels[i], TBN);
samplePos = fragPos + samplePos * pushConstants.radius;
//samplePos = fragWorldPos + samplePos * pushConstants.radius;
//return output;
// Fix from: https://github.com/JoeyDeVries/LearnOpenGL/issues/364
float4 worldSamplePos = mul(camera.View, float4(samplePos, 1.0));
worldSamplePos.xyz /= worldSamplePos.w;
//samplePos = worldSamplePos.xyz;
float4 offset = float4(samplePos, 1.0f);
offset = mul(camera.Projection, offset);
offset.xyz /= offset.w;
offset.xyz = offset.xyz * 0.5 + 0.5;
offset.x = clamp(offset.x, 0.00001, 0.999);
offset.y = clamp(offset.y, 0.00001, 0.999);
float sampleDepth = ViewPosFromDepth(SampleDepth(offset.xy), offset.xy, camera.InverseProjection).z;
float rangeCheck = smoothstep(0.0, 1.0, pushConstants.radius / abs(sampleDepth - fragPos.z));
occlusion += (sampleDepth - pushConstants.bias >= samplePos.z ? 1.0 : 0.0) * rangeCheck;
}
occlusion = 1.0 - (occlusion / 64.0);
occlusion = pow(occlusion, pushConstants.power);
output.oColor0 = float4(occlusion, occlusion, occlusion, 1.0f);
return output;
}

View File

@@ -0,0 +1,36 @@
#include "Utils/header.hlsl"
[[vk::binding(0, 7)]]
StructuredBuffer<float3> ssaoKernels;
struct SSAOConstant
{
int noiseTextureID;
int normalTextureID;
int depthTextureID;
float radius;
float bias;
float2 noiseScale;
float power;
};
[[vk::push_constant]]
SSAOConstant pushConstants;
// Outputs
struct VSOutput {
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -0,0 +1,28 @@
struct VSInput
{
[[vk::location(0)]] float3 Position : POSITION0;
[[vk::location(1)]] float3 Color : COLOR0;
};
struct UBO
{
float4x4 projectionMatrix;
float4x4 modelMatrix;
float4x4 viewMatrix;
};
cbuffer ubo : register(b0, space0) { UBO ubo; }
struct VSOutput
{
float4 Pos : SV_POSITION;
[[vk::location(0)]] float3 Color : COLOR0;
};
VSOutput main(VSInput input, uint VertexIndex : SV_VertexID)
{
VSOutput output = (VSOutput)0;
output.Color = input.Color * float(VertexIndex);
output.Pos = mul(ubo.projectionMatrix, mul(ubo.viewMatrix, mul(ubo.modelMatrix, float4(input.Position.xyz, 1.0))));
return output;
}

View File

@@ -0,0 +1,52 @@
#include "Utils/header.hlsl"
struct PSInput {
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct TonemapPushConstant
{
float Exposure;
float Gamma;
int SourceTextureID;
};
[[vk::push_constant]]
TonemapPushConstant pushConstants;
float3 PBRNeutralToneMapping(float3 color)
{
const float startCompression = 0.8 - 0.04;
const float desaturation = 0.15;
float x = min(color.r, min(color.g, color.b));
float offset = x < 0.08 ? x - 6.25 * x * x : 0.04;
color -= offset;
float peak = max(color.r, max(color.g, color.b));
if (peak < startCompression) return color;
const float d = 1. - startCompression;
float newPeak = 1. - d * d / (peak + d - startCompression);
color *= newPeak / peak;
float g = 1. - 1. / (desaturation * (peak - newPeak) + 1.);
return lerp(color, newPeak * float3(1, 1, 1), g);
}
PSOutput main(PSInput input)
{
PSOutput output;
float3 color = textures[pushConstants.SourceTextureID].Sample(mySampler[0], input.UV).rgb;
float3 mapped = float3(1.0, 1.0, 1.0) - exp(-color * pushConstants.Exposure);
color = pow(mapped, float3(pushConstants.Gamma, pushConstants.Gamma, pushConstants.Gamma));
output.oColor0 = float4(color, 1);
return output;
}

View File

@@ -0,0 +1,30 @@
#include "Utils/header.hlsl"
struct TonemapPushConstant
{
float Exposure;
float Gamma;
int SourceTextureID;
};
[[vk::push_constant]]
TonemapPushConstant pushConstants;
// Outputs
struct VSOutput {
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -0,0 +1,111 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float3 Color : TEXCOORD0;
float2 UV : TEXCOORD1;
float3 Normal : TEXCOORD2;
float3 Tangent : TEXCOORD3;
float3 Bitangent : TEXCOORD4;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
float4 oNormal : SV_TARGET1;
float4 oMaterial : SV_TARGET2;
float4 oEntityID : SV_TARGET3;
};
struct ModelPushConstant
{
int modelIndex; // Push constant data
int materialIndex;
int cameraID;
float entityID;
};
[[vk::push_constant]]
ModelPushConstant pushConstants;
PSOutput main(PSInput input)
{
PSOutput output;
Material inMaterial = material[pushConstants.materialIndex];
SamplerState samplerr = mySampler[inMaterial.samplingType];
// ALBEDO COLOR
float4 albedoColor = float4(inMaterial.albedo.xyz, 1.0f);
if(inMaterial.hasAlbedo == 1)
{
float4 albedoSample = textures[inMaterial.albedoTextureId].Sample(samplerr, input.UV);
// Alpha cutout?
if(inMaterial.alphaScissor == 1 && albedoSample.a < 0.001f)
{
discard;
}
albedoColor.xyz = albedoSample.xyz * albedoColor.xyz;
}
output.oColor0 = albedoColor;
// NORMAL
// TODO use TBN matrix
float3 T = input.Tangent.xyz;
float3 B = input.Bitangent.xyz;
float3 N = input.Normal.xyz;
float3x3 TBN = float3x3(T, B, N);
float3 normal = float3(0.0, 0.0, 1.0);
if(inMaterial.hasNormal == 1)
{
normal = textures[inMaterial.normalTextureId].Sample(samplerr, input.UV).rgb;
normal.xyz = normal.zxy;
normal = normal * 2.0f - 1.0f;
}
else
{
normal = normal;
}
//normal = input.Normal;
normal = mul(transpose(TBN), normal);
normal = normal / 2.0f + 0.5f;
output.oNormal = float4(normal, 1.0f);
// MATERIAL
// MATERIAL PROPERTIES
float metalnessValue = inMaterial.metalnessValue;
if(inMaterial.hasMetalness == 1)
{
// TODO: Sample from metal texture
}
float aoValue = inMaterial.aoValue;
if(inMaterial.hasAO == 1)
{
// TODO: Sample from AO texture
}
float roughnessValue = inMaterial.roughnessValue;
if(inMaterial.hasRoughness == 1)
{
// TODO: Sample from roughness texture
}
float3 materialOuput = float3(inMaterial.metalnessValue, inMaterial.aoValue, inMaterial.roughnessValue);
output.oMaterial = float4(materialOuput, 1.0f);
output.oEntityID = float4(pushConstants.entityID, pushConstants.materialIndex, 0.0f, 1.0f);
return output;
}

View File

@@ -0,0 +1,74 @@
#include "Utils/header.hlsl"
struct ModelPushConstant
{
int modelIndex; // Push constant data
int materialIndex;
int cameraID;
float entityID;
};
[[vk::push_constant]]
ModelPushConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float3 Color : TEXCOORD0;
float2 UV : TEXCOORD1;
float3 Normal : TEXCOORD2;
float3 Tangent : TEXCOORD3;
float3 Bitangent : TEXCOORD4;
};
float3x3 invert(float3x3 m)
{
float3 a = m[0];
float3 b = m[1];
float3 c = m[2];
float3 r0 = cross(b, c);
float3 r1 = cross(c, a);
float3 r2 = cross(a, b);
float det = dot(r2, c);
// Return identity if not invertible (optional fallback)
if (abs(det) < 1e-6)
return float3x3(1.0, 0.0, 0.0,
0.0, 1.0, 0.0,
0.0, 0.0, 1.0);
float invDet = 1.0 / det;
return float3x3(r0 * invDet,
r1 * invDet,
r2 * invDet);
}
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
CameraView camView = cameras[pushConstants.cameraID];
ModelData modelData = model[pushConstants.modelIndex];
// Load vertex data from the buffer
Vertex v = vertexBuffer[vertexIndex];
// Output the position of each vertex
output.Position = mul(camView.Projection, mul(camView.View, mul(modelData.model, float4(v.position, 1.0f))));
output.Color = normalize(float3(v.position.xyz));
output.UV = float2(v.uv_x, v.uv_y);
float3x3 upper3x3 = (float3x3)modelData.model;
float3x3 normalMatrix = transpose(invert(upper3x3));
output.Bitangent = mul(normalMatrix, normalize(v.bitangent.xyz));
output.Normal = mul(normalMatrix, normalize(v.normal.xyz));
output.Tangent = mul(normalMatrix, normalize(v.tangent.xyz));
//output.Normal = v.normal.xyz;
return output;
}

View File

@@ -0,0 +1,267 @@
#include "Utils/header.hlsl"
struct PSInput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
struct PSOutput {
float4 oColor0 : SV_TARGET;
};
struct VolumetricConstant
{
int DepthTextureID;
int StepCount;
float FogAmount;
float Exponant;
int CamViewID;
int LightCount;
float Ambient;
float Time;
float NoiseSpeed;
float NoiseScale;
float NoiseStrength;
float CSMSplits[4];
};
[[vk::push_constant]]
VolumetricConstant pushConstants;
float2 GetTexelSize(Texture2D tex)
{
uint width, height;
tex.GetDimensions(width, height);
return 1.0 / float2(width, height);
}
float LinearizeDepth(float depth, float nearPlane, float farPlane)
{
return (2.0 * nearPlane) / (farPlane + nearPlane - (1.0 - depth) * (farPlane - nearPlane));
}
float ComputeScattering(float lightDotView)
{
float PI = 3.141592653589793f;
float result = 1.0f - pushConstants.FogAmount;
result /= (4.0f * PI * pow(1.0f + pushConstants.FogAmount * pushConstants.FogAmount - (1.0f * pushConstants.FogAmount) * lightDotView, 1.5f));
return result;
}
float3 WorldPosFromDepth(float depth, float2 uv, float4x4 invProj, float4x4 invView)
{
float z = depth;
float4 clipSpacePosition = float4(uv.x * 2.0 - 1.0, (uv.y * 2.0 - 1.0), z, 1.0f);
float4 viewSpacePosition = mul(invProj, clipSpacePosition);
viewSpacePosition /= viewSpacePosition.w;
float4 worldSpacePosition = mul(invView, viewSpacePosition);
return worldSpacePosition.xyz;
}
// Simplex 3D Noise
float mod289(float x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
float3 mod289(float3 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
float4 mod289(float4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }
float4 permute(float4 x) { return mod289(((x*34.0)+1.0)*x); }
float4 taylorInvSqrt(float4 r) { return 1.79284291400159 - 0.85373472095314 * r; }
float snoise(float3 v)
{
const float2 C = float2(1.0/6.0, 1.0/3.0) ;
const float4 D = float4(0.0, 0.5, 1.0, 2.0);
// First corner
float3 i = floor(v + dot(v, C.yyy));
float3 x0 = v - i + dot(i, C.xxx);
// Other corners
float3 g = step(x0.yzx, x0.xyz);
float3 l = 1.0 - g;
float3 i1 = min(g.xyz, l.zxy);
float3 i2 = max(g.xyz, l.zxy);
// x0 = x0 - 0.0 + 0.0 * C.xxx;
float3 x1 = x0 - i1 + C.xxx;
float3 x2 = x0 - i2 + C.yyy;
float3 x3 = x0 - 1.0 + 3.0 * C.xxx;
// Permutations
i = mod289(i);
float4 p = permute(permute(permute(
i.z + float4(0.0, i1.z, i2.z, 1.0))
+ i.y + float4(0.0, i1.y, i2.y, 1.0))
+ i.x + float4(0.0, i1.x, i2.x, 1.0));
// Gradients: 7x7 points over a cube, mapped onto a unit sphere
float4 j = p - 49.0 * floor(p * (1.0 / 49.0)); // mod(p,7*7)
float4 x_ = floor(j * (1.0 / 7.0));
float4 y_ = floor(j - 7.0 * x_); // mod(j,7)
float4 x = (x_ * 2.0 + 0.5) / 7.0 - 1.0;
float4 y = (y_ * 2.0 + 0.5) / 7.0 - 1.0;
float4 h = 1.0 - abs(x) - abs(y);
float4 b0 = float4(x.xy, y.xy);
float4 b1 = float4(x.zw, y.zw);
float4 s0 = floor(b0) * 2.0 + 1.0;
float4 s1 = floor(b1) * 2.0 + 1.0;
float4 sh = -step(h, 0.0);
float4 a0 = b0.xzyw + s0.xzyw * sh.xxyy;
float4 a1 = b1.xzyw + s1.xzyw * sh.zzww;
float3 g0 = float3(a0.xy, h.x);
float3 g1 = float3(a0.zw, h.y);
float3 g2 = float3(a1.xy, h.z);
float3 g3 = float3(a1.zw, h.w);
// Normalize gradients
float4 norm = taylorInvSqrt(float4(dot(g0,g0), dot(g1,g1), dot(g2,g2), dot(g3,g3)));
g0 *= norm.x;
g1 *= norm.y;
g2 *= norm.z;
g3 *= norm.w;
// Mix final noise value
float4 m = max(0.6 - float4(dot(x0,x0), dot(x1,x1), dot(x2,x2), dot(x3,x3)), 0.0);
m = m * m;
return 42.0 * dot(m*m, float4(dot(g0,x0), dot(g1,x1), dot(g2,x2), dot(g3,x3)));
}
int GetCSMSplit(float depth)
{
for(int i = 0; i < 4; i++)
{
float csmSplitDepth = pushConstants.CSMSplits[i];
if(depth < csmSplitDepth + 0.000001)
{
return i;
}
}
return 0;
}
PSOutput main(PSInput input)
{
float ditherPattern[4][4] = { { 0.0f, 0.5f, 0.125f, 0.625f},
{ 0.75f, 0.22f, 0.875f, 0.375f},
{ 0.1875f, 0.6875f, 0.0625f, 0.5625},
{ 0.9375f, 0.4375f, 0.8125f, 0.3125} };
CameraView camView = cameras[pushConstants.CamViewID];
float3 startPosition = camView.Position;
int depthTexture = pushConstants.DepthTextureID;
float depth = textures[depthTexture].Sample(mySampler[0], input.UV).r;
float3 worldPos = WorldPosFromDepth(depth, input.UV, camView.InverseProjection, camView.InverseView);
float3 rayVector = worldPos - startPosition;
float rayLength = length(rayVector);
PSOutput output;
if(rayLength > 1000.0)
{
output.oColor0 = float4(0.0f, 0.0f, 0, 0.0f);
//return output;
}
float stepLength = rayLength / pushConstants.StepCount;
float3 rayDirection = rayVector / rayLength;
float3 step = rayDirection * stepLength;
float3 accumFog = float3(0, 0, 0);
float3 currentPosition = startPosition;
for(int i = 0; i < pushConstants.StepCount; i++)
{
for(int l = 0; l < pushConstants.LightCount; l++)
{
Light light = lights[l];
if(light.type == 0)
{
float lightDepth = length(worldPos - camView.Position);
int splitIndex = GetCSMSplit(lightDepth);
if(splitIndex == -1)
{
//accumFog += (ComputeScattering(dot(rayDirection, light.direction)).rrr * light.color.xyz) * pushConstants.Exponant;
}
else
{
CameraView lightView = cameras[light.transformId[splitIndex]];
float4 fragPosLightSpace = mul(lightView.Projection, mul(lightView.View, float4(currentPosition, 1.0)));
float3 projCoords = fragPosLightSpace.xyz / fragPosLightSpace.w;
projCoords.xy = projCoords.xy * 0.5 + 0.5;
float currentDepth = projCoords.z;
float closestDepth = textures[light.shadowMapTextureId[splitIndex]].Sample(mySampler[0], projCoords.xy).r;
float3 noiseOffset = float3(pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time);
float3 noiseSamplePos = (currentPosition + noiseOffset) * pushConstants.NoiseScale;
if(closestDepth < currentDepth)
{
accumFog += (ComputeScattering(dot(rayDirection, light.direction)).rrr * light.color.xyz) * pushConstants.Exponant * ((snoise(noiseSamplePos.xyz) + 1.0) / 2.0);
}
else
{
accumFog += (ComputeScattering(dot(rayDirection, light.direction)).rrr * light.color.xyz) * pushConstants.Ambient * ((snoise(noiseSamplePos.xyz) + 1.0) / 2.0);
}
}
}
else if(light.type == 1)
{
float3 lightToFrag = currentPosition - light.position;
float distance = length(lightToFrag);
float3 lightDir = normalize(-lightToFrag);
float attenuation = 1.0 / (distance * distance);
attenuation = 1.0 - smoothstep(0.0, 3.0f, distance);
float3 noiseOffset = float3(pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time);
float3 noiseSamplePos = (currentPosition + noiseOffset) * pushConstants.NoiseScale;
float lightScatter = (snoise(noiseSamplePos.xyz) + 1.0) * 0.5;
float3 scatterTerm = ComputeScattering(dot(rayDirection, lightDir)).rrr * light.color.xyz;
accumFog += scatterTerm * lightScatter * pushConstants.Exponant * attenuation;
}
else if(light.type == 2)
{
float3 lightToFrag = currentPosition - light.position;
float distance = length(lightToFrag);
float3 lightDir = normalize(-lightToFrag);
float attenuation = 1.0 / (distance * distance);
attenuation = 1.0 - smoothstep(0.0, 6.0f, distance);
float3 noiseOffset = float3(pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time, pushConstants.NoiseSpeed * pushConstants.Time);
float3 noiseSamplePos = (currentPosition + noiseOffset) * pushConstants.NoiseScale;
float lightScatter = (snoise(noiseSamplePos.xyz) + 1.0) * 0.5;
float theta = dot(lightDir, normalize(-light.direction));
float epsilon = light.innerConeAngle - light.outerConeAngle;
float intensity = clamp((theta - light.outerConeAngle) / epsilon, 0.0, 1.0);
float3 scatterTerm = ComputeScattering(dot(rayDirection, lightDir)).rrr * light.color.xyz;
accumFog += scatterTerm * lightScatter * pushConstants.Exponant * attenuation * intensity;
}
}
currentPosition += step ;
}
accumFog /= pushConstants.StepCount;
output.oColor0 = float4(accumFog.x, accumFog.y, accumFog.z, 1.0f);
return output;
}

View File

@@ -0,0 +1,39 @@
#include "Utils/header.hlsl"
struct VolumetricConstant
{
int DepthTextureID;
int StepCount;
float FogAmount;
float Exponant;
int CamViewID;
int LightCount;
float Ambient;
float Time;
float NoiseSpeed;
float NoiseScale;
float NoiseStrength;
float CSMSplits[4];
};
[[vk::push_constant]]
VolumetricConstant pushConstants;
// Outputs
struct VSOutput
{
float4 Position : SV_Position;
float2 UV : TEXCOORD0;
};
// Main vertex shader
VSOutput main(uint vertexIndex : SV_VertexID)
{
VSOutput output;
Vertex v = vertexBuffer[vertexIndex];
output.UV = float2(v.uv_x, v.uv_y);
output.Position = float4(v.position, 1.0f);
return output;
}

View File

@@ -23,6 +23,9 @@ uniform float u_Exposure;
uniform float u_Gamma;
uniform sampler2D u_Source2;
uniform vec2 u_Source2Size;
uniform int u_HasLensDirt;
uniform sampler2D u_LensDirt;
uniform float u_LensDirtIntensity;
uniform float u_Threshold;
uniform float u_BlurAmount;
@@ -127,6 +130,13 @@ void main()
}
else if (u_Stage == 5) // Final combine
{
vec4 lensDirt = vec4(0.0f);
if(u_HasLensDirt == 1)
{
lensDirt = max(texture(u_LensDirt, UV) * u_LensDirtIntensity, 1.0 - u_LensDirtIntensity);
}
outputColor *= lensDirt;
outputColor += texture(u_Source2, UV);
vec3 color = outputColor.rgb;

View File

@@ -60,10 +60,8 @@ struct DirectionalLight
{
vec3 Direction;
vec3 Color;
int ShadowMapsIDs[4];
float CascadeDepth[4];
mat4 LightTransforms[4];
int Volumetric;
int Shadow;
};
@@ -75,6 +73,7 @@ uniform DirectionalLight u_DirectionalLight;
uniform int u_DisableSSAO = 0;
uniform float u_AmbientTerm;
uniform sampler2D u_PreviousFrame;
// Converts depth to World space coords.
vec3 WorldPosFromDepth(float depth) {
@@ -160,6 +159,7 @@ float SampleShadowMap(sampler2D shadowMap, vec2 coords, float compare)
float SampleShadowMapLinear(sampler2D shadowMap, vec2 coords, float compare, vec2 texelSize)
{
//return SampleShadowMap(shadowMap, coords.xy, compare);
vec2 pixelPos = coords / texelSize + vec2(0.5);
vec2 fracPart = fract(pixelPos);
vec2 startTexel = (pixelPos - fracPart) * texelSize;
@@ -197,12 +197,14 @@ float ShadowCalculation(vec3 FragPos, vec3 normal)
float bias = max(0.005 * (1.0 - dot(normal, u_DirectionalLight.Direction)), 0.0005);
//float pcfDepth = texture(ShadowMaps[shadowmap], vec3(projCoords.xy, currentDepth), bias);
//return SampleShadowMap(ShadowMaps[shadowmap], projCoords.xy, currentDepth - bias);
if (shadowmap <= 4)
{
const float NUM_SAMPLES = 4.f;
const float SAMPLES_START = (NUM_SAMPLES - 1.0f) / 2.0f;
const float NUM_SAMPLES_SQUARED = NUM_SAMPLES * NUM_SAMPLES;
vec2 texelSize = 1.0 / vec2(4096, 4096);
vec2 texelSize = 1.0 / vec2(2048, 2048);
float result = 0.0f;
for (float y = -SAMPLES_START; y <= SAMPLES_START; y += 1.0f)
@@ -216,7 +218,6 @@ float ShadowCalculation(vec3 FragPos, vec3 normal)
return result / NUM_SAMPLES_SQUARED;
}
else
{
return SampleShadowMap(ShadowMaps[shadowmap], projCoords.xy, currentDepth - bias);

View File

@@ -0,0 +1,117 @@
#shader vertex
#version 440 core
layout(location = 0) in vec3 VertexPosition;
layout(location = 1) in vec2 UVPosition;
out flat vec2 UV;
void main()
{
UV = UVPosition;
gl_Position = vec4(VertexPosition, 1.0f);
}
#shader fragment
#version 440 core
uniform sampler2D u_Source;
uniform vec2 u_Resolution;
in vec2 UV;
out vec4 FragColor;
const float PI = 3.1415927;
const int ARROW_V_STYLE = 1;
const int ARROW_LINE_STYLE = 2;
// Choose your arrow head style
const int ARROW_STYLE = ARROW_LINE_STYLE;
const float ARROW_TILE_SIZE = 64.0;
// How sharp should the arrow head be? Used
const float ARROW_HEAD_ANGLE = 45.0 * PI / 180.0;
// Used for ARROW_LINE_STYLE
const float ARROW_HEAD_LENGTH = ARROW_TILE_SIZE / 6.0;
const float ARROW_SHAFT_THICKNESS = 3.0;
// Computes the center pixel of the tile containing pixel pos
vec2 arrowTileCenterCoord(vec2 pos) {
return (floor(pos / ARROW_TILE_SIZE) + 0.5) * ARROW_TILE_SIZE;
}
// v = field sampled at tileCenterCoord(p), scaled by the length
// desired in pixels for arrows
// Returns 1.0 where there is an arrow pixel.
float arrow(vec2 p, vec2 v) {
// Make everything relative to the center, which may be fractional
p -= arrowTileCenterCoord(p);
float mag_v = length(v), mag_p = length(p);
if (mag_v > 0.0) {
// Non-zero velocity case
vec2 dir_p = p / mag_p, dir_v = v / mag_v;
// We can't draw arrows larger than the tile radius, so clamp magnitude.
// Enforce a minimum length to help see direction
mag_v = clamp(mag_v, 5.0, ARROW_TILE_SIZE / 2.0);
// Arrow tip location
v = dir_v * mag_v;
// Define a 2D implicit surface so that the arrow is antialiased.
// In each line, the left expression defines a shape and the right controls
// how quickly it fades in or out.
float dist;
if (ARROW_STYLE == ARROW_LINE_STYLE) {
// Signed distance from a line segment based on https://www.shadertoy.com/view/ls2GWG by
// Matthias Reitinger, @mreitinger
// Line arrow style
dist =
max(
// Shaft
ARROW_SHAFT_THICKNESS / 4.0 -
max(abs(dot(p, vec2(dir_v.y, -dir_v.x))), // Width
abs(dot(p, dir_v)) - mag_v + ARROW_HEAD_LENGTH / 2.0), // Length
// Arrow head
min(0.0, dot(v - p, dir_v) - cos(ARROW_HEAD_ANGLE / 2.0) * length(v - p)) * 2.0 + // Front sides
min(0.0, dot(p, dir_v) + ARROW_HEAD_LENGTH - mag_v)); // Back
} else {
// V arrow style
dist = min(0.0, mag_v - mag_p) * 2.0 + // length
min(0.0, dot(normalize(v - p), dir_v) - cos(ARROW_HEAD_ANGLE / 2.0)) * 2.0 * length(v - p) + // head sides
min(0.0, dot(p, dir_v) + 1.0) + // head back
min(0.0, cos(ARROW_HEAD_ANGLE / 2.0) - dot(normalize(v * 0.33 - p), dir_v)) * mag_v * 0.8; // cutout
}
return clamp(1.0 + dist, 0.0, 1.0);
} else {
// Center of the pixel is always on the arrow
return max(0.0, 1.2 - mag_p);
}
}
vec2 field(vec2 pos) {
return texture(u_Source, UV).xy;
}
void main()
{
vec2 fragCoord = UV * u_Resolution.xy;
vec4 fragColor =
(1.0 - arrow(fragCoord.xy, field(arrowTileCenterCoord(fragCoord.xy)) * ARROW_TILE_SIZE * 0.4)) *
vec4(field(fragCoord.xy) * 0.5 + 0.5, 0.5, 1.0);
FragColor = fragColor;
}

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