├── .gitignore ├── .travis.yml ├── Engine ├── Aether3D_OSX_Metal │ └── Aether3D_OSX_Metal.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── glaze.xcuserdatad │ │ │ ├── UserInterfaceState.xcuserstate │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcuserdata │ │ └── glaze.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── Aether3D_OSX_Metal.xcscheme │ │ └── xcschememanagement.plist ├── Aether3D_iOS │ ├── Aether3D_iOS.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ ├── xcshareddata │ │ │ │ └── Aether3D_iOS.xccheckout │ │ │ └── xcuserdata │ │ │ │ └── glaze.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcuserdata │ │ │ └── glaze.xcuserdatad │ │ │ └── xcschemes │ │ │ └── xcschememanagement.plist │ └── Aether3D_iOS │ │ └── Info.plist ├── Assets │ ├── Bloom.metal │ ├── Decal.metal │ ├── DepthNormals.metal │ ├── LightCuller.metal │ ├── MetalCommon.h │ ├── Moments.metal │ ├── SDF.metal │ ├── SSAO.metal │ ├── Skybox.metal │ ├── SpriteShader.metal │ ├── Standard.metal │ ├── Unlit.metal │ ├── UnlitSkin.metal │ ├── compile_deploy_d3d12_shaders.cmd │ ├── compile_deploy_vulkan_shaders.cmd │ ├── compile_shaders.sh │ ├── dxc.exe │ ├── dxil.dll │ ├── glider.ico │ ├── glider.png │ ├── hlsl │ │ ├── Bloom.hlsl │ │ ├── Blur.hlsl │ │ ├── LightCuller.hlsl │ │ ├── Standard_frag.hlsl │ │ ├── Standard_skin_vert.hlsl │ │ ├── Standard_vert.hlsl │ │ ├── compose.hlsl │ │ ├── depthnormals_frag.hlsl │ │ ├── depthnormals_skin_vert.hlsl │ │ ├── depthnormals_vert.hlsl │ │ ├── moments_alphatest_frag.hlsl │ │ ├── moments_frag.hlsl │ │ ├── moments_skin_vert.hlsl │ │ ├── moments_vert.hlsl │ │ ├── outline.hlsl │ │ ├── particle_cull.hlsl │ │ ├── particle_draw.hlsl │ │ ├── particle_simulate.hlsl │ │ ├── sdf_frag.hlsl │ │ ├── sdf_vert.hlsl │ │ ├── skybox_frag.hlsl │ │ ├── skybox_vert.hlsl │ │ ├── sprite_frag.hlsl │ │ ├── sprite_vert.hlsl │ │ ├── ssao.hlsl │ │ ├── ubo.h │ │ ├── unlit_cube_frag.hlsl │ │ ├── unlit_cube_vert.hlsl │ │ ├── unlit_frag.hlsl │ │ ├── unlit_skin_vert.hlsl │ │ └── unlit_vert.hlsl │ ├── outline.metal │ ├── particle.metal │ └── sample.jpg ├── Components │ ├── AudioSourceComponent.cpp │ ├── CameraComponent.cpp │ ├── DecalRendererComponent.cpp │ ├── DirectionalLightComponent.cpp │ ├── GameObject.cpp │ ├── LineRendererComponent.cpp │ ├── MeshRendererComponent.cpp │ ├── ParticleSystemComponent.cpp │ ├── PointLightComponent.cpp │ ├── SpotLightComponent.cpp │ ├── SpriteRendererComponent.cpp │ ├── TextRendererComponent.cpp │ └── TransformComponent.cpp ├── Core │ ├── AudioClip.cpp │ ├── AudioSystem.hpp │ ├── AudioSystemAV.mm │ ├── AudioSystemOpenAL.cpp │ ├── FileSystem.cpp │ ├── FileWatcher.cpp │ ├── FileWatcher.hpp │ ├── Font.cpp │ ├── Frustum.cpp │ ├── Frustum.hpp │ ├── MathUtil.cpp │ ├── Matrix.cpp │ ├── MatrixNEON.cpp │ ├── MatrixSSE3.cpp │ ├── Mesh.cpp │ ├── Scene.cpp │ ├── Statistics.cpp │ ├── Statistics.hpp │ ├── SubMesh.hpp │ └── System.cpp ├── Include │ ├── Array.hpp │ ├── AudioClip.hpp │ ├── AudioSourceComponent.hpp │ ├── CameraComponent.hpp │ ├── ComputeShader.hpp │ ├── DecalRendererComponent.hpp │ ├── DirectionalLightComponent.hpp │ ├── Doxyfile │ ├── FileSystem.hpp │ ├── Font.hpp │ ├── GameObject.hpp │ ├── LineRendererComponent.hpp │ ├── Macros.hpp │ ├── Material.hpp │ ├── Matrix.hpp │ ├── Mesh.hpp │ ├── MeshRendererComponent.hpp │ ├── ParticleSystemComponent.hpp │ ├── PointLightComponent.hpp │ ├── Quaternion.hpp │ ├── RenderTexture.hpp │ ├── Scene.hpp │ ├── Shader.hpp │ ├── SpotLightComponent.hpp │ ├── SpriteRendererComponent.hpp │ ├── System.hpp │ ├── TextRendererComponent.hpp │ ├── Texture2D.hpp │ ├── TextureBase.hpp │ ├── TextureCube.hpp │ ├── TransformComponent.hpp │ ├── VR.hpp │ ├── Vec3.hpp │ └── Window.hpp ├── Makefile_Vulkan ├── Makefile_Vulkan_OpenVR ├── Tests │ ├── 01_Math.cpp │ ├── 02_Components.cpp │ ├── 03_Simple3D.cpp │ ├── 04_Serialization.cpp │ ├── Makefile │ ├── UnitTests │ │ └── UnitTests │ │ │ ├── UnitTests.vcxproj │ │ │ ├── UnitTests.vcxproj.filters │ │ │ └── maths.cpp │ └── scene.scene ├── ThirdParty │ ├── AL │ │ ├── al.h │ │ ├── alc.h │ │ ├── alext.h │ │ ├── efx-creative.h │ │ ├── efx-presets.h │ │ └── efx.h │ ├── WinPixEventRuntime │ │ ├── AmdDxExt │ │ │ ├── AmdExtD3D.h │ │ │ ├── AmdExtD3DCommandListMarkerApi.h │ │ │ ├── AmdExtD3DDeviceApi.h │ │ │ └── AmdPix3.h │ │ ├── PIXEvents.h │ │ ├── PIXEventsCommon.h │ │ ├── PIXEventsLegacy.h │ │ ├── pix3.h │ │ └── pix3_win.h │ ├── d3dx12.h │ ├── lib │ │ ├── WinPixEventRuntime.lib │ │ ├── libOpenAL32.dll.a │ │ └── libOpenAL32.lib │ ├── stb_image.c │ └── stb_vorbis.c ├── Video │ ├── D3D12 │ │ ├── ComputeShaderD3D12.cpp │ │ ├── DescriptorHeapManager.cpp │ │ ├── DescriptorHeapManager.hpp │ │ ├── GfxDeviceD3D12.cpp │ │ ├── LightTilerD3D12.cpp │ │ ├── RenderTextureD3D12.cpp │ │ ├── RendererD3D12.cpp │ │ ├── ShaderD3D12.cpp │ │ ├── Texture2D_D3D12.cpp │ │ ├── TextureCubeD3D12.cpp │ │ └── VertexBufferD3D12.cpp │ ├── DDSLoader.cpp │ ├── DDSLoader.hpp │ ├── GfxDevice.hpp │ ├── LightTiler.hpp │ ├── Material.cpp │ ├── Metal │ │ ├── ComputeShaderMetal.mm │ │ ├── GfxDeviceMetal.mm │ │ ├── LightTilerMetal.mm │ │ ├── RenderTextureMetal.mm │ │ ├── RendererMetal.mm │ │ ├── ShaderMetal.mm │ │ ├── Texture2DMetal.mm │ │ ├── TextureCubeMetal.mm │ │ └── VertexBufferMetal.mm │ ├── Renderer.hpp │ ├── RendererCommon.cpp │ ├── TextureCommon.cpp │ ├── VertexBuffer.hpp │ ├── Vulkan │ │ ├── ComputeShaderVulkan.cpp │ │ ├── GfxDeviceVulkan.cpp │ │ ├── LightTilerVulkan.cpp │ │ ├── OpenVRSupportVulkan.cpp │ │ ├── RenderTextureVulkan.cpp │ │ ├── RendererVulkan.cpp │ │ ├── ShaderVulkan.cpp │ │ ├── Texture2DVulkan.cpp │ │ ├── TextureCubeVulkan.cpp │ │ ├── VertexBufferVulkan.cpp │ │ ├── VulkanUtils.cpp │ │ └── VulkanUtils.hpp │ ├── WindowWin32.cpp │ └── WindowXCB.cpp ├── VisualStudio_D3D12 │ ├── Aether3D_D3D12.sln │ ├── Aether3D_D3D12.vcxproj │ └── Aether3D_D3D12.vcxproj.filters └── VisualStudio_Vulkan │ ├── Aether3D_Vulkan.sln │ ├── Aether3D_Vulkan.vcxproj │ └── Aether3D_Vulkan.vcxproj.filters ├── LICENSE.txt ├── README.md ├── Samples ├── 01_OpenWindow │ ├── Makefile │ ├── OpenWindow.cpp │ └── VisualStudio │ │ ├── OpenWindow.sln │ │ ├── OpenWindow.vcxproj │ │ ├── OpenWindow.vcxproj.filters │ │ └── OpenWindow.vcxproj.user ├── 03_Misc2D │ ├── Makefile │ ├── Misc2D.cpp │ └── VisualStudio │ │ ├── Misc2D.sln │ │ ├── Misc2D.vcxproj │ │ ├── Misc2D.vcxproj.filters │ │ └── Misc2D.vcxproj.user ├── 04_Misc3D │ ├── Makefile │ ├── Misc3D.cpp │ └── VisualStudio │ │ ├── Misc3D.sln │ │ ├── Misc3D.vcxproj │ │ ├── Misc3D.vcxproj.filters │ │ └── Misc3D.vcxproj.user ├── City │ ├── City │ │ ├── City.vcxproj │ │ ├── City.vcxproj.filters │ │ └── City.vcxproj.user │ ├── Makefile │ └── city.cpp ├── MetalSampleOSX │ ├── MetalSampleOSX.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcuserdata │ │ │ │ └── glaze.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcuserdata │ │ │ └── glaze.xcuserdatad │ │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ │ └── xcschemes │ │ │ ├── MetalSampleOSX.xcscheme │ │ │ └── xcschememanagement.plist │ ├── MetalSampleOSX │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── GameViewController.h │ │ ├── GameViewController.mm │ │ ├── Info.plist │ │ └── main.m │ └── MetalSampleOSXTests │ │ ├── Info.plist │ │ └── MetalSampleOSXTests.m ├── MetalSampleiOS │ ├── MetalSampleiOS.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcuserdata │ │ │ │ └── glaze.xcuserdatad │ │ │ │ └── UserInterfaceState.xcuserstate │ │ └── xcuserdata │ │ │ └── glaze.xcuserdatad │ │ │ ├── xcdebugger │ │ │ └── Breakpoints_v2.xcbkptlist │ │ │ └── xcschemes │ │ │ ├── MetalSampleiOS.xcscheme │ │ │ └── xcschememanagement.plist │ ├── MetalSampleiOS │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── GameViewController.h │ │ ├── GameViewController.mm │ │ ├── Info.plist │ │ └── main.m │ └── MetalSampleiOSTests │ │ ├── Info.plist │ │ └── MetalSampleiOSTests.mm ├── NuklearTest │ ├── Makefile │ ├── NuklearTest.cpp │ ├── VisualStudio │ │ ├── NuklearTest.vcxproj │ │ ├── NuklearTest.vcxproj.filters │ │ └── NuklearTest.vcxproj.user │ └── nuklear.h └── PBRSample │ ├── Makefile │ ├── PBRSample.cpp │ └── PBRSample │ ├── PBRSample.vcxproj │ ├── PBRSample.vcxproj.filters │ └── PBRSample.vcxproj.user └── Tools ├── CombineFiles ├── CombineFiles.cpp ├── Makefile └── VisualStudio │ ├── CombineFiles.vcxproj │ └── CombineFiles.vcxproj.filters ├── Editor └── Editor │ ├── Editor.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcuserdata │ │ │ └── glaze.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── glaze.xcuserdatad │ │ └── xcschemes │ │ └── xcschememanagement.plist │ ├── Inspector.cpp │ ├── Inspector.hpp │ ├── Makefile │ ├── SceneView.cpp │ ├── SceneView.hpp │ ├── VisualStudio │ ├── Editor.vcxproj │ ├── Editor.vcxproj.filters │ └── Editor.vcxproj.user │ ├── macOS │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ ├── ColorMap.textureset │ │ │ ├── Contents.json │ │ │ └── Universal.mipmapset │ │ │ │ ├── ColorMap.png │ │ │ │ └── Contents.json │ │ └── Contents.json │ ├── Base.lproj │ │ └── Main.storyboard │ ├── Editor.entitlements │ ├── GameViewController.h │ ├── GameViewController.mm │ ├── Info.plist │ └── main.m │ └── main.cpp ├── FBX_Converter ├── ConvertFBX.sln ├── ConvertFBX.vcxproj ├── ConvertFBX.vcxproj.filters ├── Makefile └── convert_fbx.cpp ├── OBJ_Converter ├── ConvertOBJ │ ├── ConvertOBJ.sln │ ├── ConvertOBJ.vcxproj │ └── ConvertOBJ.vcxproj.filters ├── Makefile ├── Makefile_mtl ├── Read_MTL │ ├── Read_MTL.vcxproj │ ├── Read_MTL.vcxproj.filters │ └── Read_MTL.vcxproj.user ├── convert_obj.cpp └── read_mtl.cpp ├── SDF_Generator ├── Makefile └── SDF_Generator.cpp ├── common.hpp └── io_export_aether3d.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.o 3 | *.dSYM 4 | *.dylib 5 | *.sdf 6 | *.exp 7 | *.pdb 8 | *.ilk 9 | *.suo 10 | *.db 11 | *.xcuserstate 12 | .vs/ 13 | x64/ 14 | xcuserdata/ 15 | 16 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | os: 2 | - linux 3 | # - osx 4 | 5 | sudo: required 6 | dist: bionic 7 | 8 | # before_install: 9 | #- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get -qq update; fi 10 | #- if [ $TRAVIS_OS_NAME == linux ]; then sudo apt-get install -y libopenal-dev libx11-xcb-dev libxcb1-dev libxcb-ewmh-dev libxcb-icccm4-dev libxcb-keysyms1-dev; fi 11 | # - wget -O vulkansdk-linux-x86_64-1.1.73.0.run https://vulkan.lunarg.com/sdk/download/1.1.73.0/linux/vulkansdk-linux-x86_64-1.1.73.0.run 12 | # - chmod ugo+x vulkansdk-linux-x86_64-1.1.73.0.run 13 | # - ./vulkansdk-linux-x86_64-1.1.73.0.run 14 | # - export VULKAN_SDK=$TRAVIS_BUILD_DIR/VulkanSDK/1.1.73.0/x86_64 15 | # - export LD_LIBRARY_PATH=$VULKAN_SDK/lib:$LD_LIBRARY_PATH 16 | # - export VK_LAYER_PATH=$VULKAN_SDK/etc/explicit_layer.d 17 | 18 | language: cpp 19 | compiler: 20 | - gcc 21 | script: 22 | # - cd Engine 23 | # - make -f Makefile_Vulkan 24 | - mkdir ../aether3d_build 25 | - cd Tools/OBJ_Converter 26 | - make 27 | - make -f Makefile_mtl 28 | - cd ../SDF_Generator 29 | - make 30 | # - cd ../Editor/Editor 31 | # - make 32 | - cd ../CombineFiles 33 | - make 34 | # - cd ../../Engine/Tests 35 | # - make 36 | # - ./01_Math 37 | # - ./01_MathSSE 38 | #- cd ../../Samples/01_OpenWindow 39 | #- make 40 | #- cd ../03_Misc2D 41 | #- make vulkan 42 | #- cd ../04_Misc3D 43 | #- make vulkan 44 | #- cd ../NuklearTest 45 | #- make vulkan 46 | 47 | -------------------------------------------------------------------------------- /Engine/Aether3D_OSX_Metal/Aether3D_OSX_Metal.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Engine/Aether3D_OSX_Metal/Aether3D_OSX_Metal.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/Aether3D_OSX_Metal/Aether3D_OSX_Metal.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Engine/Aether3D_OSX_Metal/Aether3D_OSX_Metal.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | BuildLocationStyle 6 | UseTargetSettings 7 | CustomBuildLocationType 8 | RelativeToDerivedData 9 | DerivedDataLocationStyle 10 | Default 11 | IssueFilterStyle 12 | ShowActiveSchemeOnly 13 | LiveSourceIssuesEnabled 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Engine/Aether3D_OSX_Metal/Aether3D_OSX_Metal.xcodeproj/xcuserdata/glaze.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Engine/Aether3D_OSX_Metal/Aether3D_OSX_Metal.xcodeproj/xcuserdata/glaze.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Aether3D_OSX_Metal.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | AB6E12B91C11D7450020A929 16 | 17 | primary 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Engine/Aether3D_iOS/Aether3D_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Engine/Aether3D_iOS/Aether3D_iOS.xcodeproj/project.xcworkspace/xcshareddata/Aether3D_iOS.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | BF1E5A54-7C41-4002-9F74-AE1D5B05B627 9 | IDESourceControlProjectName 10 | Aether3D_iOS 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 1432FAA66C12895A759C8ABE3B85F5F564946412 14 | https://github.com/bioglaze/aether3d.git 15 | 16 | IDESourceControlProjectPath 17 | Engine/Aether3D_iOS/Aether3D_iOS.xcodeproj 18 | IDESourceControlProjectRelativeInstallPathDictionary 19 | 20 | 1432FAA66C12895A759C8ABE3B85F5F564946412 21 | ../../../.. 22 | 23 | IDESourceControlProjectURL 24 | https://github.com/bioglaze/aether3d.git 25 | IDESourceControlProjectVersion 26 | 111 27 | IDESourceControlProjectWCCIdentifier 28 | 1432FAA66C12895A759C8ABE3B85F5F564946412 29 | IDESourceControlProjectWCConfigurations 30 | 31 | 32 | IDESourceControlRepositoryExtensionIdentifierKey 33 | public.vcs.git 34 | IDESourceControlWCCIdentifierKey 35 | 1432FAA66C12895A759C8ABE3B85F5F564946412 36 | IDESourceControlWCCName 37 | aether3d 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Engine/Aether3D_iOS/Aether3D_iOS.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/Aether3D_iOS/Aether3D_iOS.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Engine/Aether3D_iOS/Aether3D_iOS.xcodeproj/xcuserdata/glaze.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Aether3D_iOS.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | Aether3D_iOS.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | 4449E8231B14B3E7009A869C 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Engine/Aether3D_iOS/Aether3D_iOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Engine/Assets/Bloom.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace metal; 6 | #include "MetalCommon.h" 7 | 8 | float Gaussian( float x, float d ) 9 | { 10 | return 1.0f / (sqrt(2.0f * 3.14159f * d * d)) * exp( -(x * x) / (2.0f * d * d)); 11 | } 12 | 13 | kernel void downsampleAndThreshold(texture2d colorTexture [[texture(0)]], 14 | texture2d downsampledBrightTexture [[texture(1)]], 15 | constant Uniforms& uniforms [[ buffer(0) ]], 16 | ushort2 gid [[thread_position_in_grid]], 17 | ushort2 tid [[thread_position_in_threadgroup]], 18 | ushort2 dtid [[threadgroup_position_in_grid]]) 19 | { 20 | const float4 color = colorTexture.read( gid ); 21 | const float luminance = dot( color.rgb, float3( 0.2126f, 0.7152f, 0.0722f ) ); 22 | const float luminanceThreshold = uniforms.bloomParams.x; 23 | const float4 finalColor = luminance > luminanceThreshold ? color * uniforms.bloomParams.y : float4( 0, 0, 0, 0 ); 24 | downsampledBrightTexture.write( finalColor, gid.xy / 2 ); 25 | } 26 | 27 | kernel void blur(texture2d inputTexture [[texture(0)]], 28 | texture2d resultTexture [[texture(1)]], 29 | constant Uniforms& uniforms [[ buffer(0) ]], 30 | ushort2 gid [[thread_position_in_grid]], 31 | ushort2 tid [[thread_position_in_threadgroup]], 32 | ushort2 dtid [[threadgroup_position_in_grid]]) 33 | { 34 | float weights[ 5 ] = { 0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216 }; 35 | float4 accumColor = inputTexture.read( uint2( gid.x, gid.y ) ) * weights[ 0 ]; 36 | 37 | for (int x = 1; x < 5; ++x) 38 | { 39 | accumColor += inputTexture.read( uint2( gid.x + x * uniforms.tilesXY.z, gid.y + x * uniforms.tilesXY.w ) ) * weights[ x ]; 40 | accumColor += inputTexture.read( uint2( gid.x - x * uniforms.tilesXY.z, gid.y - x * uniforms.tilesXY.w ) ) * weights[ x ]; 41 | } 42 | 43 | resultTexture.write( accumColor, gid.xy ); 44 | } 45 | -------------------------------------------------------------------------------- /Engine/Assets/Decal.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | // Not functional yet! 5 | 6 | using namespace metal; 7 | 8 | #include "MetalCommon.h" 9 | 10 | struct ColorInOut 11 | { 12 | float4 position [[position]]; 13 | float4 tintColor; 14 | float4 projCoord; 15 | float2 texCoords; 16 | half4 color; 17 | }; 18 | 19 | struct Vertex 20 | { 21 | float3 position [[attribute(0)]]; 22 | float2 texcoord [[attribute(1)]]; 23 | float4 color [[attribute(2)]]; 24 | }; 25 | 26 | vertex ColorInOut decal_vertex(Vertex vert [[stage_in]], 27 | constant Uniforms& uniforms [[ buffer(5) ]]) 28 | { 29 | ColorInOut out; 30 | 31 | float4 in_position = float4( vert.position, 1.0 ); 32 | 33 | out.position = uniforms.localToClip * in_position; 34 | out.color = half4( vert.color ); 35 | out.texCoords = vert.texcoord * uniforms.tex0scaleOffset.xy + uniforms.tex0scaleOffset.wz; 36 | out.tintColor = float4( 1, 1, 1, 1 ); 37 | out.projCoord = uniforms.localToShadowClip * in_position; 38 | return out; 39 | } 40 | 41 | fragment float4 decal_fragment( ColorInOut in [[stage_in]], 42 | texture2d textureMap [[texture(0)]], 43 | texture2d _ShadowMap [[texture(3)]], 44 | texturecube _ShadowMapCube [[texture(2)]], 45 | constant Uniforms& uniforms [[ buffer(5) ]], 46 | sampler sampler0 [[sampler(0)]] ) 47 | { 48 | float4 sampledColor = textureMap.sample( sampler0, in.texCoords ) * in.tintColor; 49 | 50 | float depth = in.projCoord.z / in.projCoord.w; 51 | 52 | if (uniforms.lightType == 2) 53 | { 54 | depth = depth * 0.5f + 0.5f; 55 | } 56 | 57 | float shadow = uniforms.lightType == 0 ? 1.0f : max( uniforms.minAmbient, VSM( _ShadowMap, in.projCoord, depth, uniforms.lightType ) ); 58 | 59 | return sampledColor * float4( shadow, shadow, shadow, 1 ); 60 | } 61 | -------------------------------------------------------------------------------- /Engine/Assets/DepthNormals.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using namespace metal; 4 | #include "MetalCommon.h" 5 | 6 | struct Vertex 7 | { 8 | float3 position [[attribute(0)]]; 9 | float2 texcoord [[attribute(1)]]; 10 | float3 normal [[attribute(3)]]; 11 | }; 12 | 13 | struct VertexSkin 14 | { 15 | float3 position [[attribute(0)]]; 16 | float2 texcoord [[attribute(1)]]; 17 | float3 normal [[attribute(3)]]; 18 | int4 boneIndex [[attribute(5)]]; 19 | float4 boneWeights [[attribute(6)]]; 20 | }; 21 | 22 | struct ColorInOut 23 | { 24 | float4 position [[position]]; 25 | float4 mvPosition; 26 | float4 normal; 27 | }; 28 | 29 | vertex ColorInOut depthnormals_skin_vertex( VertexSkin vert [[stage_in]], 30 | constant Uniforms& uniforms [[ buffer(5) ]]) 31 | { 32 | ColorInOut out; 33 | 34 | matrix_float4x4 boneTransform = uniforms.boneMatrices[ vert.boneIndex.x ] * vert.boneWeights.x + 35 | uniforms.boneMatrices[ vert.boneIndex.y ] * vert.boneWeights.y + 36 | uniforms.boneMatrices[ vert.boneIndex.z ] * vert.boneWeights.z + 37 | uniforms.boneMatrices[ vert.boneIndex.w ] * vert.boneWeights.w; 38 | 39 | float4 in_position = float4( vert.position.xyz, 1.0 ); 40 | float4 skinnedPosition = boneTransform * in_position; 41 | float4 in_normal = float4( vert.normal.xyz, 0.0 ); 42 | float4 skinnedNormal = boneTransform * in_normal; 43 | out.position = uniforms.localToClip * skinnedPosition; 44 | out.mvPosition = uniforms.localToView * skinnedPosition; 45 | out.normal = uniforms.localToView * skinnedNormal; 46 | return out; 47 | } 48 | 49 | vertex ColorInOut depthnormals_vertex( Vertex vert [[stage_in]], 50 | constant Uniforms& uniforms [[ buffer(5) ]]) 51 | { 52 | ColorInOut out; 53 | 54 | float4 in_position = float4( vert.position.xyz, 1.0 ); 55 | float4 in_normal = float4( vert.normal.xyz, 0.0 ); 56 | out.position = uniforms.localToClip * in_position; 57 | out.mvPosition = uniforms.localToView * in_position; 58 | out.normal = uniforms.localToView * in_normal; 59 | return out; 60 | } 61 | 62 | fragment float4 depthnormals_fragment( ColorInOut in [[stage_in]] ) 63 | { 64 | float linearDepth = in.mvPosition.z; 65 | 66 | return float4( linearDepth, in.normal.xyz ); 67 | } 68 | -------------------------------------------------------------------------------- /Engine/Assets/MetalCommon.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | struct Uniforms 4 | { 5 | matrix_float4x4 localToClip; 6 | matrix_float4x4 localToView; 7 | matrix_float4x4 localToWorld; 8 | matrix_float4x4 localToShadowClip; 9 | matrix_float4x4 clipToView; 10 | matrix_float4x4 viewToClip; 11 | float4 lightPosition; 12 | float4 lightDirection; 13 | float4 lightColor; 14 | float lightConeAngle; 15 | int lightType; // 0: None, 1: Spot, 2: Dir, 3: Point 16 | float minAmbient; 17 | uint maxNumLightsPerTile; 18 | uint windowWidth; 19 | uint windowHeight; 20 | uint numLights; // 16 bits for point light count, 16 for spot light count 21 | float f0; 22 | float4 tex0scaleOffset; 23 | float4 tilesXY; 24 | matrix_float4x4 boneMatrices[ 80 ]; 25 | int isVR; 26 | int kernelSize; 27 | float2 bloomParams; 28 | float4 kernelOffsets[ 16 ]; 29 | float4 cameraParams; // .x: fov (radians), .y: aspect, .z: near, .w: far 30 | float4 particleColor; 31 | int particleCount; 32 | int particleReset; // If 1, particle is reset. 0 otherwise. 33 | float timeStamp; // In seconds. 34 | float roughness; 35 | float alphaThreshold; 36 | }; 37 | 38 | static float linstep( float low, float high, float v ) 39 | { 40 | return clamp( (v - low) / (high - low), 0.0f, 1.0f ); 41 | } 42 | 43 | static constexpr sampler shadowSampler( coord::normalized, address::clamp_to_zero, filter::linear, mip_filter::linear ); 44 | 45 | static float VSM( texture2d shadowMap, float4 projCoord, float depth, int lightType ) 46 | { 47 | float2 uv = (projCoord.xy / projCoord.w) * 0.5f + 0.5f; 48 | uv.y = 1.0f - uv.y; 49 | 50 | // Spot light 51 | if (lightType == 1 && (uv.x < 0 || uv.x > 1 || uv.y < 0 || uv.y > 1 || depth < 0 || depth > 1)) 52 | { 53 | return 0; 54 | } 55 | 56 | // Directional light 57 | if (lightType == 2 && (uv.x < 0 || uv.x > 1 || uv.y < 0 || uv.y > 1 || depth < 0 || depth > 1)) 58 | { 59 | return 1; 60 | } 61 | 62 | float2 moments = shadowMap.sample( shadowSampler, uv ).rg; 63 | 64 | float variance = max( moments.y - moments.x * moments.x, -0.001f ); 65 | 66 | float delta = depth - moments.x; 67 | float p = smoothstep( depth - 0.001f, depth, moments.x ); // modifying - 0.001f controls intensity. 68 | float pMax = linstep( 0.2f, 1.0f, variance / (variance + delta * delta) ); 69 | 70 | return clamp( max( p, pMax ), 0.0f, 1.0f ); 71 | } 72 | 73 | static float VSMPoint( texturecube shadowMap, float4 projCoord, float depth, int lightType ) 74 | { 75 | float3 uv = (projCoord.xyz / projCoord.w) * 0.5f + 0.5f; 76 | uv.y = 1.0f - uv.y; 77 | 78 | float2 moments = shadowMap.sample( shadowSampler, uv ).rg; 79 | 80 | float variance = max( moments.y - moments.x * moments.x, -0.001f ); 81 | 82 | float delta = depth - moments.x; 83 | float p = smoothstep( depth - 0.02f, depth, moments.x ); 84 | float pMax = linstep( 0.2f, 1.0f, variance / (variance + delta * delta) ); 85 | 86 | return clamp( max( p, pMax ), 0.0f, 1.0f ); 87 | } 88 | -------------------------------------------------------------------------------- /Engine/Assets/SDF.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct Uniforms 7 | { 8 | matrix_float4x4 localToClip; 9 | }; 10 | 11 | struct Vertex 12 | { 13 | float3 position [[attribute(0)]]; 14 | float2 texcoord [[attribute(1)]]; 15 | float4 color [[attribute(2)]]; 16 | }; 17 | 18 | struct ColorInOut 19 | { 20 | float4 position [[position]]; 21 | half4 color; 22 | float2 texCoords; 23 | }; 24 | 25 | constexpr sampler s( coord::normalized, address::repeat, filter::linear ); 26 | 27 | vertex ColorInOut sdf_vertex( Vertex vert [[stage_in]], 28 | constant Uniforms& uniforms [[ buffer(5) ]]) 29 | { 30 | ColorInOut out; 31 | 32 | float4 in_position = float4( vert.position, 1.0 ); 33 | out.position = uniforms.localToClip * in_position; 34 | 35 | out.color = half4( vert.color ); 36 | out.texCoords = vert.texcoord; 37 | return out; 38 | } 39 | 40 | fragment half4 sdf_fragment( ColorInOut in [[stage_in]], 41 | texture2d texture [[texture(0)]] ) 42 | { 43 | const float edgeDistance = 0.5; 44 | float distance = half4(texture.sample(s, in.texCoords)).r; 45 | float edgeWidth = 0.7f * length( float2( dfdx( distance ), dfdy( distance ) ) ); 46 | float opacity = smoothstep( edgeDistance - edgeWidth, edgeDistance + edgeWidth, distance ); 47 | 48 | return half4( in.color.rgb, opacity ); 49 | } 50 | -------------------------------------------------------------------------------- /Engine/Assets/Skybox.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | struct Uniforms 7 | { 8 | matrix_float4x4 localToClip; 9 | }; 10 | 11 | struct ColorInOut 12 | { 13 | float4 position [[position]]; 14 | //half4 color; 15 | float3 texCoords; 16 | }; 17 | 18 | struct Vertex 19 | { 20 | float3 position [[attribute(0)]]; 21 | float2 texcoord [[attribute(1)]]; 22 | }; 23 | 24 | constexpr sampler samp( coord::normalized, address::repeat, filter::linear ); 25 | 26 | vertex ColorInOut skybox_vertex( Vertex vert [[stage_in]], 27 | constant Uniforms& uniforms [[ buffer(5) ]]) 28 | { 29 | ColorInOut out; 30 | 31 | float4 in_position = float4( vert.position, 1.0 ); 32 | out.position = uniforms.localToClip * in_position; 33 | 34 | out.texCoords = vert.position; 35 | return out; 36 | } 37 | 38 | fragment half4 skybox_fragment( ColorInOut in [[stage_in]], 39 | texturecube texture [[texture(4)]] ) 40 | { 41 | half4 sampledColor = half4( texture.sample( samp, in.texCoords ) ); 42 | return half4(sampledColor); 43 | } 44 | -------------------------------------------------------------------------------- /Engine/Assets/SpriteShader.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | #include "MetalCommon.h" 7 | 8 | struct Vertex 9 | { 10 | float3 position [[attribute(0)]]; 11 | float2 texcoord [[attribute(1)]]; 12 | float4 color [[attribute(2)]]; 13 | }; 14 | 15 | struct ColorInOut 16 | { 17 | float4 position [[position]]; 18 | half4 color; 19 | float2 texCoords; 20 | }; 21 | 22 | constexpr sampler s( coord::normalized, address::repeat, filter::linear ); 23 | 24 | vertex ColorInOut sprite_vertex(Vertex vert [[stage_in]], 25 | constant Uniforms& uniforms [[ buffer(5) ]]) 26 | { 27 | ColorInOut out; 28 | 29 | float4 in_position = float4( float3( vert.position ), 1.0 ); 30 | out.position = uniforms.localToClip * in_position; 31 | 32 | out.color = half4( vert.color * uniforms.lightColor ); 33 | out.texCoords = vert.texcoord; 34 | return out; 35 | } 36 | 37 | fragment half4 sprite_fragment(ColorInOut in [[stage_in]], 38 | texture2d texture [[texture(0)]]) 39 | { 40 | half4 sampledColor = half4( texture.sample( s, in.texCoords ) ) * in.color; 41 | return half4( sampledColor ); 42 | } 43 | -------------------------------------------------------------------------------- /Engine/Assets/Unlit.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | #include "MetalCommon.h" 7 | 8 | struct ColorInOut 9 | { 10 | float4 position [[position]]; 11 | float4 tintColor; 12 | float4 projCoord; 13 | float2 texCoords; 14 | half4 color; 15 | }; 16 | 17 | struct Vertex 18 | { 19 | float3 position [[attribute(0)]]; 20 | float2 texcoord [[attribute(1)]]; 21 | float4 color [[attribute(2)]]; 22 | }; 23 | 24 | vertex ColorInOut unlit_vertex(Vertex vert [[stage_in]], 25 | constant Uniforms& uniforms [[ buffer(5) ]]) 26 | { 27 | ColorInOut out; 28 | 29 | float4 in_position = float4( vert.position, 1.0 ); 30 | 31 | out.position = uniforms.localToClip * in_position; 32 | out.color = half4( vert.color ); 33 | out.texCoords = vert.texcoord * uniforms.tex0scaleOffset.xy + uniforms.tex0scaleOffset.wz; 34 | out.tintColor = float4( 1, 1, 1, 1 ); 35 | out.projCoord = uniforms.localToShadowClip * in_position; 36 | return out; 37 | } 38 | 39 | fragment float4 unlit_fragment( ColorInOut in [[stage_in]], 40 | texture2d textureMap [[texture(0)]], 41 | texture2d _ShadowMap [[texture(3)]], 42 | texturecube _ShadowMapCube [[texture(2)]], 43 | constant Uniforms& uniforms [[ buffer(5) ]], 44 | sampler sampler0 [[sampler(0)]] ) 45 | { 46 | float4 sampledColor = textureMap.sample( sampler0, in.texCoords ) * in.tintColor; 47 | 48 | float depth = in.projCoord.z / in.projCoord.w; 49 | 50 | if (uniforms.lightType == 2) 51 | { 52 | depth = depth * 0.5f + 0.5f; 53 | } 54 | 55 | float shadow = uniforms.lightType == 0 ? 1.0f : max( uniforms.minAmbient, VSM( _ShadowMap, in.projCoord, depth, uniforms.lightType ) ); 56 | 57 | return sampledColor * float4( shadow, shadow, shadow, 1 ); 58 | } 59 | -------------------------------------------------------------------------------- /Engine/Assets/UnlitSkin.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace metal; 5 | 6 | #include "MetalCommon.h" 7 | 8 | //float linstep( float low, float high, float v ); 9 | float VSM( texture2d shadowMap, float4 projCoord, float depth, int lightType ); 10 | 11 | struct ColorInOut 12 | { 13 | float4 position [[position]]; 14 | float4 tintColor; 15 | float4 projCoord; 16 | float2 texCoords; 17 | half4 color; 18 | }; 19 | 20 | struct Vertex 21 | { 22 | float3 position [[attribute(0)]]; 23 | float2 texcoord [[attribute(1)]]; 24 | float4 color [[attribute(2)]]; 25 | 26 | int4 boneIndex [[attribute(5)]]; 27 | float4 boneWeights [[attribute(6)]]; 28 | }; 29 | 30 | vertex ColorInOut unlit_skin_vertex(Vertex vert [[stage_in]], 31 | constant Uniforms& uniforms [[ buffer(5) ]]) 32 | { 33 | ColorInOut out; 34 | 35 | matrix_float4x4 boneTransform = uniforms.boneMatrices[ vert.boneIndex.x ] * vert.boneWeights.x + 36 | uniforms.boneMatrices[ vert.boneIndex.y ] * vert.boneWeights.y + 37 | uniforms.boneMatrices[ vert.boneIndex.z ] * vert.boneWeights.z + 38 | uniforms.boneMatrices[ vert.boneIndex.w ] * vert.boneWeights.w; 39 | 40 | float4 in_position = float4( vert.position, 1.0 ); 41 | float4 position2 = boneTransform * in_position; 42 | out.position = uniforms.localToClip * position2; 43 | 44 | out.color = half4( vert.color ); 45 | out.texCoords = vert.texcoord; 46 | out.tintColor = float4( 1, 1, 1, 1 ); 47 | out.projCoord = uniforms.localToShadowClip * in_position; 48 | return out; 49 | } 50 | 51 | fragment float4 unlit_skin_fragment( ColorInOut in [[stage_in]], 52 | texture2d textureMap [[texture(0)]], 53 | texture2d _ShadowMap [[texture(1)]], 54 | sampler sampler0 [[sampler(0)]], 55 | constant Uniforms& uniforms [[ buffer(5) ]] ) 56 | { 57 | float4 sampledColor = textureMap.sample( sampler0, in.texCoords ) * in.tintColor; 58 | 59 | float depth = in.projCoord.z / in.projCoord.w; 60 | depth = depth * 0.5f + 0.5f; 61 | float shadow = max( uniforms.minAmbient, VSM( _ShadowMap, in.projCoord, depth, uniforms.lightType ) ); 62 | 63 | return sampledColor * float4( shadow, shadow, shadow, 1 ); 64 | } 65 | -------------------------------------------------------------------------------- /Engine/Assets/dxc.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/Assets/dxc.exe -------------------------------------------------------------------------------- /Engine/Assets/dxil.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/Assets/dxil.dll -------------------------------------------------------------------------------- /Engine/Assets/glider.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/Assets/glider.ico -------------------------------------------------------------------------------- /Engine/Assets/glider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/Assets/glider.png -------------------------------------------------------------------------------- /Engine/Assets/hlsl/Bloom.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | groupshared uint helper[ 128 ]; 4 | 5 | [numthreads( 8, 8, 1 )] 6 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 7 | { 8 | const float4 color = tex.Load( uint3( globalIdx.x * 2, globalIdx.y * 2, 0 ) ); 9 | const float luminance = dot( color.rgb, float3( 0.2126f, 0.7152f, 0.0722f ) ); 10 | const float luminanceThreshold = bloomParams.x; 11 | const float4 finalColor = luminance > luminanceThreshold ? color * bloomParams.y : float4( 0, 0, 0, 0 ); 12 | 13 | rwTexture[ globalIdx.xy ] = finalColor; 14 | } 15 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/Blur.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | groupshared uint helper[ 128 ]; 4 | 5 | [numthreads( 8, 8, 1 )] 6 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 7 | { 8 | float weights[ 5 ] = { 0.227027, 0.1945946, 0.1216216, 0.054054, 0.016216 }; 9 | float4 accumColor = tex.Load( uint3( globalIdx.x, globalIdx.y, 0 ) ) * weights[ 0 ]; 10 | 11 | for (int x = 1; x < 5; ++x) 12 | { 13 | accumColor += tex.Load( uint3(globalIdx.x + x * tilesXY.z, globalIdx.y + x * tilesXY.w, 0) ) * weights[ x ]; 14 | accumColor += tex.Load( uint3( globalIdx.x - x * tilesXY.z, globalIdx.y - x * tilesXY.w, 0 ) ) * weights[ x ]; 15 | } 16 | 17 | rwTexture[ globalIdx.xy ] = accumColor; 18 | } 19 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/Standard_skin_vert.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | struct VS_INPUT 4 | { 5 | float3 pos : POSITION; 6 | float2 uv : TEXCOORD0; 7 | float4 color : COLOR; 8 | float3 normal : NORMAL; 9 | float4 tangent : TANGENT; 10 | float4 boneWeights : WEIGHTS; 11 | uint4 boneIndex : BONES; 12 | }; 13 | 14 | struct PS_INPUT 15 | { 16 | float4 pos : SV_Position; 17 | float4 positionVS_u : TEXCOORD0; 18 | float4 positionWS_v : TEXCOORD1; 19 | float3 tangentVS : TANGENT; 20 | float3 bitangentVS : BINORMAL; 21 | float3 normalVS : NORMAL; 22 | float4 projCoord : TEXCOORD2; 23 | }; 24 | 25 | PS_INPUT main( VS_INPUT input ) 26 | { 27 | matrix boneTransform = boneMatrices[ input.boneIndex.x ] * input.boneWeights.x + 28 | boneMatrices[ input.boneIndex.y ] * input.boneWeights.y + 29 | boneMatrices[ input.boneIndex.z ] * input.boneWeights.z + 30 | boneMatrices[ input.boneIndex.w ] * input.boneWeights.w; 31 | const float4 position = mul( boneTransform, float4( input.pos, 1.0f ) ); 32 | const float4 normal = mul( boneTransform, float4( input.normal, 0.0f ) ); 33 | const float4 tangent = mul( boneTransform, float4( input.tangent.xyz, 0.0f ) ); 34 | 35 | PS_INPUT output = (PS_INPUT)0; 36 | 37 | output.pos = mul( localToClip, position ); 38 | output.positionVS_u = float4( mul( localToView, position ).xyz, input.uv.x ); 39 | output.positionWS_v = float4( mul( localToWorld, position ).xyz, input.uv.y ); 40 | output.normalVS = mul( localToView, normal ).xyz; 41 | output.tangentVS = mul( localToView, float4( tangent.xyz, 0 ) ).xyz; 42 | float3 ct = cross( normal.xyz, tangent.xyz ) * input.tangent.w; 43 | output.bitangentVS.xyz = mul( localToView, float4( ct, 0 ) ).xyz; 44 | 45 | return output; 46 | } 47 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/Standard_vert.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | struct VS_INPUT 4 | { 5 | float3 pos : POSITION; 6 | float2 uv : TEXCOORD0; 7 | float4 color : COLOR; 8 | float3 normal : NORMAL; 9 | float4 tangent : TANGENT; 10 | }; 11 | 12 | struct PS_INPUT 13 | { 14 | float4 pos : SV_Position; 15 | float4 positionVS_u : TEXCOORD0; 16 | float4 positionWS_v : TEXCOORD1; 17 | float3 tangentVS : TANGENT; 18 | float3 bitangentVS : BINORMAL; 19 | float3 normalVS : NORMAL; 20 | float4 projCoord : TEXCOORD2; 21 | }; 22 | 23 | PS_INPUT main( VS_INPUT input ) 24 | { 25 | PS_INPUT output = (PS_INPUT)0; 26 | float4 position = float4( input.pos, 1.0f ); 27 | 28 | output.pos = mul( localToClip, position ); 29 | output.positionVS_u = float4( mul( localToView, position ).xyz, input.uv.x ); 30 | output.positionWS_v = float4( mul( localToWorld, position ).xyz, input.uv.y ); 31 | output.normalVS = mul( localToView, float4(input.normal, 0) ).xyz; 32 | output.tangentVS = mul( localToView, float4(input.tangent.xyz, 0) ).xyz; 33 | output.projCoord = mul( localToShadowClip, float4( input.pos, 1.0 ) ); 34 | //float3 ct = cross( input.normal, input.tangent.xyz ) * input.tangent.w; 35 | // FIXME: This is not what MikkTSpace does, it does the above version! But the renderer is not yet 36 | // fully MikkTSpace compatible, and this is needed to get light direction working correctly. 37 | float3 ct = cross( input.tangent.xyz, input.normal ) * input.tangent.w; 38 | output.bitangentVS.xyz = mul( localToView, float4( ct, 0 ) ).xyz; 39 | 40 | return output; 41 | } 42 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/compose.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | [numthreads( 8, 8, 1 )] 4 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 5 | { 6 | float4 color = tex.Load( uint3( globalIdx.x, globalIdx.y, 0 ) ) * specularTex.Load( uint3( globalIdx.x, globalIdx.y, 0 ) ); 7 | 8 | rwTexture[ globalIdx.xy ] = color; 9 | } 10 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/depthnormals_frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float3 mvPosition : POSITION; 5 | float3 normal : NORMAL; 6 | }; 7 | 8 | float4 main( VSOutput vsOut ) : SV_Target 9 | { 10 | float linearDepth = vsOut.mvPosition.z; 11 | return float4( linearDepth, vsOut.normal ); 12 | } 13 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/depthnormals_skin_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float3 mvPosition : POSITION; 5 | float3 normal : NORMAL; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float3 normal : NORMAL, float4 tangent : TANGENT, float4 color : COLOR, float4 boneWeights : WEIGHTS, uint4 boneIndex : BONES ) 11 | { 12 | VSOutput vsOut; 13 | matrix boneTransform = boneMatrices[ boneIndex.x ] * boneWeights.x + 14 | boneMatrices[ boneIndex.y ] * boneWeights.y + 15 | boneMatrices[ boneIndex.z ] * boneWeights.z + 16 | boneMatrices[ boneIndex.w ] * boneWeights.w; 17 | const float4 position2 = mul( boneTransform, float4( pos, 1.0f ) ); 18 | const float4 normal2 = mul( boneTransform, float4( normal, 0.0f ) ); 19 | 20 | vsOut.pos = mul( localToClip, position2 ); 21 | vsOut.mvPosition = mul( localToView, position2 ).xyz; 22 | vsOut.normal = mul( localToView, normal2 ).xyz; 23 | return vsOut; 24 | } 25 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/depthnormals_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float3 mvPosition : POSITION; 5 | float3 normal : NORMAL; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | VSOutput main( float3 pos : POSITION, float3 normal : NORMAL ) 11 | { 12 | VSOutput vsOut; 13 | vsOut.pos = mul( localToClip, float4( pos, 1.0 ) ); 14 | vsOut.mvPosition = mul( localToView, float4( pos, 1.0 ) ).xyz; 15 | vsOut.normal = mul( localToView, float4( normal, 0.0 ) ).xyz; 16 | return vsOut; 17 | } 18 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/moments_alphatest_frag.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | struct VSOutput 4 | { 5 | float4 pos : SV_Position; 6 | float2 uv : TEXCOORD; 7 | }; 8 | 9 | float4 main( VSOutput vsOut ) : SV_Target 10 | { 11 | float linearDepth = vsOut.pos.z; 12 | 13 | float dx = ddx( linearDepth ); 14 | float dy = ddy( linearDepth ); 15 | 16 | float moment1 = linearDepth; 17 | float moment2 = linearDepth * linearDepth + 0.25f * (dx * dx + dy * dy); 18 | 19 | float alphaTest = tex.Sample( sLinear, vsOut.uv ).r; 20 | 21 | return alphaTest > alphaThreshold ? float4( moment1, moment2, 0.0f, 1.0f ) : float4( 1, 1, 0, 0 ); 22 | } 23 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/moments_frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | }; 6 | 7 | float4 main( VSOutput vsOut ) : SV_Target 8 | { 9 | float linearDepth = vsOut.pos.z; 10 | 11 | float dx = ddx( linearDepth ); 12 | float dy = ddy( linearDepth ); 13 | 14 | float moment1 = linearDepth; 15 | float moment2 = linearDepth * linearDepth + 0.25f * (dx * dx + dy * dy); 16 | 17 | return float4( moment1, moment2, 0.0f, 1.0f ); 18 | } 19 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/moments_skin_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | }; 6 | 7 | #include "ubo.h" 8 | 9 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float3 nor : NORMAL, float4 tangent : TANGENT, float4 color : COLOR, float4 boneWeights : WEIGHTS, uint4 boneIndex : BONES ) 10 | { 11 | VSOutput vsOut; 12 | float4 position2 = mul( boneMatrices[ boneIndex.x ], float4( pos, 1.0f ) ) * boneWeights.x; 13 | position2 += mul( boneMatrices[ boneIndex.y ], float4( pos, 1.0f ) ) * boneWeights.y; 14 | position2 += mul( boneMatrices[ boneIndex.z ], float4( pos, 1.0f ) ) * boneWeights.z; 15 | position2 += mul( boneMatrices[ boneIndex.w ], float4( pos, 1.0f ) ) * boneWeights.w; 16 | vsOut.pos = mul( localToClip, position2 ); 17 | vsOut.uv = uv; 18 | 19 | #if !VULKAN 20 | vsOut.pos.y = -vsOut.pos.y; 21 | #endif 22 | 23 | if (lightType == 2) 24 | { 25 | // Disabled to get animatedGO's shadow working on Vulkan on Linux 26 | // vsOut.pos.z = vsOut.pos.z * 0.5f + 0.5f; // -1..1 to 0..1 conversion 27 | } 28 | 29 | return vsOut; 30 | } 31 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/moments_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | }; 6 | 7 | #include "ubo.h" 8 | 9 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float3 normal : NORMAL ) 10 | { 11 | VSOutput vsOut; 12 | vsOut.uv = uv; 13 | vsOut.pos = mul( localToClip, float4( pos, 1.0f ) ); 14 | #if !VULKAN 15 | vsOut.pos.y = -vsOut.pos.y; 16 | #endif 17 | 18 | if (lightType == 2) // Directional light. 19 | { 20 | vsOut.pos.z = vsOut.pos.z * 0.5f + 0.5f; // -1..1 to 0..1 conversion 21 | } 22 | 23 | return vsOut; 24 | } 25 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/outline.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | [numthreads( 8, 8, 1 )] 4 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 5 | { 6 | // Algorithm source: https://ourmachinery.com/post/borderland-part-3-selection-highlighting/ 7 | float4 id0 = tex.GatherRed( sLinear, globalIdx.xy / float2( windowWidth, windowHeight ), int2( -2, -2 ) ); 8 | float4 id1 = tex.GatherRed( sLinear, globalIdx.xy / float2( windowWidth, windowHeight ), int2( 0, -2 ) ); 9 | float4 id2 = tex.GatherRed( sLinear, globalIdx.xy / float2( windowWidth, windowHeight ), int2( -2, 0 ) ); 10 | float4 id3 = tex.GatherRed( sLinear, globalIdx.xy / float2( windowWidth, windowHeight ), int2( 0, 0 ) ); 11 | 12 | id2.xw = id1.xy; 13 | float idCenter = id3.w; 14 | id3.w = id0.y; 15 | 16 | static const float avg_scalar = 1.f / 8.f; 17 | float a = dot( float4( id2 != idCenter ), avg_scalar ); 18 | a += dot( float4( id3 != idCenter ), avg_scalar ); 19 | 20 | // Removes a bright line that should not be there. 21 | if (globalIdx.y < 8) 22 | { 23 | a = 0; 24 | } 25 | 26 | rwTexture[ globalIdx.xy ] = a; 27 | } 28 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/particle_cull.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | #define TILE_RES 32 4 | #define MAX_NUM_PARTICLES_PER_TILE 1000 5 | #define PARTICLE_INDEX_BUFFER_SENTINEL 0x7fffffff 6 | #define NUM_THREADS_PER_TILE (TILE_RES * TILE_RES) 7 | 8 | groupshared uint ldsParticleIdxCounter; 9 | groupshared uint ldsParticlesIdx[ MAX_NUM_PARTICLES_PER_TILE ]; 10 | 11 | uint GetNumTilesX() 12 | { 13 | return (uint)((windowWidth + TILE_RES - 1) / (float)TILE_RES); 14 | } 15 | 16 | uint GetNumTilesY() 17 | { 18 | return (uint)((windowHeight + TILE_RES - 1) / (float)TILE_RES); 19 | } 20 | 21 | [numthreads( TILE_RES, TILE_RES, 1 )] 22 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 23 | { 24 | uint localIdxFlattened = localIdx.x + localIdx.y * TILE_RES; 25 | uint tileIdxFlattened = groupIdx.x + groupIdx.y * GetNumTilesX(); 26 | 27 | if (localIdxFlattened == 0) 28 | { 29 | ldsParticleIdxCounter = 0; 30 | } 31 | 32 | GroupMemoryBarrierWithGroupSync(); 33 | 34 | for (uint i = 0; i < particleCount; i += NUM_THREADS_PER_TILE) 35 | { 36 | uint il = localIdxFlattened + i; 37 | const float sizePad = particles[ il ].positionAndSize.w * 2; 38 | 39 | if (il < particleCount && 40 | particles[ il ].clipPosition.w != 666 && 41 | particles[ il ].clipPosition.x > globalIdx.x - sizePad - TILE_RES && particles[ il ].clipPosition.x < globalIdx.x + TILE_RES + sizePad && 42 | particles[ il ].clipPosition.y > globalIdx.y - sizePad - TILE_RES && particles[ il ].clipPosition.y < globalIdx.y + TILE_RES + sizePad) 43 | { 44 | uint dstIdx = 0; 45 | InterlockedAdd( ldsParticleIdxCounter, 1, dstIdx ); 46 | ldsParticlesIdx[ dstIdx ] = il; 47 | } 48 | } 49 | 50 | GroupMemoryBarrierWithGroupSync(); 51 | 52 | uint startOffset = MAX_NUM_PARTICLES_PER_TILE * tileIdxFlattened; 53 | 54 | for (uint k = localIdxFlattened; k < ldsParticleIdxCounter; k += NUM_THREADS_PER_TILE) 55 | { 56 | perTileParticleIndexBuffer[ startOffset + k ] = ldsParticlesIdx[ k ]; 57 | } 58 | 59 | if (localIdxFlattened == 0) 60 | { 61 | perTileParticleIndexBuffer[ startOffset + ldsParticleIdxCounter ] = PARTICLE_INDEX_BUFFER_SENTINEL; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/particle_draw.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | #define TILE_RES 32 4 | #define PARTICLE_INDEX_BUFFER_SENTINEL 0x7fffffff 5 | #define MAX_PARTICLES_PER_TILE 1000 6 | 7 | uint GetTileIndex( float2 screenPos ) 8 | { 9 | const float tileRes = (float)TILE_RES; 10 | uint numCellsX = (windowWidth + TILE_RES - 1) / TILE_RES; 11 | uint tileIdx = floor( screenPos.x / tileRes ) + floor( screenPos.y / tileRes ) * numCellsX; 12 | return tileIdx; 13 | } 14 | 15 | [numthreads( 8, 8, 1 )] 16 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 17 | { 18 | const uint tileIndex = GetTileIndex( globalIdx.xy ); 19 | uint index = MAX_PARTICLES_PER_TILE * tileIndex; 20 | uint nextParticleIndex = perTileParticleIndexBuffer[ index ]; 21 | 22 | float4 color = rwTexture[ globalIdx.xy ]; 23 | float depth = tex[ globalIdx.xy ].r; 24 | 25 | while (nextParticleIndex != PARTICLE_INDEX_BUFFER_SENTINEL) 26 | { 27 | uint particleIndex = nextParticleIndex; 28 | ++index; 29 | nextParticleIndex = perTileParticleIndexBuffer[ index ]; 30 | 31 | float dist = distance( particles[ particleIndex ].clipPosition.xy, globalIdx.xy ); 32 | const float radius = particles[ particleIndex ].positionAndSize.w; 33 | 34 | if (dist < radius /* && particles[particleIndex].clipPosition.z / particles[particleIndex].clipPosition.w < depth*/) 35 | { 36 | color = particles[ particleIndex ].color; 37 | } 38 | } 39 | 40 | rwTexture[ globalIdx.xy ] = color; 41 | } 42 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/particle_simulate.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | float rand_1_05( float2 uv ) 4 | { 5 | float2 nois = (frac( sin( dot( uv, float2(12.9898, 78.233) * 2.0 ) ) * 43758.5453 )); 6 | return abs( nois.x + nois.y ) * 0.5; 7 | } 8 | 9 | bool3 greaterThan( float3 a, float3 b ) 10 | { 11 | return bool3( a.x > b.x, a.y > b.y, a.z > b.z ); 12 | } 13 | 14 | [numthreads( 64, 1, 1 )] 15 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 16 | { 17 | const uint i = globalIdx.x; 18 | float2 uv = globalIdx.xy; 19 | float ra = rand_1_05( uv ); 20 | float x = 1; 21 | float4 position = float4( x * 8 * sin( globalIdx.x * 20 + timeStamp ), globalIdx.x % 20, x * 8 * cos( globalIdx.x * 20 + timeStamp ), 1 ); 22 | position = mul( localToWorld, position ); 23 | 24 | if (particleReset == 1) 25 | { 26 | particles[ i ].lifeTimeSecs = float4( timeStamp, 0, 0, 0 ); 27 | } 28 | 29 | particles[ i ].positionAndSize = position; 30 | particles[ i ].positionAndSize.w = 5; 31 | particles[ i ].color = particleColor; 32 | 33 | float4 clipPos = mul( viewToClip, position ); 34 | 35 | #if !VULKAN 36 | clipPos.y = -clipPos.y; 37 | #endif 38 | if (any( greaterThan( abs( clipPos.xyz ), float3( abs( clipPos.www ) ) ) )) 39 | { 40 | particles[ i ].clipPosition = float4( 0, 0, 0, 666 ); 41 | return; 42 | } 43 | 44 | float3 ndc = clipPos.xyz / clipPos.w; 45 | float3 unscaledWindowCoords = 0.5f * ndc + float3( 0.5f, 0.5f, 0.5f ); 46 | float3 windowCoords = float3( windowWidth * unscaledWindowCoords.x, windowHeight * unscaledWindowCoords.y, unscaledWindowCoords.z ); 47 | 48 | particles[ i ].clipPosition = float4( windowCoords.x, windowCoords.y, clipPos.z, 1 ); 49 | } 50 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/sdf_frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | }; 7 | 8 | Texture2D< float4 > tex : register(t0); 9 | SamplerState sLinear : register(s0); 10 | 11 | float4 main( VSOutput vsOut ) : SV_Target 12 | { 13 | const float edgeDistance = 0.5f; 14 | float distance = tex.Sample( sLinear, vsOut.uv ).r; 15 | float edgeWidth = 0.7f * length( float2( ddx( distance ), ddy( distance ) ) ); 16 | float opacity = smoothstep( edgeDistance - edgeWidth, edgeDistance + edgeWidth, distance ); 17 | return float4( vsOut.color.rgb, opacity ); 18 | } 19 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/sdf_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float4 color : COLOR ) 11 | { 12 | VSOutput vsOut; 13 | vsOut.pos = mul( localToClip, float4( pos, 1.0f ) ); 14 | vsOut.uv = uv; 15 | vsOut.color = color; 16 | return vsOut; 17 | } 18 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/skybox_frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float4 color : COLOR; 5 | float3 uv : TEXCOORD; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | float4 main( VSOutput vsOut ) : SV_Target 11 | { 12 | return texCube.Sample( sLinear, vsOut.uv ); 13 | } 14 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/skybox_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float4 color : COLOR; 5 | float3 uv : TEXCOORD; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float4 color : COLOR ) 11 | { 12 | VSOutput vsOut; 13 | vsOut.pos = mul( localToClip, float4( pos, 1.0f ) ); 14 | 15 | if (isVR == 1) 16 | { 17 | vsOut.pos.y = -vsOut.pos.y; 18 | } 19 | 20 | vsOut.color = color; 21 | vsOut.uv = pos.xyz; 22 | return vsOut; 23 | } 24 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/sprite_frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | float4 main( VSOutput vsOut ) : SV_Target 11 | { 12 | return tex.Sample( sLinear, vsOut.uv ) * vsOut.color; 13 | } 14 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/sprite_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float4 color : COLOR ) 11 | { 12 | VSOutput vsOut; 13 | vsOut.pos = mul( localToClip, float4( pos, 1.0f ) ); 14 | vsOut.uv = uv; 15 | vsOut.color = color * lightColor; 16 | return vsOut; 17 | } 18 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/ssao.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | float ssao( float3x3 tangentToView, float3 originPosVS, float radius, int kernelSize, uint3 globalIdx, float2 depthTexDim ) 4 | { 5 | float occlusion = 0.0f; 6 | 7 | for (int i = 0; i < kernelSize; ++i) 8 | { 9 | float3 samplePosVS = mul( tangentToView, kernelOffsets[ i ].xyz ); 10 | samplePosVS = samplePosVS * radius + originPosVS; 11 | 12 | // project sample position: 13 | float4 offset = mul( viewToClip, float4( samplePosVS, 1.0f ) ); 14 | offset.xy /= offset.w; // only need xy 15 | offset.xy = offset.xy * 0.5f + 0.5f; // scale/bias to texcoords 16 | #if !VULKAN 17 | 18 | #else 19 | offset.y = 1 - offset.y; 20 | #endif 21 | float sampleDepth = -normalTex.Load( int3( offset.xy * depthTexDim, 0 ) ).r; 22 | 23 | float diff = abs( originPosVS.z - sampleDepth ); 24 | if (diff < 0.0001f) 25 | { 26 | occlusion += sampleDepth < samplePosVS.z ? 1.0f : 0.0f; 27 | continue; 28 | } 29 | 30 | float rangeCheck = smoothstep( 0.0f, 1.0f, radius / diff ); 31 | occlusion += (sampleDepth < (samplePosVS.z - 0.025f) ? 1.0f : 0.0f) * rangeCheck; 32 | } 33 | 34 | occlusion = 1.0f - (occlusion / float( kernelSize )); 35 | float uPower = 1.8f; 36 | //return pow( abs( occlusion ), uPower ); 37 | return pow( max( abs( occlusion ), 0.3f ), uPower ); 38 | } 39 | 40 | [numthreads( 8, 8, 1 )] 41 | void CSMain( uint3 globalIdx : SV_DispatchThreadID, uint3 localIdx : SV_GroupThreadID, uint3 groupIdx : SV_GroupID ) 42 | { 43 | int depthWidth, depthHeight; 44 | normalTex.GetDimensions( depthWidth, depthHeight ); 45 | 46 | int noiseWidth, noiseHeight; 47 | specularTex.GetDimensions( noiseWidth, noiseHeight ); 48 | 49 | //float2 noiseTexCoords = float2( float( depthWidth ) / float( noiseWidth ), float( depthHeight ) / float( noiseHeight ) ); 50 | 51 | float2 uv = (float2( globalIdx.xy ) + 0.5f) / float2( depthWidth, depthHeight ); 52 | // get view space origin: 53 | float originDepth = -normalTex.Load( int3( globalIdx.xy, 0 ) ).r; 54 | float uTanHalfFov = tan( cameraParams.x * 0.5f ); 55 | float uAspectRatio = depthWidth / (float)depthHeight; 56 | float2 xy = uv * 2 - 1; 57 | //noiseTexCoords *= uv; 58 | 59 | float3 viewDirection = float3( -xy.x * uTanHalfFov * uAspectRatio, -xy.y * uTanHalfFov, 1.0f ); 60 | float3 originPosVS = viewDirection * originDepth; 61 | 62 | // get view space normal: 63 | float3 normal = -normalize( normalTex.Load( int3( globalIdx.xy, 0 ) ).gba ); 64 | 65 | // construct kernel basis matrix: 66 | float3 rvec = normalize( specularTex.Load( int3( globalIdx.x % noiseWidth, globalIdx.y % noiseHeight, 0 ) ).rgb ); 67 | //float3 rvec = normalize( specularTex.Sample( sampler1, noiseTexCoords ).rgb ); 68 | float3 tangent = normalize( rvec - normal * dot( rvec, normal ) ); 69 | float3 bitangent = cross( tangent, normal ); 70 | float3x3 tangentToView = transpose( float3x3( tangent, bitangent, normal ) ); 71 | 72 | float s = ssao( tangentToView, originPosVS, 0.5f, 16, globalIdx, float2( depthWidth, depthHeight ) ); 73 | float4 color = float4( 1, 1, 1, 1 ); 74 | 75 | rwTexture[ globalIdx.xy ] = color * s; 76 | } 77 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/unlit_cube_frag.hlsl: -------------------------------------------------------------------------------- 1 | #include "ubo.h" 2 | 3 | struct VSOutput 4 | { 5 | float4 pos : SV_POSITION; 6 | float3 uv : TEXCOORD; 7 | float4 color : COLOR; 8 | }; 9 | 10 | float4 main( VSOutput vsOut ) : SV_Target 11 | { 12 | return texCube.Sample( sLinear, vsOut.uv ); 13 | } 14 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/unlit_cube_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_POSITION; 4 | float3 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | }; 7 | 8 | #include "ubo.h" 9 | 10 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float4 color : COLOR ) 11 | { 12 | VSOutput vsOut; 13 | vsOut.pos = mul( localToClip, float4( pos, 1.0 ) ); 14 | vsOut.uv = pos; 15 | vsOut.color = color; 16 | return vsOut; 17 | } 18 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/unlit_frag.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_POSITION; 4 | float2 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | float4 projCoord : TANGENT; 7 | }; 8 | 9 | #include "ubo.h" 10 | 11 | float linstep( float low, float high, float v ) 12 | { 13 | return saturate( (v - low) / (high - low) ); 14 | } 15 | 16 | float VSM( float depth, float4 projCoord ) 17 | { 18 | float2 uv = projCoord.xy / projCoord.w; 19 | 20 | // Spot light 21 | if (lightType == 1 && (uv.x < 0 || uv.x > 1 || uv.y < 0 || uv.y > 1)) 22 | { 23 | return 0; 24 | } 25 | 26 | if (lightType == 1 && (depth < 0 || depth > 1)) 27 | { 28 | return 0; 29 | } 30 | 31 | float2 moments = shadowTex.SampleLevel( sLinear, uv, 0 ).rg; 32 | 33 | float variance = max( moments.y - moments.x * moments.x, -0.001f ); 34 | 35 | float delta = depth - moments.x; 36 | float p = smoothstep( depth - 0.01f, depth, moments.x ); 37 | float pMax = linstep( minAmbient, 1.0f, variance / (variance + delta * delta) ); 38 | 39 | return saturate( max( p, pMax ) ); 40 | } 41 | 42 | float4 main( VSOutput vsOut ) : SV_Target 43 | { 44 | float depth = vsOut.projCoord.z / vsOut.projCoord.w; 45 | 46 | float shadow = lightType == 0 ? 1.0f : max( minAmbient, VSM( depth, vsOut.projCoord ) ); 47 | float4 texColor = tex.Sample( sLinear, vsOut.uv ); 48 | float4 outColor = texColor * shadow; 49 | outColor.a = texColor.a; 50 | return outColor; 51 | } 52 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/unlit_skin_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_Position; 4 | float2 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | float4 projCoord : TANGENT; 7 | }; 8 | 9 | #include "ubo.h" 10 | 11 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float3 nor : NORMAL, float4 tangent : TANGENT, float4 color : COLOR, float4 boneWeights : WEIGHTS, uint4 boneIndex : BONES ) 12 | { 13 | matrix boneTransform = boneMatrices[ boneIndex.x ] * boneWeights.x + 14 | boneMatrices[ boneIndex.y ] * boneWeights.y + 15 | boneMatrices[ boneIndex.z ] * boneWeights.z + 16 | boneMatrices[ boneIndex.w ] * boneWeights.w; 17 | const float4 position2 = mul( boneTransform, float4( pos, 1.0f ) ); 18 | 19 | VSOutput vsOut; 20 | vsOut.pos = mul( localToClip, position2 ); 21 | 22 | if (isVR == 1) 23 | { 24 | vsOut.pos.y = -vsOut.pos.y; 25 | } 26 | 27 | vsOut.uv = uv; 28 | vsOut.color = color; 29 | vsOut.projCoord = mul( localToShadowClip, position2 ); 30 | return vsOut; 31 | } 32 | -------------------------------------------------------------------------------- /Engine/Assets/hlsl/unlit_vert.hlsl: -------------------------------------------------------------------------------- 1 | struct VSOutput 2 | { 3 | float4 pos : SV_POSITION; 4 | float2 uv : TEXCOORD; 5 | float4 color : COLOR; 6 | float4 projCoord : TANGENT; 7 | }; 8 | 9 | #include "ubo.h" 10 | 11 | VSOutput main( float3 pos : POSITION, float2 uv : TEXCOORD, float4 color : COLOR ) 12 | { 13 | VSOutput vsOut; 14 | vsOut.pos = mul( localToClip, float4( pos, 1.0 ) ); 15 | 16 | if (isVR == 1) 17 | { 18 | vsOut.pos.y = -vsOut.pos.y; 19 | } 20 | 21 | vsOut.uv = uv; 22 | vsOut.color = color; 23 | vsOut.projCoord = mul( localToShadowClip, float4( pos, 1.0 ) ); 24 | return vsOut; 25 | } 26 | -------------------------------------------------------------------------------- /Engine/Assets/outline.metal: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | using namespace metal; 6 | #include "MetalCommon.h" 7 | 8 | constexpr sampler sLinear( coord::normalized, address::repeat, filter::linear ); 9 | 10 | kernel void outline(texture2d colorTexture [[texture(0)]], 11 | texture2d outlineTexture [[texture(1)]], 12 | constant Uniforms& uniforms [[ buffer(0) ]], 13 | ushort2 gid [[thread_position_in_grid]], 14 | ushort2 tid [[thread_position_in_threadgroup]], 15 | ushort2 dtid [[threadgroup_position_in_grid]]) 16 | { 17 | // Algorithm source: https://ourmachinery.com/post/borderland-part-3-selection-highlighting/ 18 | float2 uv = (float2)gid.xy / float2( uniforms.windowWidth, uniforms.windowHeight ); 19 | float4 id0 = colorTexture.gather( sLinear, uv, int2( -2, -2 ) ); 20 | float4 id1 = colorTexture.gather( sLinear, uv, int2( 0, -2 ) ); 21 | float4 id2 = colorTexture.gather( sLinear, uv, int2( -2, 0 ) ); 22 | float4 id3 = colorTexture.gather( sLinear, uv, int2( 0, 0 ) ); 23 | 24 | id2.xw = id1.xy; 25 | float idCenter = id3.w; 26 | id3.w = id0.y; 27 | 28 | const float avg_scalar = 1.f / 8.f; 29 | float a = dot( float4( id2 != idCenter ), avg_scalar ); 30 | a += dot( float4( id3 != idCenter ), avg_scalar ); 31 | 32 | outlineTexture.write( a, gid.xy ); 33 | } 34 | -------------------------------------------------------------------------------- /Engine/Assets/sample.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/Assets/sample.jpg -------------------------------------------------------------------------------- /Engine/Components/AudioSourceComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioSourceComponent.hpp" 2 | #include "AudioSystem.hpp" 3 | #include 4 | 5 | static constexpr int MaxComponents = 30; 6 | 7 | ae3d::AudioSourceComponent audioSourceComponents[ MaxComponents ]; 8 | unsigned nextFreeAudioSourceComponent = 0; 9 | 10 | unsigned ae3d::AudioSourceComponent::New() 11 | { 12 | if (nextFreeAudioSourceComponent == MaxComponents - 1) 13 | { 14 | return nextFreeAudioSourceComponent; 15 | } 16 | 17 | return nextFreeAudioSourceComponent++; 18 | } 19 | 20 | ae3d::AudioSourceComponent* ae3d::AudioSourceComponent::Get( unsigned index ) 21 | { 22 | return &audioSourceComponents[ index ]; 23 | } 24 | 25 | void ae3d::AudioSourceComponent::SetClipId( unsigned audioClipId ) 26 | { 27 | clipId = audioClipId; 28 | } 29 | 30 | void ae3d::AudioSourceComponent::Play() const 31 | { 32 | if (isEnabled) 33 | { 34 | AudioSystem::Play( clipId, isLooping ); 35 | } 36 | } 37 | 38 | std::string GetSerialized( ae3d::AudioSourceComponent* component ) 39 | { 40 | std::string str( "audiosource\n" ); 41 | str += std::to_string( component->GetClipId() ) + "\n"; 42 | str += "3d " + std::to_string( component->Is3D() ? 1 : 0 ) + "\n"; 43 | str += "enabled " + std::to_string( (int)component->IsEnabled() ) + "\n\n\n"; 44 | 45 | return str; 46 | } 47 | 48 | -------------------------------------------------------------------------------- /Engine/Components/DecalRendererComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "DecalRendererComponent.hpp" 2 | #include "System.hpp" 3 | #include 4 | 5 | ae3d::DecalRendererComponent::DecalRendererComponent() 6 | { 7 | 8 | } 9 | 10 | static constexpr int MaxComponents = 30; 11 | 12 | ae3d::DecalRendererComponent decalRendererComponents[ MaxComponents ]; 13 | unsigned nextFreeDecalRendererComponent = 0; 14 | 15 | unsigned ae3d::DecalRendererComponent::New() 16 | { 17 | if (nextFreeDecalRendererComponent == MaxComponents - 1) 18 | { 19 | return nextFreeDecalRendererComponent; 20 | } 21 | 22 | return nextFreeDecalRendererComponent++; 23 | } 24 | 25 | ae3d::DecalRendererComponent* ae3d::DecalRendererComponent::Get( unsigned index ) 26 | { 27 | return &decalRendererComponents[ index ]; 28 | } 29 | 30 | std::string GetSerialized( ae3d::DecalRendererComponent* component ) 31 | { 32 | std::string outStr = "decalrenderer\n"; 33 | outStr += "decalrenderer_enabled "; 34 | outStr += std::to_string( component->IsEnabled() ? 1 : 0 ); 35 | return outStr; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /Engine/Components/DirectionalLightComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "DirectionalLightComponent.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | std::vector< ae3d::DirectionalLightComponent > directionalLightComponents; 8 | unsigned nextFreeDirectionalLightComponent = 0; 9 | extern bool someLightCastsShadow; 10 | 11 | unsigned ae3d::DirectionalLightComponent::New() 12 | { 13 | if (nextFreeDirectionalLightComponent == directionalLightComponents.size()) 14 | { 15 | directionalLightComponents.resize( directionalLightComponents.size() + 10 ); 16 | } 17 | 18 | return nextFreeDirectionalLightComponent++; 19 | } 20 | 21 | ae3d::DirectionalLightComponent* ae3d::DirectionalLightComponent::Get( unsigned index ) 22 | { 23 | return &directionalLightComponents[ index ]; 24 | } 25 | 26 | void ae3d::DirectionalLightComponent::SetCastShadow( bool enable, int shadowMapSize ) 27 | { 28 | castsShadow = enable; 29 | const int mapSize = (shadowMapSize > 0 && shadowMapSize < 16385) ? shadowMapSize : 512; 30 | 31 | // TODO: create only if not already created with current size. 32 | if (castsShadow) 33 | { 34 | someLightCastsShadow = true; 35 | shadowMap.Create2D( mapSize, mapSize, DataType::R32G32, TextureWrap::Clamp, TextureFilter::Linear, "dirlight shadow", false, RenderTexture::UavFlag::Disabled ); 36 | } 37 | } 38 | 39 | std::string GetSerialized( const ae3d::DirectionalLightComponent* component ) 40 | { 41 | std::stringstream outStream; 42 | std::locale c_locale( "C" ); 43 | outStream.imbue( c_locale ); 44 | 45 | auto color = component->GetColor(); 46 | 47 | outStream << "dirlight\n"; 48 | outStream << "color " << color.x << " " << color.y << " " << color.z << "\n"; 49 | outStream << "dirlight_enabled " << component->IsEnabled() << "\n"; 50 | outStream << "shadow " << (component->CastsShadow() ? 1 : 0) << "\n\n"; 51 | return outStream.str(); 52 | } 53 | -------------------------------------------------------------------------------- /Engine/Components/LineRendererComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "LineRendererComponent.hpp" 2 | #include "System.hpp" 3 | 4 | ae3d::LineRendererComponent::LineRendererComponent() 5 | { 6 | 7 | } 8 | 9 | static constexpr int MaxComponents = 30; 10 | 11 | ae3d::LineRendererComponent lineRendererComponents[ MaxComponents ]; 12 | unsigned nextFreeLineRendererComponent = 0; 13 | 14 | unsigned ae3d::LineRendererComponent::New() 15 | { 16 | if (nextFreeLineRendererComponent == MaxComponents - 1) 17 | { 18 | return nextFreeLineRendererComponent; 19 | } 20 | 21 | return nextFreeLineRendererComponent++; 22 | } 23 | 24 | ae3d::LineRendererComponent* ae3d::LineRendererComponent::Get( unsigned index ) 25 | { 26 | return &lineRendererComponents[ index ]; 27 | } 28 | -------------------------------------------------------------------------------- /Engine/Components/PointLightComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "PointLightComponent.hpp" 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | extern bool someLightCastsShadow; 8 | std::vector< ae3d::PointLightComponent > pointLightComponents; 9 | unsigned nextFreePointLightComponent = 0; 10 | 11 | unsigned ae3d::PointLightComponent::New() 12 | { 13 | if (nextFreePointLightComponent == pointLightComponents.size()) 14 | { 15 | pointLightComponents.resize( pointLightComponents.size() + 10 ); 16 | } 17 | 18 | return nextFreePointLightComponent++; 19 | } 20 | 21 | ae3d::PointLightComponent* ae3d::PointLightComponent::Get( unsigned index ) 22 | { 23 | return &pointLightComponents[ index ]; 24 | } 25 | 26 | void ae3d::PointLightComponent::SetCastShadow( bool enable, int shadowMapSize ) 27 | { 28 | castsShadow = enable; 29 | const int mapSize = (shadowMapSize > 0 && shadowMapSize < 16385) ? shadowMapSize : 512; 30 | 31 | if (castsShadow && cachedShadowMapSize != mapSize) 32 | { 33 | someLightCastsShadow = true; 34 | cachedShadowMapSize = mapSize; 35 | shadowMap.CreateCube( mapSize, DataType::R32G32, TextureWrap::Clamp, TextureFilter::Linear, "pointlight shadow" ); 36 | } 37 | } 38 | 39 | std::string GetSerialized( ae3d::PointLightComponent* component ) 40 | { 41 | std::stringstream outStream; 42 | std::locale c_locale( "C" ); 43 | outStream.imbue( c_locale ); 44 | 45 | auto color = component->GetColor(); 46 | 47 | outStream << "pointlight\n"; 48 | outStream << "shadow " << (component->CastsShadow() ? 1 : 0) << "\n"; 49 | outStream << "radius " << component->GetRadius() << "\n"; 50 | outStream << "pointlight_enabled " << component->IsEnabled() << "\n"; 51 | outStream << "color " << color.x << " " << color.y << " " << color.z << "\n\n"; 52 | 53 | return outStream.str(); 54 | } 55 | -------------------------------------------------------------------------------- /Engine/Components/SpotLightComponent.cpp: -------------------------------------------------------------------------------- 1 | #include "SpotLightComponent.hpp" 2 | #include "System.hpp" 3 | #include 4 | 5 | extern bool someLightCastsShadow; 6 | static constexpr int MaxComponents = 100; 7 | ae3d::SpotLightComponent spotLightComponents[ MaxComponents ]; 8 | unsigned nextFreeSpotlLightComponent = 0; 9 | 10 | unsigned ae3d::SpotLightComponent::New() 11 | { 12 | System::Assert( nextFreeSpotlLightComponent < MaxComponents, "Too many spot light components!" ); 13 | 14 | if (nextFreeSpotlLightComponent == MaxComponents - 1) 15 | { 16 | return nextFreeSpotlLightComponent; 17 | } 18 | 19 | return nextFreeSpotlLightComponent++; 20 | } 21 | 22 | ae3d::SpotLightComponent* ae3d::SpotLightComponent::Get( unsigned index ) 23 | { 24 | return &spotLightComponents[ index ]; 25 | } 26 | 27 | void ae3d::SpotLightComponent::SetCastShadow( bool enable, int shadowMapSize ) 28 | { 29 | castsShadow = enable; 30 | const int mapSize = (shadowMapSize > 0 && shadowMapSize < 16385) ? shadowMapSize : 512; 31 | 32 | if (castsShadow && cachedShadowMapSize != mapSize) 33 | { 34 | someLightCastsShadow = true; 35 | cachedShadowMapSize = mapSize; 36 | shadowMap.Create2D( mapSize, mapSize, DataType::R32G32, TextureWrap::Clamp, TextureFilter::Linear, "spotlight shadow", false, RenderTexture::UavFlag::Disabled ); 37 | } 38 | } 39 | 40 | void ae3d::SpotLightComponent::SetConeAngle( float degrees ) 41 | { 42 | coneAngle = degrees; 43 | 44 | if (coneAngle < 0 || coneAngle > 180) 45 | { 46 | coneAngle = 35; 47 | } 48 | } 49 | 50 | std::string GetSerialized( const ae3d::SpotLightComponent* component ) 51 | { 52 | std::string outStr = "spotlight\nshadow "; 53 | outStr += std::to_string( component->CastsShadow() ? 1 : 0 ); 54 | outStr += "\nconeAngle "; 55 | outStr += std::to_string( component->GetConeAngle() ); 56 | outStr += "\nspotlight_enabled "; 57 | outStr += std::to_string( component->IsEnabled() ? 1 : 0 ); 58 | outStr += "\nradius "; 59 | outStr += std::to_string( component->GetRadius() ); 60 | outStr += "\ncolor "; 61 | auto color = component->GetColor(); 62 | outStr += std::to_string( color.x ); 63 | outStr += " "; 64 | outStr += std::to_string( color.y ); 65 | outStr += " "; 66 | outStr += std::to_string( color.z ); 67 | outStr += "\n\n"; 68 | 69 | return outStr; 70 | } 71 | -------------------------------------------------------------------------------- /Engine/Core/AudioClip.cpp: -------------------------------------------------------------------------------- 1 | #include "AudioClip.hpp" 2 | #include "AudioSystem.hpp" 3 | 4 | void ae3d::AudioClip::Load( const FileSystem::FileContentsData& clipData ) 5 | { 6 | handle = AudioSystem::GetClipIdForData( clipData ); 7 | length = AudioSystem::GetClipLengthForId( handle ); 8 | } 9 | -------------------------------------------------------------------------------- /Engine/Core/AudioSystem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | namespace FileSystem 6 | { 7 | struct FileContentsData; 8 | } 9 | 10 | namespace AudioSystem 11 | { 12 | /// Creates the audio device. Must be called before other methods in this namespace. 13 | void Init(); 14 | 15 | /// Releases all allocated handles and shuts down the audio system. 16 | void Deinit(); 17 | 18 | /* 19 | Loads a clip data and returns its handle that can be used to play the clip. 20 | 21 | \param clipData .wav or Ogg Vorbis audio data. 22 | \return Clip handle that can be passed to Play. 23 | */ 24 | unsigned GetClipIdForData( const FileSystem::FileContentsData& clipData ); 25 | 26 | /// \return Length in seconds. 27 | float GetClipLengthForId( unsigned handle ); 28 | 29 | /// \param clipId Clip handle from GetClipIdForData. 30 | /// \param isLooping True, if the clip should loop 31 | void Play( unsigned clipId, bool isLooping ); 32 | 33 | /// \param x X coordinate. 34 | /// \param y Y coordinate. 35 | /// \param z Z coordinate. 36 | void SetListenerPosition( float x, float y, float z ); 37 | 38 | /// \param forwardX Forward x. 39 | /// \param forwardY Forward y. 40 | /// \param forwardZ Forward z. 41 | void SetListenerOrientation( float forwardX, float forwardY, float forwardZ ); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Engine/Core/FileWatcher.cpp: -------------------------------------------------------------------------------- 1 | // This is an independent project of an individual developer. Dear PVS-Studio, please check it. 2 | // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com 3 | #include "FileWatcher.hpp" 4 | #include 5 | #include 6 | 7 | ae3d::FileWatcher fileWatcher; 8 | 9 | void ae3d::FileWatcher::AddFile( const std::string& path, void(*updateFunc)(const std::string&) ) 10 | { 11 | pathToEntry[ path ] = Entry(); 12 | pathToEntry[ path ].path = path; 13 | pathToEntry[ path ].updateFunc = updateFunc; 14 | 15 | struct stat inode; 16 | 17 | if (stat( path.c_str(), &inode ) != -1) 18 | { 19 | #if _MSC_VER 20 | tm timeinfo; 21 | localtime_s( &timeinfo, &inode.st_mtime ); 22 | tm* timeinfo2 = &timeinfo; 23 | #else 24 | const tm* timeinfo2 = std::localtime( &inode.st_mtime ); 25 | #endif 26 | pathToEntry[ path ].hour = timeinfo2->tm_hour; 27 | pathToEntry[ path ].minute = timeinfo2->tm_min; 28 | pathToEntry[ path ].second = timeinfo2->tm_sec; 29 | } 30 | } 31 | 32 | void ae3d::FileWatcher::Poll() 33 | { 34 | struct stat inode = {}; 35 | 36 | for (auto& entry : pathToEntry) 37 | { 38 | if (stat( entry.second.path.c_str(), &inode ) != -1) 39 | { 40 | #if _MSC_VER 41 | tm timeinfo; 42 | localtime_s( &timeinfo, &inode.st_mtime ); 43 | tm* timeinfo2 = &timeinfo; 44 | #else 45 | const tm* timeinfo2 = std::localtime( &inode.st_mtime ); 46 | #endif 47 | 48 | if (timeinfo2->tm_hour != entry.second.hour || timeinfo2->tm_min != entry.second.minute || timeinfo2->tm_sec != entry.second.second) 49 | { 50 | entry.second.updateFunc( entry.second.path ); 51 | entry.second.hour = timeinfo2->tm_hour; 52 | entry.second.minute = timeinfo2->tm_min; 53 | entry.second.second = timeinfo2->tm_sec; 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Engine/Core/FileWatcher.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ae3d 7 | { 8 | /** Keeps track of files and calls updateFunc when they have changed on disk. This enables asset hotloading. */ 9 | class FileWatcher 10 | { 11 | public: 12 | void AddFile( const std::string& path, void(*updateFunc)(const std::string&) ); 13 | // Scans for all watched file modification timestamps and calls updateFunc if they have been updated. 14 | void Poll(); 15 | 16 | private: 17 | struct Entry 18 | { 19 | int hour = 0; 20 | int minute = 0; 21 | int second = 0; 22 | std::string path; 23 | void(*updateFunc)(const std::string&) = nullptr; 24 | }; 25 | 26 | std::map< std::string, Entry > pathToEntry; 27 | }; 28 | } 29 | -------------------------------------------------------------------------------- /Engine/Core/MathUtil.cpp: -------------------------------------------------------------------------------- 1 | // This is an independent project of an individual developer. Dear PVS-Studio, please check it. 2 | // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com 3 | #include "Vec3.hpp" 4 | #include 5 | #include 6 | 7 | using namespace ae3d; 8 | 9 | namespace MathUtil 10 | { 11 | void GetMinMax( const Vec3* aPoints, int count, Vec3& outMin, Vec3& outMax ) 12 | { 13 | outMin = aPoints[ 0 ]; 14 | outMax = aPoints[ 0 ]; 15 | 16 | for (int i = 1, s = count; i < s; ++i) 17 | { 18 | const Vec3& point = aPoints[ i ]; 19 | 20 | if (point.x < outMin.x) 21 | { 22 | outMin.x = point.x; 23 | } 24 | 25 | if (point.y < outMin.y) 26 | { 27 | outMin.y = point.y; 28 | } 29 | 30 | if (point.z < outMin.z) 31 | { 32 | outMin.z = point.z; 33 | } 34 | 35 | if (point.x > outMax.x) 36 | { 37 | outMax.x = point.x; 38 | } 39 | 40 | if (point.y > outMax.y) 41 | { 42 | outMax.y = point.y; 43 | } 44 | 45 | if (point.z > outMax.z) 46 | { 47 | outMax.z = point.z; 48 | } 49 | } 50 | } 51 | 52 | void GetCorners( const Vec3& min, const Vec3& max, Vec3 outCorners[ 8 ] ) 53 | { 54 | outCorners[ 0 ] = Vec3( min.x, min.y, min.z ); 55 | outCorners[ 1 ] = Vec3( max.x, min.y, min.z ); 56 | outCorners[ 2 ] = Vec3( min.x, max.y, min.z ); 57 | outCorners[ 3 ] = Vec3( min.x, min.y, max.z ); 58 | outCorners[ 4 ] = Vec3( max.x, max.y, min.z ); 59 | outCorners[ 5 ] = Vec3( min.x, max.y, max.z ); 60 | outCorners[ 6 ] = Vec3( max.x, max.y, max.z ); 61 | outCorners[ 7 ] = Vec3( max.x, min.y, max.z ); 62 | } 63 | 64 | float Lerp( float start, float end, float amount ) 65 | { 66 | return (1.0f - amount) * start + amount * end; 67 | } 68 | 69 | float Random( float aMin, float aMax ) 70 | { 71 | static std::mt19937 mt( static_cast( std::time( nullptr ) ) ); 72 | std::uniform_real_distribution ud( aMin, aMax ); 73 | return ud( mt ); 74 | } 75 | 76 | float Floor( float f ) 77 | { 78 | return floorf( f ); 79 | } 80 | 81 | bool IsNaN( float f ) 82 | { 83 | return f != f; 84 | } 85 | 86 | bool IsFinite( float f ) 87 | { 88 | return isfinite( f ); 89 | } 90 | 91 | bool IsPowerOfTwo( unsigned i ) 92 | { 93 | return ((i & (i - 1)) == 0); 94 | } 95 | 96 | int Min( int x, int y ) 97 | { 98 | return x < y ? x : y; 99 | } 100 | 101 | int Max( int x, int y ) 102 | { 103 | return x > y ? x : y; 104 | } 105 | 106 | int GetMipmapCount( int width, int height ) 107 | { 108 | return 1 + static_cast< int >(floor( log2( Max( width, height ) ) )); 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /Engine/Core/MatrixNEON.cpp: -------------------------------------------------------------------------------- 1 | #if RENDERER_METAL && !(__i386__) 2 | #include "Matrix.hpp" 3 | #include 4 | #include 5 | #include 6 | #include "Vec3.hpp" 7 | 8 | using namespace ae3d; 9 | 10 | void Matrix44::Multiply( const Matrix44& ma, const Matrix44& mb, Matrix44& out ) 11 | { 12 | Matrix44 result; 13 | Matrix44 matA = ma; 14 | Matrix44 matB = mb; 15 | 16 | const float* a = matA.m; 17 | const float* b = matB.m; 18 | float32x4_t a_line, b_line, r_line; 19 | 20 | for (int i = 0; i < 16; i += 4) 21 | { 22 | // unroll the first step of the loop to avoid having to initialize r_line to zero 23 | a_line = vld1q_f32( b ); 24 | b_line = vld1q_dup_f32( &a[ i ] ); 25 | r_line = vmulq_f32( a_line, b_line ); 26 | 27 | for (int j = 1; j < 4; j++) 28 | { 29 | a_line = vld1q_f32( &b[ j * 4 ] ); 30 | b_line = vdupq_n_f32( a[ i + j ] ); 31 | r_line = vaddq_f32(vmulq_f32( a_line, b_line ), r_line); 32 | } 33 | 34 | vst1q_f32( &result.m[ i ], r_line ); 35 | } 36 | 37 | out = result; 38 | } 39 | 40 | void ae3d::Matrix44::TransformPoint( const Vec4& vec, const Matrix44& mat, Vec4* out ) 41 | { 42 | Vec4 tmp; 43 | tmp.x = mat.m[0] * vec.x + mat.m[ 4 ] * vec.y + mat.m[ 8] * vec.z + mat.m[12] * vec.w; 44 | tmp.y = mat.m[1] * vec.x + mat.m[ 5 ] * vec.y + mat.m[ 9] * vec.z + mat.m[13] * vec.w; 45 | tmp.z = mat.m[2] * vec.x + mat.m[ 6 ] * vec.y + mat.m[10] * vec.z + mat.m[14] * vec.w; 46 | tmp.w = mat.m[3] * vec.x + mat.m[ 7 ] * vec.y + mat.m[11] * vec.z + mat.m[15] * vec.w; 47 | 48 | *out = tmp; 49 | 50 | #if AE3D_CHECK_FOR_NAN 51 | ae3d::CheckNaN( mat ); 52 | #endif 53 | } 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /Engine/Core/MatrixSSE3.cpp: -------------------------------------------------------------------------------- 1 | #ifdef SIMD_SSE3 2 | #include "Matrix.hpp" 3 | #include 4 | #include "Vec3.hpp" 5 | 6 | using namespace ae3d; 7 | 8 | void Matrix44::Multiply( const Matrix44& ma, const Matrix44& mb, Matrix44& out ) 9 | { 10 | Matrix44 result; 11 | Matrix44 matA = ma; 12 | Matrix44 matB = mb; 13 | 14 | const float* a = matA.m; 15 | const float* b = matB.m; 16 | __m128 a_line, b_line, r_line; 17 | 18 | for (int i = 0; i < 16; i += 4) 19 | { 20 | // unroll the first step of the loop to avoid having to initialize r_line to zero 21 | a_line = _mm_load_ps( b ); 22 | b_line = _mm_set1_ps( a[ i ] ); 23 | r_line = _mm_mul_ps( a_line, b_line ); 24 | 25 | for (int j = 1; j < 4; j++) 26 | { 27 | a_line = _mm_load_ps( &b[ j * 4 ] ); 28 | b_line = _mm_set1_ps( a[ i + j ] ); 29 | r_line = _mm_add_ps(_mm_mul_ps( a_line, b_line ), r_line); 30 | } 31 | 32 | _mm_store_ps( &result.m[ i ], r_line ); 33 | } 34 | 35 | out = result; 36 | } 37 | 38 | void Matrix44::TransformPoint( const Vec4& vec, const Matrix44& mat, Vec4* out ) 39 | { 40 | Matrix44 transpose; 41 | mat.Transpose( transpose ); 42 | alignas( 16 ) Vec4 v4 = vec; 43 | 44 | __m128 vec4 = _mm_load_ps( &v4.x ); 45 | __m128 row1 = _mm_load_ps( &transpose.m[ 0 ] ); 46 | __m128 row2 = _mm_load_ps( &transpose.m[ 4 ] ); 47 | __m128 row3 = _mm_load_ps( &transpose.m[ 8 ] ); 48 | __m128 row4 = _mm_load_ps( &transpose.m[ 12 ] ); 49 | 50 | __m128 r1 = _mm_mul_ps( row1, vec4 ); 51 | __m128 r2 = _mm_mul_ps( row2, vec4 ); 52 | __m128 r3 = _mm_mul_ps( row3, vec4 ); 53 | __m128 r4 = _mm_mul_ps( row4, vec4 ); 54 | 55 | __m128 sum_01 = _mm_hadd_ps( r1, r2 ); 56 | __m128 sum_23 = _mm_hadd_ps( r3, r4 ); 57 | __m128 result = _mm_hadd_ps( sum_01, sum_23 ); 58 | _mm_store_ps( &out->x, result ); 59 | } 60 | #endif 61 | -------------------------------------------------------------------------------- /Engine/Core/Statistics.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace Statistics 4 | { 5 | void BeginLightCullerProfiling(); 6 | void EndLightCullerProfiling(); 7 | 8 | void BeginShadowMapProfiling(); 9 | void EndShadowMapProfiling(); 10 | 11 | void BeginDepthNormalsProfiling(); 12 | void EndDepthNormalsProfiling(); 13 | 14 | void BeginAcquireNextImageProfiling(); 15 | void EndAcquireNextImageProfiling(); 16 | float GetAcquireNextImageTimeMS(); 17 | 18 | float GetFrameTimeMS(); 19 | float GetShadowMapTimeMS(); 20 | float GetShadowMapTimeGpuMS(); 21 | float GetDepthNormalsTimeMS(); 22 | float GetDepthNormalsTimeGpuMS(); 23 | float GetSceneAABBTimeMS(); 24 | float GetLightCullerTimeGpuMS(); 25 | float GetPrimaryPassTimeGpuMS(); 26 | 27 | float GetBloomCpuTimeMS(); 28 | float GetBloomGpuTimeMS(); 29 | 30 | void BeginFrameTimeProfiling(); 31 | void EndFrameTimeProfiling(); 32 | 33 | void BeginLightUpdateProfiling(); 34 | void EndLightUpdateProfiling(); 35 | float GetLightUpdateTimeMS(); 36 | 37 | void BeginSceneAABB(); 38 | void EndSceneAABB(); 39 | 40 | void BeginPresentTimeProfiling(); 41 | void EndPresentTimeProfiling(); 42 | float GetPresentTimeMS(); 43 | 44 | void BeginWaitForPreviousFrameProfiling(); 45 | void EndWaitForPreviousFrameProfiling(); 46 | float GetWaitForPreviousFrameProfiling(); 47 | 48 | float GetFrustumCullTimeMS(); 49 | void IncFrustumCullTime( float ms ); 50 | void IncQueueWaitTime( float ms ); 51 | float GetQueueWaitTimeMS(); 52 | void SetBloomTime( float cpuMs, float gpuMs ); 53 | void IncTriangleCount( int triangles ); 54 | int GetTriangleCount(); 55 | void IncCreateConstantBufferCalls(); 56 | int GetCreateConstantBufferCalls(); 57 | void IncDrawCalls(); 58 | int GetDrawCalls(); 59 | void IncRenderTargetBinds(); 60 | int GetRenderTargetBinds(); 61 | void ResetFrameStatistics(); 62 | void IncShaderBinds(); 63 | int GetShaderBinds(); 64 | void IncBarrierCalls(); 65 | int GetBarrierCalls(); 66 | void IncFenceCalls(); 67 | int GetFenceCalls(); 68 | void IncAllocCalls(); 69 | int GetAllocCalls(); 70 | void IncTotalAllocCalls(); 71 | int GetTotalAllocCalls(); 72 | void IncPSOBindCalls(); 73 | int GetPSOBindCalls(); 74 | void IncQueueSubmitCalls(); 75 | int GetQueueSubmitCalls(); 76 | void SetDepthNormalsGpuTime( float timeMS ); 77 | void SetShadowMapGpuTime( float timeMS ); 78 | void SetLightCullerGpuTime( float timeMS ); 79 | void SetPrimaryPassGpuTime( float timeMS ); 80 | } 81 | -------------------------------------------------------------------------------- /Engine/Core/SubMesh.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | #include "VertexBuffer.hpp" 6 | #include "Vec3.hpp" 7 | 8 | namespace ae3d 9 | { 10 | struct Joint 11 | { 12 | Matrix44 globalBindposeInverse; 13 | std::vector< Matrix44 > animTransforms; 14 | int parentIndex = -1; 15 | char name[ 128 ]; 16 | }; 17 | 18 | struct SubMesh 19 | { 20 | Vec3 aabbMin; 21 | Vec3 aabbMax; 22 | VertexBuffer vertexBuffer; 23 | std::string name; 24 | std::vector< VertexBuffer::VertexPTNTC > verticesPTNTC; 25 | std::vector< VertexBuffer::VertexPTNTC_Skinned > verticesPTNTC_Skinned; 26 | std::vector< VertexBuffer::VertexPTN > verticesPTN; 27 | std::vector< VertexBuffer::Face > indices; 28 | std::vector< Joint > joints; 29 | }; 30 | } 31 | -------------------------------------------------------------------------------- /Engine/Include/Array.hpp: -------------------------------------------------------------------------------- 1 | // This is an independent project of an individual developer. Dear PVS-Studio, please check it. 2 | // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com 3 | #pragma once 4 | 5 | template< typename T > struct Array 6 | { 7 | Array() noexcept {} 8 | 9 | explicit Array( unsigned elementCount ) { Allocate( elementCount ); } 10 | 11 | Array( const Array& other ) { *this = other; } 12 | 13 | ~Array() noexcept 14 | { 15 | delete[] elements; 16 | elements = nullptr; 17 | count = 0; 18 | } 19 | 20 | Array& operator=( const Array& other ) 21 | { 22 | if (this == &other) 23 | { 24 | return *this; 25 | } 26 | 27 | delete[] elements; 28 | count = other.count; 29 | elements = new T[ count ]; 30 | 31 | for ( unsigned i = 0; i < count; ++i) 32 | { 33 | elements[ i ] = other.elements[ i ]; 34 | } 35 | 36 | return *this; 37 | } 38 | 39 | T& operator[]( unsigned index ) { return elements[ index ]; } 40 | 41 | const T& operator[]( unsigned index ) const { return elements[ index ]; } 42 | 43 | void Add( const T& item ) 44 | { 45 | T* after = new T[ count + 1 ](); 46 | 47 | for ( unsigned i = 0; i < count; ++i) 48 | { 49 | after[ i ] = elements[ i ]; 50 | } 51 | 52 | after[ count ] = item; 53 | delete[] elements; 54 | elements = after; 55 | count = count + 1; 56 | } 57 | 58 | void Remove( unsigned index ) 59 | { 60 | for (unsigned i = index; i < count - 1 && count > 0; ++i) 61 | { 62 | elements[ i ] = elements[ i + 1 ]; 63 | } 64 | 65 | if (count > 0) 66 | { 67 | --count; 68 | } 69 | } 70 | 71 | void Allocate( unsigned size ) 72 | { 73 | if (count == size) 74 | { 75 | return; 76 | } 77 | 78 | delete[] elements; 79 | elements = size > 0 ? new T[ size ]() : nullptr; 80 | count = size; 81 | } 82 | 83 | T* elements = nullptr; 84 | unsigned count = 0; 85 | }; 86 | 87 | -------------------------------------------------------------------------------- /Engine/Include/AudioClip.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | namespace FileSystem 6 | { 7 | struct FileContentsData; 8 | } 9 | 10 | /// Audio clip. 11 | class AudioClip 12 | { 13 | public: 14 | /// \param clipData Clip data from .wav or .ogg file. 15 | void Load( const FileSystem::FileContentsData& clipData ); 16 | 17 | /// \return Clip's handle. 0 means that the clip is empty/not pointing to any audio clip. 18 | unsigned GetId() const { return handle; } 19 | 20 | /// \return Clip's length in seconds or 1 if the clip is not loaded. 21 | float LengthInSeconds() const { return length; } 22 | 23 | private: 24 | unsigned handle = 0; 25 | float length = 0; 26 | }; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /Engine/Include/AudioSourceComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | /// Contains an audio clip and methods to play it. \see AudioClip 6 | class AudioSourceComponent 7 | { 8 | public: 9 | /// \return GameObject that owns this component. 10 | class GameObject* GetGameObject() const { return gameObject; } 11 | 12 | /// \param enabled True if the component should be audible, false otherwise. 13 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 14 | 15 | /// \return True, if clips played through this source will be affected by this game object's and camera's position. 16 | bool Is3D() const { return is3D; } 17 | 18 | /// \return True, if enabled 19 | bool IsEnabled() const { return isEnabled; } 20 | 21 | /// \return Clip's id 22 | unsigned GetClipId() const { return clipId; } 23 | 24 | /// \param audioClipId Audio clip id. 25 | void SetClipId( unsigned audioClipId ); 26 | 27 | /// \param enable True, if clips played through this source will be affected by this GameObject's and camera's position. Not implemented on macOS/iOS. 28 | void Set3D( bool enable ) { is3D = enable; } 29 | 30 | /// \param enable True, if the clip will be looped when playing. 31 | void SetLooping( bool enable ) { isLooping = enable; } 32 | 33 | /// Plays the clip. 34 | void Play() const; 35 | 36 | private: 37 | friend class GameObject; 38 | 39 | /// \return Component's type code. Must be unique for each component type. 40 | static int Type() { return 3; } 41 | 42 | /// \return Component handle that uniquely identifies the instance. 43 | static unsigned New(); 44 | 45 | /// \return Component at index or null if index is invalid. 46 | static AudioSourceComponent* Get( unsigned index ); 47 | 48 | GameObject* gameObject = nullptr; 49 | unsigned clipId = 0; 50 | bool is3D = false; 51 | bool isLooping = false; 52 | bool isEnabled = true; 53 | }; 54 | } 55 | -------------------------------------------------------------------------------- /Engine/Include/DecalRendererComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Quaternion.hpp" 4 | 5 | namespace ae3d 6 | { 7 | // Not used yet, does nothing! 8 | class DecalRendererComponent 9 | { 10 | public: 11 | /// Constructor. 12 | DecalRendererComponent(); 13 | 14 | /// \return GameObject that owns this component. 15 | class GameObject* GetGameObject() const { return gameObject; } 16 | 17 | /// \return True, if the component is enabled. 18 | bool IsEnabled() const { return isEnabled; } 19 | 20 | /// \param enabled True if the component should be rendered, false otherwise. 21 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 22 | 23 | /// \return Texture. 24 | class Texture2D* GetTexture() const { return texture; } 25 | 26 | /// \param theTexture Texture that's projected to the decal's area. 27 | void SetTexture( Texture2D* theTexture ) { texture = theTexture; } 28 | 29 | /// \return Orientation 30 | Quaternion GetOrientation() const { return orientation; } 31 | 32 | /// \param q Orientation 33 | void SetOrientation( struct Quaternion& q ) { orientation = q; } 34 | 35 | private: 36 | friend class GameObject; 37 | friend class Scene; 38 | 39 | /* \return Component's type code. Must be unique for each component type. */ 40 | static int Type() { return 12; } 41 | 42 | /* \return Component handle that uniquely identifies the instance. */ 43 | static unsigned New(); 44 | 45 | /* \return Component at index or null if index is invalid. */ 46 | static DecalRendererComponent* Get( unsigned index ); 47 | 48 | GameObject* gameObject = nullptr; 49 | Texture2D* texture = nullptr; 50 | Quaternion orientation; 51 | bool isEnabled = true; 52 | }; 53 | } 54 | -------------------------------------------------------------------------------- /Engine/Include/DirectionalLightComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "RenderTexture.hpp" 4 | #include "Vec3.hpp" 5 | 6 | namespace ae3d 7 | { 8 | /// Directional light illuminates the Scene from a given direction. Ideal for sunlight. 9 | class DirectionalLightComponent 10 | { 11 | public: 12 | DirectionalLightComponent() noexcept : shadowMap() {} 13 | 14 | /// \return GameObject that owns this component. 15 | class GameObject* GetGameObject() const { return gameObject; } 16 | 17 | /// \param enabled True if the component should be rendered, false otherwise. 18 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 19 | 20 | /// \return Color 21 | const Vec3& GetColor() const { return color; } 22 | 23 | /// \return Color 24 | Vec3& GetColor() { return color; } 25 | 26 | /// \param aColor Color in range 0-1. 27 | void SetColor( const Vec3& aColor ) { color = aColor; } 28 | 29 | /// \return True, if the light casts a shadow. 30 | bool CastsShadow() const { return castsShadow; } 31 | 32 | /// \return True, if enabled 33 | bool IsEnabled() const { return isEnabled; } 34 | 35 | /// \param enable If true, the light will cast a shadow. 36 | /// \param shadowMapSize Shadow map size in pixels. If it's invalid, it falls back to 512. 37 | void SetCastShadow( bool enable, int shadowMapSize ); 38 | 39 | /// \return Shadow map 40 | RenderTexture* GetShadowMap() { return &shadowMap; } 41 | 42 | private: 43 | friend class GameObject; 44 | friend class Scene; 45 | 46 | /// \return Component's type code. Must be unique for each component type. 47 | static int Type() { return 6; } 48 | 49 | /// \return Component handle that uniquely identifies the instance. 50 | static unsigned New(); 51 | 52 | /// \return Component at index or null if index is invalid. 53 | static DirectionalLightComponent* Get( unsigned index ); 54 | 55 | RenderTexture shadowMap; 56 | GameObject* gameObject = nullptr; 57 | bool castsShadow = false; 58 | bool isEnabled = true; 59 | Vec3 color{ 1, 1, 1 }; 60 | }; 61 | } 62 | -------------------------------------------------------------------------------- /Engine/Include/FileSystem.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include 5 | 6 | namespace ae3d 7 | { 8 | namespace FileSystem 9 | { 10 | /** File contents. */ 11 | struct FileContentsData 12 | { 13 | /// File content bytes. 14 | std::vector data; 15 | /// File path. 16 | std::string path; 17 | 18 | #if defined __APPLE__ 19 | /// Original path. Path without bundle. 20 | std::string pathWithoutBundle; 21 | #endif 22 | /// True if data has been loaded from path. 23 | bool isLoaded = false; 24 | }; 25 | 26 | /** 27 | Reads file contents. 28 | 29 | \param path Path. 30 | */ 31 | FileContentsData FileContents( const char* path ); 32 | 33 | /// \param path .pak file path. After this call FileContents() searches first in all loaded .pak files and if the file is not found, it's loaded without .pak file. 34 | void LoadPakFile( const char* path ); 35 | 36 | /// \param path .pak file. If it was loaded, it's unloaded and FileContents() does not search files inside it. 37 | void UnloadPakFile( const char* path ); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Engine/Include/Font.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | namespace FileSystem 6 | { 7 | struct FileContentsData; 8 | } 9 | 10 | /// Contains glyphs loaded from AngelCode BMFont files. For Mac there is a compatible program called BMGlyph. 11 | class Font 12 | { 13 | public: 14 | /// Constructor. 15 | Font(); 16 | 17 | /** 18 | \param fontTex Font texture. No outline support. 19 | \param metaData BMFont metadata. Must be text or binary. 20 | */ 21 | void LoadBMFont( class Texture2D* fontTex, const FileSystem::FileContentsData& metaData ); 22 | 23 | /** \return Font texture. */ 24 | Texture2D* GetTexture() { return texture; } 25 | 26 | /// \return Text width. 27 | int TextWidth( const char* text ) const; 28 | 29 | private: 30 | friend class TextRendererComponent; 31 | 32 | struct Character 33 | { 34 | float x = 0, y = 0; 35 | float width = 0, height = 0; 36 | float xOffset = 0, yOffset = 0; 37 | float xAdvance = 0; 38 | }; 39 | 40 | /** 41 | \param text Text. 42 | \param color Color in range 0-1. 43 | \param outVertexBuffer Vertex buffer created from text. 44 | */ 45 | void CreateVertexBuffer( const char* text, const struct Vec4& color, class VertexBuffer& outVertexBuffer ) const; 46 | 47 | /** \param metaData BMFont text metadata. */ 48 | void LoadBMFontMetaText(const FileSystem::FileContentsData& metaData); 49 | 50 | /** \param metaData BMFont binary metadata. */ 51 | void LoadBMFontMetaBinary(const FileSystem::FileContentsData& metaData); 52 | 53 | /** The spacing for each character (horizontal, vertical). */ 54 | int spacing[ 2 ]; 55 | 56 | /** The padding for each character (up, right, down, left). */ 57 | int padding[ 4 ]; 58 | 59 | /** This is the distance in pixels between each line of text. */ 60 | int lineHeight = 32; 61 | 62 | /** The number of pixels from the absolute top of the line to the base of the characters. */ 63 | int base = 32; 64 | 65 | Character chars[ 256 ]; 66 | Texture2D* texture = nullptr; 67 | }; 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Engine/Include/LineRendererComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | /// Renders lines. Use this component to get proper depth testing relative to other objects in a scene. 6 | /// For debug visualization lines you can use System::DrawLines() which is simpler. 7 | class LineRendererComponent 8 | { 9 | public: 10 | /// Constructor. 11 | LineRendererComponent(); 12 | 13 | /// \return GameObject that owns this component. 14 | class GameObject* GetGameObject() const { return gameObject; } 15 | 16 | /// \param enabled True if the component should be rendered, false otherwise. 17 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 18 | 19 | /// \return Line handle. 20 | int GetLineHandle() const { return lineHandle; } 21 | 22 | /// \param handle Line handle. Use System::CreateLineBuffer() to generate the handle. 23 | void SetLineHandle( int handle ) { lineHandle = handle; } 24 | 25 | private: 26 | friend class GameObject; 27 | friend class Scene; 28 | 29 | /* \return Component's type code. Must be unique for each component type. */ 30 | static int Type() { return 10; } 31 | 32 | /* \return Component handle that uniquely identifies the instance. */ 33 | static unsigned New(); 34 | 35 | /* \return Component at index or null if index is invalid. */ 36 | static LineRendererComponent* Get( unsigned index ); 37 | 38 | GameObject* gameObject = nullptr; 39 | int lineHandle = 0; 40 | bool isEnabled = true; 41 | }; 42 | } 43 | -------------------------------------------------------------------------------- /Engine/Include/Macros.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define AE3D_SAFE_RELEASE(x) if (x) { x->Release(); x = nullptr; } 4 | #define AE3D_CHECK_D3D(x, msg) if (x != S_OK) { ae3d::System::Assert( false, msg ); } 5 | #define AE3D_CHECK_VULKAN(x, msg) if (x != VK_SUCCESS) { ae3d::System::Assert( false, msg ); } 6 | -------------------------------------------------------------------------------- /Engine/Include/Mesh.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Array.hpp" 5 | 6 | namespace ae3d 7 | { 8 | namespace FileSystem 9 | { 10 | struct FileContentsData; 11 | } 12 | 13 | struct SubMesh; 14 | struct Vec3; 15 | 16 | /// Contains a mesh. Can contain submeshes. 17 | class Mesh 18 | { 19 | public: 20 | /// Result of loading the mesh. 21 | enum class LoadResult { Success, Corrupted, OutOfMemory, FileNotFound }; 22 | 23 | /// Constructor. 24 | Mesh(); 25 | 26 | /// \param other Other. 27 | Mesh( const Mesh& other ); 28 | 29 | /// Destructor. 30 | ~Mesh(); 31 | 32 | /// \param other Other. 33 | Mesh& operator=( const Mesh& other ); 34 | 35 | /// \return Path where this mesh was loaded from. 36 | const char* GetPath() const; 37 | 38 | /// \param meshData Data from .ae3d mesh file. 39 | /// \return Load result. 40 | LoadResult Load( const FileSystem::FileContentsData& meshData ); 41 | 42 | /// \return Axis-aligned bounding box minimum in local coordinates. 43 | const Vec3& GetAABBMin() const; 44 | 45 | /// \return Axis-aligned bounding box maximum in local coordinates. 46 | const Vec3& GetAABBMax() const; 47 | 48 | /// \param subMeshIndex Submesh index. If invalid, the first submesh AABB min is returned. 49 | /// \return Axis-aligned bounding box minimum for a submesh in local coordinates. 50 | const Vec3& GetSubMeshAABBMin( unsigned subMeshIndex ) const; 51 | 52 | /// \param subMeshIndex Submesh index. If invalid, the first submesh AABB max is returned. 53 | /// \return Axis-aligned bounding box maximum in local coordinates. 54 | const Vec3& GetSubMeshAABBMax( unsigned subMeshIndex ) const; 55 | 56 | /// Gets a raw triangle array, that can be used for example in picking. 57 | /// \param subMeshIndex Sub mesh index. 58 | /// \param outTriangles Triangles are returned in this array. 59 | void GetSubMeshFlattenedTriangles( unsigned subMeshIndex, Array< Vec3 >& outTriangles ) const; 60 | 61 | /// \return Submesh count. 62 | unsigned GetSubMeshCount() const; 63 | 64 | /// \param index Submesh index. 65 | /// \return Submesh name. If index is invalid, returns first submesh's name. 66 | const char* GetSubMeshName( unsigned index ) const; 67 | 68 | private: 69 | friend class MeshRendererComponent; 70 | 71 | struct Impl; 72 | Impl& m() { return reinterpret_cast(_storage); } 73 | Impl const& m() const { return reinterpret_cast(_storage); } 74 | 75 | static const std::size_t StorageSize = 1384; 76 | static const std::size_t StorageAlign = 16; 77 | 78 | std::aligned_storage::type _storage = {}; 79 | 80 | SubMesh* GetSubMeshes( int& outCount ); 81 | }; 82 | } 83 | -------------------------------------------------------------------------------- /Engine/Include/ParticleSystemComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | class ParticleSystemComponent 6 | { 7 | public: 8 | /// \return GameObject that owns this component. 9 | class GameObject* GetGameObject() const { return gameObject; } 10 | 11 | int GetMaxParticles() const { return maxParticles; } 12 | void SetMaxParticles( int count ); 13 | 14 | void GetColor( float& outR, float& outG, float& outB ) 15 | { 16 | outR = red; 17 | outG = green; 18 | outB = blue; 19 | } 20 | 21 | /// \param r Red in range 0-1. 22 | /// \param g Green in range 0-1. 23 | /// \param b Blue in range 0-1. 24 | void SetColor( float r, float g, float b ) 25 | { 26 | red = r; 27 | green = g; 28 | blue = b; 29 | } 30 | 31 | void Simulate( class ComputeShader& simulationShader ); 32 | void Cull( class ComputeShader& cullShader ); 33 | 34 | void Draw( ComputeShader& drawShader, class RenderTexture& target ); 35 | 36 | /// \return True, if enabled 37 | bool IsEnabled() const { return isEnabled; } 38 | 39 | /// \param enabled True if the component should be audible, false otherwise. 40 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 41 | 42 | private: 43 | friend class GameObject; 44 | 45 | /** \return Component's type code. Must be unique for each component type. */ 46 | static int Type() { return 11; } 47 | 48 | /** \return Component handle that uniquely identifies the instance. */ 49 | static unsigned New(); 50 | 51 | /** \return Component at index or null if index is invalid. */ 52 | static ParticleSystemComponent* Get( unsigned index ); 53 | 54 | static bool IsAnyAlive(); 55 | 56 | GameObject* gameObject = nullptr; 57 | int maxParticles = 1000; 58 | float red = 1.0f; 59 | float green = 1.0f; 60 | float blue = 1.0f; 61 | bool isEnabled = true; 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /Engine/Include/PointLightComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "RenderTexture.hpp" 4 | 5 | namespace ae3d 6 | { 7 | /// Point light illuminates the scene from a given position into all directions. 8 | class PointLightComponent 9 | { 10 | public: 11 | PointLightComponent() noexcept : shadowMap() {} 12 | 13 | /// \return GameObject that owns this component. 14 | class GameObject* GetGameObject() const { return gameObject; } 15 | 16 | /// \return True, if enabled 17 | bool IsEnabled() const { return isEnabled; } 18 | 19 | /// \param enabled True if the component should be rendered, false otherwise. 20 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 21 | 22 | /// \return Color 23 | Vec3& GetColor() { return color; } 24 | 25 | /// \param aColor Color in range 0-1. 26 | void SetColor( const Vec3& aColor ) { color = aColor; } 27 | 28 | /// \return True, if the light casts a shadow. 29 | bool CastsShadow() const { return castsShadow; } 30 | 31 | /// \param enable If true, the light will cast a shadow. 32 | /// \param shadowMapSize Shadow map size in pixels. If it's invalid, it falls back to 512. 33 | void SetCastShadow( bool enable, int shadowMapSize ); 34 | 35 | /// \return Shadow map 36 | RenderTexture* GetShadowMap() { return &shadowMap; } 37 | 38 | /// \return radius. 39 | float& GetRadius() { return radius; } 40 | 41 | /// \return radius. 42 | float GetRadius() const { return radius; } 43 | 44 | /// \param aRadius radius 45 | void SetRadius( float aRadius ) { radius = aRadius; } 46 | 47 | private: 48 | friend class GameObject; 49 | friend class Scene; 50 | 51 | /// \return Component's type code. Must be unique for each component type. 52 | static int Type() { return 8; } 53 | 54 | /// \return Component handle that uniquely identifies the instance. 55 | static unsigned New(); 56 | 57 | /// \return Component at index or null if index is invalid. 58 | static PointLightComponent* Get( unsigned index ); 59 | 60 | RenderTexture shadowMap; 61 | Vec3 color{ 1, 1, 1 }; 62 | float radius = 10; 63 | GameObject* gameObject = nullptr; 64 | bool castsShadow = false; 65 | bool isEnabled = true; 66 | int cachedShadowMapSize = 0; 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /Engine/Include/SpotLightComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "RenderTexture.hpp" 4 | #include "Vec3.hpp" 5 | 6 | namespace ae3d 7 | { 8 | /// Spot light illuminates the scene from a given position with a viewing cone. 9 | class SpotLightComponent 10 | { 11 | public: 12 | SpotLightComponent() noexcept : shadowMap() {} 13 | 14 | /// \return GameObject that owns this component. 15 | class GameObject* GetGameObject() const { return gameObject; } 16 | 17 | /// \return True, if enabled 18 | bool IsEnabled() const { return isEnabled; } 19 | 20 | /// \param enabled True if the component should be rendered, false otherwise. 21 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 22 | 23 | /// \return Color 24 | const Vec3& GetColor() const { return color; } 25 | 26 | /// \return Color 27 | Vec3& GetColor() { return color; } 28 | 29 | /// \return True, if the light casts a shadow. 30 | bool CastsShadow() const { return castsShadow; } 31 | 32 | /// \param enable If true, the light will cast a shadow. 33 | /// \param shadowMapSize Shadow map size in pixels. If it's invalid, it falls back to 512. 34 | void SetCastShadow( bool enable, int shadowMapSize ); 35 | 36 | /// \param aRadius for light culler. Defaults to 2. 37 | void SetRadius( float aRadius ) { radius = aRadius; } 38 | 39 | /// \return Radius for light culler. 40 | float GetRadius() const { return radius; } 41 | 42 | /// \return Radius for light culler. 43 | float& GetRadius() { return radius; } 44 | 45 | /// \return Shadow map 46 | RenderTexture* GetShadowMap() { return &shadowMap; } 47 | 48 | /// \return Cone angle in degrees. 49 | float GetConeAngle() const { return coneAngle; } 50 | 51 | /// \return Cone angle in degrees. 52 | float& GetConeAngle() { return coneAngle; } 53 | 54 | /// \param degrees Angle in degrees. 55 | void SetConeAngle( float degrees ); 56 | 57 | /// \param aColor Color in range 0-1. 58 | void SetColor( const Vec3& aColor ) { color = aColor; } 59 | 60 | private: 61 | friend class GameObject; 62 | friend class Scene; 63 | 64 | /// \return Component's type code. Must be unique for each component type. 65 | static int Type() { return 7; } 66 | 67 | /// \return Component handle that uniquely identifies the instance. 68 | static unsigned New(); 69 | 70 | /// \return Component at index or null if index is invalid. 71 | static SpotLightComponent* Get( unsigned index ); 72 | 73 | RenderTexture shadowMap; 74 | GameObject* gameObject = nullptr; 75 | Vec3 color{ 1, 1, 1 }; 76 | float coneAngle = 45; 77 | float radius = 2; 78 | bool castsShadow = false; 79 | bool isEnabled = true; 80 | int cachedShadowMapSize = 0; 81 | }; 82 | } 83 | -------------------------------------------------------------------------------- /Engine/Include/TextRendererComponent.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace ae3d 6 | { 7 | struct Vec4; 8 | 9 | /// Contains text. 10 | class TextRendererComponent 11 | { 12 | public: 13 | /// Shader type for rendering text. 14 | enum class ShaderType { Sprite, SDF }; 15 | 16 | /// Constructor. 17 | TextRendererComponent(); 18 | 19 | /// \param other Other. 20 | TextRendererComponent( const TextRendererComponent& other ); 21 | 22 | /// Destructor. 23 | ~TextRendererComponent(); 24 | 25 | /// \param other Other. 26 | TextRendererComponent& operator=( const TextRendererComponent& other ); 27 | 28 | /// \return GameObject that owns this component. 29 | class GameObject* GetGameObject() const { return gameObject; } 30 | 31 | /// \return True, if enabled. 32 | bool IsEnabled() const { return isEnabled; } 33 | 34 | /// \return Color. 35 | const Vec4& GetColor() const; 36 | 37 | /// \param enabled True if the component should be rendered, false otherwise. 38 | void SetEnabled( bool enabled ) { isEnabled = enabled; } 39 | 40 | /// \param color Color in range 0-1. 41 | void SetColor( const struct Vec4& color ); 42 | 43 | /// \param font Font. 44 | void SetFont( class Font* font ); 45 | 46 | /// \return Text. 47 | const char* GetText() const; 48 | 49 | /// \param text Text. Characters not in font are rendered empty. 50 | void SetText( const char* text ); 51 | 52 | /// \param shaderType Shader type. 53 | void SetShader( ShaderType shaderType ); 54 | 55 | private: 56 | friend class GameObject; 57 | friend class Scene; 58 | 59 | /** \return Component's type code. Must be unique for each component type. */ 60 | static int Type() { return 4; } 61 | 62 | /** \return Component handle that uniquely identifies the instance. */ 63 | static unsigned New(); 64 | 65 | /** \return Component at index or null if index is invalid. */ 66 | static TextRendererComponent* Get( unsigned index ); 67 | 68 | /** \param localToClip Transforms screen-space coordinates to clip space. */ 69 | void Render( const float* localToClip ); 70 | 71 | struct Impl; 72 | Impl& m() { return reinterpret_cast(_storage); } 73 | Impl const& m() const { return reinterpret_cast(_storage); } 74 | 75 | static const std::size_t StorageSize = 1384; 76 | static const std::size_t StorageAlign = 16; 77 | 78 | std::aligned_storage::type _storage = {}; 79 | 80 | GameObject* gameObject = nullptr; 81 | bool isEnabled = true; 82 | }; 83 | } 84 | -------------------------------------------------------------------------------- /Engine/Include/TextureCube.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "TextureBase.hpp" 4 | 5 | namespace ae3d 6 | { 7 | namespace FileSystem 8 | { 9 | struct FileContentsData; 10 | } 11 | 12 | /// Cube Map texture. 13 | class TextureCube : public TextureBase 14 | { 15 | public: 16 | /// Gets a default texture that is always available after System::LoadBuiltinAssets(). 17 | static TextureCube* GetDefaultTexture(); 18 | 19 | /** 20 | \param negX Negative X axis texture. 21 | \param posX Positive X axis texture. 22 | \param negY Negative Y axis texture. 23 | \param posY Positive Y axis texture. 24 | \param negZ Negative Z axis texture. 25 | \param posZ Positive Z axis texture. 26 | \param wrap Wrapping mode. 27 | \param filter Filtering mode. 28 | \param mipmaps Should mipmaps be generated and used. 29 | \param colorSpace Color space. 30 | */ 31 | void Load( const FileSystem::FileContentsData& negX, const FileSystem::FileContentsData& posX, 32 | const FileSystem::FileContentsData& negY, const FileSystem::FileContentsData& posY, 33 | const FileSystem::FileContentsData& negZ, const FileSystem::FileContentsData& posZ, 34 | TextureWrap wrap, TextureFilter filter, Mipmaps mipmaps, ColorSpace colorSpace ); 35 | 36 | /// \return Positive X texture path. 37 | const std::string& PosX() const { return posXpath; } 38 | 39 | /// \return Negative X texture path. 40 | const std::string& NegX() const { return negXpath; } 41 | 42 | /// \return Positive Y texture path. 43 | const std::string& PosY() const { return posYpath; } 44 | 45 | /// \return Negative Y texture path. 46 | const std::string& NegY() const { return negYpath; } 47 | 48 | /// \return Positive Z texture path. 49 | const std::string& PosZ() const { return posZpath; } 50 | 51 | /// \return Negative Z texture path. 52 | const std::string& NegZ() const { return negZpath; } 53 | 54 | #if RENDERER_VULKAN 55 | VkImageView& GetView() { return view; } 56 | #endif 57 | /// Destroys all textures. Called internally at exit. 58 | static void DestroyTextures(); 59 | 60 | private: 61 | std::string posXpath, posYpath, negXpath, negYpath, posZpath, negZpath; 62 | #if RENDERER_VULKAN 63 | VkImage image = VK_NULL_HANDLE; 64 | VkImageView view = VK_NULL_HANDLE; 65 | VkDeviceMemory deviceMemory = VK_NULL_HANDLE; 66 | #endif 67 | }; 68 | } 69 | -------------------------------------------------------------------------------- /Engine/Include/VR.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | struct Vec3; 6 | class GameObject; 7 | 8 | namespace VR 9 | { 10 | /// Inits the device. Must be called as early as possible. 11 | void Init(); 12 | 13 | /// Releases resources. 14 | void Deinit(); 15 | 16 | /// \return Left hand position 17 | Vec3 GetLeftHandPosition(); 18 | 19 | /// \return Right hand position 20 | Vec3 GetRightHandPosition(); 21 | 22 | /// \param outWidth Returns optimal width for window. 23 | /// \param outHeight Returns optimal height for window. 24 | void GetIdealWindowSize( int& outWidth, int& outHeight ); 25 | 26 | /// Displays the image on the device. Called after both eyes have been rendered. 27 | void SubmitFrame(); 28 | 29 | /// Gets the pose from device. 30 | void CalcEyePose(); 31 | 32 | /// Sets camera's projection and view matrix according to device. 33 | /// \param camera Camera. Must contain TransformComponent and CameraComponent. 34 | /// \param yawDegrees Yaw in degrees. 35 | /// \param eye 0 for left eye, 1 for right. 36 | void CalcCameraForEye( GameObject& camera, float yawDegrees, int eye ); 37 | 38 | /// Re-centers the sensor position and orientation. 39 | void RecenterTracking(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Engine/Tests/04_Serialization.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "Array.hpp" 4 | #include "CameraComponent.hpp" 5 | #include "FileSystem.hpp" 6 | #include "GameObject.hpp" 7 | #include "Mesh.hpp" 8 | #include "MeshRendererComponent.hpp" 9 | #include "RenderTexture.hpp" 10 | #include "SpriteRendererComponent.hpp" 11 | #include "System.hpp" 12 | #include "Scene.hpp" 13 | #include "TransformComponent.hpp" 14 | #include "TextRendererComponent.hpp" 15 | #include "Vec3.hpp" 16 | #include "Window.hpp" 17 | 18 | using namespace ae3d; 19 | 20 | int main() 21 | { 22 | Window::Create( 512, 512, WindowCreateFlags::Empty ); 23 | System::LoadBuiltinAssets(); 24 | 25 | std::vector< GameObject > gameObjects; 26 | std::map< std::string, Material* > materialNameToMaterial; 27 | std::map< std::string, Texture2D* > textureNameToTexture; 28 | Array< Mesh* > meshes; 29 | Scene scene; 30 | 31 | auto res = scene.Deserialize( FileSystem::FileContents( "serialization_test.scene" ), gameObjects, textureNameToTexture, 32 | materialNameToMaterial, meshes ); 33 | 34 | if (res != Scene::DeserializeResult::Success) 35 | { 36 | System::Print( "Scene serialization failed!\n" ); 37 | return 1; 38 | } 39 | 40 | return 0; 41 | } 42 | 43 | 44 | -------------------------------------------------------------------------------- /Engine/Tests/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER := g++ -g 3 | ENGINE_LIB := libaether3d_linux_vulkan.a 4 | LIBS := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal 5 | 6 | ifeq ($(OS),Windows_NT) 7 | ENGINE_LIB := libaether3d_win_vulkan.a 8 | LIBS := -L../ThirdParty/lib -lOpenAL32 -lOpenGL32 -lgdi32 9 | endif 10 | 11 | all: 12 | $(COMPILER) -DRENDERER_VULKAN -std=c++11 04_Serialization.cpp ../Core/Matrix.cpp -I../Include -o ../../../aether3d_build/Samples/04_Serialization ../../../aether3d_build/$(ENGINE_LIB) $(LIBS) 13 | $(COMPILER) -DRENDERER_VULKAN -std=c++11 02_Components.cpp ../Core/Matrix.cpp -I../Include -o ../../../aether3d_build/Samples/02_Components ../../../aether3d_build/$(ENGINE_LIB) $(LIBS) 14 | $(COMPILER) -DRENDERER_VULKAN -std=c++11 03_Simple3D.cpp ../Core/Matrix.cpp -I../Include -o ../../../aether3d_build/Samples/03_Simple3D ../../../aether3d_build/$(ENGINE_LIB) $(LIBS) 15 | ifeq ($(OS),Windows_NT) 16 | g++ -Wall -march=native -std=c++11 -DRENDERER_VULKAN -DSIMD_SSE3 01_Math.cpp ../Core/Matrix.cpp ../Core/MatrixSSE3.cpp -I../Include -o ../../../aether3d_build/Samples/01_MathSSE 17 | g++ -Wall -DRENDERER_VULKAN -std=c++11 01_Math.cpp ../Core/Matrix.cpp -I../Include -o ../../../aether3d_build/Samples/01_Math 18 | endif 19 | ifeq ($(UNAME), Linux) 20 | g++ -DRENDERER_VULKAN -std=c++11 -march=native -fsanitize=address -DSIMD_SSE3 01_Math.cpp ../Core/Matrix.cpp ../Core/MatrixSSE3.cpp -I../Include -o ../../../aether3d_build/Samples/01_MathSSE 21 | g++ -DRENDERER_VULKAN -std=c++11 -fsanitize=address 01_Math.cpp ../Core/Matrix.cpp -I../Include -o ../../../aether3d_build/Samples/01_Math 22 | endif 23 | 24 | -------------------------------------------------------------------------------- /Engine/Tests/UnitTests/UnitTests/UnitTests.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 10 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | -------------------------------------------------------------------------------- /Engine/Tests/scene.scene: -------------------------------------------------------------------------------- 1 | gameobject mutsis 2 | -------------------------------------------------------------------------------- /Engine/ThirdParty/AL/efx-creative.h: -------------------------------------------------------------------------------- 1 | /* The tokens that would be defined here are already defined in efx.h. This 2 | * empty file is here to provide compatibility with Windows-based projects 3 | * that would include it. */ 4 | -------------------------------------------------------------------------------- /Engine/ThirdParty/WinPixEventRuntime/AmdDxExt/AmdExtD3D.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2016-2024 Advanced Micro Devices, Inc. All rights reserved. */ 2 | #pragma once 3 | 4 | #include 5 | #include 6 | 7 | /* All AMD extensions contain the standard IUnknown interface: 8 | * virtual HRESULT STDMETHODCALLTYPE QueryInterface( 9 | * REFIID riid, 10 | * _COM_Outptr_ void __RPC_FAR *__RPC_FAR *ppvObject) = 0; 11 | * virtual ULONG STDMETHODCALLTYPE AddRef( void) = 0; 12 | * virtual ULONG STDMETHODCALLTYPE Release( void) = 0; 13 | */ 14 | 15 | /* 16 | * The app must use GetProcAddress, etc.to retrieve this exported function 17 | * The associated typedef provides a convenient way to define the function pointer 18 | * 19 | * HRESULT __cdecl AmdExtD3DCreateInterface( 20 | * IUnknown* pOuter, ///< [in] object on which to base this new interface; usually a D3D device 21 | * REFIID riid, ///< ID of the requested interface 22 | * void** ppvObject); ///< [out] The result interface object 23 | */ 24 | typedef HRESULT (__cdecl *PFNAmdExtD3DCreateInterface)(IUnknown* pOuter, REFIID riid, void** ppvObject); 25 | 26 | /** 27 | *********************************************************************************************************************** 28 | * @brief Abstract factory for extension interfaces 29 | * 30 | * Each extension interface (e.g. tessellation) will derive from this class 31 | *********************************************************************************************************************** 32 | */ 33 | MIDL_INTERFACE("014937EC-9288-446F-A9AC-D75A8E3A984F") 34 | IAmdExtD3DFactory : public IUnknown 35 | { 36 | public: 37 | virtual HRESULT CreateInterface( 38 | IUnknown* pOuter, ///< [in] An object on which to base this new interface; the required object type 39 | ///< is usually a device object but not always 40 | REFIID riid, ///< The ID of the requested interface 41 | void** ppvObject) = 0; ///< [out] The result interface object 42 | }; 43 | -------------------------------------------------------------------------------- /Engine/ThirdParty/WinPixEventRuntime/AmdDxExt/AmdExtD3DCommandListMarkerApi.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2017-2024 Advanced Micro Devices, Inc. All rights reserved. */ 2 | 3 | #pragma once 4 | 5 | #include 6 | 7 | /** 8 | *********************************************************************************************************************** 9 | * @brief D3D Command List Marker extension API object 10 | *********************************************************************************************************************** 11 | */ 12 | MIDL_INTERFACE("735F1F3A-555D-4F70-AB92-7DB4A3AB1D28") 13 | IAmdExtD3DCommandListMarker : public IUnknown 14 | { 15 | public: 16 | /// Set a command list marker to indicate the beginning of a rendering pass 17 | virtual void PushMarker(const char* pMarker) = 0; 18 | /// Set a command list marker to indicate the end of the current rendering pass 19 | virtual void PopMarker() = 0; 20 | /// Set a command list marker to indicate a rendering activity 21 | virtual void SetMarker(const char* pMarker) = 0; 22 | }; 23 | -------------------------------------------------------------------------------- /Engine/ThirdParty/lib/WinPixEventRuntime.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/ThirdParty/lib/WinPixEventRuntime.lib -------------------------------------------------------------------------------- /Engine/ThirdParty/lib/libOpenAL32.dll.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/ThirdParty/lib/libOpenAL32.dll.a -------------------------------------------------------------------------------- /Engine/ThirdParty/lib/libOpenAL32.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Engine/ThirdParty/lib/libOpenAL32.lib -------------------------------------------------------------------------------- /Engine/Video/D3D12/DescriptorHeapManager.hpp: -------------------------------------------------------------------------------- 1 | #ifndef DESCRIPTOR_HEAP_MANAGER 2 | #define DESCRIPTOR_HEAP_MANAGER 3 | 4 | #include 5 | 6 | class DescriptorHeapManager 7 | { 8 | public: 9 | static ID3D12DescriptorHeap* GetCbvSrvUavHeap() { return cbvSrvUavHeap; } 10 | static ID3D12DescriptorHeap* GetSamplerHeap() { return samplerHeap; } 11 | static ID3D12DescriptorHeap* GetRTVHeap() { return rtvHeap; } 12 | static ID3D12DescriptorHeap* GetDSVHeap() { return dsvHeap; } 13 | static D3D12_CPU_DESCRIPTOR_HANDLE AllocateDescriptor( D3D12_DESCRIPTOR_HEAP_TYPE type ); 14 | static D3D12_GPU_DESCRIPTOR_HANDLE GetCbvSrvUavGpuHandle( unsigned index ); 15 | static D3D12_CPU_DESCRIPTOR_HANDLE GetCbvSrvUavCpuHandle( unsigned index ); 16 | 17 | static void Deinit(); 18 | static const UINT numDescriptors = 32000; 19 | 20 | private: 21 | static ID3D12DescriptorHeap* cbvSrvUavHeap; 22 | static D3D12_CPU_DESCRIPTOR_HANDLE currentCbvSrvUavHandle; 23 | 24 | static ID3D12DescriptorHeap* samplerHeap; 25 | static D3D12_CPU_DESCRIPTOR_HANDLE currentSamplerHandle; 26 | 27 | static ID3D12DescriptorHeap* rtvHeap; 28 | static D3D12_CPU_DESCRIPTOR_HANDLE currentRtvHandle; 29 | 30 | static ID3D12DescriptorHeap* dsvHeap; 31 | static D3D12_CPU_DESCRIPTOR_HANDLE currentDsvHandle; 32 | }; 33 | #endif 34 | -------------------------------------------------------------------------------- /Engine/Video/D3D12/RendererD3D12.cpp: -------------------------------------------------------------------------------- 1 | #include "Renderer.hpp" 2 | #include "FileSystem.hpp" 3 | #include "ComputeShader.hpp" 4 | 5 | ae3d::Renderer renderer; 6 | 7 | void ae3d::BuiltinShaders::Load() 8 | { 9 | spriteRendererShader.Load( "", "", FileSystem::FileContents( "shaders/sprite_vert.obj" ), FileSystem::FileContents( "shaders/sprite_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 10 | sdfShader.Load( "", "", FileSystem::FileContents( "shaders/sdf_vert.obj" ), FileSystem::FileContents( "shaders/sdf_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 11 | skyboxShader.Load( "", "", FileSystem::FileContents( "shaders/skybox_vert.obj" ), FileSystem::FileContents( "shaders/skybox_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 12 | momentsShader.Load( "", "", FileSystem::FileContents( "shaders/moments_vert.obj" ), FileSystem::FileContents( "shaders/moments_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 13 | momentsAlphaTestShader.Load( "", "", FileSystem::FileContents( "shaders/moments_vert.obj" ), FileSystem::FileContents( "shaders/moments_alphatest_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 14 | momentsSkinShader.Load( "", "", FileSystem::FileContents( "shaders/moments_skin_vert.obj" ), FileSystem::FileContents( "shaders/moments_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 15 | depthNormalsShader.Load( "", "", FileSystem::FileContents( "shaders/depthnormals_vert.obj" ), FileSystem::FileContents( "shaders/depthnormals_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 16 | depthNormalsSkinShader.Load( "", "", FileSystem::FileContents( "shaders/depthnormals_skin_vert.obj" ), FileSystem::FileContents( "shaders/depthnormals_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 17 | uiShader.Load( "", "", FileSystem::FileContents( "shaders/sprite_vert.obj" ), FileSystem::FileContents( "shaders/sprite_frag.obj" ), FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 18 | 19 | lightCullShader.Load( "", FileSystem::FileContents( "shaders/LightCuller.obj" ), FileSystem::FileContents( "" ) ); 20 | particleCullShader.Load( "", FileSystem::FileContents( "shaders/particle_cull.obj" ), FileSystem::FileContents( "" ) ); 21 | particleSimulationShader.Load( "", FileSystem::FileContents( "shaders/particle_simulate.obj" ), FileSystem::FileContents( "" ) ); 22 | particleDrawShader.Load( "", FileSystem::FileContents( "shaders/particle_draw.obj" ), FileSystem::FileContents( "" ) ); 23 | } 24 | -------------------------------------------------------------------------------- /Engine/Video/DDSLoader.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Array.hpp" 4 | 5 | namespace ae3d 6 | { 7 | namespace FileSystem 8 | { 9 | struct FileContentsData; 10 | } 11 | } 12 | 13 | /// Loads a .dds (DirectDraw Surface) 14 | namespace DDSLoader 15 | { 16 | /// Load result 17 | enum class LoadResult { Success, UnknownPixelFormat, FileNotFound }; 18 | /// Format 19 | enum class Format { Invalid, BC1, BC2, BC3, BC4U, BC4S, BC5U, BC5S }; 20 | 21 | struct Output 22 | { 23 | Array< unsigned char > imageData; 24 | Array< int > dataOffsets; // Mipmap offsets in imageData 25 | Format format = Format::Invalid; 26 | }; 27 | 28 | /** 29 | Loads a .dds file. 30 | 31 | \param fileContents Contents of .dds file. 32 | \param outWidth Stores the width of the texture in pixels. 33 | \param outHeight Stores the height of the texture in pixels. 34 | \param outOpaque Stores info about alpha channel. 35 | \param output Stores information needed to create graphics API objects. 36 | \return Load result. 37 | */ 38 | LoadResult Load( const ae3d::FileSystem::FileContentsData& fileContents, int& outWidth, int& outHeight, bool& outOpaque, Output& output ); 39 | } 40 | -------------------------------------------------------------------------------- /Engine/Video/Material.cpp: -------------------------------------------------------------------------------- 1 | // This is an independent project of an individual developer. Dear PVS-Studio, please check it. 2 | // PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com 3 | #include "Material.hpp" 4 | #include "GfxDevice.hpp" 5 | #include "Texture2D.hpp" 6 | #include "RenderTexture.hpp" 7 | #include "Shader.hpp" 8 | 9 | ae3d::RenderTexture* ae3d::Material::sTexRT; 10 | 11 | namespace GfxDeviceGlobal 12 | { 13 | extern PerObjectUboStruct perObjectUboStruct; 14 | } 15 | 16 | bool ae3d::Material::IsValidShader() const 17 | { 18 | return shader && shader->IsValid(); 19 | } 20 | 21 | void ae3d::Material::Apply() 22 | { 23 | if (shader == nullptr) 24 | { 25 | return; 26 | } 27 | 28 | shader->Use(); 29 | 30 | for (int slot = 0; slot < TEXTURE_SLOT_COUNT; ++slot) 31 | { 32 | shader->SetTexture( tex2dSlots[ slot ], slot ); 33 | } 34 | 35 | if (alphaTest) 36 | { 37 | shader->SetTexture( alphaTest, 0 ); 38 | } 39 | 40 | for (int slot = 0; slot < TEXTURE_SLOT_COUNT; ++slot) 41 | { 42 | if (texCubeSlots[ slot ]) 43 | { 44 | shader->SetTexture( texCubeSlots[ slot ], slot ); 45 | } 46 | 47 | if (rtSlots[ slot ]) 48 | { 49 | shader->SetRenderTexture( rtSlots[ slot ], slot ); 50 | } 51 | } 52 | 53 | if (sTexRT) 54 | { 55 | #if RENDERER_METAL 56 | if (sTexRT->IsCube()) 57 | { 58 | shader->SetRenderTexture( sTexRT, 2 ); 59 | } 60 | else 61 | { 62 | shader->SetRenderTexture( sTexRT, 3 ); 63 | } 64 | #else 65 | if (sTexRT->IsCube()) 66 | { 67 | shader->SetRenderTexture( sTexRT, 4 ); 68 | } 69 | else 70 | { 71 | shader->SetRenderTexture( sTexRT, 3 ); 72 | } 73 | #endif 74 | } 75 | 76 | if (depthUnits > 0.0001f || depthUnits < -0.0001f || depthFactor > 0.0001f || depthFactor < -0.0001f) 77 | { 78 | GfxDevice::SetPolygonOffset( true, depthFactor, depthUnits ); 79 | } 80 | else 81 | { 82 | GfxDevice::SetPolygonOffset( false, 0, 0 ); 83 | } 84 | 85 | GfxDeviceGlobal::perObjectUboStruct.f0 = f0; 86 | GfxDeviceGlobal::perObjectUboStruct.roughness = roughness; 87 | } 88 | 89 | void ae3d::Material::SetShader( Shader* aShader ) 90 | { 91 | shader = aShader; 92 | } 93 | 94 | void ae3d::Material::SetF0( float af0 ) 95 | { 96 | f0 = af0; 97 | } 98 | 99 | void ae3d::Material::SetTexture( Texture2D* texture, int slot ) 100 | { 101 | if (0 <= slot && slot < TEXTURE_SLOT_COUNT) 102 | { 103 | tex2dSlots[ slot ] = texture; 104 | } 105 | } 106 | 107 | void ae3d::Material::SetTexture( TextureCube* texture ) 108 | { 109 | texCubeSlots[ 4 ] = texture; 110 | } 111 | 112 | void ae3d::Material::SetRenderTexture( RenderTexture* renderTexture, int slot ) 113 | { 114 | rtSlots[ slot ] = renderTexture; 115 | } 116 | 117 | void ae3d::Material::SetGlobalRenderTexture( RenderTexture* renderTexture ) 118 | { 119 | sTexRT = renderTexture; 120 | } 121 | -------------------------------------------------------------------------------- /Engine/Video/Metal/RendererMetal.mm: -------------------------------------------------------------------------------- 1 | #include "Renderer.hpp" 2 | #include "FileSystem.hpp" 3 | #include "GfxDevice.hpp" 4 | #include "Vec3.hpp" 5 | 6 | ae3d::Renderer renderer; 7 | 8 | id< MTLBuffer > particleBuffer; 9 | id< MTLBuffer > particleTileBuffer; 10 | 11 | void ae3d::BuiltinShaders::Load() 12 | { 13 | spriteRendererShader.LoadFromLibrary( "sprite_vertex", "sprite_fragment" ); 14 | sdfShader.LoadFromLibrary( "sdf_vertex", "sdf_fragment" ); 15 | skyboxShader.LoadFromLibrary( "skybox_vertex", "skybox_fragment" ); 16 | momentsShader.LoadFromLibrary( "moments_vertex", "moments_fragment" ); 17 | momentsSkinShader.LoadFromLibrary( "moments_skin_vertex", "moments_fragment" ); 18 | momentsAlphaTestShader.LoadFromLibrary( "moments_vertex", "moments_alphatest_fragment" ); 19 | depthNormalsShader.LoadFromLibrary( "depthnormals_vertex", "depthnormals_fragment" ); 20 | depthNormalsSkinShader.LoadFromLibrary( "depthnormals_skin_vertex", "depthnormals_fragment" ); 21 | lightCullShader.Load( "light_culler", FileSystem::FileContents(""), FileSystem::FileContents("") ); 22 | particleSimulationShader.Load( "particle_simulation", FileSystem::FileContents(""), FileSystem::FileContents("") ); 23 | particleDrawShader.Load( "particle_draw", FileSystem::FileContents(""), FileSystem::FileContents("") ); 24 | particleCullShader.Load( "particle_cull", FileSystem::FileContents( "" ), FileSystem::FileContents( "" ) ); 25 | uiShader.LoadFromLibrary( "sprite_vertex", "sprite_fragment" ); 26 | 27 | const unsigned maxParticleCount = 1000000; 28 | particleBuffer = [GfxDevice::GetMetalDevice() newBufferWithLength:sizeof( Particle ) * maxParticleCount 29 | options:MTLResourceStorageModePrivate]; 30 | particleBuffer.label = @"Particle buffer"; 31 | 32 | const unsigned tileCount = renderer.GetNumParticleTilesX() * renderer.GetNumParticleTilesY(); 33 | const unsigned maxParticlesPerTile = 1000; 34 | 35 | particleTileBuffer = [GfxDevice::GetMetalDevice() newBufferWithLength:maxParticlesPerTile * tileCount * sizeof( unsigned ) 36 | options:MTLResourceStorageModePrivate]; 37 | particleTileBuffer.label = @"particleTileBuffer"; 38 | } 39 | -------------------------------------------------------------------------------- /Engine/Video/Renderer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "ComputeShader.hpp" 4 | #include "Shader.hpp" 5 | #include "VertexBuffer.hpp" 6 | #include "Texture2D.hpp" 7 | 8 | namespace ae3d 9 | { 10 | class TextureCube; 11 | class CameraComponent; 12 | struct Vec4; 13 | 14 | struct Particle 15 | { 16 | ae3d::Vec4 positionAndSize; 17 | ae3d::Vec4 color; 18 | ae3d::Vec4 clipPosition; 19 | ae3d::Vec4 lifeTimeSecs; // Stored in .x component. 20 | }; 21 | 22 | struct BuiltinShaders 23 | { 24 | // Loads shader binaries from running directory's 'shaders' subfolder. 25 | void Load(); 26 | 27 | Shader spriteRendererShader; 28 | Shader sdfShader; 29 | Shader skyboxShader; 30 | Shader momentsShader; 31 | Shader momentsSkinShader; 32 | Shader momentsAlphaTestShader; 33 | Shader depthNormalsShader; 34 | Shader depthNormalsSkinShader; 35 | Shader uiShader; 36 | ComputeShader lightCullShader; 37 | ComputeShader particleSimulationShader; 38 | ComputeShader particleCullShader; 39 | ComputeShader particleDrawShader; 40 | }; 41 | 42 | /// High-level rendering stuff. 43 | class Renderer 44 | { 45 | public: 46 | VertexBuffer& GetQuadBuffer() { return quadBuffer; } 47 | 48 | /// \return True if skybox has been generated. 49 | bool IsSkyboxGenerated() const { return skyboxBuffer.IsGenerated(); } 50 | 51 | void GenerateQuadBuffer(); 52 | void GenerateSkybox(); 53 | void GenerateTextures(); 54 | void GenerateSSAOKernel( int count, Vec4* outKernel ); 55 | void RenderSkybox( TextureCube* skyTexture, const CameraComponent& camera ); 56 | 57 | unsigned GetNumParticleTilesX() const; 58 | unsigned GetNumParticleTilesY() const; 59 | 60 | Texture2D& GetWhiteTexture() { return whiteTexture; } 61 | 62 | BuiltinShaders builtinShaders; 63 | 64 | private: 65 | VertexBuffer skyboxBuffer; 66 | VertexBuffer quadBuffer; 67 | Texture2D whiteTexture; 68 | }; 69 | } 70 | -------------------------------------------------------------------------------- /Engine/Video/Vulkan/VulkanUtils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef VULKAN_UTILS 2 | #define VULKAN_UTILS 3 | 4 | #include 5 | 6 | namespace ae3d 7 | { 8 | class VertexBuffer; 9 | class Shader; 10 | 11 | namespace GfxDevice 12 | { 13 | enum class DepthFunc; 14 | enum class BlendMode; 15 | enum class CullMode; 16 | enum class FillMode; 17 | enum class PrimitiveTopology; 18 | } 19 | 20 | void SetImageLayout( VkCommandBuffer cmdbuffer, VkImage image, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, 21 | VkImageLayout newImageLayout, unsigned layerCount, unsigned mipLevel, unsigned mipLevelCount ); 22 | 23 | void SetupImageBarrier( VkImage image, VkImageAspectFlags aspectMask, VkImageLayout oldImageLayout, 24 | VkImageLayout newImageLayout, unsigned layerCount, unsigned mipLevel, unsigned mipLevelCount, 25 | VkImageMemoryBarrier& outBarrier, VkPipelineStageFlags& outSrcStageFlags, VkPipelineStageFlags& outDstStageFlags ); 26 | 27 | std::uint64_t GetPSOHash( ae3d::VertexBuffer& vertexBuffer, ae3d::Shader& shader, ae3d::GfxDevice::BlendMode blendMode, 28 | ae3d::GfxDevice::DepthFunc depthFunc, ae3d::GfxDevice::CullMode cullMode, ae3d::GfxDevice::FillMode fillMode, VkRenderPass renderPass, ae3d::GfxDevice::PrimitiveTopology topology ); 29 | 30 | void CreateInstance( VkInstance* outInstance ); 31 | std::uint32_t GetMemoryType( std::uint32_t typeBits, VkFlags properties ); 32 | } 33 | 34 | namespace debug 35 | { 36 | extern bool enabled; 37 | extern bool hasMarker; 38 | void Setup( VkInstance instance ); 39 | void SetupDevice( VkDevice device ); 40 | void Free( VkInstance instance ); 41 | void SetObjectName( VkDevice device, std::uint64_t object, VkObjectType objectType, const char* name ); 42 | void BeginRegion( VkCommandBuffer cmdbuffer, const char* pMarkerName, float r, float g, float b ); 43 | void EndRegion( VkCommandBuffer cmdBuffer ); 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /Engine/VisualStudio_D3D12/Aether3D_D3D12.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.23107.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Aether3D_D3D12", "Aether3D_D3D12.vcxproj", "{8175F3CB-546B-4D77-B5BC-7A0F2D32FFCB}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {8175F3CB-546B-4D77-B5BC-7A0F2D32FFCB}.Debug|x64.ActiveCfg = Debug|x64 15 | {8175F3CB-546B-4D77-B5BC-7A0F2D32FFCB}.Debug|x64.Build.0 = Debug|x64 16 | {8175F3CB-546B-4D77-B5BC-7A0F2D32FFCB}.Release|x64.ActiveCfg = Release|x64 17 | {8175F3CB-546B-4D77-B5BC-7A0F2D32FFCB}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Engine/VisualStudio_Vulkan/Aether3D_Vulkan.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Aether3D_Vulkan", "Aether3D_Vulkan.vcxproj", "{06F5885C-BFC6-454B-A06C-117E62C4FE73}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | OpenVR Debug|x64 = OpenVR Debug|x64 12 | OpenVR Release|x64 = OpenVR Release|x64 13 | Release|x64 = Release|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.Debug|x64.ActiveCfg = Debug|x64 17 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.Debug|x64.Build.0 = Debug|x64 18 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.OpenVR Debug|x64.ActiveCfg = OpenVR Debug|x64 19 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.OpenVR Debug|x64.Build.0 = OpenVR Debug|x64 20 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.OpenVR Release|x64.ActiveCfg = OpenVR Release|x64 21 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.OpenVR Release|x64.Build.0 = OpenVR Release|x64 22 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.Release|x64.ActiveCfg = Release|x64 23 | {06F5885C-BFC6-454B-A06C-117E62C4FE73}.Release|x64.Build.0 = Release|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {26A6CA4C-BACB-42E8-BECC-0231C4E8CB2F} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018-2022 Timo Wiren 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgement in the product documentation would be 14 | appreciated but is not required. 15 | 2. Altered source versions must be plainly marked as such, and must not be 16 | misrepresented as being the original software. 17 | 3. This notice may not be removed or altered from any source distribution. 18 | -------------------------------------------------------------------------------- /Samples/01_OpenWindow/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER ?= g++ 3 | VULKAN_LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lopenal -lvulkan 4 | LIB_PATH := -L. 5 | 6 | ifeq ($(OS),Windows_NT) 7 | LIB_PATH := -L../../Engine/ThirdParty/lib -I$(VULKAN_SDK)\Include 8 | endif 9 | 10 | WARNINGS := -g -Wpedantic -Wall -Wextra 11 | 12 | all: 13 | ifneq ($(OS),Windows_NT) 14 | mkdir -p ../../../aether3d_build/Samples 15 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -I../../Engine/ThirdParty -I../../Engine/Include OpenWindow.cpp -std=c++11 ../../../aether3d_build/libaether3d_linux_vulkan.a -o ../../../aether3d_build/Samples/OpenWindow_vulkan $(VULKAN_LINKER) 16 | endif 17 | ifeq ($(OS),Windows_NT) 18 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -L$(VULKAN_SDK)/Lib -I../../Engine/ThirdParty -I../../Engine/Include OpenWindow.cpp -std=c++11 ../../../aether3d_build/libaether3d_win_vulkan.a -o ../../../aether3d_build/Samples/OpenWindow_vulkan -lOpenAL32 -lgdi32 -lvulkan-1 19 | endif 20 | -------------------------------------------------------------------------------- /Samples/01_OpenWindow/VisualStudio/OpenWindow.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2018 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenWindow", "OpenWindow.vcxproj", "{E281525E-3C63-4BA2-A431-71B475AADBB4}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug D3D12|x64 = Debug D3D12|x64 11 | Debug Vulkan|x64 = Debug Vulkan|x64 12 | Release D3D12|x64 = Release D3D12|x64 13 | Release Vulkan|x64 = Release Vulkan|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Debug D3D12|x64.ActiveCfg = Debug D3D12|x64 17 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Debug D3D12|x64.Build.0 = Debug D3D12|x64 18 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Debug Vulkan|x64.ActiveCfg = Debug Vulkan|x64 19 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Debug Vulkan|x64.Build.0 = Debug Vulkan|x64 20 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Release D3D12|x64.ActiveCfg = Release D3D12|x64 21 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Release D3D12|x64.Build.0 = Release D3D12|x64 22 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Release Vulkan|x64.ActiveCfg = Release Vulkan|x64 23 | {E281525E-3C63-4BA2-A431-71B475AADBB4}.Release Vulkan|x64.Build.0 = Release Vulkan|x64 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {A5F66E4E-D0EA-4054-B044-B489E268CC5E} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /Samples/01_OpenWindow/VisualStudio/OpenWindow.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(TargetDir) 5 | WindowsLocalDebugger 6 | 7 | 8 | $(TargetDir) 9 | WindowsLocalDebugger 10 | 11 | 12 | $(TargetDir) 13 | WindowsLocalDebugger 14 | 15 | 16 | $(TargetDir) 17 | WindowsLocalDebugger 18 | 19 | 20 | $(TargetDir) 21 | WindowsLocalDebugger 22 | 23 | 24 | $(TargetDir) 25 | WindowsLocalDebugger 26 | 27 | 28 | $(TargetDir)\Samples\ 29 | WindowsLocalDebugger 30 | 31 | 32 | $(TargetDir)\Samples\ 33 | WindowsLocalDebugger 34 | 35 | 36 | $(TargetDir)\Samples\ 37 | WindowsLocalDebugger 38 | 39 | 40 | $(TargetDir)\Samples\ 41 | WindowsLocalDebugger 42 | 43 | 44 | $(TargetDir)\Samples\ 45 | WindowsLocalDebugger 46 | 47 | 48 | $(TargetDir)\Samples\ 49 | WindowsLocalDebugger 50 | 51 | -------------------------------------------------------------------------------- /Samples/03_Misc2D/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER ?= g++ 3 | VULKAN_LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal 4 | LIB_PATH := -L. 5 | 6 | ifeq ($(OS),Windows_NT) 7 | LIB_PATH := -L../../Engine/ThirdParty/lib -I$(VULKAN_SDK)\Include 8 | endif 9 | 10 | WARNINGS := -Wpedantic -Wall -Wextra 11 | 12 | all: 13 | ifneq ($(OS),Windows_NT) 14 | mkdir -p ../../../aether3d_build/Samples 15 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -I../../Engine/ThirdParty -I../../Engine/Include Misc2D.cpp -std=c++11 ../../../aether3d_build/libaether3d_linux_vulkan.a -o ../../../aether3d_build/Samples/Misc2D_vulkan $(VULKAN_LINKER) 16 | endif 17 | ifeq ($(OS),Windows_NT) 18 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -L$(VULKAN_SDK)/Lib -I../../Engine/ThirdParty -I../../Engine/Include Misc2D.cpp -std=c++11 ../../../aether3d_build/libaether3d_win_vulkan.a -o ../../../aether3d_build/Samples/Misc2D_vulkan -lOpenAL32 -lgdi32 -lvulkan-1 19 | endif 20 | -------------------------------------------------------------------------------- /Samples/03_Misc2D/VisualStudio/Misc2D.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27703.2018 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Misc2D", "Misc2D.vcxproj", "{2ECCA482-D6E6-4602-B349-287A90A60810}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug D3D12|x64 = Debug D3D12|x64 11 | Debug Vulkan|x64 = Debug Vulkan|x64 12 | Release D3D12|x64 = Release D3D12|x64 13 | EndGlobalSection 14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 15 | {2ECCA482-D6E6-4602-B349-287A90A60810}.Debug D3D12|x64.ActiveCfg = Debug D3D12|x64 16 | {2ECCA482-D6E6-4602-B349-287A90A60810}.Debug D3D12|x64.Build.0 = Debug D3D12|x64 17 | {2ECCA482-D6E6-4602-B349-287A90A60810}.Debug Vulkan|x64.ActiveCfg = Debug Vulkan|x64 18 | {2ECCA482-D6E6-4602-B349-287A90A60810}.Debug Vulkan|x64.Build.0 = Debug Vulkan|x64 19 | {2ECCA482-D6E6-4602-B349-287A90A60810}.Release D3D12|x64.ActiveCfg = Release D3D12|x64 20 | {2ECCA482-D6E6-4602-B349-287A90A60810}.Release D3D12|x64.Build.0 = Release D3D12|x64 21 | EndGlobalSection 22 | GlobalSection(SolutionProperties) = preSolution 23 | HideSolutionNode = FALSE 24 | EndGlobalSection 25 | GlobalSection(ExtensibilityGlobals) = postSolution 26 | SolutionGuid = {C112E6ED-F2AE-4AA0-A246-6661063BEF38} 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /Samples/03_Misc2D/VisualStudio/Misc2D.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(TargetDir) 5 | WindowsLocalDebugger 6 | 7 | 8 | $(TargetDir) 9 | WindowsLocalDebugger 10 | 11 | 12 | $(TargetDir) 13 | WindowsLocalDebugger 14 | 15 | 16 | $(TargetDir) 17 | WindowsLocalDebugger 18 | 19 | 20 | $(TargetDir) 21 | WindowsLocalDebugger 22 | 23 | 24 | $(TargetDir)\Samples 25 | WindowsLocalDebugger 26 | 27 | 28 | $(TargetDir)\Samples 29 | WindowsLocalDebugger 30 | 31 | 32 | $(TargetDir)\Samples 33 | WindowsLocalDebugger 34 | 35 | 36 | $(TargetDir)\Samples 37 | WindowsLocalDebugger 38 | 39 | 40 | $(TargetDir)\Samples 41 | WindowsLocalDebugger 42 | 43 | -------------------------------------------------------------------------------- /Samples/04_Misc3D/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER ?= g++ 3 | VULKAN_LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal 4 | VULKAN_LINKER_OPENVR := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal -lopenvr_api 5 | LIB_PATH := -L. -L../../Engine/ThirdParty/lib 6 | 7 | ifeq ($(OS),Windows_NT) 8 | LIB_PATH := -L../../Engine/ThirdParty/lib -I$(VULKAN_SDK)\Include 9 | endif 10 | 11 | WARNINGS := -g -Wpedantic -Wall -Wextra 12 | SANITIZERS := -fsanitize=address,undefined 13 | 14 | all: 15 | ifneq ($(OS),Windows_NT) 16 | mkdir -p ../../../aether3d_build/Samples 17 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -I../../Engine/ThirdParty -I../../Engine/Include Misc3D.cpp -std=c++11 ../../../aether3d_build/libaether3d_linux_vulkan.a -o ../../../aether3d_build/Samples/Misc3D_vulkan $(VULKAN_LINKER) 18 | endif 19 | ifeq ($(OS),Windows_NT) 20 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -L$(VULKAN_SDK)/Lib -I../../Engine/ThirdParty -I../../Engine/Include Misc3D.cpp -std=c++11 ../../../aether3d_build/libaether3d_win_vulkan.a -o ../../../aether3d_build/Samples/Misc3D_vulkan -lOpenAL32 -lgdi32 -lvulkan-1 21 | endif 22 | 23 | vulkan_openvr: 24 | mkdir -p ../../../aether3d_build/Samples 25 | $(COMPILER) -DRENDERER_VULKAN -DAE3D_OPENVR $(WARNINGS) $(LIB_PATH) -I../../Engine/ThirdParty -I../../Engine/Include Misc3D.cpp -std=c++11 ../../../aether3d_build/libaether3d_linux_vulkan_openvr.a -o ../../../aether3d_build/Samples/Misc3D_vulkan_openvr $(VULKAN_LINKER_OPENVR) 26 | 27 | -------------------------------------------------------------------------------- /Samples/04_Misc3D/VisualStudio/Misc3D.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.27428.2015 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Misc3D", "Misc3D.vcxproj", "{35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug D3D12|x64 = Debug D3D12|x64 11 | Debug Vulkan OpenVR|x64 = Debug Vulkan OpenVR|x64 12 | Debug Vulkan|x64 = Debug Vulkan|x64 13 | Release D3D12|x64 = Release D3D12|x64 14 | Release Vulkan OpenVR|x64 = Release Vulkan OpenVR|x64 15 | Release Vulkan|x64 = Release Vulkan|x64 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Debug D3D12|x64.ActiveCfg = D3D12 Debug|x64 19 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Debug D3D12|x64.Build.0 = D3D12 Debug|x64 20 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Debug Vulkan OpenVR|x64.ActiveCfg = Debug Vulkan OpenVR|x64 21 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Debug Vulkan OpenVR|x64.Build.0 = Debug Vulkan OpenVR|x64 22 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Debug Vulkan|x64.ActiveCfg = Debug Vulkan|x64 23 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Debug Vulkan|x64.Build.0 = Debug Vulkan|x64 24 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Release D3D12|x64.ActiveCfg = D3D12 Release|x64 25 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Release D3D12|x64.Build.0 = D3D12 Release|x64 26 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Release Vulkan OpenVR|x64.ActiveCfg = Release Vulkan OpenVR|x64 27 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Release Vulkan OpenVR|x64.Build.0 = Release Vulkan OpenVR|x64 28 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Release Vulkan|x64.ActiveCfg = Release Vulkan|x64 29 | {35F2C02B-FFF4-4D85-B36B-F0E1D3E060C5}.Release Vulkan|x64.Build.0 = Release Vulkan|x64 30 | EndGlobalSection 31 | GlobalSection(SolutionProperties) = preSolution 32 | HideSolutionNode = FALSE 33 | EndGlobalSection 34 | GlobalSection(ExtensibilityGlobals) = postSolution 35 | SolutionGuid = {2D7F3054-1B55-4B59-A53A-160891E007A1} 36 | EndGlobalSection 37 | EndGlobal 38 | -------------------------------------------------------------------------------- /Samples/City/City/City.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/City/City/City.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(TargetDir)\Samples 5 | WindowsLocalDebugger 6 | 7 | 8 | $(TargetDir)\Samples 9 | WindowsLocalDebugger 10 | 11 | 12 | $(TargetDir)\Samples 13 | WindowsLocalDebugger 14 | 15 | 16 | $(TargetDir)\Samples 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /Samples/City/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER ?= g++ 3 | VULKAN_LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal 4 | LIB_PATH := -L. -L../../Engine/ThirdParty/lib 5 | 6 | ifeq ($(OS),Windows_NT) 7 | LIB_PATH := -L../../Engine/ThirdParty/lib -I$(VULKAN_SDK)\Include 8 | endif 9 | 10 | WARNINGS := -g -Wpedantic -Wall -Wextra 11 | SANITIZERS := -fsanitize=address,undefined 12 | 13 | all: 14 | ifneq ($(OS),Windows_NT) 15 | mkdir -p ../../../aether3d_build/Samples 16 | $(COMPILER) -DDEBUG -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -I../../Engine/ThirdParty -I../../Engine/Include city.cpp -std=c++11 ../../../aether3d_build/libaether3d_linux_vulkan.a -o ../../../aether3d_build/Samples/city_vulkan $(VULKAN_LINKER) 17 | endif 18 | ifeq ($(OS),Windows_NT) 19 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -L$(VULKAN_SDK)/Lib -I../../Engine/ThirdParty -I../../Engine/Include city.cpp -std=c++11 ../../../aether3d_build/libaether3d_win_vulkan.a -o ../../../aether3d_build/Samples/city_vulkan -lOpenAL32 -lgdi32 -lvulkan-1 20 | endif 21 | 22 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Samples/MetalSampleOSX/MetalSampleOSX.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX.xcodeproj/xcuserdata/glaze.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX.xcodeproj/xcuserdata/glaze.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MetalSampleOSX.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | ABE04F7A1C1216A80025C436 16 | 17 | primary 18 | 19 | 20 | ABE04F931C1216A80025C436 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AppDelegate : NSObject 4 | 5 | @property (assign) IBOutlet NSWindow *window; 6 | 7 | @end -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | @interface AppDelegate () 4 | 5 | @end 6 | 7 | extern NSViewController* myViewController; 8 | 9 | @implementation AppDelegate 10 | 11 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 12 | { 13 | [_window setTitle: @"Aether3D Metal Sample"]; 14 | [_window center]; 15 | [_window makeFirstResponder:myViewController]; 16 | [[ [myViewController view] window ] setAcceptsMouseMovedEvents:YES]; 17 | } 18 | 19 | - (void)applicationWillTerminate:(NSNotification *)aNotification 20 | { 21 | // Insert code here to tear down your application 22 | } 23 | 24 | - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender 25 | { 26 | return YES; 27 | } 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX/GameViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GameViewController : NSViewController 5 | 6 | 7 | @end -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | NSHighResolutionCapable 6 | 7 | CFBundleDevelopmentRegion 8 | en 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | $(PRODUCT_BUNDLE_IDENTIFIER) 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | $(PRODUCT_NAME) 19 | CFBundlePackageType 20 | APPL 21 | CFBundleShortVersionString 22 | 1.0 23 | CFBundleSignature 24 | ???? 25 | CFBundleVersion 26 | 1 27 | LSMinimumSystemVersion 28 | $(MACOSX_DEPLOYMENT_TARGET) 29 | NSHumanReadableCopyright 30 | Copyright © 2017 Timo Wiren. All rights reserved. 31 | NSMainNibFile 32 | MainMenu 33 | NSPrincipalClass 34 | NSApplication 35 | 36 | 37 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSX/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | int main(int argc, const char * argv[]) { 4 | return NSApplicationMain(argc, argv); 5 | } 6 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSXTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Samples/MetalSampleOSX/MetalSampleOSXTests/MetalSampleOSXTests.m: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface MetalSampleOSXTests : XCTestCase 4 | 5 | @end 6 | 7 | @implementation MetalSampleOSXTests 8 | 9 | - (void)setUp { 10 | [super setUp]; 11 | // Put setup code here. This method is called before the invocation of each test method in the class. 12 | } 13 | 14 | - (void)tearDown { 15 | // Put teardown code here. This method is called after the invocation of each test method in the class. 16 | [super tearDown]; 17 | } 18 | 19 | - (void)testExample { 20 | // This is an example of a functional test case. 21 | // Use XCTAssert and related functions to verify your tests produce the correct results. 22 | } 23 | 24 | - (void)testPerformanceExample { 25 | // This is an example of a performance test case. 26 | [self measureBlock:^{ 27 | // Put the code you want to measure the time of here. 28 | }]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Samples/MetalSampleiOS/MetalSampleiOS.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS.xcodeproj/xcuserdata/glaze.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 9 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS.xcodeproj/xcuserdata/glaze.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | MetalSampleiOS.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | ABA29F3F1C19E1F90098E21D 16 | 17 | primary 18 | 19 | 20 | ABA29F5B1C19E1F90098E21D 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AppDelegate : UIResponder 4 | 5 | @property (strong, nonatomic) UIWindow *window; 6 | 7 | 8 | @end 9 | 10 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | @interface AppDelegate () 4 | 5 | @end 6 | 7 | @implementation AppDelegate 8 | 9 | 10 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 11 | // Override point for customization after application launch. 12 | return YES; 13 | } 14 | 15 | - (void)applicationWillResignActive:(UIApplication *)application { 16 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 17 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 18 | } 19 | 20 | - (void)applicationDidEnterBackground:(UIApplication *)application { 21 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 22 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 23 | } 24 | 25 | - (void)applicationWillEnterForeground:(UIApplication *)application { 26 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 27 | } 28 | 29 | - (void)applicationDidBecomeActive:(UIApplication *)application { 30 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 31 | } 32 | 33 | - (void)applicationWillTerminate:(UIApplication *)application { 34 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/GameViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | 5 | @interface GameViewController : UIViewController 6 | 7 | @end 8 | 9 | 10 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | metal 33 | 34 | UIRequiresFullScreen 35 | 36 | UIStatusBarHidden 37 | 38 | UISupportedInterfaceOrientations 39 | 40 | UIInterfaceOrientationLandscapeLeft 41 | UIInterfaceOrientationLandscapeRight 42 | 43 | UISupportedInterfaceOrientations~ipad 44 | 45 | UIInterfaceOrientationPortrait 46 | UIInterfaceOrientationPortraitUpsideDown 47 | UIInterfaceOrientationLandscapeLeft 48 | UIInterfaceOrientationLandscapeRight 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOS/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // MetalSampleiOS 4 | // 5 | // Created by Timo Wiren on 10/12/15. 6 | // Copyright © 2015 Timo Wiren. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOSTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Samples/MetalSampleiOS/MetalSampleiOSTests/MetalSampleiOSTests.mm: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface MetalSampleiOSTests : XCTestCase 4 | 5 | @end 6 | 7 | @implementation MetalSampleiOSTests 8 | 9 | - (void)setUp { 10 | [super setUp]; 11 | // Put setup code here. This method is called before the invocation of each test method in the class. 12 | } 13 | 14 | - (void)tearDown { 15 | // Put teardown code here. This method is called after the invocation of each test method in the class. 16 | [super tearDown]; 17 | } 18 | 19 | - (void)testExample { 20 | // This is an example of a functional test case. 21 | // Use XCTAssert and related functions to verify your tests produce the correct results. 22 | } 23 | 24 | - (void)testPerformanceExample { 25 | // This is an example of a performance test case. 26 | [self measureBlock:^{ 27 | // Put the code you want to measure the time of here. 28 | }]; 29 | } 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /Samples/NuklearTest/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER ?= g++ 3 | VULKAN_LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal 4 | LIB_PATH := -L. 5 | 6 | ifeq ($(OS),Windows_NT) 7 | LIB_PATH := -L../../Engine/ThirdParty/lib -I$(VULKAN_SDK)\Include 8 | endif 9 | 10 | WARNINGS := -g -Wpedantic -Wall -Wextra 11 | 12 | all: 13 | ifneq ($(OS),Windows_NT) 14 | mkdir -p ../../../aether3d_build/Samples 15 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -I../../Engine/ThirdParty -I../../Engine/Include NuklearTest.cpp -std=c++11 ../../../aether3d_build/libaether3d_linux_vulkan.a -o ../../../aether3d_build/Samples/NuklearTest_vulkan $(VULKAN_LINKER) 16 | endif 17 | ifeq ($(OS),Windows_NT) 18 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -L$(VULKAN_SDK)/Lib -I../../Engine/ThirdParty -I../../Engine/Include NuklearTest.cpp -std=c++11 ../../../aether3d_build/libaether3d_win_vulkan.a -o ../../../aether3d_build/Samples/NuklearTest_vulkan -lOpenAL32 -lgdi32 -lvulkan-1 19 | endif 20 | 21 | -------------------------------------------------------------------------------- /Samples/NuklearTest/VisualStudio/NuklearTest.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Samples/NuklearTest/VisualStudio/NuklearTest.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(TargetDir)\Samples 5 | WindowsLocalDebugger 6 | 7 | 8 | $(TargetDir)\Samples 9 | WindowsLocalDebugger 10 | 11 | 12 | $(TargetDir)\Samples 13 | WindowsLocalDebugger 14 | 15 | 16 | $(TargetDir)\Samples 17 | WindowsLocalDebugger 18 | 19 | -------------------------------------------------------------------------------- /Samples/PBRSample/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER ?= g++ 3 | VULKAN_LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal 4 | LIB_PATH := -L. -L../../Engine/ThirdParty/lib 5 | 6 | ifeq ($(OS),Windows_NT) 7 | LIB_PATH := -L../../Engine/ThirdParty/lib -I$(VULKAN_SDK)\Include 8 | endif 9 | 10 | WARNINGS := -g -Wpedantic -Wall -Wextra 11 | SANITIZERS := -fsanitize=address,undefined 12 | 13 | all: 14 | ifneq ($(OS),Windows_NT) 15 | mkdir -p ../../../aether3d_build/Samples 16 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -I../../Engine/ThirdParty -I../../Engine/Include PBRSample.cpp -std=c++11 ../../../aether3d_build/libaether3d_linux_vulkan.a -o ../../../aether3d_build/Samples/PBRSample_vulkan $(VULKAN_LINKER) 17 | endif 18 | ifeq ($(OS),Windows_NT) 19 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -L$(VULKAN_SDK)/Lib -I../../Engine/ThirdParty -I../../Engine/Include PBRSample.cpp -std=c++11 ../../../aether3d_build/libaether3d_win_vulkan.a -o ../../../aether3d_build/Samples/PBRSample_vulkan -lOpenAL32 -lgdi32 -lvulkan-1 20 | endif 21 | 22 | -------------------------------------------------------------------------------- /Samples/PBRSample/PBRSample/PBRSample.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} 14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms 15 | 16 | 17 | 18 | 19 | Source Files 20 | 21 | 22 | -------------------------------------------------------------------------------- /Samples/PBRSample/PBRSample/PBRSample.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(TargetDir)\Samples 5 | WindowsLocalDebugger 6 | 7 | 8 | $(TargetDir)\Samples 9 | WindowsLocalDebugger 10 | 11 | -------------------------------------------------------------------------------- /Tools/CombineFiles/CombineFiles.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | Combines files listed in input text file into one. 3 | 4 | Usage: CombineFiles input.txt output 5 | 6 | Input file contains one path per line. 7 | 8 | Output file's first 4 bytes is the block count. After it blocks are followed where data is ordered like below: 9 | offset data 10 | 0 file name 11 | 128 file length 12 | 132 file contents 13 | */ 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | struct FileMetaBlock 23 | { 24 | std::string path; 25 | unsigned dataSize; 26 | }; 27 | 28 | int main( int argCount, char* args[] ) 29 | { 30 | if (argCount != 3) 31 | { 32 | std::cout << "Usage: CombineFiles indexFile.txt outputfile" << std::endl; 33 | return 1; 34 | } 35 | 36 | std::ifstream fileListFile( args[ 1 ] ); 37 | if (!fileListFile.is_open()) 38 | { 39 | std::cout << "Could not open " << args[ 1 ] << std::endl; 40 | return 1; 41 | } 42 | 43 | std::list< FileMetaBlock > fileList; 44 | std::string line; 45 | const unsigned MaxPathLength = 128; 46 | 47 | while (std::getline( fileListFile, line )) 48 | { 49 | fileList.push_back( FileMetaBlock() ); 50 | fileList.back().path = line; 51 | 52 | if (line.length() > MaxPathLength) 53 | { 54 | std::cout << "Too long path in " << line << ". Max length is " << MaxPathLength << std::endl; 55 | return 1; 56 | } 57 | } 58 | 59 | // 1st pass: Determine file sizes. 60 | for (auto& file : fileList) 61 | { 62 | std::ifstream ifs( file.path ); 63 | ifs.seekg( 0, std::ios::end ); 64 | file.dataSize = static_cast< unsigned >( ifs.tellg() ); 65 | } 66 | 67 | std::ofstream ofs( args[ 2 ], std::ios::out | std::ios::binary ); 68 | const unsigned listLength = static_cast< unsigned >( fileList.size() ); 69 | ofs.write( (char*)&listLength, 4 ); 70 | 71 | for (const auto& file : fileList) 72 | { 73 | char path[ MaxPathLength ] = { 0 }; 74 | std::strcpy( path, file.path.c_str() ); 75 | ofs.write( (char*)path, MaxPathLength ); 76 | ofs.write( (char*)&file.dataSize, 4 ); 77 | std::vector< unsigned char > data; 78 | std::ifstream ifs( file.path ); 79 | data.assign( std::istreambuf_iterator< char >( ifs ), std::istreambuf_iterator< char >() ); 80 | ofs.write( (char*)data.data(), data.size() ); 81 | } 82 | 83 | return 0; 84 | } 85 | -------------------------------------------------------------------------------- /Tools/CombineFiles/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER := g++ 3 | WARNINGS := -Wall -pedantic -Wextra -Wcast-align -Wctor-dtor-privacy -Wdisabled-optimization \ 4 | -Wdouble-promotion -Wformat=2 -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs \ 5 | -Wshadow -Wredundant-decls -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wtrampolines \ 6 | -Wunsafe-loop-optimizations -Wvector-operation-performance -Wzero-as-null-pointer-constant 7 | 8 | ifeq ($(UNAME), Darwin) 9 | COMPILER := clang++ 10 | WARNINGS := -Weverything -Wno-old-style-cast -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic \ 11 | -Wno-exit-time-destructors -Wno-float-equal -Wno-unused-macros -Wno-sign-conversion \ 12 | -Wno-missing-variable-declarations -Wno-undef -Wno-missing-prototypes -Wno-documentation \ 13 | -Wno-implicit-fallthrough -Wno-global-constructors 14 | 15 | endif 16 | 17 | all: 18 | $(COMPILER) $(WARNINGS) -std=c++11 CombineFiles.cpp -o ../../../aether3d_build/CombineFiles 19 | 20 | -------------------------------------------------------------------------------- /Tools/CombineFiles/VisualStudio/CombineFiles.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | 10 | 11 | Source Files 12 | 13 | 14 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/Editor.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/Editor.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Tools/Editor/Editor/Editor.xcodeproj/project.xcworkspace/xcuserdata/glaze.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Tools/Editor/Editor/Editor.xcodeproj/xcuserdata/glaze.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | Editor.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | Editor.xcscheme_^#shared#^_ 13 | 14 | orderHint 15 | 0 16 | 17 | 18 | SuppressBuildableAutocreation 19 | 20 | AB010CD0206F70B40014ED08 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/Inspector.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | class GameObject; 6 | class Material; 7 | } 8 | 9 | class Inspector 10 | { 11 | public: 12 | enum class Command { Empty, CreateGO, OpenScene, SaveScene }; 13 | 14 | void Init(); 15 | bool IsTextEditActive(); 16 | void SetTextEditText( const char* str ); 17 | void BeginInput(); 18 | void EndInput(); 19 | void Deinit(); 20 | void HandleLeftMouseClick( int x, int y, int state ); 21 | void HandleMouseScroll( int y ); 22 | void HandleMouseMotion( int x, int y ); 23 | void HandleKey( int key, int state ); 24 | void HandleChar( char ch ); 25 | void Render( unsigned width, unsigned height, ae3d::GameObject* gameObject, Command& outCommand, ae3d::GameObject** gameObjects, unsigned goCount, ae3d::Material* material, int& outSelectedGameObject ); 26 | bool IsSSAOEnabled() const { return ssao; } 27 | bool IsBloomEnabled() const { return bloom; } 28 | float GetBloomThreshold() const { return bloomThreshold; } 29 | float GetBloomIntensity() const { return bloomIntensity; } 30 | 31 | private: 32 | float bloomThreshold; 33 | float bloomIntensity; 34 | bool textEditActive; 35 | bool ssao; 36 | bool bloom; 37 | }; 38 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER ?= g++ 3 | LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lGL -lopenal 4 | VULKAN_LINKER := -ldl -lxcb -lxcb-ewmh -lxcb-keysyms -lxcb-icccm -lX11-xcb -lX11 -lvulkan -lopenal 5 | LIB_PATH := -L. 6 | 7 | ifeq ($(OS),Windows_NT) 8 | LINKER := -lOpenAL32 -lOpenGL32 -lgdi32 9 | LIB_PATH := -L../../../Engine/ThirdParty/lib -I$(VULKAN_SDK)\Include 10 | endif 11 | 12 | SANITIZERS := -fsanitize=address,undefined 13 | WARNINGS := -g -Wpedantic -Wall -Wextra 14 | 15 | all: 16 | ifeq ($(OS),Windows_NT) 17 | IF exist ..\..\..\..\aether3d_build\Samples ( echo building ) ELSE ( mkdir ..\..\..\..\aether3d_build\Samples ) 18 | $(COMPILER) -DRENDERER_VULKAN -D_MSC_VER $(WARNINGS) $(LIB_PATH) -I../../../Engine/ThirdParty -I../../../Engine/Include main.cpp Inspector.cpp SceneView.cpp -std=c++11 ../../../../aether3d_build/libaether3d_win_vulkan.a -o ../../../../aether3d_build/Samples/Editor_vulkan $(VULKAN_LINKER) 19 | endif 20 | ifneq ($(OS),Windows_NT) 21 | mkdir -p ../../../../aether3d_build/Samples 22 | $(COMPILER) -DRENDERER_VULKAN $(WARNINGS) $(LIB_PATH) -I../../../Engine/ThirdParty -I../../../Engine/Include main.cpp Inspector.cpp SceneView.cpp -std=c++11 ../../../../aether3d_build/libaether3d_linux_vulkan.a -o ../../../../aether3d_build/Samples/Editor_vulkan $(VULKAN_LINKER) 23 | endif 24 | 25 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/SceneView.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace ae3d 4 | { 5 | class GameObject; 6 | class Material; 7 | struct Vec3; 8 | 9 | namespace FileSystem 10 | { 11 | struct FileContentsData; 12 | } 13 | } 14 | 15 | struct SceneView; 16 | 17 | enum class SSAO 18 | { 19 | Enabled, 20 | Disabled, 21 | }; 22 | 23 | enum class Bloom 24 | { 25 | Enabled, 26 | Disabled, 27 | }; 28 | 29 | enum class CollisionFilter 30 | { 31 | All, 32 | ExcludeGizmo, 33 | OnlyGizmo, 34 | }; 35 | 36 | float svGetCameraSign( SceneView* sv ); 37 | void svInit( SceneView** sceneView, int width, int height ); 38 | bool svIsDraggingGizmo( SceneView* sv ); 39 | void svAddGameObject( SceneView* sceneView ); 40 | void svDuplicateGameObject( SceneView* sceneView ); 41 | void svDrawSprites( SceneView* sv, unsigned screenWidth, unsigned screenHeight ); 42 | void svBeginRender( SceneView* sceneView, SSAO ssao, Bloom bloom, float bloomThreshold, float bloomIntensity ); 43 | void svEndRender( SceneView* sceneView ); 44 | ae3d::Material* svGetMaterial( SceneView* sceneView ); 45 | bool svIsTransformGizmoSelected( SceneView* sceneView ); 46 | ae3d::GameObject** svGetGameObjects( SceneView* sceneView, int& outCount ); 47 | void svLoadScene( SceneView* sceneView, const ae3d::FileSystem::FileContentsData& contents ); 48 | void svSaveScene( SceneView* sceneView, char* path ); 49 | void svRotateCamera( SceneView* sceneView, float xDegrees, float yDegrees ); 50 | void svMoveCamera( SceneView* sceneView, const ae3d::Vec3& moveDir ); 51 | void svHandleMouseMotion( SceneView* sv, int deltaX, int deltaY ); 52 | void svHandleLeftMouseDown( SceneView* sv, int screenX, int screenY, int width, int height ); 53 | void svHandleLeftMouseUp( SceneView* sv ); 54 | void svMoveSelection( SceneView* sceneView, const ae3d::Vec3& moveDir ); 55 | ae3d::GameObject* svSelectObject( SceneView* sceneView, int screenX, int screenY, int width, int height ); 56 | ae3d::GameObject* svSelectGameObjectIndex( SceneView* sceneView, int index ); 57 | void svDeleteGameObject( SceneView* sceneView ); 58 | void svFocusOnSelected( SceneView* sceneView ); 59 | void svUpdate( SceneView* sceneView ); 60 | void svHighlightGizmo( SceneView* sv, int screenX, int screenY, int width, int height ); 61 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/VisualStudio/Editor.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/VisualStudio/Editor.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(TargetDir)\Samples 5 | WindowsLocalDebugger 6 | 7 | 8 | $(TargetDir)\Samples 9 | WindowsLocalDebugger 10 | 11 | 12 | $(TargetDir)\Samples 13 | WindowsLocalDebugger 14 | 15 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/AppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AppDelegate : NSObject 4 | 5 | @property (assign) IBOutlet NSWindow *window; 6 | 7 | @end 8 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/AppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "AppDelegate.h" 2 | 3 | @interface AppDelegate () 4 | 5 | @end 6 | 7 | extern NSViewController* myViewController; 8 | extern float backingScale; 9 | 10 | @implementation AppDelegate 11 | 12 | - (void)applicationDidFinishLaunching:(NSNotification *)aNotification 13 | { 14 | [[ [myViewController view] window ] makeFirstResponder:myViewController]; 15 | [[ [myViewController view] window ] setAcceptsMouseMovedEvents:YES]; 16 | backingScale = [[ [myViewController view] window ] backingScaleFactor]; 17 | } 18 | 19 | - (void)applicationWillTerminate:(NSNotification *)aNotification 20 | { 21 | } 22 | 23 | - (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender 24 | { 25 | return YES; 26 | } 27 | 28 | @end 29 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/Assets.xcassets/ColorMap.textureset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | }, 6 | "properties" : { 7 | "origin" : "bottom-left", 8 | "interpretation" : "non-premultiplied-colors" 9 | }, 10 | "textures" : [ 11 | { 12 | "idiom" : "universal", 13 | "filename" : "Universal.mipmapset" 14 | } 15 | ] 16 | } 17 | 18 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bioglaze/aether3d/56451f547165c68e7e43acd34881cc8dbe66faa8/Tools/Editor/Editor/macOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/ColorMap.png -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/Assets.xcassets/ColorMap.textureset/Universal.mipmapset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | }, 6 | "levels" : [ 7 | { 8 | "filename" : "ColorMap.png", 9 | "mipmap-level" : "base" 10 | } 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/Editor.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/GameViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | 4 | @interface GameViewController : NSViewController 5 | 6 | @end 7 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | Copyright © 2018 Timo Wiren. All rights reserved. 27 | NSMainStoryboardFile 28 | Main 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /Tools/Editor/Editor/macOS/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // Editor 4 | // 5 | // Created by Timo Wiren on 31/03/2018. 6 | // Copyright © 2018 Timo Wiren. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, const char * argv[]) { 12 | return NSApplicationMain(argc, argv); 13 | } 14 | -------------------------------------------------------------------------------- /Tools/FBX_Converter/ConvertFBX.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConvertFBX", "ConvertFBX.vcxproj", "{BA497D54-8968-4B73-83A0-E2C46457A32D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {BA497D54-8968-4B73-83A0-E2C46457A32D}.Debug|x64.ActiveCfg = Debug|x64 15 | {BA497D54-8968-4B73-83A0-E2C46457A32D}.Debug|x64.Build.0 = Debug|x64 16 | {BA497D54-8968-4B73-83A0-E2C46457A32D}.Release|x64.ActiveCfg = Release|x64 17 | {BA497D54-8968-4B73-83A0-E2C46457A32D}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tools/FBX_Converter/ConvertFBX.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Tools/FBX_Converter/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER := clang++ -Ifbx_sdk/include -Lfbx_sdk/lib/linux/x64 -ldl -lfbxsdk 3 | 4 | ifeq ($(UNAME), Darwin) 5 | COMPILER := clang++ --stdlib=libc++ -ldl -framework CoreFoundation 6 | FBX_INCLUDE := -I"/Applications/Autodesk/FBX SDK/2020.1.1/include" 7 | FBX_LIB := -liconv -lxml2 -lz "/Applications/Autodesk/FBX SDK/2020.1.1/lib/clang/release/libfbxsdk.a" 8 | all: 9 | $(COMPILER) -DRENDERER_NULL -g -std=c++11 $(FBX_LIB) convert_fbx.cpp ../../Engine/Core/Matrix.cpp $(FBX_INCLUDE) -I../../Engine/Include -o ../../../aether3d_build/convert_fbx 10 | endif 11 | 12 | ifeq ($(UNAME), Linux) 13 | COMPILER := g++ 14 | FBX_INCLUDE := -I/home/glaze/Downloads/fbx_sdk/include 15 | FBX_LIB := /home/glaze/Downloads/fbx_sdk/lib/gcc/x64/release/libfbxsdk.a -lxml2 -lz 16 | GCCWARNINGS := -Wall -pedantic -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization \ 17 | -Wdouble-promotion -Wformat=2 -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs \ 18 | -Wshadow -Wredundant-decls -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wtrampolines \ 19 | -Wunsafe-loop-optimizations -Wvector-operation-performance -Wuseless-cast -Wformat=2 20 | all: 21 | $(COMPILER) -DRENDERER_NULL -g -std=c++11 convert_fbx.cpp $(FBX_LIB) -lpthread -ldl ../../Engine/Core/Matrix.cpp $(FBX_INCLUDE) -I../../Engine/Include -o ../../../aether3d_build/convert_fbx 22 | endif 23 | 24 | -------------------------------------------------------------------------------- /Tools/OBJ_Converter/ConvertOBJ/ConvertOBJ.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25123.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ConvertOBJ", "ConvertOBJ.vcxproj", "{B1DEB1C2-54AC-4056-AACD-268E57B8742D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Release|x64 = Release|x64 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {B1DEB1C2-54AC-4056-AACD-268E57B8742D}.Debug|x64.ActiveCfg = Debug|x64 15 | {B1DEB1C2-54AC-4056-AACD-268E57B8742D}.Debug|x64.Build.0 = Debug|x64 16 | {B1DEB1C2-54AC-4056-AACD-268E57B8742D}.Release|x64.ActiveCfg = Release|x64 17 | {B1DEB1C2-54AC-4056-AACD-268E57B8742D}.Release|x64.Build.0 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | EndGlobal 23 | -------------------------------------------------------------------------------- /Tools/OBJ_Converter/ConvertOBJ/ConvertOBJ.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Tools/OBJ_Converter/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER := g++ 3 | 4 | WARNINGS := -Wall -Wpedantic -Wextra -Wcast-align -Wctor-dtor-privacy -Wdisabled-optimization \ 5 | -Wdouble-promotion -Wformat=2 -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs \ 6 | -Wshadow -Wredundant-decls -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wtrampolines \ 7 | -Wunsafe-loop-optimizations -Wvector-operation-performance -Wzero-as-null-pointer-constant 8 | 9 | ifeq ($(UNAME), Darwin) 10 | COMPILER := clang++ 11 | WARNINGS := -g -Weverything -Wno-old-style-cast -Wno-padded -Wno-c++98-compat -Wno-c++98-compat-pedantic \ 12 | -Wno-exit-time-destructors -Wno-float-equal -Wno-unused-macros -Wno-sign-conversion \ 13 | -Wno-missing-variable-declarations -Wno-undef -Wno-missing-prototypes -Wno-documentation \ 14 | -Wno-implicit-fallthrough -Wno-global-constructors 15 | 16 | endif 17 | 18 | all: 19 | $(COMPILER) $(WARNINGS) -std=c++11 convert_obj.cpp -I../../Engine/Include -o ../../../aether3d_build/convert_obj 20 | 21 | -------------------------------------------------------------------------------- /Tools/OBJ_Converter/Makefile_mtl: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER := g++ 3 | 4 | ifeq ($(UNAME), Darwin) 5 | COMPILER := clang++ --stdlib=libc++ 6 | endif 7 | 8 | all: 9 | $(COMPILER) -g -std=c++11 -Wall -Wextra read_mtl.cpp -o ../../../aether3d_build/read_mtl 10 | 11 | -------------------------------------------------------------------------------- /Tools/OBJ_Converter/Read_MTL/Read_MTL.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Tools/OBJ_Converter/Read_MTL/Read_MTL.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | exp_sponza.obj 5 | $(TargetDir) 6 | WindowsLocalDebugger 7 | 8 | -------------------------------------------------------------------------------- /Tools/SDF_Generator/Makefile: -------------------------------------------------------------------------------- 1 | UNAME := $(shell uname) 2 | COMPILER := g++ 3 | CCOMPILER := gcc 4 | WARNINGS := -Wall -pedantic -Wextra -Wcast-align -Wctor-dtor-privacy -Wdisabled-optimization -Wdouble-promotion -Wformat=2 -Winit-self -Winvalid-pch -Wlogical-op -Wmissing-include-dirs -Wshadow -Wredundant-decls -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wtrampolines -Wunsafe-loop-optimizations -Wvector-operation-performance -Wzero-as-null-pointer-constant 5 | 6 | ifeq ($(UNAME), Darwin) 7 | COMPILER := clang++ 8 | CCOMPILER := clang 9 | WARNINGS := -Wall -Wextra -pedantic 10 | endif 11 | 12 | all: 13 | $(CCOMPILER) -c ../../Engine/ThirdParty/stb_image.c -o stb_image.o 14 | $(COMPILER) $(WARNINGS) -std=c++11 -g -I../../Engine/ThirdParty SDF_Generator.cpp stb_image.o -o ../../../aether3d_build/SDF_Generator 15 | 16 | --------------------------------------------------------------------------------