├── .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