├── .gitattributes ├── .gitignore ├── LICENSE ├── README.md ├── ToyBox.sln └── ToyBox ├── AssetLoader.h ├── Assets ├── Models │ ├── box_stack.mtl │ ├── bunny.mtl │ ├── imgui.ini │ └── teapot.mtl ├── Others │ ├── fad.png │ ├── moon.jpg │ ├── moonnn.jpg │ ├── pbr-result.png │ ├── sc01.jpg │ ├── sc02.jpg │ ├── sc03.jpg │ ├── v02 (1).png │ ├── v02 (2).png │ ├── v02 (3).png │ ├── v02 (4).png │ ├── v02 (5).png │ ├── v02 (6).png │ ├── v02 (7).png │ ├── v02 (8).png │ ├── v02 (9).png │ └── worley.jpg └── Textures │ ├── AO.png │ ├── CubeMap │ ├── Sky1 │ │ ├── sback37.jpg │ │ ├── sfront37.jpg │ │ ├── sleft37.jpg │ │ ├── sright37.jpg │ │ └── stop37.jpg │ ├── Sky10 │ │ ├── backsnowe.jpg │ │ ├── frontsnowe.jpg │ │ ├── leftsnowe.jpg │ │ ├── rightsnowe.jpg │ │ └── topsnowe.jpg │ ├── Sky11 │ │ ├── back.jpg │ │ ├── front.jpg │ │ ├── left.jpg │ │ ├── right.jpg │ │ └── up.jpg │ ├── Sky12 │ │ ├── backax2.jpg │ │ ├── frontax2.jpg │ │ ├── leftax2.jpg │ │ ├── rightax2.jpg │ │ └── topax2.jpg │ ├── Sky13 │ │ ├── back55.jpg │ │ ├── front55.jpg │ │ ├── left55.jpg │ │ ├── right55.jpg │ │ └── top55.jpg │ ├── Sky14 │ │ ├── back1h.jpg │ │ ├── front1h.jpg │ │ ├── left1h.jpg │ │ ├── right1h.jpg │ │ └── top1h.jpg │ ├── Sky15 │ │ ├── backsa3.jpg │ │ ├── frontsa3.jpg │ │ ├── leftsa3.jpg │ │ ├── rightsa3.jpg │ │ └── topsa3.jpg │ ├── Sky16 │ │ ├── backw3.jpg │ │ ├── frontw3.jpg │ │ ├── leftw3.jpg │ │ ├── rightw3.jpg │ │ └── topw3.jpg │ ├── Sky17 │ │ ├── dsback.jpg │ │ ├── dsfront.jpg │ │ ├── dsleft.jpg │ │ ├── dsright.jpg │ │ └── dstop.jpg │ ├── Sky18 │ │ ├── backred2.jpg │ │ ├── frontred2.jpg │ │ ├── leftred2.jpg │ │ ├── rightred2.jpg │ │ └── topred2.jpg │ ├── Sky2 │ │ ├── oback7.jpg │ │ ├── ofront7.jpg │ │ ├── oleft7.jpg │ │ ├── oright7.jpg │ │ └── otop7.jpg │ ├── Sky3 │ │ ├── oback6.jpg │ │ ├── ofront6.jpg │ │ ├── oleft6.jpg │ │ ├── oright6.jpg │ │ └── otop6.jpg │ ├── Sky4 │ │ ├── oback1.jpg │ │ ├── ofront1.jpg │ │ ├── oleft1.jpg │ │ ├── oright1.jpg │ │ └── otop1.jpg │ ├── Sky5 │ │ ├── oback18.jpg │ │ ├── ofront18.jpg │ │ ├── oleft18.jpg │ │ ├── oright18.jpg │ │ └── otop18.jpg │ ├── Sky6 │ │ ├── oback19.jpg │ │ ├── ofront19.jpg │ │ ├── oleft19.jpg │ │ ├── oright19.jpg │ │ └── otop19.jpg │ ├── Sky7 │ │ ├── backaw2.jpg │ │ ├── frontaw2.jpg │ │ ├── leftaw2.jpg │ │ ├── rightaw2.jpg │ │ └── topaw2.jpg │ ├── Sky8 │ │ ├── back62.jpg │ │ ├── front62.jpg │ │ ├── left62.jpg │ │ ├── right62.jpg │ │ └── top62.jpg │ └── Sky9 │ │ ├── backsnow1.jpg │ │ ├── frontsnow1.jpg │ │ ├── leftsnow1.jpg │ │ ├── rightsnow1.jpg │ │ └── topsnow1.jpg │ ├── HDRI │ ├── DS360_041_Extra_Env.hdr │ ├── DS360_041_Extra_Ref.hdr │ ├── HDR_029_Sky_Cloudy_Env.hdr │ ├── HDR_029_Sky_Cloudy_Ref.hdr │ ├── Newport_Loft_Env.hdr │ └── Newport_Loft_Ref.hdr │ ├── LUTs │ ├── FilmLut.tga │ ├── KelemenLUT.png │ ├── SSSLUT.png │ └── ibl_brdf_lut.png │ ├── LensDirt │ ├── LensDirt00.png │ ├── LensDirt01.png │ ├── LensDirt02.png │ └── LensDirt03.png │ ├── MatCap │ ├── matcap.jpg │ ├── matcap2.jpg │ ├── matcap3.jpg │ ├── matcap4.jpg │ ├── matcap5.jpg │ ├── matcap6.jpg │ └── matcap7.jpg │ ├── albedo.png │ ├── metallic.png │ ├── normal.png │ ├── rough_normal.jpg │ └── roughness.png ├── BRDF.fs ├── BRDF.vs ├── BVH.h ├── BasicRayMarching.fs ├── BlinnPhong.fs ├── Bloom.fs ├── BlurEffects.fs ├── Bokeh.fs ├── Bone.h ├── BoundingBox.h ├── Box.cpp ├── Box.h ├── ButtonEx.cpp ├── ButtonEx.h ├── CNN.h ├── CakeParser.h ├── Camera.cpp ├── Camera.h ├── Capsule.cpp ├── Capsule.h ├── Chromatic.fs ├── Cloud.fs ├── CodeEditor.h ├── Color.h ├── ColorCorrection.fs ├── ColorSpace.fs ├── ConstColor.fs ├── ConstColor.vs ├── Coroutine.cpp ├── Coroutine.h ├── Curve.fs ├── Curves.h ├── Cylinder.cpp ├── Cylinder.h ├── DOF_MultiPass.fs ├── Debugger.cpp ├── Debugger.h ├── DepthOfField.fs ├── Dummy.h ├── EnvSphere.fs ├── EnvSphere.vs ├── Exposure.fs ├── FBM.fs ├── FNN.h ├── FXAA.fs ├── FileManager.h ├── FireGenerator.fs ├── Flare.fs ├── Flat.fs ├── Flat.vs ├── FlowMenu.cpp ├── FlowMenu.h ├── FuzzyMatch.h ├── GBufferRender.fs ├── GBufferRenderer.fs ├── GNN.h ├── Galaxy.fs ├── GaussianBlur.fs ├── Gizmo.cpp ├── Gizmo.h ├── Graphics.cpp ├── Graphics.h ├── HalfMesh.cpp ├── HalfMesh.h ├── HeightToNormal.fs ├── Helper.h ├── HelperBase.h ├── Helpers.h ├── Hitable.h ├── HotkeyMgr.cpp ├── HotkeyMgr.h ├── IRMapGen.fs ├── IRMapGen.vs ├── Icons.h ├── IconsFontAwesome4.h ├── ImGradient.cpp ├── ImGradient.h ├── ImPie.cpp ├── ImPie.h ├── ImTextEditor.cpp ├── ImTextEditor.h ├── ImTimeline.cpp ├── ImTimeline.h ├── LR.h ├── Levels.fs ├── Light.cpp ├── Light.h ├── MOON.fs ├── MShader.cpp ├── MShader.h ├── Margins.fs ├── MatSphere.h ├── Material.cpp ├── Material.h ├── MaterialEditor.cpp ├── MaterialEditor.h ├── MathUtils.cpp ├── MathUtils.h ├── Matrix.h ├── Matrix3x3.h ├── Matrix4x4.h ├── Mesh.cpp ├── Mesh.h ├── Model.cpp ├── Model.h ├── MoonEnums.h ├── NFunction.cpp ├── NFunction.h ├── NGraph.cpp ├── NGraph.h ├── NNBase.h ├── NNManager.cpp ├── NNManager.h ├── NVariable.h ├── NativeOperators.cpp ├── NativeOperators.h ├── Neuron.cpp ├── Neuron.h ├── NodeEditorBase.cpp ├── NodeEditorBase.h ├── NoiseGenerator.fs ├── OBJExporter.cpp ├── OBJLoader.cpp ├── OBJMgr.h ├── OP_MeshEditor.h ├── ObjectBase.cpp ├── ObjectBase.h ├── OperatorBase.h ├── OperatorLoader.h ├── OperatorMgr.cpp ├── OperatorMgr.h ├── Optimizer.cpp ├── Optimizer.h ├── Outline.fs ├── Outline.vs ├── PBR.fs ├── PBR.vs ├── PBR_Diff.fs ├── PBR_Ref.fs ├── PMapGen.h ├── PatternGenerator.fs ├── PipelineMgr.cpp ├── PipelineMgr.h ├── Pixelization.fs ├── Plane.cpp ├── Plane.h ├── Plotter.h ├── PluginManager.h ├── PluginMgr.h ├── PostEffects.cpp ├── PostEffects.h ├── PostFactory.cpp ├── PostFactory.h ├── PreInclude.h ├── PreIntegerSSS.fs ├── Prefilter.fs ├── ProceduralMap.cpp ├── ProceduralMap.h ├── Proxy.h ├── Quaternion.cpp ├── Quaternion.h ├── RFX_Solver.h ├── RNN.h ├── Ray.h ├── Renderer.cpp ├── Renderer.h ├── Resources ├── Icon.jpg ├── Icon_fullSize.jpg ├── Icon_fullSize.png ├── MaterialIcons-Regular.ttf ├── fontaudio.ttf ├── fontawesome-webfont.ttf ├── kenney-icon-font.ttf ├── logo.png └── msyh.ttc ├── Ring.cpp ├── Ring.h ├── SEM.fs ├── SEM.vs ├── SEM_Phong.fs ├── SEM_Phong.vs ├── SM_Solver.h ├── SSAO.fs ├── SSR.fs ├── SceneMgr.h ├── ScreenBlend.fs ├── ScreenBuffer.fs ├── ScreenBuffer.vs ├── ShapeBase.h ├── Shapes.h ├── SimplePhong.fs ├── SimplePhong.vs ├── SmartMeshes.h ├── Sphere.cpp ├── Sphere.h ├── SphericalSampling.fs ├── Spline.h ├── StackWindow.h ├── Starry.cpp ├── Starry.h ├── Strutil.h ├── Tape.h ├── TextMesh.h ├── Texture.h ├── ThreadPool.h ├── ToneMapping.fs ├── ToyBox.vcxproj ├── ToyBox.vcxproj.filters ├── Transform.h ├── UIController.h ├── Utility.cpp ├── Utility.h ├── VFB.cpp ├── VFB.h ├── Vector2.cpp ├── Vector2.h ├── Vector3.cpp ├── Vector3.h ├── Vector4.cpp ├── Vector4.h ├── VertexID.fs ├── VertexID.vs ├── Vignette.fs ├── Volume.cpp ├── Volume.h ├── WideNDeep.h ├── WinDiagHandler.h ├── fontHeaders ├── IconsFontAwesome4.h ├── IconsFontaudio.h ├── IconsKenney.h └── IconsMaterialDesign.h ├── imgui.ini ├── imgui ├── ImNodes.cpp ├── ImNodes.h ├── ImNodesEz.cpp ├── ImNodesEz.h ├── ImPlot.cpp ├── ImPlot.h ├── imconfig.h ├── imgui.cpp ├── imgui.h ├── imgui_demo.cpp ├── imgui_draw.cpp ├── imgui_impl_glfw.cpp ├── imgui_impl_glfw.h ├── imgui_impl_opengl3.cpp ├── imgui_impl_opengl3.h ├── imgui_internal.h ├── imgui_widgets.cpp ├── imstb_rectpack.h ├── imstb_textedit.h ├── imstb_truetype.h └── misc │ ├── README.txt │ ├── cpp │ ├── README.txt │ ├── imgui_stdlib.cpp │ └── imgui_stdlib.h │ ├── fonts │ ├── Cousine-Regular.ttf │ ├── DroidSans.ttf │ ├── Karla-Regular.ttf │ ├── ProggyClean.ttf │ ├── ProggyTiny.ttf │ ├── Roboto-Medium.ttf │ ├── binary_to_compressed_c.cpp │ └── fontawesome-webfont.ttf │ ├── freetype │ ├── README.md │ ├── imgui_freetype.cpp │ └── imgui_freetype.h │ ├── natvis │ ├── README.txt │ └── imgui.natvis │ └── single_file │ └── imgui_single_file.h ├── imgui_backup.ini ├── mNoise.fs ├── main.cpp ├── opengl ├── include │ ├── GLFW │ │ ├── glfw3.h │ │ └── glfw3native.h │ ├── KHR │ │ └── khrplatform.h │ ├── STB │ │ ├── stb_image.h │ │ └── stb_image_write.h │ ├── glad │ │ └── glad.h │ └── stb_image.h ├── lib │ ├── OpenGL32.Lib │ ├── glfw3.dll │ ├── glfw3.lib │ └── glfw3dll.lib └── src │ └── glad.c ├── packages.config ├── properties.h └── pthreadVC2.dll /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 RIP 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /ToyBox.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28010.2026 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToyBox", "ToyBox\ToyBox.vcxproj", "{1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|x64 = Debug|x64 11 | Debug|x86 = Debug|x86 12 | Release|x64 = Release|x64 13 | Release|x86 = Release|x86 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Debug|x64.ActiveCfg = Debug|x64 17 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Debug|x64.Build.0 = Debug|x64 18 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Debug|x86.ActiveCfg = Debug|Win32 19 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Debug|x86.Build.0 = Debug|Win32 20 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Release|x64.ActiveCfg = Release|x64 21 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Release|x64.Build.0 = Release|x64 22 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Release|x86.ActiveCfg = Release|Win32 23 | {1E1D6DCC-53B9-46EA-9597-322CBD4DF97D}.Release|x86.Build.0 = Release|Win32 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {A4A07963-002E-4786-9BC5-C363708C111B} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /ToyBox/Assets/Models/box_stack.mtl: -------------------------------------------------------------------------------- 1 | # Blender MTL File: 'box_stack.blend' 2 | # Material Count: 3 3 | 4 | newmtl mat_bot 5 | Ns 96.078431 6 | Ka 1.000000 1.000000 1.000000 7 | Kd 0.640000 0.640000 0.640000 8 | Ks 0.500000 0.500000 0.500000 9 | Ke 0.000000 0.000000 0.000000 10 | Ni 1.000000 11 | d 1.000000 12 | illum 2 13 | 14 | newmtl mat_mid 15 | Ns 96.078431 16 | Ka 1.000000 1.000000 1.000000 17 | Kd 0.640000 0.640000 0.640000 18 | Ks 0.500000 0.500000 0.500000 19 | Ke 0.000000 0.000000 0.000000 20 | Ni 1.000000 21 | d 1.000000 22 | illum 2 23 | 24 | newmtl mat_top 25 | Ns 96.078431 26 | Ka 1.000000 1.000000 1.000000 27 | Kd 0.640000 0.640000 0.640000 28 | Ks 0.500000 0.500000 0.500000 29 | Ke 0.000000 0.000000 0.000000 30 | Ni 1.000000 31 | d 1.000000 32 | illum 2 33 | -------------------------------------------------------------------------------- /ToyBox/Assets/Models/bunny.mtl: -------------------------------------------------------------------------------- 1 | # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware 2 | # File Created: 27.03.2020 12:18:22 3 | 4 | newmtl bunnyMat 5 | Ns 10.0000 6 | Ni 1.5000 7 | d 1.0000 8 | Tr 0.0000 9 | Tf 1.0000 1.0000 1.0000 10 | illum 2 11 | Ka 0.5880 0.5880 0.5880 12 | Kd 0.5880 0.5880 0.5880 13 | Ks 0.0000 0.0000 0.0000 14 | Ke 0.0000 0.0000 0.0000 15 | -------------------------------------------------------------------------------- /ToyBox/Assets/Models/teapot.mtl: -------------------------------------------------------------------------------- 1 | # 3ds Max Wavefront OBJ Exporter v0.97b - (c)2007 guruware 2 | # File Created: 09.12.2019 16:38:36 3 | 4 | newmtl wire_135110008 5 | Ns 32 6 | d 1 7 | Tr 0 8 | Tf 1 1 1 9 | illum 2 10 | Ka 0.5294 0.4314 0.0314 11 | Kd 0.5294 0.4314 0.0314 12 | Ks 0.3500 0.3500 0.3500 13 | -------------------------------------------------------------------------------- /ToyBox/Assets/Others/fad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/fad.png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/moon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/moon.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Others/moonnn.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/moonnn.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Others/pbr-result.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/pbr-result.png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/sc01.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/sc01.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Others/sc02.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/sc02.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Others/sc03.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/sc03.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (1).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (1).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (2).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (2).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (3).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (3).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (4).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (4).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (5).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (5).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (6).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (6).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (7).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (7).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (8).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (8).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/v02 (9).png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/v02 (9).png -------------------------------------------------------------------------------- /ToyBox/Assets/Others/worley.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Others/worley.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/AO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/AO.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky1/sback37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky1/sback37.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky1/sfront37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky1/sfront37.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky1/sleft37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky1/sleft37.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky1/sright37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky1/sright37.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky1/stop37.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky1/stop37.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky10/backsnowe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky10/backsnowe.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky10/frontsnowe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky10/frontsnowe.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky10/leftsnowe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky10/leftsnowe.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky10/rightsnowe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky10/rightsnowe.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky10/topsnowe.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky10/topsnowe.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky11/back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky11/back.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky11/front.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky11/front.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky11/left.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky11/left.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky11/right.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky11/right.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky11/up.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky11/up.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky12/backax2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky12/backax2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky12/frontax2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky12/frontax2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky12/leftax2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky12/leftax2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky12/rightax2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky12/rightax2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky12/topax2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky12/topax2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky13/back55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky13/back55.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky13/front55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky13/front55.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky13/left55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky13/left55.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky13/right55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky13/right55.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky13/top55.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky13/top55.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky14/back1h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky14/back1h.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky14/front1h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky14/front1h.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky14/left1h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky14/left1h.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky14/right1h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky14/right1h.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky14/top1h.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky14/top1h.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky15/backsa3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky15/backsa3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky15/frontsa3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky15/frontsa3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky15/leftsa3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky15/leftsa3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky15/rightsa3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky15/rightsa3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky15/topsa3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky15/topsa3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky16/backw3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky16/backw3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky16/frontw3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky16/frontw3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky16/leftw3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky16/leftw3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky16/rightw3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky16/rightw3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky16/topw3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky16/topw3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky17/dsback.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky17/dsback.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky17/dsfront.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky17/dsfront.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky17/dsleft.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky17/dsleft.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky17/dsright.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky17/dsright.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky17/dstop.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky17/dstop.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky18/backred2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky18/backred2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky18/frontred2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky18/frontred2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky18/leftred2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky18/leftred2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky18/rightred2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky18/rightred2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky18/topred2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky18/topred2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky2/oback7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky2/oback7.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky2/ofront7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky2/ofront7.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky2/oleft7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky2/oleft7.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky2/oright7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky2/oright7.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky2/otop7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky2/otop7.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky3/oback6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky3/oback6.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky3/ofront6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky3/ofront6.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky3/oleft6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky3/oleft6.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky3/oright6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky3/oright6.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky3/otop6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky3/otop6.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky4/oback1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky4/oback1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky4/ofront1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky4/ofront1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky4/oleft1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky4/oleft1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky4/oright1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky4/oright1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky4/otop1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky4/otop1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky5/oback18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky5/oback18.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky5/ofront18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky5/ofront18.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky5/oleft18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky5/oleft18.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky5/oright18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky5/oright18.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky5/otop18.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky5/otop18.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky6/oback19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky6/oback19.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky6/ofront19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky6/ofront19.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky6/oleft19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky6/oleft19.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky6/oright19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky6/oright19.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky6/otop19.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky6/otop19.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky7/backaw2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky7/backaw2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky7/frontaw2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky7/frontaw2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky7/leftaw2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky7/leftaw2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky7/rightaw2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky7/rightaw2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky7/topaw2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky7/topaw2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky8/back62.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky8/back62.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky8/front62.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky8/front62.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky8/left62.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky8/left62.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky8/right62.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky8/right62.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky8/top62.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky8/top62.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky9/backsnow1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky9/backsnow1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky9/frontsnow1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky9/frontsnow1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky9/leftsnow1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky9/leftsnow1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky9/rightsnow1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky9/rightsnow1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/CubeMap/Sky9/topsnow1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/CubeMap/Sky9/topsnow1.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/HDRI/DS360_041_Extra_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/HDRI/DS360_041_Extra_Env.hdr -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/HDRI/DS360_041_Extra_Ref.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/HDRI/DS360_041_Extra_Ref.hdr -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/HDRI/HDR_029_Sky_Cloudy_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/HDRI/HDR_029_Sky_Cloudy_Env.hdr -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/HDRI/HDR_029_Sky_Cloudy_Ref.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/HDRI/HDR_029_Sky_Cloudy_Ref.hdr -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/HDRI/Newport_Loft_Env.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/HDRI/Newport_Loft_Env.hdr -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/HDRI/Newport_Loft_Ref.hdr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/HDRI/Newport_Loft_Ref.hdr -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LUTs/FilmLut.tga: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LUTs/FilmLut.tga -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LUTs/KelemenLUT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LUTs/KelemenLUT.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LUTs/SSSLUT.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LUTs/SSSLUT.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LUTs/ibl_brdf_lut.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LUTs/ibl_brdf_lut.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LensDirt/LensDirt00.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LensDirt/LensDirt00.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LensDirt/LensDirt01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LensDirt/LensDirt01.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LensDirt/LensDirt02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LensDirt/LensDirt02.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/LensDirt/LensDirt03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/LensDirt/LensDirt03.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/MatCap/matcap.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/MatCap/matcap.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/MatCap/matcap2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/MatCap/matcap2.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/MatCap/matcap3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/MatCap/matcap3.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/MatCap/matcap4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/MatCap/matcap4.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/MatCap/matcap5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/MatCap/matcap5.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/MatCap/matcap6.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/MatCap/matcap6.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/MatCap/matcap7.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/MatCap/matcap7.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/albedo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/albedo.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/metallic.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/metallic.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/normal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/normal.png -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/rough_normal.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/rough_normal.jpg -------------------------------------------------------------------------------- /ToyBox/Assets/Textures/roughness.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Assets/Textures/roughness.png -------------------------------------------------------------------------------- /ToyBox/BRDF.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec2 FragColor; 3 | in vec2 TexCoords; 4 | 5 | const float PI = 3.14159265359; 6 | 7 | // http://holger.dammertz.org/stuff/notes_HammersleyOnHemisphere.html 8 | // efficient VanDerCorpus calculation. 9 | float RadicalInverse_VdC(uint bits) { 10 | bits = (bits << 16u) | (bits >> 16u); 11 | bits = ((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u); 12 | bits = ((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u); 13 | bits = ((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u); 14 | bits = ((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u); 15 | return float(bits) * 2.3283064365386963e-10; // / 0x100000000 16 | } 17 | 18 | vec2 Hammersley(uint i, uint N) { 19 | return vec2(float(i)/float(N), RadicalInverse_VdC(i)); 20 | } 21 | 22 | vec3 ImportanceSampleGGX(vec2 Xi, vec3 N, float roughness) { 23 | float a = roughness*roughness; 24 | 25 | float phi = 2.0 * PI * Xi.x; 26 | float cosTheta = sqrt((1.0 - Xi.y) / (1.0 + (a*a - 1.0) * Xi.y)); 27 | float sinTheta = sqrt(1.0 - cosTheta*cosTheta); 28 | 29 | // from spherical coordinates to cartesian coordinates - halfway vector 30 | vec3 H; 31 | H.x = cos(phi) * sinTheta; 32 | H.y = sin(phi) * sinTheta; 33 | H.z = cosTheta; 34 | 35 | // from tangent-space H vector to world-space sample vector 36 | vec3 up = abs(N.z) < 0.999 ? vec3(0.0, 0.0, 1.0) : vec3(1.0, 0.0, 0.0); 37 | vec3 tangent = normalize(cross(up, N)); 38 | vec3 bitangent = cross(N, tangent); 39 | 40 | vec3 sampleVec = tangent * H.x + bitangent * H.y + N * H.z; 41 | return normalize(sampleVec); 42 | } 43 | 44 | float GeometrySchlickGGX(float NdotV, float roughness) { 45 | // note that we use a different k for IBL 46 | float a = roughness; 47 | float k = (a * a) / 2.0; 48 | 49 | float nom = NdotV; 50 | float denom = NdotV * (1.0 - k) + k; 51 | 52 | return nom / denom; 53 | } 54 | 55 | float GeometrySmith(vec3 N, vec3 V, vec3 L, float roughness) { 56 | float NdotV = max(dot(N, V), 0.0); 57 | float NdotL = max(dot(N, L), 0.0); 58 | float ggx2 = GeometrySchlickGGX(NdotV, roughness); 59 | float ggx1 = GeometrySchlickGGX(NdotL, roughness); 60 | 61 | return ggx1 * ggx2; 62 | } 63 | 64 | vec2 IntegrateBRDF(float NdotV, float roughness) { 65 | vec3 V; 66 | V.x = sqrt(1.0 - NdotV*NdotV); 67 | V.y = 0.0; 68 | V.z = NdotV; 69 | 70 | float A = 0.0; 71 | float B = 0.0; 72 | 73 | vec3 N = vec3(0.0, 0.0, 1.0); 74 | 75 | const uint SAMPLE_COUNT = 1024u; 76 | for(uint i = 0u; i < SAMPLE_COUNT; ++i) { 77 | // generates a sample vector that's biased towards the 78 | // preferred alignment direction (importance sampling). 79 | vec2 Xi = Hammersley(i, SAMPLE_COUNT); 80 | vec3 H = ImportanceSampleGGX(Xi, N, roughness); 81 | vec3 L = normalize(2.0 * dot(V, H) * H - V); 82 | 83 | float NdotL = max(L.z, 0.0); 84 | float NdotH = max(H.z, 0.0); 85 | float VdotH = max(dot(V, H), 0.0); 86 | 87 | if(NdotL > 0.0) { 88 | float G = GeometrySmith(N, V, L, roughness); 89 | float G_Vis = (G * VdotH) / (NdotH * NdotV); 90 | float Fc = pow(1.0 - VdotH, 5.0); 91 | 92 | A += (1.0 - Fc) * G_Vis; 93 | B += Fc * G_Vis; 94 | } 95 | } 96 | A /= float(SAMPLE_COUNT); 97 | B /= float(SAMPLE_COUNT); 98 | return vec2(A, B); 99 | } 100 | 101 | void main() { 102 | vec2 integratedBRDF = IntegrateBRDF(TexCoords.x, TexCoords.y); 103 | FragColor = integratedBRDF; 104 | } -------------------------------------------------------------------------------- /ToyBox/BRDF.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCoords; 4 | 5 | out vec2 TexCoords; 6 | 7 | void main() { 8 | TexCoords = aTexCoords; 9 | gl_Position = vec4(aPos, 1.0); 10 | } -------------------------------------------------------------------------------- /ToyBox/BVH.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | #include "Vector2.h" 5 | #include "Hitable.h" 6 | #include "Debugger.h" 7 | #include "BoundingBox.h" 8 | 9 | namespace MOON { 10 | 11 | class BVH : public Hitable { 12 | public: 13 | #define CheckBox(l, r) (l->bounding_box(Vector2::ZERO(), box_left) && r->bounding_box(Vector2::ZERO(), box_right)) 14 | 15 | static unsigned int divisionAxis; 16 | static int box_compare(const void* a, const void* b) { 17 | BoundingBox box_left, box_right; 18 | Hitable *ah = *(Hitable**)a, *bh = *(Hitable**)b; 19 | if (!CheckBox(ah, bh)) std::cerr << "no bounding box in bvh constructor!" << std::endl; 20 | if (divisionAxis == 0) 21 | if (box_left.min.x - box_right.min.x < 0) return -1; 22 | else if (divisionAxis == 1) 23 | if (box_left.min.y - box_right.min.y < 0) return -1; 24 | else if (box_left.min.z - box_right.min.z < 0) return -1; 25 | return 1; 26 | } 27 | 28 | Hitable* left; 29 | Hitable* right; 30 | 31 | BVH(std::vector& l, Vector2 range, Vector2 timeStamp = Vector2::ZERO()) : left(nullptr), right(nullptr) { 32 | //if (!l.size()) return; 33 | 34 | divisionAxis = int(3 * MoonMath::drand48()); 35 | int n = range.y - range.x; 36 | std::qsort(&l[range.x], n, sizeof(Hitable*), box_compare); 37 | 38 | if (n == 0) { 39 | left = right = l[range.x]; 40 | } else if (n == 1) { 41 | left = l[range.x]; right = l[range.y]; 42 | } else { 43 | left = new BVH(l, Vector2(range.x, range.x + n / 2), timeStamp); 44 | right = new BVH(l, Vector2(range.x + n / 2 + 1, range.y), timeStamp); 45 | } 46 | 47 | BoundingBox box_left, box_right; 48 | if (!CheckBox(left, right)) 49 | std::cerr << "no bounding box in bvh constructor!" << std::endl; 50 | 51 | bbox = box_left.join(box_right); 52 | } 53 | 54 | ~BVH() override { 55 | if (left != nullptr && CheckClass(left, BVH)) 56 | delete left; 57 | if (right != nullptr && CheckClass(right, BVH)) 58 | delete right; 59 | } 60 | 61 | virtual bool Hit(const Ray& r, HitRecord& rec) const override { 62 | if (bbox.intersect(r)) { 63 | HitRecord left_rec, right_rec; 64 | bool hit_left = this->left->Hit(r, left_rec); 65 | bool hit_right = this->right->Hit(r, right_rec); 66 | if (hit_left && hit_right) 67 | rec = left_rec.t < right_rec.t ? left_rec : right_rec; 68 | else if (hit_left) 69 | rec = left_rec; 70 | else if (hit_right) 71 | rec = right_rec; 72 | else return false; 73 | return true; 74 | } else return false; 75 | } 76 | 77 | void Draw(const Vector4& color = Color::WHITE()) { 78 | DEBUG::DrawBBox(this->bbox, color); 79 | 80 | auto col = color / 2.0f; col.w = 0.5f; 81 | if (left != nullptr && CheckClass(left, BVH)) ((BVH*)left)->Draw(col); 82 | if (right != nullptr && CheckClass(right, BVH)) ((BVH*)right)->Draw(col); 83 | } 84 | }; 85 | 86 | } -------------------------------------------------------------------------------- /ToyBox/BasicRayMarching.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform mat4 invPVMat; 6 | uniform sampler2D screenBuffer; 7 | uniform sampler2D depthBuffer; 8 | 9 | uniform vec2 bufferSize; 10 | uniform vec3 bboxMin; 11 | uniform vec3 bboxMax; 12 | 13 | vec3 viewPos, viewDir; 14 | 15 | vec2 RayBoxDst(vec3 boundsMin, vec3 boundsMax, vec3 rayOrigin, vec3 invRaydir) { 16 | vec3 t0 = (boundsMin - rayOrigin) * invRaydir; 17 | vec3 t1 = (boundsMax - rayOrigin) * invRaydir; 18 | vec3 tmin = min(t0, t1); 19 | vec3 tmax = max(t0, t1); 20 | 21 | // enter point 22 | float dstA = max(max(tmin.x, tmin.y), tmin.z); 23 | // exit point 24 | float dstB = min(tmax.x, min(tmax.y, tmax.z)); 25 | 26 | float dstToBox = max(0, dstA); 27 | float dstInsideBox = max(0, dstB - dstToBox); 28 | return vec2(dstToBox, dstInsideBox); 29 | } 30 | 31 | void CalculatePixelRay(vec2 n) { 32 | vec4 ray_start = invPVMat * vec4(n.x, n.y, -1.0, 1.0); 33 | vec4 ray_end = invPVMat * vec4(n.x, n.y, 1.0, 1.0); 34 | 35 | ray_start.xyz /= ray_start.w; 36 | ray_end.xyz /= ray_end.w; 37 | 38 | viewPos = ray_start.xyz; 39 | viewDir = normalize((ray_end - ray_start).xyz); 40 | } 41 | 42 | vec4 CalculateWorldSpacePosition(float depth, vec2 n) { 43 | return invPVMat * vec4(n.x, n.y, depth, 1.0); 44 | } 45 | 46 | float CloudRayMarching(vec3 startPoint, vec3 direction, vec3 worldPos) { 47 | vec3 testPoint = startPoint; 48 | 49 | float depthEyeLinear = length(worldPos - testPoint); 50 | vec2 intersectInfo = RayBoxDst(bboxMin, bboxMax, testPoint, 1.0 / direction); 51 | float dstLimit = min(depthEyeLinear - intersectInfo.x, intersectInfo.y); 52 | 53 | float sum = 1.0; 54 | if (dstLimit > 0) { 55 | testPoint = startPoint + intersectInfo.x * direction; 56 | for (int i = 0; i < 256; i++) { 57 | testPoint += direction * 0.1; 58 | if (0.1 * i > dstLimit) break; 59 | if (testPoint.x < bboxMax.x && testPoint.x > bboxMin.x && 60 | testPoint.z < bboxMax.z && testPoint.z > bboxMin.z && 61 | testPoint.y < bboxMax.y && testPoint.y > bboxMin.y) 62 | sum += 0.1; 63 | //if (sum >= 1.0) break; 64 | } 65 | } 66 | return sum; 67 | } 68 | 69 | void main() { 70 | vec3 color = texture(screenBuffer, TexCoords).rgb; 71 | float depth = 2 * texture(depthBuffer, TexCoords).r - 1; 72 | vec4 worldPos = CalculateWorldSpacePosition(depth, TexCoords * 2.0 - vec2(1.0)); 73 | worldPos.xyz /= worldPos.w; 74 | 75 | // cloud ray marching 76 | CalculatePixelRay(TexCoords * 2.0 - vec2(1.0)); 77 | float cloud = CloudRayMarching(viewPos, viewDir, worldPos.xyz); 78 | 79 | FragColor = vec4(color * pow(cloud, 2.2), 1.0); 80 | 81 | // debug 82 | //float depthEyeLinear = length(worldPos.xyz - viewPos); 83 | //vec2 intersectInfo = RayBoxDst(bboxMin, bboxMax, viewPos, 1.0 / viewDir); 84 | //float dstLimit = min(depthEyeLinear - intersectInfo.x, intersectInfo.y); 85 | //FragColor = vec4(clamp(dstLimit, 0, 1), pow(depthEyeLinear / 10, 2.0) / 20, pow(depthEyeLinear / 10, 2.0), 1); 86 | } -------------------------------------------------------------------------------- /ToyBox/BlinnPhong.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec3 Normal; 5 | in vec3 FragPos; 6 | 7 | uniform vec3 lightPos; 8 | uniform vec3 viewPos; 9 | uniform vec3 lightColor; 10 | uniform vec3 objectColor; 11 | uniform vec3 illumination; 12 | uniform float specularLV; 13 | 14 | void main(){ 15 | //ambient 16 | float ambientStrength = 0.1; 17 | vec3 ambient = ambientStrength * lightColor; 18 | 19 | // diffuse 20 | vec3 norm = normalize(Normal); 21 | vec3 lightDir = normalize(lightPos - FragPos); 22 | float diff = max(dot(norm, lightDir), 0.0); 23 | vec3 diffuse = diff * lightColor; 24 | 25 | // specular 26 | float specularStrength = 0.5; 27 | vec3 viewDir = normalize(viewPos - FragPos); 28 | 29 | // difference with Phong model ---------------------- 30 | vec3 halfDir = normalize(viewDir + lightDir); 31 | float spec = pow(max(dot(halfDir, norm), 0.0), specularLV); 32 | // -------------------------------------------------- 33 | 34 | vec3 specular = specularStrength * lightColor * clamp(spec, 0.0, 1.0); 35 | 36 | vec3 result = (ambient + diffuse + specular) * objectColor; 37 | FragColor = vec4(illumination + result, 1.0); 38 | } 39 | -------------------------------------------------------------------------------- /ToyBox/BlurEffects.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | uniform sampler2D screenBuffer; 7 | 8 | // global params 9 | uniform int _type; 10 | 11 | // box & gaussian params 12 | uniform int _iter; 13 | uniform float _sigma; 14 | 15 | // bokeh params 16 | uniform float _time; 17 | uniform float _expo; 18 | uniform float GOLDEN_ANGLE; 19 | 20 | // Gaussian Blur ---------------------------------------------------------------------------- 21 | float normpdf(float x, float sigma) { 22 | return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma; 23 | } 24 | 25 | vec3 GaussianBlur(){ 26 | // declare stuff 27 | int iSize = _iter * 2 + 1; 28 | 29 | // create the 1-D kernel 30 | float kernel[129]; // kernel size = iSize, iSize max = 64 31 | for (int j = 0; j <= _iter; ++j) { 32 | kernel[_iter + j] = kernel[_iter - j] = normpdf(float(j), _sigma); 33 | } 34 | 35 | // get the normalization factor (as the gaussian has been clamped) 36 | float Z = 0.0; 37 | for (int j = 0; j < iSize; ++j) { 38 | Z += kernel[j]; 39 | } 40 | 41 | // read out the texels 42 | vec3 final_colour = vec3(0.0); 43 | for (int i = -_iter; i <= _iter; ++i) { 44 | for (int j = -_iter; j <= _iter; ++j) { 45 | final_colour += kernel[_iter + j] * kernel[_iter + i] * 46 | texture(screenBuffer, TexCoords + vec2(float(i), float(j)) / bufferSize).rgb; 47 | } 48 | } 49 | 50 | return final_colour / (Z * Z); 51 | } 52 | 53 | // Box Blur --------------------------------------------------------------------------------- 54 | vec3 BoxBlur(){ 55 | vec3 final_colour = vec3(0.0); 56 | 57 | int cnt = 0; 58 | for (int i = -_iter; i <= _iter; ++i) { 59 | for (int j = -_iter; j <= _iter; ++j) { 60 | final_colour += texture(screenBuffer, TexCoords + vec2(float(i), float(j)) / bufferSize).rgb; 61 | cnt++; 62 | } 63 | } 64 | 65 | return final_colour / cnt; 66 | } 67 | 68 | // Bokeh ------------------------------------------------------------------------------------ 69 | vec3 Bokeh(float radius) { 70 | float r = 1.0, ITERATIONS = _iter * 30; 71 | vec3 acc = vec3(0), div = acc; 72 | vec2 vangle = vec2(0.0, radius * 0.01 / sqrt(ITERATIONS)); 73 | mat2 rot = mat2(cos(GOLDEN_ANGLE), sin(GOLDEN_ANGLE), -sin(GOLDEN_ANGLE), cos(GOLDEN_ANGLE)); 74 | 75 | for (int j = 0; j < ITERATIONS; j++) { 76 | // the approx increase in the scale of sqrt(0, 1, 2, 3...) 77 | r += 1.0 / r; 78 | vangle = rot * vangle; 79 | vec2 offset = (r - 1.0) * vangle; 80 | offset.y *= bufferSize.x / bufferSize.y; 81 | vec3 col = texture(screenBuffer, TexCoords + offset).rgb; 82 | // Contrast it for better highlights - leave this out elsewhere. 83 | col = col * col * _expo; 84 | vec3 bokeh = pow(col, vec3(4)); 85 | acc += col * bokeh; 86 | div += bokeh; 87 | } 88 | 89 | return acc / div; 90 | } 91 | 92 | void main() { 93 | if (_type == 0) { 94 | FragColor = vec4(BoxBlur(), 1.0); 95 | } else if (_type == 1) { 96 | FragColor = vec4(GaussianBlur(), 1.0); 97 | } else if (_type == 2) { 98 | FragColor = vec4(Bokeh(_time), 1.0); 99 | } 100 | } -------------------------------------------------------------------------------- /ToyBox/Bokeh.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | uniform sampler2D screenBuffer; 7 | 8 | uniform float _time; 9 | 10 | // The Golden Angle is (3.0 - sqrt(5.0)) * PI radians, which doesn't precompiled for some reason. 11 | #define GOLDEN_ANGLE 2.39996 12 | #define ITERATIONS 150 13 | 14 | mat2 rot = mat2(cos(GOLDEN_ANGLE), sin(GOLDEN_ANGLE), -sin(GOLDEN_ANGLE), cos(GOLDEN_ANGLE)); 15 | 16 | vec3 Bokeh(sampler2D tex, vec2 uv, float radius) { 17 | vec3 acc = vec3(0), div = acc; 18 | float r = 1.0; 19 | vec2 vangle = vec2(0.0, radius * 0.01 / sqrt(float(ITERATIONS))); 20 | 21 | for (int j = 0; j < ITERATIONS; j++) { 22 | // the approx increase in the scale of sqrt(0, 1, 2, 3...) 23 | r += 1.0 / r; 24 | vangle = rot * vangle; 25 | vec3 col = texture(tex, uv + (r - 1.0) * vangle).xyz; // Sample the image 26 | col = col * col * 1.8; // Contrast it for better highlights - leave this out elsewhere. 27 | vec3 bokeh = pow(col, vec3(4)); 28 | acc += col * bokeh; 29 | div += bokeh; 30 | } 31 | 32 | return acc / div; 33 | } 34 | 35 | void main() { 36 | float rad = 0.8 - 0.8 * cos(_time * 6.283); 37 | 38 | FragColor = vec4(Bokeh(screenBuffer, TexCoords, rad), 1.0); 39 | } -------------------------------------------------------------------------------- /ToyBox/Bone.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HelperBase.h" 3 | 4 | namespace MOON { 5 | 6 | class Bone : public Helper { 7 | public: 8 | 9 | 10 | }; 11 | 12 | } -------------------------------------------------------------------------------- /ToyBox/Box.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Mesh.h" 3 | #include "Model.h" 4 | #include "Vector3.h" 5 | 6 | namespace MOON { 7 | 8 | class Box : public Model { 9 | public: 10 | Vector3 size; 11 | Vector3 segment; 12 | 13 | void CreateProcedural(const bool& interactive) override; 14 | void ListProceduralProperties() override; 15 | 16 | Box(const std::string &name, const bool& interactive = false, 17 | Vector3 size = Vector3::ONE(), Vector3 segment = Vector3::ONE(), 18 | const int id = MOON_AUTOID) : 19 | Model(name, id), size(size), segment(segment) { 20 | CreateProcedural(interactive); 21 | } 22 | 23 | static void InteractiveCreate(void* arg); 24 | static Mesh* GenerateMesh(Vector3 size, Vector3 segment); 25 | }; 26 | 27 | } -------------------------------------------------------------------------------- /ToyBox/CNN.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/CakeParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // ******* ** ** ** ******** 3 | // **/////** **** /** ** /**///// 4 | // /** ** //** /***** /******* 5 | // /** ** ********** /**//** /**//// 6 | // //******* /*** /*** /** //** /******** 7 | // /////// /// /// // // //////// 8 | // 9 | // @author HZT 10 | // @date TODO 11 | // @version 0.0.0 12 | // 13 | 14 | #pragma once 15 | #include 16 | #include 17 | 18 | namespace MOON { 19 | 20 | class CakeParser { 21 | public: 22 | 23 | }; 24 | 25 | } 26 | -------------------------------------------------------------------------------- /ToyBox/Camera.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Camera.cpp -------------------------------------------------------------------------------- /ToyBox/Capsule.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Capsule.cpp -------------------------------------------------------------------------------- /ToyBox/Capsule.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Mesh.h" 3 | #include "Model.h" 4 | #include "Vector3.h" 5 | 6 | namespace MOON { 7 | 8 | class Capsule : public Model { 9 | public: 10 | Vector2 size; 11 | Vector2 segment; 12 | 13 | void CreateProcedural(const bool& interactive) override; 14 | void ListProceduralProperties() override; 15 | 16 | Capsule(const std::string &name, const bool& interactive = false, 17 | Vector2 size = Vector2::ONE(), Vector2 segment = Vector2(3, 3), 18 | const int id = MOON_AUTOID) : 19 | Model(name, id), size(size), segment(segment) { 20 | CreateProcedural(interactive); 21 | } 22 | 23 | static void InteractiveCreate(void* arg); 24 | static Mesh* GenerateMesh(Vector2 size, Vector2 segment); 25 | }; 26 | 27 | } -------------------------------------------------------------------------------- /ToyBox/Chromatic.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | uniform sampler2D screenBuffer; 7 | 8 | uniform float _fishEye; 9 | uniform float _chromatic; 10 | uniform float _scale; 11 | 12 | void main() { 13 | vec2 normUV = (TexCoords * 2.0 - 1.0) * _scale; 14 | 15 | // screen deformation 16 | vec2 uv = (normUV + 1.0) / 2.0 + normUV * dot(normUV, normUV) * 0.1 * _fishEye; 17 | vec3 color = texture(screenBuffer, uv).rgb; 18 | 19 | // chromatic aberration 20 | vec2 mo = normUV * 0.01 * _chromatic; 21 | FragColor.r = texture(screenBuffer, uv - mo * 0.1, 0.0).r; 22 | FragColor.g = texture(screenBuffer, uv - mo * 0.6, 0.0).g; 23 | FragColor.b = texture(screenBuffer, uv - mo * 1.0, 0.0).b; 24 | 25 | FragColor.a = 1.0; 26 | } -------------------------------------------------------------------------------- /ToyBox/Color.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "Vector4.h" 6 | #include "MathUtils.h" 7 | 8 | namespace MOON { 9 | class Color { 10 | public: 11 | // based on : https://www.sioe.cn/yingyong/yanse-rgb-16/ 12 | static Vector4 RED() { return Vector4(1.0f, 0.0f, 0.0f, 1.0f); } 13 | static Vector4 BLUE() { return Vector4(0.0f, 0.0f, 1.0f, 1.0f); } 14 | static Vector4 GREEN() { return Vector4(0.0f, 1.0f, 0.0f, 1.0f); } 15 | static Vector4 WHITE() { return Vector4(1.0f, 1.0f, 1.0f, 1.0f); } 16 | static Vector4 BLACK() { return Vector4(0.0f, 0.0f, 0.0f, 1.0f); } 17 | static Vector4 YELLOW() { return Vector4(1.0f, 1.0f, 0.0f, 1.0f); } 18 | static Vector4 ORANGE() { return Vector4(1.0f, 0.647f, 0.0f, 1.0f); } 19 | static Vector4 Gray() { return Vector4(0.439f, 0.502f, 0.565f, 1.0f); } 20 | 21 | static Vector4 Random(bool randomAlpha = false) { return Vector4( 22 | MoonMath::Random01(), 23 | MoonMath::Random01(), 24 | MoonMath::Random01(), 25 | randomAlpha ? MoonMath::Random01() : 1.0f 26 | );} 27 | 28 | inline static float GrayScaleVal(const Vector4 &color) { return (color.x + color.y + color.z) / 3.0f; } 29 | inline static Vector4 GrayScaleColor(const Vector4 &color) { 30 | float grayCol = GrayScaleVal(color); 31 | return Vector4(grayCol, grayCol, grayCol, color.w); 32 | } 33 | 34 | // convert object ID to unique color 35 | inline static Vector4 IDEncoder(const unsigned int &ID) { 36 | if (ID >= MOON_IDBOUNDARY) { 37 | std::cout << "ERROR: ID is too large! ID: " << ID << std::endl; 38 | return Vector4::ZERO(); 39 | } 40 | 41 | /// black (0, 0, 0, 0) is backgroundColor 42 | /// so object ID is start from 1 43 | std::vector data = MoonMath::TENtoNBase(ID, 256); 44 | 45 | // reverse order 46 | return Vector4(data[0], data.size() > 1 ? data[1] : 0, 47 | data.size() > 2 ? data[2] : 0, 48 | 255 - (data.size() > 3 ? data[3] : 0)) / 255.0f; 49 | } 50 | 51 | /// *NOTE: alpha is start from 1 to 0, while r,g,b is start from 0 to 1 52 | // convert object color to object ID 53 | inline static unsigned int IDDecoder(Vector4 Color) { 54 | if (Color == Vector4::ZERO()) { 55 | //std::cout << "ERROR: ID can not be 0!" << std::endl; 56 | return 0; 57 | } 58 | 59 | Color *= 255; 60 | return (255 - Color[3]) * 256 * 256 * 256 + Color[2] * 256 * 256 + Color[1] * 256 + Color[0]; 61 | } 62 | 63 | // convert object color to object ID 64 | inline static unsigned int IDDecoder(float r, float g, float b, float a) { 65 | if (!r && !g && !b && !a) { 66 | //std::cout << "ERROR: ID can not be 0!" << std::endl; 67 | return 0; 68 | } 69 | 70 | r *= 255; g *= 255; b *= 255; a *= 255; 71 | return (255 - a) * 256 * 256 * 256 + b * 256 * 256 + g * 256 + r; 72 | } 73 | }; 74 | } -------------------------------------------------------------------------------- /ToyBox/ColorCorrection.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | 7 | void main() { 8 | vec3 color = texture(screenBuffer, TexCoords).rgb; 9 | 10 | FragColor = vec4(color, 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/ColorSpace.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | uniform float gamma; 7 | uniform int space; 8 | uniform int dir; 9 | 10 | vec3 to_linear(vec3 col, int space) { 11 | if (space == 0) return col; // linear 12 | else if (space == 1){ // srgb 13 | 14 | } else if (space == 2){ // gamma 15 | 16 | } else if (space == 3){ // cineon 17 | 18 | } 19 | } 20 | 21 | vec3 to_srgb(vec3 linearCol) { 22 | 23 | return linearCol; 24 | } 25 | 26 | vec3 to_gamma(vec3 linearCol, float gamma) { 27 | 28 | return linearCol; 29 | } 30 | 31 | vec3 to_cineon(vec3 linearCol) { 32 | 33 | return linearCol; 34 | } 35 | 36 | vec3 to_aces_cg(vec3 linearCol) { 37 | 38 | return linearCol; 39 | } 40 | 41 | vec3 to_rec_709(vec3 linearCol) { 42 | 43 | return linearCol; 44 | } 45 | 46 | void main() { 47 | vec3 color_in = texture(screenBuffer, TexCoords).rgb; 48 | 49 | if (dir == 1) { 50 | color_in = to_linear(color_in, space); 51 | } else { 52 | if (space == 1){ // srgb 53 | color_in = to_srgb(color_in); 54 | } else if (space == 2){ // gamma 55 | color_in = to_gamma(color_in, gamma); 56 | } else if (space == 3){ // cineon 57 | color_in = to_cineon(color_in); 58 | } 59 | } 60 | 61 | FragColor = vec4(color_in, 1.0); 62 | } -------------------------------------------------------------------------------- /ToyBox/ConstColor.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | uniform vec4 lineColor; 5 | 6 | void main(){ 7 | FragColor = lineColor; 8 | } -------------------------------------------------------------------------------- /ToyBox/ConstColor.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | uniform mat4 model; 5 | uniform mat4 view; 6 | uniform mat4 projection; 7 | 8 | void main() { 9 | gl_Position = projection * view * model * vec4(aPos, 1.0f); 10 | } -------------------------------------------------------------------------------- /ToyBox/Coroutine.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Coroutine.h -------------------------------------------------------------------------------- /ToyBox/Curve.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | 7 | void main() { 8 | vec3 color = texture(screenBuffer, TexCoords).rgb; 9 | 10 | FragColor = vec4(color, 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/Curves.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include "Vector3.h" 6 | 7 | namespace MOON { 8 | namespace Curves { 9 | class CubicBezier { 10 | public: 11 | static bool ComputeCurve(const std::vector &knots, 12 | const std::vector &controllers, const int &smooth, 13 | std::vector &result) { 14 | if (controllers.size() != (knots.size() << 1) - 2) { 15 | std::cout << "Bezier: controllers.size(" << controllers.size () 16 | << ") != knots.size(" << knots.size() << ") << 1 - 2" << std::endl; 17 | return false; 18 | } 19 | float step = 1.0f / smooth; 20 | for (int i = 0, ctrl = 0; i < knots.size() - 1; i++) { 21 | for (float u = 0; u < 1; u += step) { 22 | if (u >= 1) break; 23 | float uu = 1 - u; 24 | result.push_back( 25 | pow(uu, 3) * knots[i] + 26 | 3 * u * pow(uu, 2) * controllers[ctrl] + 27 | 3 * pow(u, 2) * uu * controllers[ctrl + 1] + 28 | pow(u, 3) * knots[i + 1] 29 | ); 30 | } 31 | ctrl += 2; 32 | } 33 | result.push_back(knots[knots.size() - 1]); 34 | return true; 35 | } 36 | }; 37 | 38 | class BSpline { 39 | public: 40 | static bool ComputeCurve(const std::vector &knots, const int &p, 41 | const bool &closed, const bool &uniform, std::vector &result) { 42 | if (closed) { 43 | std::vector cknots(knots); 44 | for (int i = 0; i < p + 1; i++) cknots.push_back(knots[i]); 45 | std::vector m = CalculateDivide(cknots.size(), p, uniform); 46 | } else { 47 | 48 | } 49 | return true; 50 | } 51 | 52 | static std::vector CalculateDivide(const int &n, const int &p, const bool &uniform) { 53 | std::vector m; 54 | if (uniform) { 55 | int tot = n + p + 1; 56 | for (int i = 0; i < tot; i++) 57 | m.push_back((float)i / tot); 58 | } else { 59 | 60 | } 61 | } 62 | }; 63 | 64 | class NURBSCurve { 65 | public: 66 | 67 | }; 68 | 69 | class CatmullRom { 70 | public: 71 | static Vector3 CatmullRom_Interpolation(const Vector3 &p0, const Vector3 &p1, const Vector3 &p2, const Vector3 &p3, const float &t) { 72 | return p1 + (0.5f * (p2 - p0) * t) + 73 | 0.5f * (2.0f * p0 - 5.0f * p1 + 4.0f * p2 - p3) * t * t + 74 | 0.5f * (-p0 + 3.0f * p1 - 3.0f * p2 + p3) * t * t * t; 75 | } 76 | }; 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /ToyBox/Cylinder.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Cylinder.cpp -------------------------------------------------------------------------------- /ToyBox/Cylinder.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Mesh.h" 3 | #include "Model.h" 4 | #include "Vector3.h" 5 | 6 | namespace MOON { 7 | 8 | class Cylinder : public Model { 9 | public: 10 | Vector2 size; 11 | Vector2 segment; 12 | 13 | void CreateProcedural(const bool& interactive) override; 14 | void ListProceduralProperties() override; 15 | 16 | Cylinder(const std::string &name, const bool& interactive = false, 17 | Vector2 size = Vector2::ONE(), Vector2 segment = Vector2(3, 3), 18 | const int id = MOON_AUTOID) : 19 | Model(name, id), size(size), segment(segment) { 20 | CreateProcedural(interactive); 21 | } 22 | 23 | static void InteractiveCreate(void* arg); 24 | static Mesh* GenerateMesh(Vector2 size, Vector2 segment); 25 | }; 26 | 27 | } -------------------------------------------------------------------------------- /ToyBox/DOF_MultiPass.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | uniform sampler2D screenBuffer; 7 | uniform sampler2D depthBuffer; 8 | 9 | // blur direction 10 | uniform vec2 dir; 11 | 12 | // global params 13 | uniform bool debug; 14 | 15 | // DOF params 16 | uniform float _iter; 17 | uniform float _falloff; 18 | uniform float _distance; 19 | uniform float _multiply; 20 | uniform float _tolerance; 21 | uniform float _cutoff; 22 | uniform float _accurate; 23 | 24 | float weight(float x) { 25 | return 1.0 - x * x * x * x; 26 | } 27 | 28 | float SampleDepth(vec2 uv) { 29 | float depth = 2 * texture(depthBuffer, uv).r - 1; 30 | depth = abs(_distance - depth); 31 | if (depth <= _tolerance) depth = pow(depth / _tolerance, _falloff) * _tolerance; 32 | depth = pow(depth * _multiply, 1.0 / _iter); 33 | return depth; 34 | } 35 | 36 | void main() { 37 | float dist = SampleDepth(TexCoords); 38 | float totalw = 0.0; 39 | 40 | vec3 color = vec3(0.0); 41 | float halfAcc = _accurate / 2.0; 42 | for (int i = 0; i <= _accurate; i++) { 43 | float fi = float(i - halfAcc) / halfAcc; 44 | 45 | vec2 p = TexCoords; 46 | p.xy += dir * fi * dist; 47 | 48 | float w = weight(fi); 49 | vec4 c = vec4(texture(screenBuffer, p).rgb, SampleDepth(p)); 50 | if (dist >= c.a) w *= max(1.0 - (dist - c.a) / _cutoff, 0.0); 51 | color += c.rgb * w; 52 | totalw += w; 53 | } 54 | 55 | color /= totalw; 56 | FragColor = vec4(color, 1.0); 57 | } -------------------------------------------------------------------------------- /ToyBox/Debugger.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "Debugger.h" 4 | #include "SceneMgr.h" 5 | #include "Matrix4x4.h" 6 | #include "BoundingBox.h" 7 | #include "Gizmo.h" 8 | 9 | namespace MOON { 10 | 11 | void DEBUG::DrawBBox(const BoundingBox& bbox, const Vector4 &color, const float &lineWidth, const Matrix4x4& modelMat) { 12 | std::vector corners; 13 | bbox.GetCorners(&corners); 14 | 15 | std::vector drawList{ 16 | corners[0], corners[1], 17 | corners[1], corners[2], 18 | corners[2], corners[3], 19 | corners[3], corners[0], 20 | 21 | corners[4], corners[5], 22 | corners[5], corners[6], 23 | corners[6], corners[7], 24 | corners[7], corners[4], 25 | 26 | corners[0], corners[6], 27 | corners[5], corners[3], 28 | corners[2], corners[4], 29 | corners[7], corners[1] 30 | }; 31 | 32 | Gizmo::DrawLines(drawList, color, lineWidth, true, false, modelMat); 33 | } 34 | 35 | void DEBUG::Line(const Vector3 &start, const Vector3 &end, const Vector4 &color, const float &lineWidth) { 36 | Gizmo::DrawLine(start, end, color, lineWidth); 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /ToyBox/Debugger.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "Vector3.h" 8 | #include "Vector4.h" 9 | #include "Matrix4x4.h" 10 | #include "Color.h" 11 | 12 | namespace MOON { 13 | 14 | extern class BoundingBox; 15 | class DEBUG { 16 | public: 17 | static void Line(const Vector3 &start, const Vector3 &end, const Vector4 &color = Color::WHITE(), const float &lineWidth = 1.0f); 18 | static void DrawBBox(const BoundingBox& bbox, const Vector4 &color = Color::WHITE(), const float &lineWidth = 1.0f, const Matrix4x4& modelMat = Matrix4x4::identity()); 19 | 20 | inline static void Separator(unsigned int cnt) { 21 | std::cout << std::endl; 22 | while (cnt--) std::cout << "-"; 23 | std::cout << std::endl; 24 | } 25 | 26 | // TODO 27 | static void Log(const std::string& info); 28 | static void Warn(const std::string& info); 29 | static void Error(const std::string& info); 30 | }; 31 | 32 | } -------------------------------------------------------------------------------- /ToyBox/Dummy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HelperBase.h" 3 | 4 | namespace MOON { 5 | 6 | class Dummy : public Helper { 7 | public: 8 | bool drawBox; 9 | bool drawCross; 10 | 11 | float displaySize; 12 | 13 | Dummy(const std::string &name, const int id = MOON_AUTOID) : Helper(name, id) { 14 | this->drawBox = true; 15 | this->drawCross = false; 16 | this->displaySize = 1.0f; 17 | this->wireColor = Vector4(0, 0.8f, 0, 1); 18 | 19 | #pragma region generate_dummy_shape 20 | // box: 0~3 21 | splineList.push_back(Spline("box_base", 22 | SplineType::CORNER, { 23 | Vector3( 0.5f, -0.5f, 0.5f), 24 | Vector3(-0.5f, -0.5f, 0.5f), 25 | Vector3(-0.5f, -0.5f, -0.5f), 26 | Vector3( 0.5f, -0.5f, -0.5f), 27 | Vector3( 0.5f, -0.5f, 0.5f), 28 | Vector3( 0.5f, 0.5f, 0.5f) 29 | } 30 | )); 31 | splineList.push_back(Spline("box_top", 32 | SplineType::CORNER, { 33 | Vector3( 0.5f, 0.5f, -0.5f), 34 | Vector3(-0.5f, 0.5f, -0.5f), 35 | Vector3(-0.5f, 0.5f, 0.5f), 36 | Vector3( 0.5f, 0.5f, 0.5f), 37 | Vector3( 0.5f, 0.5f, -0.5f), 38 | Vector3( 0.5f, -0.5f, -0.5f) 39 | } 40 | )); 41 | splineList.push_back(Spline("left_column", 42 | SplineType::CORNER, { 43 | Vector3(-0.5f, -0.5f, 0.5f), 44 | Vector3(-0.5f, 0.5f, 0.5f) 45 | } 46 | )); 47 | splineList.push_back(Spline("right_column", 48 | SplineType::CORNER, { 49 | Vector3(-0.5f, 0.5f, -0.5f), 50 | Vector3(-0.5f, -0.5f, -0.5f) 51 | } 52 | )); 53 | 54 | // cross: 4~6 55 | splineList.push_back(Spline("cross_forward", 56 | SplineType::CORNER, { 57 | Vector3(0, 0, -1.0f), 58 | Vector3(0, 0, 1.0f) 59 | } 60 | )); 61 | splineList.push_back(Spline("cross_left", 62 | SplineType::CORNER, { 63 | Vector3(-1.0f, 0, 0), 64 | Vector3(1.0f, 0, 0) 65 | } 66 | )); 67 | splineList.push_back(Spline("cross_up", 68 | SplineType::CORNER, { 69 | Vector3(0, -1.0f, 0), 70 | Vector3(0, 1.0f, 0) 71 | } 72 | )); 73 | #pragma endregion 74 | } 75 | 76 | ~Dummy() override = default; 77 | 78 | void Draw(Shader* overrideShader = NULL) override { 79 | if (drawBox) { 80 | for (int i = 0; i < 4; i++) 81 | splineList[i].Draw( 82 | transform.localToWorldMat, 83 | wireColor, overrideShader 84 | ); 85 | } 86 | if (drawCross) { 87 | for (int i = 4; i < 7; i++) 88 | splineList[i].Draw( 89 | transform.localToWorldMat, 90 | wireColor, overrideShader 91 | ); 92 | } 93 | } 94 | 95 | void ListHelperPropties() override { 96 | ImGui::Text("Dummy:"); 97 | ImGui::Indent(10.0f); 98 | 99 | ImGui::Text("WireBox:"); ImGui::SameLine(80.0f); 100 | ImGui::Checkbox("box", &drawBox, true); 101 | 102 | ImGui::Text("Cross:"); ImGui::SameLine(80.0f); 103 | ImGui::Checkbox("cross", &drawCross, true); 104 | ImGui::Unindent(10.0f); 105 | } 106 | }; 107 | 108 | } -------------------------------------------------------------------------------- /ToyBox/EnvSphere.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec2 UV; 3 | in vec3 Norm; 4 | 5 | #define MAX_COL_LENGTH 8 6 | 7 | struct GradColor { 8 | vec3 skyColor; 9 | vec3 groundColor; 10 | }; 11 | 12 | uniform int type; 13 | uniform float time; 14 | uniform sampler2D HDRI; 15 | uniform GradColor colors[MAX_COL_LENGTH]; 16 | 17 | // functions -------------------------------------------------------------- 18 | vec3 LerpColor(vec3 dir, vec3 colSky, vec3 colGrd) { 19 | vec3 unit_direction = normalize(dir); 20 | float t = 0.5 * (unit_direction.y + 1.0); 21 | //return (1.0 - t) * vec3(1, 1, 1) + t * vec3(0.5, 0.7, 1.0); 22 | return (1.0 - t) * colGrd + t * colSky; 23 | } 24 | 25 | // time: [0.0, 1.0] 26 | vec3 ProceduralSky(vec3 dir, float time) { 27 | //int ceil_id = 28 | return vec3(0); 29 | } 30 | 31 | vec3 SampleSphericalMap(vec3 dir) { 32 | vec2 invAtan = vec2(0.1591, 0.3183); 33 | 34 | vec2 uv = vec2(atan(dir.z, dir.x), asin(dir.y)); 35 | uv *= invAtan; uv.x += 0.5; uv.y += 0.5; 36 | 37 | uv.y = 1.0 - uv.y; 38 | return texture2D(HDRI, uv).rgb; 39 | } 40 | 41 | void main() { 42 | if (type == 3) 43 | gl_FragColor = vec4(pow(ProceduralSky(normalize(Norm), time), vec3(2.2)), 1.0); 44 | else 45 | gl_FragColor = vec4(SampleSphericalMap(normalize(Norm)), 1.0); 46 | } 47 | -------------------------------------------------------------------------------- /ToyBox/EnvSphere.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 position; 3 | layout (location = 1) in vec3 normal; 4 | layout (location = 2) in vec2 uv; 5 | 6 | out vec3 Norm; 7 | out vec2 UV; 8 | 9 | uniform mat4 model; 10 | uniform mat4 view; 11 | uniform mat4 projection; 12 | 13 | void main() { 14 | UV = uv; 15 | Norm = normal; 16 | gl_Position = projection * view * model * vec4(position, 1.0); 17 | } -------------------------------------------------------------------------------- /ToyBox/Exposure.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform float exposure; 6 | uniform float highlight; 7 | uniform float contrast; 8 | uniform sampler2D screenBuffer; 9 | 10 | void main() { 11 | vec3 hdrColor = texture(screenBuffer, TexCoords).rgb; 12 | 13 | // exposure 14 | vec3 mapped = hdrColor * exposure; 15 | 16 | // saturation 17 | //float luminance = 0.2125 * hdrColor.r + 0.7154 * hdrColor.g + 0.0721 * hdrColor.b; 18 | //vec3 luminanceColor = vec3(luminance, luminance, luminance); 19 | //mapped = mix(luminanceColor, mapped, saturation); 20 | 21 | // highlight 22 | if ((mapped.r + mapped.g + mapped.b) / 3.0 > 1.0) { 23 | mapped = mix(normalize(mapped), mapped, highlight); 24 | } 25 | 26 | // contrast 27 | vec3 avgColor = vec3(0.5, 0.5, 0.5); 28 | mapped = mix(avgColor, mapped, contrast); 29 | 30 | FragColor = vec4(mapped, 1.0); 31 | } -------------------------------------------------------------------------------- /ToyBox/FBM.fs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/FBM.fs -------------------------------------------------------------------------------- /ToyBox/FNN.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/FNN.h -------------------------------------------------------------------------------- /ToyBox/FXAA.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | uniform int FXAA_SPAN_MAX; 7 | uniform sampler2D screenBuffer; 8 | 9 | void main() { 10 | //int FXAA_SPAN_MAX = 8; 11 | float FXAA_REDUCE_MUL = 1.0 / 8.0; 12 | float FXAA_REDUCE_MIN = 1.0 / 128.0; 13 | 14 | vec3 rgbNW = texture2D(screenBuffer, TexCoords + vec2(-1.0,-1.0) / bufferSize).xyz; 15 | vec3 rgbNE = texture2D(screenBuffer, TexCoords + vec2( 1.0,-1.0) / bufferSize).xyz; 16 | vec3 rgbSW = texture2D(screenBuffer, TexCoords + vec2(-1.0, 1.0) / bufferSize).xyz; 17 | vec3 rgbSE = texture2D(screenBuffer, TexCoords + vec2( 1.0, 1.0) / bufferSize).xyz; 18 | vec3 rgbM = texture2D(screenBuffer, TexCoords).xyz; 19 | 20 | vec3 luma = vec3(0.299, 0.587, 0.114); 21 | float lumaNW = dot(rgbNW, luma); 22 | float lumaNE = dot(rgbNE, luma); 23 | float lumaSW = dot(rgbSW, luma); 24 | float lumaSE = dot(rgbSE, luma); 25 | float lumaM = dot(rgbM, luma); 26 | 27 | float lumaMin = min(lumaM, min(min(lumaNW, lumaNE), min(lumaSW, lumaSE))); 28 | float lumaMax = max(lumaM, max(max(lumaNW, lumaNE), max(lumaSW, lumaSE))); 29 | 30 | vec2 dir; 31 | dir.x = (lumaSW + lumaSE) - (lumaNW + lumaNE); 32 | dir.y = (lumaNW + lumaSW) - (lumaNE + lumaSE); 33 | 34 | float dirReduce = max((lumaNW + lumaNE + lumaSW + lumaSE) * (0.25 * FXAA_REDUCE_MUL), FXAA_REDUCE_MIN); 35 | 36 | float rcpDirMin = 1.0 / (min(abs(dir.x), abs(dir.y)) + dirReduce); 37 | 38 | dir = min(vec2( FXAA_SPAN_MAX, FXAA_SPAN_MAX), 39 | max(vec2(-FXAA_SPAN_MAX, -FXAA_SPAN_MAX), 40 | dir * rcpDirMin)) / bufferSize; 41 | 42 | vec3 rgbA = (1.0 / 2.0) * ( 43 | texture2D(screenBuffer, TexCoords.xy + dir * (1.0 / 3.0 - 0.5)).xyz + 44 | texture2D(screenBuffer, TexCoords.xy + dir * (2.0 / 3.0 - 0.5)).xyz 45 | ); 46 | vec3 rgbB = rgbA * (1.0 / 2.0) + (1.0 / 4.0) * ( 47 | texture2D(screenBuffer, TexCoords.xy + dir * -0.5).xyz + 48 | texture2D(screenBuffer, TexCoords.xy + dir * 0.5).xyz 49 | ); 50 | float lumaB = dot(rgbB, luma); 51 | 52 | if (lumaB < lumaMin || lumaB > lumaMax) FragColor = vec4(rgbA, 1.0); 53 | else FragColor = vec4(rgbB, 1.0); 54 | } -------------------------------------------------------------------------------- /ToyBox/FileManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Strutil.h" 3 | 4 | namespace MOON { 5 | 6 | enum FILE_TYPE { 7 | // mesh formats 8 | GMSH, OBJ, FBX, BINARY, VTK, 9 | // texture formats 10 | HDRI, JPEG, PNG, BMP, TAG, EXR, 11 | // fallback 12 | UNKNOWN 13 | }; 14 | 15 | class FileManager { 16 | public: 17 | static FILE_TYPE GuessFormat(const std::string file_path) { 18 | Strutil::to_lower(file_path); 19 | if (Strutil::ends_with(file_path, ".msh")) { 20 | return FILE_TYPE::GMSH; 21 | } else if (Strutil::ends_with(file_path, ".obj")) { 22 | return FILE_TYPE::OBJ; 23 | } else if (Strutil::ends_with(file_path, ".bm")) { 24 | return FILE_TYPE::BINARY; 25 | } else if (Strutil::ends_with(file_path, ".vtk")) { 26 | return FILE_TYPE::VTK; 27 | } else if (Strutil::ends_with(file_path, ".hdr")) { 28 | return FILE_TYPE::HDRI; 29 | } else if (Strutil::ends_with(file_path, ".jpg")) { 30 | return FILE_TYPE::JPEG; 31 | } else if (Strutil::ends_with(file_path, ".png")) { 32 | return FILE_TYPE::PNG; 33 | } else { 34 | return FILE_TYPE::UNKNOWN; 35 | } 36 | } 37 | }; 38 | 39 | } 40 | -------------------------------------------------------------------------------- /ToyBox/FireGenerator.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | //uniform sampler2D screenBuffer; 7 | uniform float scale; 8 | uniform vec2 offset; 9 | uniform float power; 10 | uniform float time; 11 | 12 | uniform vec3 tint; 13 | 14 | vec2 hash(vec2 p) { 15 | p = vec2( 16 | dot(p, vec2(127.1, 311.7)), 17 | dot(p, vec2(269.5, 183.3)) 18 | ); 19 | return -1.0 + 2.0 * fract(sin(p) * 43758.5453123); 20 | } 21 | 22 | float noise(vec2 p) { 23 | const float K1 = 0.366025404; // (sqrt(3) - 1) / 2; 24 | const float K2 = 0.211324865; // (3 - sqrt(3)) / 6; 25 | 26 | vec2 i = floor(p + (p.x + p.y) * K1); 27 | 28 | vec2 a = p - i + (i.x + i.y) * K2; 29 | vec2 o = (a.x > a.y) ? vec2(1.0, 0.0) : vec2(0.0, 1.0); 30 | vec2 b = a - o + K2; 31 | vec2 c = a - 1.0 + 2.0 * K2; 32 | 33 | vec3 h = max(0.5 - vec3(dot(a, a), dot(b, b), dot(c, c)), 0.0); 34 | 35 | vec3 n = pow(h, vec3(4.0)) * vec3(dot(a, hash(i + 0.0)), dot(b, hash(i + o)), dot(c, hash(i + 1.0))); 36 | 37 | return dot(n, vec3(70.0)); 38 | } 39 | 40 | float fbm(vec2 uv) { 41 | float f; 42 | mat2 m = mat2(1.6, 1.2, -1.2, 1.6); 43 | f = 0.5000 * noise(uv); uv = m * uv; 44 | f += 0.2500 * noise(uv); uv = m * uv; 45 | f += 0.1250 * noise(uv); uv = m * uv; 46 | f += 0.0625 * noise(uv); uv = m * uv; 47 | f = 0.5 + 0.5 * f; 48 | return f; 49 | } 50 | 51 | void main() { 52 | vec2 uv = vec2(TexCoords.x, 1.0 - TexCoords.y); 53 | vec2 q = (uv + offset) * scale; q.x *= 5.0; q.y *= 2.0; 54 | float strength = floor(q.x + 1.0); 55 | float T3 = max(3.0, 1.25 * strength) * time; 56 | q.x = mod(q.x, 1.0) - 0.5; q.y -= 0.25; 57 | float n = fbm(strength * q - vec2(0, T3)); 58 | float c = 1.0 - 16.0 * pow( 59 | max(0.0, length(q * vec2(1.8 + q.y * 1.5, 0.75)) - 60 | n * max(0.0, q.y + 0.25)), 1.2 61 | ); 62 | float c1 = n * c * (1.5 - pow(2.50 * uv.y, 4.0)); 63 | c1 = clamp(c1, 0.0, 1.0); 64 | 65 | //vec3 col = vec3(1.5 * c1, 1.5 * pow(c1, 3), pow(c1, 6)); 66 | vec3 col = vec3( 67 | clamp(tint.r * 3.0, 1.0, 1.5) * pow(c1, (1.0 - tint.r) * 6), 68 | clamp(tint.g * 3.0, 1.0, 1.5) * pow(c1, (1.0 - tint.g) * 6), 69 | clamp(tint.b * 3.0, 1.0, 1.5) * pow(c1, (1.0 - tint.b) * 6) 70 | ) * power; 71 | 72 | float a = c * (1.0 - pow(uv.y, 3.0)); 73 | FragColor = vec4(mix(vec3(0.0), col, a), 1.0); 74 | } -------------------------------------------------------------------------------- /ToyBox/Flare.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | uniform float threshold; 7 | uniform float intensity; 8 | uniform float stretch; 9 | uniform float brightness; 10 | uniform vec3 tint; 11 | 12 | float GetLight(vec2 uv){ 13 | vec3 color = texture(screenBuffer, uv).rgb; 14 | return pow((color.r + color.g + color.b) / 3.0, threshold) * (1.0 - threshold); 15 | } 16 | 17 | vec3 flares(sampler2D tex, vec2 uv, float _threshold, float intensity, float stretch, float brightness) { 18 | _threshold = 1.0 - _threshold; 19 | 20 | float hdr = floor(_threshold + GetLight(uv)); 21 | //hdr = vec3(floor(_threshold + pow(hdr.r, 1.0))); 22 | 23 | float d = intensity; 24 | float c = intensity * stretch; 25 | 26 | // horizontal 27 | for (float i = c; i > -1.0; i--) { 28 | float texL = GetLight(uv + vec2(i / d, 0.0)); 29 | float texR = GetLight(uv - vec2(i / d, 0.0)); 30 | hdr += floor(_threshold + pow(max(texL, texR), 4.0)) * (1.0 - i / c); 31 | } 32 | 33 | // vertical 34 | //for (float i = c / 2.0; i > -1.0; i--) { 35 | // float texU = texture(tex, uv + vec2(0.0, i / d)).r; 36 | // float texD = texture(tex, uv - vec2(0.0, i / d)).r; 37 | // hdr += floor(_threshold + pow(max(texU, texD), 40.0)) * (1.0 - i / c) * 0.25; 38 | //} 39 | 40 | return vec3(hdr) * tint * brightness / threshold; 41 | } 42 | 43 | void main() { 44 | vec3 color = texture(screenBuffer, TexCoords).rgb; 45 | 46 | color += flares(screenBuffer, TexCoords, 0.9, intensity, stretch, brightness / 100.0); 47 | 48 | FragColor = vec4(color, 1.0); 49 | } -------------------------------------------------------------------------------- /ToyBox/Flat.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | flat in vec3 Normal; 5 | flat in vec3 FragPos; 6 | 7 | uniform vec3 lightPos; 8 | uniform vec3 viewPos; 9 | uniform vec3 lightColor; 10 | uniform vec3 objectColor; 11 | uniform float specularLV; 12 | 13 | void main(){ 14 | //ambient 15 | float ambientStrength = 0.1; 16 | vec3 ambient = ambientStrength * lightColor; 17 | 18 | // diffuse 19 | vec3 norm = normalize(Normal); 20 | vec3 lightDir = normalize(lightPos - FragPos); 21 | float diff = max(dot(norm, lightDir), 0.0); 22 | vec3 diffuse = diff * lightColor; 23 | 24 | // specular 25 | float specularStrength = 0.5; 26 | vec3 viewDir = normalize(viewPos - FragPos); 27 | vec3 halfDir = normalize(viewDir + lightDir); 28 | float spec = pow(max(dot(halfDir, norm), 0.0), specularLV); 29 | vec3 specular = specularStrength * lightColor * clamp(spec, 0.0, 1.0); 30 | 31 | vec3 result = (ambient + diffuse + specular) * objectColor; 32 | FragColor = vec4(result, 1.0); 33 | } 34 | -------------------------------------------------------------------------------- /ToyBox/Flat.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec3 aNormal; 4 | 5 | flat out vec3 FragPos; 6 | flat out vec3 Normal; 7 | 8 | uniform mat4 model; 9 | uniform mat4 view; 10 | uniform mat4 projection; 11 | 12 | void main() { 13 | FragPos = vec3(model * vec4(aPos, 1.0)); 14 | Normal = mat3(transpose(inverse(model))) * aNormal; 15 | 16 | gl_Position = projection * view * vec4(FragPos, 1.0); 17 | } -------------------------------------------------------------------------------- /ToyBox/FlowMenu.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "ImPie.h" 4 | 5 | namespace MOON { 6 | class MOON_FlowMenu { 7 | public: 8 | // Legacy right-click menu 9 | static void QuadMenu(); 10 | static void FlowMenu(); 11 | }; 12 | } -------------------------------------------------------------------------------- /ToyBox/FuzzyMatch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/FuzzyMatch.h -------------------------------------------------------------------------------- /ToyBox/GBufferRender.fs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/GBufferRender.fs -------------------------------------------------------------------------------- /ToyBox/GBufferRenderer.fs: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/GBufferRenderer.fs -------------------------------------------------------------------------------- /ToyBox/GNN.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/GaussianBlur.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | uniform sampler2D screenBuffer; 7 | 8 | uniform int _iter; 9 | uniform float _sigma; 10 | 11 | float normpdf(float x, float sigma) { 12 | return 0.39894 * exp(-0.5 * x * x / (sigma * sigma)) / sigma; 13 | } 14 | 15 | void main() { 16 | // declare stuff 17 | float kernel[129]; // kernel size = iSize, iSize max = 64 18 | int iSize = _iter * 2 + 1; 19 | int kSize = (iSize - 1) / 2; 20 | vec3 final_colour = vec3(0.0); 21 | 22 | // create the 1-D kernel 23 | float Z = 0.0; 24 | for (int j = 0; j <= kSize; ++j) { 25 | kernel[kSize + j] = kernel[kSize - j] = normpdf(float(j), _sigma); 26 | } 27 | 28 | // get the normalization factor (as the gaussian has been clamped) 29 | for (int j = 0; j < iSize; ++j) { 30 | Z += kernel[j]; 31 | } 32 | 33 | // read out the texels 34 | for (int i = -kSize; i <= kSize; ++i) { 35 | for (int j = -kSize; j <= kSize; ++j) { 36 | final_colour += kernel[kSize + j] * kernel[kSize + i] * 37 | texture(screenBuffer, TexCoords + vec2(float(i), float(j)) / bufferSize).rgb; 38 | } 39 | } 40 | 41 | FragColor = vec4(final_colour / (Z * Z), 1.0); 42 | } -------------------------------------------------------------------------------- /ToyBox/Graphics.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Graphics.h -------------------------------------------------------------------------------- /ToyBox/HalfMesh.cpp: -------------------------------------------------------------------------------- 1 | #include "HalfMesh.h" 2 | #include "SceneMgr.h" 3 | 4 | namespace MOON { 5 | 6 | void HalfMesh::SetupMesh() { 7 | glGenVertexArrays(1, &VAO); 8 | glGenBuffers(1, &VBO); 9 | glGenBuffers(1, &EBO); 10 | 11 | UpdateMesh(); 12 | 13 | // set the vertex attribute pointers 14 | // vertex Positions 15 | glEnableVertexAttribArray(0); 16 | glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)0); 17 | // vertex normals 18 | glEnableVertexAttribArray(1); 19 | glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Normal)); 20 | // vertex texture coords 21 | glEnableVertexAttribArray(2); 22 | glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, UV)); 23 | // vertex tangent 24 | glEnableVertexAttribArray(3); 25 | glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Tangent)); 26 | // vertex bitangent 27 | glEnableVertexAttribArray(4); 28 | glVertexAttribPointer(4, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex), (void*)offsetof(Vertex, Bitangent)); 29 | 30 | glBindVertexArray(0); 31 | } 32 | 33 | void HalfMesh::ClearSelection(const int& type) { 34 | if (type == VERT) 35 | MOON_InputManager::Selector::ClearSelectionPrototype(vertices, selected_verts); 36 | else if (type == EDGE) 37 | MOON_InputManager::Selector::ClearSelectionPrototype(edges, selected_edges); 38 | else if (type == FACE) 39 | MOON_InputManager::Selector::ClearSelectionPrototype(faces, selected_faces); 40 | else { 41 | MOON_InputManager::Selector::ClearSelectionPrototype(vertices, selected_verts); 42 | MOON_InputManager::Selector::ClearSelectionPrototype(edges, selected_edges); 43 | MOON_InputManager::Selector::ClearSelectionPrototype(faces, selected_faces); 44 | } 45 | } 46 | 47 | void HalfMesh::Select(const Element& type, const unsigned int ID) { 48 | if (type == VERT) 49 | MOON_InputManager::Selector::SelectPrototype(vertices, selected_verts, ID); 50 | else if (type == EDGE) 51 | MOON_InputManager::Selector::SelectPrototype(edges, selected_edges, ID); 52 | else if (type == FACE) 53 | MOON_InputManager::Selector::SelectPrototype(faces, selected_faces, ID); 54 | } 55 | 56 | void HalfMesh::Select_Append(const Element& type, unsigned int ID, const bool& autoInvertSelect) { 57 | if (type == VERT) 58 | MOON_InputManager::Selector::Select_AppendPrototype( 59 | vertices, selected_verts, ID, autoInvertSelect 60 | ); 61 | else if (type == EDGE) 62 | MOON_InputManager::Selector::Select_AppendPrototype( 63 | edges, selected_edges, ID, autoInvertSelect 64 | ); 65 | else if (type == FACE) 66 | MOON_InputManager::Selector::Select_AppendPrototype( 67 | faces, selected_faces, ID, autoInvertSelect 68 | ); 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /ToyBox/HalfMesh.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/HalfMesh.h -------------------------------------------------------------------------------- /ToyBox/HeightToNormal.fs: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/Helper.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/HelperBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ObjectBase.h" 3 | #include "Spline.h" 4 | 5 | namespace MOON { 6 | class Helper : public MObject { 7 | public: 8 | std::vector splineList; 9 | 10 | Helper(const std::string &name, const int id = MOON_AUTOID) : MObject(name, id) {} 11 | virtual ~Helper() override = default; 12 | 13 | void ListProperties() override { 14 | // list name ---------------------------------------------------------------------- 15 | ListName(); 16 | ImGui::Separator(); 17 | 18 | // list transform ----------------------------------------------------------------- 19 | ListTransform(); 20 | ImGui::Separator(); 21 | 22 | // list Splines ------------------------------------------------------------------- 23 | ListHelperPropties(); 24 | ImGui::Separator(); 25 | 26 | // list operators ----------------------------------------------------------------- 27 | opstack.ListStacks(); 28 | ImGui::Spacing(); 29 | } 30 | 31 | virtual void Draw(Shader* overrideShader = NULL) override { 32 | for (auto sp : splineList) { 33 | sp.Draw(transform.localToWorldMat, wireColor, overrideShader); 34 | } 35 | } 36 | 37 | virtual void ListHelperPropties() { 38 | ImGui::Text("Spline:"); 39 | if (ImGui::TreeNodeEx((std::to_string(splineList.size()) + " spline(s)").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { 40 | for (auto &iter : splineList) { 41 | if (ImGui::TreeNodeEx(iter.name.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { 42 | iter.ListParameters(); 43 | iter.ListKnots(); 44 | iter.ListControllers(); 45 | ImGui::TreePop(); 46 | } 47 | } 48 | ImGui::TreePop(); 49 | } 50 | } 51 | }; 52 | } -------------------------------------------------------------------------------- /ToyBox/Helpers.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HelperBase.h" 3 | #include "Dummy.h" 4 | #include "Tape.h" 5 | #include "Proxy.h" 6 | #include "Volume.h" 7 | 8 | namespace MOON { 9 | 10 | enum HelperType { 11 | dummy, 12 | tape, 13 | volume, 14 | proxy 15 | }; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /ToyBox/Hitable.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Ray.h" 3 | #include "Vector2.h" 4 | #include "Vector3.h" 5 | #include "MathUtils.h" 6 | #include "BoundingBox.h" 7 | 8 | namespace MOON { 9 | extern class Material; 10 | 11 | struct HitRecord { 12 | float t; // distance between camera and target (hited by the ray) 13 | Vector3 p; 14 | Vector3 normal; 15 | Vector2 uv; 16 | Material *mat; 17 | 18 | HitRecord(): t(INFINITY) {} 19 | HitRecord(const HitRecord& rec) : t(rec.t), p(rec.p), normal(rec.normal), uv(rec.uv), mat(rec.mat) {} 20 | }; 21 | 22 | class Hitable { 23 | public: 24 | BoundingBox bbox; 25 | 26 | Hitable() {} 27 | Hitable(const BoundingBox& box) : bbox(box) {} 28 | virtual ~Hitable() = default; 29 | 30 | virtual bool Hit(const Ray &t, HitRecord &rec) const { return true; }; 31 | virtual bool bounding_box(Vector2 timeStamp, BoundingBox& box) const { 32 | box = bbox; 33 | return true; 34 | } 35 | }; 36 | 37 | } -------------------------------------------------------------------------------- /ToyBox/HotkeyMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "MoonEnums.h" 6 | 7 | namespace MOON { 8 | extern class Vector2; 9 | extern class MObject; 10 | extern class Dummy; 11 | class HotKeyManager { 12 | public: 13 | enum SelectType { 14 | rectangle, 15 | circle, 16 | lasso, 17 | paint 18 | }; 19 | 20 | static ViewportState state; 21 | static SnapMode snapType; 22 | static bool enableSnap; 23 | 24 | static MObject* globalEditTarget; 25 | static Element globalEditElem; 26 | 27 | static void MOON_InputProcessor(GLFWwindow *window); 28 | static void SelectRegion(const SelectType& type = rectangle); 29 | static void ConvertRegionToSelection(const Vector2& start, const Vector2& end); 30 | }; 31 | 32 | } 33 | -------------------------------------------------------------------------------- /ToyBox/IRMapGen.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec2 UV; 5 | 6 | uniform sampler2D environmentMap; 7 | 8 | const float PI = 3.14159265359; 9 | const vec2 invAtan = vec2(0.1591, 0.3183); 10 | 11 | vec3 SampleSphericalMap(vec3 dir) { 12 | vec2 uv = vec2(atan(dir.z, dir.x), asin(dir.y)); 13 | uv *= invAtan; uv.x += 0.5; uv.y += 0.5; 14 | 15 | //uv.y = 1.0 - uv.y; 16 | return texture2D(environmentMap, uv).rgb; 17 | } 18 | 19 | vec3 UVtoDirection(vec2 uv) { 20 | bool flag = (uv.x < 0.25 || uv.x > 0.75) ? true : false; 21 | uv.x -= 0.5; uv.y -= 0.5; 22 | uv /= invAtan; 23 | 24 | vec3 dir; 25 | dir.y = sin(uv.y); 26 | float t = tan(uv.x); 27 | dir.x = sqrt((1 - dir.y * dir.y) / (1 + t * t)); 28 | if (flag) dir.x *= -1; 29 | dir.z = dir.x * t; 30 | 31 | return dir; 32 | } 33 | 34 | void main() { 35 | // The world vector acts as the normal of a tangent surface from the origin, aligned to WorldPos. 36 | // Given this normal, calculate all incoming radiance of the environment. 37 | // The result of this radiance is the radiance of light coming from -Normal direction, 38 | // which is what we use in the PBR shader to sample irradiance. 39 | vec3 WorldPos = UVtoDirection(UV); 40 | vec3 N = normalize(WorldPos); 41 | 42 | // tangent space calculation from origin point 43 | vec3 up = vec3(0.0, 1.0, 0.0); 44 | vec3 right = normalize(cross(up, N)); 45 | up = normalize(cross(N, right)); 46 | 47 | float nrSamples = 0.0; 48 | float sampleDelta = 0.025; 49 | vec3 irradiance = vec3(0.0); 50 | for(float phi = 0.0; phi < 2.0 * PI; phi += sampleDelta) { 51 | for(float theta = 0.0; theta < 0.5 * PI; theta += sampleDelta) { 52 | // spherical to cartesian (in tangent space) 53 | vec3 tangentSample = vec3(sin(theta) * cos(phi), sin(theta) * sin(phi), cos(theta)); 54 | 55 | tangentSample = normalize(tangentSample); 56 | 57 | // tangent space to world 58 | vec3 sampleVec = tangentSample.x * right + tangentSample.y * up + tangentSample.z * N; 59 | 60 | irradiance += SampleSphericalMap(normalize(sampleVec)) * cos(theta) * sin(theta); 61 | nrSamples++; 62 | } 63 | } 64 | irradiance = PI * irradiance * (1.0 / float(nrSamples)); 65 | 66 | FragColor = vec4(irradiance, 1.0); 67 | } -------------------------------------------------------------------------------- /ToyBox/IRMapGen.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aUV; 4 | 5 | out vec2 UV; 6 | 7 | //uniform mat4 projection; 8 | //uniform mat4 view; 9 | 10 | void main() { 11 | UV = aUV; 12 | gl_Position = vec4(aPos, 1.0); 13 | } -------------------------------------------------------------------------------- /ToyBox/Icons.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "fontHeaders/IconsFontAwesome4.h" 3 | #include "fontHeaders/IconsMaterialDesign.h" 4 | //#include "fontHeaders/IconsFontaudio.h" 5 | //#include "fontHeaders/IconsKenney.h" 6 | 7 | // headers: https://github.com/juliettef/IconFontCppHeaders. -------------------------------------------------------------------------------- /ToyBox/ImGradient.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "imgui.h" 3 | #include 4 | 5 | struct ImGradientMark { 6 | float color[4]; 7 | float position; //0 to 1 8 | }; 9 | 10 | class ImGradient { 11 | public: 12 | ImGradient(); 13 | ~ImGradient(); 14 | 15 | void getColorAt(float position, float* color) const; 16 | void addMark(float position, ImColor const color); 17 | void removeMark(ImGradientMark* mark); 18 | void refreshCache(); 19 | std::list & getMarks() { return m_marks; } 20 | private: 21 | void computeColorAt(float position, float* color) const; 22 | std::list m_marks; 23 | float m_cachedValues[256 * 3]; 24 | }; 25 | 26 | namespace ImGui { 27 | bool GradientButton(ImGradient* gradient); 28 | 29 | bool GradientEditor(ImGradient* gradient, 30 | ImGradientMark* & draggingMark, 31 | ImGradientMark* & selectedMark); 32 | 33 | 34 | } -------------------------------------------------------------------------------- /ToyBox/ImPie.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace ImGui { 6 | bool BeginPiePopup(const char* pName, int iMouseButton = 0); 7 | void EndPiePopup(); 8 | 9 | bool PieMenuItem(const char* pName, bool bEnabled = true); 10 | bool BeginPieMenu(const char* pName, bool bEnabled = true); 11 | void EndPieMenu(); 12 | } -------------------------------------------------------------------------------- /ToyBox/LR.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/LR.h -------------------------------------------------------------------------------- /ToyBox/Levels.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | 7 | void main() { 8 | vec3 color = texture(screenBuffer, TexCoords).rgb; 9 | 10 | FragColor = vec4(color, 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/Light.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "Light.h" 3 | #include "Gizmo.h" 4 | #include "ButtonEx.h" 5 | #include "Matrix4x4.h" 6 | #include "SceneMgr.h" 7 | 8 | namespace MOON { 9 | 10 | #pragma region light 11 | std::vector& Light::GetLightShape() { 12 | static std::vector empty; 13 | return empty; 14 | } 15 | 16 | void Light::Draw(Shader* overrideShader) { 17 | Gizmo::DrawLinesDirect( 18 | GetLightShape(), wireColor, 19 | overrideShader == NULL ? 0.5f : 5.0f, true, 20 | transform.localToWorldMat * ViewportDistanceMatrix, 21 | overrideShader 22 | ); 23 | } 24 | 25 | void Light::ListProperties() { 26 | // list name 27 | ListName(); 28 | ImGui::Separator(); 29 | 30 | // list transform 31 | ListTransform(); 32 | ImGui::Separator(); 33 | 34 | // list other props 35 | ListLightProperties(); 36 | } 37 | 38 | void Light::ListLightProperties() { 39 | ImGui::Text("Light:"); 40 | 41 | ImGui::Indent(10.0f); 42 | //ImGui::Text("Color"); ImGui::SameLine(80.0f); 43 | ImGui::ColorEdit3("Color", &color[0]); 44 | ImGui::Text("Power"); ImGui::SameLine(80.0f); 45 | ButtonEx::DragFloatNoLabel("power", &power, 0.1f); 46 | ImGui::Unindent(10.0f); 47 | } 48 | #pragma endregion 49 | 50 | #pragma region dir_light 51 | std::vector& DirLight::GetLightShape() { 52 | static std::vector lightShape = std::vector{ 53 | Vector3(0.5f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, 0.5f), Vector3(-0.5f, 0.0f, 0.0f), 54 | Vector3(0.0f, 0.0f, -0.5f), Vector3(0.5f, 0.0f, 0.0f), Vector3(0.0f, -0.75f, 0.0f), 55 | Vector3(0.0f, 0.0f, 0.5f), Vector3(0.0f, 0.75f, 0.0f), Vector3(-0.5f, 0.0f, 0.0f), 56 | Vector3(0.0f, -0.75f, 0.0f), Vector3(0.0f, 0.0f, -0.5f), Vector3(0.0f, 0.75f, 0.0f), 57 | Vector3(0.5f, 0.0f, 0.0f) 58 | }; 59 | 60 | return lightShape; 61 | } 62 | 63 | void DirLight::ListLightProperties() { 64 | ImGui::Text("Light[Point]:"); 65 | 66 | ImGui::Indent(10.0f); 67 | //ImGui::Text("Color"); ImGui::SameLine(80.0f); 68 | ImGui::ColorEdit3("Color", &color[0]); 69 | ImGui::Text("Power"); ImGui::SameLine(80.0f); 70 | ButtonEx::DragFloatNoLabel("power", &power, 0.1f); 71 | ImGui::Unindent(10.0f); 72 | } 73 | #pragma endregion 74 | 75 | #pragma region point_light 76 | std::vector& PointLight::GetLightShape() { 77 | static std::vector lightShape = std::vector{ 78 | Vector3(0.5f, 0.0f, 0.0f), Vector3(0.0f, 0.0f, 0.5f), Vector3(-0.5f, 0.0f, 0.0f), 79 | Vector3(0.0f, 0.0f, -0.5f), Vector3(0.5f, 0.0f, 0.0f), Vector3(0.0f, -0.75f, 0.0f), 80 | Vector3(0.0f, 0.0f, 0.5f), Vector3(0.0f, 0.75f, 0.0f), Vector3(-0.5f, 0.0f, 0.0f), 81 | Vector3(0.0f, -0.75f, 0.0f), Vector3(0.0f, 0.0f, -0.5f), Vector3(0.0f, 0.75f, 0.0f), 82 | Vector3(0.5f, 0.0f, 0.0f) 83 | }; 84 | 85 | return lightShape; 86 | } 87 | 88 | void PointLight::ListLightProperties() { 89 | ImGui::Text("Light[Point]:"); 90 | 91 | ImGui::Indent(10.0f); 92 | //ImGui::Text("Color"); ImGui::SameLine(80.0f); 93 | ImGui::ColorEdit3("Color", &color[0]); 94 | ImGui::Text("Power"); ImGui::SameLine(80.0f); 95 | ButtonEx::DragFloatNoLabel("power", &power, 0.1f); 96 | ImGui::Unindent(10.0f); 97 | } 98 | #pragma endregion 99 | 100 | #pragma region spot_light 101 | 102 | #pragma endregion 103 | 104 | #pragma region moon_light 105 | 106 | #pragma endregion 107 | 108 | #pragma region dome_light 109 | 110 | #pragma endregion 111 | 112 | } -------------------------------------------------------------------------------- /ToyBox/MShader.cpp: -------------------------------------------------------------------------------- 1 | #include "StackWindow.h" 2 | #include "CodeEditor.h" 3 | #include "MShader.h" 4 | #include "UIController.h" 5 | 6 | namespace MOON { 7 | void Shader::ListProperties() { 8 | // list name ---------------------------------------------------------------------- 9 | ListName(); 10 | ImGui::Separator(); 11 | 12 | // list shaders ------------------------------------------------------------------- 13 | // vs 14 | ImGui::PushID("vs"); 15 | if (ImGui::TreeNode("vert source", ID)) { 16 | ImGui::SameLine(); 17 | if (ImGui::SmallButton(ICON_FA_PENCIL_SQUARE_O)) { 18 | MainUI::show_code_editor = true; 19 | MainUI::CEditor.LoadFile(vertexPath); 20 | } 21 | ImGui::Indent(-10.0f); 22 | ImGui::InputTextMultiline(UniquePropName("vssource"), vsbuf, 23 | IM_ARRAYSIZE(vsbuf), ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16)); 24 | ImGui::Unindent(-10.0f); 25 | ImGui::TreePop(); 26 | } else { 27 | ImGui::SameLine(); 28 | if (ImGui::SmallButton(ICON_FA_PENCIL_SQUARE_O)) { 29 | MainUI::show_code_editor = true; 30 | MainUI::CEditor.LoadFile(vertexPath); 31 | } 32 | } 33 | ImGui::PopID(); 34 | // fs 35 | ImGui::PushID("fs"); 36 | if (ImGui::TreeNode("frag source", ID)) { 37 | ImGui::SameLine(); 38 | if (ImGui::SmallButton(ICON_FA_PENCIL_SQUARE_O)) { 39 | MainUI::show_code_editor = true; 40 | MainUI::CEditor.LoadFile(fragmentPath); 41 | } 42 | ImGui::Indent(-10.0f); 43 | ImGui::InputTextMultiline(UniquePropName("fssource"), fsbuf, 44 | IM_ARRAYSIZE(fsbuf), ImVec2(-FLT_MIN, ImGui::GetTextLineHeight() * 16)); 45 | ImGui::Unindent(-10.0f); 46 | ImGui::TreePop(); 47 | } else { 48 | ImGui::SameLine(); 49 | if (ImGui::SmallButton(ICON_FA_PENCIL_SQUARE_O)) { 50 | MainUI::show_code_editor = true; 51 | MainUI::CEditor.LoadFile(fragmentPath); 52 | } 53 | } 54 | ImGui::PopID(); 55 | 56 | ImGui::Indent(10.0f); 57 | if (ImGui::Button("Recompile")) {} 58 | ImGui::SameLine(); 59 | if (ImGui::Button("Save")) { 60 | RegistStackWnd("Information"); 61 | } 62 | QueryWnd("Information", "Overwrite existing shader files?", this, &Shader::SaveShaders); 63 | ImGui::SameLine(); 64 | if (ImGui::Button("Revert")) { RevertCodes(); } 65 | ImGui::Unindent(10.0f); 66 | 67 | ImGui::Spacing(); 68 | } 69 | 70 | void Shader::RevertCodes() { 71 | std::string vs, fs; 72 | ReadShaderSource(vs, fs); 73 | strcpy(vsbuf, vs.c_str()); 74 | strcpy(fsbuf, fs.c_str()); 75 | } 76 | } -------------------------------------------------------------------------------- /ToyBox/Margins.fs: -------------------------------------------------------------------------------- 1 | vec3 margins(vec3 color, vec2 uv, float marginSize) 2 | { 3 | if(uv.y < marginSize || uv.y > 1.0-marginSize) 4 | { 5 | return vec3(0.0); 6 | }else{ 7 | return color; 8 | } 9 | } -------------------------------------------------------------------------------- /ToyBox/MatSphere.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Hitable.h" 3 | #include "Material.h" 4 | #include "Vector3.h" 5 | 6 | #include 7 | #include 8 | 9 | namespace MOON { 10 | class MSphere : public Hitable { 11 | public: 12 | Vector3 pos; 13 | float radius; 14 | Material *mat; 15 | 16 | MSphere(const Vector3 &pos, const float &r) : pos(pos), radius(r), mat(NULL) {}; 17 | MSphere(const Vector3 &pos, const float &r, Material *mat) : pos(pos), radius(r), mat(mat) {}; 18 | 19 | ~MSphere() { 20 | //if (mat) delete mat; 21 | } 22 | 23 | inline bool Hit(const Ray &r, HitRecord &rec) const { 24 | Vector3 oc = r.pos - this->pos; 25 | float dis_a = r.dir.dot(r.dir); 26 | float dis_b = oc.dot(r.dir); 27 | float dis_c = oc.dot(oc) - pow(radius, 2.0); 28 | float discriminant = dis_b * dis_b - dis_a * dis_c; 29 | 30 | if (discriminant > 0) { 31 | float temp = (-dis_b - sqrt(discriminant)) / dis_a; 32 | if (temp > EPSILON && temp < rec.t) { 33 | //std::cout << temp << std::endl; 34 | rec.t = temp; 35 | rec.p = r.PointAtParameter(rec.t); 36 | rec.normal = (rec.p - this->pos) / radius; 37 | rec.mat = mat; 38 | return true; 39 | } 40 | temp = (-dis_b + sqrt(discriminant)) / dis_a; 41 | if (temp > EPSILON && temp < rec.t) { 42 | rec.t = temp; 43 | rec.p = r.PointAtParameter(rec.t); 44 | rec.normal = (rec.p - this->pos) / radius; 45 | rec.mat = mat; 46 | return true; 47 | } 48 | } 49 | return false; 50 | } 51 | 52 | }; 53 | } -------------------------------------------------------------------------------- /ToyBox/MaterialEditor.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/MaterialEditor.cpp -------------------------------------------------------------------------------- /ToyBox/MaterialEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "NodeEditorBase.h" 3 | 4 | namespace MOON { 5 | 6 | class MaterialEditor : public NodeEditor { 7 | public: 8 | MaterialEditor(); 9 | ~MaterialEditor() = default; 10 | 11 | // TODO : clear canvas 12 | void ClearEditor() { 13 | std::cout << "node editor cleared." << std::endl; 14 | } 15 | 16 | void PopMenu() override { 17 | // Numerics ---------------------------------- 18 | if (ImGui::BeginMenu("Numerics")) { 19 | ListSlots("Numeric"); 20 | ImGui::EndMenu(); 21 | } 22 | 23 | // Operators --------------------------------- 24 | if (ImGui::BeginMenu("Operators")) { 25 | ListSlots("Operator"); 26 | ImGui::EndMenu(); 27 | } 28 | 29 | // Procedural Texture ------------------------ 30 | if (ImGui::BeginMenu("Procedural")) { 31 | ListSlots("Procedural"); 32 | ImGui::EndMenu(); 33 | } 34 | 35 | ImGui::Separator(); 36 | // Mtls -------------------------------------- 37 | ListSlots("Material"); 38 | 39 | // Other funcs ------------------------------- 40 | if (anythingSelected) { 41 | ImGui::Separator(); 42 | if (ImGui::MenuItem("Delete")) {} 43 | if (ImGui::MenuItem("Copy")) {} 44 | if (ImGui::MenuItem("Paste")) {} 45 | } 46 | 47 | //if (ImGui::MenuItem("Reset Zoom")) canvas.zoom = 1; 48 | //if (ImGui::IsAnyMouseDown() && !ImGui::IsWindowHovered()) ImGui::CloseCurrentPopup(); 49 | } 50 | }; 51 | 52 | } -------------------------------------------------------------------------------- /ToyBox/MathUtils.cpp: -------------------------------------------------------------------------------- 1 | #include "MathUtils.h" 2 | #include "Matrix4x4.h" 3 | 4 | namespace MOON { 5 | Vector3 MoonMath::RotateAround(const Vector3 &position, const Vector3 ¢er, const Vector3 &axis, const float &angle) { 6 | Vector3 point = Matrix4x4::RotateMat(angle, axis).multVec(position - center); 7 | Vector3 resultVec3 = center + point; 8 | return resultVec3; 9 | } 10 | 11 | float MoonMath::closestDistanceBetweenLines(const Vector3 &a0, const Vector3 &a1, const Vector3 &b0, const Vector3 &b1, Vector3 &Line1Closest, Vector3 &Line2Closest) { 12 | // Based on https://stackoverflow.com/questions/2824478/shortest-distance-between-two-line-segments 13 | float Distance; 14 | 15 | // Calculate denomitator 16 | auto A = a1 - a0; 17 | auto B = b1 - b0; 18 | float magA = A.magnitude(); 19 | float magB = B.magnitude(); 20 | 21 | auto _A = A / magA; 22 | auto _B = B / magB; 23 | 24 | auto cross = Vector3::Cross(_A, _B); 25 | auto denom = cross.magnitude() * cross.magnitude(); 26 | 27 | // If lines are parallel (denom=0) test if lines overlap. 28 | // If they don't overlap then there is a closest point solution. 29 | // If they do overlap, there are infinite closest positions, but there is a closest distance 30 | if (denom == 0) { 31 | auto d0 = Vector3::Dot(_A, (b0 - a0)); 32 | 33 | // Overlap only possible with clamping 34 | auto d1 = Vector3::Dot(_A, (b1 - a0)); 35 | 36 | // Is segment B before A? 37 | if (d0 <= 0 && 0 >= d1) { 38 | if (abs(d0) < abs(d1)) { 39 | Line1Closest = a0; 40 | Line2Closest = b0; 41 | Distance = (a0 - b0).magnitude(); 42 | 43 | return Distance; 44 | } 45 | Line1Closest = a0; 46 | Line2Closest = b1; 47 | Distance = (a0 - b1).magnitude(); 48 | 49 | return Distance; 50 | } 51 | // Is segment B after A? 52 | else if (d0 >= magA && magA <= d1) { 53 | if (abs(d0) < abs(d1)) { 54 | Line1Closest = a1; 55 | Line2Closest = b0; 56 | Distance = (a1 - b0).magnitude(); 57 | 58 | return Distance; 59 | } 60 | Line1Closest = a1; 61 | Line2Closest = b1; 62 | Distance = (a1 - b1).magnitude(); 63 | 64 | return Distance; 65 | } 66 | 67 | // Segments overlap, return distance between parallel segments 68 | Line1Closest = Vector3::ZERO(); 69 | Line2Closest = Vector3::ZERO(); 70 | Distance = (((d0 * _A) + a0) - b0).magnitude(); 71 | return Distance; 72 | } 73 | 74 | // Lines criss-cross: Calculate the projected closest points 75 | auto t = (b0 - a0); 76 | auto detA = Determinant(t, _B, cross); 77 | auto detB = Determinant(t, _A, cross); 78 | 79 | auto t0 = detA / denom; 80 | auto t1 = detB / denom; 81 | 82 | auto pA = a0 + (_A * t0); // Projected closest point on segment A 83 | auto pB = b0 + (_B * t1); // Projected closest point on segment B 84 | 85 | // Clamp projections 86 | if (t0 < 0) pA = a0; 87 | else if (t0 > magA) pA = a1; 88 | 89 | if (t1 < 0) pB = b0; 90 | else if (t1 > magB) pB = b1; 91 | 92 | float dot; 93 | // Clamp projection A 94 | if (t0 < 0 || t0 > magA) { 95 | dot = Vector3::Dot(_B, (pA - b0)); 96 | if (dot < 0) dot = 0; 97 | else if (dot > magB) dot = magB; 98 | pB = b0 + (_B * dot); 99 | } 100 | // Clamp projection B 101 | if (t1 < 0 || t1 > magB) { 102 | dot = Vector3::Dot(_A, (pB - a0)); 103 | if (dot < 0) dot = 0; 104 | else if (dot > magA) dot = magA; 105 | pA = a0 + (_A * dot); 106 | } 107 | 108 | Line1Closest = pA; 109 | Line2Closest = pB; 110 | Distance = (pA - pB).magnitude(); 111 | 112 | return Distance; 113 | } 114 | 115 | } -------------------------------------------------------------------------------- /ToyBox/Matrix.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Matrix.h -------------------------------------------------------------------------------- /ToyBox/Matrix3x3.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Matrix3x3.h -------------------------------------------------------------------------------- /ToyBox/Matrix4x4.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Matrix4x4.h -------------------------------------------------------------------------------- /ToyBox/Mesh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Mesh.cpp -------------------------------------------------------------------------------- /ToyBox/Mesh.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Mesh.h -------------------------------------------------------------------------------- /ToyBox/NFunction.cpp: -------------------------------------------------------------------------------- 1 | #include "NFunction.h" 2 | #include "NGraph.h" 3 | 4 | namespace MOON { 5 | namespace NN { 6 | 7 | void GradDesc::Update() { 8 | for (auto iter = graph->neurons.begin(); iter != graph->neurons.end(); iter++) { 9 | if (typeid(**iter) == typeid(NVariable)) { 10 | NVariable* node = dynamic_cast(*iter); 11 | if (node->trainable) { 12 | Matrix gradient = this->GetGradient(node); 13 | node->SetVal(*node->value - lr * gradient); 14 | } 15 | } 16 | } 17 | } 18 | 19 | void RMSProp::Update() { 20 | for (auto iter = graph->neurons.begin(); iter != graph->neurons.end(); iter++) { 21 | if (typeid(**iter) == typeid(NVariable)) { 22 | NVariable* node = dynamic_cast(*iter); 23 | if (node->trainable) { 24 | Matrix gradient = this->GetGradient(node); 25 | if (s.find(node->id) == s.end()) { 26 | s[node->id] = gradient.Map([](float& i) -> void {i = i * i;}); 27 | } else { 28 | s[node->id] = friction * s[node->id] + (1.0f - friction) * 29 | gradient.Map([](float& i) -> void {i = i * i;}); 30 | } 31 | Matrix res; 32 | Matrix::multiElem(lr * gradient, s[node->id].Map([](float &i) -> 33 | void { i = 1.0 / std::sqrt(i + 1e-10); }), res); 34 | node->SetVal(*node->value - res); 35 | } 36 | } 37 | } 38 | } 39 | 40 | void Adam::Update() { 41 | for (auto iter = graph->neurons.begin(); iter != graph->neurons.end(); iter++) { 42 | if (typeid(**iter) == typeid(NVariable)) { 43 | NVariable* node = dynamic_cast(*iter); 44 | if (node->trainable) { 45 | Matrix gradient = this->GetGradient(node); 46 | int id = node->id; 47 | if (s.find(id) == s.end()) { 48 | v[id] = gradient; 49 | s[id] = gradient.Map([](float &i) -> void { i = i * i; }); 50 | } else { 51 | v[id] = friction.x * v[id] + (1.0 - friction.x) * gradient; 52 | s[id] = friction.y * s[id] + (1.0 - friction.y) * 53 | gradient.Map([](float &i) -> void { i = i * i; }); 54 | } 55 | Matrix res; 56 | Matrix::multiElem(lr * v[id], s[id].Map([](float& i) -> 57 | void { i = 1.0 / std::sqrt(i + 1e-10); }), res); 58 | node->SetVal(*node->value - res); 59 | } 60 | } 61 | } 62 | } 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /ToyBox/NFunction.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "Optimizer.h" 10 | 11 | namespace MOON { 12 | namespace NN { 13 | enum OptimizerType { 14 | GD, 15 | RMSP, 16 | ADAM 17 | }; 18 | 19 | // Gradient Descent 20 | class GradDesc : public Optimizer { 21 | public: 22 | GradDesc(NGraph* graph, Neuron* target, float learningRate = 0.1f, int batch_size = 10) : 23 | Optimizer(graph, target, learningRate, batch_size) {} 24 | 25 | void Update() override; 26 | }; 27 | 28 | // Root Mean Square Prop 29 | class RMSProp : public Optimizer { 30 | public: 31 | float friction; 32 | std::unordered_map s; 33 | 34 | RMSProp(NGraph* graph, Neuron* target, float learningRate = 0.01f, float friction = 0.9f, int batch_size = 32) : 35 | Optimizer(graph, target, learningRate, batch_size) { 36 | assert(0 < friction && friction < 1); 37 | this->friction = friction; 38 | } 39 | 40 | void Update() override; 41 | }; 42 | 43 | // Adaptive Moment Estimation 44 | class Adam : public Optimizer { 45 | public: 46 | Vector2 friction; 47 | std::unordered_map s, v; 48 | 49 | Adam(NGraph* graph, Neuron* target, float learningRate = 0.01f, float f_1 = 0.9f, float f_2 = 0.99f, int batch_size = 10) : 50 | Optimizer(graph, target, learningRate, batch_size) { 51 | assert(0 < f_1 && f_1 < 1); 52 | assert(0 < f_2 && f_2 < 1); 53 | friction.setValue(f_1, f_2); 54 | } 55 | 56 | void Update() override; 57 | }; 58 | 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /ToyBox/NGraph.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/NGraph.cpp -------------------------------------------------------------------------------- /ToyBox/NNBase.h: -------------------------------------------------------------------------------- 1 | /* _ _ _ _ _ _ 2 | * |_|_ _|_| |_|_ |_| |_|_ |_| 3 | * |_|_||_|_| |_|_| _|_| |_|_| _|_| 4 | * |_| |_| |_| |_|_| |_| |_|_| 5 | * |_| |_| |_| |_| |_| |_| 6 | * 7 | * @author HZT 8 | * @date 2020-05-09 9 | * @version 0.1.0 10 | */ 11 | 12 | #pragma once 13 | #include "Neuron.h" 14 | #include "NVariable.h" 15 | #include "Optimizer.h" 16 | #include "NFunction.h" 17 | #include "NNManager.h" 18 | #include "Plotter.h" 19 | 20 | namespace MOON { 21 | namespace NN { 22 | extern class NGraph; 23 | class NNBase { 24 | public: 25 | NGraph* graph; 26 | 27 | Optimizer* opt; 28 | 29 | Neuron* loss; 30 | Neuron* label; 31 | Neuron* feature; 32 | Neuron* predict; 33 | 34 | // dimension of input vector 35 | unsigned int in_size; 36 | // dimension of output vector 37 | unsigned int out_size; 38 | 39 | NNBase(const float &in_size, const float &out_size, NGraph* graph = NNM::globalNNGraph) : 40 | graph(graph), in_size(in_size), out_size(out_size) { 41 | opt = nullptr; loss = nullptr; feature = nullptr; label = nullptr; predict = nullptr; 42 | } 43 | 44 | virtual ~NNBase() = default; 45 | 46 | }; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /ToyBox/NNManager.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "NNManager.h" 6 | 7 | namespace MOON { 8 | namespace NN { 9 | 10 | void NNManager::Draw() { 11 | 12 | } 13 | 14 | } 15 | } -------------------------------------------------------------------------------- /ToyBox/NNManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "NVariable.h" 9 | #include "NGraph.h" 10 | 11 | namespace MOON { 12 | #define MOON_NeuralNetworkManager NN::NNManager 13 | #define NNM NNManager 14 | namespace NN { 15 | class NNManager { 16 | public: 17 | static unsigned int graphCnt; 18 | static NGraph* globalNNGraph; 19 | static NGraph* currentGraph; 20 | static std::vector graphList; 21 | 22 | static void Init() { 23 | globalNNGraph = new NN::NGraph(); 24 | currentGraph = NN::NNM::globalNNGraph; 25 | graphList.push_back(globalNNGraph); 26 | } 27 | 28 | static void Release() { 29 | for (auto& iter : graphList) delete iter; 30 | graphList.clear(); 31 | } 32 | 33 | static unsigned int GenGraphID() { 34 | return graphCnt++; 35 | } 36 | 37 | static NGraph* NewGraph() { 38 | NGraph* newGraph = new NGraph(); 39 | AddGraph(newGraph); 40 | return newGraph; 41 | } 42 | 43 | static NGraph* NewGraph(const std::string &name) { 44 | NGraph* newGraph = new NGraph(name); 45 | AddGraph(newGraph); 46 | return newGraph; 47 | } 48 | 49 | static void AddGraph(NGraph* g) { 50 | auto count = graphList.size(); 51 | graphList.push_back(g); 52 | currentGraph = g; 53 | 54 | std::cout << "[NNM]: Graph " << g->name << (graphList.size() > count ? " was" : " was not") << " inserted." << std::endl; 55 | } 56 | 57 | // TODO 58 | static void RemoveGraph(const NGraph* g) { 59 | 60 | } 61 | static void RemoveGraph(const std::string &name) { 62 | 63 | } 64 | static void RemoveGraph(const int &id) { 65 | 66 | } 67 | 68 | // TODO 69 | static void PrintAllGraphs() { 70 | std::cout << "total graph: " << graphCnt << std::endl; 71 | } 72 | 73 | static void Draw(); 74 | 75 | }; 76 | } 77 | } -------------------------------------------------------------------------------- /ToyBox/NVariable.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/NVariable.h -------------------------------------------------------------------------------- /ToyBox/NativeOperators.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ButtonEx.h" 7 | #include "StackWindow.h" 8 | #include "ObjectBase.h" 9 | #include "OperatorBase.h" 10 | #include "Icons.h" 11 | 12 | namespace MOON { 13 | static Operators* DefineNativeOperators() { 14 | return new Operators{ 15 | // Mesh Operators ----------------------------------------------------------------------- 16 | { "Model", []() -> Operator* { return new Operator("EditModel", 17 | /// content renderer 18 | [](Operator* node) -> bool { 19 | 20 | return false; 21 | }, /// process data 22 | [](MObject* input) -> MObject* { 23 | 24 | } 25 | ); }} 26 | }; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /ToyBox/Neuron.cpp: -------------------------------------------------------------------------------- 1 | #include "Neuron.h" 2 | #include "NNManager.h" 3 | 4 | namespace MOON { 5 | namespace NN { 6 | Neuron::Neuron(NGraph* graph) { 7 | this->graph = graph; 8 | this->value = NULL; 9 | this->jacobi = NULL; 10 | this->id = graph->GenNeuronID(); 11 | graph->AddNode(this); 12 | } 13 | 14 | Neuron::Neuron(Neuron* singleParent, NGraph* graph) { 15 | this->graph = graph; 16 | this->value = NULL; 17 | this->jacobi = NULL; 18 | this->id = graph->GenNeuronID(); 19 | if (singleParent != NULL) { 20 | this->parent.push_back(singleParent); 21 | if (singleParent != this) 22 | singleParent->child.push_back(this); 23 | } 24 | graph->AddNode(this); 25 | } 26 | 27 | Neuron::Neuron(std::vector &parent, NGraph* graph) { 28 | this->graph = graph; 29 | //this->parent = parent; 30 | this->value = NULL; 31 | this->jacobi = NULL; 32 | this->id = graph->GenNeuronID(); 33 | for (auto iter = parent.begin(); iter != parent.end(); iter++) { 34 | this->parent.push_back(*iter); 35 | (*iter)->child.push_back(this); 36 | } 37 | graph->AddNode(this); 38 | } 39 | 40 | void Neuron::SetGraph(NGraph* g) { 41 | graph->RemoveNode(this); 42 | this->id = g->GenNeuronID(); 43 | g->AddNode(this); 44 | // TODO : clear childs and parents 45 | } 46 | 47 | bool operator==(const Neuron &n1, const Neuron &n2) { 48 | /*if (n1.parent == n2.parent && n1.child == n2.child && 49 | n1.value == n2.value && n1.jacobi == n2.jacobi && 50 | n1.graph == n2.graph) return true;*/ 51 | if (n1.graph == n2.graph && n1.id == n2.id) return true; 52 | else return false; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /ToyBox/Neuron.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "Matrix.h" 9 | #include "Utility.h" 10 | 11 | namespace MOON { 12 | namespace NN { 13 | extern class NGraph; 14 | class Neuron { 15 | public: 16 | unsigned int id; 17 | std::vector parent; 18 | std::vector child; 19 | Matrix* value; 20 | Matrix* jacobi; 21 | NGraph* graph; 22 | 23 | Neuron(NGraph* graph); 24 | Neuron(Neuron* singleParent, NGraph* graph); 25 | Neuron(std::vector &parent, NGraph* graph); 26 | 27 | virtual ~Neuron() { 28 | parent.clear(); 29 | child.clear(); 30 | if (value != NULL) delete value; 31 | if (jacobi != NULL) delete jacobi; 32 | } 33 | 34 | friend bool operator==(const Neuron &n1, const Neuron &n2); 35 | 36 | void AddParent(Neuron* p) { 37 | parent.push_back(p); 38 | p->child.push_back(this); 39 | } 40 | void RemoveParent(Neuron* target) { 41 | Utility::RemoveElem(target->child, this); 42 | Utility::RemoveElem(parent, target); 43 | } 44 | 45 | void SetGraph(NGraph* g); 46 | 47 | virtual void Compute() = 0; 48 | virtual void SetVal(const Matrix &val) {} 49 | 50 | void Forward() { 51 | //std::cout << "forward: " << this->id << std::endl; 52 | for (auto iter = parent.begin(); iter != parent.end(); iter++) { 53 | if ((*iter)->value == NULL) (*iter)->Forward(); 54 | } 55 | this->Compute(); 56 | } 57 | 58 | /* 59 | calculate Jacobian Matrix from parent node to this node 60 | */ 61 | virtual Matrix CalcJacobian(const Neuron* parent) { 62 | return Matrix(Dimension(), 1); 63 | } 64 | 65 | int Dimension() const { 66 | assert(value != NULL); 67 | return value->size.x * value->size.y; 68 | } 69 | 70 | Vector2 Shape() const { 71 | if (value != NULL) return value->size; 72 | else { 73 | //std::cout << "[NN]: value is empty! id: " << id << std::endl; 74 | return Vector2::ZERO(); 75 | } 76 | } 77 | 78 | void ResetVal(bool recursive = true) { 79 | if (value != NULL) delete value; 80 | value = NULL; 81 | //std::cout << "reset: " << id << std::endl; 82 | 83 | if (recursive) { 84 | for (auto iter = child.begin(); iter != child.end(); iter++) { 85 | (*iter)->ResetVal(); 86 | } 87 | } 88 | } 89 | 90 | void ClearJacobian() { 91 | if (jacobi != NULL) delete jacobi; 92 | jacobi = NULL; 93 | } 94 | 95 | /* 96 | calculate Jacobian Matrix from result node to this node 97 | r : result node 98 | */ 99 | Matrix Backward(const Neuron* r) { 100 | if (jacobi == NULL) { 101 | if (this == r) { 102 | jacobi = new Matrix(Dimension(), 1); 103 | } else { 104 | jacobi = new Matrix(r->Dimension(), Dimension(), 0); 105 | 106 | for (auto iter = child.begin(); iter != child.end(); iter++) { 107 | if ((*iter)->value != NULL) { 108 | *jacobi += (*iter)->Backward(r) * (*iter)->CalcJacobian(this); 109 | } 110 | } 111 | } 112 | } 113 | 114 | return *jacobi; 115 | } 116 | }; 117 | } 118 | } -------------------------------------------------------------------------------- /ToyBox/OBJExporter.cpp: -------------------------------------------------------------------------------- 1 | #include "OBJMgr.h" 2 | #include "SceneMgr.h" 3 | #include "Texture.h" 4 | #include "Utility.h" 5 | #include "Material.h" 6 | #include "MathUtils.h" 7 | 8 | #include 9 | 10 | #define MOON_DEBUG_MODE 11 | 12 | namespace MOON { 13 | // TODO 14 | } -------------------------------------------------------------------------------- /ToyBox/OBJMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "Vector2.h" 8 | #include "Vector3.h" 9 | #include "Mesh.h" 10 | 11 | namespace MOON { 12 | extern class Model; 13 | 14 | // Get element at given index position 15 | template 16 | inline const T & getElement(const std::vector &elements, std::string &index) { 17 | int idx = std::stoi(index); 18 | if (idx < 0) idx = int(elements.size()) + idx; 19 | else idx--; 20 | return elements[idx]; 21 | } 22 | 23 | // TODO 24 | class OBJExporter { 25 | public: 26 | OBJExporter() = default; 27 | ~OBJExporter() = default; 28 | 29 | bool ExportTo(const std::vector &meshList, const std::string &path); 30 | }; 31 | 32 | class OBJLoader { 33 | public: 34 | static float progress; 35 | static std::string info; 36 | static std::vector LoadedVertices; 37 | static std::vector LoadedIndices; 38 | 39 | //OBJLoader() : info("Loading... ..."), progress(0) {} 40 | //~OBJLoader() = default; 41 | 42 | static void GetInfo(std::string& info, float& progress); 43 | static void LoadFile(Model* container); 44 | static bool LoadFile(const std::string &Path, std::vector &LoadedMeshes); 45 | 46 | private: 47 | // Generate vertices from a list of positions, tcoords, normals and a face line 48 | static void GenVerticesFromRawOBJ(std::vector& oVerts, 49 | const std::vector& iPositions, 50 | const std::vector& iTCoords, 51 | const std::vector& iNormals, 52 | std::string icurline); 53 | 54 | // Triangulate a list of vertices into a face by printing inducies corresponding with triangles within it 55 | static void VertexTriangluation(std::vector& oIndices, 56 | const std::vector& iVerts); 57 | 58 | // Load Materials from .mtl file 59 | static bool LoadMaterials(const std::string &path); 60 | 61 | static Texture* LoadTexture(const std::string &path, const std::string &name = UseFileName); 62 | }; 63 | } 64 | -------------------------------------------------------------------------------- /ToyBox/OP_MeshEditor.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/OperatorBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "ObjectBase.h" 7 | #include "imgui/ImNodesEz.h" 8 | 9 | namespace MOON { 10 | #define Operators std::multimap 11 | 12 | struct Operator { 13 | public: 14 | std::string name; 15 | std::string type; 16 | //std::string path; 17 | 18 | bool enabled = true; 19 | bool opened = true; 20 | //bool executed = false; 21 | 22 | MObject* processed = nullptr; 23 | 24 | // if anything has been changed, return true 25 | bool(*content)(Operator*, MObject*); 26 | ImNodes::SlotData dataHolder; 27 | 28 | MObject* Execute(MObject* object) { 29 | //if (processed != nullptr) delete processed; 30 | processed = execute(this, object); 31 | return processed; 32 | } 33 | 34 | explicit Operator(const std::string& type, const ImNodes::SlotData &data, 35 | bool(*content)(Operator*, MObject*), MObject*(*execute)(Operator*, MObject*)) : 36 | dataHolder(data) { 37 | this->name = this->type = type; 38 | this->content = content; 39 | this->execute = execute; 40 | } 41 | 42 | ~Operator() { 43 | if (processed != nullptr) { 44 | delete processed; 45 | processed = nullptr; 46 | } 47 | } 48 | 49 | void ListName(const unsigned int& ID) { 50 | // list name 51 | char buf[64]; strcpy(buf, name.c_str()); 52 | 53 | //ImGui::Text("Name:"); ImGui::SameLine(); 54 | ImGui::SetNextItemWidth(ImGui::GetContentRegionAvailWidth() - 20); 55 | ImGui::InputText(("Name_" + std::to_string(ID)).c_str(), buf, 64); 56 | 57 | // if user renamed this object 58 | if (strcmp(buf, name.c_str())) name = std::string(buf); 59 | } 60 | 61 | private: 62 | MObject*(*execute)(Operator*, MObject*); 63 | }; 64 | } -------------------------------------------------------------------------------- /ToyBox/OperatorLoader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | 4 | namespace MOON { 5 | class OPLoader { 6 | public: 7 | OPLoader() = default; 8 | ~OPLoader() = default; 9 | 10 | inline static bool LoadAllPlugins(const std::string &path) { 11 | // TODO 12 | 13 | return true; 14 | } 15 | }; 16 | } -------------------------------------------------------------------------------- /ToyBox/OperatorMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "Utility.h" 6 | #include "OperatorBase.h" 7 | #include "PluginManager.h" 8 | 9 | namespace MOON { 10 | extern struct MObject::OPStack; 11 | class OperatorManager { 12 | public: 13 | static Operators* available_operators; 14 | static std::vector matchList; 15 | 16 | static bool showList; 17 | static bool focusKey; 18 | static char buf[64]; 19 | static int selection; 20 | static unsigned int parentID; 21 | 22 | #pragma region operator rendering & searching 23 | static void SearchOps_Fuzzy(const char* typeName); 24 | 25 | static void Instantiate(Operator* op, MObject::OPStack& opstack); 26 | 27 | static void ListCategory(const std::string &typeName, MObject::OPStack& opstack, unsigned int& loop); 28 | 29 | static void ListOperators(MObject::OPStack& opstack); 30 | #pragma endregion 31 | 32 | #pragma region load_operators 33 | static Operators* DefineNativeOperators(); 34 | 35 | inline static bool LoadNativeOperators() { 36 | available_operators = DefineNativeOperators(); 37 | return true; 38 | } 39 | 40 | inline static bool RemoveOperator(const std::string &type) { 41 | 42 | return true; 43 | } 44 | 45 | inline static bool LoadOperatorAtPath(const std::string &path) { 46 | 47 | return true; 48 | } 49 | 50 | inline static bool LoadExternalOperators(const std::string &path) { 51 | 52 | return true; 53 | } 54 | #pragma endregion 55 | }; 56 | } -------------------------------------------------------------------------------- /ToyBox/Optimizer.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Optimizer.cpp -------------------------------------------------------------------------------- /ToyBox/Optimizer.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Optimizer.h -------------------------------------------------------------------------------- /ToyBox/Outline.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform bool isSelected; 4 | out vec4 FragColor; 5 | 6 | void main() { 7 | FragColor = isSelected ? vec4(1.0, 0.0, 0.0, 1.0) : vec4(0.0, 0.0, 1.0, 1.0); 8 | } -------------------------------------------------------------------------------- /ToyBox/Outline.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec3 aNormal; 4 | 5 | uniform mat4 model; 6 | uniform mat4 view; 7 | uniform mat4 projection; 8 | 9 | void main() { 10 | gl_Position = projection * view * model * vec4((aPos + aNormal * 0.1), 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/PBR.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec3 aNormal; 4 | layout (location = 2) in vec2 aTexCoords; 5 | 6 | out vec2 TexCoords; 7 | out vec3 WorldPos; 8 | out vec3 Normal; 9 | 10 | uniform mat4 projection; 11 | uniform mat4 view; 12 | uniform mat4 model; 13 | 14 | void main() { 15 | TexCoords = aTexCoords; 16 | WorldPos = vec3(model * vec4(aPos, 1.0)); 17 | //Normal = mat3(model) * aNormal; 18 | Normal = mat3(transpose(inverse(model))) * aNormal; 19 | 20 | gl_Position = projection * view * vec4(WorldPos, 1.0); 21 | } -------------------------------------------------------------------------------- /ToyBox/PMapGen.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | #include "Vector2.h" 6 | 7 | namespace MOON { 8 | /* CPU based procedural map generator */ 9 | class ProceduralMapGenerator { 10 | public: 11 | static void MakeCheckImage(const Vector2 &PMapSize, GLubyte *checkImage) { 12 | for (int i = 0, c, cnt = 0; i < PMapSize.x; i++) { 13 | for (int j = 0; j < PMapSize.y; j++) { 14 | c = ((((i & 0x8) == 0) ^ ((j & 0x8)) == 0)) * 255; 15 | checkImage[cnt++] = (GLubyte)c; 16 | checkImage[cnt++] = (GLubyte)c; 17 | checkImage[cnt++] = (GLubyte)c; 18 | } 19 | } 20 | } 21 | 22 | static void MakeBlankImage(GLubyte *targetImage) { 23 | memset(targetImage, (GLubyte)0, sizeof(targetImage)); 24 | } 25 | }; 26 | } -------------------------------------------------------------------------------- /ToyBox/PipelineMgr.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "PipelineMgr.h" 5 | #include "SceneMgr.h" 6 | 7 | namespace MOON { 8 | 9 | void PipelineManager::DrawDeferredShading() { 10 | glDisable(GL_DEPTH_TEST); 11 | MOON_ShaderManager::screenBufferShader->use(); 12 | glBindVertexArray(quadVAO); 13 | glBindTexture(GL_TEXTURE_2D, MOON_TextureManager::IDLUT->localID); 14 | glDrawArrays(GL_TRIANGLES, 0, 6); 15 | } 16 | 17 | void PipelineManager::ConfigureScreenQuad() { 18 | glGenVertexArrays(1, &quadVAO); 19 | glGenBuffers(1, &quadVBO); 20 | glBindVertexArray(quadVAO); 21 | glBindBuffer(GL_ARRAY_BUFFER, quadVBO); 22 | glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, GL_STATIC_DRAW); 23 | glEnableVertexAttribArray(0); 24 | glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)0); 25 | glEnableVertexAttribArray(1); 26 | glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(float), (void*)(2 * sizeof(float))); 27 | } 28 | 29 | } -------------------------------------------------------------------------------- /ToyBox/PipelineMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MoonEnums.h" 3 | 4 | namespace MOON { 5 | 6 | class PipelineManager { 7 | public: 8 | static ShadingMode mode; 9 | 10 | static void DrawDeferredShading(); 11 | 12 | private: 13 | static unsigned int quadVAO, quadVBO; 14 | 15 | // vertex attributes for a quad that fills the 16 | // entire screen in Normalized Device Coordinates. 17 | static float quadVertices[24]; 18 | 19 | // config screen quad VAO 20 | static void ConfigureScreenQuad(); 21 | }; 22 | 23 | } -------------------------------------------------------------------------------- /ToyBox/Pixelization.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | 7 | void main() { 8 | vec3 color = texture(screenBuffer, TexCoords).rgb; 9 | 10 | FragColor = vec4(color, 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/Plane.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Mesh.h" 3 | #include "Model.h" 4 | #include "Vector3.h" 5 | 6 | namespace MOON { 7 | 8 | class Plane : public Model { 9 | public: 10 | Vector2 size; 11 | Vector2 segment; 12 | 13 | void CreateProcedural(const bool& interactive) override; 14 | void ListProceduralProperties() override; 15 | 16 | Plane(const std::string &name, const bool& interactive = false, 17 | Vector2 size = Vector2::ONE(), Vector2 segment = Vector2(3, 3), 18 | const int id = MOON_AUTOID) : 19 | Model(name, id), size(size), segment(segment) { 20 | CreateProcedural(interactive); 21 | } 22 | 23 | static void InteractiveCreate(void* arg); 24 | static Mesh* GenerateMesh(Vector2 size, Vector2 segment); 25 | }; 26 | 27 | } -------------------------------------------------------------------------------- /ToyBox/PluginManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | 4 | namespace MOON { 5 | 6 | } 7 | -------------------------------------------------------------------------------- /ToyBox/PluginMgr.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/PostEffects.cpp: -------------------------------------------------------------------------------- 1 | #include "SceneMgr.h" 2 | #include "PostEffects.h" 3 | 4 | namespace MOON { 5 | 6 | bool DepthOfField::PostBehaviour(FrameBuffer* src, FrameBuffer* dst) { 7 | if (fastMode) return false; 8 | 9 | Shader* passShader = MOON_ShaderManager::CreateShader("DOF_Pass", "ScreenBuffer.vs", "DOF_MultiPass.fs"); 10 | 11 | // do three pass 12 | passShader->use(); 13 | 14 | passShader->setBool("debug", debug); 15 | 16 | passShader->setFloat("_distance", distance); 17 | passShader->setFloat("_multiply", multiply); 18 | passShader->setFloat("_tolerance", tolerance); 19 | passShader->setFloat("_cutoff", cutoff); 20 | 21 | passShader->setFloat("_time", radius); 22 | passShader->setFloat("_expo", exposure); 23 | passShader->setFloat("_angle", angle); 24 | 25 | passShader->setFloat("_iter", iter); 26 | passShader->setFloat("_falloff", falloff); 27 | 28 | passShader->setFloat("_accurate", accurate); 29 | 30 | passShader->setTexture("depthBuffer", src->attachment, 2); 31 | passShader->setVec2("dir", 0.02, 0.02); 32 | Graphics::Blit(src, dst, passShader); 33 | passShader->setVec2("dir", 0.02, -0.02); 34 | Graphics::Blit(dst, passShader); 35 | passShader->setVec2("dir", 0.00, 0.04); 36 | Graphics::Blit(dst, passShader); 37 | 38 | //ConfigureProps(); 39 | //Graphics::Blit(dst, shader); 40 | return true; 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /ToyBox/PostFactory.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "PostFactory.h" 3 | 4 | namespace MOON { 5 | 6 | PostEffect* PostFactory::Instantiate(std::string className) { 7 | auto iter = effectList.find(className); 8 | if (iter == effectList.end()) return NULL; 9 | else return iter->second(); 10 | } 11 | 12 | void PostFactory::RegistClass(std::string name, EffectCreator method) { 13 | effectList.insert(std::pair(name, method)); 14 | } 15 | 16 | RegisterAction::RegisterAction(std::string className, EffectCreator ptrCreateFn) { 17 | PostFactory::RegistClass(className, ptrCreateFn); 18 | } 19 | 20 | } -------------------------------------------------------------------------------- /ToyBox/PostFactory.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include "Graphics.h" 5 | 6 | namespace MOON { 7 | typedef PostEffect*(*EffectCreator)(); 8 | 9 | #define REGIST_POST_EFFECT(effect) \ 10 | PostEffect* objectCreator##effect(){ \ 11 | return new effect; \ 12 | } \ 13 | RegisterAction g_creatorRegister##effect(#effect, \ 14 | (EffectCreator)objectCreator##effect) 15 | 16 | class PostFactory { 17 | public: 18 | static std::map effectList; 19 | static PostEffect* Instantiate(std::string className); 20 | static void RegistClass(std::string name, EffectCreator method); 21 | }; 22 | 23 | class RegisterAction { 24 | public: 25 | RegisterAction(std::string className, EffectCreator ptrCreateFn); 26 | }; 27 | 28 | } -------------------------------------------------------------------------------- /ToyBox/PreIntegerSSS.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | in vec3 WorldPos; 5 | in vec3 Normal; 6 | 7 | uniform int specType; 8 | 9 | uniform vec3 tintColor; 10 | uniform vec3 specColor; 11 | uniform vec3 scatColor; 12 | 13 | uniform sampler2D albedoMap; 14 | uniform sampler2D normalMap; 15 | uniform sampler2D roughnessMap; 16 | uniform sampler2D scatterMap; 17 | uniform sampler2D SSSLUTMap; 18 | uniform sampler2D kelemenLUTMap; 19 | 20 | uniform float _roughness; 21 | uniform float _specMulti; 22 | uniform float _curveFactor; 23 | 24 | uniform float _distortion; 25 | uniform float _scatMulti; 26 | uniform float _scatScale; 27 | 28 | void main() { 29 | FragColor = vec4(vec3(0.5), 1.0); 30 | } 31 | -------------------------------------------------------------------------------- /ToyBox/ProceduralMap.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/ProceduralMap.h -------------------------------------------------------------------------------- /ToyBox/Proxy.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HelperBase.h" 3 | 4 | namespace MOON { 5 | 6 | class Proxy : public Helper { 7 | public: 8 | 9 | 10 | }; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /ToyBox/Quaternion.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Quaternion.cpp -------------------------------------------------------------------------------- /ToyBox/RFX_Solver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace MOON { 4 | namespace RaindropFX { 5 | 6 | class Solver { 7 | public: 8 | 9 | 10 | }; 11 | 12 | } 13 | } -------------------------------------------------------------------------------- /ToyBox/RNN.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/Ray.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector3.h" 4 | 5 | namespace MOON { 6 | class Ray { 7 | public: 8 | Vector3 pos; 9 | Vector3 dir; 10 | 11 | Ray() {} 12 | Ray(const Ray &r) : pos(r.pos), dir(r.dir) {} 13 | Ray(const Vector3 &position, const Vector3 &direction) { 14 | pos = position; 15 | dir = direction; 16 | } 17 | 18 | friend std::ostream& operator<<(std::ostream &os, const Ray &r) { 19 | os << "pos: " << r.pos << ", dir: " << r.dir; 20 | return os; 21 | } 22 | 23 | inline Vector3 PointAtParameter(float dist) const { 24 | return pos + dist * dir; 25 | } 26 | }; 27 | } -------------------------------------------------------------------------------- /ToyBox/Renderer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * _ _ _ _ ______ _ __ _ __ _ __ _ 3 | * |_)|_||_)|_) | | |_)|_ |\|| \|_ |_)|_ |_) 4 | * | \| ||_)|_)_|_ | | \|__| ||_/|__| \|__| \ 5 | * 6 | * @author HZT 7 | * @date 2020-11-16 8 | * @version 0.1.8 9 | */ 10 | 11 | #pragma once 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "BVH.h" 18 | #include "VFB.h" 19 | #include "Vector2.h" 20 | #include "Utility.h" 21 | #include "Hitable.h" 22 | #include "Texture.h" 23 | #include "MatSphere.h" 24 | #include "PostEffects.h" 25 | 26 | namespace MOON { 27 | extern class Camera; 28 | class Renderer { 29 | public: 30 | enum AccStruct { 31 | acc_NONE, 32 | acc_AABB, 33 | acc_BVH, 34 | acc_BSP, 35 | acc_KDTree 36 | }; 37 | 38 | enum RenderMode { 39 | scanline, 40 | bucket, 41 | progressive 42 | }; 43 | 44 | enum SamplingMode { 45 | BruteForce, 46 | PhotonMapping, 47 | LightCache, 48 | IrradianceMap 49 | }; 50 | 51 | // global settings 52 | static AccStruct acc; 53 | static TexFilter filter; 54 | static RenderMode renderMode; 55 | static SamplingMode sampleMode; 56 | static ToneMappingMethod tone; 57 | 58 | static int bucketSize; 59 | 60 | static bool depth; 61 | static bool motion; 62 | static bool useIS; // enable importance sampling 63 | static float aspect; 64 | static Vector2 OUTPUT_SIZE; 65 | static GLfloat *matPrevRaw; 66 | static GLfloat *outputRAW; 67 | static FrameBuffer* output; 68 | //static GLuint outputTexID; 69 | 70 | static Camera matCamera; 71 | static Camera* targetCamera; 72 | 73 | static std::string timeStamp; 74 | 75 | static unsigned int samplingRate; 76 | static unsigned int prevSampleRate; 77 | static unsigned int maxReflectionDepth; 78 | 79 | // local params 80 | static clock_t start, end; 81 | static float progress; 82 | static bool isAbort; 83 | static bool prevInQueue; 84 | 85 | // functions 86 | static void StartRendering(); 87 | 88 | static void* renderingMatPreview(void* args); 89 | static void* renderingTestImage(void* args); 90 | static void* rendering(void* args); 91 | 92 | static bool PrepareVFB(); 93 | static bool PrepareRendering(); 94 | static bool PrepareMatPrevRendering(Texture* target); 95 | static void SetOutputSize(unsigned int width, unsigned int height); 96 | 97 | static void Clear() { 98 | VFB::Clear(); 99 | if (output != nullptr) delete output; 100 | if (outputRAW != nullptr) free(outputRAW); 101 | if (matPrevRaw != nullptr) free(matPrevRaw); 102 | } 103 | 104 | private: 105 | static void UpdateTimeStamp(); 106 | static Vector3 SamplingColor(const Ray &r, int depth); 107 | static Vector3 SamplingColor_IS(const Ray &r, int depth); 108 | static Vector3 SamplingColor_MatPrev(const Ray &r, int depth, const MSphere* ball, const MSphere* ground); 109 | 110 | // environment sampling 111 | static Vector3 ProceduralSky(const Ray &r); 112 | static Vector3 SampleSphericalMap(const Ray &r); 113 | }; 114 | } -------------------------------------------------------------------------------- /ToyBox/Resources/Icon.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/Icon.jpg -------------------------------------------------------------------------------- /ToyBox/Resources/Icon_fullSize.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/Icon_fullSize.jpg -------------------------------------------------------------------------------- /ToyBox/Resources/Icon_fullSize.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/Icon_fullSize.png -------------------------------------------------------------------------------- /ToyBox/Resources/MaterialIcons-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/MaterialIcons-Regular.ttf -------------------------------------------------------------------------------- /ToyBox/Resources/fontaudio.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/fontaudio.ttf -------------------------------------------------------------------------------- /ToyBox/Resources/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /ToyBox/Resources/kenney-icon-font.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/kenney-icon-font.ttf -------------------------------------------------------------------------------- /ToyBox/Resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/logo.png -------------------------------------------------------------------------------- /ToyBox/Resources/msyh.ttc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Resources/msyh.ttc -------------------------------------------------------------------------------- /ToyBox/Ring.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Ring.cpp -------------------------------------------------------------------------------- /ToyBox/Ring.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Mesh.h" 3 | #include "Model.h" 4 | #include "Vector3.h" 5 | 6 | namespace MOON { 7 | 8 | class Ring : public Model { 9 | public: 10 | Vector2 size; 11 | Vector2 segment; 12 | 13 | void CreateProcedural(const bool& interactive) override; 14 | void ListProceduralProperties() override; 15 | 16 | Ring(const std::string &name, const bool& interactive = false, 17 | Vector2 size = Vector2::ONE(), Vector2 segment = Vector2(3, 3), 18 | const int id = MOON_AUTOID) : 19 | Model(name, id), size(size), segment(segment) { 20 | CreateProcedural(interactive); 21 | } 22 | 23 | static void InteractiveCreate(void* arg); 24 | static Mesh* GenerateMesh(Vector2 size, Vector2 segment); 25 | }; 26 | 27 | } -------------------------------------------------------------------------------- /ToyBox/SEM.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | in vec3 vN; 3 | in vec3 eye; 4 | 5 | uniform sampler2D tMatCap; 6 | 7 | void main() { 8 | // r = e - 2.0 * dot(n, e) * n; 9 | vec3 r = reflect(normalize(eye), normalize(vN)); 10 | // m = 2.0 * sqrt(pow(r.x, 2.0) + pow(r.y, 2.0) + pow(r.z + 1.0, 2.0)); 11 | float m = 2.82842712474619 * sqrt(r.z + 1.0); 12 | 13 | vec2 uv = r.xy / m + 0.5; 14 | uv.y = 1.0 - uv.y; 15 | 16 | vec3 base = texture2D(tMatCap, uv).rgb; 17 | gl_FragColor = vec4(base, 1.0); 18 | } -------------------------------------------------------------------------------- /ToyBox/SEM.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 position; 3 | layout (location = 1) in vec3 normal; 4 | layout (location = 2) in vec2 uv; 5 | 6 | out vec3 vN; 7 | out vec3 eye; 8 | 9 | uniform mat4 model; 10 | uniform mat4 view; 11 | uniform mat4 projection; 12 | 13 | void main() { 14 | mat4 modelViewMat = view * model; 15 | vec4 p = vec4(position, 1.0); 16 | 17 | eye = vec3(modelViewMat * p); 18 | vN = mat3(transpose(inverse(modelViewMat))) * normal; 19 | 20 | gl_Position = projection * modelViewMat * p; 21 | } -------------------------------------------------------------------------------- /ToyBox/SEM_Phong.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | uniform sampler2D tMatCap; 4 | 5 | varying vec3 e; 6 | varying vec3 n; 7 | 8 | void main() { 9 | vec3 r = reflect( e, n ); 10 | float m = 2. * sqrt( pow( r.x, 2. ) + pow( r.y, 2. ) + pow( r.z + 1., 2. ) ); 11 | vec2 vN = r.xy / m + .5; 12 | 13 | vec3 base = texture2D( tMatCap, vN ).rgb; 14 | 15 | gl_FragColor = vec4( base, 1. ); 16 | } -------------------------------------------------------------------------------- /ToyBox/SEM_Phong.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | varying vec3 e; 4 | varying vec3 n; 5 | 6 | void main() { 7 | e = normalize( vec3( modelViewMatrix * vec4( position, 1.0 ) ) ); 8 | n = normalize( normalMatrix * normal ); 9 | 10 | gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1. ); 11 | } 12 | -------------------------------------------------------------------------------- /ToyBox/SM_Solver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | namespace MOON { 4 | namespace SplineMesher { 5 | 6 | class Solver { 7 | 8 | }; 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /ToyBox/SSAO.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | 7 | void main() { 8 | vec3 color = texture(screenBuffer, TexCoords).rgb; 9 | 10 | FragColor = vec4(color, 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/SSR.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | 7 | void main() { 8 | vec3 color = texture(screenBuffer, TexCoords).rgb; 9 | 10 | FragColor = vec4(color, 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/ScreenBlend.fs: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/ScreenBuffer.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform sampler2D screenBuffer; 6 | 7 | void main() { 8 | vec3 color = texture(screenBuffer, TexCoords).rgb; 9 | 10 | FragColor = vec4(color, 1.0); 11 | } -------------------------------------------------------------------------------- /ToyBox/ScreenBuffer.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec2 aTexCoords; 4 | 5 | out vec2 TexCoords; 6 | 7 | void main() { 8 | TexCoords = aTexCoords; 9 | gl_Position = vec4(aPos, 1.0); 10 | } -------------------------------------------------------------------------------- /ToyBox/ShapeBase.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "ObjectBase.h" 3 | 4 | namespace MOON { 5 | 6 | class Shape : MObject { 7 | public: 8 | 9 | }; 10 | 11 | } -------------------------------------------------------------------------------- /ToyBox/Shapes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Icons.h" 3 | #include "ObjectBase.h" 4 | #include "Spline.h" 5 | 6 | namespace MOON { 7 | class Shape : public MObject { 8 | public: 9 | std::vector splineList; 10 | 11 | Shape(const std::string &name, const int id = MOON_AUTOID) : MObject(name, id) { } 12 | virtual ~Shape() override = default; 13 | 14 | void ListProperties() override { 15 | // list name ---------------------------------------------------------------------- 16 | ListName(); 17 | ImGui::Separator(); 18 | 19 | // list transform ----------------------------------------------------------------- 20 | ListTransform(); 21 | ImGui::Separator(); 22 | 23 | // list Splines ------------------------------------------------------------------- 24 | ListSplinePropties(); 25 | ImGui::Separator(); 26 | 27 | // list operators ----------------------------------------------------------------- 28 | opstack.ListStacks(); 29 | ImGui::Spacing(); 30 | } 31 | 32 | void AddSpline(const std::string &name, const SplineType &type) { 33 | splineList.push_back(Spline(name, type)); 34 | } 35 | 36 | void Draw(Shader* overrideShader = NULL) override { 37 | for (auto sp : splineList) { 38 | sp.Draw(transform.localToWorldMat, wireColor, overrideShader); 39 | if (selected && overrideShader == NULL) 40 | sp.DrawHandles(transform.localToWorldMat, wireColor); 41 | } 42 | } 43 | 44 | void DebugVectors() { 45 | for (auto sp : splineList) { 46 | sp.DebugVectors(transform.localToWorldMat); 47 | } 48 | } 49 | 50 | virtual void ListSplinePropties() { 51 | ImGui::Text("Spline:"); 52 | if (ImGui::TreeNodeEx((std::to_string(splineList.size()) + " spline(s)").c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { 53 | for (auto &iter : splineList) { 54 | if (ImGui::TreeNodeEx(iter.name.c_str(), ImGuiTreeNodeFlags_DefaultOpen)) { 55 | iter.ListParameters(); 56 | iter.ListKnots(); 57 | iter.ListControllers(); 58 | ImGui::TreePop(); 59 | } 60 | } 61 | ImGui::TreePop(); 62 | } 63 | } 64 | }; 65 | 66 | class Line : public Shape { 67 | public: 68 | Line(const std::string &name, const int id = MOON_AUTOID) : Shape(name, id) { 69 | splineList.push_back(Spline(("spline_" + std::to_string(splineList.size())).c_str(), CORNER)); 70 | splineList[0].knotList.push_back(Vector3::ZERO()); 71 | splineList[0].knotList.push_back(Vector3(1, 0, 0)); 72 | splineList[0].controllerList.push_back(Vector3(0.25f, 0, 0)); 73 | splineList[0].controllerList.push_back(Vector3(0.75f, 0, 0)); 74 | splineList[0].Update(); 75 | } 76 | ~Line() override = default; 77 | }; 78 | 79 | class Circle : public Shape { 80 | public: 81 | float radius; 82 | 83 | }; 84 | 85 | class Rectangle : public Shape { 86 | public: 87 | Vector2 size; 88 | float rounded; 89 | 90 | }; 91 | 92 | class NGone : public Shape { 93 | public: 94 | unsigned int sides; 95 | float theta; 96 | 97 | }; 98 | 99 | } -------------------------------------------------------------------------------- /ToyBox/SimplePhong.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | 4 | in vec3 Normal; 5 | in vec3 FragPos; 6 | 7 | uniform vec3 lightPos; 8 | uniform vec3 viewPos; 9 | uniform vec3 lightColor; 10 | uniform vec3 objectColor; 11 | //uniform bool isHovered; 12 | //uniform bool isSelected; 13 | 14 | void main() { 15 | // ambient 16 | float ambientStrength = 0.1; 17 | vec3 ambient = ambientStrength * lightColor; 18 | 19 | // diffuse 20 | vec3 norm = normalize(Normal); 21 | vec3 lightDir = normalize(lightPos - FragPos); 22 | float diff = max(dot(norm, lightDir), 0.0); 23 | vec3 diffuse = diff * lightColor; 24 | 25 | // specular 26 | float specularStrength = 0.5; 27 | vec3 viewDir = normalize(viewPos - FragPos); 28 | vec3 reflectDir = reflect(-lightDir, norm); 29 | float spec = pow(max(dot(viewDir, reflectDir), 0.0), 128); 30 | vec3 specular = specularStrength * spec * lightColor; 31 | 32 | vec3 result = (ambient + diffuse + specular) * objectColor; 33 | //if (isSelected) 34 | //FragColor = vec4(result, 1.0) * 0.8 + vec4(1.0, 1.0, 0.0, 1.0) * 0.2; 35 | //else if (isHovered) 36 | //FragColor = vec4(result, 1.0) * 0.8 + vec4(0.529, 0.808, 1.0, 1.0) * 0.2; 37 | //else 38 | FragColor = vec4(result, 1.0); 39 | } -------------------------------------------------------------------------------- /ToyBox/SimplePhong.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | layout (location = 1) in vec3 aNormal; 4 | 5 | out vec3 FragPos; 6 | out vec3 Normal; 7 | 8 | uniform mat4 model; 9 | uniform mat4 view; 10 | uniform mat4 projection; 11 | 12 | void main() { 13 | FragPos = vec3(model * vec4(aPos, 1.0)); 14 | Normal = mat3(transpose(inverse(model))) * aNormal; 15 | 16 | gl_Position = projection * view * vec4(FragPos, 1.0); 17 | } -------------------------------------------------------------------------------- /ToyBox/SmartMeshes.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Capsule.h" 3 | #include "Cylinder.h" 4 | #include "Ring.h" 5 | #include "Sphere.h" 6 | #include "Plane.h" 7 | #include "Box.h" -------------------------------------------------------------------------------- /ToyBox/Sphere.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "Mesh.h" 3 | #include "Model.h" 4 | 5 | namespace MOON { 6 | 7 | class Sphere : public Model { 8 | public: 9 | float radius; 10 | int segment; 11 | 12 | void CreateProcedural(const bool& interactive) override; 13 | void ListProceduralProperties() override; 14 | 15 | Sphere(const std::string &name, const bool& interactive = false, 16 | float radius = 1.0f, int segment = 24, const int id = MOON_AUTOID) : 17 | Model(name, id), radius(radius), segment(segment) { 18 | CreateProcedural(interactive); 19 | } 20 | 21 | ~Sphere() override {}; 22 | 23 | static void InteractiveCreate(void* arg); 24 | static Mesh* GenerateMesh(float rad, int divs); 25 | }; 26 | 27 | } -------------------------------------------------------------------------------- /ToyBox/SphericalSampling.fs: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/StackWindow.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | 6 | #include "Icons.h" 7 | 8 | namespace MOON { 9 | #define Icon_Name_To_ID(x, y) (std::string(x) + y).c_str() 10 | 11 | enum StackWndType { 12 | QUERY, 13 | PROGRESS 14 | }; 15 | 16 | static bool regQuery = false; 17 | static bool regProgress = false; 18 | 19 | // stack window(delegation) 20 | static void RegistStackWnd(const std::string& wndName, const StackWndType type = StackWndType::QUERY) { 21 | switch (type) { 22 | case StackWndType::QUERY: 23 | regQuery = true; break; 24 | case StackWndType::PROGRESS: 25 | regProgress = true; break; 26 | default: 27 | return; 28 | } 29 | } 30 | 31 | template 32 | static void QueryWnd(const std::string& wndName, const std::string& content, T* tar, void (T::*deleMethod)()) { 33 | bool dummy_open = true; 34 | if (regQuery) { 35 | ImGui::OpenPopup(Icon_Name_To_ID(ICON_FA_EXCLAMATION_TRIANGLE, " " + wndName)); 36 | regQuery = false; 37 | } 38 | if (ImGui::BeginPopupModal(Icon_Name_To_ID(ICON_FA_EXCLAMATION_TRIANGLE, " " + wndName), &dummy_open, ImGuiWindowFlags_NoResize)) { 39 | ImVec2 size = ImGui::CalcTextSize(content.c_str()); 40 | ImGui::SetWindowSize(ImVec2(size.x + 30.0f, size.y + 65.0f)); 41 | ImGui::Text(content.c_str()); 42 | if (ImGui::Button("Yes")) { 43 | (tar->*deleMethod)(); 44 | ImGui::CloseCurrentPopup(); 45 | } 46 | ImGui::SameLine(); 47 | if (ImGui::Button("No")) ImGui::CloseCurrentPopup(); 48 | ImGui::EndPopup(); 49 | } 50 | } 51 | 52 | static void ProgressWnd(const std::string& wndName, const std::string* content, const float* progress) { 53 | if (regProgress) { 54 | ImGui::OpenPopup(Icon_Name_To_ID(ICON_FA_HOURGLASS_HALF, " " + wndName)); 55 | regProgress = false; 56 | } 57 | if (ImGui::BeginPopupModal(Icon_Name_To_ID(ICON_FA_HOURGLASS_HALF, " " + wndName), 0, ImGuiWindowFlags_NoResize)) { 58 | ImGui::SetWindowSize(ImVec2(200.0f, 80.0f)); 59 | ImGui::Text((*content).c_str()); 60 | ImGui::ProgressBar(*progress); 61 | if (*progress >= 1.0f) { 62 | ImGui::CloseCurrentPopup(); 63 | } 64 | ImGui::EndPopup(); 65 | } 66 | } 67 | 68 | } -------------------------------------------------------------------------------- /ToyBox/Starry.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Starry.cpp -------------------------------------------------------------------------------- /ToyBox/Starry.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/Tape.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "HelperBase.h" 3 | 4 | namespace MOON { 5 | 6 | class Tape : public Helper { 7 | public: 8 | 9 | 10 | }; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /ToyBox/TextMesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | -------------------------------------------------------------------------------- /ToyBox/Texture.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Texture.h -------------------------------------------------------------------------------- /ToyBox/ThreadPool.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #define HAVE_STRUCT_TIMESPEC 3 | #include 4 | #include 5 | #include 6 | #include 7 | #pragma comment(lib, "pthreadVC2.lib") 8 | 9 | namespace MOON { 10 | #define MAX_THREADSNUM std::thread::hardware_concurrency() 11 | 12 | class MThread { 13 | private: 14 | std::thread m_t; 15 | 16 | public: 17 | template 18 | explicit MThread(void (T::*deleMethod)(void*), T* tasker, void* arg) { 19 | m_t = std::thread(deleMethod, tasker, arg); 20 | } 21 | ~MThread() { if (m_t.joinable()) m_t.join(); } 22 | 23 | MThread(MThread const&) = delete; 24 | }; 25 | 26 | class ThreadPool { 27 | public: 28 | static std::vector pool; 29 | 30 | inline static void WaitAllThreadExit() { 31 | for (std::thread* th : pool) { 32 | if (th->joinable()) th->join(); 33 | } 34 | } 35 | 36 | inline static void Clean() { 37 | for (std::thread* th : pool) delete th; 38 | pool.clear(); 39 | } 40 | 41 | // method need to be static 42 | inline static void CreateThread(void* (*method)(void*), void* arg) { 43 | pthread_t newThread; 44 | int ret = pthread_create(&newThread, NULL, method, arg); 45 | if (ret) std::cout << "thread error! pthread_create error: error_code=" << ret << std::endl; 46 | else std::cout << "new thread created!" << std::endl; 47 | } 48 | 49 | template 50 | inline static void CreateThread(void (T::*deleMethod)(P&), T* tasker, P& arg) { 51 | std::thread* newThread = new std::thread(deleMethod, tasker, arg); 52 | //newThread->detach(); 53 | pool.push_back(newThread); 54 | } 55 | }; 56 | 57 | } -------------------------------------------------------------------------------- /ToyBox/ToneMapping.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform int type; 6 | uniform float gamma; // default 2.2 7 | uniform sampler2D screenBuffer; 8 | uniform sampler2D FilmLut; 9 | 10 | float a = 2.51, b = 0.03, c = 2.43, d = 0.59, e = 0.14; 11 | float A = 0.15, B = 0.50, C = 0.10, D = 0.20, E = 0.02, F = 0.30, W = 11.2; 12 | 13 | vec3 Uncharted2Tonemap(vec3 x) { 14 | return ((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F; 15 | } 16 | vec3 UnchartedStyleTonemap(vec3 texColor) { 17 | texColor *= 16; // Hardcoded Exposure Adjustment 18 | 19 | float ExposureBias = 1.0; 20 | vec3 curr = Uncharted2Tonemap(ExposureBias * texColor); 21 | 22 | // whiteScale: Uncharted2Tonemap(vec3(W)) 23 | vec3 color = curr / Uncharted2Tonemap(vec3(W)); 24 | 25 | return color; 26 | } 27 | 28 | vec3 log10(vec3 x) { 29 | return log2(x) / log2(10.0); 30 | } 31 | vec3 Cineon(vec3 texColor) { 32 | texColor *= 16.0; // Hardcoded Exposure Adjustment 33 | 34 | vec3 ld = vec3(0.002); 35 | float linReference = 0.18; 36 | float logReference = 444; 37 | float logGamma = 0.45; 38 | 39 | vec3 LogColor = log10(0.4 * texColor.rgb / linReference) / ld * logGamma + logReference; 40 | LogColor /= 1023.0; 41 | LogColor.rgb = clamp(LogColor.rgb, 0.0, 1.0); 42 | 43 | float FilmLutWidth = 256.0; 44 | float Padding = 0.5 / FilmLutWidth; 45 | 46 | // apply response lookup and color grading for target display 47 | vec3 retColor; 48 | retColor.r = texture(FilmLut, vec2(mix(Padding, 1 - Padding, LogColor.r), 0.5)).r; 49 | retColor.g = texture(FilmLut, vec2(mix(Padding, 1 - Padding, LogColor.g), 0.5)).r; 50 | retColor.b = texture(FilmLut, vec2(mix(Padding, 1 - Padding, LogColor.b), 0.5)).r; 51 | 52 | return clamp(retColor, 0.0, 1.0); 53 | } 54 | 55 | vec3 ACESFilm(vec3 x) { 56 | return clamp((x*(a*x+b))/(x*(c*x+d)+e), 0.0, 1.0); 57 | } 58 | 59 | void main() { 60 | vec3 hdrColor = texture(screenBuffer, TexCoords).rgb; 61 | vec3 mapped = hdrColor; 62 | 63 | if (type == 0) { // Reinhard tone mapping 64 | mapped = hdrColor / (hdrColor + vec3(1.0)); 65 | } else if (type == 1) { // Cineon converter 66 | mapped = Cineon(hdrColor); 67 | } else if (type == 2) { // ACES tone mapping 68 | mapped = ACESFilm(hdrColor); 69 | } else if (type == 3) { // Uncharted2 Style Tonemap 70 | mapped = UnchartedStyleTonemap(hdrColor); 71 | } 72 | 73 | if (type == 4){ // applyLUT 74 | // TODO 75 | } else { 76 | // Gamma correction 77 | mapped = pow(mapped, vec3(1.0 / gamma)); 78 | } 79 | 80 | FragColor = vec4(mapped, 1.0); 81 | } -------------------------------------------------------------------------------- /ToyBox/UIController.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/UIController.h -------------------------------------------------------------------------------- /ToyBox/VFB.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/VFB.cpp -------------------------------------------------------------------------------- /ToyBox/VFB.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include "Icons.h" 4 | #include "Texture.h" 5 | #include "PostEffects.h" 6 | #include "StackWindow.h" 7 | 8 | namespace MOON { 9 | 10 | class VFB { 11 | public: 12 | static bool show; 13 | static bool show_history; 14 | static bool show_postfx; 15 | 16 | static std::vector postStack; 17 | 18 | static void Draw(); 19 | static void VFB_Main(); 20 | static void VFB_History(); 21 | static void VFB_PostFX(); 22 | 23 | static void UpdateOutput(); 24 | 25 | static void Clear() { 26 | if (postStack.size()) Utility::ReleaseVector(postStack); 27 | } 28 | 29 | static void InitPostStack() { 30 | postStack = std::vector{ 31 | new ColorSpaceConverter(), 32 | new Exposure(), 33 | new ColorCorrection(), 34 | new Levels(), 35 | new Curve(), 36 | new Bloom(), 37 | new Flare(), 38 | new ToneMapping() 39 | }; 40 | } 41 | }; 42 | 43 | } -------------------------------------------------------------------------------- /ToyBox/Vector2.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector2.h" 2 | #include "Vector3.h" 3 | 4 | namespace MOON { 5 | Vector2::Vector2(const Vector3 &v) { 6 | x = v.x; y = v.y; 7 | } 8 | 9 | bool operator==(const Vector2 &v1, const Vector2 &v2) { 10 | if (v1.x == v2.x && v1.y == v2.y) return true; 11 | else return false; 12 | } 13 | 14 | bool operator!=(const Vector2 &v1, const Vector2 &v2) { 15 | if (v1.x == v2.x && v1.y == v2.y) return false; 16 | else return true; 17 | } 18 | 19 | std::istream& operator>>(std::istream &is, Vector2 &t) { 20 | is >> t.x >> t.y; 21 | return is; 22 | } 23 | 24 | std::ostream& operator<<(std::ostream &os, const Vector2 &t) { 25 | os << "(" << t.x << ", " << t.y << ")"; 26 | return os; 27 | } 28 | 29 | Vector2 operator+(const Vector2 &v1, const Vector2 &v2) { 30 | return Vector2(v1.x + v2.x, v1.y + v2.y); 31 | } 32 | 33 | Vector2 operator-(const Vector2 &v1, const Vector2 &v2) { 34 | return Vector2(v1.x - v2.x, v1.y - v2.y); 35 | } 36 | 37 | Vector2 operator*(const Vector2 &v1, const Vector2 &v2) { 38 | return Vector2(v1.x * v2.x, v1.y * v2.y); 39 | } 40 | 41 | Vector2 operator/(const Vector2 &v1, const Vector2 &v2) { 42 | return Vector2(v1.x / v2.x, v1.y / v2.y); 43 | } 44 | 45 | Vector2 operator*(const float &t, const Vector2 &v) { 46 | return Vector2(t * v.x, t * v.y); 47 | } 48 | 49 | Vector2 operator/(const float &t, const Vector2 &v) { 50 | return Vector2(v.x / t, v.y / t); 51 | } 52 | 53 | Vector2 operator*(const Vector2 &v, const float &t) { 54 | return Vector2(t * v.x, t * v.y); 55 | } 56 | 57 | Vector2 operator/(const Vector2 &v, const float &t) { 58 | return Vector2(v.x / t, v.y / t); 59 | } 60 | 61 | Vector2& Vector2::operator+=(const Vector2 &v) { 62 | x += v.x; y += v.y; 63 | return *this; 64 | } 65 | 66 | Vector2& Vector2::operator-=(const Vector2 &v) { 67 | x -= v.x; y -= v.y; 68 | return *this; 69 | } 70 | 71 | Vector2& Vector2::operator*=(const Vector2 &v) { 72 | x *= v.x; y *= v.y; 73 | return *this; 74 | } 75 | 76 | Vector2& Vector2::operator/=(const Vector2 &v) { 77 | x /= v.x; y /= v.y; 78 | return *this; 79 | } 80 | 81 | Vector2& Vector2::operator*=(const float &t) { 82 | x *= t; y *= t; 83 | return *this; 84 | } 85 | 86 | Vector2& Vector2::operator/=(const float &t) { 87 | x /= t; y /= t; 88 | return *this; 89 | } 90 | 91 | Vector2 Vector2::Normalize(const Vector2 &v) { 92 | float len = 1 / v.magnitude(); 93 | 94 | return Vector2(v.x, v.y) * len; 95 | } 96 | 97 | float Vector2::Dot(const Vector2 &v1, const Vector2 &v2) { 98 | return v1.x * v2.x + v1.y * v2.y; 99 | } 100 | 101 | float Vector2::Cross(const Vector2 &v1, const Vector2 &v2) { 102 | return (v1.x * v2.y - v1.y * v2.x); 103 | } 104 | 105 | Vector2 Vector2::ONE() { 106 | return Vector2(1.0, 1.0); 107 | } 108 | 109 | Vector2 Vector2::ZERO() { 110 | return Vector2(0.0, 0.0); 111 | } 112 | } -------------------------------------------------------------------------------- /ToyBox/Vector2.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/Vector2.h -------------------------------------------------------------------------------- /ToyBox/Vector4.cpp: -------------------------------------------------------------------------------- 1 | #include "Vector4.h" 2 | #include "Vector3.h" 3 | 4 | namespace MOON { 5 | Vector4::Vector4(const Vector3 &v) : x(v.x), y(v.y), z(v.z), w(1) {} 6 | 7 | std::istream& operator>>(std::istream &is, Vector4 &t) { 8 | is >> t.x >> t.y >> t.z >> t.w; 9 | return is; 10 | } 11 | 12 | std::ostream& operator<<(std::ostream &os, const Vector4 &t) { 13 | os << "(" << t.x << ", " << t.y << ", " << t.z << ", " << t.w << ")"; 14 | return os; 15 | } 16 | 17 | Vector4& Vector4::operator+=(const Vector4 &v) { 18 | x += v.x; y += v.y; z += v.z; w += v.w; 19 | return *this; 20 | } 21 | Vector4& Vector4::operator-=(const Vector4 &v) { 22 | x -= v.x; y -= v.y; z -= v.z; w -= v.w; 23 | return *this; 24 | } 25 | Vector4& Vector4::operator*=(const Vector4 &v) { 26 | x *= v.x; y *= v.y; z *= v.z; w *= v.w; 27 | return *this; 28 | } 29 | Vector4& Vector4::operator/=(const Vector4 &v) { 30 | x /= v.x; y /= v.y; z /= v.z; w /= v.w; 31 | return *this; 32 | } 33 | Vector4& Vector4::operator*=(const float &t) { 34 | x *= t; y *= t; z *= t; w *= t; 35 | return *this; 36 | } 37 | Vector4& Vector4::operator/=(const float &t) { 38 | x /= t; y /= t; z /= t; w /= t; 39 | return *this; 40 | } 41 | 42 | Vector4 operator+(const Vector4 &v1, const Vector4 &v2) { 43 | return Vector4(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z, v1.w + v2.w); 44 | } 45 | 46 | Vector4 operator-(const Vector4 &v1, const Vector4 &v2) { 47 | return Vector4(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z, v1.w - v2.w); 48 | } 49 | 50 | Vector4 operator*(const Vector4 &v1, const Vector4 &v2) { 51 | return Vector4(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w); 52 | } 53 | 54 | Vector4 operator/(const Vector4 &v1, const Vector4 &v2) { 55 | return Vector4(v1.x / v2.x, v1.y / v2.y, v1.z / v2.z, v1.w / v2.w); 56 | } 57 | 58 | Vector4 operator*(const float &t, const Vector4 &v) { 59 | return Vector4(t * v.x, t * v.y, t * v.z, t * v.w); 60 | } 61 | 62 | Vector4 operator/(const float &t, const Vector4 &v) { 63 | return Vector4(v.x / t, v.y / t, v.z / t, v.w / t); 64 | } 65 | 66 | Vector4 operator*(const Vector4 &v, const float &t) { 67 | return Vector4(t * v.x, t * v.y, t * v.z, t * v.w); 68 | } 69 | 70 | Vector4 operator/(const Vector4 &v, const float &t) { 71 | return Vector4(v.x / t, v.y / t, v.z / t, v.w / t); 72 | } 73 | 74 | bool operator!=(const Vector4 &v1, const Vector4 &v2) { 75 | return !(v1 == v2); 76 | } 77 | 78 | bool operator==(const Vector4 &v1, const Vector4 &v2) { 79 | if (v1.x == v2.x && v1.y == v2.y && v1.z == v2.z && v1.w == v2.w) return true; 80 | else return false; 81 | } 82 | 83 | Vector4 Vector4::ONE() { 84 | return Vector4(1.0, 1.0, 1.0, 1.0); 85 | } 86 | 87 | Vector4 Vector4::ZERO() { 88 | return Vector4(0.0, 0.0, 0.0, 0.0); 89 | } 90 | } -------------------------------------------------------------------------------- /ToyBox/Vector4.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | namespace MOON { 6 | extern class Vector3; 7 | class Vector4 { 8 | public: 9 | float x, y, z, w; 10 | Vector4() :x(0), y(0), z(0), w(0) {} 11 | Vector4(float x1, float y1, float z1, float w1) :x(x1), y(y1), z(z1), w(w1) {} 12 | Vector4(float *v) :x(v[0]), y(v[1]), z(v[2]), w(v[3]) {} 13 | Vector4(const Vector4 &v) :x(v.x), y(v.y), z(v.z), w(v.w) {} 14 | Vector4(const Vector3 &v); 15 | ~Vector4() {} 16 | 17 | Vector4& operator+=(const Vector4 &v); 18 | Vector4& operator-=(const Vector4 &v); 19 | Vector4& operator*=(const Vector4 &v); 20 | Vector4& operator/=(const Vector4 &v); 21 | Vector4& operator*=(const float &t); 22 | Vector4& operator/=(const float &t); 23 | 24 | friend std::istream& operator>>(std::istream &is, Vector4 &t); 25 | friend std::ostream& operator<<(std::ostream &os, const Vector4 &t); 26 | friend bool operator==(const Vector4 &v1, const Vector4 &v2); 27 | friend bool operator!=(const Vector4 &v1, const Vector4 &v2); 28 | friend Vector4 operator+(const Vector4 &v1, const Vector4 &v2); 29 | friend Vector4 operator-(const Vector4 &v1, const Vector4 &v2); 30 | friend Vector4 operator*(const Vector4 &v1, const Vector4 &v2); 31 | friend Vector4 operator/(const Vector4 &v1, const Vector4 &v2); 32 | friend Vector4 operator*(const float &t, const Vector4 &v); 33 | friend Vector4 operator/(const float &t, const Vector4 &v); 34 | friend Vector4 operator*(const Vector4 &v, const float &t); 35 | friend Vector4 operator/(const Vector4 &v, const float &t); 36 | 37 | inline void operator=(const Vector4 &v) { x = v.x; y = v.y; z = v.z; w = v.w; } 38 | inline const Vector4 operator+() const { return *this; } 39 | inline Vector4 operator-() const { return Vector4(-x, -y, -z, -w); } 40 | inline float operator[](int i) const { return i == 0 ? x : (i == 1 ? y : (i == 2 ? z : w)); } 41 | inline float& operator[](int i) { return i == 0 ? x : (i == 1 ? y : (i == 2 ? z : w)); } 42 | 43 | inline void setValue(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } 44 | 45 | static Vector4 ONE(); 46 | static Vector4 ZERO(); 47 | }; 48 | } -------------------------------------------------------------------------------- /ToyBox/VertexID.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | flat in int ID; 3 | 4 | out vec4 FragColor; 5 | 6 | void main() { 7 | vec4 data; 8 | 9 | int cnt = 0, num = ID; 10 | while (num > 0) { 11 | data[cnt++] = num % 256; 12 | num /= 256; 13 | } 14 | 15 | FragColor = vec4(data[0], data[1], data[2], 255 - data[3]) / 255.0; 16 | } -------------------------------------------------------------------------------- /ToyBox/VertexID.vs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; 3 | 4 | uniform mat4 model; 5 | uniform mat4 view; 6 | uniform mat4 projection; 7 | uniform int offset; 8 | 9 | flat out int ID; 10 | 11 | void main() { 12 | ID = gl_VertexID + offset + 1; 13 | gl_Position = projection * view * model * vec4(aPos, 1.0f); 14 | } -------------------------------------------------------------------------------- /ToyBox/Vignette.fs: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec2 TexCoords; 4 | 5 | uniform vec2 bufferSize; 6 | uniform sampler2D screenBuffer; 7 | 8 | uniform float _weight; 9 | uniform float _shape; 10 | uniform float _smooth; 11 | 12 | void main() { 13 | vec3 color = texture(screenBuffer, TexCoords).rgb; 14 | 15 | // vignette color 16 | vec2 vi = pow(abs(TexCoords * 2.0 - 1.0), vec2(_shape)); 17 | float vigCol = 1.0 - pow(dot(vi, vi) * 0.45 * _weight, _smooth); 18 | 19 | FragColor = vec4(color.rgb * vigCol, 1.0); 20 | } -------------------------------------------------------------------------------- /ToyBox/Volume.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include "MShader.h" 3 | #include "Hitable.h" 4 | #include "ObjectBase.h" 5 | 6 | namespace MOON { 7 | 8 | class Volume : public MObject, public Hitable { 9 | public: 10 | enum SourceType { 11 | Noise, 12 | Galaxy, 13 | Tex3D, 14 | OpenVDB, 15 | Alembic 16 | }; 17 | 18 | SourceType source; 19 | 20 | bool drawBound; 21 | bool useLight; 22 | bool writeDepth; 23 | 24 | float time; 25 | float step; 26 | float rayStep; 27 | int lightStep; 28 | int maxMarchLoop; 29 | 30 | float darknessThreshold; 31 | float midtoneOffset; 32 | float shadowOffset; 33 | float lightAbsorptionTowardSun; 34 | float lightAbsorptionThroughCloud; 35 | 36 | Vector3 mainColor; 37 | Vector3 shadowColor; 38 | Vector4 phaseParams; 39 | 40 | float scatterMultiply; 41 | float densityOffset; 42 | float densityMultiply; 43 | 44 | int downSampling; 45 | Vector3 offset; 46 | Vector2 multiply; 47 | float scale; 48 | 49 | Volume(const std::string &name, const bool& interactive = false, 50 | const int id = MOON_AUTOID) : MObject(name, id) { 51 | source = Noise; drawBound = true; useLight = true; writeDepth = false; 52 | 53 | step = 0.1f; rayStep = 0.1f; lightStep = 8; maxMarchLoop = 128; 54 | time = 1.0f; 55 | 56 | darknessThreshold = 0.0f; midtoneOffset = 0.59f; shadowOffset = 1.02f; 57 | lightAbsorptionTowardSun = 0.1f; 58 | lightAbsorptionThroughCloud = 1.0f; 59 | 60 | mainColor.setValue(0.5f, 0.5f, 0.5f); shadowColor.setValue(0.1f, 0.1f, 0.1f); 61 | phaseParams.setValue(0.72f, 1.0f, 0.5f, 1.58f); 62 | 63 | scatterMultiply = 1.0f; 64 | densityOffset = 4.02f; 65 | densityMultiply = 2.3f; 66 | 67 | downSampling = 4; 68 | offset.setValue(0.0f, 0.0f, 0.0f); 69 | scale = 8.0f; 70 | multiply.setValue(2.0f, 4.0f); 71 | 72 | CreateProcedural(interactive); 73 | } 74 | virtual ~Volume() override = default; 75 | 76 | virtual void ListProperties() override { 77 | // list name ---------------------------------------------------------------------- 78 | ListName(); 79 | ImGui::Separator(); 80 | 81 | // list transform ----------------------------------------------------------------- 82 | ListTransform(); 83 | ImGui::Separator(); 84 | 85 | // list properties ---------------------------------------------------------------- 86 | ListVolumePropties(); 87 | ImGui::Separator(); 88 | 89 | // list operators ----------------------------------------------------------------- 90 | opstack.ListStacks(); 91 | ImGui::Spacing(); 92 | } 93 | 94 | static void InteractiveCreate(void* arg); 95 | virtual void Draw(Shader* overrideShader = NULL) override; 96 | 97 | void ListVolumePropties(); 98 | void SetupParameters(Shader* rayMarchingShader); 99 | void CreateProcedural(const bool& interactive) override; 100 | }; 101 | 102 | } 103 | -------------------------------------------------------------------------------- /ToyBox/WideNDeep.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/WideNDeep.h -------------------------------------------------------------------------------- /ToyBox/WinDiagHandler.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/WinDiagHandler.h -------------------------------------------------------------------------------- /ToyBox/imgui/ImNodesEz.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/ImNodesEz.h -------------------------------------------------------------------------------- /ToyBox/imgui/imgui_impl_glfw.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Platform Binding for GLFW 2 | // This needs to be used along with a Renderer (e.g. OpenGL3, Vulkan..) 3 | // (Info: GLFW is a cross-platform general purpose library for handling windows, inputs, OpenGL/Vulkan graphics context creation, etc.) 4 | 5 | // Implemented features: 6 | // [X] Platform: Clipboard support. 7 | // [X] Platform: Gamepad support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_NavEnableGamepad'. 8 | // [x] Platform: Mouse cursor shape and visibility. Disable with 'io.ConfigFlags |= ImGuiConfigFlags_NoMouseCursorChange'. FIXME: 3 cursors types are missing from GLFW. 9 | // [X] Platform: Keyboard arrays indexed using GLFW_KEY_* codes, e.g. ImGui::IsKeyPressed(GLFW_KEY_SPACE). 10 | // [X] Platform: Multi-viewport support (multiple windows). Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 11 | 12 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 13 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 14 | // https://github.com/ocornut/imgui 15 | 16 | // About GLSL version: 17 | // The 'glsl_version' initialization parameter defaults to "#version 150" if NULL. 18 | // Only override if your GL version doesn't handle this GLSL version. Keep NULL if unsure! 19 | 20 | #pragma once 21 | #include "imgui.h" // IMGUI_IMPL_API 22 | 23 | struct GLFWwindow; 24 | struct GLFWmonitor; 25 | 26 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForOpenGL(GLFWwindow* window, bool install_callbacks); 27 | IMGUI_IMPL_API bool ImGui_ImplGlfw_InitForVulkan(GLFWwindow* window, bool install_callbacks); 28 | IMGUI_IMPL_API void ImGui_ImplGlfw_Shutdown(); 29 | IMGUI_IMPL_API void ImGui_ImplGlfw_NewFrame(); 30 | 31 | // GLFW callbacks 32 | // - When calling Init with 'install_callbacks=true': GLFW callbacks will be installed for you. They will call user's previously installed callbacks, if any. 33 | // - When calling Init with 'install_callbacks=false': GLFW callbacks won't be installed. You will need to call those function yourself from your own GLFW callbacks. 34 | IMGUI_IMPL_API void ImGui_ImplGlfw_MouseButtonCallback(GLFWwindow* window, int button, int action, int mods); 35 | IMGUI_IMPL_API void ImGui_ImplGlfw_ScrollCallback(GLFWwindow* window, double xoffset, double yoffset); 36 | IMGUI_IMPL_API void ImGui_ImplGlfw_KeyCallback(GLFWwindow* window, int key, int scancode, int action, int mods); 37 | IMGUI_IMPL_API void ImGui_ImplGlfw_CharCallback(GLFWwindow* window, unsigned int c); 38 | IMGUI_IMPL_API void ImGui_ImplGlfw_MonitorCallback(GLFWmonitor* monitor, int event); 39 | -------------------------------------------------------------------------------- /ToyBox/imgui/imgui_impl_opengl3.h: -------------------------------------------------------------------------------- 1 | // dear imgui: Renderer for modern OpenGL with shaders / programmatic pipeline 2 | // - Desktop GL: 2.x 3.x 4.x 3 | // - Embedded GL: ES 2.0 (WebGL 1.0), ES 3.0 (WebGL 2.0) 4 | // This needs to be used along with a Platform Binding (e.g. GLFW, SDL, Win32, custom..) 5 | 6 | // Implemented features: 7 | // [X] Renderer: User texture binding. Use 'GLuint' OpenGL texture identifier as void*/ImTextureID. Read the FAQ about ImTextureID! 8 | // [X] Renderer: Multi-viewport support. Enable with 'io.ConfigFlags |= ImGuiConfigFlags_ViewportsEnable'. 9 | // [x] Renderer: Desktop GL only: Support for large meshes (64k+ vertices) with 16-bit triangles. 10 | 11 | // You can copy and use unmodified imgui_impl_* files in your project. See main.cpp for an example of using this. 12 | // If you are new to dear imgui, read examples/README.txt and read the documentation at the top of imgui.cpp. 13 | // https://github.com/ocornut/imgui 14 | 15 | // About Desktop OpenGL function loaders: 16 | // Modern desktop OpenGL doesn't have a standard portable header file to load OpenGL function pointers. 17 | // Helper libraries are often used for this purpose! Here we are supporting a few common ones (gl3w, glew, glad). 18 | // You may use another loader/header of your choice (glext, glLoadGen, etc.), or chose to manually implement your own. 19 | 20 | // About GLSL version: 21 | // The 'glsl_version' initialization parameter should be NULL (default) or a "#version XXX" string. 22 | // On computer platform the GLSL version default to "#version 130". On OpenGL ES 3 platform it defaults to "#version 300 es" 23 | // Only override if your GL version doesn't handle this GLSL version. See GLSL version table at the top of imgui_impl_opengl3.cpp. 24 | 25 | #pragma once 26 | #include "imgui.h" // IMGUI_IMPL_API 27 | 28 | // Backend API 29 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_Init(const char* glsl_version = NULL); 30 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_Shutdown(); 31 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_NewFrame(); 32 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_RenderDrawData(ImDrawData* draw_data); 33 | 34 | // (Optional) Called by Init/NewFrame/Shutdown 35 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateFontsTexture(); 36 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyFontsTexture(); 37 | IMGUI_IMPL_API bool ImGui_ImplOpenGL3_CreateDeviceObjects(); 38 | IMGUI_IMPL_API void ImGui_ImplOpenGL3_DestroyDeviceObjects(); 39 | 40 | // Specific OpenGL versions 41 | //#define IMGUI_IMPL_OPENGL_ES2 // Auto-detected on Emscripten 42 | //#define IMGUI_IMPL_OPENGL_ES3 // Auto-detected on iOS/Android 43 | 44 | // Desktop OpenGL: attempt to detect default GL loader based on available header files. 45 | // If auto-detection fails or doesn't select the same GL loader file as used by your application, 46 | // you are likely to get a crash in ImGui_ImplOpenGL3_Init(). 47 | // You can explicitly select a loader by using '#define IMGUI_IMPL_OPENGL_LOADER_XXX' in imconfig.h or compiler command-line. 48 | #if !defined(IMGUI_IMPL_OPENGL_LOADER_GL3W) \ 49 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLEW) \ 50 | && !defined(IMGUI_IMPL_OPENGL_LOADER_GLAD) \ 51 | && !defined(IMGUI_IMPL_OPENGL_LOADER_CUSTOM) 52 | #define IMGUI_IMPL_OPENGL_LOADER_GLAD 53 | #endif 54 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/README.txt: -------------------------------------------------------------------------------- 1 | 2 | misc/cpp/ 3 | InputText() wrappers for C++ standard library (STL) type: std::string. 4 | This is also an example of how you may wrap your own similar types. 5 | 6 | misc/fonts/ 7 | Fonts loading/merging instructions (e.g. How to handle glyph ranges, how to merge icons fonts). 8 | Command line tool "binary_to_compressed_c" to create compressed arrays to embed data in source code. 9 | Suggested fonts and links. 10 | 11 | misc/freetype/ 12 | Font atlas builder/rasterizer using FreeType instead of stb_truetype. 13 | Benefit from better FreeType rasterization, in particular for small fonts. 14 | 15 | misc/natvis/ 16 | Natvis file to describe dear imgui types in the Visual Studio debugger. 17 | With this, types like ImVector<> will be displayed nicely in the debugger. 18 | You can include this file a Visual Studio project file, or install it in Visual Studio folder. 19 | 20 | misc/single_file/ 21 | Single-file header stub. 22 | We use this to validate compiling all *.cpp files in a same compilation unit. 23 | Users of that technique (also called "Unity builds") can generally provide this themselves, 24 | so we don't really recommend you use this in your projects. 25 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/cpp/README.txt: -------------------------------------------------------------------------------- 1 | 2 | imgui_stdlib.h + imgui_stdlib.cpp 3 | InputText() wrappers for C++ standard library (STL) type: std::string. 4 | This is also an example of how you may wrap your own similar types. 5 | 6 | imgui_scoped.h 7 | [Experimental, not currently in main repository] 8 | Additional header file with some RAII-style wrappers for common Dear ImGui functions. 9 | Try by merging: https://github.com/ocornut/imgui/pull/2197 10 | Discuss at: https://github.com/ocornut/imgui/issues/2096 11 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/cpp/imgui_stdlib.cpp: -------------------------------------------------------------------------------- 1 | // dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) 2 | // This is also an example of how you may wrap your own similar types. 3 | 4 | // Compatibility: 5 | // - std::string support is only guaranteed to work from C++11. 6 | // If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) 7 | 8 | // Changelog: 9 | // - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string 10 | 11 | #include "imgui.h" 12 | #include "imgui_stdlib.h" 13 | 14 | struct InputTextCallback_UserData 15 | { 16 | std::string* Str; 17 | ImGuiInputTextCallback ChainCallback; 18 | void* ChainCallbackUserData; 19 | }; 20 | 21 | static int InputTextCallback(ImGuiInputTextCallbackData* data) 22 | { 23 | InputTextCallback_UserData* user_data = (InputTextCallback_UserData*)data->UserData; 24 | if (data->EventFlag == ImGuiInputTextFlags_CallbackResize) 25 | { 26 | // Resize string callback 27 | // If for some reason we refuse the new length (BufTextLen) and/or capacity (BufSize) we need to set them back to what we want. 28 | std::string* str = user_data->Str; 29 | IM_ASSERT(data->Buf == str->c_str()); 30 | str->resize(data->BufTextLen); 31 | data->Buf = (char*)str->c_str(); 32 | } 33 | else if (user_data->ChainCallback) 34 | { 35 | // Forward to user callback, if any 36 | data->UserData = user_data->ChainCallbackUserData; 37 | return user_data->ChainCallback(data); 38 | } 39 | return 0; 40 | } 41 | 42 | bool ImGui::InputText(const char* label, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) 43 | { 44 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 45 | flags |= ImGuiInputTextFlags_CallbackResize; 46 | 47 | InputTextCallback_UserData cb_user_data; 48 | cb_user_data.Str = str; 49 | cb_user_data.ChainCallback = callback; 50 | cb_user_data.ChainCallbackUserData = user_data; 51 | return InputText(label, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); 52 | } 53 | 54 | bool ImGui::InputTextMultiline(const char* label, std::string* str, const ImVec2& size, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) 55 | { 56 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 57 | flags |= ImGuiInputTextFlags_CallbackResize; 58 | 59 | InputTextCallback_UserData cb_user_data; 60 | cb_user_data.Str = str; 61 | cb_user_data.ChainCallback = callback; 62 | cb_user_data.ChainCallbackUserData = user_data; 63 | return InputTextMultiline(label, (char*)str->c_str(), str->capacity() + 1, size, flags, InputTextCallback, &cb_user_data); 64 | } 65 | 66 | bool ImGui::InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags, ImGuiInputTextCallback callback, void* user_data) 67 | { 68 | IM_ASSERT((flags & ImGuiInputTextFlags_CallbackResize) == 0); 69 | flags |= ImGuiInputTextFlags_CallbackResize; 70 | 71 | InputTextCallback_UserData cb_user_data; 72 | cb_user_data.Str = str; 73 | cb_user_data.ChainCallback = callback; 74 | cb_user_data.ChainCallbackUserData = user_data; 75 | return InputTextWithHint(label, hint, (char*)str->c_str(), str->capacity() + 1, flags, InputTextCallback, &cb_user_data); 76 | } 77 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/cpp/imgui_stdlib.h: -------------------------------------------------------------------------------- 1 | // dear imgui: wrappers for C++ standard library (STL) types (std::string, etc.) 2 | // This is also an example of how you may wrap your own similar types. 3 | 4 | // Compatibility: 5 | // - std::string support is only guaranteed to work from C++11. 6 | // If you try to use it pre-C++11, please share your findings (w/ info about compiler/architecture) 7 | 8 | // Changelog: 9 | // - v0.10: Initial version. Added InputText() / InputTextMultiline() calls with std::string 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | namespace ImGui 16 | { 17 | // ImGui::InputText() with std::string 18 | // Because text input needs dynamic resizing, we need to setup a callback to grow the capacity 19 | IMGUI_API bool InputText(const char* label, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 20 | IMGUI_API bool InputTextMultiline(const char* label, std::string* str, const ImVec2& size = ImVec2(0, 0), ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 21 | IMGUI_API bool InputTextWithHint(const char* label, const char* hint, std::string* str, ImGuiInputTextFlags flags = 0, ImGuiInputTextCallback callback = NULL, void* user_data = NULL); 22 | } 23 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/fonts/Cousine-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/misc/fonts/Cousine-Regular.ttf -------------------------------------------------------------------------------- /ToyBox/imgui/misc/fonts/DroidSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/misc/fonts/DroidSans.ttf -------------------------------------------------------------------------------- /ToyBox/imgui/misc/fonts/Karla-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/misc/fonts/Karla-Regular.ttf -------------------------------------------------------------------------------- /ToyBox/imgui/misc/fonts/ProggyClean.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/misc/fonts/ProggyClean.ttf -------------------------------------------------------------------------------- /ToyBox/imgui/misc/fonts/ProggyTiny.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/misc/fonts/ProggyTiny.ttf -------------------------------------------------------------------------------- /ToyBox/imgui/misc/fonts/Roboto-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/misc/fonts/Roboto-Medium.ttf -------------------------------------------------------------------------------- /ToyBox/imgui/misc/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/imgui/misc/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /ToyBox/imgui/misc/freetype/imgui_freetype.h: -------------------------------------------------------------------------------- 1 | // dear imgui: wrapper to use FreeType (instead of stb_truetype) 2 | // Get latest version at https://github.com/ocornut/imgui/tree/master/misc/freetype 3 | // Original code by @Vuhdo (Aleksei Skriabin), maintained by @ocornut 4 | 5 | #pragma once 6 | 7 | #include "imgui.h" // IMGUI_API, ImFontAtlas 8 | 9 | namespace ImGuiFreeType 10 | { 11 | // Hinting greatly impacts visuals (and glyph sizes). 12 | // When disabled, FreeType generates blurrier glyphs, more or less matches the stb's output. 13 | // The Default hinting mode usually looks good, but may distort glyphs in an unusual way. 14 | // The Light hinting mode generates fuzzier glyphs but better matches Microsoft's rasterizer. 15 | 16 | // You can set those flags on a per font basis in ImFontConfig::RasterizerFlags. 17 | // Use the 'extra_flags' parameter of BuildFontAtlas() to force a flag on all your fonts. 18 | enum RasterizerFlags 19 | { 20 | // By default, hinting is enabled and the font's native hinter is preferred over the auto-hinter. 21 | NoHinting = 1 << 0, // Disable hinting. This generally generates 'blurrier' bitmap glyphs when the glyph are rendered in any of the anti-aliased modes. 22 | NoAutoHint = 1 << 1, // Disable auto-hinter. 23 | ForceAutoHint = 1 << 2, // Indicates that the auto-hinter is preferred over the font's native hinter. 24 | LightHinting = 1 << 3, // A lighter hinting algorithm for gray-level modes. Many generated glyphs are fuzzier but better resemble their original shape. This is achieved by snapping glyphs to the pixel grid only vertically (Y-axis), as is done by Microsoft's ClearType and Adobe's proprietary font renderer. This preserves inter-glyph spacing in horizontal text. 25 | MonoHinting = 1 << 4, // Strong hinting algorithm that should only be used for monochrome output. 26 | Bold = 1 << 5, // Styling: Should we artificially embolden the font? 27 | Oblique = 1 << 6, // Styling: Should we slant the font, emulating italic style? 28 | Monochrome = 1 << 7 // Disable anti-aliasing. Combine this with MonoHinting for best results! 29 | }; 30 | 31 | IMGUI_API bool BuildFontAtlas(ImFontAtlas* atlas, unsigned int extra_flags = 0); 32 | 33 | // By default ImGuiFreeType will use IM_ALLOC()/IM_FREE(). 34 | // However, as FreeType does lots of allocations we provide a way for the user to redirect it to a separate memory heap if desired: 35 | IMGUI_API void SetAllocatorFunctions(void* (*alloc_func)(size_t sz, void* user_data), void (*free_func)(void* ptr, void* user_data), void* user_data = NULL); 36 | } 37 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/natvis/README.txt: -------------------------------------------------------------------------------- 1 | 2 | Natvis file to describe dear imgui types in the Visual Studio debugger. 3 | With this, types like ImVector<> will be displayed nicely in the debugger. 4 | You can include this file a Visual Studio project file, or install it in Visual Studio folder. 5 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/natvis/imgui.natvis: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | {{Size={Size} Capacity={Capacity}}} 9 | 10 | 11 | Size 12 | Data 13 | 14 | 15 | 16 | 17 | 18 | {{x={x,g} y={y,g}}} 19 | 20 | 21 | 22 | {{x={x,g} y={y,g} z={z,g} w={w,g}}} 23 | 24 | 25 | 26 | {{Min=({Min.x,g} {Min.y,g}) Max=({Max.x,g} {Max.y,g}) Size=({Max.x-Min.x,g} {Max.y-Min.y,g})}} 27 | 28 | Min 29 | Max 30 | Max.x - Min.x 31 | Max.y - Min.y 32 | 33 | 34 | 35 | 36 | {{Name {Name,s} Active {(Active||WasActive)?1:0,d} Child {(Flags & 0x01000000)?1:0,d} Popup {(Flags & 0x04000000)?1:0,d} Hidden {(Hidden)?1:0,d}} 37 | 38 | 39 | 40 | {{ID {ID,x} Pos=({Pos.x,g} {Pos.y,g}) Size=({Size.x,g} {Size.y,g}) Parent {(ParentNode==0)?0:ParentNode->ID,x} Childs {(ChildNodes[0] != 0)+(ChildNodes[1] != 0)} Windows {Windows.Size} } 41 | 42 | 43 | -------------------------------------------------------------------------------- /ToyBox/imgui/misc/single_file/imgui_single_file.h: -------------------------------------------------------------------------------- 1 | // dear imgui: single-file wrapper include 2 | // We use this to validate compiling all *.cpp files in a same compilation unit. 3 | // Users of that technique (also called "Unity builds") can generally provide this themselves, 4 | // so we don't really recommend you use this in your projects. 5 | 6 | // Do this: 7 | // #define IMGUI_IMPLEMENTATION 8 | // Before you include this file in *one* C++ file to create the implementation. 9 | // Using this in your project will leak the contents of imgui_internal.h and ImVec2 operators in this compilation unit. 10 | #include "../../imgui.h" 11 | 12 | #ifdef IMGUI_IMPLEMENTATION 13 | #include "../../imgui.cpp" 14 | #include "../../imgui_demo.cpp" 15 | #include "../../imgui_draw.cpp" 16 | #include "../../imgui_widgets.cpp" 17 | #endif 18 | -------------------------------------------------------------------------------- /ToyBox/opengl/lib/OpenGL32.Lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/opengl/lib/OpenGL32.Lib -------------------------------------------------------------------------------- /ToyBox/opengl/lib/glfw3.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/opengl/lib/glfw3.dll -------------------------------------------------------------------------------- /ToyBox/opengl/lib/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/opengl/lib/glfw3.lib -------------------------------------------------------------------------------- /ToyBox/opengl/lib/glfw3dll.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/opengl/lib/glfw3dll.lib -------------------------------------------------------------------------------- /ToyBox/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /ToyBox/properties.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define PROPERTY(t,n) __declspec( property (put = property__set_##n, get = property__get_##n)) t n;\ 4 | typedef t property__tmp_type_##n 5 | #define READONLY_PROPERTY(t,n) __declspec( property (get = property__get_##n) ) t n;\ 6 | typedef t property__tmp_type_##n 7 | #define WRITEONLY_PROPERTY(t,n) __declspec( property (put = property__set_##n) ) t n;\ 8 | typedef t property__tmp_type_##n 9 | 10 | #define GET(n) property__tmp_type_##n property__get_##n() 11 | #define SET(n) void property__set_##n(const property__tmp_type_##n& value) -------------------------------------------------------------------------------- /ToyBox/pthreadVC2.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RIPmr/MoonEngine/b6d8464cdf87c2045b5d4ecce348dc76815b7ff1/ToyBox/pthreadVC2.dll --------------------------------------------------------------------------------