├── .github └── workflows │ └── nfe-ci.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── Data ├── BlueNoise128_RGBA16.dat ├── Fonts │ └── DroidSans-Regular.otf └── TestScenes │ ├── area_light_test.json │ ├── background_light_test.json │ ├── bitmap_texture_test.json │ ├── cornell_box.json │ ├── cornell_box_obstructed.json │ ├── directional_light_test.json │ ├── dispersion_test.json │ ├── dof_test.json │ ├── furnace_test.json │ ├── furnace_test_2.json │ ├── glass_bunny.json │ ├── glossy_refraction_test.json │ ├── material_env_test.json │ ├── material_perf_test.json │ ├── materials_test.json │ ├── mesh_light_test.json │ ├── mis_test.json │ ├── sds.json │ ├── sds_test.json │ ├── shapes_test.json │ ├── small_light_test.json │ ├── sphere_light_test.json │ ├── sponza.json │ └── texture_test.json ├── Deps ├── .gitignore ├── CMakeLists.txt ├── cmake │ └── NFEGetAllTargets.cmake ├── deps_builder.py ├── post_build.bat └── post_build.sh ├── Engine.sln ├── Gallery ├── 1.jpg ├── 2.jpg ├── caustics.jpg ├── rough_glass.jpg └── sponza.jpg ├── LICENSE ├── README.md ├── Scripts ├── build.sh ├── clean.bat ├── clean.sh ├── clear.sh ├── color.py ├── cppcheck.bat ├── cppcheck.sh ├── doxygen.cfg ├── gen_doc.bat ├── gen_doc.sh ├── pre-commit.bat ├── pre-commit.sh ├── rebuild-all.sh ├── syncher.py ├── tests.py └── xmlParser.py ├── Src ├── Apps │ ├── CMakeLists.txt │ ├── EngineDemo │ │ ├── CMakeLists.txt │ │ ├── Controllers │ │ │ ├── FlickeringLightController.cpp │ │ │ ├── FlickeringLightController.hpp │ │ │ ├── FreeCameraController.cpp │ │ │ ├── FreeCameraController.hpp │ │ │ ├── TriggeredLightController.cpp │ │ │ └── TriggeredLightController.hpp │ │ ├── EngineDemo.vcxproj │ │ ├── EngineDemo.vcxproj.filters │ │ ├── GameWindow.cpp │ │ ├── GameWindow.hpp │ │ ├── Main.cpp │ │ ├── Main.hpp │ │ ├── PCH.cpp │ │ └── PCH.hpp │ ├── RaytracerDemo │ │ ├── CMakeLists.txt │ │ ├── CustomScene.cpp │ │ ├── Demo.cpp │ │ ├── Demo.h │ │ ├── DemoRenderer.cpp │ │ ├── DemoRenderer.h │ │ ├── Demo_UserInterface.cpp │ │ ├── Main.cpp │ │ ├── MeshLoader.cpp │ │ ├── MeshLoader.h │ │ ├── ObjectEditor.cpp │ │ ├── ObjectEditor.h │ │ ├── PCH.cpp │ │ ├── PCH.h │ │ ├── RaytracerDemo.vcxproj │ │ ├── RaytracerDemo.vcxproj.filters │ │ ├── SceneLoader.cpp │ │ └── SceneLoader.h │ └── RendererDemo │ │ ├── CMakeLists.txt │ │ ├── Common.cpp │ │ ├── Common.hpp │ │ ├── Main.cpp │ │ ├── PCH.cpp │ │ ├── PCH.hpp │ │ ├── RendererDemo.vcxproj │ │ ├── RendererDemo.vcxproj.filters │ │ ├── Scenes │ │ ├── Basic.cpp │ │ ├── Compute.cpp │ │ ├── DepthStencil.cpp │ │ ├── DynamicTexture.cpp │ │ ├── Multisample.cpp │ │ ├── Multithreaded.cpp │ │ ├── RenderTargets.cpp │ │ ├── Scene.cpp │ │ ├── Scene.hpp │ │ └── VertexBuffers.cpp │ │ └── Shaders │ │ └── HLSL5 │ │ ├── InstancingTestPS.hlsl │ │ ├── InstancingTestVS.hlsl │ │ ├── PostProcessPS.hlsl │ │ ├── RenderTargetPS.hlsl │ │ ├── TessellationCommon.hlsl │ │ ├── TessellationDS.hlsl │ │ ├── TessellationHS.hlsl │ │ ├── TessellationPS.hlsl │ │ ├── TessellationVS.hlsl │ │ ├── TestCS.hlsl │ │ ├── TestPS.hlsl │ │ └── TestVS.hlsl ├── Benchmarks │ ├── CMakeLists.txt │ └── RaytracerBenchmark │ │ ├── CMakeLists.txt │ │ ├── GeometryBenchmark.cpp │ │ ├── HashGridBenchmark.cpp │ │ ├── MatrixBenchmark.cpp │ │ ├── MemoryBenchmark.cpp │ │ ├── PCH.cpp │ │ ├── PCH.h │ │ ├── PackedBenchmark.cpp │ │ ├── RandomBenchmark.cpp │ │ ├── RaytracerBenchmark.vcxproj │ │ ├── RaytracerBenchmark.vcxproj.filters │ │ ├── TranscendentalBenchmark.cpp │ │ └── VectorBenchmark.cpp ├── CMakeLists.txt ├── Engine │ ├── CMakeLists.txt │ ├── Common │ │ ├── CMakeLists.txt │ │ ├── Common.vcxproj │ │ ├── Common.vcxproj.filters │ │ ├── Config │ │ │ ├── Config.cpp │ │ │ ├── Config.hpp │ │ │ ├── ConfigCommon.hpp │ │ │ ├── ConfigDataTranslator.hpp │ │ │ ├── ConfigInterface.hpp │ │ │ ├── ConfigTokenizer.cpp │ │ │ ├── ConfigTokenizer.hpp │ │ │ ├── ConfigValue.cpp │ │ │ └── ConfigValue.hpp │ │ ├── Containers │ │ │ ├── ArrayView.hpp │ │ │ ├── ArrayViewImpl.hpp │ │ │ ├── Comparator.hpp │ │ │ ├── Containers.natvis │ │ │ ├── Deque.hpp │ │ │ ├── DequeImpl.hpp │ │ │ ├── DynArray.hpp │ │ │ ├── DynArrayImpl.hpp │ │ │ ├── FixedArray.hpp │ │ │ ├── FixedArrayImpl.hpp │ │ │ ├── Hash.hpp │ │ │ ├── HashMap.hpp │ │ │ ├── HashMapImpl.hpp │ │ │ ├── HashSet.hpp │ │ │ ├── HashSetImpl.hpp │ │ │ ├── Iterators │ │ │ │ ├── ArrayIterator.hpp │ │ │ │ └── ArrayIteratorImpl.hpp │ │ │ ├── Map.hpp │ │ │ ├── MapImpl.hpp │ │ │ ├── PackedArray.hpp │ │ │ ├── PackedArrayImpl.hpp │ │ │ ├── Set.hpp │ │ │ ├── SetImpl.hpp │ │ │ ├── SharedPtr.hpp │ │ │ ├── SharedPtrBase.cpp │ │ │ ├── SharedPtrBase.hpp │ │ │ ├── SharedPtrData.cpp │ │ │ ├── SharedPtrData.hpp │ │ │ ├── SharedPtrImpl.hpp │ │ │ ├── StaticArray.hpp │ │ │ ├── StaticArrayImpl.hpp │ │ │ ├── String.cpp │ │ │ ├── String.hpp │ │ │ ├── StringImpl.hpp │ │ │ ├── StringView.cpp │ │ │ ├── StringView.hpp │ │ │ ├── StringViewImpl.hpp │ │ │ ├── UniquePtr.hpp │ │ │ ├── UniquePtrImpl.hpp │ │ │ ├── WeakPtr.hpp │ │ │ └── WeakPtrImpl.hpp │ │ ├── Debug │ │ │ └── Common.log │ │ ├── FileSystem │ │ │ ├── DirectoryWatch.hpp │ │ │ ├── File.hpp │ │ │ ├── FileAsync.cpp │ │ │ ├── FileAsync.hpp │ │ │ ├── FileBuffered.cpp │ │ │ ├── FileBuffered.hpp │ │ │ ├── FileSystem.hpp │ │ │ ├── FileSystemCommon.cpp │ │ │ ├── Linux │ │ │ │ ├── DirectoryWatch.cpp │ │ │ │ ├── File.cpp │ │ │ │ ├── FileAsyncPlatform.cpp │ │ │ │ └── FileSystem.cpp │ │ │ └── Windows │ │ │ │ ├── DirectoryWatch.cpp │ │ │ │ ├── File.cpp │ │ │ │ ├── FileAsyncPlatform.cpp │ │ │ │ └── FileSystem.cpp │ │ ├── ForwardDeclarations.hpp │ │ ├── Image │ │ │ ├── Image.cpp │ │ │ ├── Image.hpp │ │ │ ├── ImageBMP.cpp │ │ │ ├── ImageBMP.hpp │ │ │ ├── ImageDDS.cpp │ │ │ ├── ImageDDS.hpp │ │ │ ├── ImageFormat.cpp │ │ │ ├── ImageFormat.hpp │ │ │ ├── ImageJPG.cpp │ │ │ ├── ImageJPG.hpp │ │ │ ├── ImagePNG.cpp │ │ │ ├── ImagePNG.hpp │ │ │ ├── ImageType.cpp │ │ │ ├── ImageType.hpp │ │ │ ├── Mipmap.cpp │ │ │ └── Mipmap.hpp │ │ ├── Logger │ │ │ ├── Backends │ │ │ │ ├── BackendCommon.hpp │ │ │ │ ├── BackendConsole.cpp │ │ │ │ ├── BackendConsole.hpp │ │ │ │ ├── BackendHTML.cpp │ │ │ │ ├── BackendHTML.hpp │ │ │ │ ├── BackendTxt.cpp │ │ │ │ ├── BackendTxt.hpp │ │ │ │ ├── BackendXML.cpp │ │ │ │ ├── BackendXML.hpp │ │ │ │ └── Windows │ │ │ │ │ ├── BackendWindowsDebugger.cpp │ │ │ │ │ └── BackendWindowsDebugger.hpp │ │ │ ├── LogGrouper.cpp │ │ │ ├── LogGrouper.hpp │ │ │ ├── LogScope.cpp │ │ │ ├── LogScope.hpp │ │ │ ├── Logger.cpp │ │ │ ├── Logger.hpp │ │ │ ├── LoggerBackend.cpp │ │ │ ├── LoggerBackend.hpp │ │ │ ├── LoggerImpl.cpp │ │ │ └── LoggerImpl.hpp │ │ ├── Math │ │ │ ├── Box.hpp │ │ │ ├── ColorHelpers.cpp │ │ │ ├── ColorHelpers.hpp │ │ │ ├── Constants.hpp │ │ │ ├── Conversions.cpp │ │ │ ├── Conversions.hpp │ │ │ ├── Distribution.cpp │ │ │ ├── Distribution.hpp │ │ │ ├── EquationSolver.cpp │ │ │ ├── EquationSolver.hpp │ │ │ ├── Frustum.cpp │ │ │ ├── Frustum.hpp │ │ │ ├── Geometry.cpp │ │ │ ├── Geometry.hpp │ │ │ ├── Half.hpp │ │ │ ├── HalfImpl.hpp │ │ │ ├── HdrColor.cpp │ │ │ ├── HdrColor.hpp │ │ │ ├── HilbertCurve.cpp │ │ │ ├── HilbertCurve.hpp │ │ │ ├── LdrColor.cpp │ │ │ ├── LdrColor.hpp │ │ │ ├── Math.cpp │ │ │ ├── Math.hpp │ │ │ ├── Math.natvis │ │ │ ├── MathTypes.cpp │ │ │ ├── Matrix2.cpp │ │ │ ├── Matrix2.hpp │ │ │ ├── Matrix2Impl.hpp │ │ │ ├── Matrix3.cpp │ │ │ ├── Matrix3.hpp │ │ │ ├── Matrix3Impl.hpp │ │ │ ├── Matrix4.cpp │ │ │ ├── Matrix4.hpp │ │ │ ├── Packed.cpp │ │ │ ├── Packed.hpp │ │ │ ├── PackedLoadVec4f.hpp │ │ │ ├── PackedLoadVec8f.hpp │ │ │ ├── Plane.hpp │ │ │ ├── PlaneImpl.hpp │ │ │ ├── Quaternion.cpp │ │ │ ├── Quaternion.hpp │ │ │ ├── QuaternionImpl.hpp │ │ │ ├── Random.cpp │ │ │ ├── Random.hpp │ │ │ ├── Ray.hpp │ │ │ ├── RayGeometry.hpp │ │ │ ├── Rectangle.hpp │ │ │ ├── SamplingHelpers.cpp │ │ │ ├── SamplingHelpers.hpp │ │ │ ├── SimdBox.hpp │ │ │ ├── SimdGeometry.hpp │ │ │ ├── SimdRay.hpp │ │ │ ├── SimdTriangle.hpp │ │ │ ├── Sphere.hpp │ │ │ ├── SphericalQuad.hpp │ │ │ ├── Transcendental.cpp │ │ │ ├── Transcendental.hpp │ │ │ ├── TranscendentalImpl.hpp │ │ │ ├── Transform.cpp │ │ │ ├── Transform.hpp │ │ │ ├── Triangle.hpp │ │ │ ├── Utils.cpp │ │ │ ├── Utils.hpp │ │ │ ├── Vec16f.hpp │ │ │ ├── Vec16fImplAVX512.hpp │ │ │ ├── Vec16fImplNaive.hpp │ │ │ ├── Vec16i.hpp │ │ │ ├── Vec16iImplAVX512.hpp │ │ │ ├── Vec16iImplNaive.hpp │ │ │ ├── Vec2f.hpp │ │ │ ├── Vec2fImpl.hpp │ │ │ ├── Vec2x16f.hpp │ │ │ ├── Vec2x4f.hpp │ │ │ ├── Vec2x8f.hpp │ │ │ ├── Vec3f.hpp │ │ │ ├── Vec3fImpl.hpp │ │ │ ├── Vec3x16f.hpp │ │ │ ├── Vec3x4f.hpp │ │ │ ├── Vec3x8f.hpp │ │ │ ├── Vec4f.cpp │ │ │ ├── Vec4f.hpp │ │ │ ├── Vec4fImpl.hpp │ │ │ ├── Vec4fImplNaive.hpp │ │ │ ├── Vec4fImplSSE.hpp │ │ │ ├── Vec4fU.hpp │ │ │ ├── Vec4fUImpl.hpp │ │ │ ├── Vec4i.hpp │ │ │ ├── Vec4iImplNaive.hpp │ │ │ ├── Vec4iImplSSE.hpp │ │ │ ├── Vec8f.hpp │ │ │ ├── Vec8fImplAVX.hpp │ │ │ ├── Vec8fImplCommon.hpp │ │ │ ├── Vec8fImplNaive.hpp │ │ │ ├── Vec8i.hpp │ │ │ ├── Vec8iImplAVX2.hpp │ │ │ ├── Vec8iImplNaive.hpp │ │ │ └── WindowFunctions.hpp │ │ ├── Memory │ │ │ ├── Aligned.hpp │ │ │ ├── Buffer.cpp │ │ │ ├── Buffer.hpp │ │ │ ├── DefaultAllocator.cpp │ │ │ ├── DefaultAllocator.hpp │ │ │ └── MemoryHelpers.hpp │ │ ├── PCH.cpp │ │ ├── PCH.hpp │ │ ├── Reflection │ │ │ ├── Object.cpp │ │ │ ├── Object.hpp │ │ │ ├── ReflectionClassDeclare.hpp │ │ │ ├── ReflectionClassDefine.hpp │ │ │ ├── ReflectionEnumMacros.hpp │ │ │ ├── ReflectionMember.cpp │ │ │ ├── ReflectionMember.hpp │ │ │ ├── ReflectionMemberMetadataBuilder.cpp │ │ │ ├── ReflectionMemberMetadataBuilder.hpp │ │ │ ├── ReflectionMemberPath.hpp │ │ │ ├── ReflectionTypeRegistry.cpp │ │ │ ├── ReflectionTypeRegistry.hpp │ │ │ ├── ReflectionTypeResolver.hpp │ │ │ ├── ReflectionUnitTestHelper.hpp │ │ │ ├── ReflectionUtils.hpp │ │ │ ├── ReflectionVariant.cpp │ │ │ ├── ReflectionVariant.hpp │ │ │ ├── SerializationContext.cpp │ │ │ ├── SerializationContext.hpp │ │ │ ├── Serializer.cpp │ │ │ ├── Serializer.hpp │ │ │ └── Types │ │ │ │ ├── ReflectionArrayType.hpp │ │ │ │ ├── ReflectionClassType.cpp │ │ │ │ ├── ReflectionClassType.hpp │ │ │ │ ├── ReflectionDynArrayType.cpp │ │ │ │ ├── ReflectionDynArrayType.hpp │ │ │ │ ├── ReflectionEnumType.cpp │ │ │ │ ├── ReflectionEnumType.hpp │ │ │ │ ├── ReflectionFundamentalType.cpp │ │ │ │ ├── ReflectionFundamentalType.hpp │ │ │ │ ├── ReflectionNativeArrayType.cpp │ │ │ │ ├── ReflectionNativeArrayType.hpp │ │ │ │ ├── ReflectionPointerType.cpp │ │ │ │ ├── ReflectionPointerType.hpp │ │ │ │ ├── ReflectionSharedPtrType.cpp │ │ │ │ ├── ReflectionSharedPtrType.hpp │ │ │ │ ├── ReflectionStringType.cpp │ │ │ │ ├── ReflectionStringType.hpp │ │ │ │ ├── ReflectionType.cpp │ │ │ │ ├── ReflectionType.hpp │ │ │ │ ├── ReflectionUniquePtrType.cpp │ │ │ │ └── ReflectionUniquePtrType.hpp │ │ ├── System │ │ │ ├── Assertion.cpp │ │ │ ├── Assertion.hpp │ │ │ ├── AsyncQueueManager.hpp │ │ │ ├── ConditionVariable.hpp │ │ │ ├── Console.hpp │ │ │ ├── KeyCodes.hpp │ │ │ ├── Library.hpp │ │ │ ├── Linux │ │ │ │ ├── AssertionLinux.cpp │ │ │ │ ├── AsyncQueueManager.cpp │ │ │ │ ├── AsyncQueueManager.hpp │ │ │ │ ├── ConditionVariableImpl.hpp │ │ │ │ ├── Console.cpp │ │ │ │ ├── Console.hpp │ │ │ │ ├── Library.cpp │ │ │ │ ├── Memory.cpp │ │ │ │ ├── MutexImpl.hpp │ │ │ │ ├── RWLockImpl.hpp │ │ │ │ ├── SystemInfoPlatform.cpp │ │ │ │ ├── Thread.cpp │ │ │ │ ├── Timer.cpp │ │ │ │ └── Window.cpp │ │ │ ├── Memory.hpp │ │ │ ├── Mutex.hpp │ │ │ ├── RWLock.hpp │ │ │ ├── RWSpinLock.hpp │ │ │ ├── RWSpinLockImpl.hpp │ │ │ ├── SpinLock.hpp │ │ │ ├── SpinLockImpl.hpp │ │ │ ├── SystemInfo.cpp │ │ │ ├── SystemInfo.hpp │ │ │ ├── SystemInfoConstants.hpp │ │ │ ├── Thread.hpp │ │ │ ├── Timer.hpp │ │ │ ├── Window.hpp │ │ │ └── Windows │ │ │ │ ├── AssertionWindows.cpp │ │ │ │ ├── AsyncQueueManager.cpp │ │ │ │ ├── AsyncQueueManager.hpp │ │ │ │ ├── Common.cpp │ │ │ │ ├── Common.hpp │ │ │ │ ├── ConditionVariableImpl.hpp │ │ │ │ ├── Console.cpp │ │ │ │ ├── Console.hpp │ │ │ │ ├── Library.cpp │ │ │ │ ├── Main.cpp │ │ │ │ ├── Memory.cpp │ │ │ │ ├── MutexImpl.hpp │ │ │ │ ├── RWLockImpl.hpp │ │ │ │ ├── SystemInfoPlatform.cpp │ │ │ │ ├── Thread.cpp │ │ │ │ ├── Timer.cpp │ │ │ │ └── Window.cpp │ │ ├── Utils │ │ │ ├── BVH.cpp │ │ │ ├── BVH.hpp │ │ │ ├── BitUtils.hpp │ │ │ ├── BitUtilsImplCommon.hpp │ │ │ ├── BitUtilsImplLinuxAVX.hpp │ │ │ ├── BitUtilsImplNative.hpp │ │ │ ├── BitUtilsImplWindowsAVX.hpp │ │ │ ├── CompressedInt.cpp │ │ │ ├── CompressedInt.hpp │ │ │ ├── Entropy.cpp │ │ │ ├── Entropy.hpp │ │ │ ├── EnumIterator.hpp │ │ │ ├── FundamentalTypesUnion.hpp │ │ │ ├── LanguageUtils.hpp │ │ │ ├── Latch.cpp │ │ │ ├── Latch.hpp │ │ │ ├── MD5.cpp │ │ │ ├── MD5.hpp │ │ │ ├── ParallelAlgorithms.hpp │ │ │ ├── ScopedLock.hpp │ │ │ ├── Stream │ │ │ │ ├── BufferInputStream.cpp │ │ │ │ ├── BufferInputStream.hpp │ │ │ │ ├── BufferOutputStream.cpp │ │ │ │ ├── BufferOutputStream.hpp │ │ │ │ ├── FileInputStream.cpp │ │ │ │ ├── FileInputStream.hpp │ │ │ │ ├── FileOutputStream.cpp │ │ │ │ ├── FileOutputStream.hpp │ │ │ │ ├── InputStream.cpp │ │ │ │ ├── InputStream.hpp │ │ │ │ ├── OutputStream.cpp │ │ │ │ ├── OutputStream.hpp │ │ │ │ └── StreamCommon.hpp │ │ │ ├── StringUtils.cpp │ │ │ ├── StringUtils.hpp │ │ │ ├── TaskBuilder.cpp │ │ │ ├── TaskBuilder.hpp │ │ │ ├── ThreadPool.cpp │ │ │ ├── ThreadPool.hpp │ │ │ ├── ThreadPoolTask.cpp │ │ │ ├── ThreadPoolTask.hpp │ │ │ ├── Waitable.cpp │ │ │ └── Waitable.hpp │ │ ├── nfCommon.cpp │ │ └── nfCommon.hpp │ ├── Core │ │ ├── CMakeLists.txt │ │ ├── Core.hpp │ │ ├── Core.vcxproj │ │ ├── Core.vcxproj.filters │ │ ├── ForwardDeclarations.hpp │ │ ├── Input │ │ │ ├── InputEvent.cpp │ │ │ └── InputEvent.hpp │ │ ├── Main.cpp │ │ ├── PCH.cpp │ │ ├── PCH.hpp │ │ ├── Resources_old │ │ │ ├── Material.cpp │ │ │ ├── Material.hpp │ │ │ ├── Mesh.cpp │ │ │ ├── Mesh.hpp │ │ │ ├── MultiPipelineState.cpp │ │ │ ├── MultiPipelineState.hpp │ │ │ ├── Multishader.cpp │ │ │ ├── Multishader.hpp │ │ │ ├── Resource.cpp │ │ │ ├── Resource.hpp │ │ │ ├── ResourcesManager.cpp │ │ │ ├── ResourcesManager.hpp │ │ │ ├── SoundSample.cpp │ │ │ ├── SoundSample.hpp │ │ │ ├── Texture.cpp │ │ │ └── Texture.hpp │ │ ├── Scene │ │ │ ├── Components │ │ │ │ ├── Component.cpp │ │ │ │ ├── Component.hpp │ │ │ │ ├── ComponentCamera.cpp │ │ │ │ ├── ComponentCamera.hpp │ │ │ │ ├── ComponentController.cpp │ │ │ │ ├── ComponentController.hpp │ │ │ │ ├── ComponentLight.cpp │ │ │ │ ├── ComponentLight.hpp │ │ │ │ ├── ComponentMesh.cpp │ │ │ │ ├── ComponentMesh.hpp │ │ │ │ ├── ComponentTrigger.cpp │ │ │ │ └── ComponentTrigger.hpp │ │ │ ├── Entity.cpp │ │ │ ├── Entity.hpp │ │ │ ├── EntityController.cpp │ │ │ ├── EntityController.hpp │ │ │ ├── Events │ │ │ │ ├── Event.cpp │ │ │ │ ├── Event.hpp │ │ │ │ ├── Event_Input.cpp │ │ │ │ ├── Event_Input.hpp │ │ │ │ ├── Event_Tick.cpp │ │ │ │ ├── Event_Tick.hpp │ │ │ │ ├── Event_Trigger.cpp │ │ │ │ └── Event_Trigger.hpp │ │ │ ├── Scene.cpp │ │ │ ├── Scene.hpp │ │ │ └── Systems │ │ │ │ ├── EntitySystem.cpp │ │ │ │ ├── EntitySystem.hpp │ │ │ │ ├── EventSystem.cpp │ │ │ │ ├── EventSystem.hpp │ │ │ │ ├── InputSystem.cpp │ │ │ │ ├── InputSystem.hpp │ │ │ │ ├── RendererSystem.cpp │ │ │ │ ├── RendererSystem.hpp │ │ │ │ ├── System.cpp │ │ │ │ ├── System.hpp │ │ │ │ ├── TriggerSystem.cpp │ │ │ │ └── TriggerSystem.hpp │ │ ├── Scene_old │ │ │ └── SceneManager.cpp │ │ ├── ShaderCommon.hpp │ │ └── Utils │ │ │ ├── ConfigManager.cpp │ │ │ ├── ConfigManager.hpp │ │ │ ├── ConfigVariable.cpp │ │ │ ├── ConfigVariable.hpp │ │ │ ├── Profiler.cpp │ │ │ ├── Profiler.hpp │ │ │ └── SimpleInput.hpp │ ├── Data │ │ ├── nfEngineLogs.css │ │ └── tablefilter.js │ ├── Raytracer │ │ ├── BVH │ │ │ ├── BVH.cpp │ │ │ ├── BVH.h │ │ │ ├── BVHBuilder.cpp │ │ │ └── BVHBuilder.h │ │ ├── CMakeLists.txt │ │ ├── Color │ │ │ ├── BlackBodyColor.cpp │ │ │ ├── BlackBodyColor.h │ │ │ ├── Color.cpp │ │ │ ├── Color.h │ │ │ ├── ColorRGB.cpp │ │ │ ├── ColorRGB.h │ │ │ ├── MonochromaticColor.cpp │ │ │ ├── MonochromaticColor.h │ │ │ ├── RayColor.cpp │ │ │ ├── RayColor.h │ │ │ ├── Wavelength.cpp │ │ │ └── Wavelength.h │ │ ├── Config.h │ │ ├── ForwardDeclarations.hpp │ │ ├── Material │ │ │ ├── BSDF │ │ │ │ ├── BSDF.cpp │ │ │ │ ├── BSDF.h │ │ │ │ ├── DielectricBSDF.cpp │ │ │ │ ├── DielectricBSDF.h │ │ │ │ ├── DiffuseBSDF.cpp │ │ │ │ ├── DiffuseBSDF.h │ │ │ │ ├── MetalBSDF.cpp │ │ │ │ ├── MetalBSDF.h │ │ │ │ ├── Microfacet.cpp │ │ │ │ ├── Microfacet.h │ │ │ │ ├── NullBSDF.cpp │ │ │ │ ├── NullBSDF.h │ │ │ │ ├── PlasticBSDF.cpp │ │ │ │ ├── PlasticBSDF.h │ │ │ │ ├── RoughDielectricBSDF.cpp │ │ │ │ ├── RoughDielectricBSDF.h │ │ │ │ ├── RoughDiffuseBSDF.cpp │ │ │ │ ├── RoughDiffuseBSDF.h │ │ │ │ ├── RoughMetalBSDF.cpp │ │ │ │ ├── RoughMetalBSDF.h │ │ │ │ ├── RoughPlasticBSDF.cpp │ │ │ │ └── RoughPlasticBSDF.h │ │ │ ├── Material.cpp │ │ │ ├── Material.h │ │ │ ├── MaterialParameter.cpp │ │ │ └── MaterialParameter.h │ │ ├── Medium │ │ │ ├── Medium.cpp │ │ │ ├── Medium.h │ │ │ ├── PhaseFunction.cpp │ │ │ └── PhaseFunction.h │ │ ├── PCH.cpp │ │ ├── PCH.h │ │ ├── RayLib.h │ │ ├── Raytracer.h │ │ ├── Raytracer.vcxproj │ │ ├── Raytracer.vcxproj.filters │ │ ├── Renderers │ │ │ ├── DebugRenderer.cpp │ │ │ ├── DebugRenderer.h │ │ │ ├── LightTracer.cpp │ │ │ ├── LightTracer.h │ │ │ ├── PathTracer.cpp │ │ │ ├── PathTracer.h │ │ │ ├── PathTracerMIS.cpp │ │ │ ├── PathTracerMIS.h │ │ │ ├── Renderer.cpp │ │ │ ├── Renderer.h │ │ │ ├── RendererContext.cpp │ │ │ ├── RendererContext.h │ │ │ ├── VertexConnectionAndMerging.cpp │ │ │ └── VertexConnectionAndMerging.h │ │ ├── Rendering │ │ │ ├── Counters.h │ │ │ ├── Film.cpp │ │ │ ├── Film.h │ │ │ ├── PathDebugging.h │ │ │ ├── PostProcess.cpp │ │ │ ├── PostProcess.h │ │ │ ├── RenderingContext.cpp │ │ │ ├── RenderingContext.h │ │ │ ├── RenderingParams.cpp │ │ │ ├── RenderingParams.h │ │ │ ├── ShadingData.h │ │ │ ├── Tonemapping.cpp │ │ │ ├── Tonemapping.h │ │ │ ├── Viewport.cpp │ │ │ └── Viewport.h │ │ ├── Sampling │ │ │ ├── GenericSampler.cpp │ │ │ ├── GenericSampler.h │ │ │ ├── HaltonSampler.cpp │ │ │ └── HaltonSampler.h │ │ ├── Scene │ │ │ ├── Camera.cpp │ │ │ ├── Camera.h │ │ │ ├── Light │ │ │ │ ├── AreaLight.cpp │ │ │ │ ├── AreaLight.h │ │ │ │ ├── BackgroundLight.cpp │ │ │ │ ├── BackgroundLight.h │ │ │ │ ├── DirectionalLight.cpp │ │ │ │ ├── DirectionalLight.h │ │ │ │ ├── Light.cpp │ │ │ │ ├── Light.h │ │ │ │ ├── PointLight.cpp │ │ │ │ ├── PointLight.h │ │ │ │ ├── SpotLight.cpp │ │ │ │ └── SpotLight.h │ │ │ ├── Object │ │ │ │ ├── SceneObject.cpp │ │ │ │ ├── SceneObject.h │ │ │ │ ├── SceneObject_Decal.cpp │ │ │ │ ├── SceneObject_Decal.h │ │ │ │ ├── SceneObject_Light.cpp │ │ │ │ ├── SceneObject_Light.h │ │ │ │ ├── SceneObject_Shape.cpp │ │ │ │ └── SceneObject_Shape.h │ │ │ ├── Scene.cpp │ │ │ └── Scene.h │ │ ├── Shapes │ │ │ ├── BoxShape.cpp │ │ │ ├── BoxShape.h │ │ │ ├── CsgShape.cpp │ │ │ ├── CsgShape.h │ │ │ ├── CylinderShape.cpp │ │ │ ├── CylinderShape.h │ │ │ ├── Mesh │ │ │ │ ├── VertexBuffer.cpp │ │ │ │ ├── VertexBuffer.h │ │ │ │ └── VertexBufferDesc.h │ │ │ ├── MeshShape.cpp │ │ │ ├── MeshShape.h │ │ │ ├── RectShape.cpp │ │ │ ├── RectShape.h │ │ │ ├── Shape.cpp │ │ │ ├── Shape.h │ │ │ ├── SphereShape.cpp │ │ │ └── SphereShape.h │ │ ├── Textures │ │ │ ├── BitmapTexture.cpp │ │ │ ├── BitmapTexture.h │ │ │ ├── BitmapTexture3D.cpp │ │ │ ├── BitmapTexture3D.h │ │ │ ├── CheckerboardTexture.cpp │ │ │ ├── CheckerboardTexture.h │ │ │ ├── ConstTexture.cpp │ │ │ ├── ConstTexture.h │ │ │ ├── GradientTexture.cpp │ │ │ ├── GradientTexture.h │ │ │ ├── MixTexture.cpp │ │ │ ├── MixTexture.h │ │ │ ├── NoiseTexture.cpp │ │ │ ├── NoiseTexture.h │ │ │ ├── NoiseTexture3D.cpp │ │ │ ├── NoiseTexture3D.h │ │ │ ├── Texture.cpp │ │ │ └── Texture.h │ │ ├── Traversal │ │ │ ├── HitPoint.h │ │ │ ├── Intersection.h │ │ │ ├── RayPacket.cpp │ │ │ ├── RayPacket.h │ │ │ ├── RayPacketTypes.h │ │ │ ├── RayStream.cpp │ │ │ ├── RayStream.h │ │ │ ├── TraversalContext.cpp │ │ │ ├── TraversalContext.h │ │ │ ├── Traversal_Packet.cpp │ │ │ ├── Traversal_Packet.h │ │ │ ├── Traversal_Simd.h │ │ │ └── Traversal_Single.h │ │ └── Utils │ │ │ ├── Bitmap.cpp │ │ │ ├── Bitmap.h │ │ │ ├── BitmapBMP.cpp │ │ │ ├── BitmapDDS.cpp │ │ │ ├── BitmapEXR.cpp │ │ │ ├── BitmapUtils.cpp │ │ │ ├── BitmapUtils.h │ │ │ ├── BitmapVDB.cpp │ │ │ ├── BlockCompression.cpp │ │ │ ├── BlockCompression.h │ │ │ ├── HashGrid.h │ │ │ ├── KdTree.cpp │ │ │ ├── KdTree.h │ │ │ ├── LookupTable.h │ │ │ ├── Memory.cpp │ │ │ ├── Memory.h │ │ │ ├── Profiler.cpp │ │ │ ├── Profiler.h │ │ │ └── iacaMarks.h │ └── Renderers │ │ ├── CMakeLists.txt │ │ ├── RendererCommon │ │ ├── Backbuffer.hpp │ │ ├── Buffer.hpp │ │ ├── CMakeLists.txt │ │ ├── CommandQueue.hpp │ │ ├── CommandRecorder.hpp │ │ ├── ComputePipelineState.hpp │ │ ├── Device.hpp │ │ ├── Fence.cpp │ │ ├── Fence.hpp │ │ ├── MemoryBlock.hpp │ │ ├── PCH.cpp │ │ ├── PCH.hpp │ │ ├── PipelineState.hpp │ │ ├── RenderTarget.hpp │ │ ├── RendererCommon.hpp │ │ ├── RendererCommon.vcxproj │ │ ├── Shader.hpp │ │ ├── Texture.hpp │ │ ├── Types.cpp │ │ ├── Types.hpp │ │ └── VertexLayout.hpp │ │ ├── RendererD3D12 │ │ ├── Backbuffer.cpp │ │ ├── Backbuffer.hpp │ │ ├── Buffer.cpp │ │ ├── Buffer.hpp │ │ ├── CMakeLists.txt │ │ ├── CommandList.cpp │ │ ├── CommandList.hpp │ │ ├── CommandListManager.cpp │ │ ├── CommandListManager.hpp │ │ ├── CommandQueue.cpp │ │ ├── CommandQueue.hpp │ │ ├── CommandRecorder.cpp │ │ ├── CommandRecorder.hpp │ │ ├── Common.cpp │ │ ├── Common.hpp │ │ ├── ComputePipelineState.cpp │ │ ├── ComputePipelineState.hpp │ │ ├── D3DPtr.hpp │ │ ├── DescriptorSet.cpp │ │ ├── DescriptorSet.hpp │ │ ├── Descriptors.hpp │ │ ├── Device.cpp │ │ ├── Device.hpp │ │ ├── Fence.cpp │ │ ├── Fence.hpp │ │ ├── Format.hpp │ │ ├── HeapAllocator.cpp │ │ ├── HeapAllocator.hpp │ │ ├── Main.cpp │ │ ├── MemoryBlock.cpp │ │ ├── MemoryBlock.hpp │ │ ├── PCH.cpp │ │ ├── PCH.hpp │ │ ├── PipelineState.cpp │ │ ├── PipelineState.hpp │ │ ├── ReferencedResourcesList.cpp │ │ ├── ReferencedResourcesList.hpp │ │ ├── RenderTarget.cpp │ │ ├── RenderTarget.hpp │ │ ├── RendererD3D12.cpp │ │ ├── RendererD3D12.hpp │ │ ├── RendererD3D12.vcxproj │ │ ├── RendererD3D12.vcxproj.filters │ │ ├── Resource.cpp │ │ ├── Resource.hpp │ │ ├── ResourceState.cpp │ │ ├── ResourceState.hpp │ │ ├── ResourceStateCache.cpp │ │ ├── ResourceStateCache.hpp │ │ ├── RingBuffer.cpp │ │ ├── RingBuffer.hpp │ │ ├── Sampler.cpp │ │ ├── Sampler.hpp │ │ ├── Shader.cpp │ │ ├── Shader.hpp │ │ ├── ShaderCompiler.cpp │ │ ├── ShaderCompiler.hpp │ │ ├── Texture.cpp │ │ ├── Texture.hpp │ │ ├── Translations.cpp │ │ ├── Translations.hpp │ │ ├── VertexLayout.cpp │ │ ├── VertexLayout.hpp │ │ └── packages.config │ │ └── RendererVk │ │ ├── API │ │ ├── Backbuffer.cpp │ │ ├── Backbuffer.hpp │ │ ├── BasePipelineState.cpp │ │ ├── BasePipelineState.hpp │ │ ├── Buffer.cpp │ │ ├── Buffer.hpp │ │ ├── CommandList.cpp │ │ ├── CommandList.hpp │ │ ├── CommandQueue.cpp │ │ ├── CommandQueue.hpp │ │ ├── CommandRecorder.cpp │ │ ├── CommandRecorder.hpp │ │ ├── ComputePipelineState.cpp │ │ ├── ComputePipelineState.hpp │ │ ├── Device.cpp │ │ ├── Device.hpp │ │ ├── Fence.cpp │ │ ├── Fence.hpp │ │ ├── IResource.hpp │ │ ├── Linux │ │ │ ├── XcbBackbuffer.cpp │ │ │ └── XcbDevice.cpp │ │ ├── MemoryBlock.cpp │ │ ├── MemoryBlock.hpp │ │ ├── PipelineState.cpp │ │ ├── PipelineState.hpp │ │ ├── RenderTarget.cpp │ │ ├── RenderTarget.hpp │ │ ├── Sampler.cpp │ │ ├── Sampler.hpp │ │ ├── Shader.cpp │ │ ├── Shader.hpp │ │ ├── Texture.cpp │ │ ├── Texture.hpp │ │ ├── VertexLayout.cpp │ │ ├── VertexLayout.hpp │ │ └── Win │ │ │ ├── WinBackbuffer.cpp │ │ │ └── WinDevice.cpp │ │ ├── CMakeLists.txt │ │ ├── Defines.hpp │ │ ├── Internal │ │ ├── CommandBufferManager.cpp │ │ ├── CommandBufferManager.hpp │ │ ├── Debugger.cpp │ │ ├── Debugger.hpp │ │ ├── DescriptorSetCache.cpp │ │ ├── DescriptorSetCache.hpp │ │ ├── Extensions.cpp │ │ ├── Extensions.hpp │ │ ├── FenceSignaller.cpp │ │ ├── FenceSignaller.hpp │ │ ├── GetProc.hpp │ │ ├── Instance.cpp │ │ ├── Instance.hpp │ │ ├── LayoutTracker.cpp │ │ ├── LayoutTracker.hpp │ │ ├── Linux │ │ │ ├── XcbExtensions.cpp │ │ │ └── XcbExtensions.hpp │ │ ├── QueueFamilyManager.cpp │ │ ├── QueueFamilyManager.hpp │ │ ├── RenderPassDesc.hpp │ │ ├── RenderPassManager.cpp │ │ ├── RenderPassManager.hpp │ │ ├── RingBuffer.cpp │ │ ├── RingBuffer.hpp │ │ ├── SemaphorePool.cpp │ │ ├── SemaphorePool.hpp │ │ ├── ShaderIncluder.cpp │ │ ├── ShaderIncluder.hpp │ │ ├── Translations.cpp │ │ ├── Translations.hpp │ │ ├── Types.hpp │ │ ├── Utilities.cpp │ │ ├── Utilities.hpp │ │ └── Win │ │ │ ├── WinExtensions.cpp │ │ │ └── WinExtensions.hpp │ │ ├── Main.cpp │ │ ├── PCH.cpp │ │ ├── PCH.hpp │ │ ├── RendererVk.vcxproj │ │ └── RendererVk.vcxproj.filters ├── PropertyPages │ ├── DebugProperties.props │ ├── FinalProperties.props │ ├── GlobalProperties.props │ └── ReleaseProperties.props ├── Shaders │ ├── AmbientLightPS.json │ ├── DebugPS.json │ ├── DebugVS.json │ ├── FullScreenQuadVS.json │ ├── GeometryPassPS.json │ ├── GeometryPassVS.json │ ├── GuiGS.json │ ├── GuiPS.json │ ├── GuiVS.json │ ├── HLSL5 │ │ ├── AmbientLightPS.hlsl │ │ ├── Common.hlsl │ │ ├── DebugPS.hlsl │ │ ├── DebugVS.hlsl │ │ ├── FullScreenQuadVS.hlsl │ │ ├── GeometryPassPS.hlsl │ │ ├── GeometryPassVS.hlsl │ │ ├── GuiCommon.hlsl │ │ ├── GuiGS.hlsl │ │ ├── GuiPS.hlsl │ │ ├── GuiVS.hlsl │ │ ├── ImGuiPS.hlsl │ │ ├── ImGuiVS.hlsl │ │ ├── LightCommon.hlsl │ │ ├── OmniLightCommon.hlsl │ │ ├── OmniLightPS.hlsl │ │ ├── OmniLightVS.hlsl │ │ ├── ShadowCommon.hlsl │ │ ├── ShadowPS.hlsl │ │ ├── ShadowVS.hlsl │ │ ├── SpotLightCommon.hlsl │ │ ├── SpotLightPS.hlsl │ │ ├── SpotLightVS.hlsl │ │ └── TonemappingPS.hlsl │ ├── ImGuiPS.json │ ├── ImGuiVS.json │ ├── OmniLightPS.json │ ├── OmniLightVS.json │ ├── Sets │ │ ├── AmbientLight.cfg │ │ ├── Debug.cfg │ │ ├── GeometryPass.cfg │ │ ├── Gui.cfg │ │ ├── ImGui.cfg │ │ ├── OmniLight.cfg │ │ ├── Shadow.cfg │ │ ├── SpotLight.cfg │ │ └── Tonemapping.cfg │ ├── ShadowPS.json │ ├── ShadowVS.json │ ├── SpotLightPS.json │ ├── SpotLightVS.json │ └── TonemappingPS.json └── Tests │ ├── CMakeLists.txt │ ├── CommonPerfTest │ ├── CMakeLists.txt │ ├── CommonPerfTest.vcxproj │ ├── CommonPerfTest.vcxproj.filters │ ├── Main.cpp │ ├── PCH.cpp │ ├── PCH.hpp │ ├── Test.hpp │ └── TestCases │ │ ├── BVHPerfTest.cpp │ │ ├── ConfigPerfTest.cpp │ │ ├── FilePerfTest.cpp │ │ ├── HashSetPerfTest.cpp │ │ ├── LoggerPerfTest.cpp │ │ ├── SetPerfTest.cpp │ │ └── ThreadPoolPerfTest.cpp │ ├── CommonTest │ ├── CMakeLists.txt │ ├── CommonTest.vcxproj │ ├── CommonTest.vcxproj.filters │ ├── Constants.cpp │ ├── Constants.hpp │ ├── Main.cpp │ ├── PCH.cpp │ ├── PCH.hpp │ ├── TestCases │ │ ├── Containers │ │ │ ├── ArrayViewTest.cpp │ │ │ ├── DequeTest.cpp │ │ │ ├── DynArrayTest.cpp │ │ │ ├── DynArrayTest_Containers.cpp │ │ │ ├── FixedArrayTest.cpp │ │ │ ├── HashMapTest.cpp │ │ │ ├── HashSetTest_Containers.cpp │ │ │ ├── MapTest.cpp │ │ │ ├── PackedArrayTest.cpp │ │ │ ├── SetTest.cpp │ │ │ ├── SetTest_Containers.cpp │ │ │ ├── SharedPtrTest.cpp │ │ │ ├── SharedPtrTest_Containers.cpp │ │ │ ├── StaticArrayTest.cpp │ │ │ ├── StringTest.cpp │ │ │ ├── StringViewTest.cpp │ │ │ ├── UniquePtrTest.cpp │ │ │ ├── UniquePtrTest_Containers.cpp │ │ │ └── WeakPtrTest.cpp │ │ ├── FileSystem │ │ │ ├── DirectoryWatchTest.cpp │ │ │ ├── FileAsyncTest.cpp │ │ │ ├── FileBufferedTest.cpp │ │ │ ├── FileSystemTest.cpp │ │ │ └── FileTest.cpp │ │ ├── Math │ │ │ ├── MathBoxTest.cpp │ │ │ ├── MathConversionsTest.cpp │ │ │ ├── MathDistributionTest.cpp │ │ │ ├── MathEquationSolverTest.cpp │ │ │ ├── MathGeometryTest.cpp │ │ │ ├── MathMatrix2Test.cpp │ │ │ ├── MathMatrix3Test.cpp │ │ │ ├── MathMatrix4Test.cpp │ │ │ ├── MathPackedTest.cpp │ │ │ ├── MathQuaternionTest.cpp │ │ │ ├── MathRayGeometryTest.cpp │ │ │ ├── MathTest.cpp │ │ │ ├── MathTranscendental.cpp │ │ │ ├── MathTransformTest.cpp │ │ │ ├── MathVec16fTest.cpp │ │ │ ├── MathVec2fTest.cpp │ │ │ ├── MathVec3fTest.cpp │ │ │ ├── MathVec4fTest.cpp │ │ │ ├── MathVec4fUTest.cpp │ │ │ ├── MathVec4iTest.cpp │ │ │ ├── MathVec8fTest.cpp │ │ │ ├── MathVec8iTest.cpp │ │ │ └── RandomTest.cpp │ │ ├── Memory │ │ │ ├── AlignedTest.cpp │ │ │ └── MemoryTest.cpp │ │ ├── Reflection │ │ │ ├── ReflectionClassTest.cpp │ │ │ ├── ReflectionDynArrayTest.cpp │ │ │ ├── ReflectionEnumTest.cpp │ │ │ ├── ReflectionFundamentalTypesTest.cpp │ │ │ ├── ReflectionPolymorphicClassTest.cpp │ │ │ ├── ReflectionSerializerTest.cpp │ │ │ ├── ReflectionSharedPtrTest.cpp │ │ │ ├── ReflectionTestCommon.cpp │ │ │ ├── ReflectionTestCommon.hpp │ │ │ ├── ReflectionTypeMismatchTest.cpp │ │ │ └── ReflectionUniquePtrTest.cpp │ │ ├── System │ │ │ ├── ConditionVariableTest.cpp │ │ │ ├── ExclusiveLockTest.cpp │ │ │ ├── SharedLockTest.cpp │ │ │ ├── SystemInfoTest.cpp │ │ │ ├── ThreadTest.cpp │ │ │ ├── TimerTest.cpp │ │ │ └── WindowTest.cpp │ │ └── Utils │ │ │ ├── BVHTest.cpp │ │ │ ├── BitUtilsTest.cpp │ │ │ ├── BufferInputStreamTest.cpp │ │ │ ├── BufferOutputStreamTest.cpp │ │ │ ├── CompressedInt.cpp │ │ │ ├── ConfigTest.cpp │ │ │ ├── EnumIteratorTest.cpp │ │ │ ├── ImageTest.cpp │ │ │ ├── LatchTest.cpp │ │ │ ├── MD5Test.cpp │ │ │ ├── StringUtilsTest.cpp │ │ │ ├── ThreadPoolSimpleTest.cpp │ │ │ └── ThreadPoolStressTest.cpp │ ├── TestClasses.hpp │ └── TestResources │ │ ├── CMakeLists.txt │ │ ├── ImageSamples │ │ ├── SaveTests │ │ │ └── textureJPG.jpg_saved.jpg │ │ ├── textureBC1.dds │ │ ├── textureBC1_MM.dds │ │ ├── textureBC2.dds │ │ ├── textureBC3.dds │ │ ├── textureBC4.dds │ │ ├── textureBC5.dds │ │ ├── textureBMP16ARGB.bmp │ │ ├── textureBMP16RGB.bmp │ │ ├── textureBMP16XRGB.bmp │ │ ├── textureBMP24.bmp │ │ ├── textureBMP32ARGB.bmp │ │ ├── textureBMP32XRGB.bmp │ │ ├── textureBMP4.bmp │ │ ├── textureBMP8.bmp │ │ ├── textureJPG.jpg │ │ ├── texturePNG_GA.png │ │ ├── texturePNG_RGB.png │ │ ├── texturePNG_RGBA.png │ │ ├── texturePNG_RGBA_interlaced.png │ │ └── texturePNG_RGBA_palette.png │ │ └── TestCalcLib │ │ ├── CMakeLists.txt │ │ ├── TestCalcLib.cpp │ │ ├── TestCalcLib.hpp │ │ ├── testCalcLib.vcxproj │ │ └── testCalcLib.vcxproj.filters │ ├── RaytracerTests │ ├── BitmapTest.cpp │ ├── CMakeLists.txt │ ├── HashGridTest.cpp │ ├── KdTreeTest.cpp │ ├── Main.cpp │ ├── MathDistributionTest.cpp │ ├── PCH.cpp │ ├── PCH.h │ ├── RaytracerTests.vcxproj │ ├── RaytracerTests.vcxproj.filters │ └── RaytracingTests.cpp │ └── RendererTest │ ├── Backends.cpp │ ├── Backends.hpp │ ├── CMakeLists.txt │ ├── DrawTest.cpp │ ├── DrawTest.hpp │ ├── Main.cpp │ ├── PCH.cpp │ ├── PCH.hpp │ ├── RendererTest.cpp │ ├── RendererTest.hpp │ ├── RendererTest.vcxproj │ ├── RendererTest.vcxproj.filters │ ├── Shaders │ ├── GLSL │ │ └── Simple.glsl │ └── HLSL5 │ │ ├── Simple.hlsl │ │ ├── SimpleDrawPS.hlsl │ │ └── SimpleDrawVS.hlsl │ └── TestCases │ ├── Buffer.cpp │ ├── CommandBuffer.cpp │ ├── Shader.cpp │ ├── SimpleDraw.cpp │ └── Texture2D.cpp ├── cmake └── NFESourceGroup.cmake └── engineConfig.cfg /Data/BlueNoise128_RGBA16.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Data/BlueNoise128_RGBA16.dat -------------------------------------------------------------------------------- /Data/Fonts/DroidSans-Regular.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Data/Fonts/DroidSans-Regular.otf -------------------------------------------------------------------------------- /Data/TestScenes/bitmap_texture_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "materials": 3 | [ 4 | { 5 | "name": "ground", 6 | "bsdf": "diffuse", 7 | "baseColor": [0.9, 0.9, 0.9], 8 | "baseColorTexture": "TEXTURES\\default.bmp", 9 | "metalness": 0.0, 10 | "roughness": 0.5 11 | } 12 | ], 13 | "objects": 14 | [ 15 | { 16 | "type": "rect", 17 | "size" : [20.0, 20.0], 18 | "transform": { "translation": [0.0, -1.0, 0.0], "orientation": [-90.0, 0.0, 0.0] }, 19 | "textureScale" : [0.4, 0.4], 20 | "material": "ground" 21 | } 22 | ], 23 | "camera": 24 | { 25 | "transform": 26 | { 27 | "translation": [-3.8, 0.3, 4.1], 28 | "orientation": [72.0, -178.0, 0.0] 29 | }, 30 | "fieldOfView": 50.0, 31 | "aperture": 0.32, 32 | "focalPlaneDistance": 1.3, 33 | "enableDOF": true 34 | } 35 | } -------------------------------------------------------------------------------- /Data/TestScenes/dof_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "lights": 3 | [ 4 | { 5 | "type": "background", 6 | "color": [2.0, 2.0, 2.0], 7 | "texture" : "TEXTURES/ENV/OutdoorCityParkingLotEveningClear_HIRES.exr" 8 | } 9 | ], 10 | "camera": 11 | { 12 | "transform": 13 | { 14 | "translation": [0.0, 0.0, 3.0], 15 | "orientation": [-0.3, 0.46, 0.0] 16 | }, 17 | "aperture": 0.2, 18 | "enableDOF": true, 19 | "focalDistance": 2.0, 20 | "fieldOfView": 55.0 21 | } 22 | } -------------------------------------------------------------------------------- /Data/TestScenes/material_env_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "materials": 3 | [ 4 | { 5 | "name": "diffuse", 6 | "bsdf": "diffuse", 7 | "baseColor": [0.6, 0.6, 0.6], 8 | "metalness": 0.0, 9 | "roughness": 0.0 10 | } 11 | ], 12 | "objects": 13 | [ 14 | { 15 | "type": "sphere", 16 | "radius": 1.0, 17 | "material": "diffuse" 18 | } 19 | ], 20 | "lights": 21 | [ 22 | { 23 | "type": "background", 24 | "color": [2.0, 2.0, 2.0], 25 | "texture" : "TEXTURES/ENV/spruit_sunrise_16k.dds" 26 | } 27 | ], 28 | "camera": 29 | { 30 | "transform": 31 | { 32 | "translation": [0.0, 0.0, 3.0], 33 | "orientation": [1.0, 180.0, 0.0] 34 | }, 35 | "fieldOfView": 50.0 36 | } 37 | } -------------------------------------------------------------------------------- /Data/TestScenes/material_perf_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "materials": 3 | [ 4 | { 5 | "name": "ground", 6 | "bsdf": "roughMetal", 7 | "baseColor": [0.9, 0.5, 0.1], 8 | "metalness": 0.0, 9 | "roughness": 0.01 10 | } 11 | ], 12 | "objects": 13 | [ 14 | { 15 | "type": "plane", 16 | "transform": { "translation": [0.0, -1.0, 0.0] }, 17 | "textureScale" : [0.4, 0.4], 18 | "size": [10.0, 10.0], 19 | "material": "ground" 20 | } 21 | ], 22 | "lights": 23 | [ 24 | { 25 | "type": "background", 26 | "color": [2.0, 2.0, 2.0], 27 | "texture": "TEXTURES/ENV/OutdoorCityParkingLotEveningClear_4K.exr" 28 | } 29 | ], 30 | "camera": 31 | { 32 | "transform": 33 | { 34 | "translation": [-2.4, 4.03, 3.49], 35 | "orientation": [0.69, 2.76, 0.0] 36 | }, 37 | "fieldOfView": 45.0 38 | } 39 | } -------------------------------------------------------------------------------- /Data/TestScenes/sphere_light_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "materials": 3 | [ 4 | { 5 | "name": "ground", 6 | "bsdf": "diffuse", 7 | "baseColor": [0.9, 0.9, 0.9], 8 | "baseColorTexture": "TEXTURES/default.bmp", 9 | "metalness": 0.0, 10 | "roughness": 0.5 11 | } 12 | ], 13 | "objects": 14 | [ 15 | { 16 | "type": "plane", 17 | "transform": { "translation": [0.0, -1.0, 0.0] }, 18 | "textureScale" : [0.4, 0.4], 19 | "size": [20.0, 20.0], 20 | "material": "ground" 21 | } 22 | ], 23 | "lights": 24 | [ 25 | { 26 | "type": "sphere", 27 | "color": [3.0, 3.0, 3.0], 28 | "position": [0.0, 1.0, 0.0], 29 | "radius": 1.0 30 | } 31 | ], 32 | "camera": 33 | { 34 | "transform": 35 | { 36 | "translation": [-2.4, 4.03, 3.49], 37 | "orientation": [0.69, 2.76, 0.0] 38 | }, 39 | "fieldOfView": 45.0 40 | } 41 | } -------------------------------------------------------------------------------- /Data/TestScenes/sponza.json: -------------------------------------------------------------------------------- 1 | { 2 | "materials": 3 | [ 4 | { 5 | "name": "plastic", 6 | "baseColor": [1.0, 1.0, 1.0], 7 | "metalness": 0.0, 8 | "roughness": 0.0 9 | } 10 | ], 11 | "objects": 12 | [ 13 | { 14 | "type": "mesh", 15 | "path": "MODELS/crytek-sponza/sponza.obj", 16 | "material": "plastic" 17 | } 18 | ], 19 | "lights": 20 | [ 21 | { 22 | "type": "background", 23 | "color": [1.0, 1.5, 2.0] 24 | }, 25 | { 26 | "type": "directional", 27 | "color": [20000.0, 19000.0, 18000.0], 28 | "angle": 1.0, 29 | "transform": { "orientation": [80.0, 0.0, 0.0] } 30 | } 31 | ], 32 | "camera": 33 | { 34 | "transform": 35 | { 36 | "translation": [979.0, 613.0, 99.0], 37 | "orientation": [6.7, -100.0, 0.0] 38 | }, 39 | "fieldOfView": 48.0 40 | } 41 | } -------------------------------------------------------------------------------- /Deps/.gitignore: -------------------------------------------------------------------------------- 1 | Bin 2 | build 3 | -------------------------------------------------------------------------------- /Deps/cmake/NFEGetAllTargets.cmake: -------------------------------------------------------------------------------- 1 | # @file 2 | # @author Lookey (costyrra.xl@gmail.com) 3 | # @brief CMake module defining NFE_GET_ALL_TARGETS function 4 | 5 | 6 | # @f NFE_GET_ALL_TARGETS 7 | # 8 | # Acquire a list of all targets defined up to the point of calling in CMake. 9 | FUNCTION(NFE_GET_ALL_TARGETS VAR) 10 | SET(TARGETS) 11 | __NFE_GET_ALL_TARGETS_RECURSIVE(TARGETS ${CMAKE_CURRENT_SOURCE_DIR}) 12 | SET(${VAR} ${TARGETS} PARENT_SCOPE) 13 | ENDFUNCTION() 14 | 15 | # @f __NFE_GET_ALL_TARGETS_RECURSIVE 16 | # 17 | # Helper macro for recursive acquisition of buildsystem targets 18 | MACRO(__NFE_GET_ALL_TARGETS_RECURSIVE TARGETS DIR) 19 | GET_PROPERTY(SUBDIRS DIRECTORY ${DIR} PROPERTY SUBDIRECTORIES) 20 | FOREACH(SUBDIR ${SUBDIRS}) 21 | __NFE_GET_ALL_TARGETS_RECURSIVE(${TARGETS} ${SUBDIR}) 22 | ENDFOREACH() 23 | 24 | GET_PROPERTY(CUR_TARGETS DIRECTORY ${DIR} PROPERTY BUILDSYSTEM_TARGETS) 25 | LIST(APPEND ${TARGETS} ${CUR_TARGETS}) 26 | ENDMACRO() 27 | -------------------------------------------------------------------------------- /Deps/post_build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | pushd . 4 | 5 | set script_dir=%~dp0 6 | cd "%script_dir%" 7 | echo Current directory is %cd% 8 | 9 | if NOT EXIST zlib\zconf.h ( 10 | echo Moving zconf.h.included to zconf.h so Git is happy about Deps/zlib being clean 11 | ren "%script_dir%\zlib\zconf.h.included" zconf.h 12 | ) 13 | 14 | popd 15 | 16 | echo Script is done 17 | -------------------------------------------------------------------------------- /Deps/post_build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd . > /dev/null 4 | cd $(dirname "${BASH_SOURCE[0]}") 5 | echo -n "Current deirectory is "; pwd 6 | 7 | 8 | # move zconf.h.included back to zconf.h 9 | if [ ! -e "./zlib/zconf.h" ]; then 10 | echo "Moving zconf.h.included to zconf.h so Git is happy about Deps/zlib being clean" 11 | mv ./zlib/zconf.h.included ./zlib/zconf.h 12 | fi 13 | 14 | popd > /dev/null 15 | 16 | echo "Post-build script is done" 17 | -------------------------------------------------------------------------------- /Gallery/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Gallery/1.jpg -------------------------------------------------------------------------------- /Gallery/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Gallery/2.jpg -------------------------------------------------------------------------------- /Gallery/caustics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Gallery/caustics.jpg -------------------------------------------------------------------------------- /Gallery/rough_glass.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Gallery/rough_glass.jpg -------------------------------------------------------------------------------- /Gallery/sponza.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Gallery/sponza.jpg -------------------------------------------------------------------------------- /Scripts/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | CPU_COUNT=`grep -c ^processor /proc/cpuinfo` 4 | echo "Available CPU cores: ${CPU_COUNT}" 5 | echo 6 | 7 | if [ "$#" -gt 1 ]; 8 | then 9 | echo "Incorrect number of parameters." 10 | echo "Usage: build.sh [BUILD_TYPE]" 11 | echo 12 | echo "Where:" 13 | echo " BUILD_TYPE - type of build (debug/release)" 14 | echo 15 | fi 16 | 17 | if [ "$#" -eq 0 ]; 18 | then 19 | echo "No BUILD_TYPE argument - assuming Release build" 20 | BUILD_TYPE="Release" 21 | else 22 | BUILD_TYPE=$1 23 | fi 24 | 25 | 26 | pushd . > /dev/null 27 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 28 | cd ${DIR}/.. 29 | echo -n "Current directory is "; pwd 30 | 31 | echo 32 | 33 | # ensure case-sensitiveness 34 | BUILD_TYPE="$(tr '[:lower:]' '[:upper:]' <<< ${BUILD_TYPE:0:1})${BUILD_TYPE:1}" 35 | 36 | mkdir -p build-$BUILD_TYPE 37 | 38 | # Build with given configuration 39 | cd build-$BUILD_TYPE 40 | cmake .. -DCMAKE_BUILD_TYPE=$BUILD_TYPE 41 | make -j ${CPU_COUNT} 42 | rc=$? 43 | echo 44 | 45 | popd > /dev/null 46 | 47 | exit $rc 48 | -------------------------------------------------------------------------------- /Scripts/clean.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | pushd . 4 | cd %~dp0\.. 5 | echo Current directory is %cd% 6 | 7 | echo | set /p=Removing VS-related files... 8 | del /F /Q "Engine.sdf" 2> clean_errors.txt 9 | del /F /Q "*.vsp" 2>> clean_errors.txt 10 | del /F /Q "*.psess" 2>> clean_errors.txt 11 | rd /S /Q "ipch" 2>> clean_errors.txt 12 | echo DONE 13 | 14 | echo | set /p=Removing compilation results... 15 | rd /S /Q "Bin" 2>> clean_errors.txt 16 | rd /S /Q "Obj" 2>> clean_errors.txt 17 | echo DONE 18 | 19 | echo | set /p=Removing shader compilation results... 20 | rd /S /Q "ShaderCache" 2>> clean_errors.txt 21 | rd /S /Q "ShaderCache_Debug" 2>> clean_errors.txt 22 | echo DONE 23 | 24 | echo | set /p=Removing other files... 25 | del /F /Q "cppcheck_result.txt" 26 | del /F /Q "*.pyc" 2>>clean_errors.txt 27 | echo DONE 28 | 29 | popd 30 | -------------------------------------------------------------------------------- /Scripts/clean.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd . > /dev/null 4 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 5 | cd ${DIR}/.. 6 | echo -n "Current directory is "; pwd 7 | 8 | # remove Visual Studio files 9 | echo -n "Removing VS-related files... " 10 | rm -f Engine.sdf *.vsp *.psess 11 | rm -rf ipch 12 | echo "DONE" 13 | 14 | # remove CMake files 15 | echo -n "Removing CMake-related files... " 16 | rm -rf CMakeFiles CMakeCache.txt cmake_install.cmake 17 | echo "DONE" 18 | 19 | echo -n "Removing compilation results... " 20 | rm -rf Bin 21 | rm -rf Obj 22 | echo "DONE" 23 | 24 | echo -n "Removing shader compilation results... " 25 | rm -rf ShaderCache 26 | rm -rf ShaderCache_Debug 27 | echo "DONE" 28 | 29 | echo -n "Removing build-produced files... " 30 | rm -rf build-* 31 | echo "DONE" 32 | 33 | echo -n "Removing other files... " 34 | rm -f cppcheck_result.txt 35 | rm -f *.pyc 36 | echo "DONE" 37 | 38 | popd > /dev/null 39 | -------------------------------------------------------------------------------- /Scripts/clear.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd . > /dev/null 4 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 5 | cd ${DIR}/.. 6 | echo -n "Current directory is "; pwd 7 | 8 | # remove CMake files 9 | echo -n "Removing CMake-related files... " 10 | rm -rf CMakeCache.txt cmake_install.cmake Makefile 11 | find . -type d -name CMakeFiles -prune -exec rm -rf {} \; 12 | echo "DONE" 13 | 14 | echo -n "Removing compilation results... " 15 | rm -rf Bin 16 | rm -rf Obj 17 | echo "DONE" 18 | 19 | echo -n "Removing build-produced files... " 20 | rm -rf build-* 21 | echo "DONE" 22 | 23 | popd > /dev/null 24 | -------------------------------------------------------------------------------- /Scripts/cppcheck.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: make sure that cppcheck is reachable 4 | echo | set /p=Checking for cppcheck... 5 | for %%X in (cppcheck.exe) do (set FOUND=%%~$PATH:X) 6 | if defined FOUND ( 7 | echo FOUND 8 | ) else ( 9 | echo NOT FOUND 10 | echo Make sure you download cppcheck before using this script. 11 | echo See README.md for more info. Exiting. 12 | pause 13 | exit /b 14 | ) 15 | 16 | pushd . 17 | cd %~dp0\.. 18 | echo Current dir is %cd% 19 | 20 | if "%1" == "quiet" ( 21 | cppcheck ./Src/ -q -j 8 --enable=warning 2> cppcheck_result.txt 22 | ) else ( 23 | cppcheck ./Src/ -j 8 --enable=warning 2> cppcheck_result.txt 24 | ) 25 | 26 | popd 27 | -------------------------------------------------------------------------------- /Scripts/cppcheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "Checking for cppcheck... " 4 | EXE_PATH=$(which cppcheck) 5 | if [ ! -x "$EXE_PATH" ] ; then 6 | echo "NOT FOUND" 7 | echo " Make sure you download cppcheck before using this script." 8 | echo " See README.md for more info. Exiting." 9 | read -p "Press [Enter] to continue. " 10 | exit 11 | else 12 | echo "FOUND" 13 | fi 14 | 15 | pushd . > /dev/null 16 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 17 | cd ${DIR}/.. 18 | echo -n "Current directory is "; pwd 19 | 20 | if [ "$1" == "quiet" ] ; then 21 | cppcheck ./Src/ -q -j 8 --enable=warning 2> cppcheck_result.txt 22 | else 23 | cppcheck ./Src/ -j 8 --enable=warning 2> cppcheck_result.txt 24 | fi 25 | 26 | popd > /dev/null 27 | -------------------------------------------------------------------------------- /Scripts/gen_doc.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | :: make sure that doxygen is reachable 4 | echo | set /p=Checking for doxygen... 5 | for %%X in (doxygen.exe) do (set FOUND=%%~$PATH:X) 6 | if defined FOUND ( 7 | echo FOUND 8 | ) else ( 9 | echo NOT FOUND 10 | echo Make sure you download doxygen before using this script. 11 | echo See README.md for more info. Exiting. 12 | pause 13 | exit /b 14 | ) 15 | 16 | pushd . 17 | cd %~dp0\.. 18 | echo Current directory is %cd% 19 | doxygen Scripts\doxygen.cfg 20 | popd 21 | -------------------------------------------------------------------------------- /Scripts/gen_doc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo -n "Checking for doxygen... " 4 | EXE_PATH=$(which astyle) 5 | if [ ! -x "$EXE_PATH" ] ; then 6 | echo "NOT FOUND" 7 | echo " Make sure you download doxygen before using this script." 8 | echo " See README.md for more info. Exiting." 9 | read -p "Press [Enter] to continue. " 10 | exit 11 | else 12 | echo "FOUND" 13 | fi 14 | 15 | pushd . > /dev/null 16 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 17 | cd ${DIR}/.. 18 | echo -n "Current directory is "; pwd 19 | 20 | doxygen Scripts/doxygen.cfg 21 | 22 | popd > /dev/null 23 | -------------------------------------------------------------------------------- /Scripts/pre-commit.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | 3 | pushd . 4 | cd %~dp0 5 | 6 | echo. 7 | echo Pre-commit script for nfEngine project 8 | echo Script meant to verify if provided commit is OK 9 | echo. 10 | echo ===================== 11 | echo Running code analysis 12 | echo ===================== 13 | echo. 14 | 15 | call cppcheck.bat quiet 16 | if exist ..\cppcheck_result.txt ( 17 | echo Results from cppcheck: 18 | type ..\cppcheck_result.txt 19 | ) 20 | 21 | echo. 22 | echo =================== 23 | echo Running style check 24 | echo =================== 25 | echo. 26 | 27 | call format.bat dry 28 | 29 | echo. 30 | echo ============= 31 | echo Running tests 32 | echo ============= 33 | echo. 34 | 35 | call tests.py -q 36 | 37 | popd 38 | 39 | echo. 40 | echo Pre-commit script has finished its work. 41 | echo Remember to compare these results with current top commit on devel branch. 42 | echo. 43 | echo If you see any errors, fix them before committing. Otherwise, failed 44 | echo verification during review is imminent. 45 | echo. 46 | -------------------------------------------------------------------------------- /Scripts/rebuild-all.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | pushd . > /dev/null 4 | DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) 5 | cd ${DIR}/.. 6 | echo -n "Current directory is "; pwd 7 | 8 | Scripts/clean.sh 9 | echo 10 | 11 | Scripts/build.sh Debug 12 | Scripts/build.sh Release 13 | 14 | popd > /dev/null 15 | -------------------------------------------------------------------------------- /Src/Apps/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(NFE_APPS_DIRECTORY ${NFE_SRC_DIRECTORY}/Apps) 2 | 3 | ADD_SUBDIRECTORY("RaytracerDemo") 4 | ADD_SUBDIRECTORY("RendererDemo") 5 | 6 | # EngineDemo needs rewrite for other platforms - uses WinMain and other Windows-only parts 7 | IF(WIN32) 8 | ADD_SUBDIRECTORY("EngineDemo") 9 | SET(NFE_ENGINEDEMO_DEPENDENCY EngineDemo) 10 | ELSEIF(UNIX) 11 | SET(NFE_ENGINEDEMO_DEPENDENCY ) 12 | ELSE(WIN32) 13 | MESSAGE(FATAL_ERROR "Target platform not supported") 14 | ENDIF(WIN32) 15 | 16 | # Meta target to build all test apps 17 | ADD_CUSTOM_TARGET(Apps_All DEPENDS RendererDemo RaytracerDemo ${NFE_ENGINEDEMO_DEPENDENCY} 18 | COMMENT "Build all apps and their dependencies" 19 | ) 20 | -------------------------------------------------------------------------------- /Src/Apps/EngineDemo/Controllers/FlickeringLightController.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Core/Scene/Scene.hpp" 4 | #include "Engine/Core/Scene/EntityController.hpp" 5 | #include "Engine/Core/Scene/Events/Event.hpp" 6 | 7 | #include "Engine/Common/Math/Random.hpp" 8 | 9 | namespace NFE { 10 | 11 | /** 12 | * Example entity controller implementation - light that flickers randomly. 13 | */ 14 | class FlickeringLightController : public Scene::IEntityController 15 | { 16 | public: 17 | FlickeringLightController( 18 | const Math::Vec3f& baseColor = Math::Vec3f(1.0f, 1.0f, 1.0f), 19 | float frequency = 0.02f); 20 | 21 | virtual void OnEvent(const Scene::Event& event) override; 22 | 23 | private: 24 | Math::Vec3f mBaseColor; 25 | 26 | // 0.0f - no flicker, 1.0f - no light all the time 27 | float mFrequency; 28 | }; 29 | 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Apps/EngineDemo/Controllers/TriggeredLightController.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Core/Scene/EntityController.hpp" 4 | #include "Engine/Core/Scene/Events/Event.hpp" 5 | 6 | 7 | namespace NFE { 8 | 9 | /** 10 | * Example entity controller implementation - light that changes a color when camera is inside trigger. 11 | */ 12 | class TriggeredLightController : public Scene::IEntityController 13 | { 14 | public: 15 | TriggeredLightController(); 16 | ~TriggeredLightController(); 17 | 18 | virtual void OnEvent(const Scene::Event& event) override; 19 | 20 | private: 21 | // number of source triggers that entered controlled light 22 | uint32 mTriggerCounter; 23 | }; 24 | 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Apps/EngineDemo/Main.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Core/Scene/Systems/EntitySystem.hpp" 4 | #include "Engine/Common/Math/Random.hpp" 5 | #include "Engine/Common/System/Timer.hpp" 6 | #include "Engine/Common/Logger/Logger.hpp" 7 | #include "Engine/Common/Containers/UniquePtr.hpp" 8 | 9 | namespace NFE { 10 | 11 | class GameWindow; 12 | 13 | extern Engine* gEngine; 14 | extern float gDeltaTime; 15 | 16 | void SceneDeleter(Scene::Scene* scene); 17 | GameWindow* AddWindow(GameWindow* parent = nullptr); 18 | 19 | } // namespace NFE 20 | -------------------------------------------------------------------------------- /Src/Apps/EngineDemo/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" -------------------------------------------------------------------------------- /Src/Apps/EngineDemo/PCH.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | //ignore pointless warnings 4 | #pragma warning (disable: 4251) 5 | #pragma warning (disable: 4100) 6 | 7 | // enable memory allocation tracking (Windows only) 8 | #if defined(NFE_PLATFORM_WINDOWS) && defined(NFE_CONFIGURATION_DEBUG) 9 | #define _CRTDBG_MAP_ALLOC 10 | #include 11 | #include 12 | #endif // defined(NFE_PLATFORM_WINDOWS) && defined(NFE_CONFIGURATION_DEBUG) 13 | 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #if defined(NFE_PLATFORM_WINDOWS) 21 | #define WIN32_LEAN_AND_MEAN 22 | #define NOMINMAX 23 | #include 24 | #endif // defined(NFE_PLATFORM_WINDOWS) 25 | 26 | #ifdef GetWindowFont 27 | #undef GetWindowFont // ImGui workaround - GetWindowFont is both WinAPI macro and ImGui function 28 | #endif 29 | #include "imgui.h" -------------------------------------------------------------------------------- /Src/Apps/RaytracerDemo/MeshLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Raytracer/Shapes/MeshShape.h" 4 | #include "Engine/Raytracer/Material/Material.h" 5 | #include "Engine/Raytracer/Utils/Bitmap.h" 6 | #include "Engine/Common/Containers/HashMap.hpp" 7 | 8 | namespace NFE { 9 | namespace helpers { 10 | 11 | using MaterialsMap = Common::HashMap; 12 | 13 | RT::BitmapPtr LoadBitmapObject(const Common::StringView& baseDir, const Common::StringView& path); 14 | RT::TexturePtr LoadTexture(const Common::StringView& baseDir, const Common::StringView& path); 15 | RT::MeshShapePtr LoadMesh(const Common::String& filePath, MaterialsMap& outMaterials, const float scale = 1.0f); 16 | RT::MaterialPtr CreateDefaultMaterial(MaterialsMap& outMaterials); 17 | 18 | } // namespace helpers 19 | } // namespace NFE -------------------------------------------------------------------------------- /Src/Apps/RaytracerDemo/ObjectEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Common/Reflection/ReflectionTypeRegistry.hpp" 4 | #include "Engine/Common/Reflection/Types/ReflectionFundamentalType.hpp" 5 | #include "Engine/Common/Reflection/Object.hpp" 6 | 7 | namespace NFE { 8 | 9 | bool EditObject_Root_Internal(const char* rootName, const RTTI::Type* type, void* data); 10 | 11 | template 12 | typename std::enable_if, const RTTI::Type*>::type GetEditedObjectType(const T& object) 13 | { 14 | return object.GetDynamicType(); 15 | } 16 | 17 | template 18 | typename std::enable_if, const RTTI::Type*>::type GetEditedObjectType(const T& object) 19 | { 20 | NFE_UNUSED(object); 21 | return RTTI::GetType(); 22 | } 23 | 24 | template 25 | bool EditObject(const char* rootName, T& object) 26 | { 27 | const RTTI::Type* type = GetEditedObjectType(object); 28 | return EditObject_Root_Internal(rootName, type, &object); 29 | } 30 | 31 | } // namesapce NFE -------------------------------------------------------------------------------- /Src/Apps/RaytracerDemo/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" -------------------------------------------------------------------------------- /Src/Apps/RaytracerDemo/PCH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(NFE_CONFIGURATION_DEBUG) && defined(NFE_PLATFORM_WINDOWS) 4 | #define _CRTDBG_MAP_ALLOC 5 | #include 6 | #include 7 | #endif // NFE_CONFIGURATION_DEBUG 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | -------------------------------------------------------------------------------- /Src/Apps/RaytracerDemo/SceneLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Raytracer/Scene/Scene.h" 4 | 5 | namespace NFE { 6 | namespace helpers { 7 | 8 | bool LoadScene(const Common::String& path, RT::Scene& scene, RT::Camera& camera); 9 | 10 | } // namespace helpers 11 | } // namespace NFE -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/PCH.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Precompiled header CPP stub 5 | */ 6 | 7 | #include "PCH.hpp" 8 | -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/PCH.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Precompiled header 5 | */ 6 | 7 | #pragma once 8 | 9 | // enable memory allocation tracking (Windows only) 10 | #if defined(NFE_PLATFORM_WINDOWS) && defined(NFE_CONFIGURATION_DEBUG) 11 | #define _CRTDBG_MAP_ALLOC 12 | #include 13 | #include 14 | #endif // defined(NFE_PLATFORM_WINDOWS) && defined(NFE_CONFIGURATION_DEBUG) 15 | 16 | #if defined(NFE_PLATFORM_WINDOWS) 17 | #define WIN32_LEAN_AND_MEAN 18 | #define NOMINMAX 19 | #include 20 | #endif // defined(NFE_PLATFORM_WINDOWS) 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/InstancingTestPS.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexShaderOutput 2 | { 3 | float4 Pos : SV_POSITION; 4 | float4 Color : TEXCOORD0; 5 | }; 6 | 7 | float4 main(VertexShaderOutput input) : SV_TARGET0 8 | { 9 | return input.Color; 10 | } 11 | -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/InstancingTestVS.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexShaderInput 2 | { 3 | float3 Pos : POSITION; 4 | float4 Color : TEXCOORD0; 5 | 6 | #if (USE_INSTANCING > 0) 7 | float3 InstancePos : TEXCOORD1; 8 | float4 InstanceColor : TEXCOORD2; 9 | #endif // (USE_INSTANCING > 0) 10 | }; 11 | 12 | struct VertexShaderOutput 13 | { 14 | float4 Pos : SV_POSITION; 15 | float4 Color : TEXCOORD0; 16 | }; 17 | 18 | VertexShaderOutput main(VertexShaderInput input) 19 | { 20 | VertexShaderOutput output; 21 | output.Pos = float4(input.Pos, 1.0f); 22 | output.Color = input.Color; 23 | 24 | #if (USE_INSTANCING > 0) 25 | output.Pos += float4(input.InstancePos, 0.0f); 26 | output.Color *= input.InstanceColor; 27 | #endif // (USE_INSTANCING > 0) 28 | 29 | return output; 30 | } 31 | -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/RenderTargetPS.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexShaderOutput 2 | { 3 | float2 TexCoord : TEXCOORD0; 4 | float4 Color : TEXCOORD1; 5 | float4 Pos : SV_POSITION; 6 | }; 7 | 8 | struct PixelShaderOutput 9 | { 10 | float4 color0 : SV_TARGET0; 11 | #if (TARGETS > 1) 12 | float4 color1 : SV_TARGET1; 13 | #endif 14 | }; 15 | 16 | PixelShaderOutput main(VertexShaderOutput In) 17 | { 18 | PixelShaderOutput Out; 19 | Out.color0 = In.Color; 20 | #if (TARGETS > 1) 21 | Out.color1 = float4(1.0f, 1.0f, 1.0f, 1.0f) - In.Color; 22 | #endif 23 | return Out; 24 | } 25 | -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/TessellationCommon.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexShaderOutput 2 | { 3 | float3 pos : POSITION; 4 | }; 5 | 6 | struct HullShaderConstantOutput 7 | { 8 | float edges[2] : SV_TessFactor; 9 | }; 10 | 11 | struct HullShaderOutput 12 | { 13 | float3 pos : POSITION; 14 | }; 15 | 16 | struct DomainShaderOutput 17 | { 18 | float4 position : SV_Position; 19 | }; -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/TessellationDS.hlsl: -------------------------------------------------------------------------------- 1 | #include "TessellationCommon.hlsl" 2 | 3 | [domain("isoline")] 4 | DomainShaderOutput main(HullShaderConstantOutput input, 5 | OutputPatch outputPatch, 6 | float2 uv : SV_DomainLocation) 7 | { 8 | DomainShaderOutput output; 9 | 10 | float t = uv.x; 11 | 12 | // Bezier interpolation 13 | float3 pos = pow(1.0f - t, 3.0f) * outputPatch[0].pos + 14 | 3.0f * pow(1.0f - t, 2.0f) * t * outputPatch[1].pos + 15 | 3.0f * (1.0f - t) * pow(t, 2.0f) * outputPatch[2].pos + 16 | pow(t, 3.0f) * outputPatch[3].pos; 17 | 18 | output.position = float4(pos, 1.0f); 19 | 20 | return output; 21 | } -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/TessellationHS.hlsl: -------------------------------------------------------------------------------- 1 | #include "TessellationCommon.hlsl" 2 | 3 | HullShaderConstantOutput HSConst() 4 | { 5 | HullShaderConstantOutput output; 6 | output.edges[0] = 1.0f; // Detail factor 7 | output.edges[1] = 60.0; // Density factor 8 | return output; 9 | } 10 | 11 | [domain("isoline")] 12 | [partitioning("integer")] 13 | [outputtopology("line")] 14 | [outputcontrolpoints(4)] 15 | [patchconstantfunc("HSConst")] 16 | HullShaderOutput main(InputPatch inputPatch, 17 | uint id : SV_OutputControlPointID) 18 | { 19 | HullShaderOutput output; 20 | output.pos = inputPatch[id].pos; 21 | return output; 22 | } -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/TessellationPS.hlsl: -------------------------------------------------------------------------------- 1 | #include "TessellationCommon.hlsl" 2 | 3 | float4 main(DomainShaderOutput input) : SV_Target0 4 | { 5 | return float4(1.0f, 1.0f, 1.0f, 1.0f); 6 | } -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/TessellationVS.hlsl: -------------------------------------------------------------------------------- 1 | #include "TessellationCommon.hlsl" 2 | 3 | // simple passtrough vertex shader 4 | VertexShaderOutput main(VertexShaderOutput input) 5 | { 6 | return input; 7 | } 8 | -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/TestPS.hlsl: -------------------------------------------------------------------------------- 1 | #if (USE_TEXTURE > 0) 2 | [[vk::binding(0)]] 3 | Texture2D gTexture : register(t0); 4 | [[vk::binding(0)]] 5 | SamplerState gSampler : register(s0); 6 | #endif 7 | 8 | struct VertexShaderOutput 9 | { 10 | float2 TexCoord : TEXCOORD0; 11 | float4 Color : TEXCOORD1; 12 | float4 Pos : SV_POSITION; 13 | }; 14 | 15 | float4 main(VertexShaderOutput In) : SV_TARGET0 16 | { 17 | #if (USE_TEXTURE > 0) 18 | return In.Color * gTexture.Sample(gSampler, In.TexCoord); 19 | #else 20 | return In.Color; 21 | #endif 22 | } 23 | -------------------------------------------------------------------------------- /Src/Apps/RendererDemo/Shaders/HLSL5/TestVS.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexShaderInput 2 | { 3 | float3 Pos : POSITION; 4 | float2 TexCoord : TEXCOORD0; 5 | float4 Color : TEXCOORD1; 6 | }; 7 | 8 | struct VertexShaderOutput 9 | { 10 | float2 TexCoord : TEXCOORD0; 11 | float4 Color : TEXCOORD1; 12 | float4 Pos : SV_POSITION; 13 | }; 14 | 15 | #if (USE_CBUFFER > 0) 16 | cbuffer TestCBuffer : register(b0) 17 | { 18 | row_major float4x4 viewMatrix; 19 | }; 20 | #endif 21 | 22 | VertexShaderOutput main(VertexShaderInput In) 23 | { 24 | VertexShaderOutput Out = (VertexShaderOutput)0; 25 | Out.Pos = float4(In.Pos, 1.0f); 26 | 27 | #if (USE_CBUFFER > 0) 28 | Out.Pos = mul(Out.Pos, viewMatrix); 29 | #endif 30 | 31 | Out.TexCoord = In.TexCoord; 32 | Out.Color = In.Color; 33 | return Out; 34 | } 35 | -------------------------------------------------------------------------------- /Src/Benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(NFE_BENCHMARKS_DIRECTORY ${NFE_SRC_DIRECTORY}/Benchmarks) 2 | 3 | # ADD_SUBDIRECTORY("RaytracerBenchmark") 4 | -------------------------------------------------------------------------------- /Src/Benchmarks/RaytracerBenchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | MESSAGE("Generating Makefile for Benchmark project") 2 | 3 | FILE(GLOB RT_BENCHMARK_SOURCES *.cpp) 4 | FILE(GLOB_RECURSE RT_BENCHMARK_EXTERNAL_SOURCES ../External/benchmark/*.cc) 5 | FILE(GLOB RT_BENCHMARK_HEADERS *.h) 6 | 7 | # Search for dependencies 8 | # PKG_CHECK_MODULES(RT_BENCHMARK_DEPS REQUIRED) 9 | 10 | INCLUDE_DIRECTORIES(${RT_BENCHMARK_DIRECTORY}/ ${RT_ROOT_DIRECTORY}/External/benchmark/include/ ${RT_ROOT_DIRECTORY}/External/benchmark/) 11 | LINK_DIRECTORIES(${RT_LIB_DIRECTORY} ${NFE_OUTPUT_DIRECTORY}) 12 | 13 | ADD_EXECUTABLE(Benchmark ${RT_BENCHMARK_SOURCES} ${RT_BENCHMARK_HEADERS} ${RT_BENCHMARK_EXTERNAL_SOURCES} ${RT_BENCHMARK_LINUX_SOURCES}) 14 | SET_TARGET_PROPERTIES(Benchmark PROPERTIES LINK_FLAGS "-pthread") 15 | 16 | ADD_DEPENDENCIES(Benchmark Core) 17 | TARGET_LINK_LIBRARIES(Benchmark Core dl ${RT_BENCHMARK_DEPS_LIBRARIES}) 18 | ADD_CUSTOM_COMMAND(TARGET Benchmark POST_BUILD COMMAND 19 | ${CMAKE_COMMAND} -E copy $ ${NFE_OUTPUT_DIRECTORY}/${targetfile}) 20 | -------------------------------------------------------------------------------- /Src/Benchmarks/RaytracerBenchmark/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" -------------------------------------------------------------------------------- /Src/Benchmarks/RaytracerBenchmark/PCH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_DEBUG) && defined(WIN32) 4 | #define _CRTDBG_MAP_ALLOC 5 | #include 6 | #include 7 | #endif // _DEBUG 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | -------------------------------------------------------------------------------- /Src/Engine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # @file 2 | # @author Lookey (costyrra.xl@gmail.com) 3 | # @brief CMake for nfEngine 4 | 5 | SET(NFE_ENGINE_DIRECTORY ${NFE_SRC_DIRECTORY}/Engine) 6 | 7 | ADD_SUBDIRECTORY("Common") 8 | ADD_SUBDIRECTORY("Raytracer") 9 | ADD_SUBDIRECTORY("Renderers") 10 | ADD_SUBDIRECTORY("Core") 11 | 12 | IF(WIN32) 13 | SET(ENGINE_RENDERERD3D12_DEPENDENCY ) #RendererD3D12) 14 | ELSE(WIN32) 15 | SET(ENGINE_RENDERERD3D12_DEPENDENCY ) 16 | ENDIF(WIN32) 17 | 18 | ADD_CUSTOM_TARGET(Engine_All DEPENDS Common Raytracer RendererCommon RendererVk ${ENGINE_RENDERERD3D12_DEPENDENCY} Core 19 | COMMENT "Build all Engine projects and dependencies" 20 | ) 21 | -------------------------------------------------------------------------------- /Src/Engine/Common/Containers/Comparator.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Comparator template class used for comparing elements in containers, sorting, etc. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../nfCommon.hpp" 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | 15 | // default values comparator 16 | template 17 | struct DefaultComparator 18 | { 19 | NFE_INLINE bool Less(const T& left, const T& right) const 20 | { 21 | return left < right; 22 | } 23 | 24 | NFE_INLINE bool Equal(const T& left, const T& right) const 25 | { 26 | return left == right; 27 | } 28 | }; 29 | 30 | } // namespace Common 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Common/Containers/SharedPtrBase.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief Shared pointer data 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "SharedPtrBase.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | 15 | uint32 SharedPtrBase::RefCount() const 16 | { 17 | if (mData) 18 | { 19 | const int32 numRefs = mData->mStrongRefs; 20 | NFE_ASSERT(numRefs >= 0, "Invalid ref count"); 21 | return static_cast(numRefs); 22 | } 23 | 24 | return 0; 25 | } 26 | 27 | uint32 SharedPtrBase::WeakRefCount() const 28 | { 29 | if (mData) 30 | { 31 | const uint32 numRefs = mData->mWeakRefs; 32 | NFE_ASSERT(numRefs > 0, "Invalid ref count"); 33 | return static_cast(numRefs); 34 | } 35 | 36 | return 0; 37 | } 38 | 39 | } // namespace Common 40 | } // namespace NFE 41 | -------------------------------------------------------------------------------- /Src/Engine/Common/Containers/SharedPtrData.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief Shared pointer data 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "SharedPtrData.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | 15 | SharedPtrData::SharedPtrData() 16 | : mStrongRefs(1) 17 | , mWeakRefs(1) 18 | { } 19 | 20 | SharedPtrData::~SharedPtrData() 21 | { 22 | NFE_ASSERT(mStrongRefs == 0, "Strong references counter expected to be equal to zero"); 23 | NFE_ASSERT(mWeakRefs == 0, "Weak references counter expected to be equal to zero"); 24 | } 25 | 26 | } // namespace Common 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Common/Debug/Common.log: -------------------------------------------------------------------------------- 1 | C:\Users\Michal\Documents\DEV\nfengine\Src\Engine\Common\Common.vcxproj(359,5): error MSB4019: The imported project "C:\Users\Michal\Documents\DEV\nfengine\Src\PropertyPages\GlobalProperties.props" was not found. Confirm that the expression in the Import declaration "..\..\PropertyPages\GlobalProperties.props" is correct, and that the file exists on disk. 2 | -------------------------------------------------------------------------------- /Src/Engine/Common/Image/ImageBMP.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief ImageBMP class declaration. 5 | */ 6 | 7 | #pragma once 8 | #include "ImageType.hpp" 9 | 10 | namespace NFE { 11 | namespace Common { 12 | 13 | class Image; 14 | 15 | class ImageBMP : public ImageType 16 | { 17 | NFE_DECLARE_POLYMORPHIC_CLASS(ImageBMP) 18 | 19 | public: 20 | virtual StringView GetName() const override; 21 | virtual bool Check(InputStream* stream) override; 22 | virtual bool Load(Image* img, InputStream* stream) override; 23 | virtual bool Save(Image* img, OutputStream* stream) override; 24 | }; 25 | 26 | } // namespace Common 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Common/Image/ImageDDS.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief ImageDDS class declaration. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "ImageType.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | class ImageDDS : public ImageType 16 | { 17 | NFE_DECLARE_POLYMORPHIC_CLASS(ImageDDS) 18 | 19 | public: 20 | virtual StringView GetName() const override; 21 | virtual bool Check(InputStream* stream) override; 22 | virtual bool Load(Image* img, InputStream* stream) override; 23 | virtual bool Save(Image* img, OutputStream* stream) override; 24 | }; 25 | 26 | } // namespace Common 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Common/Image/ImageJPG.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief ImageJPG class declaration. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "ImageType.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | class ImageJPG : public ImageType 16 | { 17 | NFE_DECLARE_POLYMORPHIC_CLASS(ImageJPG) 18 | 19 | public: 20 | virtual StringView GetName() const override; 21 | virtual bool Check(InputStream* stream) override; 22 | virtual bool Load(Image* img, InputStream* stream) override; 23 | virtual bool Save(Image* img, OutputStream* stream) override; 24 | }; 25 | 26 | } // namespace Common 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Common/Image/ImagePNG.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief ImagePNG class declaration. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "ImageType.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | class ImagePNG : public ImageType 16 | { 17 | NFE_DECLARE_POLYMORPHIC_CLASS(ImagePNG) 18 | 19 | public: 20 | virtual StringView GetName() const override; 21 | virtual bool Check(InputStream* stream) override; 22 | virtual bool Load(Image* img, InputStream* stream) override; 23 | virtual bool Save(Image* img, OutputStream* stream) override; 24 | }; 25 | 26 | } // namespace Common 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/Backends/BackendCommon.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief Common logger backends definitions 5 | */ 6 | 7 | #pragma once 8 | 9 | #define NFE_MAX_LOG_MESSAGE_LENGTH 1024 10 | 11 | /// snprintf was not implemented until Visual Studio 2015 12 | #if defined(NFE_PLATFORM_WINDOWS) && defined(_MSC_VER) 13 | #if _MSC_VER <= 1800 14 | #define snprintf sprintf_s 15 | #endif 16 | #endif -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/Backends/BackendConsole.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of console (standard output) logger backend 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../LoggerBackend.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | /** 16 | * Console logger backend implementation. 17 | */ 18 | class NFCOMMON_API LoggerBackendConsole final : public ILoggerBackend 19 | { 20 | public: 21 | void Log(LogType type, const char* srcFile, int line, const char* str, double timeElapsed) override; 22 | }; 23 | 24 | } // namespace Common 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/Backends/BackendHTML.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of HTML logger backend 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../LoggerBackend.hpp" 10 | #include "../../FileSystem/File.hpp" 11 | #include "../../Containers/DynArray.hpp" 12 | 13 | 14 | namespace NFE { 15 | namespace Common { 16 | 17 | /** 18 | * HTML logger backend implementation. 19 | */ 20 | class NFCOMMON_API LoggerBackendHTML final : public ILoggerBackend 21 | { 22 | File mFile; 23 | DynArray mBuffer; 24 | 25 | public: 26 | LoggerBackendHTML(); 27 | ~LoggerBackendHTML(); 28 | 29 | bool Init() override; 30 | void Log(LogType type, const char* srcFile, int line, const char* str, double timeElapsed) override; 31 | }; 32 | 33 | } // namespace Common 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/Backends/BackendTxt.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief Declaration of raw txt logger backend 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../LoggerBackend.hpp" 10 | #include "../../FileSystem/File.hpp" 11 | #include "../../Containers/DynArray.hpp" 12 | 13 | 14 | namespace NFE { 15 | namespace Common { 16 | 17 | /** 18 | * Raw txt logger backend implementation. 19 | */ 20 | class NFCOMMON_API LoggerBackendTxt final : public ILoggerBackend 21 | { 22 | File mFile; 23 | DynArray mBuffer; 24 | 25 | public: 26 | LoggerBackendTxt(); 27 | 28 | bool Init() override; 29 | void Log(LogType type, const char* srcFile, int line, const char* str, double timeElapsed) override; 30 | }; 31 | 32 | } // namespace Common 33 | } // namespace NFE 34 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/Backends/BackendXML.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief Declaration of XML logger backend 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../LoggerBackend.hpp" 10 | #include "../../FileSystem/File.hpp" 11 | #include "../../Containers/DynArray.hpp" 12 | 13 | 14 | namespace NFE { 15 | namespace Common { 16 | 17 | /** 18 | * XML logger backend implementation. 19 | */ 20 | class NFCOMMON_API LoggerBackendXML : public ILoggerBackend 21 | { 22 | File mFile; 23 | DynArray mBuffer; 24 | 25 | public: 26 | LoggerBackendXML(); 27 | ~LoggerBackendXML(); 28 | 29 | bool Init() override; 30 | void Log(LogType type, const char* srcFile, int line, const char* str, double timeElapsed) override; 31 | }; 32 | 33 | } // namespace Common 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/Backends/Windows/BackendWindowsDebugger.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of Windows debugger logger backend 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../../LoggerBackend.hpp" 10 | #include "../../../Containers/DynArray.hpp" 11 | #include "../../../Containers/String.hpp" 12 | #include "../../../System/Windows/Common.hpp" 13 | 14 | namespace NFE { 15 | namespace Common { 16 | 17 | /** 18 | * Implementation of Windows debugger logger backend. 19 | */ 20 | class NFCOMMON_API LoggerBackendWinDebugger final : public ILoggerBackend 21 | { 22 | DynArray mBuffer; 23 | String mDebugString; 24 | Utf16String mWideDebugString; 25 | 26 | public: 27 | LoggerBackendWinDebugger(); 28 | void Log(LogType type, const char* srcFile, int line, const char* str, double timeElapsed) override; 29 | }; 30 | 31 | } // namespace Common 32 | } // namespace NFE 33 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/LogScope.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief Definition of LogScope class 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "LogScope.hpp" 9 | #include "Logger/Logger.hpp" 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | LogScope::LogScope() 15 | : LogScope("Scope") 16 | { 17 | } 18 | 19 | LogScope::LogScope(const char* name) 20 | : mScopeName(name) 21 | { 22 | NFE_LOG_INFO("Entering scope %s.", mScopeName); 23 | } 24 | 25 | LogScope::LogScope(const char* name, const char* file, int line) 26 | : mScopeName(name) 27 | { 28 | NFE_LOG_INFO("Entering scope %s in %s@%i.", mScopeName, file, line); 29 | } 30 | 31 | LogScope::~LogScope() 32 | { 33 | NFE_LOG_INFO("Exiting scope %s.", mScopeName); 34 | } 35 | 36 | } // namespace Common 37 | } // namespace NFE 38 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/LogScope.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief LogScope class declarations. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../nfCommon.hpp" 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | class NFCOMMON_API LogScope 15 | { 16 | private: 17 | const char* mScopeName; 18 | 19 | public: 20 | LogScope(); 21 | LogScope(const char* name); 22 | LogScope(const char* name, const char* file, int line); 23 | ~LogScope(); 24 | }; 25 | 26 | // Macro for easy calling LogScope's constructor with __FILE__ and __LINE__. 27 | #define LOG_SCOPE(scopeName) LogScope scopeName(#scopeName, __FILE__, __LINE__) 28 | 29 | } // namespace Common 30 | } // namespace NFE -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/Logger.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Definition of Logger class 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "LoggerImpl.hpp" 9 | 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | ILogger::ILogger() = default; 16 | ILogger::~ILogger() = default; 17 | 18 | ILogger* ILogger::GetInstance() 19 | { 20 | return Logger::GetInstance(); 21 | } 22 | 23 | } // namespace Common 24 | } // namespace NFE 25 | -------------------------------------------------------------------------------- /Src/Engine/Common/Logger/LoggerBackend.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Definition of ILoggerBackend class 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "LoggerBackend.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | 15 | ILoggerBackend::ILoggerBackend() 16 | : mIsEnabled(false) 17 | { 18 | } 19 | 20 | ILoggerBackend::~ILoggerBackend() = default; 21 | 22 | bool ILoggerBackend::Init() 23 | { 24 | return true; 25 | } 26 | 27 | 28 | } // namespace Common 29 | } // namespace NFE 30 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/ColorHelpers.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "ColorHelpers.hpp" 8 | 9 | namespace NFE { 10 | namespace Math { 11 | 12 | static const float* Init_sRGB_To_Linear_LUT() 13 | { 14 | float* lut = (float*)NFE_MALLOC(256 * sizeof(float), NFE_CACHE_LINE_SIZE); 15 | 16 | NFE_ASSERT(lut, "Failed to allocate LUT"); 17 | 18 | for (uint32 i = 0; i < 256u; ++i) 19 | { 20 | const float x = static_cast(i) / 255.0f; 21 | lut[i] = Convert_sRGB_To_Linear_Exact(x); 22 | } 23 | 24 | return lut; 25 | } 26 | 27 | NFCOMMON_API const float* sRGB_To_Linear_LUT = Init_sRGB_To_Linear_LUT(); 28 | 29 | } // namespace Math 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Constants.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace NFE { 4 | namespace Math { 5 | namespace constants { 6 | 7 | // Planck constant 8 | constexpr const float h = 6.6260693e-34f; 9 | 10 | // Speed of light 11 | constexpr const float c = 299792458.0f; 12 | 13 | // Boltzmann's constant 14 | constexpr const float k = 1.3806505e-23f; 15 | 16 | } // namespace constants 17 | } // namespace Math 18 | } // namespace NFE 19 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Conversions.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of functions for types conversions. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../nfCommon.hpp" 10 | #include "Math.hpp" 11 | 12 | 13 | namespace NFE { 14 | namespace Math { 15 | 16 | NFCOMMON_API uint8 ToUint8(float x); 17 | NFCOMMON_API uint8 ToNormUint8(float x); 18 | NFCOMMON_API int8 ToInt8(float x); 19 | NFCOMMON_API int8 ToNormInt8(float x); 20 | NFCOMMON_API uint16 ToUint16(float x); 21 | NFCOMMON_API uint16 ToNormUint16(float x); 22 | NFCOMMON_API int16 ToInt16(float x); 23 | NFCOMMON_API int16 ToNormInt16(float x); 24 | NFCOMMON_API uint32 ToUint32(float x); 25 | NFCOMMON_API int32 ToInt32(float x); 26 | 27 | } // namespace Math 28 | } // namespace NFE 29 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Distribution.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../nfCommon.hpp" 4 | 5 | namespace NFE { 6 | namespace Math { 7 | 8 | // Utility class for fast sampling 1D probability distribution function 9 | // (piecewise constant) 10 | class NFCOMMON_API Distribution 11 | { 12 | NFE_MAKE_NONCOPYABLE(Distribution) 13 | NFE_MAKE_NONMOVEABLE(Distribution) 14 | 15 | public: 16 | Distribution(); 17 | ~Distribution(); 18 | 19 | // initialize with 1D pdf function 20 | bool Initialize(const float* pdfValues, uint32 numValues); 21 | 22 | // sample discrete 23 | uint32 SampleDiscrete(const float u, float& outPdf) const; 24 | 25 | // get PDF of given value 26 | float Pdf(uint32 valueIndex) const; 27 | 28 | private: 29 | float* mPDF; 30 | float* mCDF; // Cumulative distribution function 31 | uint32 mSize; 32 | }; 33 | 34 | } // namespace Math 35 | } // namespace NFE 36 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Geometry.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Engine/Common/Math/Geometry.hpp -------------------------------------------------------------------------------- /Src/Engine/Common/Math/HdrColor.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "HdrColor.hpp" 3 | #include "LdrColor.hpp" 4 | #include "Reflection/ReflectionClassDefine.hpp" 5 | 6 | NFE_DEFINE_CLASS(NFE::Math::HdrColorRGB) 7 | { 8 | NFE_CLASS_MEMBER(r); 9 | NFE_CLASS_MEMBER(g); 10 | NFE_CLASS_MEMBER(b); 11 | } 12 | NFE_END_DEFINE_CLASS() 13 | 14 | 15 | NFE_DEFINE_CLASS(NFE::Math::HdrColorRGBA) 16 | { 17 | NFE_CLASS_MEMBER(r); 18 | NFE_CLASS_MEMBER(g); 19 | NFE_CLASS_MEMBER(b); 20 | NFE_CLASS_MEMBER(a); 21 | } 22 | NFE_END_DEFINE_CLASS() 23 | 24 | 25 | namespace NFE { 26 | namespace Math { 27 | 28 | HdrColorRGB::HdrColorRGB(const LdrColorRGB& color) 29 | { 30 | r = Convert_sRGB_To_Linear(color.r / 255.0f); 31 | g = Convert_sRGB_To_Linear(color.g / 255.0f); 32 | b = Convert_sRGB_To_Linear(color.b / 255.0f); 33 | } 34 | 35 | } // namespace Math 36 | } // namespace NFE 37 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/HilbertCurve.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Math.hpp" 4 | 5 | namespace NFE { 6 | namespace Math { 7 | 8 | NFCOMMON_API void HilbertIndexToCoords(uint32 size, uint32 index, uint32& x, uint32& y); 9 | 10 | } // namespace Math 11 | } // namespace NFE 12 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/LdrColor.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "LdrColor.hpp" 3 | #include "../Reflection/ReflectionClassDefine.hpp" 4 | 5 | NFE_DEFINE_CLASS(NFE::Math::LdrColorRGB) 6 | { 7 | NFE_CLASS_MEMBER(r); 8 | NFE_CLASS_MEMBER(g); 9 | NFE_CLASS_MEMBER(b); 10 | } 11 | NFE_END_DEFINE_CLASS() 12 | 13 | NFE_DEFINE_CLASS(NFE::Math::LdrColorRGBA) 14 | { 15 | NFE_CLASS_MEMBER(r); 16 | NFE_CLASS_MEMBER(g); 17 | NFE_CLASS_MEMBER(b); 18 | NFE_CLASS_MEMBER(a); 19 | } 20 | NFE_END_DEFINE_CLASS() 21 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/RayGeometry.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Engine/Common/Math/RayGeometry.hpp -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Rectangle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Math.hpp" 4 | 5 | namespace NFE { 6 | namespace Math { 7 | 8 | // 2D rectangle 9 | template 10 | class Rectangle 11 | { 12 | public: 13 | NFE_FORCE_INLINE constexpr Rectangle() 14 | : minX(T(0)) 15 | , maxX(T(0)) 16 | , minY(T(0)) 17 | , maxY(T(0)) 18 | { } 19 | 20 | NFE_FORCE_INLINE constexpr Rectangle(T minX, T maxX, T minY, T maxY) 21 | : minX(minX) 22 | , maxX(maxX) 23 | , minY(minY) 24 | , maxY(maxY) 25 | { } 26 | 27 | NFE_FORCE_INLINE constexpr T Width() const 28 | { 29 | return maxX - minX; 30 | } 31 | 32 | NFE_FORCE_INLINE constexpr T Height() const 33 | { 34 | return maxY - minY; 35 | } 36 | 37 | T minX; 38 | T maxX; 39 | T minY; 40 | T maxY; 41 | }; 42 | 43 | using Rectf = Rectangle; 44 | using Recti = Rectangle; 45 | 46 | } // namespace Math 47 | } // namespace NFE 48 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/SimdTriangle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Triangle.hpp" 4 | 5 | 6 | namespace NFE { 7 | namespace Math { 8 | 9 | 10 | template 11 | class NFE_ALIGN(alignof(VecType)) SimdTriangle 12 | { 13 | public: 14 | 15 | NFE_ALIGNED_CLASS(alignof(VecType)) 16 | 17 | VecType v0; 18 | VecType edge1; 19 | VecType edge2; 20 | 21 | SimdTriangle() = default; 22 | SimdTriangle(const SimdTriangle&) = default; 23 | SimdTriangle& operator = (const SimdTriangle&) = default; 24 | 25 | // splat single triangle 26 | NFE_FORCE_INLINE explicit SimdTriangle(const Triangle& tri) 27 | : v0(tri.v0) 28 | , edge1(tri.v1 - tri.v0) 29 | , edge2(tri.v2 - tri.v0) 30 | { } 31 | }; 32 | 33 | 34 | } // namespace Math 35 | } // namespace NFE 36 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Sphere.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vec4f.hpp" 4 | 5 | 6 | namespace NFE { 7 | namespace Math { 8 | 9 | /** 10 | * Sphere 11 | */ 12 | class NFE_ALIGN(16) Sphere 13 | { 14 | public: 15 | NFE_ALIGNED_CLASS(16) 16 | 17 | Vec4f origin; //< Sphere center 18 | float r; //< Sphere radius 19 | 20 | NFE_FORCE_INLINE Sphere() 21 | : origin(), r() 22 | {} 23 | 24 | NFE_FORCE_INLINE Sphere(const Vec4f& origin, float r) 25 | : origin(origin), r(r) 26 | {} 27 | 28 | NFE_FORCE_INLINE float SupportVertex(const Vec4f& dir) const 29 | { 30 | Vec4f pos = origin + r * dir; 31 | return Vec4f::Dot3(dir, pos); 32 | } 33 | }; 34 | 35 | 36 | } // namespace Math 37 | } // namespace NFE 38 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Triangle.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Math.hpp" 4 | #include "Vec4f.hpp" 5 | #include "Vec3f.hpp" 6 | 7 | 8 | namespace NFE { 9 | namespace Math { 10 | 11 | 12 | class NFE_ALIGN(16) Triangle 13 | { 14 | public: 15 | Vec4f v0, v1, v2; 16 | 17 | NFE_FORCE_INLINE Triangle() = default; 18 | NFE_FORCE_INLINE Triangle(const Triangle&) = default; 19 | 20 | NFE_FORCE_INLINE Triangle(const Vec4f& v0, const Vec4f& v1, const Vec4f& v2) 21 | : v0(v0), v1(v1), v2(v2) 22 | {} 23 | }; 24 | 25 | class ProcessedTriangle 26 | { 27 | public: 28 | Vec3f v0; 29 | Vec3f edge1; 30 | Vec3f edge2; 31 | 32 | NFE_FORCE_INLINE ProcessedTriangle() = default; 33 | NFE_FORCE_INLINE ProcessedTriangle(const ProcessedTriangle&) = default; 34 | 35 | NFE_FORCE_INLINE ProcessedTriangle(const Vec4f& v0, const Vec4f& v1, const Vec4f& v2) 36 | { 37 | this->v0 = v0.ToVec3f(); 38 | edge1 = (v1 - v0).ToVec3f(); 39 | edge2 = (v2 - v0).ToVec3f(); 40 | } 41 | }; 42 | 43 | 44 | } // namespace Math 45 | } // namespace NFE 46 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Utils.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace NFE { 4 | namespace Math { 5 | 6 | 7 | // compute Fresnel reflection term for dielectric material 8 | NFCOMMON_API float FresnelDielectric(float NdV, float eta); 9 | 10 | // compute Fresnel reflection term for metalic material 11 | NFCOMMON_API float FresnelMetal(const float NdV, const float eta, const float k); 12 | 13 | 14 | } // namespace Math 15 | } // namespace NFE 16 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Vec4f.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "Vec4f.hpp" 3 | 4 | namespace NFE { 5 | namespace Math { 6 | 7 | const Vec4f Vec4f::Refract3(const Vec4f& i, const Vec4f& n, float eta) 8 | { 9 | float NdotV = Vec4f::Dot3(i, n); 10 | if (NdotV < 0.0f) 11 | { 12 | eta = 1.0f / eta; 13 | } 14 | 15 | const float k = 1.0f - eta * eta * (1.0f - NdotV * NdotV); 16 | if (k <= 0.0f) 17 | { 18 | return Vec4f::Zero(); 19 | } 20 | 21 | Vec4f transmitted = Vec4f::NegMulAndAdd(Vec4f(eta * NdotV + sqrtf(k)), n, i * eta); 22 | if (NdotV > 0.0f) 23 | { 24 | transmitted.z = -transmitted.z; 25 | } 26 | 27 | return transmitted.Normalized3(); 28 | } 29 | 30 | } // namespace Math 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Common/Math/Vec4fImpl.hpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Engine/Common/Math/Vec4fImpl.hpp -------------------------------------------------------------------------------- /Src/Engine/Common/Math/WindowFunctions.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Math.hpp" 4 | 5 | namespace NFE { 6 | namespace Math { 7 | namespace WindowFunctions { 8 | 9 | 10 | NFE_INLINE float MitchellNetravali(const float x, const float B, const float C) 11 | { 12 | const float ax = Abs(x); 13 | const float ax2 = ax * ax; 14 | const float ax3 = ax * ax2; 15 | 16 | if (ax < 1.0f) 17 | { 18 | return ((12.0f - 9.0f * B - 6.0f * C) * ax3 + (-18.0f + 12.0f * B + 6.0f * C) * ax2 + (6.0f - 2.0f * B)) / 6.0f; 19 | } 20 | else if (ax < 2.0f) 21 | { 22 | return ((-B - 6.0f * C) * ax3 + (6.0f * B + 30.0f * C) * ax2 + (-12.0f * B - 48.0f * C) * ax + (8.0f * B + 24.0f * C)) / 6.0f; 23 | } 24 | else 25 | { 26 | return 0.0f; 27 | } 28 | } 29 | 30 | NFE_FORCE_INLINE float CatmullRom(const float x) 31 | { 32 | return MitchellNetravali(x, 0.0f, 0.5f); 33 | } 34 | 35 | } // namespace WindowFunctions 36 | } // namespace Math 37 | } // namespace NFE 38 | -------------------------------------------------------------------------------- /Src/Engine/Common/PCH.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Source file used to trigger precompiled header compilation. 5 | */ 6 | 7 | #include "PCH.hpp" 8 | -------------------------------------------------------------------------------- /Src/Engine/Common/Reflection/Object.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Definition of reflection system's base object class. 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "Object.hpp" 8 | #include "ReflectionClassDefine.hpp" 9 | 10 | 11 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::IObject) 12 | NFE_END_DEFINE_CLASS() 13 | 14 | 15 | namespace NFE { 16 | 17 | IObject::~IObject() = default; 18 | 19 | bool IObject::OnPropertyChanged(const Common::StringView propertyName) 20 | { 21 | NFE_UNUSED(propertyName); 22 | return true; 23 | } 24 | 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Common/Reflection/Object.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Declaration of reflection system's base object class. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "ReflectionClassDeclare.hpp" 9 | 10 | 11 | namespace NFE { 12 | 13 | /** 14 | * Base object class for all polymorphic types registered in RTTI. 15 | */ 16 | class NFCOMMON_API IObject 17 | { 18 | NFE_DECLARE_POLYMORPHIC_CLASS(IObject) 19 | 20 | public: 21 | virtual ~IObject(); 22 | 23 | // Called when a property gets changed (e.g. by the editor) 24 | virtual bool OnPropertyChanged(const Common::StringView propertyName); 25 | }; 26 | 27 | using ObjectPtr = Common::SharedPtr; 28 | 29 | static_assert(sizeof(IObject) == sizeof(size_t), "IObject should not have any members"); 30 | 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Common/Reflection/ReflectionMember.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Definition of reflection system's Member class. 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "ReflectionMember.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace RTTI { 13 | 14 | 15 | Member::Member(const char* name, size_t offset, const Type* type) 16 | : mType(type) 17 | , mName(name) 18 | { 19 | // validate name 20 | { 21 | const size_t len = strlen(name); 22 | NFE_ASSERT(len > 0, "Member name cannot be empty"); 23 | 24 | NFE_ASSERT(isalpha(name[0]), "Invalid member name: '%s'. Must start with a letter", name); 25 | 26 | for (size_t i = 0; i < len; ++i) 27 | { 28 | NFE_ASSERT(isalnum(name[i]) || name[i] == '_', "Invalid member name: '%s'", name); 29 | } 30 | } 31 | 32 | NFE_ASSERT(offset < std::numeric_limits::max(), "Member '%s' offset is too big (%zu bytes)", name, offset); 33 | mOffset = static_cast(offset); 34 | } 35 | 36 | 37 | } // namespace RTTI 38 | } // namespace NFE 39 | -------------------------------------------------------------------------------- /Src/Engine/Common/Reflection/ReflectionMemberMetadataBuilder.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../nfCommon.hpp" 4 | 5 | namespace NFE { 6 | namespace RTTI { 7 | 8 | class NFCOMMON_API MemberMetadataBuilder 9 | { 10 | friend class Member; 11 | 12 | public: 13 | ~MemberMetadataBuilder(); 14 | 15 | // range specifier 16 | MemberMetadataBuilder& Min(double min); 17 | MemberMetadataBuilder& Max(double max); 18 | 19 | // make normalized integer (0...1 or -1...1 range) 20 | MemberMetadataBuilder& Norm(); 21 | 22 | MemberMetadataBuilder& LogScale(float power); 23 | 24 | // set custom debug name 25 | MemberMetadataBuilder& Name(const char* name); 26 | 27 | // force non-null pointer 28 | MemberMetadataBuilder& NonNull(); 29 | 30 | private: 31 | MemberMetadataBuilder(Member& member) : mMember(member) { } 32 | 33 | Member& mMember; 34 | }; 35 | 36 | 37 | } // namespace RTTI 38 | } // namespace NFE 39 | -------------------------------------------------------------------------------- /Src/Engine/Common/Reflection/ReflectionUnitTestHelper.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../nfCommon.hpp" 4 | #include "../Containers/DynArray.hpp" 5 | 6 | namespace NFE { 7 | namespace RTTI { 8 | 9 | /** 10 | * A utility class used only for unit test purposes. 11 | * Allows for marking types and member as missing which emulates the behavior of 12 | * deserializing objects that have code-data mismatch. 13 | */ 14 | struct NFCOMMON_API UnitTestHelper 15 | { 16 | struct MemberTypeRemap 17 | { 18 | const Member* member; 19 | const Type* newType; 20 | }; 21 | 22 | Common::DynArray mMissingTypes; 23 | Common::DynArray mMemberTypeRemappings; 24 | }; 25 | 26 | } // namespace RTTI 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Common/Reflection/Serializer.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../nfCommon.hpp" 4 | #include "Object.hpp" 5 | #include "../Containers/DynArray.hpp" 6 | #include "../Containers/SharedPtr.hpp" 7 | 8 | 9 | namespace NFE { 10 | namespace RTTI { 11 | 12 | // serialize single object into binary data stream 13 | NFCOMMON_API bool Serialize(const ObjectPtr& rootObject, Common::OutputStream& outputStream); 14 | 15 | // serialize multiple objects into binary data stream 16 | NFCOMMON_API bool Serialize(const Common::ArrayView rootObjects, Common::OutputStream& outputStream); 17 | 18 | // deserialize multiple objects from a binary data stream 19 | NFCOMMON_API bool Deserialize(Common::DynArray& outRootObjects, Common::InputStream& inputStream); 20 | 21 | } // namespace RTTI 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Common/System/AsyncQueueManager.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief AsyncQueueManager utility declarations. 5 | */ 6 | 7 | #pragma once 8 | 9 | #if defined(NFE_PLATFORM_WINDOWS) 10 | #include "Windows/AsyncQueueManager.hpp" 11 | #elif defined(NFE_PLATFORM_LINUX) 12 | #include "Linux/AsyncQueueManager.hpp" 13 | #else 14 | #error Invalid platform 15 | #endif -------------------------------------------------------------------------------- /Src/Engine/Common/System/Console.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Utilities for Console Interface 5 | */ 6 | 7 | #include "../nfCommon.hpp" 8 | 9 | #if defined(NFE_PLATFORM_WINDOWS) 10 | #include "Windows/Console.hpp" 11 | #elif defined(NFE_PLATFORM_LINUX) 12 | #include "Linux/Console.hpp" 13 | #else 14 | #error Invalid platform 15 | #endif 16 | -------------------------------------------------------------------------------- /Src/Engine/Common/System/Memory.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @author mkulagowski (mkkulagowski(at)gmail.com) 5 | * @brief Memory utilities declarations. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "../nfCommon.hpp" 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | /** 16 | * Check memory block access privileges. This function is mainly used to verify pointers 17 | * passed as input parameters to engine API to avoid access violations (segmentation faults). 18 | * @param ptr Pointer to the beginning of a block 19 | * @param size Block size 20 | * @return True if given memory block can be read. 21 | */ 22 | NFCOMMON_API bool MemoryCheck(const void* ptr, size_t size); 23 | 24 | /** 25 | * Template version of MemoryCheck(). Useful to verify pointer to a single object. 26 | */ 27 | template 28 | bool MemoryCheck(const T* ptr) 29 | { 30 | return MemoryCheck(ptr, sizeof(T)); 31 | } 32 | } // namespace Common 33 | } // namespace NFE 34 | -------------------------------------------------------------------------------- /Src/Engine/Common/System/SpinLockImpl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Spin Lock implementation. 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "SpinLock.hpp" 9 | 10 | namespace NFE { 11 | namespace Common { 12 | 13 | bool SpinLock::TryAcquireExclusive() 14 | { 15 | return !mLocked.test_and_set(std::memory_order_acquire); 16 | } 17 | 18 | void SpinLock::AcquireExclusive() 19 | { 20 | while (mLocked.test_and_set(std::memory_order_acquire)) 21 | { } 22 | } 23 | 24 | void SpinLock::ReleaseExclusive() 25 | { 26 | mLocked.clear(std::memory_order_release); 27 | } 28 | 29 | } // namespace Common 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Common/System/SystemInfoConstants.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkulagowski (mkkulagowski(at)gmail.com) 4 | * @brief Constants for SystemInfo class 5 | */ 6 | 7 | #pragma once 8 | 9 | const unsigned int EXTENDED_ID_MAX_VALUE = 0x80000000; 10 | const unsigned int CPU_BRAND_STRING_LENGTH = 0x40; 11 | const unsigned int CPU_BRAND_STRING_1 = 0x80000002; 12 | const unsigned int CPU_BRAND_STRING_2 = 0x80000003; 13 | const unsigned int CPU_BRAND_STRING_3 = 0x80000004; 14 | const unsigned int CPU_CACHE_LINE_SIZE = 0x80000006; 15 | 16 | const unsigned int CPUID_FEATURES_1_2 = 0x1; 17 | const unsigned int CPUID_FEATURES_3 = 0x7; 18 | const unsigned int CPUID_FEATURES_4_5 = 0x80000001; -------------------------------------------------------------------------------- /Src/Engine/Common/System/Windows/Common.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Common Windows helpers declarations. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../../Containers/String.hpp" 10 | 11 | #include 12 | 13 | namespace NFE { 14 | namespace Common { 15 | 16 | // TODO get rid of Utf16String 17 | using Utf16String = std::wstring; 18 | 19 | /** 20 | * Convert a string from UTF-8 to Windows' UTF-16. 21 | */ 22 | NFCOMMON_API bool UTF8ToUTF16(const StringView in, Utf16String& out); 23 | 24 | /** 25 | * Convert a string from Windows' UTF-16 to UTF-8. 26 | */ 27 | NFCOMMON_API bool UTF16ToUTF8(const Utf16String& in, String& out); 28 | 29 | /** 30 | * Translates GetLastError() code to a string. 31 | */ 32 | String GetLastErrorString(); 33 | 34 | } // namespace Common 35 | } // namespace NFE 36 | -------------------------------------------------------------------------------- /Src/Engine/Common/System/Windows/Console.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Implementation of Console-related function specific for Windows 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "Console.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | void PrintColored(const ConsoleColor& foreground, const char* format, ...) 15 | { 16 | HANDLE hstdout = GetStdHandle(STD_OUTPUT_HANDLE); 17 | CONSOLE_SCREEN_BUFFER_INFO console_info; 18 | GetConsoleScreenBufferInfo(hstdout, &console_info); 19 | SetConsoleTextAttribute(hstdout, static_cast(foreground)); 20 | 21 | va_list args; 22 | va_start(args, format); 23 | vfprintf(stderr, format, args); 24 | va_end(args); 25 | 26 | SetConsoleTextAttribute(hstdout, console_info.wAttributes); 27 | } 28 | 29 | } // namespace Common 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Common/System/Windows/Main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Entry point of DLL 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | 10 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 11 | { 12 | (void)hModule; 13 | (void)lpReserved; 14 | 15 | switch (ul_reason_for_call) 16 | { 17 | case DLL_PROCESS_ATTACH: 18 | case DLL_THREAD_ATTACH: 19 | case DLL_THREAD_DETACH: 20 | case DLL_PROCESS_DETACH: 21 | break; 22 | } 23 | 24 | return TRUE; 25 | } 26 | -------------------------------------------------------------------------------- /Src/Engine/Common/System/Windows/MutexImpl.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Mutex Windows implementation. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../Mutex.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | 16 | Mutex::Mutex() 17 | { 18 | ::InitializeSRWLock(&mLockObject); 19 | } 20 | 21 | Mutex::~Mutex() = default; 22 | 23 | bool Mutex::TryAcquireExclusive() 24 | { 25 | return 0 != ::TryAcquireSRWLockExclusive(&mLockObject); 26 | } 27 | 28 | void Mutex::AcquireExclusive() 29 | { 30 | ::AcquireSRWLockExclusive(&mLockObject); 31 | } 32 | 33 | void Mutex::ReleaseExclusive() 34 | { 35 | ::ReleaseSRWLockExclusive(&mLockObject); 36 | } 37 | 38 | 39 | } // namespace Common 40 | } // namespace NFE 41 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/CompressedInt.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @brief Variable-lenght coding of integer numbers 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "CompressedInt.hpp" 8 | 9 | 10 | namespace NFE { 11 | namespace Common { 12 | 13 | 14 | } // namespace Common 15 | } // namespace NFE 16 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Entropy.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../nfCommon.hpp" 4 | 5 | #ifdef WIN32 6 | #define WIN32_LEAN_AND_MEAN 7 | #define NOMINMAX 8 | #include 9 | #include 10 | #endif // WIN32 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | // True random number generator (slow) 16 | class NFCOMMON_API Entropy 17 | { 18 | NFE_MAKE_NONCOPYABLE(Entropy) 19 | NFE_MAKE_NONMOVEABLE(Entropy) 20 | 21 | public: 22 | Entropy(); 23 | ~Entropy(); 24 | 25 | uint32 GetInt(); 26 | 27 | private: 28 | #if defined(WIN32) 29 | HCRYPTPROV mCryptProv; 30 | #elif defined(__LINUX__) | defined(__linux__) 31 | int mRandomSourceFD; 32 | #endif // defined(WIN32) 33 | }; 34 | 35 | } // namespace Common 36 | } // namespace NFE 37 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/BufferInputStream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "InputStream.hpp" 4 | 5 | 6 | namespace NFE { 7 | namespace Common { 8 | 9 | /** 10 | * Implementation of InputStream - buffer (file in the memory) reader. 11 | */ 12 | class NFCOMMON_API BufferInputStream : public InputStream 13 | { 14 | NFE_MAKE_NONCOPYABLE(BufferInputStream) 15 | NFE_MAKE_NONMOVEABLE(BufferInputStream) 16 | 17 | private: 18 | const void* mData; 19 | size_t mSize; 20 | size_t mPos; 21 | 22 | public: 23 | BufferInputStream(const void* data, size_t dataSize); 24 | BufferInputStream(const Buffer& buffer); 25 | 26 | uint64 GetSize() override; 27 | bool Seek(int64 offset, SeekMode mode) override; 28 | size_t Read(void* buffer, size_t num) override; 29 | }; 30 | 31 | } // namespace Common 32 | } // namespace NFE 33 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/BufferOutputStream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OutputStream.hpp" 4 | 5 | 6 | namespace NFE { 7 | namespace Common { 8 | 9 | /** 10 | * Implementation of OutputStream - buffer writer. 11 | */ 12 | class NFCOMMON_API BufferOutputStream : public OutputStream 13 | { 14 | NFE_MAKE_NONCOPYABLE(BufferOutputStream) 15 | NFE_MAKE_NONMOVEABLE(BufferOutputStream) 16 | 17 | public: 18 | BufferOutputStream(Buffer& targetBuffer); 19 | ~BufferOutputStream(); 20 | 21 | size_t GetSize() const; 22 | const void* GetData() const; 23 | 24 | virtual size_t Write(const void* buffer, size_t num) override; 25 | virtual bool Seek(int64 offset, SeekMode mode) override; 26 | virtual uint64 GetPosition() const override; 27 | 28 | private: 29 | Buffer& mBuffer; 30 | size_t mCursor; 31 | }; 32 | 33 | } // namespace Common 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/FileInputStream.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "FileInputStream.hpp" 3 | 4 | 5 | namespace NFE { 6 | namespace Common { 7 | 8 | FileInputStream::FileInputStream(const StringView& path) 9 | { 10 | mFile.Open(path, AccessMode::Read, false); 11 | } 12 | 13 | FileInputStream::~FileInputStream() 14 | { 15 | mFile.Close(); 16 | } 17 | 18 | uint64 FileInputStream::GetSize() 19 | { 20 | return mFile.GetSize(); 21 | } 22 | 23 | bool FileInputStream::Seek(int64 offset, SeekMode mode) 24 | { 25 | return mFile.Seek(offset, mode); 26 | } 27 | 28 | size_t FileInputStream::Read(void* buffer, size_t num) 29 | { 30 | return mFile.Read(buffer, num); 31 | } 32 | 33 | } // namespace Common 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/FileInputStream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "InputStream.hpp" 4 | #include "../../FileSystem/File.hpp" 5 | 6 | 7 | namespace NFE { 8 | namespace Common { 9 | 10 | /** 11 | * Implementation of InputStream - file reader. 12 | */ 13 | class NFCOMMON_API FileInputStream : public InputStream 14 | { 15 | NFE_MAKE_NONCOPYABLE(FileInputStream) 16 | NFE_MAKE_NONMOVEABLE(FileInputStream) 17 | 18 | private: 19 | File mFile; 20 | 21 | public: 22 | FileInputStream(const StringView& path); 23 | ~FileInputStream(); 24 | 25 | uint64 GetSize() override; 26 | bool Seek(int64 offset, SeekMode mode) override; 27 | size_t Read(void* buffer, size_t num) override; 28 | }; 29 | 30 | } // namespace Common 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/FileOutputStream.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "FileOutputStream.hpp" 3 | 4 | 5 | namespace NFE { 6 | namespace Common { 7 | 8 | FileOutputStream::FileOutputStream(const StringView& fileName) 9 | { 10 | mFile.Open(fileName, AccessMode::Write, true); 11 | } 12 | 13 | size_t FileOutputStream::Write(const void* buffer, size_t num) 14 | { 15 | return mFile.Write(buffer, num); 16 | } 17 | 18 | uint64 FileOutputStream::GetPosition() const 19 | { 20 | return mFile.GetPos(); 21 | } 22 | 23 | bool FileOutputStream::Seek(int64 offset, SeekMode mode) 24 | { 25 | return mFile.Seek(offset, mode); 26 | } 27 | 28 | } // namespace Common 29 | } // namespace NFE 30 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/FileOutputStream.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "OutputStream.hpp" 4 | #include "../../FileSystem/File.hpp" 5 | 6 | 7 | namespace NFE { 8 | namespace Common { 9 | 10 | /** 11 | * Implementation of OutputStream - file writer. 12 | */ 13 | class NFCOMMON_API FileOutputStream : public OutputStream 14 | { 15 | NFE_MAKE_NONCOPYABLE(FileOutputStream) 16 | NFE_MAKE_NONMOVEABLE(FileOutputStream) 17 | 18 | private: 19 | File mFile; 20 | 21 | public: 22 | FileOutputStream(const StringView& fileName); 23 | 24 | virtual size_t Write(const void* buffer, size_t num) override; 25 | virtual bool Seek(int64 offset, SeekMode mode) override; 26 | virtual uint64 GetPosition() const override; 27 | }; 28 | 29 | } // namespace Common 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/InputStream.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @author mkkulagowski (mkulagowski(at)gmail.com) 5 | * @brief Definition of InputStream class for reading files, buffers, etc. 6 | */ 7 | 8 | #include "PCH.hpp" 9 | #include "InputStream.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | InputStream::InputStream() = default; 16 | InputStream::~InputStream() = default; 17 | 18 | } // namespace Common 19 | } // namespace NFE 20 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/OutputStream.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @author mkkulagowski (mkulagowski(at)gmail.com) 5 | * @brief Definition of OutputStream class for writing files, buffers, etc. 6 | */ 7 | 8 | #include "PCH.hpp" 9 | #include "OutputStream.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Common { 14 | 15 | OutputStream::OutputStream() = default; 16 | OutputStream::~OutputStream() = default; 17 | 18 | } // namespace Common 19 | } // namespace NFE 20 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Stream/StreamCommon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../nfCommon.hpp" 4 | 5 | namespace NFE { 6 | namespace Common { 7 | 8 | /** 9 | * File/stream seeking mode. 10 | */ 11 | enum class SeekMode : uint8 12 | { 13 | Begin, ///< relative to the stream beginning 14 | Current, ///< relative to current cursor position 15 | End, ///< relative to the stream end 16 | }; 17 | 18 | } // namespace Common 19 | } // namespace NFE 20 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/ThreadPoolTask.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Thread pool task class declarations. 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "ThreadPoolTask.hpp" 9 | 10 | namespace NFE { 11 | namespace Common { 12 | 13 | Task::Task() 14 | { 15 | Reset(); 16 | } 17 | 18 | void Task::Reset() 19 | { 20 | mState = State::Invalid; 21 | mDependencyState = 0; 22 | mTasksLeft = 0; 23 | mParent = InvalidTaskID; 24 | mDependency = InvalidTaskID; 25 | mHead = InvalidTaskID; 26 | mTail = InvalidTaskID; 27 | mSibling = InvalidTaskID; 28 | mWaitable = nullptr; 29 | mDebugName = nullptr; 30 | } 31 | 32 | Task::Task(Task&& other) 33 | { 34 | mState = other.mState.load(); 35 | mTasksLeft = other.mTasksLeft.load(); 36 | mParent = other.mParent; 37 | mDependency = other.mDependency; 38 | mHead = other.mHead; 39 | mTail = other.mTail; 40 | mSibling = other.mSibling; 41 | mWaitable = other.mWaitable; 42 | } 43 | 44 | } // namespace Common 45 | } // namespace NFE 46 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Waitable.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "Waitable.hpp" 3 | #include "../System/Thread.hpp" 4 | 5 | namespace NFE { 6 | namespace Common { 7 | 8 | Waitable::Waitable() 9 | : mFinished(false) 10 | { } 11 | 12 | Waitable::~Waitable() 13 | { 14 | Wait(); 15 | } 16 | 17 | void Waitable::Wait() 18 | { 19 | NFE_ASSERT(Thread::IsMainThread(), "Nothing should wait on non-main thread as it may cause deadlock"); 20 | 21 | if (!mFinished) 22 | { 23 | ScopedExclusiveLock lock(mMutex); 24 | while (!mFinished) 25 | { 26 | mConditionVariable.Wait(lock); 27 | } 28 | } 29 | } 30 | 31 | void Waitable::OnFinished() 32 | { 33 | const bool oldState = mFinished.exchange(true); 34 | NFE_ASSERT(!oldState, "OnFinished can be called only once on waitable object"); 35 | 36 | ScopedExclusiveLock lock(mMutex); 37 | mConditionVariable.SignalAll(); 38 | 39 | } 40 | 41 | } // namespace Common 42 | } // namespace NFE 43 | -------------------------------------------------------------------------------- /Src/Engine/Common/Utils/Waitable.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../nfCommon.hpp" 4 | #include "../System/Mutex.hpp" 5 | #include "../System/ConditionVariable.hpp" 6 | 7 | #include 8 | 9 | namespace NFE { 10 | namespace Common { 11 | 12 | /** 13 | * Helper class allowing for waiting for an event. 14 | */ 15 | class NFCOMMON_API Waitable final 16 | { 17 | NFE_MAKE_NONCOPYABLE(Waitable) 18 | NFE_MAKE_NONMOVEABLE(Waitable) 19 | 20 | public: 21 | Waitable(); 22 | ~Waitable(); 23 | 24 | // Check if the task has been finished. 25 | NFE_INLINE bool IsFinished() { return mFinished.load(); } 26 | 27 | // Wait for a task to finish. 28 | // NOTE This can be called only on the main thread! 29 | void Wait(); 30 | 31 | void OnFinished(); 32 | 33 | private: 34 | 35 | Mutex mMutex; 36 | ConditionVariable mConditionVariable; 37 | std::atomic mFinished; 38 | }; 39 | 40 | 41 | 42 | } // namespace Common 43 | } // namespace NFE 44 | -------------------------------------------------------------------------------- /Src/Engine/Common/nfCommon.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | */ 4 | 5 | #include "PCH.hpp" 6 | #include "nfCommon.hpp" 7 | #include "Reflection/ReflectionTypeRegistry.hpp" 8 | #include "Logger/LoggerImpl.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace Common { 13 | 14 | 15 | bool InitSubsystems() 16 | { 17 | // setup handling access violation, etc. 18 | InitFatalErrorHandlers(); 19 | 20 | if (!Logger::GetInstance()->Init()) 21 | return false; 22 | 23 | return true; 24 | } 25 | 26 | void ShutdownSubsystems() 27 | { 28 | // cleanup registered RTTI types 29 | RTTI::TypeRegistry::GetInstance().Cleanup(); 30 | 31 | // shutdown logger 32 | Logger::GetInstance()->Shutdown(); 33 | 34 | // shutdown default memory allocator 35 | // DefaultAllocator::GetInstance().Shutdown(); 36 | } 37 | 38 | 39 | } // namespace Common 40 | } // namespace NFE 41 | -------------------------------------------------------------------------------- /Src/Engine/Core/Core.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Basic types declarations. This file will be included by most of the engine's headers. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../Common/nfCommon.hpp" 10 | #include "ForwardDeclarations.hpp" 11 | 12 | 13 | // DLL import / export macro 14 | #ifdef NFE_PLATFORM_WINDOWS 15 | #ifdef NF_CORE_EXPORTS 16 | #define CORE_API __declspec(dllexport) 17 | #else 18 | #define CORE_API __declspec(dllimport) 19 | #endif 20 | #elif defined(NFE_PLATFORM_LINUX) 21 | #define CORE_API __attribute__((visibility("default"))) 22 | #else 23 | #error "Target platform not supported" 24 | #endif -------------------------------------------------------------------------------- /Src/Engine/Core/Input/InputEvent.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Input events definitions. 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "InputEvent.hpp" -------------------------------------------------------------------------------- /Src/Engine/Core/Input/InputEvent.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Input events declarations. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../Core.hpp" 10 | #include "../../Common/Containers/String.hpp" 11 | 12 | 13 | namespace NFE { 14 | namespace Input { 15 | 16 | /** 17 | * Structure representing a mapped input event. 18 | */ 19 | struct EventData 20 | { 21 | enum class Type 22 | { 23 | Unknown, 24 | KeyPress, 25 | KeyRelease, 26 | Axis 27 | }; 28 | 29 | // event type 30 | Type type; 31 | 32 | // event name (mapping name) 33 | Common::String name; 34 | 35 | // used only for Type::Axis events 36 | float axisValue; 37 | 38 | 39 | EventData() 40 | : type(Type::Unknown) 41 | , axisValue(0.0f) 42 | { } 43 | 44 | EventData(Type type, Common::StringView name, float axisValue = 0.0f) 45 | : type(type) 46 | , name(name) 47 | , axisValue(axisValue) 48 | { } 49 | }; 50 | 51 | } // namespace Input 52 | } // namespace NFE -------------------------------------------------------------------------------- /Src/Engine/Core/Main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief DLL entry point (Windows only). 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | 10 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 11 | { 12 | switch (ul_reason_for_call) 13 | { 14 | case DLL_PROCESS_ATTACH: 15 | case DLL_PROCESS_DETACH: 16 | case DLL_THREAD_ATTACH: 17 | case DLL_THREAD_DETACH: 18 | break; 19 | } 20 | return TRUE; 21 | } 22 | -------------------------------------------------------------------------------- /Src/Engine/Core/PCH.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Source file used to trigger precompiled header compilation. 5 | */ 6 | 7 | #include "PCH.hpp" 8 | -------------------------------------------------------------------------------- /Src/Engine/Core/Resources_old/SoundSample.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Sound sample resource declarations. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../Core.hpp" 10 | #include "Resource.hpp" 11 | 12 | namespace NFE { 13 | namespace Resource { 14 | 15 | /** 16 | * Sound sample information. 17 | */ 18 | struct SoundInfo 19 | { 20 | uint32 numChannels; 21 | 22 | // 1 - 8bit signed int, 2 - 16bit signed int, 4 - 32bit float 23 | uint32 bytesPerSample; 24 | 25 | // samples per second 26 | uint32 sampleRate; 27 | 28 | uint64 numSamples; 29 | 30 | SoundInfo(); 31 | }; 32 | 33 | /** 34 | * This class describes sound sample resource. 35 | */ 36 | class CORE_API SoundSample : public ResourceBase 37 | { 38 | SoundInfo mSoundInfo; 39 | 40 | // if sound type = sample, data is stored here 41 | void* mSampleData; 42 | 43 | bool OnLoad(); 44 | void OnUnload(); 45 | 46 | public: 47 | SoundSample(); 48 | ~SoundSample(); 49 | 50 | void Release(); 51 | }; 52 | 53 | } // namespace Resource 54 | } // namespace NFE 55 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/EntityController.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "EntityController.hpp" 3 | 4 | 5 | namespace NFE { 6 | namespace Scene { 7 | 8 | IEntityController::IEntityController() 9 | : mEntity(nullptr) 10 | {} 11 | 12 | IEntityController::~IEntityController() 13 | { 14 | NFE_ASSERT(!mEntity, "Controller is still attached to an entity"); 15 | } 16 | 17 | void IEntityController::Attach(Entity* entity) 18 | { 19 | NFE_ASSERT(!mEntity, "The controller is already attached to an entity"); 20 | NFE_ASSERT(entity, "Invalid entity"); 21 | mEntity = entity; 22 | } 23 | 24 | void IEntityController::Detach() 25 | { 26 | NFE_ASSERT(mEntity, "The controller is not attached to an entity"); 27 | mEntity = nullptr; 28 | } 29 | 30 | } // namespace Scene 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/EntityController.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of IEntityController. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../Core.hpp" 10 | #include "Events/Event.hpp" 11 | 12 | 13 | namespace NFE { 14 | namespace Scene { 15 | 16 | 17 | /** 18 | * Entity controller. 19 | * 20 | * The only class allowed to modify entity. 21 | */ 22 | class CORE_API IEntityController 23 | { 24 | NFE_MAKE_NONCOPYABLE(IEntityController) 25 | 26 | public: 27 | IEntityController(); 28 | virtual ~IEntityController(); 29 | 30 | void Attach(Entity* entity); 31 | void Detach(); 32 | 33 | // get entity the controller is attached to 34 | Entity* GetEntity() const { return mEntity; } 35 | 36 | /** 37 | * Called by the engine when the entity receives an event. 38 | * @note This is the only allowed place, when entity modification is performed. 39 | */ 40 | virtual void OnEvent(const Event& event) = 0; 41 | 42 | private: 43 | Entity* mEntity; 44 | }; 45 | 46 | 47 | } // namespace Scene 48 | } // namespace NFE 49 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Events/Event.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "Event.hpp" 8 | #include "Engine/Common/Reflection/ReflectionClassDefine.hpp" 9 | 10 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::Scene::Event) 11 | NFE_END_DEFINE_CLASS() 12 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Events/Event.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "../../Core.hpp" 9 | 10 | #include "../../../Common/Reflection/ReflectionClassDeclare.hpp" 11 | #include "../../../Common/Reflection/Object.hpp" 12 | #include "../../../Common/Containers/SharedPtr.hpp" 13 | 14 | namespace NFE { 15 | namespace Scene { 16 | 17 | /** 18 | * Base class for all event types. 19 | */ 20 | class CORE_API Event : public IObject 21 | { 22 | NFE_DECLARE_POLYMORPHIC_CLASS(Event) 23 | 24 | public: 25 | virtual ~Event() { } 26 | }; 27 | 28 | using EventPtr = Common::SharedPtr; 29 | 30 | 31 | } // namespace Scene 32 | } // namespace NFE 33 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Events/Event_Input.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "Event_Input.hpp" 8 | #include "Engine/Common/Reflection/ReflectionClassDefine.hpp" 9 | 10 | 11 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::Scene::Event_Input) 12 | NFE_CLASS_PARENT(NFE::Scene::Event) 13 | NFE_END_DEFINE_CLASS() 14 | 15 | 16 | namespace NFE { 17 | namespace Scene { 18 | 19 | Event_Input::Event_Input(const Input::EventData& data) 20 | : mData(data) 21 | { 22 | } 23 | 24 | } // namespace Scene 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Events/Event_Input.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Event.hpp" 9 | #include "../../Input/InputEvent.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Scene { 14 | 15 | /** 16 | * Input event - triggered on an input action (key press, mouse move, etc.) 17 | */ 18 | class CORE_API Event_Input : public Event 19 | { 20 | NFE_DECLARE_POLYMORPHIC_CLASS(Event_Input) 21 | 22 | public: 23 | explicit Event_Input(const Input::EventData& data); 24 | const Input::EventData& GetData() const { return mData; } 25 | 26 | private: 27 | Input::EventData mData; 28 | }; 29 | 30 | } // namespace Scene 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Events/Event_Tick.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "Event_Tick.hpp" 8 | #include "Engine/Common/Reflection/ReflectionClassDefine.hpp" 9 | 10 | 11 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::Scene::Event_Tick) 12 | NFE_CLASS_PARENT(NFE::Scene::Event) 13 | NFE_END_DEFINE_CLASS() 14 | 15 | 16 | namespace NFE { 17 | namespace Scene { 18 | 19 | Event_Tick::Event_Tick(float timeDelta, uint64 frameNumber) 20 | : mTimeDelta(timeDelta) 21 | , mFrameNumber(frameNumber) 22 | { 23 | } 24 | 25 | } // namespace Scene 26 | } // namespace NFE 27 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Events/Event_Tick.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #pragma once 7 | 8 | #include "Event.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace Scene { 13 | 14 | /** 15 | * Tick event - send once every frame. 16 | */ 17 | class CORE_API Event_Tick : public Event 18 | { 19 | NFE_DECLARE_POLYMORPHIC_CLASS(Event_Tick) 20 | 21 | public: 22 | explicit Event_Tick(float timeDelta, uint64 frameNumber); 23 | float GetTimeDelta() const { return mTimeDelta; } 24 | uint64 GetFrameNumber() const { return mFrameNumber; } 25 | 26 | private: 27 | float mTimeDelta; 28 | uint64 mFrameNumber; 29 | }; 30 | 31 | 32 | } // namespace Scene 33 | } // namespace NFE 34 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Events/Event_Trigger.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "Event_Trigger.hpp" 8 | #include "Engine/Common/Reflection/ReflectionClassDefine.hpp" 9 | 10 | 11 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::Scene::Event_Trigger) 12 | NFE_CLASS_PARENT(NFE::Scene::Event) 13 | NFE_END_DEFINE_CLASS() 14 | 15 | 16 | namespace NFE { 17 | namespace Scene { 18 | 19 | Event_Trigger::Event_Trigger(Entity& sourceEntity, Entity& targetEntity, Type type) 20 | : mSourceEntity(sourceEntity) 21 | , mTargetEntity(targetEntity) 22 | , mType(type) 23 | { } 24 | 25 | 26 | } // namespace Scene 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Systems/RendererSystem.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Definitions of renderer system. 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "RendererSystem.hpp" 9 | #include "Engine/Common/Reflection/ReflectionClassDefine.hpp" 10 | 11 | 12 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::Scene::RendererSystem) 13 | NFE_CLASS_PARENT(NFE::Scene::ISystem) 14 | NFE_END_DEFINE_CLASS() 15 | 16 | 17 | namespace NFE { 18 | namespace Scene { 19 | 20 | using namespace Common; 21 | using namespace Math; 22 | 23 | RendererSystem::RendererSystem(Scene& scene) 24 | : ISystem(scene) 25 | { 26 | //mRenderScene = MakeUniquePtr(); 27 | } 28 | 29 | void RendererSystem::Update(const SystemUpdateContext& context) 30 | { 31 | NFE_UNUSED(context); 32 | //if (!mRenderScene) 33 | // return; 34 | 35 | //mRenderScene->Update(context.timeDelta); 36 | } 37 | 38 | } // namespace Scene 39 | } // namespace NFE 40 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Systems/RendererSystem.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declarations of renderer system. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../../Core.hpp" 10 | #include "System.hpp" 11 | 12 | #include "../../../Common/Utils/ThreadPool.hpp" 13 | #include "../../../Common/Memory/Aligned.hpp" 14 | 15 | 16 | namespace NFE { 17 | namespace Scene { 18 | 19 | 20 | /** 21 | * Scene system - high level renderer (interface). 22 | */ 23 | class RendererSystem : public ISystem 24 | { 25 | NFE_DECLARE_POLYMORPHIC_CLASS(RendererSystem) 26 | NFE_MAKE_NONCOPYABLE(RendererSystem) 27 | 28 | public: 29 | static const int ID = 3; 30 | 31 | explicit RendererSystem(Scene& scene); 32 | 33 | /** 34 | * Get rendering scene. 35 | */ 36 | //Renderer::RenderScene* GetRenderScene() const { return mRenderScene.Get(); } 37 | 38 | void Update(const SystemUpdateContext& context) override; 39 | 40 | private: 41 | //Common::UniquePtr mRenderScene; 42 | }; 43 | 44 | } // namespace Scene 45 | } // namespace NFE 46 | -------------------------------------------------------------------------------- /Src/Engine/Core/Scene/Systems/System.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "System.hpp" 8 | #include "Engine/Common/Reflection/ReflectionClassDefine.hpp" 9 | 10 | 11 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::Scene::ISystem) 12 | NFE_END_DEFINE_CLASS() 13 | 14 | namespace NFE { 15 | namespace Scene { 16 | 17 | ISystem::ISystem(Scene& scene) 18 | : mScene(scene) 19 | { } 20 | 21 | } // namespace Scene 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Core/ShaderCommon.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Common/Math/Vec4f.hpp" 4 | #include "Engine/Common/Math/Matrix4.hpp" 5 | 6 | 7 | namespace NFE { 8 | 9 | // translate HLSL types to C++ types 10 | typedef Math::Vec4f float4; 11 | typedef Math::Vec3f float3; 12 | typedef Math::Vec2f float2; 13 | typedef Math::Matrix4 float4x4; 14 | 15 | struct Int4 16 | { 17 | int i[4]; 18 | }; 19 | 20 | struct Int3 21 | { 22 | int i[3]; 23 | }; 24 | 25 | struct Int2 26 | { 27 | int i[2]; 28 | }; 29 | 30 | struct Uint4 31 | { 32 | unsigned int i[4]; 33 | }; 34 | 35 | struct Uint3 36 | { 37 | unsigned int i[3]; 38 | }; 39 | 40 | struct Uint2 41 | { 42 | unsigned int i[2]; 43 | }; 44 | 45 | typedef Int4 int4; 46 | typedef Int3 int3; 47 | typedef Int2 int2; 48 | typedef Uint4 uint4; 49 | typedef Uint3 uint3; 50 | typedef Uint2 uint2; 51 | 52 | } // namespace NFE -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Color/BlackBodyColor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Color.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | class NFE_RAYTRACER_API BlackBodyColor : public IColor 9 | { 10 | NFE_DECLARE_POLYMORPHIC_CLASS(BlackBodyColor) 11 | 12 | public: 13 | 14 | BlackBodyColor(); 15 | 16 | virtual const RayColor Resolve(const Wavelength& wavelength) const override; 17 | virtual bool IsValid() const override; 18 | 19 | private: 20 | float mTemperature; // in Kelvins 21 | float mIntensity; 22 | bool mNormalize; 23 | }; 24 | 25 | } // namespace RT 26 | } // namespace NFE 27 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Color/Color.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "Color.h" 3 | #include "../../Common/Reflection/ReflectionClassDefine.hpp" 4 | 5 | 6 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::RT::IColor) 7 | NFE_END_DEFINE_CLASS() 8 | 9 | 10 | namespace NFE { 11 | namespace RT { 12 | 13 | using namespace Math; 14 | 15 | } // namespace RT 16 | } // namespace NFE 17 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Color/Color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "RayColor.h" 4 | #include "../../Common/Reflection/ReflectionClassDeclare.hpp" 5 | #include "../../Common/Containers/SharedPtr.hpp" 6 | 7 | namespace NFE { 8 | namespace RT { 9 | 10 | // Represents spectral power distribution (SPD) 11 | class NFE_RAYTRACER_API IColor : public IObject 12 | { 13 | NFE_DECLARE_POLYMORPHIC_CLASS(IColor) 14 | 15 | public: 16 | virtual ~IColor() = default; 17 | 18 | // resolve to ray color, given ray's wavelength 19 | virtual const RayColor Resolve(const Wavelength& wavelength) const = 0; 20 | 21 | // check if color values are valid 22 | virtual bool IsValid() const = 0; 23 | }; 24 | 25 | using ColorPtr = Common::SharedPtr; 26 | 27 | 28 | } // namespace RT 29 | } // namespace NFE 30 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Color/ColorRGB.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "ColorRGB.h" 3 | #include "../../Common/Reflection/ReflectionClassDefine.hpp" 4 | 5 | 6 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::RT::ColorRGB) 7 | { 8 | NFE_CLASS_PARENT(NFE::RT::IColor); 9 | NFE_CLASS_MEMBER(mColor); 10 | } 11 | NFE_END_DEFINE_CLASS() 12 | 13 | 14 | namespace NFE { 15 | namespace RT { 16 | 17 | using namespace Math; 18 | 19 | bool ColorRGB::IsValid() const 20 | { 21 | return mColor.IsValid(); 22 | } 23 | 24 | const RayColor ColorRGB::Resolve(const Wavelength& wavelength) const 25 | { 26 | return RayColor::ResolveRGB(wavelength, mColor); 27 | } 28 | 29 | } // namespace RT 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Color/ColorRGB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Color.h" 4 | #include "../../Common/Math/LdrColor.hpp" 5 | #include "../../Common/Math/HdrColor.hpp" 6 | 7 | namespace NFE { 8 | namespace RT { 9 | 10 | // basic RGB color implementation 11 | class NFE_RAYTRACER_API ColorRGB : public IColor 12 | { 13 | NFE_DECLARE_POLYMORPHIC_CLASS(ColorRGB) 14 | 15 | public: 16 | NFE_FORCE_INLINE ColorRGB() 17 | { 18 | mColor = Math::HdrColorRGB(1.0f, 1.0f, 1.0f); 19 | } 20 | 21 | NFE_FORCE_INLINE ColorRGB(const Math::LdrColorRGB& color) : mColor(color) { } 22 | NFE_FORCE_INLINE ColorRGB(const Math::HdrColorRGB& color) : mColor(color) { } 23 | 24 | virtual const RayColor Resolve(const Wavelength& wavelength) const override; 25 | virtual bool IsValid() const override; 26 | 27 | private: 28 | Math::HdrColorRGB mColor; 29 | 30 | // TODO different color primaries 31 | }; 32 | 33 | } // namespace RT 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Color/MonochromaticColor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Color.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // single-wavelength color 9 | class NFE_RAYTRACER_API MonochromaticColor : public IColor 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(MonochromaticColor) 12 | 13 | public: 14 | MonochromaticColor(); 15 | 16 | virtual const RayColor Resolve(const Wavelength& wavelength) const override; 17 | virtual bool IsValid() const override; 18 | 19 | private: 20 | float mWavelength; 21 | float mVariance; 22 | float mIntensity; 23 | }; 24 | 25 | } // namespace RT 26 | } // namespace NFE 27 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Config.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifndef NFE_CONFIGURATION_FINAL 4 | 5 | // enables runtime counting of ray-triangle and ray-box intersection tests 6 | #define NFE_ENABLE_INTERSECTION_COUNTERS 7 | 8 | // enables code for collecting path tracing debug data 9 | #define NFE_ENABLE_PATH_DEBUGGING 10 | 11 | #endif // NFE_CONFIGURATION_FINAL 12 | 13 | // enables spectral rendering via Monte Carlo wavelength sampling 14 | // NOTE: this slows down everything significantly 15 | // #define NFE_ENABLE_SPECTRAL_RENDERING 16 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/ForwardDeclarations.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | class Bitmap; 9 | 10 | struct HitPoint; 11 | struct IntersectionData; 12 | struct SingleTraversalContext; 13 | struct PacketTraversalContext; 14 | struct RenderingContext; 15 | struct RenderingParams; 16 | struct ShadingData; 17 | struct PathDebugData; 18 | class Film; 19 | struct RayPacket; 20 | 21 | class Camera; 22 | class Scene; 23 | 24 | class IShape; 25 | class ILight; 26 | class IMedium; 27 | 28 | class ISceneObject; 29 | class ITraceableSceneObject; 30 | class ShapeSceneObject; 31 | class LightSceneObject; 32 | class DecalSceneObject; 33 | 34 | class IRenderer; 35 | 36 | class IRendererContext; 37 | 38 | class BSDF; 39 | class Material; 40 | 41 | class ITexture; 42 | 43 | class ISampler; 44 | struct Wavelength; 45 | struct RayColor; 46 | class IColor; 47 | 48 | } // namespace RT 49 | } // namespace NFE 50 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/BSDF.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "BSDF.h" 3 | #include "../Common/Reflection/ReflectionClassDefine.hpp" 4 | 5 | 6 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::RT::BSDF) 7 | NFE_END_DEFINE_CLASS() 8 | 9 | namespace NFE { 10 | namespace RT { 11 | 12 | using namespace Math; 13 | 14 | } // namespace RT 15 | } // namespace NFE 16 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/DielectricBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // Smooth transparent dielectic BSDF (e.g. polished glass or surface of water). 9 | class DielectricBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(DielectricBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "dielectric"; } 15 | virtual bool IsDelta() const override { return true; } 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | }; 20 | 21 | } // namespace RT 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/DiffuseBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // simplest Lambertian diffuse 9 | class DiffuseBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(DiffuseBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "diffuse"; } 15 | virtual bool IsDelta() const override { return false; } 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | }; 20 | 21 | } // namespace RT 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/MetalBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // Smooth metal (conductor) BRDF. 9 | class MetalBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(MetalBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "metal"; } 15 | virtual bool IsDelta() const override { return true; } 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | }; 20 | 21 | } // namespace RT 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/NullBSDF.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "NullBSDF.h" 3 | #include "../Common/Reflection/ReflectionClassDefine.hpp" 4 | 5 | NFE_DEFINE_POLYMORPHIC_CLASS(NFE::RT::NullBSDF) 6 | NFE_CLASS_PARENT(NFE::RT::BSDF); 7 | NFE_END_DEFINE_CLASS() 8 | 9 | namespace NFE { 10 | namespace RT { 11 | 12 | bool NullBSDF::Sample(SamplingContext& ctx) const 13 | { 14 | NFE_UNUSED(ctx); 15 | 16 | return false; 17 | } 18 | 19 | const RayColor NullBSDF::Evaluate(const EvaluationContext& ctx, float* outDirectPdfW, float* outReversePdfW) const 20 | { 21 | NFE_UNUSED(ctx); 22 | NFE_UNUSED(outDirectPdfW); 23 | NFE_UNUSED(outReversePdfW); 24 | 25 | return RayColor::Zero(); 26 | } 27 | 28 | float NullBSDF::Pdf(const EvaluationContext& ctx, PdfDirection dir) const 29 | { 30 | NFE_UNUSED(ctx); 31 | NFE_UNUSED(dir); 32 | 33 | return 0.0f; 34 | } 35 | 36 | } // namespace RT 37 | } // namespace NFE 38 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/NullBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // BSDF that absorbs all the light 9 | class NullBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(NullBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "null"; } 15 | virtual bool IsDelta() const override { return false; } 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | }; 20 | 21 | } // namespace RT 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/PlasticBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // Smooth plastic-like BSDF 9 | class PlasticBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(PlasticBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "plastic"; } 15 | virtual bool IsDelta() const override { return false; } 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | }; 20 | 21 | } // namespace RT 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/RoughDielectricBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // Rough transparent dielectic BSDF (e.g. ground glass). 9 | class RoughDielectricBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(RoughDielectricBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "roughDielectric"; } 15 | virtual bool IsDelta() const override { return false; } // TODO depends on material 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | }; 20 | 21 | } // namespace RT 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/RoughDiffuseBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | class RoughDiffuseBSDF : public BSDF 9 | { 10 | NFE_DECLARE_POLYMORPHIC_CLASS(RoughDiffuseBSDF) 11 | 12 | public: 13 | virtual const char* GetShortName() const override { return "roughDiffuse"; } 14 | virtual bool IsDelta() const override { return false; } 15 | virtual bool Sample(SamplingContext& ctx) const override; 16 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 17 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 18 | 19 | static float Evaluate_Internal(const float NdotL, const float NdotV, const float LdotV, const float roughness); 20 | }; 21 | 22 | } // namespace RT 23 | } // namespace NFE 24 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/RoughMetalBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // Rough metal (conductor) BRDF. 9 | class RoughMetalBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(RoughMetalBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "roughMetal"; } 15 | virtual bool IsDelta() const override { return false; } // TODO depends on material 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | 20 | private: 21 | bool mUseMultiscatter = false; 22 | uint8 mMaxScatteringOrder = 8; 23 | }; 24 | 25 | } // namespace RT 26 | } // namespace NFE 27 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Material/BSDF/RoughPlasticBSDF.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BSDF.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // Rough plastic-like BSDF 9 | class RoughPlasticBSDF : public BSDF 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(RoughPlasticBSDF) 12 | 13 | public: 14 | virtual const char* GetShortName() const override { return "roughPlastic"; } 15 | virtual bool IsDelta() const override { return false; } 16 | virtual bool Sample(SamplingContext& ctx) const override; 17 | virtual const RayColor Evaluate(const EvaluationContext& ctx, float* outDirectPdfW = nullptr, float* outReversePdfW = nullptr) const override; 18 | virtual float Pdf(const EvaluationContext& ctx, PdfDirection dir) const override; 19 | }; 20 | 21 | } // namespace RT 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" -------------------------------------------------------------------------------- /Src/Engine/Raytracer/PCH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(NFE_CONFIGURATION_DEBUG) && defined(NFE_PLATFORM_WINDOWS) 4 | #define _CRTDBG_MAP_ALLOC 5 | #include 6 | #include 7 | #endif // NFE_CONFIGURATION_DEBUG 8 | 9 | #if defined(NFE_PLATFORM_WINDOWS) 10 | #define WIN32_LEAN_AND_MEAN 11 | #define NOMINMAX 12 | #include 13 | #include 14 | #include 15 | #endif // defined(NFE_PLATFORM_WINDOWS) 16 | 17 | #ifdef NFE_USE_SSE 18 | #include 19 | #endif // NFE_USE_SSE 20 | 21 | #if defined(NFE_USE_AVX2) | defined(NFE_USE_AVX) | defined(NFE_USE_FMA) 22 | #include 23 | #endif // defined(NFE_USE_AVX2) | defined(NFE_USE_AVX) | defined(NFE_USE_FMA) 24 | 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | #include 40 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/RayLib.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Common/nfCommon.hpp" 4 | 5 | // DLL import / export macro 6 | #ifdef WIN32 7 | 8 | #ifdef NFE_CORE_EXPORTS 9 | #define RAYLIB_API __declspec(dllexport) 10 | #else // RAYLIB_EXPORTS 11 | #define RAYLIB_API __declspec(dllimport) 12 | #endif // RAYLIB_EXPORTS 13 | 14 | #else // WIN32 15 | 16 | #define RAYLIB_API __attribute__((visibility("default"))) 17 | 18 | #endif // WIN32 19 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Raytracer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Common/nfCommon.hpp" 4 | #include "Config.h" 5 | #include "ForwardDeclarations.hpp" 6 | 7 | // DLL import / export macro 8 | #ifdef WIN32 9 | 10 | #ifdef NFE_RAYTRACER_EXPORTS 11 | #define NFE_RAYTRACER_API __declspec(dllexport) 12 | #else // RAYLIB_EXPORTS 13 | #define NFE_RAYTRACER_API __declspec(dllimport) 14 | #endif // RAYLIB_EXPORTS 15 | 16 | #else // WIN32 17 | 18 | #define NFE_RAYTRACER_API __attribute__((visibility("default"))) 19 | 20 | #endif // WIN32 21 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Renderers/LightTracer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Renderer.h" 4 | #include "../Material/BSDF/BSDF.h" 5 | 6 | namespace NFE { 7 | namespace RT { 8 | 9 | // Naive unidirectional light tracer 10 | // Traces random light paths starting from light surface 11 | // After hitting a geometry, connects to camera and splats the contribution onto film 12 | // Note: This renderer is unable to render specular materials viewed by the camera directly 13 | class LightTracer : public IRenderer 14 | { 15 | NFE_DECLARE_POLYMORPHIC_CLASS(LightTracer) 16 | 17 | public: 18 | LightTracer(); 19 | 20 | virtual const RayColor RenderPixel(const Math::Ray& ray, const RenderParam& param, RenderingContext& ctx) const override; 21 | 22 | }; 23 | 24 | } // namespace RT 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Renderers/PathTracer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Renderer.h" 4 | #include "../Material/BSDF/BSDF.h" 5 | 6 | namespace NFE { 7 | namespace RT { 8 | 9 | // Naive unidirectional path tracer 10 | // Note: this renderer is unable to sample "delta" lights (point and directional lights) 11 | class PathTracer : public IRenderer 12 | { 13 | NFE_DECLARE_POLYMORPHIC_CLASS(PathTracer) 14 | 15 | public: 16 | PathTracer(); 17 | 18 | virtual const RayColor RenderPixel(const Math::Ray& ray, const RenderParam& param, RenderingContext& ctx) const override; 19 | 20 | private: 21 | 22 | // compute radiance from a hit local lights 23 | const RayColor EvaluateLight(const LightSceneObject* lightObject, const Math::Ray& ray, const IntersectionData& intersection, RenderingContext& context) const; 24 | 25 | // compute radiance from global lights 26 | const RayColor EvaluateGlobalLights(const Scene& scene, const Math::Ray& ray, RenderingContext& context) const; 27 | }; 28 | 29 | } // namespace RT 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Renderers/RendererContext.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "RendererContext.h" 3 | 4 | namespace NFE { 5 | namespace RT { 6 | 7 | IRendererContext::IRendererContext() = default; 8 | 9 | IRendererContext::~IRendererContext() = default; 10 | 11 | } // namespace RT 12 | } // namespace NFE 13 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Renderers/RendererContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Raytracer.h" 4 | #include "../../Common/Containers/UniquePtr.hpp" 5 | 6 | #include 7 | 8 | namespace NFE { 9 | namespace RT { 10 | 11 | // per-thread renderer-specific context 12 | class IRendererContext 13 | { 14 | NFE_MAKE_NONCOPYABLE(IRendererContext) 15 | NFE_MAKE_NONMOVEABLE(IRendererContext) 16 | 17 | public: 18 | IRendererContext(); 19 | virtual ~IRendererContext(); 20 | }; 21 | 22 | using RendererContextPtr = Common::UniquePtr; 23 | 24 | } // namespace RT 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Rendering/RenderingContext.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "RenderingContext.h" 3 | 4 | namespace NFE { 5 | namespace RT { 6 | 7 | RenderingContext::RenderingContext() 8 | : randomSampler(randomGenerator) 9 | { } 10 | 11 | RenderingContext::~RenderingContext() = default; 12 | 13 | void SpectrumDebugData::Clear() 14 | { 15 | for (float& x : samples) 16 | { 17 | x = 0.0f; 18 | } 19 | } 20 | 21 | void SpectrumDebugData::Accumulate(const RayColor& rayColor, const Wavelength& wavelength) 22 | { 23 | for (uint32 i = 0; i < Wavelength::NumComponents; ++i) 24 | { 25 | const int32 binId = static_cast(wavelength.value[i] * samples.Size()); 26 | if (binId >= 0 && (uint32)binId < samples.Size()) 27 | { 28 | samples[binId] += rayColor[i]; 29 | } 30 | } 31 | } 32 | 33 | } // namespace RT 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Rendering/ShadingData.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Raytracer.h" 4 | #include "../Color/RayColor.h" 5 | #include "../Traversal/Intersection.h" 6 | #include "../../Common/Math/Matrix4.hpp" 7 | 8 | namespace NFE { 9 | namespace RT { 10 | 11 | struct SampledMaterialParameters 12 | { 13 | RayColor baseColor; 14 | RayColor emissionColor; 15 | float roughness; 16 | float roughnessAnisotropy; 17 | float metalness; 18 | float IoR; 19 | }; 20 | 21 | struct ShadingData 22 | { 23 | // geometry data 24 | IntersectionData intersection; 25 | 26 | // incoming ray data 27 | Math::Vec4f outgoingDirWorldSpace; 28 | 29 | SampledMaterialParameters materialParams; 30 | }; 31 | 32 | } // namespace RT 33 | } // namespace NFE 34 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Scene/Light/DirectionalLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Light.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | class DirectionalLight : public ILight 9 | { 10 | NFE_DECLARE_POLYMORPHIC_CLASS(DirectionalLight) 11 | 12 | public: 13 | NFE_RAYTRACER_API DirectionalLight() = default; 14 | 15 | NFE_RAYTRACER_API DirectionalLight(const Math::HdrColorRGB& color, const float angle = 0.2f); 16 | 17 | virtual const Math::Box GetBoundingBox() const override; 18 | virtual const RayColor Illuminate(const IlluminateParam& param, IlluminateResult& outResult) const override; 19 | virtual const RayColor GetRadiance(const RadianceParam& param, float* outDirectPdfA, float* outEmissionPdfW) const override; 20 | virtual const RayColor Emit(const EmitParam& param, EmitResult& outResult) const override; 21 | virtual Flags GetFlags() const override final; 22 | 23 | const Math::Vec4f SampleDirection(const Math::Vec2f sample, float& outPdf) const; 24 | 25 | private: 26 | float mCosAngle; 27 | bool mIsDelta; 28 | }; 29 | 30 | } // namespace RT 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Scene/Light/PointLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Light.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | class PointLight : public ILight 9 | { 10 | NFE_DECLARE_POLYMORPHIC_CLASS(PointLight) 11 | 12 | public: 13 | NFE_RAYTRACER_API PointLight(const Math::HdrColorRGB& color = Math::HdrColorRGB(1.0f)); 14 | 15 | virtual const Math::Box GetBoundingBox() const override; 16 | virtual const RayColor Illuminate(const IlluminateParam& param, IlluminateResult& outResult) const override; 17 | virtual const RayColor Emit(const EmitParam& param, EmitResult& outResult) const override; 18 | virtual Flags GetFlags() const override final; 19 | 20 | private: 21 | 22 | // TODO texture 23 | }; 24 | 25 | } // namespace RT 26 | } // namespace NFE 27 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Scene/Light/SpotLight.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Light.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | class SpotLight : public ILight 9 | { 10 | NFE_DECLARE_POLYMORPHIC_CLASS(SpotLight) 11 | 12 | public: 13 | NFE_RAYTRACER_API SpotLight(const Math::HdrColorRGB& color, const float angle); 14 | 15 | virtual const Math::Box GetBoundingBox() const override; 16 | virtual const RayColor Illuminate(const IlluminateParam& param, IlluminateResult& outResult) const override; 17 | virtual const RayColor Emit(const EmitParam& param, EmitResult& outResult) const override; 18 | virtual Flags GetFlags() const override final; 19 | 20 | private: 21 | float mAngle; 22 | float mCosAngle; 23 | bool mIsDelta; // true for 'laser' light 24 | }; 25 | 26 | } // namespace RT 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Scene/Object/SceneObject_Decal.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "SceneObject.h" 4 | #include "../../Material/MaterialParameter.h" 5 | 6 | namespace NFE { 7 | namespace RT { 8 | 9 | enum class BlendingMode 10 | { 11 | Alpha, 12 | Additive, 13 | Multiplicative, 14 | }; 15 | 16 | class DecalSceneObject : public ISceneObject 17 | { 18 | NFE_DECLARE_POLYMORPHIC_CLASS(DecalSceneObject) 19 | 20 | public: 21 | NFE_RAYTRACER_API explicit DecalSceneObject(); 22 | 23 | virtual Math::Box GetBoundingBox() const override; 24 | 25 | void Apply(ShadingData& shadingData, RenderingContext& context) const; 26 | 27 | ColorMaterialParameter baseColor; 28 | MaterialParameter roughness; 29 | 30 | float alphaMin = 0.0f; 31 | float alphaMax = 1.0f; 32 | 33 | uint32 order = 0; 34 | }; 35 | 36 | } // namespace RT 37 | } // namespace NFE 38 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Shapes/CsgShape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Shape.h" 4 | 5 | #include "../../Common/Containers/SharedPtr.hpp" 6 | 7 | namespace NFE { 8 | namespace RT { 9 | 10 | using ShapePtr = Common::SharedPtr; 11 | 12 | enum class CsgOperator : uint8 13 | { 14 | Union, 15 | Difference, 16 | Intersection, 17 | }; 18 | 19 | class CsgShape : public IShape 20 | { 21 | NFE_DECLARE_POLYMORPHIC_CLASS(CsgShape) 22 | 23 | public: 24 | NFE_RAYTRACER_API CsgShape(); 25 | 26 | virtual const Math::Box GetBoundingBox() const override; 27 | 28 | virtual bool Intersect(const Math::Ray& ray, RenderingContext& renderingCtx, ShapeIntersection& outResult) const override; 29 | virtual const Math::Vec4f SampleSurface(const Math::Vec3f& u, Math::Vec4f* outNormal, float* outPdf) const override; 30 | virtual void EvaluateIntersection(const HitPoint& hitPoint, IntersectionData& outIntersectionData) const override; 31 | 32 | private: 33 | ShapePtr mShapeA; 34 | ShapePtr mShapeB; 35 | CsgOperator mOperator; 36 | }; 37 | 38 | } // namespace RT 39 | } // namespace NFE 40 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Shapes/Mesh/VertexBufferDesc.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../../../Common/Math/Vec3f.hpp" 4 | #include "../../../Common/Containers/SharedPtr.hpp" 5 | 6 | namespace NFE { 7 | namespace RT { 8 | 9 | using MaterialPtr = Common::SharedPtr; 10 | 11 | /** 12 | * Structure describing a vertex buffer. 13 | */ 14 | struct VertexBufferDesc 15 | { 16 | uint32 numVertices = 0; 17 | uint32 numTriangles = 0; 18 | uint32 numMaterials = 0; 19 | 20 | const uint32* vertexIndexBuffer = nullptr; 21 | const Math::Vec3f* positions = nullptr; 22 | const Math::Vec3f* normals = nullptr; 23 | const Math::Vec3f* tangents = nullptr; 24 | const Math::Vec2f* texCoords = nullptr; 25 | const uint32* materialIndexBuffer = nullptr; 26 | const MaterialPtr* materials = nullptr; 27 | }; 28 | 29 | } // namespace RT 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Textures/BitmapTexture3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BitmapTexture.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | // 3D texture wrapper for Bitmap class 9 | class BitmapTexture3D : public ITexture 10 | { 11 | NFE_DECLARE_POLYMORPHIC_CLASS(BitmapTexture3D) 12 | 13 | public: 14 | NFE_RAYTRACER_API BitmapTexture3D(); 15 | NFE_RAYTRACER_API BitmapTexture3D(const BitmapPtr& bitmap); 16 | ~BitmapTexture3D(); 17 | 18 | virtual const char* GetName() const override; 19 | virtual const Math::Vec4f Evaluate(const Math::Vec4f& coords) const override; 20 | virtual const Math::Vec4f Sample(const Math::Vec3f u, Math::Vec4f& outCoords, SampleDistortion distortion, float* outPdf) const override; 21 | 22 | private: 23 | BitmapPtr mBitmap; 24 | BitmapTextureFilter mFilter; 25 | }; 26 | 27 | } // namespace RT 28 | } // namespace NFE 29 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Textures/ConstTexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Texture.h" 4 | #include "../Utils/Memory.h" 5 | #include "../../Common/Math/HdrColor.hpp" 6 | 7 | namespace NFE { 8 | namespace RT { 9 | 10 | // constant color texture 11 | class NFE_ALIGN(16) ConstTexture 12 | : public ITexture 13 | { 14 | NFE_DECLARE_POLYMORPHIC_CLASS(ConstTexture) 15 | 16 | public: 17 | NFE_RAYTRACER_API ConstTexture(const Math::Vec4f& color = Math::Vec4f(1.0f)); 18 | 19 | virtual const char* GetName() const override; 20 | virtual const Math::Vec4f Evaluate(const Math::Vec4f& coords) const override; 21 | virtual const Math::Vec4f Sample(const Math::Vec3f u, Math::Vec4f& outCoords, SampleDistortion distortion, float* outPdf) const override; 22 | 23 | private: 24 | Math::HdrColorRGBA mColor; 25 | }; 26 | 27 | } // namespace RT 28 | } // namespace NFE 29 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Textures/GradientTexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Texture.h" 4 | #include "../Utils/Memory.h" 5 | #include "../../Common/Math/Plane.hpp" 6 | #include "../../Common/Math/HdrColor.hpp" 7 | 8 | namespace NFE { 9 | namespace RT { 10 | 11 | class NFE_ALIGN(16) GradientTexture 12 | : public ITexture 13 | { 14 | NFE_DECLARE_POLYMORPHIC_CLASS(GradientTexture) 15 | 16 | public: 17 | NFE_RAYTRACER_API GradientTexture(const Math::Vec4f& colorA, const Math::Vec4f& colorB, const Math::Plane& plane, float planeDistance); 18 | 19 | virtual const char* GetName() const override; 20 | virtual const Math::Vec4f Evaluate(const Math::Vec4f& coords) const override; 21 | 22 | private: 23 | Math::HdrColorRGBA mColorA; 24 | Math::HdrColorRGBA mColorB; 25 | 26 | Math::Plane mPlane; 27 | float mDistance; 28 | float mInvDistance; 29 | }; 30 | 31 | } // namespace RT 32 | } // namespace NFE 33 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Textures/MixTexture.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Texture.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | class MixTexture : public ITexture 9 | { 10 | NFE_DECLARE_POLYMORPHIC_CLASS(MixTexture) 11 | 12 | public: 13 | NFE_RAYTRACER_API MixTexture(const TexturePtr& textureA, const TexturePtr& textureB, const TexturePtr& textureMask); 14 | 15 | virtual const char* GetName() const override; 16 | virtual const Math::Vec4f Evaluate(const Math::Vec4f& coords) const override; 17 | virtual const Math::Vec4f Sample(const Math::Vec3f u, Math::Vec4f& outCoords, SampleDistortion distortion, float* outPdf) const override; 18 | 19 | private: 20 | TexturePtr mTextureA; 21 | TexturePtr mTextureB; 22 | TexturePtr mTextureMask; 23 | }; 24 | 25 | } // namespace RT 26 | } // namespace NFE 27 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Traversal/RayPacket.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "RayPacket.h" 3 | 4 | namespace NFE { 5 | namespace RT { 6 | 7 | 8 | } // namespace RT 9 | } // namespace NFE 10 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Traversal/TraversalContext.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "HitPoint.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | struct SingleTraversalContext 9 | { 10 | const Math::Ray& ray; 11 | HitPoint& hitPoint; 12 | RenderingContext& context; 13 | }; 14 | 15 | struct SimdTraversalContext 16 | { 17 | const RayPacketTypes::Ray& ray; 18 | SimdHitPoint& hitPoint; 19 | RenderingContext& context; 20 | }; 21 | 22 | struct PacketTraversalContext 23 | { 24 | RayPacket& ray; 25 | RenderingContext& context; 26 | 27 | void StoreIntersection(RayGroup& rayGroup, const RayPacketTypes::Float& t, const RayPacketTypes::Float& u, const RayPacketTypes::Float& v, const RayPacketTypes::FloatMask& mask, uint32 objectID, uint32 subObjectID = 0) const; 28 | }; 29 | 30 | } // namespace RT 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Utils/BitmapUtils.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Bitmap.h" 4 | 5 | namespace NFE { 6 | namespace RT { 7 | 8 | /** 9 | * Class representing 2D bitmap. 10 | */ 11 | class BitmapUtils 12 | { 13 | public: 14 | struct GaussianBlurParams 15 | { 16 | float sigma; 17 | uint32 numPasses; 18 | }; 19 | 20 | static bool GaussianBlur(Bitmap& targetBitmap, const Bitmap& sourceBitmap, const GaussianBlurParams params, Common::TaskBuilder& taskBuilder); 21 | }; 22 | 23 | 24 | } // namespace RT 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Utils/BlockCompression.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../Raytracer.h" 4 | #include "../../Common/Math/Vec4f.hpp" 5 | 6 | 7 | namespace NFE { 8 | namespace RT { 9 | 10 | const Math::Vec4f DecodeBC1(const uint8* data, uint32 x, uint32 y, const uint32 width); 11 | const Math::Vec4f DecodeBC4(const uint8* data, uint32 x, uint32 y, const uint32 width); 12 | const Math::Vec4f DecodeBC5(const uint8* data, uint32 x, uint32 y, const uint32 width); 13 | 14 | } // namespace RT 15 | } // namespace NFE 16 | -------------------------------------------------------------------------------- /Src/Engine/Raytracer/Utils/KdTree.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "KdTree.h" 3 | 4 | namespace NFE { 5 | namespace RT { 6 | 7 | } // namespace RT 8 | } // namespace NFE 9 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # @file 2 | # @author Lookey (costyrra.xl@gmail.com) 3 | # @brief CMake for Renderers 4 | 5 | SET(NFE_RENDERERS_DIRECTORY ${NFE_ENGINE_DIRECTORY}/Renderers) 6 | 7 | ADD_SUBDIRECTORY("RendererCommon") 8 | 9 | #IF(WIN32) 10 | # ADD_SUBDIRECTORY("RendererD3D12") 11 | #ENDIF(WIN32) 12 | 13 | ADD_CUSTOM_TARGET(RendererD3D12) 14 | 15 | ADD_SUBDIRECTORY("RendererVk") 16 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererCommon/ComputePipelineState.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declarations of low-level rendering interface. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Shader.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | /** 16 | * Description of compute pipeline state object. 17 | */ 18 | struct ComputePipelineStateDesc 19 | { 20 | ShaderPtr computeShader; 21 | const char* debugName; //< optional debug name 22 | 23 | ComputePipelineStateDesc(const ShaderPtr& computeShader, 24 | const char* debugName = nullptr) 25 | : computeShader(computeShader) 26 | , debugName(debugName) 27 | { 28 | } 29 | }; 30 | 31 | /** 32 | * Compute Pipeline State interface. 33 | * @details Describes GPU resources used during compute shader execution. 34 | */ 35 | class IComputePipelineState 36 | { 37 | public: 38 | virtual ~IComputePipelineState() {} 39 | }; 40 | 41 | } // namespace Renderer 42 | } // namespace NFE 43 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererCommon/Fence.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | */ 5 | 6 | #include "PCH.hpp" 7 | #include "Fence.hpp" 8 | #include "Engine/Common/Utils/TaskBuilder.hpp" 9 | #include "Engine/Common/Utils/Waitable.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | using namespace Common; 16 | 17 | IFence::~IFence() = default; 18 | 19 | void IFence::Wait() 20 | { 21 | Waitable waitable; 22 | { 23 | TaskBuilder builder(waitable); 24 | Sync(builder); 25 | } 26 | waitable.Wait(); 27 | } 28 | 29 | } // namespace Renderer 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererCommon/MemoryBlock.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief Declarations of low-level rendering interface. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Types.hpp" 10 | 11 | namespace NFE { 12 | namespace Renderer { 13 | 14 | /** 15 | * Description of GPU memory block 16 | */ 17 | struct MemoryBlockDesc 18 | { 19 | uint64 size; 20 | uint32 alignment; 21 | 22 | MemoryBlockDesc(uint64 size = 0u) 23 | : size(size) 24 | , alignment(0u) 25 | {} 26 | }; 27 | 28 | /** 29 | * GPU memory block. 30 | */ 31 | class IMemoryBlock 32 | { 33 | public: 34 | virtual ~IMemoryBlock() {} 35 | }; 36 | 37 | } // namespace Renderer 38 | } // namespace NFE 39 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererCommon/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererCommon/PCH.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief Precompiled header 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "RendererCommon.hpp" 10 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererCommon/RendererCommon.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief Main header for RendererCommon project 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../../Common/nfCommon.hpp" 10 | 11 | // DLL import / export macro 12 | #ifdef NFE_PLATFORM_WINDOWS 13 | 14 | #ifdef NFE_RENDERER_COMMON_EXPORTS 15 | #define NFE_RENDERER_COMMON_API NFE_API_EXPORT 16 | #else // NFE_RENDERER_COMMON_EXPORTS 17 | #define NFE_RENDERER_COMMON_API NFE_API_IMPORT 18 | #endif // NFE_RENDERER_COMMON_EXPORTS 19 | 20 | #elif defined(NFE_PLATFORM_LINUX) 21 | 22 | #define NFE_RENDERER_COMMON_API __attribute__((visibility("default"))) 23 | 24 | #else 25 | #error Invalid platform 26 | #endif // NFE_PLATFORM_WINDOWS 27 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/Common.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Common utilities for D3D12 renderer. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Engine/Common/nfCommon.hpp" 10 | #include "Engine/Common/System/Windows/Common.hpp" 11 | #include "D3DPtr.hpp" 12 | 13 | 14 | namespace NFE { 15 | namespace Renderer { 16 | 17 | /** 18 | * DirectX API error handling 19 | * @param hr Result of a D3D call 20 | * @param srcFile,line Source file name and line with the call 21 | */ 22 | HRESULT D3DError(HRESULT hr, const char* srcFile, int line); 23 | 24 | #ifndef D3D_CALL_CHECK 25 | #define D3D_CALL_CHECK(x) D3DError((x), __FILE__, __LINE__) 26 | #endif 27 | 28 | bool SetDebugName(ID3D12Object* obj, const Common::StringView name); 29 | 30 | } // namespace Renderer 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/ComputePipelineState.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declarations of Direct3D 11 render's compute pipeline states. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../RendererCommon/ComputePipelineState.hpp" 10 | #include "Common.hpp" 11 | #include "Shader.hpp" 12 | 13 | 14 | namespace NFE { 15 | namespace Renderer { 16 | 17 | class ComputePipelineState : public IComputePipelineState 18 | { 19 | D3DPtr mPipelineState; 20 | 21 | // keep reference to compute shader bytecode 22 | InternalShaderPtr mComputeShader; 23 | 24 | void Release(); 25 | 26 | public: 27 | ComputePipelineState(); 28 | bool Init(const ComputePipelineStateDesc& desc); 29 | 30 | NFE_INLINE ID3D12PipelineState* GetPSO() const 31 | { 32 | return mPipelineState.Get(); 33 | } 34 | }; 35 | 36 | } // namespace Renderer 37 | } // namespace NFE 38 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/D3DPtr.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief D3D smart pointer definition 5 | */ 6 | 7 | #pragma once 8 | 9 | 10 | #include "Engine/Common/Containers/UniquePtr.hpp" 11 | #include "Engine/Common/Containers/SharedPtr.hpp" 12 | 13 | 14 | #ifndef D3D_SAFE_RELEASE 15 | #define D3D_SAFE_RELEASE(x) { if (x) {(x)->Release(); (x)=0;} } 16 | #endif // D3D_SAFE_RELEASE 17 | 18 | 19 | namespace NFE { 20 | namespace Renderer { 21 | 22 | template 23 | struct D3DPointerDeleter 24 | { 25 | static void Delete(T* pointer) 26 | { 27 | if (pointer) 28 | { 29 | pointer->Release(); 30 | } 31 | } 32 | }; 33 | 34 | 35 | // helper class template for automatic releasing of Direct3D objects 36 | template 37 | using D3DPtr = Common::UniquePtr>; 38 | 39 | } // namespace Renderer 40 | } // namespace NFE 41 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/Descriptors.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief Descriptor types definitions. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Engine/Common/nfCommon.hpp" 10 | #include "Engine/Common/Containers/DynArray.hpp" 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | // descriptor ID is an offset in staging descriptor heap 16 | using DescriptorID = uint32; 17 | 18 | enum class DescriptorType : uint8 19 | { 20 | CBV, 21 | SRV, 22 | UAV, 23 | Sampler, 24 | }; 25 | 26 | struct DescriptorRange 27 | { 28 | DescriptorID baseDescriptor = UINT32_MAX; 29 | uint32 numDescriptors = 0; 30 | }; 31 | 32 | using ReferencedDescriptorsRanges = Common::DynArray; 33 | 34 | } // namespace Renderer 35 | } // namespace NFE 36 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/Main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief DLL entry point definition for Direct3D 12 renderer 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 10 | { 11 | (void)hModule; 12 | (void)lpReserved; 13 | 14 | switch (ul_reason_for_call) 15 | { 16 | case DLL_PROCESS_ATTACH: 17 | case DLL_THREAD_ATTACH: 18 | case DLL_THREAD_DETACH: 19 | case DLL_PROCESS_DETACH: 20 | break; 21 | } 22 | return TRUE; 23 | } 24 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/MemoryBlock.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief Declaration of Direct3D 12 renderer's memory block. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../RendererCommon/MemoryBlock.hpp" 10 | #include "D3D12MemAlloc.h" 11 | 12 | #include "Common.hpp" 13 | 14 | 15 | namespace NFE { 16 | namespace Renderer { 17 | 18 | class MemoryBlock : public IMemoryBlock 19 | { 20 | public: 21 | MemoryBlock(); 22 | ~MemoryBlock(); 23 | 24 | bool Init(const MemoryBlockDesc& desc); 25 | 26 | NFE_FORCE_INLINE uint64 GetSize() const 27 | { 28 | return mSize; 29 | } 30 | 31 | NFE_FORCE_INLINE uint32 GetAlignment() const 32 | { 33 | return mAlignment; 34 | } 35 | 36 | NFE_FORCE_INLINE D3D12MA::Allocation* GetAllocation() const 37 | { 38 | return mAllocation.Get(); 39 | } 40 | 41 | private: 42 | uint64 mSize; 43 | uint32 mAlignment; 44 | D3DPtr mAllocation; 45 | }; 46 | 47 | } // namespace Renderer 48 | } // namespace NFE 49 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/PCH.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Precompiled header 5 | */ 6 | 7 | #pragma once 8 | 9 | #define WIN32_LEAN_AND_MEAN 10 | #define NOMINMAX 11 | #include 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | #include 21 | #include 22 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/RendererD3D12.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief D3D12 implementation of renderer's lowlevel API 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "RendererD3D12.hpp" 9 | 10 | namespace NFE { 11 | namespace Renderer { 12 | 13 | Common::UniquePtr gDevice; 14 | 15 | IDevice* Init(const DeviceInitParams* params) 16 | { 17 | if (gDevice == nullptr) 18 | { 19 | gDevice = Common::MakeUniquePtr(); 20 | if (!gDevice->Init(params)) 21 | gDevice.Reset(); 22 | } 23 | 24 | return gDevice.Get(); 25 | } 26 | 27 | void Release() 28 | { 29 | gDevice.Reset(); 30 | } 31 | 32 | } // namespace Renderer 33 | } // namespace NFE 34 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/RendererD3D12.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of Direct3D 12 rendering backend. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Device.hpp" 10 | 11 | #ifdef RENDERERD3D12_EXPORTS 12 | #define RENDERER_API __declspec(dllexport) 13 | #else 14 | #define RENDERER_API __declspec(dllimport) 15 | #endif 16 | 17 | 18 | namespace NFE { 19 | namespace Renderer { 20 | 21 | extern Common::UniquePtr gDevice; 22 | 23 | // export Device creation function 24 | extern "C" RENDERER_API IDevice* Init(const DeviceInitParams* params); 25 | extern "C" RENDERER_API void Release(); 26 | 27 | } // namespace Renderer 28 | } // namespace NFE 29 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/Resource.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @brief D3D12 implementation of renderer's generic resource 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "Resource.hpp" 9 | #include "../RendererCommon/Types.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | Resource::Resource(const D3D12_RESOURCE_STATES defaultState) 16 | : mState(defaultState) 17 | , mMode(ResourceAccessMode::Invalid) 18 | { } 19 | 20 | } // namespace Renderer 21 | } // namespace NFE 22 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/Sampler.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of Direct3D 12 render's sampler 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../RendererCommon/Texture.hpp" 10 | #include "Common.hpp" 11 | #include "Descriptors.hpp" 12 | 13 | namespace NFE { 14 | namespace Renderer { 15 | 16 | class Sampler : public ISampler 17 | { 18 | public: 19 | Sampler(); 20 | ~Sampler(); 21 | 22 | bool Init(const SamplerDesc& desc); 23 | 24 | DescriptorID GetDescriptor() const 25 | { 26 | return mDescriptor; 27 | } 28 | 29 | private: 30 | DescriptorID mDescriptor; 31 | }; 32 | 33 | } // namespace Renderer 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/ShaderCompiler.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../RendererCommon/Types.hpp" 4 | #include "D3DPtr.hpp" 5 | 6 | 7 | namespace NFE { 8 | namespace Renderer { 9 | 10 | class ShaderCompiler 11 | { 12 | D3DPtr mLibrary; 13 | D3DPtr mCompiler; 14 | D3DPtr mIncluder; 15 | 16 | public: 17 | ShaderCompiler(); 18 | ~ShaderCompiler() = default; 19 | 20 | bool Init(); 21 | bool Compile(const char* source, uint32 sourceSize, const char* sourceName, ShaderType type, 22 | const Common::DynArray& defines, D3DPtr& output); 23 | bool Disassemble(const D3DPtr& bytecode, D3DPtr& disassembly); 24 | bool Reflect(const D3DPtr& bytecode, D3DPtr& reflection); 25 | }; 26 | 27 | } // namespace Renderer 28 | } // namespace NFE 29 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/VertexLayout.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Declaration of Direct3D 12 render's vertex layout. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../RendererCommon/VertexLayout.hpp" 10 | #include "Common.hpp" 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | class VertexLayout : public IVertexLayout 16 | { 17 | friend class PipelineState; 18 | 19 | Common::DynArray mElements; 20 | 21 | public: 22 | VertexLayout(); 23 | bool Init(const VertexLayoutDesc& desc); 24 | }; 25 | 26 | } // namespace Renderer 27 | } // namespace NFE 28 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererD3D12/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/CommandList.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "CommandList.hpp" 3 | #include "Device.hpp" 4 | 5 | #include "Engine/Common/Logger/Logger.hpp" 6 | 7 | 8 | namespace NFE { 9 | namespace Renderer { 10 | 11 | CommandList::CommandList(CommandQueueType queueType, VkCommandBuffer commandBuffer, 12 | const UsedDescriptorSetsArray& sets) 13 | : ICommandList() 14 | , mQueueType(queueType) 15 | , mCommandBuffer(commandBuffer) 16 | , mUsedDescriptorSets(sets) 17 | { 18 | } 19 | 20 | CommandList::~CommandList() 21 | { 22 | // Release CB ownership back to Manager 23 | if (mCommandBuffer != VK_NULL_HANDLE) 24 | { 25 | UsedDescriptorSetsArray dsArray(mUsedDescriptorSets); 26 | gDevice->GetCommandBufferManager(mQueueType).Free(mCommandBuffer, [dsArray](){ 27 | for (DescriptorSetCollectionID id: dsArray) 28 | { 29 | gDevice->GetDescriptorSetCache().FreeDescriptorSets(id); 30 | } 31 | }); 32 | } 33 | } 34 | 35 | } // namespace Renderer 36 | } // namespace NFE 37 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/CommandList.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../RendererCommon/CommandRecorder.hpp" 4 | 5 | #include "Defines.hpp" 6 | #include "Internal/DescriptorSetCache.hpp" 7 | 8 | 9 | namespace NFE { 10 | namespace Renderer { 11 | 12 | class CommandList: public ICommandList 13 | { 14 | CommandQueueType mQueueType; 15 | VkCommandBuffer mCommandBuffer; 16 | UsedDescriptorSetsArray mUsedDescriptorSets; 17 | 18 | public: 19 | CommandList(CommandQueueType queueType, VkCommandBuffer commandBuffer, 20 | const UsedDescriptorSetsArray& sets); 21 | ~CommandList(); 22 | 23 | NFE_INLINE const VkCommandBuffer& GetCommandBuffer() const 24 | { 25 | return mCommandBuffer; 26 | } 27 | }; 28 | 29 | } // namespace Renderer 30 | } // namespace NFE 31 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/CommandQueue.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "../RendererCommon/CommandQueue.hpp" 4 | #include "Internal/QueueFamilyManager.hpp" 5 | 6 | 7 | namespace NFE { 8 | namespace Renderer { 9 | 10 | class CommandQueue: public ICommandQueue 11 | { 12 | VkQueue mQueue; 13 | CommandQueueType mType; 14 | uint32 mIndex; 15 | 16 | public: 17 | CommandQueue(); 18 | ~CommandQueue(); 19 | 20 | bool Init(CommandQueueType type, const char* debugName); 21 | void Release(); 22 | 23 | CommandQueueType GetType() const override; 24 | 25 | void Submit(const Common::ArrayView commandLists, 26 | const Common::ArrayView waitFences) override; 27 | FencePtr Signal(const FenceFlags flags) override; 28 | }; 29 | 30 | } // namespace Renderer 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/ComputePipelineState.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declarations of Vulkan render's compute pipeline states. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "BasePipelineState.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | class ComputePipelineState : public IComputePipelineState, public BasePipelineState 16 | { 17 | public: 18 | ComputePipelineState(); 19 | ~ComputePipelineState(); 20 | 21 | bool Init(const ComputePipelineStateDesc& desc); 22 | }; 23 | 24 | } // namespace Renderer 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/IResource.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declaration of Vulkan renderer's IResource base class 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Engine/Common/Containers/SharedPtr.hpp" 10 | #include "Internal/Types.hpp" 11 | 12 | 13 | namespace NFE { 14 | namespace Renderer { 15 | 16 | // Base Resource interface, used for easier resource tracking 17 | class IResource 18 | { 19 | protected: 20 | Internal::ResourceID mID; 21 | 22 | public: 23 | virtual const Internal::ResourceType GetType() const = 0; 24 | 25 | NFE_INLINE Internal::ResourceID GetID() const 26 | { 27 | return mID; 28 | } 29 | }; 30 | 31 | using ResourcePtr = Common::SharedPtr; 32 | 33 | } // namespace Renderer 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/MemoryBlock.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @author Lookey (costyrra.xl@gmail.com) 5 | * @brief Vulkan implementation of renderer's memory block. 6 | */ 7 | 8 | #include "PCH.hpp" 9 | #include "MemoryBlock.hpp" 10 | 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | MemoryBlock::MemoryBlock() 16 | : mMemory(VK_NULL_HANDLE) 17 | , mSize(0) 18 | , mAlignment(0) 19 | { 20 | } 21 | 22 | MemoryBlock::~MemoryBlock() 23 | { 24 | } 25 | 26 | bool MemoryBlock::Init(const MemoryBlockDesc& desc) 27 | { 28 | if (desc.size == 0) 29 | { 30 | NFE_LOG_ERROR("Cannot create zero-sized memory block"); 31 | return false; 32 | } 33 | 34 | return true; 35 | } 36 | 37 | } // namespace Renderer 38 | } // namespace NFE 39 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/MemoryBlock.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 4 | * @author Lookey (costyrra.xl@gmail.com) 5 | * @brief Declaration of Vulkan renderer's memory block. 6 | */ 7 | 8 | #pragma once 9 | 10 | #include "../RendererCommon/MemoryBlock.hpp" 11 | 12 | namespace NFE { 13 | namespace Renderer { 14 | 15 | class MemoryBlock: public IMemoryBlock 16 | { 17 | VkDeviceMemory mMemory; 18 | uint64 mSize; 19 | uint32 mAlignment; 20 | 21 | public: 22 | MemoryBlock(); 23 | ~MemoryBlock(); 24 | 25 | bool Init(const MemoryBlockDesc& desc); 26 | 27 | NFE_FORCE_INLINE uint64 GetSize() const 28 | { 29 | return mSize; 30 | } 31 | 32 | NFE_FORCE_INLINE uint32 GetAlignment() const 33 | { 34 | return mAlignment; 35 | } 36 | }; 37 | 38 | } // namespace Renderer 39 | } // namespace NFE 40 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/PipelineState.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declarations of Vulkan pipeline states. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "BasePipelineState.hpp" 10 | #include "Defines.hpp" 11 | 12 | 13 | namespace NFE { 14 | namespace Renderer { 15 | 16 | class PipelineState : public IPipelineState, public BasePipelineState 17 | { 18 | public: 19 | PipelineState(); 20 | ~PipelineState(); 21 | bool Init(const PipelineStateDesc& desc); 22 | }; 23 | 24 | } // namespace Renderer 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/Sampler.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declaration of Vulkan renderer's sampler 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../RendererCommon/Texture.hpp" 10 | #include "Defines.hpp" 11 | 12 | #include "IResource.hpp" 13 | 14 | 15 | namespace NFE { 16 | namespace Renderer { 17 | 18 | class Sampler : public ISampler, public IResource 19 | { 20 | friend class CommandRecorder; 21 | friend class ResourceBindingSet; 22 | 23 | VkSampler mSampler; 24 | 25 | public: 26 | Sampler(); 27 | virtual ~Sampler(); 28 | bool Init(const SamplerDesc& desc); 29 | 30 | const Internal::ResourceType GetType() const override 31 | { 32 | return Internal::ResourceType::Sampler; 33 | } 34 | }; 35 | 36 | } // namespace Renderer 37 | } // namespace NFE 38 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/VertexLayout.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declaration of Vulkan vertex layout. 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "../RendererCommon/VertexLayout.hpp" 10 | #include "Defines.hpp" 11 | #include "PipelineState.hpp" 12 | #include "Engine/Common/Containers/DynArray.hpp" 13 | 14 | namespace NFE { 15 | namespace Renderer { 16 | 17 | class VertexLayout : public IVertexLayout 18 | { 19 | friend class PipelineState; 20 | 21 | Common::DynArray mBindings; 22 | Common::DynArray mAttributes; 23 | Common::DynArray mDivisors; 24 | 25 | public: 26 | VertexLayout(); 27 | bool Init(const VertexLayoutDesc& desc); 28 | }; 29 | 30 | } // namespace Renderer 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/API/Win/WinBackbuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "../Backbuffer.hpp" 3 | 4 | #include "../Device.hpp" 5 | 6 | namespace NFE { 7 | namespace Renderer { 8 | 9 | bool Backbuffer::CreateSurface(const BackbufferDesc& desc) 10 | { 11 | mHWND = (HWND)desc.windowHandle; 12 | 13 | VkWin32SurfaceCreateInfoKHR surfInfo; 14 | VK_ZERO_MEMORY(surfInfo); 15 | surfInfo.sType = VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR; 16 | surfInfo.hwnd = mHWND; 17 | surfInfo.hinstance = (HINSTANCE)GetWindowLongPtr(mHWND, GWLP_HINSTANCE); 18 | VkResult result = vkCreateWin32SurfaceKHR(gDevice->GetInstance(), &surfInfo, nullptr, &mSurface); 19 | 20 | return (result == VK_SUCCESS); 21 | } 22 | 23 | void Backbuffer::CleanupPlatformSpecifics() 24 | { 25 | } 26 | 27 | 28 | } // namespace Renderer 29 | } // namespace NFE 30 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/FenceSignaller.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Common/Containers/DynArray.hpp" 4 | #include "Engine/Common/System/Thread.hpp" 5 | #include "Engine/Common/System/ConditionVariable.hpp" 6 | #include "Engine/Common/System/RWLock.hpp" 7 | 8 | #include "API/Fence.hpp" 9 | 10 | 11 | namespace NFE { 12 | namespace Renderer { 13 | 14 | class FenceSignaller 15 | { 16 | Common::Thread mThread; 17 | Common::RWLock mLock; 18 | std::atomic mDone; 19 | Common::DynArray mRegisteredFences; 20 | 21 | void ThreadMain(); 22 | 23 | public: 24 | FenceSignaller(); 25 | ~FenceSignaller(); 26 | 27 | bool Init(); 28 | void RegisterFence(const FenceDataPtr& fence); 29 | void UnregisterFence(const FenceDataPtr& fence); 30 | void Release(); 31 | }; 32 | 33 | } // namespace Renderer 34 | } // namespace NFE 35 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/Instance.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declarations of Vulkan Instance 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Defines.hpp" 10 | 11 | #include "Engine/Common/System/Library.hpp" 12 | 13 | 14 | namespace NFE { 15 | namespace Renderer { 16 | 17 | class Instance 18 | { 19 | private: 20 | VkInstance mInstance; 21 | 22 | public: 23 | Instance(); 24 | ~Instance(); 25 | 26 | /** 27 | * Initialize Vulkan instance for further use. 28 | * 29 | * @param debugLevel Engine's requested debug level. 30 | * @return True on success 31 | */ 32 | bool Init(int debugLevel); 33 | 34 | /** 35 | * Acquire Vulkan instance. 36 | */ 37 | inline const VkInstance& Get() const 38 | { 39 | return mInstance; 40 | } 41 | 42 | /** 43 | * Release Vulkan instance. 44 | */ 45 | void Release(); 46 | }; 47 | 48 | } // namespace Renderer 49 | } // namespace NFE 50 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/Linux/XcbExtensions.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Definitions of XCB-specific Vulkan extensions 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | #include "XcbExtensions.hpp" 10 | 11 | #include "../Extensions.hpp" 12 | #include "../GetProc.hpp" 13 | 14 | 15 | namespace NFE { 16 | namespace Renderer { 17 | 18 | PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR = VK_NULL_HANDLE; 19 | 20 | // Initializes only XCB-specific extensions 21 | bool nfvkXcbInstanceExtensionsInit(VkInstance instance) 22 | { 23 | bool allExtensionsAvailable = true; 24 | 25 | VK_GET_INSTANCEPROC(instance, vkCreateXcbSurfaceKHR); 26 | 27 | return allExtensionsAvailable; 28 | } 29 | 30 | } // namespace Renderer 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/Linux/XcbExtensions.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declarations of XCB-specific Vulkan extensions 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Defines.hpp" 10 | 11 | namespace NFE { 12 | namespace Renderer { 13 | 14 | extern PFN_vkCreateXcbSurfaceKHR vkCreateXcbSurfaceKHR; 15 | 16 | /** 17 | * Initializes Xcb Surface-related device extensions. 18 | */ 19 | bool nfvkXcbInstanceExtensionsInit(VkInstance instance); 20 | 21 | } // namespace Renderer 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/Types.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | 6 | namespace NFE { 7 | namespace Renderer { 8 | namespace Internal { 9 | 10 | 11 | using ResourceID = uint32; 12 | 13 | enum class ResourceType: uint8 14 | { 15 | Buffer = 0, 16 | Texture, 17 | Backbuffer, 18 | Sampler, 19 | Max 20 | }; 21 | 22 | 23 | } // namespace Internal 24 | } // namespace Renderer 25 | } // namespace NFE 26 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/Utilities.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "Utilities.hpp" 3 | 4 | 5 | namespace NFE { 6 | namespace Renderer { 7 | 8 | } // namespace Renderer 9 | } // namespace NFE 10 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/Win/WinExtensions.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Definitions of Win32-specific Vulkan extensions 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | #include "WinExtensions.hpp" 10 | 11 | #include "../Extensions.hpp" 12 | #include "../GetProc.hpp" 13 | 14 | 15 | namespace NFE { 16 | namespace Renderer { 17 | 18 | PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = VK_NULL_HANDLE; 19 | 20 | // Initializes only Win32-specific extensions 21 | bool nfvkWinInstanceExtensionsInit(VkInstance instance) 22 | { 23 | bool allExtensionsAvailable = true; 24 | 25 | VK_GET_INSTANCEPROC(instance, vkCreateWin32SurfaceKHR); 26 | 27 | return allExtensionsAvailable; 28 | } 29 | 30 | } // namespace Renderer 31 | } // namespace NFE 32 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Internal/Win/WinExtensions.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Declarations of Windows-specific Vulkan extensions 5 | */ 6 | 7 | #pragma once 8 | 9 | #include "Defines.hpp" 10 | 11 | namespace NFE { 12 | namespace Renderer { 13 | 14 | extern PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR; 15 | 16 | /** 17 | * Initializes Win32Surface-related device extensions. 18 | */ 19 | bool nfvkWinInstanceExtensionsInit(VkInstance instance); 20 | 21 | } // namespace Renderer 22 | } // namespace NFE 23 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/Main.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief DLL entry point definition for Vulkan renderer 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | #include "Defines.hpp" 10 | 11 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) 12 | { 13 | NFE_UNUSED(hModule); 14 | NFE_UNUSED(ul_reason_for_call); 15 | NFE_UNUSED(lpReserved); 16 | 17 | switch (ul_reason_for_call) 18 | { 19 | case DLL_PROCESS_ATTACH: 20 | case DLL_THREAD_ATTACH: 21 | case DLL_THREAD_DETACH: 22 | case DLL_PROCESS_DETACH: 23 | break; 24 | } 25 | return TRUE; 26 | } 27 | -------------------------------------------------------------------------------- /Src/Engine/Renderers/RendererVk/PCH.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Precompiled Header source file for Vulkan renderer 5 | */ 6 | 7 | #include "PCH.hpp" 8 | -------------------------------------------------------------------------------- /Src/PropertyPages/DebugProperties.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | NFE_CONFIGURATION_DEBUG;_DEBUG;%(PreprocessorDefinitions) 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Src/PropertyPages/FinalProperties.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | NFE_CONFIGURATION_FINAL;NDEBUG;%(PreprocessorDefinitions) 9 | 10 | 11 | $(SolutionDir)Deps\Bin\$(Platform)\Release\;%(AdditionalLibraryDirectories) 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /Src/Shaders/AmbientLightPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | 4 | "macros": [] 5 | } -------------------------------------------------------------------------------- /Src/Shaders/DebugPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | 4 | "macros": 5 | [ 6 | { "name": "USE_TEXTURE", "min": 0, "max": 1, "default": 0 } 7 | ] 8 | } -------------------------------------------------------------------------------- /Src/Shaders/DebugVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | 4 | "macros": 5 | [ 6 | { "name": "IS_MESH", "min": 0, "max": 1, "default": 0 } 7 | ] 8 | } -------------------------------------------------------------------------------- /Src/Shaders/FullScreenQuadVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | 4 | "macros": [] 5 | } -------------------------------------------------------------------------------- /Src/Shaders/GeometryPassPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | 4 | "macros": 5 | [ 6 | { "name": "USE_MOTION_BLUR", "min": 0, "max": 0, "default": 0 } 7 | ] 8 | } -------------------------------------------------------------------------------- /Src/Shaders/GeometryPassVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | 4 | "macros": 5 | [ 6 | { "name": "USE_MOTION_BLUR", "min": 0, "max": 0, "default": 0 } 7 | ] 8 | } -------------------------------------------------------------------------------- /Src/Shaders/GuiGS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "geometry", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Shaders/GuiPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | "macros": 4 | [ 5 | { "name": "USE_TEXTURE", "min": 0, "max": 2, "default": 0 } 6 | ] 7 | } -------------------------------------------------------------------------------- /Src/Shaders/GuiVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/AmbientLightPS.hlsl: -------------------------------------------------------------------------------- 1 | #include "LightCommon.hlsl" 2 | 3 | cbuffer AmbientLightParams : register (b1) 4 | { 5 | float4 gAmbientLight; 6 | float4 gBackgroundColor; 7 | }; 8 | 9 | struct QuadVertexShaderOutput 10 | { 11 | float4 pos : SV_POSITION; 12 | }; 13 | 14 | float4 main(QuadVertexShaderOutput input) : SV_TARGET0 15 | { 16 | int3 texelCoords = int3((int2)input.pos.xy, 0); 17 | float depth = gDepthTex.Load(texelCoords); 18 | 19 | float4 result = gBackgroundColor; 20 | if (depth < gInfinityDist) 21 | { 22 | float4 diffuseColor = gGBufferTex1.Load(texelCoords); 23 | result = diffuseColor * gAmbientLight; 24 | result += gGBufferTex2.Load(texelCoords); // emission color 25 | } 26 | 27 | return float4(result.xyz, 1.0f); 28 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/Common.hlsl: -------------------------------------------------------------------------------- 1 | // Vertex Layout for Geometry Renderer 2 | struct MeshVertexShaderInput 3 | { 4 | /// per-vertex data 5 | float3 pos : POSITION; 6 | float2 texCoord : TEXCOORD0; 7 | float4 normal : TEXCOORD1; 8 | float4 tangent : TEXCOORD2; 9 | 10 | // per-instance data 11 | float4 worldMat0 : TEXCOORD3; 12 | float4 worldMat1 : TEXCOORD4; 13 | float4 worldMat2 : TEXCOORD5; 14 | float4 velocity : TEXCOORD6; 15 | float4 angularVelocity : TEXCOORD7; // TODO: remove when MB is off 16 | }; -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/DebugPS.hlsl: -------------------------------------------------------------------------------- 1 | #if (USE_TEXTURE > 0) 2 | Texture2D gTexture : register(t0); 3 | SamplerState gSampler : register(s0); 4 | #endif // (USE_TEXTURE > 0) 5 | 6 | struct VertexShaderOutput 7 | { 8 | float4 color : COLOR; 9 | float2 texCoord : TEXCOORD0; 10 | float4 pos : SV_POSITION; 11 | }; 12 | 13 | //--------------------------------------------------------------- 14 | 15 | float4 main(VertexShaderOutput input) : SV_TARGET0 16 | { 17 | float4 color = input.color; 18 | 19 | #if (USE_TEXTURE > 0) 20 | color *= gTexture.Sample(gSampler, input.texCoord); 21 | #endif // (USE_TEXTURE > 0) 22 | 23 | return color; 24 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/FullScreenQuadVS.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexShaderInput 2 | { 3 | float3 Pos : POSITION; 4 | }; 5 | 6 | struct VertexShaderOutput 7 | { 8 | float4 Pos : SV_POSITION; 9 | }; 10 | 11 | VertexShaderOutput main(VertexShaderInput In) 12 | { 13 | VertexShaderOutput Out = (VertexShaderOutput)0; 14 | Out.Pos = float4(In.Pos, 1.0f); 15 | return Out; 16 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/GuiCommon.hlsl: -------------------------------------------------------------------------------- 1 | struct VS_INPUT_OUTPUT 2 | { 3 | float4 Rect : POSITION; 4 | float4 TexCoords : TEXCOORD0; 5 | float4 Color : TEXCOORD1; 6 | }; 7 | 8 | struct GS_OUT 9 | { 10 | float4 Pos : SV_POSITION; 11 | float2 TexCoord : TEXCOORD0; 12 | float4 Color : TEXCOORD1; 13 | }; -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/GuiPS.hlsl: -------------------------------------------------------------------------------- 1 | #include "GuiCommon.hlsl" 2 | 3 | #if (USE_TEXTURE > 0) 4 | Texture2D gTexture : register(t0); 5 | SamplerState gSampler : register(s0); 6 | #endif 7 | 8 | float4 main(GS_OUT In) : SV_TARGET0 9 | { 10 | float4 color = In.Color; 11 | 12 | #if (USE_TEXTURE == 1) // normal mode 13 | color *= gTexture.Sample(gSampler, In.TexCoord); 14 | #elif (USE_TEXTURE == 2) // alpha mode 15 | color.a *= gTexture.Sample(gSampler, In.TexCoord).r; 16 | #endif 17 | 18 | return color; 19 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/GuiVS.hlsl: -------------------------------------------------------------------------------- 1 | #include "GuiCommon.hlsl" 2 | 3 | // simple passthrough to the geometry shader 4 | VS_INPUT_OUTPUT main(VS_INPUT_OUTPUT input) 5 | { 6 | return input; 7 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/ImGuiPS.hlsl: -------------------------------------------------------------------------------- 1 | sampler gSampler : register(s0); 2 | Texture2D gTexture : register(t0); 3 | 4 | struct VertexShaderOutput 5 | { 6 | float4 pos : SV_POSITION; 7 | float2 uv : TEXCOORD0; 8 | float4 col : TEXCOORD1; 9 | }; 10 | 11 | float4 main(VertexShaderOutput input) : SV_Target 12 | { 13 | return input.col * gTexture.Sample(gSampler, input.uv); 14 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/ImGuiVS.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer VertexCBuffer : register(b0) 2 | { 3 | float4x4 gProjectionMatrix; 4 | }; 5 | 6 | struct VertexShaderInput 7 | { 8 | float2 pos : POSITION; 9 | float2 uv : TEXCOORD0; 10 | float4 col : TEXCOORD1; 11 | }; 12 | 13 | struct VertexShaderOutput 14 | { 15 | float4 pos : SV_POSITION; 16 | float2 uv : TEXCOORD0; 17 | float4 col : TEXCOORD1; 18 | }; 19 | 20 | VertexShaderOutput main(VertexShaderInput input) 21 | { 22 | VertexShaderOutput output; 23 | output.pos = mul(float4(input.pos.xy, 0.0f, 1.0f), gProjectionMatrix); 24 | output.col = input.col; 25 | output.uv = input.uv; 26 | return output; 27 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/LightCommon.hlsl: -------------------------------------------------------------------------------- 1 | cbuffer Global : register(b0) 2 | { 3 | float4x4 gCameraMatrix; 4 | float4x4 gViewMatrix; 5 | float4x4 gProjMatrix; 6 | float4 gViewportResInv; 7 | float4 gScreenScale; 8 | }; 9 | 10 | // Binding slot 1: g-buffer 11 | Texture2D gDepthTex : register(t0); 12 | Texture2D gGBufferTex0 : register(t1); 13 | Texture2D gGBufferTex1 : register(t2); 14 | Texture2D gGBufferTex2 : register(t3); 15 | Texture2D gGBufferTex3 : register(t4); 16 | 17 | struct VertexShaderInput 18 | { 19 | float3 pos : POSITION; 20 | }; 21 | 22 | struct VertexShaderOutput 23 | { 24 | float4 pos : SV_POSITION; 25 | float4 viewPos : POSITION; 26 | }; 27 | 28 | static float gMaxDepth = 10000.0f; 29 | static float gInfinityDist = 0.999999f; -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/OmniLightCommon.hlsl: -------------------------------------------------------------------------------- 1 | #include "LightCommon.hlsl" 2 | 3 | cbuffer OmniLightProps : register(b1) 4 | { 5 | float4 gLightPos; 6 | float4 gLightRadius; 7 | float4 gLightColor; 8 | float4 gShadowMapProps; // x = shadow map resolution inverse 9 | }; -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/OmniLightVS.hlsl: -------------------------------------------------------------------------------- 1 | #include "OmniLightCommon.hlsl" 2 | 3 | VertexShaderOutput main(VertexShaderInput input) 4 | { 5 | VertexShaderOutput output = (VertexShaderOutput)0; 6 | float4 worldPos = float4(gLightPos.xyz + input.pos * gLightRadius.x, 1.0f); 7 | output.viewPos = mul(worldPos, gViewMatrix); 8 | output.pos = mul(output.viewPos, gProjMatrix); 9 | return output; 10 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/ShadowCommon.hlsl: -------------------------------------------------------------------------------- 1 | struct VertexShaderOutput 2 | { 3 | float4 pos : SV_POSITION; 4 | float2 texCoord : TEXCOORD0; 5 | float4 screenPos : TEXCOORD1; 6 | float3 worldPos : TEXCOORD2; 7 | }; -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/ShadowPS.hlsl: -------------------------------------------------------------------------------- 1 | #include "ShadowCommon.hlsl" 2 | 3 | cbuffer Global : register(b0) 4 | { 5 | float4x4 gViewProjMatrix; 6 | float4 gLightPos; 7 | }; 8 | 9 | float main(VertexShaderOutput input) : SV_TARGET0 10 | { 11 | // TODO: alpha testing 12 | 13 | #if (CUBE_SHADOW_MAP > 0) 14 | float depth = length(input.worldPos - gLightPos.xyz); 15 | #else 16 | float depth = input.screenPos.z / input.screenPos.w; 17 | #endif 18 | 19 | // TODO: make it adjustable 20 | const float depthBias = 0.0001f; 21 | const float derivativeFactor = 2.0f; 22 | 23 | float dx = ddx(depth); 24 | float dy = ddy(depth); 25 | float depthDerivative = sqrt(dx*dx + dy*dy); 26 | 27 | return depth + depthBias + depthDerivative * derivativeFactor; 28 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/ShadowVS.hlsl: -------------------------------------------------------------------------------- 1 | #include "Common.hlsl" 2 | #include "ShadowCommon.hlsl" 3 | 4 | cbuffer Global : register(b0) 5 | { 6 | float4x4 gViewProjMatrix; 7 | float4 gLightPos; 8 | }; 9 | 10 | VertexShaderOutput main(MeshVertexShaderInput input) 11 | { 12 | VertexShaderOutput output; 13 | 14 | // decode world matrix 15 | float4x4 worldMatrix = transpose(float4x4(input.worldMat0, 16 | input.worldMat1, 17 | input.worldMat2, 18 | float4(0.0f, 0.0f, 0.0f, 1.0f))); 19 | 20 | float4 worldPos = mul(float4(input.pos, 1.0f), worldMatrix); 21 | output.pos = mul(worldPos, gViewProjMatrix); 22 | output.screenPos = output.pos; 23 | output.worldPos = worldPos.xyz; 24 | output.texCoord = input.texCoord; 25 | 26 | return output; 27 | } -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/SpotLightCommon.hlsl: -------------------------------------------------------------------------------- 1 | #include "LightCommon.hlsl" 2 | 3 | cbuffer SpotLightProps : register(b1) 4 | { 5 | float4 gLightPos; 6 | float4 gDirection; 7 | float4 gLightColor; 8 | float4 gFarDist; 9 | float4x4 gLightViewProjMatrix; 10 | float4x4 gLightViewProjMatrixInv; 11 | float4 gShadowMapProps; // x = shadow map resolution inverse 12 | }; -------------------------------------------------------------------------------- /Src/Shaders/HLSL5/SpotLightVS.hlsl: -------------------------------------------------------------------------------- 1 | #include "SpotLightCommon.hlsl" 2 | 3 | VertexShaderOutput main(VertexShaderInput input) 4 | { 5 | VertexShaderOutput output; 6 | 7 | // vertex position transformation 8 | float4 worldPos = mul(float4(input.pos, 1.0f), gLightViewProjMatrixInv); 9 | output.viewPos = mul(worldPos, gViewMatrix); 10 | output.pos = mul(output.viewPos, gProjMatrix); 11 | 12 | return output; 13 | } -------------------------------------------------------------------------------- /Src/Shaders/ImGuiPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Shaders/ImGuiVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Shaders/OmniLightPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | "macros": 4 | [ 5 | { "name": "USE_SHADOW_MAP", "min": 0, "max": 1, "default": 0 } 6 | ] 7 | } -------------------------------------------------------------------------------- /Src/Shaders/OmniLightVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Shaders/Sets/AmbientLight.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "FullScreenQuadVS" 2 | pixelShader = "AmbientLightPS" -------------------------------------------------------------------------------- /Src/Shaders/Sets/Debug.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "DebugVS" 2 | pixelShader = "DebugPS" 3 | 4 | macros = 5 | [ 6 | { 7 | name = "USE_TEXTURE" 8 | min = 0 9 | max = 0 10 | default = 0 11 | } 12 | 13 | { 14 | name = "IS_MESH" 15 | min = 0 16 | max = 0 17 | default = 0 18 | } 19 | ] 20 | -------------------------------------------------------------------------------- /Src/Shaders/Sets/GeometryPass.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "GeometryPassVS" 2 | pixelShader = "GeometryPassPS" 3 | 4 | macros = 5 | [ 6 | { 7 | name = "USE_MOTION_BLUR" 8 | min = 0 9 | max = 0 10 | default = 0 11 | } 12 | ] -------------------------------------------------------------------------------- /Src/Shaders/Sets/Gui.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "GuiVS" 2 | geometryShader = "GuiGS" 3 | pixelShader = "GuiPS" 4 | 5 | macros = 6 | [ 7 | { 8 | name = "USE_TEXTURE" 9 | min = 0 10 | max = 2 11 | default = 0 12 | } 13 | ] 14 | -------------------------------------------------------------------------------- /Src/Shaders/Sets/ImGui.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "ImGuiVS" 2 | pixelShader = "ImGuiPS" 3 | -------------------------------------------------------------------------------- /Src/Shaders/Sets/OmniLight.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "OmniLightVS" 2 | pixelShader = "OmniLightPS" 3 | macros = 4 | [ 5 | { 6 | name = "USE_SHADOW_MAP" 7 | min = 0 8 | max = 1 9 | default = 0 10 | } 11 | ] 12 | -------------------------------------------------------------------------------- /Src/Shaders/Sets/Shadow.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "ShadowVS" 2 | pixelShader = "ShadowPS" 3 | 4 | macros = 5 | [ 6 | { 7 | name = "CUBE_SHADOW_MAP" 8 | min = 0 9 | max = 1 10 | default = 0 11 | } 12 | ] -------------------------------------------------------------------------------- /Src/Shaders/Sets/SpotLight.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "SpotLightVS" 2 | pixelShader = "SpotLightPS" 3 | macros = 4 | [ 5 | { 6 | name = "USE_LIGHT_MAP" 7 | min = 0 8 | max = 1 9 | default = 0 10 | } 11 | 12 | { 13 | name = "USE_SHADOW_MAP" 14 | min = 0 15 | max = 1 16 | default = 0 17 | } 18 | ] -------------------------------------------------------------------------------- /Src/Shaders/Sets/Tonemapping.cfg: -------------------------------------------------------------------------------- 1 | vertexShader = "FullScreenQuadVS" 2 | pixelShader = "TonemappingPS" -------------------------------------------------------------------------------- /Src/Shaders/ShadowPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | "macros": 4 | [ 5 | { "name": "CUBE_SHADOW_MAP", "min": 0, "max": 1, "default": 0 } 6 | ] 7 | } -------------------------------------------------------------------------------- /Src/Shaders/ShadowVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Shaders/SpotLightPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | "macros": 4 | [ 5 | { "name": "USE_LIGHT_MAP", "min": 0, "max": 1, "default": 0 }, 6 | { "name": "USE_SHADOW_MAP", "min": 0, "max": 1, "default": 0 } 7 | ] 8 | } -------------------------------------------------------------------------------- /Src/Shaders/SpotLightVS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "vertex", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Shaders/TonemappingPS.json: -------------------------------------------------------------------------------- 1 | { 2 | "type": "pixel", 3 | "macros": [] 4 | } -------------------------------------------------------------------------------- /Src/Tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(NFE_TESTS_DIRECTORY ${NFE_SRC_DIRECTORY}/Tests) 2 | 3 | ADD_SUBDIRECTORY("CommonPerfTest") 4 | ADD_SUBDIRECTORY("CommonTest") 5 | #ADD_SUBDIRECTORY("RaytracerTests") 6 | ADD_SUBDIRECTORY("RendererTest") 7 | 8 | # Meta target to build all test apps 9 | ADD_CUSTOM_TARGET(Tests_All DEPENDS CommonTest CommonPerfTest RendererTest 10 | COMMENT "Build all tests and their dependencies" 11 | ) 12 | -------------------------------------------------------------------------------- /Src/Tests/CommonPerfTest/PCH.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Precompiled header source file 5 | */ 6 | 7 | #include "PCH.hpp" 8 | -------------------------------------------------------------------------------- /Src/Tests/CommonPerfTest/PCH.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Precompiled header 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include 11 | 12 | #include 13 | 14 | #if defined(NFE_PLATFORM_WINDOWS) 15 | #define WIN32_LEAN_AND_MEAN 16 | #define NOMINMAX 17 | #include 18 | #endif // defined(NFE_PLATFORM_WINDOWS) 19 | 20 | #include "gtest/gtest.h" 21 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/Constants.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "Constants.hpp" 3 | 4 | const NFE::Common::String gText("The quick brown fox jumps over the lazy dog"); 5 | const NFE::uint32 gTextSize = gText.Length(); 6 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/Constants.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Common/Containers/String.hpp" 4 | 5 | 6 | // BufferOutputStream and BufferInputStream constants 7 | extern const NFE::Common::String gText; 8 | extern const NFE::uint32 gTextSize; -------------------------------------------------------------------------------- /Src/Tests/CommonTest/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestCases/Containers/SharedPtrTest_Containers.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Unit tests for SharedPtr (when used with other containers) 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | #include "Engine/Common/Containers/SharedPtr.hpp" 10 | #include "Engine/Common/Containers/DynArray.hpp" 11 | 12 | using namespace NFE; 13 | using namespace NFE::Common; 14 | 15 | TEST(SharedPtr, SharedPtrOfSharedPtr) 16 | { 17 | using Type = SharedPtr; 18 | SharedPtr ptr = MakeSharedPtr(MakeSharedPtr(1)); 19 | 20 | ASSERT_EQ(1, **ptr); 21 | 22 | ptr->Reset(); 23 | ASSERT_EQ(*ptr, nullptr); 24 | 25 | ptr.Reset(); 26 | ASSERT_EQ(ptr, nullptr); 27 | } 28 | 29 | TEST(SharedPtr, SharedPtrOfDynArray) 30 | { 31 | using Type = DynArray; 32 | SharedPtr ptr = MakeSharedPtr(); 33 | 34 | ptr->PushBack(1); 35 | ASSERT_EQ(1u, ptr->Size()); 36 | 37 | ptr.Reset(); 38 | ASSERT_EQ(ptr, nullptr); 39 | } 40 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestCases/Containers/UniquePtrTest_Containers.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Witek902 (witek902@gmail.com) 4 | * @brief Unit tests for UniquePtr (when used with other containers) 5 | */ 6 | 7 | #include "PCH.hpp" 8 | 9 | #include "Engine/Common/Containers/UniquePtr.hpp" 10 | #include "Engine/Common/Containers/DynArray.hpp" 11 | 12 | using namespace NFE; 13 | using namespace NFE::Common; 14 | 15 | TEST(UniquePtr, UniquePtrOfUniquePtr) 16 | { 17 | using Type = UniquePtr; 18 | UniquePtr ptr = MakeUniquePtr(MakeUniquePtr(1)); 19 | 20 | ASSERT_EQ(1, **ptr); 21 | 22 | ptr->Reset(); 23 | ASSERT_EQ(*ptr, nullptr); 24 | 25 | ptr.Reset(); 26 | ASSERT_EQ(ptr, nullptr); 27 | } 28 | 29 | TEST(UniquePtr, UniquePtrOfDynArray) 30 | { 31 | using Type = DynArray; 32 | UniquePtr ptr = MakeUniquePtr(); 33 | 34 | ptr->PushBack(1); 35 | ASSERT_EQ(1u, ptr->Size()); 36 | 37 | ptr.Reset(); 38 | ASSERT_EQ(ptr, nullptr); 39 | } 40 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestCases/Math/RandomTest.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | #include "Engine/Common/Utils/Entropy.hpp" 3 | #include "Engine/Common/Math/Random.hpp" 4 | 5 | using namespace NFE; 6 | using namespace NFE::Math; 7 | 8 | ////////////////////////////////////////////////////////////////////////// 9 | 10 | TEST(RandomTest, Entropy) 11 | { 12 | Common::Entropy entropy; 13 | 14 | const uint32 iterations = 10000; 15 | 16 | uint64 sum = 0; 17 | for (uint32 i = 0; i < iterations; ++i) 18 | { 19 | sum += entropy.GetInt(); 20 | } 21 | 22 | EXPECT_GE(sum, 4900ull * (uint64)UINT32_MAX); 23 | EXPECT_LE(sum, 5100ull * (uint64)UINT32_MAX); 24 | } 25 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestCases/Utils/LatchTest.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author Lookey (costyrra.xl@gmail.com) 4 | * @brief Unit tests for Latch class. 5 | */ 6 | 7 | #include "PCH.hpp" 8 | #include "Engine/Common/Utils/Latch.hpp" 9 | #include "Engine/Common/System/Thread.hpp" 10 | 11 | 12 | namespace { 13 | const unsigned int TIMEOUT = 500; /* ms */ 14 | } // namespace 15 | 16 | using namespace NFE::Common; 17 | 18 | TEST(Latch, Wait) 19 | { 20 | Latch latch; 21 | Thread thread; 22 | 23 | ASSERT_TRUE(thread.Run([&latch]() { 24 | latch.Set(); 25 | })); 26 | 27 | thread.Wait(); 28 | latch.Wait(); 29 | } 30 | 31 | TEST(Latch, WaitFor) 32 | { 33 | Latch latch; 34 | Thread thread; 35 | 36 | ASSERT_TRUE(thread.Run([&latch]() { 37 | latch.Set(); 38 | })); 39 | 40 | thread.Wait(); 41 | ASSERT_TRUE(latch.Wait(TIMEOUT)); 42 | } 43 | 44 | TEST(Latch, Timeout) 45 | { 46 | Latch latch; 47 | ASSERT_FALSE(latch.Wait(TIMEOUT)); 48 | } 49 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # @file 2 | # @author Mkkulagowski (mk.kulagowski(at)gmail.com) 3 | # @brief CMake for TestResources 4 | 5 | ADD_SUBDIRECTORY("TestCalcLib") -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/SaveTests/textureJPG.jpg_saved.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/SaveTests/textureJPG.jpg_saved.jpg -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBC1.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBC1.dds -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBC1_MM.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBC1_MM.dds -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBC2.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBC2.dds -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBC3.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBC3.dds -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBC4.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBC4.dds -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBC5.dds: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBC5.dds -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP16ARGB.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP16ARGB.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP16RGB.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP16RGB.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP16XRGB.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP16XRGB.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP24.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP24.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP32ARGB.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP32ARGB.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP32XRGB.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP32XRGB.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP4.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP4.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP8.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureBMP8.bmp -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/textureJPG.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/textureJPG.jpg -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_GA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_GA.png -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGB.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGB.png -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGBA.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGBA.png -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGBA_interlaced.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGBA_interlaced.png -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGBA_palette.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nfprojects/nfengine/2b6b40835493d63c3908295c32f9ddc046ed01db/Src/Tests/CommonTest/TestResources/ImageSamples/texturePNG_RGBA_palette.png -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/TestCalcLib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # @file 2 | # @author Mkkulagowski (mk.kulagowski(at)gmail.com) 3 | # @brief CMake for TestCalcLib 4 | 5 | MESSAGE(STATUS "Generating build files for testCalcLib") 6 | 7 | SET(TESTCALCLIB_SOURCES 8 | TestCalcLib.cpp 9 | ) 10 | 11 | SET(TESTCALCLIB_HEADERS 12 | TestCalcLib.hpp 13 | ) 14 | 15 | # build shared lib 16 | ADD_LIBRARY(testCalcLib SHARED ${TESTCALCLIB_SOURCES} ${TESTCALCLIB_HEADERS}) 17 | 18 | TARGET_LINK_DIRECTORIES(testCalcLib 19 | PRIVATE ${NFCOMMONTEST_DIRECTORY} 20 | PRIVATE ${NFE_OUTPUT_DIRECTORY} 21 | ) 22 | 23 | TARGET_COMPILE_DEFINITIONS(testCalcLib 24 | PRIVATE TESTCALCDLL_EXPORTS 25 | ) 26 | 27 | SET_PROPERTY(TARGET testCalcLib PROPERTY FOLDER Src/Tests/TestResources) 28 | NFE_SOURCE_GROUP_BY_DIR(TESTCALCLIB_SOURCES) 29 | NFE_SOURCE_GROUP_BY_DIR(TESTCALCLIB_HEADERS) 30 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/TestCalcLib/TestCalcLib.cpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkkulagowski (mkulagowski(at)gmail.com) 4 | * @brief Definition of test library for LibraryTest 5 | */ 6 | 7 | #include "TestCalcLib.hpp" 8 | 9 | 10 | extern "C" int Add(int num1, int num2) 11 | { 12 | return num1 + num2; 13 | } 14 | 15 | extern "C" int Subtract(int num1, int num2) 16 | { 17 | return num1 - num2; 18 | } 19 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/TestCalcLib/TestCalcLib.hpp: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * @author mkkulagowski (mkulagowski(at)gmail.com) 4 | * @brief Implementation of test library for LibraryTest 5 | */ 6 | 7 | #pragma once 8 | 9 | #ifdef WIN32 10 | #ifdef TESTCALCDLL_EXPORTS 11 | #define TESTCALCDLL_API __declspec(dllexport) 12 | #else 13 | #define TESTCALCDLL_API __declspec(dllimport) 14 | #endif // TESTCALCDLL_EXPORTS 15 | 16 | #define WIN32_LEAN_AND_MEAN 17 | #define NOMINMAX 18 | #include 19 | #elif defined(__LINUX__) | defined(__linux__) 20 | #define TESTCALCDLL_API 21 | #endif // WIN32 22 | 23 | extern "C" TESTCALCDLL_API int Add(int num1, int num2); 24 | extern "C" TESTCALCDLL_API int Subtract(int num1, int num2); 25 | -------------------------------------------------------------------------------- /Src/Tests/CommonTest/TestResources/TestCalcLib/testCalcLib.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Src/Tests/RaytracerTests/Main.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" 2 | #include "../Core/Math/Math.h" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | rt::math::SetFlushDenormalsToZero(); 7 | 8 | testing::InitGoogleTest(&argc, argv); 9 | const int result = RUN_ALL_TESTS(); 10 | 11 | RT_ASSERT(rt::math::GetFlushDenormalsToZero(), "Something disabled flushing denormal float to zero"); 12 | 13 | return result; 14 | } 15 | -------------------------------------------------------------------------------- /Src/Tests/RaytracerTests/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.h" -------------------------------------------------------------------------------- /Src/Tests/RaytracerTests/PCH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #if defined(_DEBUG) && defined(WIN32) 4 | #define _CRTDBG_MAP_ALLOC 5 | #include 6 | #include 7 | #endif // _DEBUG 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "gtest/gtest.h" 18 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/PCH.cpp: -------------------------------------------------------------------------------- 1 | #include "PCH.hpp" 2 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/PCH.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // enable memory allocation tracking (Windows only) 4 | #if defined(NFE_PLATFORM_WINDOWS) && defined(NFE_CONFIGURATION_DEBUG) 5 | #define _CRTDBG_MAP_ALLOC 6 | #include 7 | #include 8 | #endif // defined(NFE_PLATFORM_WINDOWS) && defined(NFE_CONFIGURATION_DEBUG) 9 | 10 | #if defined(NFE_PLATFORM_WINDOWS) 11 | #define WIN32_LEAN_AND_MEAN 12 | #define NOMINMAX 13 | #include 14 | #endif // defined(NFE_PLATFORM_WINDOWS) 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #include "gtest/gtest.h" 21 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/RendererTest.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Engine/Renderers/RendererCommon/Device.hpp" 4 | #include "Engine/Common/System/Library.hpp" 5 | 6 | 7 | using namespace NFE; 8 | using namespace NFE::Renderer; 9 | 10 | class RendererTest : public testing::Test 11 | { 12 | protected: 13 | // prepare test case environment - initialize the renderer 14 | static void SetUpTestCase(); 15 | 16 | // prepare test case environment - release the renderer 17 | static void TearDownTestCase(); 18 | 19 | static Common::Library gRendererLib; 20 | static IDevice* gRendererDevice; 21 | static CommandQueuePtr gMainCommandQueue; 22 | static CommandQueuePtr gComputeCommandQueue; 23 | static CommandQueuePtr gCopyCommandQueue; 24 | 25 | public: 26 | ~RendererTest() { } 27 | }; 28 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/Shaders/GLSL/Simple.glsl: -------------------------------------------------------------------------------- 1 | layout (location=0) in vec3 InPos; 2 | layout (location=1) in vec4 InColor; 3 | layout (location=2) in vec2 InTexCoord; 4 | 5 | out VS_OUTPUT 6 | { 7 | vec4 Color; 8 | } Output; 9 | 10 | out gl_PerVertex 11 | { 12 | vec4 gl_Position; 13 | }; 14 | 15 | layout (row_major,binding=1) uniform TestCBuffer 16 | { 17 | mat4 viewMatrix; 18 | }; 19 | 20 | layout (binding=3) uniform sampler2D TestTexture; // just for IODesc test 21 | 22 | layout (binding=5) uniform sampler2D TestSampler; 23 | 24 | void main() 25 | { 26 | gl_Position = vec4(InPos, 1.0f); 27 | gl_Position = gl_Position * viewMatrix; 28 | Output.Color = InColor * texture2D(TestSampler, InTexCoord); 29 | } 30 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/Shaders/HLSL5/Simple.hlsl: -------------------------------------------------------------------------------- 1 | struct VS_IN 2 | { 3 | float3 Pos : POSITION; 4 | float4 Color : TEXCOORD0; 5 | float2 TexCoord : TEXCOORD1; 6 | }; 7 | 8 | struct VS_OUTPUT 9 | { 10 | float4 Color : TEXCOORD0; 11 | float4 Pos : SV_POSITION; 12 | }; 13 | 14 | cbuffer TestCBuffer : register(b1) 15 | { 16 | float4x4 viewMatrix; 17 | }; 18 | 19 | Texture2D TestTexture : register(t3); 20 | SamplerState TestSampler : register(s3); 21 | 22 | VS_OUTPUT main(VS_IN In) 23 | { 24 | VS_OUTPUT Out = (VS_OUTPUT)0; 25 | Out.Pos = float4(In.Pos, 1.0f); 26 | Out.Pos = mul(Out.Pos, viewMatrix); 27 | Out.Color = In.Color * TestTexture.SampleLevel(TestSampler, In.TexCoord, 0); 28 | return Out; 29 | } 30 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/Shaders/HLSL5/SimpleDrawPS.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef USE_TEXTURE 2 | #define USE_TEXTURE 0 3 | #endif 4 | 5 | #if (USE_TEXTURE > 0) 6 | Texture2D gTexture : register(t0); 7 | SamplerState gSampler : register(s0); 8 | #endif 9 | 10 | struct VertexShaderOutput 11 | { 12 | float2 TexCoord : TEXCOORD0; 13 | float4 Color : TEXCOORD1; 14 | }; 15 | 16 | float4 main(VertexShaderOutput input) : SV_TARGET0 17 | { 18 | #if (USE_TEXTURE > 0) 19 | return input.Color * gTexture.Sample(gSampler, In.TexCoord); 20 | #else 21 | return input.Color; 22 | #endif 23 | } 24 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/Shaders/HLSL5/SimpleDrawVS.hlsl: -------------------------------------------------------------------------------- 1 | #ifndef USE_CBUFFER 2 | #define USE_CBUFFER 0 3 | #endif 4 | 5 | #if (USE_CBUFFER > 0) 6 | cbuffer TestCBuffer : register(b0) 7 | { 8 | float4 CBufferColor; 9 | }; 10 | #endif 11 | 12 | struct VertexShaderInput 13 | { 14 | float3 Pos : POSITION; 15 | float2 TexCoord : TEXCOORD0; 16 | float4 Color : TEXCOORD1; 17 | }; 18 | 19 | struct VertexShaderOutput 20 | { 21 | float2 TexCoord : TEXCOORD0; 22 | float4 Color : TEXCOORD1; 23 | float4 Pos : SV_POSITION; 24 | }; 25 | 26 | VertexShaderOutput main(VertexShaderInput input) 27 | { 28 | VertexShaderOutput output; 29 | output.Pos = float4(input.Pos, 1.0f); 30 | output.TexCoord = input.TexCoord; 31 | output.Color = input.Color; 32 | 33 | #if (USE_CBUFFER > 0) 34 | output.Color *= CBufferColor; 35 | #endif 36 | 37 | return output; 38 | } 39 | -------------------------------------------------------------------------------- /Src/Tests/RendererTest/TestCases/CommandBuffer.cpp: -------------------------------------------------------------------------------- 1 | #include "../PCH.hpp" 2 | #include "../RendererTest.hpp" 3 | 4 | #include "Engine/Renderers/RendererCommon/CommandRecorder.hpp" 5 | #include "Engine/Renderers/RendererCommon/Fence.hpp" 6 | 7 | class CommandList : public RendererTest 8 | { 9 | public: 10 | CommandRecorderPtr commandRecorder; 11 | 12 | private: 13 | void SetUp() override 14 | { 15 | commandRecorder = gRendererDevice->CreateCommandRecorder(); 16 | ASSERT_NE(nullptr, commandRecorder.Get()); 17 | } 18 | 19 | void TearDown() override 20 | { 21 | commandRecorder.Reset(); 22 | gMainCommandQueue->Signal()->Wait(); 23 | } 24 | }; 25 | 26 | TEST_F(CommandList, ResetAndFinish) 27 | { 28 | commandRecorder->Begin(CommandQueueType::Graphics); 29 | 30 | const CommandListPtr commandList = commandRecorder->Finish(); 31 | ASSERT_NE(commandList, nullptr); 32 | 33 | gMainCommandQueue->Execute(commandList); 34 | } -------------------------------------------------------------------------------- /Src/Tests/RendererTest/TestCases/Shader.cpp: -------------------------------------------------------------------------------- 1 | #include "../PCH.hpp" 2 | #include "../Backends.hpp" 3 | #include "../RendererTest.hpp" 4 | 5 | using namespace NFE::Common; 6 | 7 | class ShaderTest : public RendererTest 8 | { 9 | }; 10 | 11 | TEST_F(ShaderTest, Disassemble) 12 | { 13 | const String shaderPath = gShaderPathPrefix + "Simple" + gShaderPathExt; 14 | 15 | ShaderDesc desc; 16 | desc.path = shaderPath.Str(); 17 | desc.type = ShaderType::Vertex; 18 | 19 | /// compile shader 20 | ShaderPtr shader; 21 | shader = gRendererDevice->CreateShader(desc); 22 | ASSERT_TRUE(shader != nullptr); 23 | 24 | String disasm; 25 | ASSERT_TRUE(shader->Disassemble(false, disasm)); 26 | EXPECT_TRUE(disasm.Length() > 0); 27 | } 28 | --------------------------------------------------------------------------------