Procedural Planets
Integrated Sebastian Lague's Planet Generator Created Tour function in SectorRenderer which makes the camera follow each terrestrial planet in turn
This commit is contained in:
parent
f8165878e0
commit
53a91351b7
332 changed files with 11904 additions and 78 deletions
118
.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
generated
118
.idea/.idea.Aetheria-Economy/.idea/contentModel.xml
generated
|
|
@ -5,6 +5,7 @@
|
|||
<e p="C:\Users\rwven\AppData\local\JetBrains\Rider2020.2\resharper-host\local\Transient\Rider\v202\SolutionCaches\_Aetheria-Economy.1410242644.00" t="ExcludeRecursive" />
|
||||
<e p="D:\WIP4\Projects\Aetheria-Economy" t="IncludeRecursive">
|
||||
<e p="Aetheria-Economy.sln" t="IncludeFlat" />
|
||||
<e p="Assembly-CSharp-Editor-firstpass.csproj" t="IncludeRecursive" />
|
||||
<e p="Assembly-CSharp-Editor.csproj" t="IncludeRecursive" />
|
||||
<e p="Assembly-CSharp-firstpass.csproj" t="IncludeRecursive" />
|
||||
<e p="Assembly-CSharp.csproj" t="IncludeRecursive" />
|
||||
|
|
@ -30,6 +31,121 @@
|
|||
</e>
|
||||
</e>
|
||||
</e>
|
||||
<e p="Celestial Body" t="Include">
|
||||
<e p="Scripts" t="Include">
|
||||
<e p="CameraUtility.cs" t="Include" />
|
||||
<e p="CelestialBodyGenerator.cs" t="Include" />
|
||||
<e p="CelestialBodySettings.cs" t="Include" />
|
||||
<e p="Editor" t="Include">
|
||||
<e p="GeneratorEditor.cs" t="Include" />
|
||||
<e p="TextureCombinerEditor.cs" t="Include" />
|
||||
<e p="TextureEditor.cs" t="Include" />
|
||||
</e>
|
||||
<e p="LODHandler.cs" t="Include" />
|
||||
<e p="MeshBaker.cs" t="Include" />
|
||||
<e p="NoiseSettings" t="Include">
|
||||
<e p="CraterSettings.cs" t="Include" />
|
||||
<e p="RidgeNoiseSettings.cs" t="Include" />
|
||||
<e p="SimpleNoiseSettings.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Normalizer.cs" t="Include" />
|
||||
<e p="OceanSettings.cs" t="Include" />
|
||||
<e p="SceneCam" t="Include">
|
||||
<e p="Editor" t="Include">
|
||||
<e p="SceneCamEditor.cs" t="Include" />
|
||||
</e>
|
||||
<e p="SceneCamManager.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Script Utilities" t="Include">
|
||||
<e p="ChanceTest.cs" t="Include" />
|
||||
<e p="ComputeHelper.cs" t="Include" />
|
||||
<e p="MathUtility.cs" t="Include" />
|
||||
<e p="PRNG.cs" t="Include" />
|
||||
<e p="ShaderHelper.cs" t="Include" />
|
||||
<e p="TextureHelper.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Shaders" t="Include">
|
||||
<e p="Compute" t="Include">
|
||||
<e p="Atmosphere" t="Include">
|
||||
<e p="AtmosphereTexture.compute" t="Include" />
|
||||
</e>
|
||||
<e p="Height" t="Include">
|
||||
<e p="AlienHeight.compute" t="Include" />
|
||||
<e p="EarthHeight.compute" t="Include" />
|
||||
<e p="MoatHeight.compute" t="Include" />
|
||||
<e p="MoonHeight.compute" t="Include" />
|
||||
<e p="ShatteredHeight.compute" t="Include" />
|
||||
</e>
|
||||
<e p="Other" t="Include">
|
||||
<e p="OceanMask.shader" t="Include" />
|
||||
<e p="PerturbPoints.compute" t="Include" />
|
||||
<e p="PerturbPointsPlatelike.compute" t="Include" />
|
||||
<e p="SteepnessCompute.compute" t="Include" />
|
||||
</e>
|
||||
<e p="Shading" t="Include">
|
||||
<e p="EarthShading.compute" t="Include" />
|
||||
<e p="MoonShading.compute" t="Include" />
|
||||
</e>
|
||||
<e p="Textures" t="Include">
|
||||
<e p="Blur.compute" t="Include" />
|
||||
<e p="Spots.compute" t="Include" />
|
||||
<e p="TextureGenerator.compute" t="Include" />
|
||||
</e>
|
||||
</e>
|
||||
<e p="Includes" t="Include">
|
||||
<e p="Craters.cginc" t="Include" />
|
||||
<e p="FractalNoise.cginc" t="Include" />
|
||||
<e p="Math.cginc" t="Include" />
|
||||
<e p="SimplexNoise.cginc" t="Include" />
|
||||
<e p="SimplexNoise2.cginc" t="Include" />
|
||||
<e p="SimplexNoise3.cginc" t="Include" />
|
||||
<e p="Triplanar.cginc" t="Include" />
|
||||
</e>
|
||||
<e p="PostProcessing" t="Include">
|
||||
<e p="Atmosphere.shader" t="Include" />
|
||||
<e p="OceanEffect.shader" t="Include" />
|
||||
<e p="Test.shader" t="Include" />
|
||||
</e>
|
||||
<e p="Surface" t="Include">
|
||||
<e p="Alien.shader" t="Include" />
|
||||
<e p="Earth.shader" t="Include" />
|
||||
<e p="MoonA.shader" t="Include" />
|
||||
<e p="MoonB.shader" t="Include" />
|
||||
</e>
|
||||
</e>
|
||||
<e p="Shading" t="Include">
|
||||
<e p="AlienShading.cs" t="Include" />
|
||||
<e p="CelestialBodyShading.cs" t="Include" />
|
||||
<e p="ColourHelper.cs" t="Include" />
|
||||
<e p="EarthShading.cs" t="Include" />
|
||||
<e p="MoonShading.cs" t="Include" />
|
||||
<e p="TestShading.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Shape" t="Include">
|
||||
<e p="AlienShape.cs" t="Include" />
|
||||
<e p="CelestialBodyShape.cs" t="Include" />
|
||||
<e p="EarthShape.cs" t="Include" />
|
||||
<e p="MoatShape.cs" t="Include" />
|
||||
<e p="MoonShape.cs" t="Include" />
|
||||
<e p="ShatteredShape.cs" t="Include" />
|
||||
</e>
|
||||
<e p="SphereMesh.cs" t="Include" />
|
||||
<e p="Test" t="Include">
|
||||
<e p="Phase.shader" t="Include" />
|
||||
<e p="RayStepTest.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Texture Gen" t="Include">
|
||||
<e p="NoiseGenerator.cs" t="Include" />
|
||||
<e p="SpotsTexture.cs" t="Include" />
|
||||
<e p="TextureCombiner.cs" t="Include" />
|
||||
<e p="TextureGenerator.cs" t="Include" />
|
||||
<e p="TextureViewer.cs" t="Include" />
|
||||
</e>
|
||||
</e>
|
||||
<e p="Textures" t="Include">
|
||||
<e p="_Sources.txt" t="Include" />
|
||||
</e>
|
||||
</e>
|
||||
<e p="Grpc.Core" t="Include">
|
||||
<e p="lib" t="Include">
|
||||
<e p="net45" t="Include">
|
||||
|
|
@ -63,6 +179,7 @@
|
|||
<e p="SerializerTestWindow.cs" t="Include" />
|
||||
</e>
|
||||
<e p="Galaxy.cs" t="Include" />
|
||||
<e p="GameSettings.cs" t="Include" />
|
||||
<e p="Gravity.cs" t="Include" />
|
||||
<e p="InitialSettings.cs" t="Include" />
|
||||
<e p="MarkovNameGenerator.cs" t="Include" />
|
||||
|
|
@ -1248,7 +1365,6 @@
|
|||
<e p="Sector Display" t="Include">
|
||||
<e p="BlueNoiseProvider.cs" t="Include" />
|
||||
<e p="CopyTransform.cs" t="Include" />
|
||||
<e p="GameSettings.cs" t="Include" />
|
||||
<e p="GasGiantObject.cs" t="Include" />
|
||||
<e p="GradientMapper.cs" t="Include" />
|
||||
<e p="GravityObject.cs" t="Include" />
|
||||
|
|
|
|||
|
|
@ -7,16 +7,18 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Economy.Shared.Unity", "Eco
|
|||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniRx", "UniRx.csproj", "{4d885cb7-1f9e-abb3-b070-7265b432ecda}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-firstpass", "Assembly-CSharp-firstpass.csproj", "{a442877d-fc0d-6756-0a98-3ca4312f9253}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MessagePack", "MessagePack.csproj", "{c511ef21-dc27-883d-b027-9a4b6f36bae4}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "com.alelievr.NodeGraphProcessor.Runtime", "com.alelievr.NodeGraphProcessor.Runtime.csproj", "{4cc9ece5-0f74-bceb-733d-48f6e84c547b}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-firstpass", "Assembly-CSharp-firstpass.csproj", "{a442877d-fc0d-6756-0a98-3ca4312f9253}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor", "Assembly-CSharp-Editor.csproj", "{a7fc89e3-14ca-fb82-7d67-c13788bee74a}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "com.alelievr.NodeGraphProcessor.Editor", "com.alelievr.NodeGraphProcessor.Editor.csproj", "{a4e83803-35fe-e54d-5974-2af6595e46a5}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Assembly-CSharp-Editor-firstpass", "Assembly-CSharp-Editor-firstpass.csproj", "{b813e4c7-10f6-4f4d-0de5-991510834dc3}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
|
@ -35,6 +37,10 @@ Global
|
|||
{4d885cb7-1f9e-abb3-b070-7265b432ecda}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4d885cb7-1f9e-abb3-b070-7265b432ecda}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4d885cb7-1f9e-abb3-b070-7265b432ecda}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{c511ef21-dc27-883d-b027-9a4b6f36bae4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{c511ef21-dc27-883d-b027-9a4b6f36bae4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{c511ef21-dc27-883d-b027-9a4b6f36bae4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -43,10 +49,6 @@ Global
|
|||
{4cc9ece5-0f74-bceb-733d-48f6e84c547b}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4cc9ece5-0f74-bceb-733d-48f6e84c547b}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4cc9ece5-0f74-bceb-733d-48f6e84c547b}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{a442877d-fc0d-6756-0a98-3ca4312f9253}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{a7fc89e3-14ca-fb82-7d67-c13788bee74a}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{a7fc89e3-14ca-fb82-7d67-c13788bee74a}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{a7fc89e3-14ca-fb82-7d67-c13788bee74a}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
|
|
@ -55,6 +57,10 @@ Global
|
|||
{a4e83803-35fe-e54d-5974-2af6595e46a5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{a4e83803-35fe-e54d-5974-2af6595e46a5}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{a4e83803-35fe-e54d-5974-2af6595e46a5}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{b813e4c7-10f6-4f4d-0de5-991510834dc3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{b813e4c7-10f6-4f4d-0de5-991510834dc3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{b813e4c7-10f6-4f4d-0de5-991510834dc3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{b813e4c7-10f6-4f4d-0de5-991510834dc3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
|
|
|||
|
|
@ -50,13 +50,10 @@
|
|||
<ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Assets\Plugins\IMP\Editor\ImposterBakeWindow.cs" />
|
||||
<Compile Include="Assets\Plugins\IMP\Editor\IMPGenerator.cs" />
|
||||
<Compile Include="Assets\Plugins\IMP\Editor\BillboardImposterInspector.cs" />
|
||||
<None Include="Assets\Plugins\IMP\Editor\Shaders\ImposterBakeAlbedo.shader" />
|
||||
<None Include="Assets\Plugins\IMP\Editor\Shaders\ImposterProcessing.shader" />
|
||||
<None Include="Assets\Plugins\IMP\Editor\Shaders\ImposterBakeWorldNormalDepth.shader" />
|
||||
<None Include="Assets\Plugins\IMP\Editor\Shaders\ImposterProcessing.compute" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\SceneCam\Editor\SceneCamEditor.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Editor\TextureEditor.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Editor\TextureCombinerEditor.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Editor\GeneratorEditor.cs" />
|
||||
<Reference Include="UnityEditor.TestRunner">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/UnityEditor.TestRunner.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -75,27 +72,42 @@
|
|||
<Reference Include="Unity.InputSystem">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.InputSystem.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Recorder.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.TextMeshPro.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.TextMeshPro.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Recorder">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.UI">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/UnityEngine.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Timeline">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Timeline.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Postprocessing.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Postprocessing.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.XR.LegacyInputHelpers">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/UnityEngine.XR.LegacyInputHelpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Rider.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Rider.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Recorder.Base">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Mathematics">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Mathematics.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.2D.Sprite.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.2D.Sprite.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Postprocessing.Runtime">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Postprocessing.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.2D.Tilemap.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.2D.Tilemap.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -123,21 +135,6 @@
|
|||
<Reference Include="UnityEditor.UI">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/UnityEditor.UI.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Postprocessing.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Postprocessing.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Postprocessing.Runtime">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Postprocessing.Runtime.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Recorder.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Recorder">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Unity.Recorder.Base">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Recorder.Base.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine">
|
||||
<HintPath>C:/Program Files/Unity/Hub/Editor/2020.1.6f1/Editor/Data/Managed/UnityEngine/UnityEngine.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
@ -730,10 +727,6 @@
|
|||
<Project>{c2362ba6-dee9-92b9-0779-f5fcf5968986}</Project>
|
||||
<Name>Economy.Shared.Unity</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="MessagePack.csproj">
|
||||
<Project>{c511ef21-dc27-883d-b027-9a4b6f36bae4}</Project>
|
||||
<Name>MessagePack</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="com.alelievr.NodeGraphProcessor.Runtime.csproj">
|
||||
<Project>{4cc9ece5-0f74-bceb-733d-48f6e84c547b}</Project>
|
||||
<Name>com.alelievr.NodeGraphProcessor.Runtime</Name>
|
||||
|
|
@ -742,6 +735,14 @@
|
|||
<Project>{a4e83803-35fe-e54d-5974-2af6595e46a5}</Project>
|
||||
<Name>com.alelievr.NodeGraphProcessor.Editor</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="UniRx.csproj">
|
||||
<Project>{4d885cb7-1f9e-abb3-b070-7265b432ecda}</Project>
|
||||
<Name>UniRx</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="MessagePack.csproj">
|
||||
<Project>{c511ef21-dc27-883d-b027-9a4b6f36bae4}</Project>
|
||||
<Name>MessagePack</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||
|
|
|
|||
|
|
@ -788,6 +788,10 @@
|
|||
<Project>{f084b629-16e6-9ccd-eff8-10a39db37a52}</Project>
|
||||
<Name>Assembly-CSharp</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="Assembly-CSharp-Editor-firstpass.csproj">
|
||||
<Project>{b813e4c7-10f6-4f4d-0de5-991510834dc3}</Project>
|
||||
<Name>Assembly-CSharp-Editor-firstpass</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="Economy.Shared.Unity.csproj">
|
||||
<Project>{c2362ba6-dee9-92b9-0779-f5fcf5968986}</Project>
|
||||
<Name>Economy.Shared.Unity</Name>
|
||||
|
|
|
|||
|
|
@ -50,18 +50,85 @@
|
|||
<ImplicitlyExpandDesignTimeFacades>false</ImplicitlyExpandDesignTimeFacades>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Test\RayStepTest.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shading\TestShading.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\CelestialBodySettings.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Texture Gen\TextureGenerator.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\CameraUtility.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Texture Gen\SpotsTexture.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\SphereMesh.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\CelestialBodyGenerator.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\Internal\AsyncCoroutineRunner.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Tests\Util\TestButtonHandler.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\TaskExtensions.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\AwaitExtensions.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shading\CelestialBodyShading.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Texture Gen\NoiseGenerator.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\NoiseSettings\CraterSettings.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Script Utilities\ShaderHelper.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shape\AlienShape.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Script Utilities\MathUtility.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Texture Gen\TextureViewer.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shape\MoatShape.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\OceanSettings.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Script Utilities\PRNG.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\NoiseSettings\SimpleNoiseSettings.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shading\MoonShading.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\IEnumeratorAwaitExtensions.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shading\AlienShading.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\SceneCam\SceneCamManager.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Script Utilities\ComputeHelper.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\NoiseSettings\RidgeNoiseSettings.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\MeshBaker.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\WaitForUpdate.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\WaitForBackgroundThread.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Normalizer.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shape\CelestialBodyShape.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\Awaiters.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shading\EarthShading.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Script Utilities\TextureHelper.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shape\EarthShape.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Texture Gen\TextureCombiner.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shape\ShatteredShape.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shape\MoonShape.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Source\Internal\SyncContextUtil.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Shading\ColourHelper.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\Script Utilities\ChanceTest.cs" />
|
||||
<Compile Include="Assets\Plugins\AsyncAwaitUtil\Tests\AsyncUtilTests.cs" />
|
||||
<Compile Include="Assets\Plugins\Celestial Body\Scripts\LODHandler.cs" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Textures\Spots.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\PostProcessing\OceanEffect.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Textures\_Sources.txt" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Includes\Triplanar.cginc" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\PostProcessing\Test.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Includes\SimplexNoise2.cginc" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Surface\Alien.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Height\ShatteredHeight.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Height\AlienHeight.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Height\MoatHeight.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Shading\EarthShading.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Test\Phase.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\PostProcessing\Atmosphere.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Atmosphere\AtmosphereTexture.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Other\SteepnessCompute.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Height\EarthHeight.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Surface\MoonB.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Textures\TextureGenerator.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Other\PerturbPoints.compute" />
|
||||
<None Include="Assets\Plugins\Grpc.Core.Api\lib\net45\Grpc.Core.Api.xml" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Includes\SimplexNoise.cginc" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Includes\FractalNoise.cginc" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Surface\Earth.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Textures\Blur.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Surface\MoonA.shader" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Other\PerturbPointsPlatelike.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Height\MoonHeight.compute" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Other\OceanMask.shader" />
|
||||
<None Include="Assets\Plugins\Grpc.Core\lib\net45\Grpc.Core.xml" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Includes\Math.cginc" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Includes\SimplexNoise3.cginc" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Includes\Craters.cginc" />
|
||||
<None Include="Assets\Plugins\Celestial Body\Scripts\Shaders\Compute\Shading\MoonShading.compute" />
|
||||
<Reference Include="Unity.Timeline.Editor">
|
||||
<HintPath>D:/WIP4/Projects/Aetheria-Economy/Library/ScriptAssemblies/Unity.Timeline.Editor.dll</HintPath>
|
||||
</Reference>
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@
|
|||
<Compile Include="Assets\Scripts\NIH\MSAGL\DebugHelpers\Persistence\DoubleStreamElement.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Geometry\OverlapRemoval\OverlapRemovalNode.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\Station.cs" />
|
||||
<Compile Include="Assets\Scripts\Sector Display\GameSettings.cs" />
|
||||
<Compile Include="Assets\Scripts\GameSettings.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\ValidateArg.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\DebugHelpers\Persistence\CurveStreamElement.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\Nudging\PointByDelegateComparer.cs" />
|
||||
|
|
@ -262,6 +262,7 @@
|
|||
<Compile Include="Assets\Scripts\NIH\MSAGL\GlobalSuppressions.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Miscellaneous\LayoutEditing\BumperPusher.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\ConstrainedDelaunayTriangulation\EdgeInserter.cs" />
|
||||
<Compile Include="Assets\Scripts\AetheriaInput.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\Nudging\PathEdge.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\MDS\SingleSourceDistances.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\MultipleSourceMultipleTargetsShortestPathOnVisibilityGraph.cs" />
|
||||
|
|
@ -353,6 +354,7 @@
|
|||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\SingleSourceSingleTargetShortestPathOnVisibilityGraph.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\NaughtyAttributes\Scripts\Core\MetaAttributes\BlankSpaceAttribute.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\ConeSpanner\LineSweeperForPortLocations.cs" />
|
||||
<Compile Include="Assets\Scripts\UI\MinimapCameraTrack.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\ConeSpanner\ConeRightSide.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Layout\ProximityOverlapRemoval\OverlapRemovalSettings.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\NaughtyAttributes\Scripts\Core\GroupAttributes\BoxGroupAttribute.cs" />
|
||||
|
|
@ -445,6 +447,7 @@
|
|||
<Compile Include="Assets\Scripts\UI\ZoneGravityObject.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\DebugHelpers\Persistence\GeometryGraphWriter.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\ProjectionSolver\UniformSolverVar.cs" />
|
||||
<Compile Include="Assets\Shaders\Compute\Stardust.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MIConvexHull\Cell2.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MIConvexHull\ConvexHull\ObjectManager.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\NaughtyAttributes\Scripts\Core\DrawerAttributes\ButtonAttribute.cs" />
|
||||
|
|
@ -650,6 +653,7 @@
|
|||
<Compile Include="Assets\Scripts\UnityExtensions.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\ConstrainedDelaunayTriangulation\CdtSweeper.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MIConvexHull\Face3.cs" />
|
||||
<Compile Include="Assets\Scripts\Sector Display\MapView.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Geometry\Curves\Ellipse.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Core\Layout\ProximityOverlapRemoval\ProximityOverlapRemoval.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\Nudging\Nudger.cs" />
|
||||
|
|
@ -672,10 +676,6 @@
|
|||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Rectilinear\BasicReflectionEvent.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Layout\Layered\IntEdge.cs" />
|
||||
<Compile Include="Assets\Scripts\NIH\MSAGL\Routing\Spline\Bundling\PointPairOrder.cs" />
|
||||
<Compile Include="Assets\Scripts\AetheriaInput.cs" />
|
||||
<Compile Include="Assets\Scripts\UI\MinimapCameraTrack.cs" />
|
||||
<Compile Include="Assets\Scripts\Sector Display\MapView.cs" />
|
||||
<Compile Include="Assets\Shaders\Compute\Stardust.cs" />
|
||||
<None Include="Assets\TextMesh Pro\Resources\Shaders\TMPro.cginc" />
|
||||
<None Include="Assets\TextMesh Pro\Resources\Shaders\TMP_SDF-Mobile Overlay.shader" />
|
||||
<None Include="Assets\Shaders\Clouds.shader" />
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Material:
|
|||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _Depth: 0.05
|
||||
- _Depth: 0.2
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _Frequency: 6.2832
|
||||
|
|
@ -78,6 +78,6 @@ Material:
|
|||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.2028302, g: 0.6274925, b: 1, a: 1}
|
||||
- _Color: {r: 0.85, g: 0.92980295, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ Material:
|
|||
- _GridFillDensity: 0.000006
|
||||
- _GridFloorBlend: 100
|
||||
- _GridFloorDensity: 4
|
||||
- _GridFloorOffset: 29.9
|
||||
- _GridFloorOffset: 25
|
||||
- _GridPatchBlend: 200
|
||||
- _GridPatchDensity: 6
|
||||
- _NoiseFrequency: 0.01
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ Material:
|
|||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _AngleFade: 3
|
||||
- _AngleFade: 5
|
||||
- _AngleWidth: 100
|
||||
- _BumpScale: 1
|
||||
- _ClipDistance: 1000
|
||||
|
|
@ -69,7 +69,7 @@ Material:
|
|||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _HeightRange: 50
|
||||
- _LineFade: 3
|
||||
- _LineFade: 5
|
||||
- _LineWidth: 100
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
|
|
|
|||
8
Assets/Plugins/Celestial Body.meta
Normal file
8
Assets/Plugins/Celestial Body.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 43c4881406f3f8f42aa862ab631cb776
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Celestial Body/Materials.meta
Normal file
8
Assets/Plugins/Celestial Body/Materials.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 070342dc4926b45d89b42ae312a5b844
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
135
Assets/Plugins/Celestial Body/Materials/Moon.mat
Normal file
135
Assets/Plugins/Celestial Body/Materials/Moon.mat
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Moon
|
||||
m_Shader: {fileID: 4800000, guid: ebd63f199114146ddacca96d32c18d9e, type: 3}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _CraterRay:
|
||||
m_Texture: {fileID: 2800000, guid: 1dd8d495747f9486b9b0f3a63b0ce851, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMap:
|
||||
m_Texture: {fileID: 2800000, guid: 65c07d8223a8f4c0ab716441f5c8c0a1, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 2800000, guid: 2c0981800f96945c8838dc6057c25d4b, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 2800000, guid: fb5f32830e2c84487ababc395fd75b0e, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMapFlat:
|
||||
m_Texture: {fileID: 2800000, guid: fb5f32830e2c84487ababc395fd75b0e, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMapSteep:
|
||||
m_Texture: {fileID: 2800000, guid: c6335a766e3764fac8a632a38635cb2b, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Tex2:
|
||||
m_Texture: {fileID: 2800000, guid: 8bd6d87e9d43d47ac953370e4b627578, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Tex3:
|
||||
m_Texture: {fileID: 2800000, guid: 56494c7daf00a41ecb4992bfa29b18be, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BiomeBlendStrength: 12.929506
|
||||
- _BiomeDistortStrength: 0.33
|
||||
- _BiomeWarpStrength: 7.524333
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _EjectaBrightness: 0.2
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.6
|
||||
- _GlossyReflections: 1
|
||||
- _MainTexScale: 4
|
||||
- _Metallic: 0.14136462
|
||||
- _Mode: 0
|
||||
- _NormalMapFlatScale: 15
|
||||
- _NormalMapScale: 5
|
||||
- _NormalMapSteepScale: 10
|
||||
- _NormalMapStrength: 0.545
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _PolesStartLongitude: 0.8486198
|
||||
- _PolesVisibility: 1
|
||||
- _SmoothnessA: 0.01718209
|
||||
- _SmoothnessB: 0.1488175
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _TexNoiseScale: 0.44
|
||||
- _TextureMinBrightness: 1
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color2: {r: 0.7735849, g: 0.7735849, b: 0.7735849, a: 1}
|
||||
- _Color3: {r: 0.13207549, g: 0.13207549, b: 0.13207549, a: 1}
|
||||
- _Color4: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _NormalMapScales: {r: 10, g: 10, b: 0, a: 0}
|
||||
- _Params: {r: 0.23, g: -1.27, b: 0.26, a: 0.52}
|
||||
- _PrimaryColA: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _PrimaryColB: {r: 0.2735849, g: 0.2735849, b: 0.2735849, a: 1}
|
||||
- _RandomBiomeValues: {r: -0.9317478, g: 0.26007134, b: 0.26075405, a: 0.0924205}
|
||||
- _RandomPoleValues: {r: -0.14810935, g: -0.00710578, b: 0.08569491, a: 2.2706196}
|
||||
- _RandomValues: {r: -1, g: 0.19, b: 0.4, a: -0.28}
|
||||
- _SecondaryColA: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _SecondaryColB: {r: 0.10720008, g: 0.1572306, b: 0.31132078, a: 0}
|
||||
- _TestParams: {r: 0, g: 1.15, b: 1.5, a: 13.36}
|
||||
- _TextureMask: {r: 0, g: 0, b: 1, a: 0}
|
||||
- _TextureWeights: {r: 0, g: 0, b: 0, a: 1}
|
||||
8
Assets/Plugins/Celestial Body/Materials/Moon.mat.meta
Normal file
8
Assets/Plugins/Celestial Body/Materials/Moon.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 41bb1c844a3fa4c39af73a372e0abb13
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
144
Assets/Plugins/Celestial Body/Materials/Sphere.mat
Normal file
144
Assets/Plugins/Celestial Body/Materials/Sphere.mat
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Sphere
|
||||
m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _CraterRay:
|
||||
m_Texture: {fileID: 2800000, guid: 1dd8d495747f9486b9b0f3a63b0ce851, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMap:
|
||||
m_Texture: {fileID: 2800000, guid: 65c07d8223a8f4c0ab716441f5c8c0a1, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailMask:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _DetailNormalMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _EmissionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMap:
|
||||
m_Texture: {fileID: 2800000, guid: fb5f32830e2c84487ababc395fd75b0e, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMapFlat:
|
||||
m_Texture: {fileID: 2800000, guid: fb5f32830e2c84487ababc395fd75b0e, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _NormalMapSteep:
|
||||
m_Texture: {fileID: 2800000, guid: c6335a766e3764fac8a632a38635cb2b, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _OcclusionMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _ParallaxMap:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Tex2:
|
||||
m_Texture: {fileID: 2800000, guid: 8bd6d87e9d43d47ac953370e4b627578, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _Tex3:
|
||||
m_Texture: {fileID: 2800000, guid: 56494c7daf00a41ecb4992bfa29b18be, type: 3}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Floats:
|
||||
- _BiomeBlendStrength: 12.929506
|
||||
- _BiomeDistortStrength: 0.33
|
||||
- _BiomeWarpStrength: 7.524333
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _EjectaBrightness: 0.2
|
||||
- _FresnelPow: 12
|
||||
- _FresnelStrengthFar: 5
|
||||
- _FresnelStrengthNear: 2
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.299
|
||||
- _GlossyReflections: 1
|
||||
- _MainTexScale: 4
|
||||
- _Metallic: 0
|
||||
- _MetallicA: 0
|
||||
- _MetallicB: 0
|
||||
- _Mode: 0
|
||||
- _NormalMapFlatScale: 15
|
||||
- _NormalMapScale: 5
|
||||
- _NormalMapSteepScale: 10
|
||||
- _NormalMapStrength: 0.545
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _PolesStartLongitude: 0.8486198
|
||||
- _PolesVisibility: 1
|
||||
- _SmoothnessA: 0.01718209
|
||||
- _SmoothnessB: 0.1488175
|
||||
- _SmoothnessEjecta: 0.5
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _TexNoiseScale: 0.44
|
||||
- _TextureMinBrightness: 1
|
||||
- _UVSec: 0
|
||||
- _UseEjecta: 1
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _Color2: {r: 0.7735849, g: 0.7735849, b: 0.7735849, a: 1}
|
||||
- _Color3: {r: 0.13207549, g: 0.13207549, b: 0.13207549, a: 1}
|
||||
- _Color4: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EjectaCol: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _FresnelCol: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _NormalMapScales: {r: 10, g: 10, b: 0, a: 0}
|
||||
- _Params: {r: 0.23, g: -1.27, b: 0.26, a: 0.52}
|
||||
- _PrimaryColA: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _PrimaryColB: {r: 0.2735849, g: 0.2735849, b: 0.2735849, a: 1}
|
||||
- _RandomBiomeValues: {r: -0.9317478, g: 0.26007134, b: 0.26075405, a: 0.0924205}
|
||||
- _RandomPoleValues: {r: -0.14810935, g: -0.00710578, b: 0.08569491, a: 2.2706196}
|
||||
- _RandomValues: {r: -1, g: 0.19, b: 0.4, a: -0.28}
|
||||
- _SecondaryColA: {r: 1, g: 1, b: 1, a: 0}
|
||||
- _SecondaryColB: {r: 0.10720008, g: 0.1572306, b: 0.31132078, a: 0}
|
||||
- _TestParams: {r: 0, g: 1.15, b: 1.5, a: 13.36}
|
||||
- _TextureMask: {r: 0, g: 0, b: 1, a: 0}
|
||||
- _TextureWeights: {r: 0, g: 0, b: 0, a: 1}
|
||||
8
Assets/Plugins/Celestial Body/Materials/Sphere.mat.meta
Normal file
8
Assets/Plugins/Celestial Body/Materials/Sphere.mat.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9a11048a1c8544c8e84d246de1e5571e
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Celestial Body/Scripts.meta
Normal file
8
Assets/Plugins/Celestial Body/Scripts.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1be7fc49445824dc98ddbcfcc3a7566e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
113
Assets/Plugins/Celestial Body/Scripts/CameraUtility.cs
Normal file
113
Assets/Plugins/Celestial Body/Scripts/CameraUtility.cs
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
using UnityEngine;
|
||||
|
||||
public static class CameraUtility {
|
||||
static readonly Vector3[] cubeCornerOffsets = {
|
||||
new Vector3 (1, 1, 1),
|
||||
new Vector3 (-1, 1, 1),
|
||||
new Vector3 (-1, -1, 1),
|
||||
new Vector3 (-1, -1, -1),
|
||||
new Vector3 (-1, 1, -1),
|
||||
new Vector3 (1, -1, -1),
|
||||
new Vector3 (1, 1, -1),
|
||||
new Vector3 (1, -1, 1),
|
||||
};
|
||||
|
||||
// http://wiki.unity3d.com/index.php/IsVisibleFrom
|
||||
public static bool VisibleFromCamera (Renderer renderer, Camera camera) {
|
||||
Plane[] frustumPlanes = GeometryUtility.CalculateFrustumPlanes (camera);
|
||||
return GeometryUtility.TestPlanesAABB (frustumPlanes, renderer.bounds);
|
||||
}
|
||||
|
||||
public static bool BoundsOverlap (MeshFilter nearObject, MeshFilter farObject, Camera camera) {
|
||||
|
||||
var near = GetScreenRectFromBounds (nearObject, camera);
|
||||
var far = GetScreenRectFromBounds (farObject, camera);
|
||||
|
||||
// ensure far object is indeed further away than near object
|
||||
if (far.zMax > near.zMin) {
|
||||
// Doesn't overlap on x axis
|
||||
if (far.xMax < near.xMin || far.xMin > near.xMax) {
|
||||
return false;
|
||||
}
|
||||
// Doesn't overlap on y axis
|
||||
if (far.yMax < near.yMin || far.yMin > near.yMax) {
|
||||
return false;
|
||||
}
|
||||
// Overlaps
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static float GetScreenHeight (Vector3 a, Vector3 b, Camera camera) {
|
||||
Debug.DrawLine(a,b,Color.red);
|
||||
Vector3 viewA = camera.WorldToViewportPoint (a);
|
||||
Vector3 viewB = camera.WorldToViewportPoint (b);
|
||||
float dst = Mathf.Abs (viewA.y - viewB.y);
|
||||
Debug.Log ("A: " + viewA.y + " B: " + viewB.y + " " + dst);
|
||||
return dst;
|
||||
}
|
||||
|
||||
// With thanks to http://www.turiyaware.com/a-solution-to-unitys-camera-worldtoscreenpoint-causing-ui-elements-to-display-when-object-is-behind-the-camera/
|
||||
public static MinMax3D GetScreenRectFromBounds (MeshFilter meshFilter, Camera camera) {
|
||||
MinMax3D minMax = new MinMax3D (float.MaxValue, float.MinValue);
|
||||
|
||||
Vector3[] screenBoundsExtents = new Vector3[8];
|
||||
var localBounds = meshFilter.sharedMesh.bounds;
|
||||
bool anyPointIsInFrontOfCamera = false;
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
Vector3 localSpaceCorner = localBounds.center + Vector3.Scale (localBounds.extents, cubeCornerOffsets[i]);
|
||||
Vector3 worldSpaceCorner = meshFilter.transform.TransformPoint (localSpaceCorner);
|
||||
Vector3 viewportSpaceCorner = camera.WorldToViewportPoint (worldSpaceCorner);
|
||||
|
||||
if (viewportSpaceCorner.z > 0) {
|
||||
anyPointIsInFrontOfCamera = true;
|
||||
} else {
|
||||
// If point is behind camera, it gets flipped to the opposite side
|
||||
// So clamp to opposite edge to correct for this
|
||||
viewportSpaceCorner.x = (viewportSpaceCorner.x <= 0.5f) ? 1 : 0;
|
||||
viewportSpaceCorner.y = (viewportSpaceCorner.y <= 0.5f) ? 1 : 0;
|
||||
}
|
||||
|
||||
// Update bounds with new corner point
|
||||
minMax.AddPoint (viewportSpaceCorner);
|
||||
}
|
||||
|
||||
// All points are behind camera so just return empty bounds
|
||||
if (!anyPointIsInFrontOfCamera) {
|
||||
return new MinMax3D ();
|
||||
}
|
||||
|
||||
return minMax;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct MinMax3D {
|
||||
public float xMin;
|
||||
public float xMax;
|
||||
public float yMin;
|
||||
public float yMax;
|
||||
public float zMin;
|
||||
public float zMax;
|
||||
|
||||
public MinMax3D (float min, float max) {
|
||||
this.xMin = min;
|
||||
this.xMax = max;
|
||||
this.yMin = min;
|
||||
this.yMax = max;
|
||||
this.zMin = min;
|
||||
this.zMax = max;
|
||||
}
|
||||
|
||||
public void AddPoint (Vector3 point) {
|
||||
xMin = Mathf.Min (xMin, point.x);
|
||||
xMax = Mathf.Max (xMax, point.x);
|
||||
yMin = Mathf.Min (yMin, point.y);
|
||||
yMax = Mathf.Max (yMax, point.y);
|
||||
zMin = Mathf.Min (zMin, point.z);
|
||||
zMax = Mathf.Max (zMax, point.z);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Plugins/Celestial Body/Scripts/CameraUtility.cs.meta
Normal file
11
Assets/Plugins/Celestial Body/Scripts/CameraUtility.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 111ff470e49f24bdfb0aa86a56f773a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
450
Assets/Plugins/Celestial Body/Scripts/CelestialBodyGenerator.cs
Normal file
450
Assets/Plugins/Celestial Body/Scripts/CelestialBodyGenerator.cs
Normal file
|
|
@ -0,0 +1,450 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class CelestialBodyGenerator : MonoBehaviour {
|
||||
|
||||
public enum PreviewMode { LOD0, LOD1, LOD2, CollisionRes }
|
||||
public ResolutionSettings resolutionSettings;
|
||||
public PreviewMode previewMode;
|
||||
|
||||
public bool logTimers;
|
||||
|
||||
public CelestialBodySettings body;
|
||||
|
||||
bool debugDoubleUpdate = true;
|
||||
int debug_numUpdates;
|
||||
|
||||
// Private variables
|
||||
Mesh previewMesh;
|
||||
Mesh collisionMesh;
|
||||
Mesh[] lodMeshes;
|
||||
|
||||
ComputeBuffer vertexBuffer;
|
||||
|
||||
bool shapeSettingsUpdated;
|
||||
bool shadingNoiseSettingsUpdated;
|
||||
Camera cam;
|
||||
|
||||
Vector2 heightMinMax;
|
||||
|
||||
// Game mode data
|
||||
int activeLODIndex = -1;
|
||||
MeshFilter terrainMeshFilter;
|
||||
Material terrainMatInstance;
|
||||
|
||||
static Dictionary<int, SphereMesh> sphereGenerators;
|
||||
|
||||
void Start () {
|
||||
if (InGameMode) {
|
||||
cam = Camera.main;
|
||||
HandleGameModeGeneration ();
|
||||
}
|
||||
}
|
||||
|
||||
void Update () {
|
||||
if (InEditMode) {
|
||||
HandleEditModeGeneration ();
|
||||
}
|
||||
}
|
||||
|
||||
// Handles creation of celestial body when entering game mode
|
||||
// This differs from the edit-mode version in the following ways:
|
||||
// • creates all LOD meshes and stores them in mesh array (to be picked based on player position)
|
||||
// • creates its own instances of materials so multiple bodies can exist with their own shading
|
||||
// • doesn't support updating of shape/shading values once generated
|
||||
void HandleGameModeGeneration () {
|
||||
if (CanGenerateMesh ()) {
|
||||
Dummy ();
|
||||
|
||||
// Generate LOD meshes
|
||||
lodMeshes = new Mesh[ResolutionSettings.numLODLevels];
|
||||
for (int i = 0; i < lodMeshes.Length; i++) {
|
||||
Vector2 lodTerrainHeightMinMax = GenerateTerrainMesh (ref lodMeshes[i], resolutionSettings.GetLODResolution (i));
|
||||
// Use min/max height of first (most detailed) LOD
|
||||
if (i == 0) {
|
||||
heightMinMax = lodTerrainHeightMinMax;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate collision mesh
|
||||
GenerateCollisionMesh (resolutionSettings.collider);
|
||||
|
||||
// Create terrain renderer and set shading properties on the instanced material
|
||||
terrainMatInstance = new Material (body.shading.terrainMaterial);
|
||||
body.shading.Initialize (body.shape);
|
||||
body.shading.SetTerrainProperties (terrainMatInstance, heightMinMax, BodyScale);
|
||||
GameObject terrainHolder = GetOrCreateMeshObject ("Terrain Mesh", null, terrainMatInstance);
|
||||
terrainMeshFilter = terrainHolder.GetComponent<MeshFilter> ();
|
||||
|
||||
// Add collider
|
||||
MeshCollider collider;
|
||||
if (!terrainHolder.TryGetComponent<MeshCollider> (out collider)) {
|
||||
collider = terrainHolder.AddComponent<MeshCollider> ();
|
||||
}
|
||||
|
||||
var collisionBakeTimer = System.Diagnostics.Stopwatch.StartNew ();
|
||||
MeshBaker.BakeMeshImmediate (collisionMesh);
|
||||
collider.sharedMesh = collisionMesh;
|
||||
LogTimer (collisionBakeTimer, "Mesh collider");
|
||||
|
||||
} else {
|
||||
Debug.Log ("Could not generate mesh");
|
||||
}
|
||||
|
||||
ReleaseAllBuffers ();
|
||||
}
|
||||
|
||||
// Handles creation of celestial body in the editor
|
||||
// This allows for updating the shape/shading settings
|
||||
void HandleEditModeGeneration () {
|
||||
if (InEditMode) {
|
||||
ComputeHelper.shouldReleaseEditModeBuffers -= ReleaseAllBuffers;
|
||||
ComputeHelper.shouldReleaseEditModeBuffers += ReleaseAllBuffers;
|
||||
}
|
||||
|
||||
if (CanGenerateMesh ()) {
|
||||
// Update shape settings and shading noise
|
||||
if (shapeSettingsUpdated) {
|
||||
shapeSettingsUpdated = false;
|
||||
shadingNoiseSettingsUpdated = false;
|
||||
Dummy ();
|
||||
|
||||
var terrainMeshTimer = System.Diagnostics.Stopwatch.StartNew ();
|
||||
heightMinMax = GenerateTerrainMesh (ref previewMesh, PickTerrainRes ());
|
||||
|
||||
LogTimer (terrainMeshTimer, "Generate terrain mesh");
|
||||
DrawEditModeMesh ();
|
||||
}
|
||||
// If only shading noise has changed, update it separately from shape to save time
|
||||
else if (shadingNoiseSettingsUpdated) {
|
||||
shadingNoiseSettingsUpdated = false;
|
||||
ComputeHelper.CreateStructuredBuffer<Vector3> (ref vertexBuffer, previewMesh.vertices);
|
||||
body.shading.Initialize (body.shape);
|
||||
Vector4[] shadingData = body.shading.GenerateShadingData (vertexBuffer);
|
||||
previewMesh.SetUVs (0, shadingData);
|
||||
|
||||
// Sometimes when changing a colour property, invalid data is returned from compute shader
|
||||
// Running the shading a second time fixes it.
|
||||
// Not sure if this is my bug, or Unity's (TODO: investigate)
|
||||
debug_numUpdates++;
|
||||
if (debugDoubleUpdate && debug_numUpdates < 2) {
|
||||
shadingNoiseSettingsUpdated = true;
|
||||
HandleEditModeGeneration ();
|
||||
}
|
||||
if (debug_numUpdates == 2) {
|
||||
debug_numUpdates = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Update shading
|
||||
if (body && body.shading) {
|
||||
// Set material properties
|
||||
body.shading.Initialize (body.shape);
|
||||
body.shading.SetTerrainProperties (body.shading.terrainMaterial, heightMinMax, BodyScale);
|
||||
}
|
||||
|
||||
ReleaseAllBuffers (); //
|
||||
}
|
||||
|
||||
public void SetLOD (int lodIndex) {
|
||||
if (lodIndex != activeLODIndex && terrainMeshFilter) {
|
||||
activeLODIndex = lodIndex;
|
||||
terrainMeshFilter.sharedMesh = lodMeshes[lodIndex];
|
||||
}
|
||||
}
|
||||
|
||||
public void OnShapeSettingChanged () {
|
||||
shapeSettingsUpdated = true;
|
||||
}
|
||||
|
||||
public void OnShadingNoiseSettingChanged () {
|
||||
shadingNoiseSettingsUpdated = true;
|
||||
}
|
||||
|
||||
void OnValidate () {
|
||||
if (body) {
|
||||
if (body.shape) {
|
||||
body.shape.OnSettingChanged -= OnShapeSettingChanged;
|
||||
body.shape.OnSettingChanged += OnShapeSettingChanged;
|
||||
}
|
||||
if (body.shading) {
|
||||
body.shading.OnSettingChanged -= OnShadingNoiseSettingChanged;
|
||||
body.shading.OnSettingChanged += OnShadingNoiseSettingChanged;
|
||||
}
|
||||
}
|
||||
|
||||
if (resolutionSettings != null) {
|
||||
resolutionSettings.ClampResolutions ();
|
||||
}
|
||||
OnShapeSettingChanged ();
|
||||
}
|
||||
|
||||
void Dummy () {
|
||||
// Crude fix for a problem I was having where the values in the vertex buffer were *occasionally* all zero at start of game
|
||||
// This function runs the compute shader once with single dummy input, after which it seems the problem doesn't occur
|
||||
// (Waiting until Time.frameCount > 3 before generating is another gross hack that seems to fix the problem)
|
||||
// I don't know why...
|
||||
Vector3[] vertices = new Vector3[] { Vector3.zero };
|
||||
ComputeHelper.CreateStructuredBuffer<Vector3> (ref vertexBuffer, vertices);
|
||||
body.shape.CalculateHeights (vertexBuffer);
|
||||
}
|
||||
|
||||
// Generates terrain mesh based on heights generated by the Shape object
|
||||
// Shading data from the Shading object is stored in the mesh uvs
|
||||
// Returns the min/max height of the terrain
|
||||
Vector2 GenerateTerrainMesh (ref Mesh mesh, int resolution) {
|
||||
var (vertices, triangles) = CreateSphereVertsAndTris (resolution);
|
||||
ComputeHelper.CreateStructuredBuffer<Vector3> (ref vertexBuffer, vertices);
|
||||
|
||||
float edgeLength = (vertices[triangles[0]] - vertices[triangles[1]]).magnitude;
|
||||
|
||||
// Set heights
|
||||
float[] heights = body.shape.CalculateHeights (vertexBuffer);
|
||||
|
||||
// Perturb vertices to give terrain a less perfectly smooth appearance
|
||||
if (body.shape.perturbVertices && body.shape.perturbCompute) {
|
||||
ComputeShader perturbShader = body.shape.perturbCompute;
|
||||
float maxperturbStrength = body.shape.perturbStrength * edgeLength / 2;
|
||||
|
||||
perturbShader.SetBuffer (0, "points", vertexBuffer);
|
||||
perturbShader.SetInt ("numPoints", vertices.Length);
|
||||
perturbShader.SetFloat ("maxStrength", maxperturbStrength);
|
||||
|
||||
ComputeHelper.Run (perturbShader, vertices.Length);
|
||||
Vector3[] pertData = new Vector3[vertices.Length];
|
||||
vertexBuffer.GetData (vertices);
|
||||
}
|
||||
|
||||
// Calculate terrain min/max height and set heights of vertices
|
||||
float minHeight = float.PositiveInfinity;
|
||||
float maxHeight = float.NegativeInfinity;
|
||||
for (int i = 0; i < heights.Length; i++) {
|
||||
float height = heights[i];
|
||||
vertices[i] *= height;
|
||||
minHeight = Mathf.Min (minHeight, height);
|
||||
maxHeight = Mathf.Max (maxHeight, height);
|
||||
}
|
||||
|
||||
// Create mesh
|
||||
CreateMesh (ref mesh, vertices.Length);
|
||||
mesh.SetVertices (vertices);
|
||||
mesh.SetTriangles (triangles, 0, true);
|
||||
mesh.RecalculateNormals (); //
|
||||
|
||||
// Shading noise data
|
||||
body.shading.Initialize (body.shape);
|
||||
Vector4[] shadingData = body.shading.GenerateShadingData (vertexBuffer);
|
||||
mesh.SetUVs (0, shadingData);
|
||||
|
||||
// Create crude tangents (vectors perpendicular to surface normal)
|
||||
// This is needed (even though normal mapping is being done with triplanar)
|
||||
// because surfaceshader wants normals in tangent space
|
||||
var normals = mesh.normals;
|
||||
var crudeTangents = new Vector4[mesh.vertices.Length];
|
||||
for (int i = 0; i < vertices.Length; i++) {
|
||||
Vector3 normal = normals[i];
|
||||
crudeTangents[i] = new Vector4 (-normal.z, 0, normal.x, 1);
|
||||
}
|
||||
mesh.SetTangents (crudeTangents);
|
||||
|
||||
return new Vector2 (minHeight, maxHeight);
|
||||
}
|
||||
|
||||
void GenerateCollisionMesh (int resolution) {
|
||||
var (vertices, triangles) = CreateSphereVertsAndTris (resolution);
|
||||
ComputeHelper.CreateStructuredBuffer<Vector3> (ref vertexBuffer, vertices);
|
||||
|
||||
// Set heights
|
||||
float[] heights = body.shape.CalculateHeights (vertexBuffer);
|
||||
for (int i = 0; i < vertices.Length; i++) {
|
||||
float height = heights[i];
|
||||
vertices[i] *= height;
|
||||
}
|
||||
|
||||
// Create mesh
|
||||
CreateMesh (ref collisionMesh, vertices.Length);
|
||||
collisionMesh.vertices = vertices;
|
||||
collisionMesh.triangles = triangles;
|
||||
}
|
||||
|
||||
void CreateMesh (ref Mesh mesh, int numVertices) {
|
||||
const int vertexLimit16Bit = 1 << 16 - 1; // 65535
|
||||
if (mesh == null) {
|
||||
mesh = new Mesh ();
|
||||
} else {
|
||||
mesh.Clear ();
|
||||
}
|
||||
mesh.indexFormat = (numVertices < vertexLimit16Bit) ? UnityEngine.Rendering.IndexFormat.UInt16 : UnityEngine.Rendering.IndexFormat.UInt32;
|
||||
}
|
||||
|
||||
void DrawEditModeMesh () {
|
||||
GameObject terrainHolder = GetOrCreateMeshObject ("Terrain Mesh", previewMesh, body.shading.terrainMaterial);
|
||||
}
|
||||
|
||||
// Gets child object with specified name.
|
||||
// If it doesn't exist, then creates object with that name, adds mesh renderer/filter and attaches mesh and material
|
||||
GameObject GetOrCreateMeshObject (string name, Mesh mesh, Material material) {
|
||||
// Find/create object
|
||||
var child = transform.Find (name);
|
||||
if (!child) {
|
||||
child = new GameObject (name).transform;
|
||||
child.parent = transform;
|
||||
child.localPosition = Vector3.zero;
|
||||
child.localRotation = Quaternion.identity;
|
||||
child.localScale = Vector3.one;
|
||||
child.gameObject.layer = gameObject.layer;
|
||||
}
|
||||
|
||||
// Add mesh components
|
||||
MeshFilter filter;
|
||||
if (!child.TryGetComponent<MeshFilter> (out filter)) {
|
||||
filter = child.gameObject.AddComponent<MeshFilter> ();
|
||||
}
|
||||
filter.sharedMesh = mesh;
|
||||
|
||||
MeshRenderer renderer;
|
||||
if (!child.TryGetComponent<MeshRenderer> (out renderer)) {
|
||||
renderer = child.gameObject.AddComponent<MeshRenderer> ();
|
||||
}
|
||||
renderer.sharedMaterial = material;
|
||||
|
||||
return child.gameObject;
|
||||
}
|
||||
|
||||
public int PickTerrainRes () {
|
||||
if (!Application.isPlaying) {
|
||||
switch (previewMode) {
|
||||
case PreviewMode.LOD0:
|
||||
return resolutionSettings.lod0;
|
||||
case PreviewMode.LOD1:
|
||||
return resolutionSettings.lod1;
|
||||
case PreviewMode.LOD2:
|
||||
return resolutionSettings.lod2;
|
||||
case PreviewMode.CollisionRes:
|
||||
return resolutionSettings.collider;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
// Radius of the ocean (0 if no ocean exists)
|
||||
// public float GetOceanRadius () {
|
||||
// if (!body.shading.hasOcean) {
|
||||
// return 0;
|
||||
// }
|
||||
// return UnscaledOceanRadius * BodyScale;
|
||||
// }
|
||||
|
||||
// float UnscaledOceanRadius {
|
||||
// get {
|
||||
// return Mathf.Lerp (heightMinMax.x, 1, body.shading.oceanLevel);
|
||||
// }
|
||||
// }
|
||||
|
||||
public float BodyScale {
|
||||
get {
|
||||
// Body radius is determined by the celestial body class,
|
||||
// which sets the local scale of the generator object (this object)
|
||||
return transform.localScale.x;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate sphere (or reuse if already generated) and return a copy of the vertices and triangles
|
||||
(Vector3[] vertices, int[] triangles) CreateSphereVertsAndTris (int resolution) {
|
||||
if (sphereGenerators == null) {
|
||||
sphereGenerators = new Dictionary<int, SphereMesh> ();
|
||||
}
|
||||
|
||||
if (!sphereGenerators.ContainsKey (resolution)) {
|
||||
sphereGenerators.Add (resolution, new SphereMesh (resolution));
|
||||
}
|
||||
|
||||
var generator = sphereGenerators[resolution];
|
||||
|
||||
var vertices = new Vector3[generator.Vertices.Length];
|
||||
var triangles = new int[generator.Triangles.Length];
|
||||
System.Array.Copy (generator.Vertices, vertices, vertices.Length);
|
||||
System.Array.Copy (generator.Triangles, triangles, triangles.Length);
|
||||
return (vertices, triangles);
|
||||
}
|
||||
|
||||
void ReleaseAllBuffers () {
|
||||
ComputeHelper.Release (vertexBuffer);
|
||||
if (body && body.shape) {
|
||||
body.shape.ReleaseBuffers ();
|
||||
}
|
||||
if (body && body.shading) {
|
||||
body.shading.ReleaseBuffers ();
|
||||
}
|
||||
}
|
||||
|
||||
void OnDestroy () {
|
||||
ReleaseAllBuffers ();
|
||||
}
|
||||
|
||||
bool CanGenerateMesh () {
|
||||
if (body == null) return false;
|
||||
return ComputeHelper.CanRunEditModeCompute && body.shape && body.shape.heightMapCompute;
|
||||
}
|
||||
|
||||
void LogTimer (System.Diagnostics.Stopwatch sw, string text) {
|
||||
if (logTimers) {
|
||||
Debug.Log (text + " " + sw.ElapsedMilliseconds + " ms.");
|
||||
}
|
||||
}
|
||||
|
||||
bool InGameMode {
|
||||
get {
|
||||
return Application.isPlaying;
|
||||
}
|
||||
}
|
||||
|
||||
bool InEditMode {
|
||||
get {
|
||||
return !Application.isPlaying;
|
||||
}
|
||||
}
|
||||
|
||||
public class TerrainData {
|
||||
public float[] heights;
|
||||
public Vector4[] uvs;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class ResolutionSettings {
|
||||
|
||||
public const int numLODLevels = 3;
|
||||
const int maxAllowedResolution = 500;
|
||||
|
||||
public int lod0 = 300;
|
||||
public int lod1 = 100;
|
||||
public int lod2 = 50;
|
||||
public int collider = 100;
|
||||
|
||||
public int GetLODResolution (int lodLevel) {
|
||||
switch (lodLevel) {
|
||||
case 0:
|
||||
return lod0;
|
||||
case 1:
|
||||
return lod1;
|
||||
case 2:
|
||||
return lod2;
|
||||
}
|
||||
return lod2;
|
||||
}
|
||||
|
||||
public void ClampResolutions () {
|
||||
lod0 = Mathf.Min (maxAllowedResolution, lod0);
|
||||
lod1 = Mathf.Min (maxAllowedResolution, lod1);
|
||||
lod2 = Mathf.Min (maxAllowedResolution, lod2);
|
||||
collider = Mathf.Min (maxAllowedResolution, collider);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bbe3bd5182f0f47d6a8a90fe1aaadc52
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (menuName = "Celestial Body/Settings Holder")]
|
||||
public class CelestialBodySettings : ScriptableObject {
|
||||
public CelestialBodyShape shape;
|
||||
public CelestialBodyShading shading;
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1cf43e303dd354502bcaddeec557e12a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Celestial Body/Scripts/Editor.meta
Normal file
8
Assets/Plugins/Celestial Body/Scripts/Editor.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c548d41dd6e37458e85fc5cee48e1799
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,98 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor (typeof (CelestialBodyGenerator))]
|
||||
public class GeneratorEditor : Editor {
|
||||
|
||||
CelestialBodyGenerator generator;
|
||||
Editor shapeEditor;
|
||||
Editor shadingEditor;
|
||||
|
||||
bool shapeFoldout;
|
||||
bool shadingFoldout;
|
||||
|
||||
public override void OnInspectorGUI ()
|
||||
{
|
||||
using (var check = new EditorGUI.ChangeCheckScope ()) {
|
||||
DrawDefaultInspector ();
|
||||
if (check.changed) {
|
||||
Regenerate ();
|
||||
}
|
||||
}
|
||||
if (generator.body == null) return;
|
||||
|
||||
if (GUILayout.Button ("Generate")) {
|
||||
Regenerate ();
|
||||
}
|
||||
if (GUILayout.Button ("Randomize Shading")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shading.randomize = true;
|
||||
generator.body.shading.seed = prng.Next (-10000, 10000);
|
||||
Regenerate ();
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Randomize Shape")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shape.randomize = true;
|
||||
generator.body.shape.seed = prng.Next (-10000, 10000);
|
||||
Regenerate ();
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Randomize Both")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shading.randomize = true;
|
||||
generator.body.shape.randomize = true;
|
||||
generator.body.shape.seed = prng.Next (-10000, 10000);
|
||||
generator.body.shading.seed = prng.Next (-10000, 10000);
|
||||
Regenerate ();
|
||||
}
|
||||
|
||||
bool randomized = generator.body.shading.randomize || generator.body.shape.randomize;
|
||||
randomized |= generator.body.shading.seed != 0 || generator.body.shape.seed != 0;
|
||||
using (new EditorGUI.DisabledGroupScope (!randomized)) {
|
||||
if (GUILayout.Button ("Reset Randomization")) {
|
||||
var prng = new System.Random ();
|
||||
generator.body.shading.randomize = false;
|
||||
generator.body.shape.randomize = false;
|
||||
generator.body.shape.seed = 0;
|
||||
generator.body.shading.seed = 0;
|
||||
Regenerate ();
|
||||
}
|
||||
}
|
||||
|
||||
// Draw shape/shading object editors
|
||||
DrawSettingsEditor (generator.body.shape, ref shapeFoldout, ref shapeEditor);
|
||||
DrawSettingsEditor (generator.body.shading, ref shadingFoldout, ref shadingEditor);
|
||||
|
||||
SaveState ();
|
||||
}
|
||||
|
||||
void Regenerate () {
|
||||
generator.OnShapeSettingChanged ();
|
||||
generator.OnShadingNoiseSettingChanged ();
|
||||
EditorApplication.QueuePlayerLoopUpdate ();
|
||||
}
|
||||
|
||||
void DrawSettingsEditor (Object settings, ref bool foldout, ref Editor editor) {
|
||||
if (settings != null) {
|
||||
foldout = EditorGUILayout.InspectorTitlebar (foldout, settings);
|
||||
if (foldout) {
|
||||
CreateCachedEditor (settings, null, ref editor);
|
||||
editor.OnInspectorGUI ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnable () {
|
||||
shapeFoldout = EditorPrefs.GetBool (nameof (shapeFoldout), false);
|
||||
shadingFoldout = EditorPrefs.GetBool (nameof (shadingFoldout), false);
|
||||
generator = (CelestialBodyGenerator) target;
|
||||
}
|
||||
|
||||
void SaveState () {
|
||||
EditorPrefs.SetBool (nameof (shapeFoldout), shapeFoldout);
|
||||
EditorPrefs.SetBool (nameof (shadingFoldout), shadingFoldout);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 823a5227efa6c4baa801dd74ca50ab82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor (typeof (TextureCombiner), true)]
|
||||
public class TextureCombinerEditor : Editor {
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
DrawDefaultInspector ();
|
||||
|
||||
var textureCombiner = (TextureCombiner) target;
|
||||
|
||||
if (GUILayout.Button ("Save")) {
|
||||
string path = Application.dataPath + "/Resources";
|
||||
textureCombiner.SaveTexture (path);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 441a3534f217d45a6945869ae94c0e63
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor (typeof (TextureViewer), true)]
|
||||
public class TextureEditor : Editor {
|
||||
|
||||
Editor generatorEditor;
|
||||
bool generatorFoldout;
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
DrawDefaultInspector ();
|
||||
|
||||
var textureViewer = (TextureViewer) target;
|
||||
|
||||
if (GUILayout.Button ("Generate")) {
|
||||
textureViewer.UpdateTexture ();
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Save")) {
|
||||
string path = Application.dataPath + "/Resources";
|
||||
textureViewer.SaveTexture (path);
|
||||
}
|
||||
|
||||
if (textureViewer.generator) {
|
||||
bool settingsUpdated = DrawSettingsEditor (textureViewer.generator, ref generatorFoldout, ref generatorEditor);
|
||||
if (settingsUpdated) {
|
||||
textureViewer.UpdateTexture ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool DrawSettingsEditor (Object settings, ref bool foldout, ref Editor editor) {
|
||||
if (settings != null) {
|
||||
foldout = EditorGUILayout.InspectorTitlebar (foldout, settings);
|
||||
if (foldout) {
|
||||
using (var check = new EditorGUI.ChangeCheckScope ()) {
|
||||
CreateCachedEditor (settings, null, ref editor);
|
||||
editor.OnInspectorGUI ();
|
||||
if (check.changed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void OnEnable () {
|
||||
generatorFoldout = EditorPrefs.GetBool (nameof (generatorFoldout), false);
|
||||
}
|
||||
|
||||
void OnDisable () {
|
||||
EditorPrefs.SetBool (nameof (generatorFoldout), generatorFoldout);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c73be003ed7554257819b982d1816b59
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
78
Assets/Plugins/Celestial Body/Scripts/LODHandler.cs
Normal file
78
Assets/Plugins/Celestial Body/Scripts/LODHandler.cs
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class LODHandler : MonoBehaviour {
|
||||
[Header ("LOD screen heights")]
|
||||
// LOD level is determined by body's screen height (1 = taking up entire screen, 0 = teeny weeny speck)
|
||||
public float lod1Threshold = .5f;
|
||||
public float lod2Threshold = .2f;
|
||||
|
||||
// [Header ("Debug")]
|
||||
// public bool debug;
|
||||
// public CelestialBody debugBody;
|
||||
|
||||
Camera cam;
|
||||
Transform camT;
|
||||
// CelestialBody[] bodies;
|
||||
CelestialBodyGenerator[] generators;
|
||||
|
||||
public void FindPlanets()
|
||||
{
|
||||
generators = FindObjectsOfType<CelestialBodyGenerator> ();
|
||||
}
|
||||
|
||||
void Update () {
|
||||
//DebugLODInfo ();
|
||||
|
||||
if (Application.isPlaying) {
|
||||
HandleLODs ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void HandleLODs () {
|
||||
for (int i = 0; i < generators.Length; i++) {
|
||||
float screenHeight = CalculateScreenHeight (generators[i]);
|
||||
int lodIndex = CalculateLODIndex (screenHeight);
|
||||
generators[i].SetLOD (lodIndex);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
int CalculateLODIndex (float screenHeight) {
|
||||
if (screenHeight > lod1Threshold) {
|
||||
return 0;
|
||||
} else if (screenHeight > lod2Threshold) {
|
||||
return 1;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
||||
// void DebugLODInfo () {
|
||||
// if (debugBody && debug) {
|
||||
// float h = CalculateScreenHeight (debugBody);
|
||||
// int index = CalculateLODIndex (h);
|
||||
// Debug.Log ($"Screen height of {debugBody.name}: {h} (lod = {index})");
|
||||
// }
|
||||
// }
|
||||
|
||||
float CalculateScreenHeight (CelestialBodyGenerator body) {
|
||||
if (cam == null) {
|
||||
cam = Camera.main;
|
||||
camT = cam.transform;
|
||||
}
|
||||
Quaternion originalRot = camT.rotation;
|
||||
Vector3 bodyCentre = body.transform.position;
|
||||
camT.LookAt (bodyCentre);
|
||||
|
||||
var radius = body.transform.localScale.x;
|
||||
Vector3 viewA = cam.WorldToViewportPoint (bodyCentre - camT.up * radius);
|
||||
Vector3 viewB = cam.WorldToViewportPoint (bodyCentre + camT.up * radius);
|
||||
float screenHeight = Mathf.Abs (viewA.y - viewB.y);
|
||||
camT.rotation = originalRot;
|
||||
|
||||
return screenHeight;
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Celestial Body/Scripts/LODHandler.cs.meta
Normal file
11
Assets/Plugins/Celestial Body/Scripts/LODHandler.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 57b1674fe39b4584faf5fa92c3e4e024
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
48
Assets/Plugins/Celestial Body/Scripts/MeshBaker.cs
Normal file
48
Assets/Plugins/Celestial Body/Scripts/MeshBaker.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Collections;
|
||||
using Unity.Jobs;
|
||||
using UnityEngine;
|
||||
|
||||
public static class MeshBaker {
|
||||
|
||||
static Dictionary<Mesh, JobHandle> jobsByMesh;
|
||||
|
||||
static MeshBaker () {
|
||||
jobsByMesh = new Dictionary<Mesh, JobHandle> ();
|
||||
}
|
||||
|
||||
public static void BakeMeshImmediate (Mesh mesh) {
|
||||
var job = new BakeJob (mesh.GetInstanceID ());
|
||||
JobHandle currentJob = job.Schedule ();
|
||||
currentJob.Complete ();
|
||||
}
|
||||
|
||||
public static void StartBakingMesh (Mesh mesh) {
|
||||
var job = new BakeJob (mesh.GetInstanceID ());
|
||||
JobHandle currentJob = job.Schedule ();
|
||||
jobsByMesh.Add (mesh, currentJob);
|
||||
}
|
||||
|
||||
public static void EnsureBakingComplete (Mesh mesh) {
|
||||
if (jobsByMesh.ContainsKey (mesh)) {
|
||||
jobsByMesh[mesh].Complete ();
|
||||
jobsByMesh.Remove (mesh);
|
||||
} else {
|
||||
BakeMeshImmediate (mesh);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public struct BakeJob : IJob {
|
||||
|
||||
int meshID;
|
||||
public BakeJob (int meshID) {
|
||||
this.meshID = meshID;
|
||||
}
|
||||
|
||||
public void Execute () {
|
||||
Physics.BakeMesh (meshID, false);
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Celestial Body/Scripts/MeshBaker.cs.meta
Normal file
11
Assets/Plugins/Celestial Body/Scripts/MeshBaker.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e6efe2e9f564c464e8b47696ab6a5752
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Celestial Body/Scripts/NoiseSettings.meta
Normal file
8
Assets/Plugins/Celestial Body/Scripts/NoiseSettings.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 944baa69d640f4d979fe5e813b8a0aaa
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class CraterSettings {
|
||||
|
||||
// Exposed settings
|
||||
public bool enabled = true;
|
||||
public int craterSeed;
|
||||
public int numCraters = 400;
|
||||
public Vector2 craterSizeMinMax = new Vector2 (0.01f, 0.1f);
|
||||
public float rimSteepness = 0.13f;
|
||||
public float rimWidth = 1.6f;
|
||||
public Vector2 smoothMinMax = new Vector2 (0.4f, 1.5f);
|
||||
[Range (0, 1)]
|
||||
public float sizeDistribution = 0.6f;
|
||||
|
||||
[HideInInspector]
|
||||
public Crater[] cachedCraters;
|
||||
|
||||
// Private
|
||||
ComputeBuffer craterBuffer;
|
||||
|
||||
// Set values using exposed settings
|
||||
public void SetComputeValues (ComputeShader computeShader, int masterSeed) {
|
||||
SetComputeValues (computeShader, masterSeed, numCraters, craterSizeMinMax, sizeDistribution);
|
||||
}
|
||||
|
||||
// Set values using custom numCraters
|
||||
public void SetComputeValues (ComputeShader computeShader, int masterSeed, int numCraters) {
|
||||
SetComputeValues (computeShader, masterSeed, numCraters, craterSizeMinMax, sizeDistribution);
|
||||
}
|
||||
|
||||
// Set values using custom numCraters and sizeMinMax
|
||||
public void SetComputeValues (ComputeShader computeShader, int masterSeed, int numCraters, Vector2 craterSizeMinMax, float sizeDistribution) {
|
||||
if (!enabled) {
|
||||
numCraters = 1;
|
||||
craterSizeMinMax = Vector2.zero;
|
||||
}
|
||||
|
||||
Random.InitState (craterSeed + masterSeed);
|
||||
Crater[] craters = new Crater[numCraters];
|
||||
PRNG prng = new PRNG (masterSeed);
|
||||
|
||||
// Create craters
|
||||
for (int i = 0; i < numCraters; i++) {
|
||||
float t = prng.ValueBiasLower (sizeDistribution);
|
||||
|
||||
float size = Mathf.Lerp (craterSizeMinMax.x, craterSizeMinMax.y, t);
|
||||
float floorHeight = Mathf.Lerp (-1.2f, -0.2f, t + prng.ValueBiasLower (0.3f));
|
||||
float smooth = Mathf.Lerp (smoothMinMax.x, smoothMinMax.y, 1 - t);
|
||||
craters[i] = new Crater () { centre = Random.onUnitSphere, size = size, floorHeight = floorHeight, smoothness = smooth };
|
||||
}
|
||||
cachedCraters = craters;
|
||||
|
||||
// Set shape data
|
||||
ComputeHelper.CreateAndSetBuffer<Crater> (ref craterBuffer, craters, computeShader, "craters");
|
||||
computeShader.SetInt ("numCraters", numCraters);
|
||||
|
||||
computeShader.SetFloat (nameof (rimSteepness), rimSteepness);
|
||||
computeShader.SetFloat (nameof (rimWidth), rimWidth);
|
||||
//computeShader.SetFloat (nameof (smoothFactor), smoothFactor);
|
||||
}
|
||||
|
||||
public void ReleaseBuffers () {
|
||||
ComputeHelper.Release (craterBuffer);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public struct Crater {
|
||||
public Vector3 centre;
|
||||
public float size;
|
||||
public float floorHeight;
|
||||
public float smoothness;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a9d550c3b804444558e4efd3f7b16c46
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class RidgeNoiseSettings {
|
||||
public int numLayers = 5;
|
||||
public float lacunarity = 2;
|
||||
public float persistence = 0.5f;
|
||||
public float scale = 1;
|
||||
public float power = 2;
|
||||
public float elevation = 1;
|
||||
public float gain = 1;
|
||||
public float verticalShift = 0;
|
||||
public float peakSmoothing = 0;
|
||||
public Vector3 offset;
|
||||
|
||||
// Set values using exposed settings
|
||||
public void SetComputeValues (ComputeShader cs, PRNG prng, string varSuffix) {
|
||||
SetComputeValues (cs, prng, varSuffix, scale, elevation, power);
|
||||
}
|
||||
|
||||
// Set values using custom scale and elevation
|
||||
public void SetComputeValues (ComputeShader cs, PRNG prng, string varSuffix, float scale, float elevation, float power) {
|
||||
Vector3 seededOffset = new Vector3 (prng.Value (), prng.Value (), prng.Value ()) * prng.Value () * 10000;
|
||||
|
||||
float[] noiseParams = {
|
||||
// [0]
|
||||
seededOffset.x + offset.x,
|
||||
seededOffset.y + offset.y,
|
||||
seededOffset.z + offset.z,
|
||||
numLayers,
|
||||
// [1]
|
||||
persistence,
|
||||
lacunarity,
|
||||
scale,
|
||||
elevation,
|
||||
// [2]
|
||||
power,
|
||||
gain,
|
||||
verticalShift,
|
||||
peakSmoothing
|
||||
};
|
||||
|
||||
cs.SetFloats ("noiseParams" + varSuffix, noiseParams);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5ce43a491b81c44459b8660e15e2ca80
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[System.Serializable]
|
||||
public class SimpleNoiseSettings {
|
||||
public int numLayers = 4;
|
||||
public float lacunarity = 2;
|
||||
public float persistence = 0.5f;
|
||||
public float scale = 1;
|
||||
public float elevation = 1;
|
||||
public float verticalShift = 0;
|
||||
public Vector3 offset;
|
||||
|
||||
// Set values using exposed settings
|
||||
public void SetComputeValues (ComputeShader cs, PRNG prng, string varSuffix) {
|
||||
SetComputeValues (cs, prng, varSuffix, scale, elevation, persistence);
|
||||
}
|
||||
|
||||
// Set values using custom scale and elevation
|
||||
public void SetComputeValues (ComputeShader cs, PRNG prng, string varSuffix, float scale, float elevation) {
|
||||
SetComputeValues (cs, prng, varSuffix, scale, elevation, persistence);
|
||||
}
|
||||
|
||||
// Set values using custom scale and elevation
|
||||
public void SetComputeValues (ComputeShader cs, PRNG prng, string varSuffix, float scale, float elevation, float persistence) {
|
||||
Vector3 seededOffset = new Vector3 (prng.Value (), prng.Value (), prng.Value ()) * prng.Value () * 10000;
|
||||
|
||||
float[] noiseParams = {
|
||||
// [0]
|
||||
seededOffset.x + offset.x,
|
||||
seededOffset.y + offset.y,
|
||||
seededOffset.z + offset.z,
|
||||
numLayers,
|
||||
// [1]
|
||||
persistence,
|
||||
lacunarity,
|
||||
scale,
|
||||
elevation,
|
||||
// [2]
|
||||
verticalShift
|
||||
};
|
||||
|
||||
cs.SetFloats ("noiseParams" + varSuffix, noiseParams);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b9fcbd96d66fe4c07b65caa879fc4898
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Plugins/Celestial Body/Scripts/Normalizer.cs
Normal file
21
Assets/Plugins/Celestial Body/Scripts/Normalizer.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class Normalizer {
|
||||
|
||||
public static void Normalize (System.Func<int, float> getValue, System.Action<int, float> setValue, int length) {
|
||||
float min = float.PositiveInfinity;
|
||||
float max = float.NegativeInfinity;
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
float value = getValue (i);
|
||||
min = System.Math.Min (min, value);
|
||||
max = System.Math.Max (max, value);
|
||||
}
|
||||
for (int i = 0; i < length; i++) {
|
||||
setValue (i, Mathf.InverseLerp (min, max, getValue (i)));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Plugins/Celestial Body/Scripts/Normalizer.cs.meta
Normal file
11
Assets/Plugins/Celestial Body/Scripts/Normalizer.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1d100b5aa20444f8fb097d412a664190
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
55
Assets/Plugins/Celestial Body/Scripts/OceanSettings.cs
Normal file
55
Assets/Plugins/Celestial Body/Scripts/OceanSettings.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[CreateAssetMenu (menuName = "Celestial Body/Ocean")]
|
||||
public class OceanSettings : ScriptableObject {
|
||||
public float depthMultiplier = 10;
|
||||
public float alphaMultiplier = 70;
|
||||
public Color colA;
|
||||
public Color colB;
|
||||
public Color specularCol = Color.white;
|
||||
[Header ("Waves")]
|
||||
public Texture2D waveNormalA;
|
||||
public Texture2D waveNormalB;
|
||||
[Range (0, 1)]
|
||||
public float waveStrength = 0.15f;
|
||||
public float waveScale = 15;
|
||||
public float waveSpeed = 0.5f;
|
||||
|
||||
//[Header("")]
|
||||
[Range (0, 1)]
|
||||
public float smoothness = 0.92f;
|
||||
public Vector4 testParams;
|
||||
|
||||
public void SetProperties (Material material, int seed, bool randomize) {
|
||||
material.SetFloat ("depthMultiplier", depthMultiplier);
|
||||
material.SetFloat ("alphaMultiplier", alphaMultiplier);
|
||||
|
||||
material.SetTexture ("waveNormalA", waveNormalA);
|
||||
material.SetTexture ("waveNormalB", waveNormalB);
|
||||
material.SetFloat ("waveStrength", waveStrength);
|
||||
material.SetFloat ("waveNormalScale", waveScale);
|
||||
material.SetFloat ("waveSpeed", waveSpeed);
|
||||
material.SetFloat ("smoothness", smoothness);
|
||||
material.SetVector ("params", testParams);
|
||||
|
||||
if (randomize) {
|
||||
var random = new PRNG (seed);
|
||||
var randomColA = Color.HSVToRGB (random.Value (), random.Range (0.6f, 0.8f), random.Range (0.65f, 1));
|
||||
var randomColB = ColourHelper.TweakHSV (randomColA,
|
||||
random.SignedValue() * 0.2f,
|
||||
random.SignedValue() * 0.2f,
|
||||
random.Range (-0.5f, -0.4f)
|
||||
);
|
||||
|
||||
material.SetColor ("colA", randomColA);
|
||||
material.SetColor ("colB", randomColB);
|
||||
material.SetColor ("specularCol", Color.white);
|
||||
} else {
|
||||
material.SetColor ("colA", colA);
|
||||
material.SetColor ("colB", colB);
|
||||
material.SetColor ("specularCol", specularCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Plugins/Celestial Body/Scripts/OceanSettings.cs.meta
Normal file
11
Assets/Plugins/Celestial Body/Scripts/OceanSettings.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0467bf655a1214b878d6510a0b2bb09f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Celestial Body/Scripts/SceneCam.meta
Normal file
8
Assets/Plugins/Celestial Body/Scripts/SceneCam.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0fae4e8ac2d2c4b0d8f5537209e54de2
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3ecf2f56406b74719a8e779682350f40
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
[CustomEditor (typeof (SceneCamManager))]
|
||||
public class SceneCamEditor : Editor {
|
||||
|
||||
SceneCamManager manager;
|
||||
|
||||
public override void OnInspectorGUI () {
|
||||
DrawDefaultInspector ();
|
||||
|
||||
var activeSceneView = SceneView.lastActiveSceneView;
|
||||
var allViews = SceneView.sceneViews;
|
||||
|
||||
if (manager.savedViews.Count > 0) {
|
||||
GUILayout.Label ($"Saved views: ({manager.savedViews.Count})");
|
||||
int deleteIndex = -1;
|
||||
|
||||
for (int i = 0; i < manager.savedViews.Count; i++) {
|
||||
GUILayout.BeginVertical ("GroupBox");
|
||||
var savedView = manager.savedViews[i];
|
||||
|
||||
savedView.name = GUILayout.TextField (savedView.name);
|
||||
|
||||
GUILayout.BeginHorizontal ();
|
||||
if (GUILayout.Button ("Set Camera View")) {
|
||||
Undo.RecordObject (manager, "Set Camera View");
|
||||
activeSceneView.pivot = savedView.pivot;
|
||||
activeSceneView.rotation = savedView.rotation;
|
||||
activeSceneView.size = savedView.size;
|
||||
}
|
||||
if (GUILayout.Button ("Replace")) {
|
||||
Undo.RecordObject (manager, "Replace View");
|
||||
savedView.pivot = activeSceneView.pivot;
|
||||
savedView.rotation = activeSceneView.rotation;
|
||||
savedView.size = activeSceneView.size;
|
||||
}
|
||||
if (GUILayout.Button ("Delete")) {
|
||||
Undo.RecordObject (manager, "Delete View");
|
||||
deleteIndex = i;
|
||||
}
|
||||
GUILayout.EndHorizontal ();
|
||||
GUILayout.EndVertical ();
|
||||
}
|
||||
|
||||
if (deleteIndex != -1) {
|
||||
manager.savedViews.RemoveAt (deleteIndex);
|
||||
}
|
||||
|
||||
GUILayout.Space (15);
|
||||
}
|
||||
|
||||
foreach (var v in allViews) {
|
||||
//GUILayout.Label (v.ToString ());
|
||||
}
|
||||
|
||||
if (GUILayout.Button ("Save Current View")) {
|
||||
Undo.RecordObject (manager, "Save View");
|
||||
var newView = new SceneCamManager.SavedView ();
|
||||
newView.name = $"View ({manager.savedViews.Count})";
|
||||
newView.pivot = activeSceneView.pivot;
|
||||
newView.rotation = activeSceneView.rotation;
|
||||
newView.size = activeSceneView.size;
|
||||
manager.savedViews.Add (newView);
|
||||
}
|
||||
}
|
||||
|
||||
void OnEnable () {
|
||||
manager = (SceneCamManager) target;
|
||||
|
||||
if (manager.savedViews == null) {
|
||||
manager.savedViews = new List<SceneCamManager.SavedView> ();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 56eb8740038fb43b9b80a07a6899dc39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class SceneCamManager : MonoBehaviour {
|
||||
|
||||
[HideInInspector]
|
||||
public List<SavedView> savedViews;
|
||||
|
||||
[System.Serializable]
|
||||
public class SavedView {
|
||||
public string name;
|
||||
public float size;
|
||||
public Vector3 pivot;
|
||||
public Quaternion rotation;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4fb6cca85fa094435b4d21a471e78d89
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a9a51a36c3395ef458da81b0bc1d4e6f
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
public class ChanceTest : MonoBehaviour {
|
||||
public Chance chance;
|
||||
public int total;
|
||||
|
||||
void Update () {
|
||||
if (Input.GetKeyDown (KeyCode.Space)) {
|
||||
chance = new Chance (new System.Random ());
|
||||
total++;
|
||||
if (chance.Percent (10)) {
|
||||
Debug.Log ("1");
|
||||
}
|
||||
if (chance.Percent (70)) {
|
||||
Debug.Log ("7");
|
||||
}
|
||||
if (chance.Percent (20)) {
|
||||
Debug.Log ("2");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Chance {
|
||||
float value;
|
||||
|
||||
public Chance (System.Random prng) {
|
||||
value = (float) prng.NextDouble ();
|
||||
}
|
||||
|
||||
public Chance (PRNG prng) {
|
||||
value = prng.Value ();
|
||||
}
|
||||
|
||||
public bool Percent (float percent) {
|
||||
if (value <= 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
float t = percent / 100f;
|
||||
value -= t;
|
||||
return value <= 0;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: dbd90d6e181eb5145ad5cb26288bb585
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
|
||||
public static class ComputeHelper {
|
||||
|
||||
// Subscribe to this event to be notified when buffers created in edit mode should be released
|
||||
// (i.e before script compilation occurs, and when exitting edit mode)
|
||||
public static event System.Action shouldReleaseEditModeBuffers;
|
||||
|
||||
// Convenience method for dispatching a compute shader.
|
||||
// It calculates the number of thread groups based on the number of iterations needed.
|
||||
public static void Run (ComputeShader cs, int numIterationsX, int numIterationsY = 1, int numIterationsZ = 1, int kernelIndex = 0) {
|
||||
Vector3Int threadGroupSizes = GetThreadGroupSizes (cs, kernelIndex);
|
||||
int numGroupsX = Mathf.CeilToInt (numIterationsX / (float) threadGroupSizes.x);
|
||||
int numGroupsY = Mathf.CeilToInt (numIterationsY / (float) threadGroupSizes.y);
|
||||
int numGroupsZ = Mathf.CeilToInt (numIterationsZ / (float) threadGroupSizes.y);
|
||||
cs.Dispatch (kernelIndex, numGroupsX, numGroupsY, numGroupsZ);
|
||||
}
|
||||
|
||||
// Only run compute shaders if this is true
|
||||
// This is only relevant for compute shaders that run outside of playmode
|
||||
public static bool CanRunEditModeCompute {
|
||||
get {
|
||||
return CheckIfCanRunInEditMode ();
|
||||
}
|
||||
}
|
||||
|
||||
// Set all values from settings object on the shader. Note, variable names must be an exact match in the shader.
|
||||
// Settings object can be any class/struct containing vectors/ints/floats/bools
|
||||
public static void SetParams (System.Object settings, ComputeShader shader, string variableNamePrefix = "", string variableNameSuffix = "") {
|
||||
var fields = settings.GetType ().GetFields ();
|
||||
foreach (var field in fields) {
|
||||
var fieldType = field.FieldType;
|
||||
string shaderVariableName = variableNamePrefix + field.Name + variableNameSuffix;
|
||||
|
||||
if (fieldType == typeof (UnityEngine.Vector4) || fieldType == typeof (Vector3) || fieldType == typeof (Vector2)) {
|
||||
shader.SetVector (shaderVariableName, (Vector4) field.GetValue (settings));
|
||||
} else if (fieldType == typeof (int)) {
|
||||
shader.SetInt (shaderVariableName, (int) field.GetValue (settings));
|
||||
} else if (fieldType == typeof (float)) {
|
||||
shader.SetFloat (shaderVariableName, (float) field.GetValue (settings));
|
||||
} else if (fieldType == typeof (bool)) {
|
||||
shader.SetBool (shaderVariableName, (bool) field.GetValue (settings));
|
||||
} else {
|
||||
Debug.Log ($"Type {fieldType} not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateStructuredBuffer<T> (ref ComputeBuffer buffer, int count) {
|
||||
int stride = System.Runtime.InteropServices.Marshal.SizeOf (typeof (T));
|
||||
bool createNewBuffer = buffer == null || !buffer.IsValid () || buffer.count != count || buffer.stride != stride;
|
||||
if (createNewBuffer) {
|
||||
Release (buffer);
|
||||
buffer = new ComputeBuffer (count, stride);
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateStructuredBuffer<T> (ref ComputeBuffer buffer, T[] data) {
|
||||
CreateStructuredBuffer<T> (ref buffer, data.Length);
|
||||
buffer.SetData (data);
|
||||
}
|
||||
|
||||
// Test
|
||||
|
||||
public static ComputeBuffer CreateAndSetBuffer<T> (T[] data, ComputeShader cs, string nameID, int kernelIndex = 0) {
|
||||
ComputeBuffer buffer = null;
|
||||
CreateAndSetBuffer<T> (ref buffer, data, cs, nameID, kernelIndex);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static void CreateAndSetBuffer<T> (ref ComputeBuffer buffer, T[] data, ComputeShader cs, string nameID, int kernelIndex = 0) {
|
||||
int stride = System.Runtime.InteropServices.Marshal.SizeOf (typeof (T));
|
||||
CreateStructuredBuffer<T> (ref buffer, data.Length);
|
||||
buffer.SetData (data);
|
||||
cs.SetBuffer (kernelIndex, nameID, buffer);
|
||||
}
|
||||
|
||||
public static ComputeBuffer CreateAndSetBuffer<T> (int length, ComputeShader cs, string nameID, int kernelIndex = 0) {
|
||||
ComputeBuffer buffer = null;
|
||||
CreateAndSetBuffer<T> (ref buffer, length, cs, nameID, kernelIndex);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
public static void CreateAndSetBuffer<T> (ref ComputeBuffer buffer, int length, ComputeShader cs, string nameID, int kernelIndex = 0) {
|
||||
CreateStructuredBuffer<T> (ref buffer, length);
|
||||
cs.SetBuffer (kernelIndex, nameID, buffer);
|
||||
}
|
||||
|
||||
// Releases supplied buffer/s if not null
|
||||
public static void Release (params ComputeBuffer[] buffers) {
|
||||
for (int i = 0; i < buffers.Length; i++) {
|
||||
if (buffers[i] != null) {
|
||||
buffers[i].Release ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector3Int GetThreadGroupSizes (ComputeShader compute, int kernelIndex = 0) {
|
||||
uint x, y, z;
|
||||
compute.GetKernelThreadGroupSizes (kernelIndex, out x, out y, out z);
|
||||
return new Vector3Int ((int) x, (int) y, (int) z);
|
||||
}
|
||||
|
||||
public static void CreateRenderTexture (ref RenderTexture texture, int size, FilterMode filterMode = FilterMode.Bilinear, GraphicsFormat format = GraphicsFormat.R16G16B16A16_SFloat) {
|
||||
CreateRenderTexture (ref texture, size, size, filterMode, format);
|
||||
}
|
||||
|
||||
public static void CreateRenderTexture (ref RenderTexture texture, int width, int height, FilterMode filterMode = FilterMode.Bilinear, GraphicsFormat format = GraphicsFormat.R16G16B16A16_SFloat) {
|
||||
if (texture == null || !texture.IsCreated () || texture.width != width || texture.height != height || texture.graphicsFormat != format) {
|
||||
if (texture != null) {
|
||||
texture.Release ();
|
||||
}
|
||||
texture = new RenderTexture (width, height, 0);
|
||||
texture.graphicsFormat = format;
|
||||
texture.enableRandomWrite = true;
|
||||
|
||||
texture.autoGenerateMips = false;
|
||||
texture.Create ();
|
||||
}
|
||||
texture.wrapMode = TextureWrapMode.Clamp;
|
||||
texture.filterMode = filterMode;
|
||||
}
|
||||
|
||||
// https://cmwdexint.com/2017/12/04/computeshader-setfloats/
|
||||
public static float[] PackFloats (params float[] values) {
|
||||
float[] packed = new float[values.Length * 4];
|
||||
for (int i = 0; i < values.Length; i++) {
|
||||
packed[i * 4] = values[i];
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
// Editor helpers:
|
||||
|
||||
#if UNITY_EDITOR
|
||||
static UnityEditor.PlayModeStateChange playModeState;
|
||||
|
||||
static ComputeHelper () {
|
||||
// Monitor play mode state
|
||||
UnityEditor.EditorApplication.playModeStateChanged -= MonitorPlayModeState;
|
||||
UnityEditor.EditorApplication.playModeStateChanged += MonitorPlayModeState;
|
||||
// Monitor script compilation
|
||||
UnityEditor.Compilation.CompilationPipeline.compilationStarted -= OnCompilationStarted;
|
||||
UnityEditor.Compilation.CompilationPipeline.compilationStarted += OnCompilationStarted;
|
||||
}
|
||||
|
||||
static void MonitorPlayModeState (UnityEditor.PlayModeStateChange state) {
|
||||
playModeState = state;
|
||||
if (state == UnityEditor.PlayModeStateChange.ExitingEditMode) {
|
||||
if (shouldReleaseEditModeBuffers != null) {
|
||||
shouldReleaseEditModeBuffers (); //
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void OnCompilationStarted (System.Object obj) {
|
||||
if (shouldReleaseEditModeBuffers != null) {
|
||||
shouldReleaseEditModeBuffers ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static bool CheckIfCanRunInEditMode () {
|
||||
bool isCompilingOrExitingEditMode = false;
|
||||
#if UNITY_EDITOR
|
||||
isCompilingOrExitingEditMode |= UnityEditor.EditorApplication.isCompiling;
|
||||
isCompilingOrExitingEditMode |= playModeState == UnityEditor.PlayModeStateChange.ExitingEditMode;
|
||||
#endif
|
||||
bool canRun = !isCompilingOrExitingEditMode;
|
||||
return canRun;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 711fda09f27fe41dfa8af54cab7ed80c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,116 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class MathUtility {
|
||||
public static bool RaySphere (Vector3 centre, float radius, Vector3 rayOrigin, Vector3 rayDir, out Vector3 intersectionPoint) {
|
||||
// See: http://viclw17.github.io/2018/07/16/raytracing-ray-sphere-intersection/
|
||||
Vector3 offset = rayOrigin - centre;
|
||||
float a = Vector3.Dot (rayDir, rayDir); // sqr ray length (in case of non-normalized rayDir)
|
||||
float b = 2 * Vector3.Dot (offset, rayDir);
|
||||
float c = Vector3.Dot (offset, offset) - radius * radius;
|
||||
float discriminant = b * b - 4 * a * c;
|
||||
|
||||
// No intersections: discriminant < 0
|
||||
// 1 intersection: discriminant == 0
|
||||
// 2 intersections: discriminant > 0
|
||||
if (discriminant >= 0) {
|
||||
float t = (-b - Mathf.Sqrt (discriminant)) / (2 * a);
|
||||
//float t2 = (-b + Mathf.Sqrt (discriminant)) / (2 * a); // The further away intersection point
|
||||
|
||||
// If t is negative, the intersection was in negative ray direction so ignore it
|
||||
if (t >= 0) {
|
||||
intersectionPoint = rayOrigin + rayDir * t;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
intersectionPoint = Vector3.zero;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool LineSegmentsIntersect (Vector2 a1, Vector2 a2, Vector2 b1, Vector2 b2) {
|
||||
float d = (b2.x - b1.x) * (a1.y - a2.y) - (a1.x - a2.x) * (b2.y - b1.y);
|
||||
if (d == 0)
|
||||
return false;
|
||||
float t = ((b1.y - b2.y) * (a1.x - b1.x) + (b2.x - b1.x) * (a1.y - b1.y)) / d;
|
||||
float u = ((a1.y - a2.y) * (a1.x - b1.x) + (a2.x - a1.x) * (a1.y - b1.y)) / d;
|
||||
|
||||
return t >= 0 && t <= 1 && u >= 0 && u <= 1;
|
||||
}
|
||||
|
||||
public static bool LinesIntersect (Vector2 a1, Vector2 a2, Vector2 a3, Vector2 a4) {
|
||||
return (a1.x - a2.x) * (a3.y - a4.y) - (a1.y - a2.y) * (a3.x - a4.x) != 0;
|
||||
}
|
||||
|
||||
public static Vector2 PointOfLineLineIntersection (Vector2 a1, Vector2 a2, Vector2 a3, Vector2 a4) {
|
||||
float d = (a1.x - a2.x) * (a3.y - a4.y) - (a1.y - a2.y) * (a3.x - a4.x);
|
||||
if (d == 0) {
|
||||
Debug.LogError ("Lines are parallel, please check that this is not the case before calling line intersection method");
|
||||
return Vector2.zero;
|
||||
} else {
|
||||
float n = (a1.x - a3.x) * (a3.y - a4.y) - (a1.y - a3.y) * (a3.x - a4.x);
|
||||
float t = n / d;
|
||||
return a1 + (a2 - a1) * t;
|
||||
}
|
||||
}
|
||||
|
||||
public static Vector2 ClosestPointOnLineSegment (Vector2 p, Vector2 a, Vector2 b) {
|
||||
Vector2 aB = b - a;
|
||||
Vector2 aP = p - a;
|
||||
float sqrLenAB = aB.sqrMagnitude;
|
||||
|
||||
if (sqrLenAB == 0)
|
||||
return a;
|
||||
|
||||
float t = Mathf.Clamp01 (Vector2.Dot (aP, aB) / sqrLenAB);
|
||||
return a + aB * t;
|
||||
}
|
||||
|
||||
public static Vector3 ClosestPointOnLineSegment (Vector3 p, Vector3 a, Vector3 b) {
|
||||
Vector3 aB = b - a;
|
||||
Vector3 aP = p - a;
|
||||
float sqrLenAB = aB.sqrMagnitude;
|
||||
|
||||
if (sqrLenAB == 0)
|
||||
return a;
|
||||
|
||||
float t = Mathf.Clamp01 (Vector3.Dot (aP, aB) / sqrLenAB);
|
||||
return a + aB * t;
|
||||
}
|
||||
|
||||
public static int SideOfLine (Vector2 a, Vector2 b, Vector2 c) {
|
||||
return (int) Mathf.Sign ((c.x - a.x) * (-b.y + a.y) + (c.y - a.y) * (b.x - a.x));
|
||||
}
|
||||
|
||||
/// returns the smallest angle between ABC. Never greater than 180
|
||||
public static float MinAngle (Vector3 a, Vector3 b, Vector3 c) {
|
||||
return Vector3.Angle ((a - b), (c - b));
|
||||
}
|
||||
|
||||
public static bool PointInTriangle (Vector2 a, Vector2 b, Vector2 c, Vector2 p) {
|
||||
float area = 0.5f * (-b.y * c.x + a.y * (-b.x + c.x) + a.x * (b.y - c.y) + b.x * c.y);
|
||||
float s = 1 / (2 * area) * (a.y * c.x - a.x * c.y + (c.y - a.y) * p.x + (a.x - c.x) * p.y);
|
||||
float t = 1 / (2 * area) * (a.x * b.y - a.y * b.x + (a.y - b.y) * p.x + (b.x - a.x) * p.y);
|
||||
return s >= 0 && t >= 0 && (s + t) <= 1;
|
||||
}
|
||||
|
||||
public static bool PointsAreClockwise (Vector2[] points) {
|
||||
float signedArea = 0;
|
||||
for (int i = 0; i < points.Length; i++) {
|
||||
int nextIndex = (i + 1) % points.Length;
|
||||
signedArea += (points[nextIndex].x - points[i].x) * (points[nextIndex].y + points[i].y);
|
||||
}
|
||||
|
||||
return signedArea >= 0;
|
||||
}
|
||||
|
||||
public static Vector2 V3ToXZ (Vector3 v3) {
|
||||
return new Vector2 (v3.x, v3.z);
|
||||
}
|
||||
|
||||
public static Vector3 V2ToXYZ (Vector2 v2, float yValue) {
|
||||
return new Vector3 (v2.x, yValue, v2.y);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 69df6ef4fd0704bd9835a45dbb941451
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
231
Assets/Plugins/Celestial Body/Scripts/Script Utilities/PRNG.cs
Normal file
231
Assets/Plugins/Celestial Body/Scripts/Script Utilities/PRNG.cs
Normal file
|
|
@ -0,0 +1,231 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PRNG {
|
||||
|
||||
public enum Weight { None, Lower, Upper, Centre, Ends }
|
||||
System.Random prng;
|
||||
int seed;
|
||||
|
||||
public int Seed {
|
||||
get {
|
||||
return seed;
|
||||
}
|
||||
}
|
||||
|
||||
public PRNG (int seed) {
|
||||
this.seed = seed;
|
||||
prng = new System.Random (this.seed);
|
||||
}
|
||||
|
||||
public PRNG (string seed) {
|
||||
this.seed = seed.GetHashCode ();
|
||||
prng = new System.Random (this.seed);
|
||||
}
|
||||
|
||||
public PRNG () {
|
||||
prng = new System.Random ();
|
||||
}
|
||||
|
||||
/// Returns a random integer value [min, max)
|
||||
public int Range (int min, int max) {
|
||||
return prng.Next (min, max);
|
||||
}
|
||||
|
||||
/// Returns a random float value [min, max)
|
||||
public float Range (float min, float max) {
|
||||
return Mathf.Lerp (min, max, (float) prng.NextDouble ());
|
||||
}
|
||||
|
||||
// Returns a vector4 where each component is a random number in range [min, max)
|
||||
public Vector4 RangeVector4 (float minInclusive, float maxExclusive) {
|
||||
Vector4 vector = Vector4.zero;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
vector[i] = Range (minInclusive, maxExclusive);
|
||||
}
|
||||
return vector;
|
||||
}
|
||||
|
||||
/// Random value [0, 1]
|
||||
public float Value () {
|
||||
// According to stackoverflow this should technically allow the random value to equal 1
|
||||
const double maxExclusive = 1.0000000004656612875245796924106;
|
||||
return (float) (prng.NextDouble () * maxExclusive);
|
||||
}
|
||||
|
||||
/// Random value [0, 1]
|
||||
/// Output is increasingly biased toward 1 as biasStrength goes from 0 to 1
|
||||
public float ValueBiasUpper (float biasStrength) {
|
||||
return 1 - ValueBiasLower (biasStrength);
|
||||
}
|
||||
|
||||
/// Random value [0, 1]
|
||||
/// Output is increasingly biased toward 0 as biasStrength goes from 0 to 1
|
||||
public float ValueBiasLower (float biasStrength) {
|
||||
float t = Value ();
|
||||
|
||||
// Avoid possible division by zero
|
||||
if (biasStrength == 1) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Remap strength for nicer input -> output relationship
|
||||
float k = Mathf.Clamp01 (1 - biasStrength);
|
||||
k = k * k * k - 1;
|
||||
|
||||
// Thanks to www.shadertoy.com/view/Xd2yRd
|
||||
return Mathf.Clamp01 ((t + t * k) / (t * k + 1));
|
||||
}
|
||||
|
||||
/// Random value [0, 1]
|
||||
/// Output is increasingly biased toward the extremes (0 or 1) as biasStrength goes from 0 to 1
|
||||
public float ValueBiasExtremes (float biasStrength) {
|
||||
float t = ValueBiasLower (biasStrength);
|
||||
return (Value () < 0.5f) ? t : 1 - t;
|
||||
}
|
||||
|
||||
/// Random value [0, 1]
|
||||
/// Output is increasingly biased toward 0.5 as biasStrength goes from 0 to 1
|
||||
public float ValueBiasCentre (float biasStrength) {
|
||||
float t = ValueBiasLower (biasStrength);
|
||||
return 0.5f + t * 0.5f * Sign ();
|
||||
}
|
||||
|
||||
// ---- Signed versions [-1, 1] ---
|
||||
|
||||
/// Random value [-1, 1]
|
||||
public float SignedValue () {
|
||||
return Value () * 2 - 1;
|
||||
}
|
||||
|
||||
/// Random value [-1, 1]
|
||||
/// Output is increasingly biased toward the extremes (-1 or 1) as biasStrength goes from 0 to 1
|
||||
public float SignedValueBiasExtremes (float biasStrength) {
|
||||
return ValueBiasExtremes (biasStrength) * 2 - 1;
|
||||
}
|
||||
|
||||
/// Random value [-1, 1]
|
||||
/// Output is increasingly biased toward 0 as biasStrength goes from 0 to 1
|
||||
public float SignedValueBiasCentre (float biasStrength) {
|
||||
return ValueBiasCentre (biasStrength) * 2 - 1;
|
||||
}
|
||||
|
||||
// Returns a weighted value in range [min, max)
|
||||
public float WeightedRange (float min, float max, Weight weight, int weightStrength = 4) {
|
||||
float value01 = WeightedValue (weight, weightStrength);
|
||||
return Mathf.Lerp (min, max, value01);
|
||||
}
|
||||
|
||||
// Returns a weighted value in range [-1, 1)
|
||||
public float WeightedSignedValue (Weight weight, int weightStrength = 4) {
|
||||
return WeightedValue (weight, weightStrength) * 2 - 1;
|
||||
}
|
||||
|
||||
// Returns a weighted value in range [0, 1)
|
||||
public float WeightedValue (Weight weight, int weightStrength = 4) {
|
||||
|
||||
if (weight == Weight.None) {
|
||||
return Value ();
|
||||
}
|
||||
|
||||
float smallestValue = Value ();
|
||||
for (int i = 0; i < weightStrength; i++) {
|
||||
smallestValue = Mathf.Min (smallestValue, Value ());
|
||||
}
|
||||
|
||||
switch (weight) {
|
||||
case Weight.Lower: // Bias towards smaller values
|
||||
return smallestValue;
|
||||
case Weight.Upper: // Bias towards larger values
|
||||
return 1 - smallestValue;
|
||||
case Weight.Centre: // Bias towards middle values
|
||||
return 0.5f + smallestValue * 0.5f * Sign ();
|
||||
case Weight.Ends: // Bias towards smaller and larger values
|
||||
return (Value () < 0.5f) ? smallestValue : 1 - smallestValue;
|
||||
default:
|
||||
Debug.LogError ("Missing weight implementation");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the smallest of n random numbers between 0 and 1
|
||||
public float SmallestRandom01 (int n) {
|
||||
float smallest = 1;
|
||||
for (int i = 0; i < n; i++) {
|
||||
smallest = Mathf.Min (smallest, Value ());
|
||||
}
|
||||
return smallest;
|
||||
}
|
||||
|
||||
// Returns the largest of n random numbers between 0 and 1
|
||||
public float LargestRandom01 (int n) {
|
||||
float largest = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
largest = Mathf.Max (largest, Value ());
|
||||
}
|
||||
return largest;
|
||||
}
|
||||
|
||||
// Returns the value closest to 0.5 out of n random numbers between 0 and 1
|
||||
public float CentredRandom01 (int n) {
|
||||
float mostCentredValue = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
float value = Value ();
|
||||
if (Mathf.Abs (value - 0.5f) < Mathf.Abs (mostCentredValue - 0.5f)) {
|
||||
mostCentredValue = value;
|
||||
}
|
||||
}
|
||||
return mostCentredValue;
|
||||
}
|
||||
|
||||
public int Sign () {
|
||||
return (prng.NextDouble () > 0.5) ? 1 : -1;
|
||||
}
|
||||
|
||||
public int NextInt () {
|
||||
return prng.Next ();
|
||||
}
|
||||
|
||||
public Vector3 JiggleVector3 (float weightX, float weightY, float weightZ) {
|
||||
return new Vector3 (SignedValue () * weightX, SignedValue () * weightY, SignedValue () * weightZ);
|
||||
}
|
||||
|
||||
// Colours
|
||||
public Color ColorHSV (float saturationMin, float saturationMax, float valueMin, float valueMax) {
|
||||
float hue = Value ();
|
||||
float saturation = Range (saturationMin, saturationMax);
|
||||
float value = Range (valueMin, valueMax);
|
||||
return Color.HSVToRGB (hue, saturation, value);
|
||||
}
|
||||
|
||||
public Color ColorGreyscale (float valueMin, float valueMax) {
|
||||
float value = Range (valueMin, valueMax);
|
||||
return new Color (value, value, value);
|
||||
}
|
||||
// Elements
|
||||
public T RandomElement<T> (T[] array) {
|
||||
return array[Range (0, array.Length)];
|
||||
}
|
||||
|
||||
public void Shuffle<T> (T[] array) {
|
||||
int n = array.Length;
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
int j = prng.Next (i, n);
|
||||
T temp = array[j];
|
||||
array[j] = array[i];
|
||||
array[i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
public void Shuffle<T> (List<T> list) {
|
||||
int n = list.Count;
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
int j = prng.Next (i, n);
|
||||
T temp = list[j];
|
||||
list[j] = list[i];
|
||||
list[i] = temp;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ae686c76044de4891a2c6a36bf7434de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class ShaderHelper {
|
||||
// Set all values from settings object on the shader. Note, variable names must be an exact match in the shader.
|
||||
// Settings object can be any class/struct containing vectors/ints/floats
|
||||
public static void SetParams (System.Object settings, Material material, string variableNamePrefix = "") {
|
||||
var fields = settings.GetType ().GetFields ();
|
||||
foreach (var field in fields) {
|
||||
var fieldType = field.FieldType;
|
||||
string shaderVariableName = variableNamePrefix + field.Name;
|
||||
|
||||
if (fieldType == typeof (UnityEngine.Vector4) || fieldType == typeof (Vector3) || fieldType == typeof (Vector2)) {
|
||||
material.SetVector (shaderVariableName, (Vector4) field.GetValue (settings));
|
||||
} else if (fieldType == typeof (int)) {
|
||||
material.SetInt (shaderVariableName, (int) field.GetValue (settings));
|
||||
} else if (fieldType == typeof (float)) {
|
||||
material.SetFloat (shaderVariableName, (float) field.GetValue (settings));
|
||||
} else {
|
||||
Debug.Log ($"Type {fieldType} not implemented");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 7782a7a4791c8426aa102052d42c2541
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public static class TextureHelper {
|
||||
|
||||
public static void TextureFromGradient (Gradient gradient, int width, ref Texture2D texture) {
|
||||
if (texture == null || texture.width != width || texture.height != 1) {
|
||||
texture = new Texture2D (width, 1);
|
||||
texture.filterMode = FilterMode.Bilinear;
|
||||
texture.wrapMode = TextureWrapMode.Clamp;
|
||||
}
|
||||
|
||||
Color[] colours = new Color[width];
|
||||
for (int i = 0; i < width; i++) {
|
||||
float t = i / (width - 1f);
|
||||
colours[i] = gradient.Evaluate (t);
|
||||
}
|
||||
texture.SetPixels (colours);
|
||||
texture.Apply ();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ca4552dbbcdf04006b442ee84e5b2703
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Plugins/Celestial Body/Scripts/Shaders.meta
Normal file
8
Assets/Plugins/Celestial Body/Scripts/Shaders.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 267a921ab0972416c9c8bd6c2d121654
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1e03537b7c5244b0882d8e7efc2c0abe
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 375b93914a7154241b14ccf7df35e859
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
#pragma kernel CSMain
|
||||
#include "../../Includes/Math.cginc"
|
||||
|
||||
RWTexture2D<float4> Result;
|
||||
int textureSize;
|
||||
int numOutScatteringSteps;
|
||||
float atmosphereRadius;
|
||||
float avgDensityHeight01;
|
||||
float densityFalloff;
|
||||
float4 params;
|
||||
|
||||
float densityAtPoint(float2 densitySamplePoint) {
|
||||
float planetRadius = 1;
|
||||
float2 planetCentre = 0;
|
||||
|
||||
float heightAboveSurface = length(densitySamplePoint - planetCentre) - planetRadius;
|
||||
float height01 = heightAboveSurface / (atmosphereRadius - planetRadius);
|
||||
float localDensity = exp(-height01 * densityFalloff) * (1 - height01);
|
||||
return localDensity;
|
||||
}
|
||||
|
||||
float opticalDepth(float2 rayOrigin, float2 rayDir, float rayLength) {
|
||||
int numOpticalDepthPoints = numOutScatteringSteps;
|
||||
|
||||
float2 densitySamplePoint = rayOrigin;
|
||||
float stepSize = rayLength / (numOpticalDepthPoints - 1);
|
||||
float opticalDepth = 0;
|
||||
|
||||
for (int i = 0; i < numOpticalDepthPoints; i ++) {
|
||||
float localDensity = densityAtPoint(densitySamplePoint);
|
||||
opticalDepth += localDensity * stepSize;
|
||||
densitySamplePoint += rayDir * stepSize;
|
||||
}
|
||||
return opticalDepth;
|
||||
}
|
||||
|
||||
|
||||
float calculateOutScattering(float2 inPoint, float2 outPoint) {
|
||||
float planetRadius = 1;
|
||||
float skinWidth = planetRadius / 1000.0;
|
||||
|
||||
|
||||
float lightTravelDst = length(outPoint - inPoint);
|
||||
float2 outScatterPoint = inPoint;
|
||||
float2 rayDir = (outPoint - inPoint) / lightTravelDst;
|
||||
float stepSize = (lightTravelDst - skinWidth) / (numOutScatteringSteps);
|
||||
|
||||
float outScatterAmount = 0;
|
||||
|
||||
for (int i = 0; i < numOutScatteringSteps; i ++) {
|
||||
outScatterPoint += rayDir * stepSize;
|
||||
|
||||
// height at planet surface = 0, at furthest extent of atmosphere = 1
|
||||
float height = length(outScatterPoint - 0) - planetRadius;//
|
||||
|
||||
|
||||
|
||||
float height01 = saturate(height / (atmosphereRadius - planetRadius));
|
||||
outScatterAmount += exp(-height01 * densityFalloff) * stepSize;
|
||||
|
||||
}
|
||||
|
||||
return outScatterAmount;
|
||||
}
|
||||
|
||||
[numthreads(8,8,1)]
|
||||
void CSMain (uint2 id : SV_DispatchThreadID)
|
||||
{
|
||||
const float planetRadius = 1;
|
||||
|
||||
float2 uv = id / (float)textureSize;
|
||||
float height01 = uv.y;
|
||||
float angle = uv.x * PI;
|
||||
//angle = (1-cos(angle))/2;
|
||||
float2 dir = float2(sin(angle), cos(angle));
|
||||
float y = -2 * uv.x + 1;
|
||||
float x = sin(acos(y));
|
||||
dir = float2(x,y);
|
||||
|
||||
float2 inPoint = float2(0, lerp(planetRadius, atmosphereRadius, height01));
|
||||
float dstThroughAtmosphere = raySphere(0, atmosphereRadius, float3(inPoint,0), float3(dir,0)).y;
|
||||
float2 outPoint = inPoint + dir * raySphere(0, atmosphereRadius, float3(inPoint,0), float3(dir,0)).y;
|
||||
//float outScattering = calculateOutScattering(inPoint, outPoint);
|
||||
float outScattering = opticalDepth(inPoint + dir * 0.0001, dir, dstThroughAtmosphere-0.0002);
|
||||
|
||||
Result[id.xy] = outScattering;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 463adb4526f5a48bdb8c71df4c6dd88d
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 44fb59fda0e1d49dda281e0401d4dc76
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
#include "../../Includes/Craters.cginc"
|
||||
//
|
||||
|
||||
StructuredBuffer<float3> vertices;
|
||||
RWStructuredBuffer<float> heights;
|
||||
uint numVertices;
|
||||
|
||||
|
||||
// Continent settings:
|
||||
float oceanDepthMultiplier;
|
||||
float oceanFloorDepth;
|
||||
float oceanFloorSmoothing;
|
||||
float mountainBlend;
|
||||
|
||||
// Old:
|
||||
float4 noiseParams_continents[3];
|
||||
float4 noiseParams_mask[3];
|
||||
float4 noiseParams_mountains[3];
|
||||
float4 noiseParams_warp[3];
|
||||
float4 params;
|
||||
|
||||
|
||||
[numthreads(512,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numVertices) {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 pos = vertices[id];
|
||||
float3 warpNoise = float3(simpleNoise(pos, noiseParams_warp),simpleNoise(pos-100, noiseParams_warp),simpleNoise(pos+100, noiseParams_warp)) * 0.01;
|
||||
float3 warpedPos = pos + warpNoise;
|
||||
float craterDepth = calculateCraterDepth(pos);
|
||||
|
||||
float continentShape = simpleNoise(pos + warpNoise * params.x, noiseParams_continents);
|
||||
|
||||
continentShape = smoothMax(continentShape, -oceanFloorDepth, oceanFloorSmoothing);
|
||||
|
||||
|
||||
if (continentShape < 0) {
|
||||
continentShape *= 1 + oceanDepthMultiplier;
|
||||
}
|
||||
|
||||
float ridgeNoise = smoothedRidgidNoise(pos + warpNoise * params.y, noiseParams_mountains);
|
||||
|
||||
|
||||
float mask = Blend(0, mountainBlend, simpleNoise(pos + warpNoise * params.z, noiseParams_mask));
|
||||
// Calculate final height
|
||||
float finalHeight = 1 + continentShape * 0.01 + ridgeNoise * 0.01 * mask + craterDepth;
|
||||
//finalHeight = 1 + Blend(0, params.x, simpleNoise(pos, noiseParams_mask)) * 0.05;
|
||||
|
||||
// Set terrain data
|
||||
heights[id] = finalHeight;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b33d87d0482194cf2a21c78c2cc775f8
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
#include "../../Includes/Math.cginc"
|
||||
//
|
||||
|
||||
StructuredBuffer<float3> vertices;
|
||||
RWStructuredBuffer<float> heights;
|
||||
uint numVertices;
|
||||
|
||||
|
||||
// Continent settings:
|
||||
float oceanDepthMultiplier;
|
||||
float oceanFloorDepth;
|
||||
float oceanFloorSmoothing;
|
||||
float mountainBlend;
|
||||
|
||||
float4 noiseParams_continents[3];
|
||||
float4 noiseParams_mask[3];
|
||||
float4 noiseParams_mountains[3];
|
||||
float4 params;
|
||||
|
||||
[numthreads(512,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numVertices) {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 pos = vertices[id];
|
||||
|
||||
float continentShape = simpleNoise(pos, noiseParams_continents);
|
||||
|
||||
continentShape = smoothMax(continentShape, -oceanFloorDepth, oceanFloorSmoothing);
|
||||
|
||||
|
||||
if (continentShape < 0) {
|
||||
continentShape *= 1 + oceanDepthMultiplier;
|
||||
}
|
||||
|
||||
float ridgeNoise = smoothedRidgidNoise(pos, noiseParams_mountains);
|
||||
|
||||
|
||||
float mask = Blend(0, mountainBlend, simpleNoise(pos, noiseParams_mask));
|
||||
// Calculate final height
|
||||
float finalHeight = 1 + continentShape * 0.01 + ridgeNoise * 0.01 * mask;
|
||||
//finalHeight = 1 + Blend(0, params.x, simpleNoise(pos, noiseParams_mask)) * 0.05;
|
||||
|
||||
// Set terrain data
|
||||
heights[id] = finalHeight;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d6df9e6cc324e48a892dd6a9cf741d65
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
#include "../../Includes/Craters.cginc"
|
||||
//
|
||||
|
||||
StructuredBuffer<float3> vertices;
|
||||
RWStructuredBuffer<float> heights;
|
||||
uint numVertices;
|
||||
|
||||
// Continent settings:
|
||||
float shoreSteepness;
|
||||
float continentFlatness;
|
||||
float continentLevel;
|
||||
float2 maskMinMax;
|
||||
float mountainBlend;
|
||||
float4 noiseParams_continents[3];//
|
||||
float4 noiseParams_mask[3];
|
||||
|
||||
// Ridge noise
|
||||
float4 noiseParams_mountains[3];
|
||||
float4 params;
|
||||
float mountainSmoothing;
|
||||
|
||||
|
||||
float calculateMountainNoise(float3 pos) {
|
||||
float3 sphereNormal = pos;
|
||||
float3 axisA = cross(sphereNormal, float3(0,1,0));
|
||||
float3 axisB = cross(sphereNormal, axisA);
|
||||
|
||||
// Sample the noise several times at small offsets from the centre and average the result
|
||||
// This reduces some of the harsh jaggedness that can occur
|
||||
float offsetDst = mountainSmoothing * 0.01;
|
||||
float sample0 = ridgidNoise(pos, noiseParams_mountains);
|
||||
float sample1 = ridgidNoise(pos - axisA * offsetDst, noiseParams_mountains);
|
||||
float sample2 = ridgidNoise(pos + axisA * offsetDst, noiseParams_mountains);
|
||||
float sample3 = ridgidNoise(pos - axisB * offsetDst, noiseParams_mountains);
|
||||
float sample4 = ridgidNoise(pos + axisB * offsetDst, noiseParams_mountains);
|
||||
return (sample0 + sample1 + sample2 + sample3 + sample4) / 5;
|
||||
}
|
||||
|
||||
[numthreads(512,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numVertices) {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 pos = vertices[id];
|
||||
|
||||
float continentShape = simpleNoise(pos, noiseParams_continents);
|
||||
continentShape = continentShape * (1 + continentShape / continentLevel * shoreSteepness);
|
||||
if (continentShape < 0) {
|
||||
continentShape *= 1+mountainSmoothing * abs(continentShape);
|
||||
}
|
||||
|
||||
float craterDepth = calculateCraterDepth(pos);
|
||||
|
||||
//float heightAboveShore = max(0, continentShape);
|
||||
//float k = (1 - saturate(heightAboveShore / continentLevel)) * shoreSteepness;
|
||||
// continentShape = smoothMin(continentShape, 0, shoreSteepness);
|
||||
|
||||
|
||||
// Calculate final height
|
||||
float finalHeight = 1 + continentShape * 0.01 + craterDepth;
|
||||
|
||||
// Set terrain data
|
||||
heights[id] = finalHeight;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e32322f519a614092915aa9cbc4cb7c2
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
#pragma kernel CSMain
|
||||
#include "../../Includes/Craters.cginc"
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
|
||||
//
|
||||
StructuredBuffer<float3> vertices;
|
||||
RWStructuredBuffer<float> heights;
|
||||
uint numVertices;
|
||||
|
||||
float4 testParams;
|
||||
|
||||
// Noise settings
|
||||
float4 noiseParams_shape[3];
|
||||
float4 noiseParams_ridge[3];
|
||||
float4 noiseParams_ridge2[3];
|
||||
|
||||
[numthreads(512, 1, 1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numVertices) { return; }
|
||||
static const float elevationMultiplier = 0.01;
|
||||
|
||||
float3 pos = vertices[id];
|
||||
|
||||
// Craters
|
||||
float craterDepth = calculateCraterDepth(pos);
|
||||
// Low-frequency noise to add some slight deformation to the base sphere shape of the moon
|
||||
float shapeNoise = simpleNoise(pos, noiseParams_shape);
|
||||
|
||||
// Ridge noise
|
||||
float ridgeNoise = smoothedRidgidNoise(pos, noiseParams_ridge);
|
||||
float ridge2 = smoothedRidgidNoise(pos, noiseParams_ridge2);
|
||||
|
||||
float noiseSum = (shapeNoise + ridgeNoise + ridge2) * elevationMultiplier;
|
||||
float finalHeight = 1 + craterDepth + noiseSum;
|
||||
heights[id] = finalHeight;
|
||||
|
||||
// Debug ridge mask
|
||||
//terrainHeights[id] = 1 + ridgeMask * .1;
|
||||
//terrainHeights[id] = 1 + ridgeNoise * elevationMultiplier;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1c8bff6c5dfd7461f8403bd2cef35625
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
#include "../../Includes/Craters.cginc"
|
||||
//
|
||||
|
||||
StructuredBuffer<float3> vertices;
|
||||
RWStructuredBuffer<float> heights;
|
||||
uint numVertices;
|
||||
|
||||
|
||||
float plateauHeight;
|
||||
float plateauSmoothing;
|
||||
|
||||
float4 noiseParams_continents[3];
|
||||
float4 noiseParams_mountains[3];
|
||||
float4 noiseParams_mountains2[3];
|
||||
float4 noiseParams_warp[3];
|
||||
float4 params;
|
||||
|
||||
|
||||
[numthreads(512,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numVertices) {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 pos = vertices[id];
|
||||
float3 warpNoise = float3(simpleNoise(pos, noiseParams_warp),simpleNoise(pos-100, noiseParams_warp),simpleNoise(pos+100, noiseParams_warp)) * 0.01;
|
||||
float craterDepth = calculateCraterDepth(pos);
|
||||
float continentShape = simpleNoise(pos + warpNoise, noiseParams_continents);
|
||||
continentShape = smoothMin(continentShape, plateauHeight, plateauSmoothing);
|
||||
|
||||
float ridgeNoise = smoothedRidgidNoise(pos, noiseParams_mountains);
|
||||
float ridgeNoise2 = smoothedRidgidNoise(pos, noiseParams_mountains2); //
|
||||
|
||||
// Calculate final height
|
||||
float finalHeight = 1 + (continentShape + ridgeNoise + ridgeNoise2) * 0.01 + craterDepth;
|
||||
//finalHeight = 1 + Blend(0, params.x, simpleNoise(pos, noiseParams_mask)) * 0.05;
|
||||
|
||||
// Set terrain data
|
||||
heights[id] = finalHeight;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 13008f929df404f2c9c4d64443449aed
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: caff2a8a0d5b640a9a75ebb6a10c3fa8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
Shader "Hidden/OceanMask"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Cull Off ZWrite Off ZTest Always
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "../../Includes/Math.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertex : SV_POSITION;
|
||||
float3 viewVector : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
// Camera space matches OpenGL convention where cam forward is -z. In unity forward is positive z.
|
||||
// (https://docs.unity3d.com/ScriptReference/Camera-cameraToWorldMatrix.html)
|
||||
float3 viewVector = mul(unity_CameraInvProjection, float4(v.uv.xy * 2 - 1, 0, -1));
|
||||
o.viewVector = mul(unity_CameraToWorld, float4(viewVector,0));
|
||||
return o;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
static const int maxNumSpheres = 10;
|
||||
float4 spheres[maxNumSpheres];
|
||||
int numSpheres;
|
||||
|
||||
fixed4 frag (v2f i) : SV_Target
|
||||
{
|
||||
float3 rayOrigin = _WorldSpaceCameraPos;
|
||||
float3 rayDir = normalize(i.viewVector);
|
||||
|
||||
//return float4(rayDir,1);
|
||||
|
||||
float nearest = 0;
|
||||
for (int sphereIndex = 0; sphereIndex < numSpheres; sphereIndex ++) {
|
||||
float2 hitInfo = raySphere(spheres[sphereIndex].xyz, spheres[sphereIndex].w, rayOrigin, rayDir);
|
||||
if (hitInfo.y > 0) {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 5c954f4bd730d46199b888d542aded55
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
#pragma kernel CSMain
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
|
||||
RWStructuredBuffer<float3> points;
|
||||
uint numPoints;
|
||||
float maxStrength;
|
||||
|
||||
float3 perturb(float3 pos) {
|
||||
float scale = 50;
|
||||
float fx = simpleNoise(pos * 1, 2, scale, .5, 2, 1);
|
||||
float fy = simpleNoise(pos * 2, 2, scale, .5, 2, 1);
|
||||
float fz = simpleNoise(pos * 3, 2, scale, .5, 2, 1);
|
||||
float3 offset = float3(fx, fy, fz);
|
||||
offset = smoothstep(-1,1,offset) * 2 -1;
|
||||
return offset;
|
||||
}
|
||||
|
||||
[numthreads(512,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numPoints) {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 pos = points[id];
|
||||
float height = length(pos);
|
||||
|
||||
float3 offset = perturb(pos);
|
||||
float3 newPos = pos + offset * maxStrength;
|
||||
|
||||
newPos = normalize(newPos) * height;
|
||||
points[id] = newPos;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: c95c667630d66481daf208e2a7a4d95d
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#pragma kernel CSMain
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
|
||||
RWStructuredBuffer<float3> points;
|
||||
uint numPoints;
|
||||
float maxStrength;
|
||||
|
||||
float3 perturb(float3 pos) {
|
||||
float3 noise = fractalNoiseGrad(pos, 4, 25, .5, 2).xyz;
|
||||
noise = smoothstep(-1,1,noise) * 2 -1;
|
||||
return noise;
|
||||
}
|
||||
|
||||
[numthreads(512,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numPoints) {
|
||||
return;
|
||||
}
|
||||
|
||||
float3 pos = points[id];
|
||||
float height = length(pos);
|
||||
|
||||
float3 offset = perturb(pos);
|
||||
float3 newPos = pos + offset * maxStrength;
|
||||
|
||||
newPos = normalize(newPos) * height;
|
||||
points[id] = newPos;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0cc4782d709194aa5a22ed5e9ab8bf09
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
StructuredBuffer<float3> vertices;
|
||||
StructuredBuffer<int> triangles;
|
||||
RWStructuredBuffer<float> steepness;
|
||||
int numTriangles;
|
||||
|
||||
[numthreads(256,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if ((int)id >= numTriangles) {
|
||||
return;
|
||||
}
|
||||
|
||||
int triangleIndex = id * 3;
|
||||
float3 a = vertices[triangles[triangleIndex]];
|
||||
float3 b = vertices[triangles[triangleIndex+1]];
|
||||
float3 c = vertices[triangles[triangleIndex+2]];
|
||||
|
||||
float3 faceNormal = normalize(cross(a-b, a-c));
|
||||
float3 sphereNormal = normalize((a+b+c)/3);
|
||||
steepness[id] = 1 - dot(faceNormal, sphereNormal);
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: b65c4a31f112141149dfdfb7d00a93f2
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1b6ba54c403c749d3935a2e0e7a34e83
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
#include "../../Includes/Math.cginc"
|
||||
|
||||
StructuredBuffer<float3> vertices;
|
||||
RWStructuredBuffer<float4> shadingData;
|
||||
uint numVertices;
|
||||
|
||||
// Noise settings
|
||||
float4 noiseParams_detailWarp[3];
|
||||
float4 noiseParams_detail[3];
|
||||
|
||||
float4 noiseParams_large[3];
|
||||
float4 noiseParams_small[3];
|
||||
|
||||
// Second warp
|
||||
float4 noiseParams_warp2[3];
|
||||
float4 noiseParams_noise2[3];
|
||||
|
||||
[numthreads(512, 1, 1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numVertices) { return; }
|
||||
|
||||
float3 pos = vertices[id];
|
||||
|
||||
// Large, low frequency noise
|
||||
float largeNoise = simpleNoise(pos, noiseParams_large);
|
||||
float smallNoise = simpleNoise(pos, noiseParams_small);
|
||||
|
||||
// Warped detail noise
|
||||
float detailWarp = simpleNoise(pos, noiseParams_detailWarp);
|
||||
float detailNoise = simpleNoise(pos + detailWarp * 0.1, noiseParams_detail);
|
||||
|
||||
// Second warp noise
|
||||
float3 warpOffset2;
|
||||
warpOffset2.x = simpleNoise(pos, noiseParams_warp2);
|
||||
warpOffset2.y = simpleNoise(pos + 99999, noiseParams_warp2);
|
||||
warpOffset2.z = simpleNoise(pos - 99999, noiseParams_warp2);
|
||||
float warpedNoise2 = simpleNoise(pos + warpOffset2 * 0.1, noiseParams_noise2);
|
||||
|
||||
|
||||
|
||||
shadingData[id] = float4(largeNoise, detailNoise, smallNoise, warpedNoise2);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f3a2904f78271471481822700022a157
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
#include "../../Includes/FractalNoise.cginc"
|
||||
#include "../../Includes/Math.cginc"
|
||||
//
|
||||
StructuredBuffer<float3> vertices;
|
||||
RWStructuredBuffer<float4> shadingData;
|
||||
uint numVertices;
|
||||
|
||||
StructuredBuffer<float4> points;
|
||||
int numRandomPoints;
|
||||
|
||||
float4 noiseParams_biomeWarp[3];
|
||||
float4 noiseParams_detailWarp[3];
|
||||
float4 noiseParams_detail[3];
|
||||
|
||||
float4 params;
|
||||
|
||||
StructuredBuffer<float4> ejectaCraters;
|
||||
int numEjectaCraters;
|
||||
|
||||
float calcSphereNoise(float3 pos) {
|
||||
float sphereNoise = 1.#INF;
|
||||
for (int i = 0; i < numRandomPoints; i ++) {
|
||||
float3 sphereCentre = points[i].xyz;
|
||||
float sphereRadius = points[i].w;
|
||||
float dst = length(pos - sphereCentre);
|
||||
float t = dst / sphereRadius;
|
||||
sphereNoise = min(sphereNoise, t);
|
||||
}
|
||||
return sphereNoise;
|
||||
}
|
||||
|
||||
[numthreads(512,1,1)]
|
||||
void CSMain (uint id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id >= numVertices) { return; }
|
||||
|
||||
float3 pos = vertices[id];
|
||||
|
||||
float3 domainWarp = 0;
|
||||
domainWarp.x = simpleNoise(pos, noiseParams_biomeWarp);
|
||||
domainWarp.y = simpleNoise(pos + 100, noiseParams_biomeWarp);
|
||||
domainWarp.z = simpleNoise(pos - 100, noiseParams_biomeWarp);
|
||||
|
||||
float3 detailWarp = 0;
|
||||
detailWarp.x = simpleNoise(pos, noiseParams_detailWarp);
|
||||
detailWarp.y = simpleNoise(pos + 100, noiseParams_detailWarp);
|
||||
detailWarp.z = simpleNoise(pos - 100, noiseParams_detailWarp);
|
||||
|
||||
float domainWarp2 = simpleNoise(pos, noiseParams_detailWarp);
|
||||
|
||||
// Sphere noise
|
||||
float3 warpedPos = pos + (domainWarp) * 0.1;
|
||||
float sphereNoise = calcSphereNoise(warpedPos);
|
||||
|
||||
float detailNoise = simpleNoise(pos + domainWarp2 * 0.1, noiseParams_detail);
|
||||
|
||||
// Calculate uv coords for crater 'ejecta ray' texture to be projected onto the surface around select craters
|
||||
float2 ejectaUV = 1;
|
||||
float minDst = 999;
|
||||
for (int craterIndex = 0; craterIndex < numEjectaCraters; craterIndex ++) {
|
||||
float3 craterCentre = ejectaCraters[craterIndex].xyz;
|
||||
float dst = length(craterCentre - pos);
|
||||
float scaledDst = dst / ejectaCraters[craterIndex].w;
|
||||
|
||||
if (scaledDst < minDst) {
|
||||
minDst = scaledDst;
|
||||
|
||||
float3 craterUp = craterCentre;
|
||||
float3 craterForward = normalize(cross(craterUp, float3(0,1,0)));
|
||||
float3 forward = normalize(cross(pos, craterUp));
|
||||
|
||||
float cross_x = forward.y * craterForward.z - forward.z * craterForward.y;
|
||||
float cross_y = forward.z * craterForward.x - forward.x * craterForward.z;
|
||||
float cross_z = forward.x * craterForward.y - forward.y * craterForward.x;
|
||||
float angleSign = sign(craterUp.x * cross_x + craterUp.y * cross_y + craterUp.z * cross_z);
|
||||
|
||||
float angle = acos(dot(craterForward, forward)) * angleSign;
|
||||
//float estBiomeVal = Blend(7 * 0.8, 0.8, calcSphereNoise(craterCentre));
|
||||
//float biomeSign = (estBiomeVal < 0.5)?-1:1;
|
||||
ejectaUV = float2 (angle, scaledDst);
|
||||
}
|
||||
}
|
||||
|
||||
shadingData[id] = float4(ejectaUV.xy, detailNoise, sphereNoise);
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 8f6c3d86008df43ca88b9d64cf8e0514
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 717e98688348e475da7adb47d0d1c7ec
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
#pragma kernel CSMain
|
||||
|
||||
Texture2D<float4> SourceTex;
|
||||
RWTexture2D<float4> Result;
|
||||
|
||||
uint textureSize;
|
||||
int blurSize;
|
||||
|
||||
uint2 Wrap(int x, int y) {
|
||||
x = (x < 0) ? textureSize + x : x;
|
||||
x = (x >= (int)textureSize) ? x - textureSize : x;
|
||||
y = (y < 0) ? textureSize + y : y;
|
||||
y = (y >= (int)textureSize) ? y - textureSize : y;
|
||||
return uint2(x, y);
|
||||
}
|
||||
|
||||
[numthreads(8,8,1)]
|
||||
void CSMain (uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id.x >= textureSize || id.y >= textureSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
float4 sum = 0;
|
||||
for (int offsetX = -blurSize; offsetX <= blurSize; offsetX ++) {
|
||||
for (int offsetY = -blurSize; offsetY <= blurSize; offsetY ++) {
|
||||
uint2 sampleCoord = Wrap(id.x + offsetX, id.y + offsetY);
|
||||
float4 sample = SourceTex[sampleCoord];
|
||||
sum += sample;
|
||||
}
|
||||
}
|
||||
|
||||
int numSamples = (blurSize * 2 + 1) * (blurSize * 2 + 1);
|
||||
float4 result = sum / numSamples;
|
||||
|
||||
Result[id.xy] = result;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3bbb70231abe74a25b57d54568b663d9
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,49 @@
|
|||
// Each #kernel tells which function to compile; you can have many kernels
|
||||
#pragma kernel CSMain
|
||||
#include "../../Includes/Math.cginc"
|
||||
//
|
||||
|
||||
// Create a RenderTexture with enableRandomWrite flag and set it
|
||||
// with cs.SetTexture
|
||||
RWTexture2D<float4> Result;
|
||||
StructuredBuffer<float4> spots;
|
||||
uint resolution;
|
||||
int numSpots;
|
||||
float background;
|
||||
float4 params;
|
||||
float smoothing;
|
||||
|
||||
[numthreads(8,8,1)]
|
||||
void CSMain (uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
|
||||
if (id.x >= resolution || id.y >= resolution) {
|
||||
return;
|
||||
}
|
||||
|
||||
float2 pos = id.xy / (float)resolution;
|
||||
float alpha = 0;
|
||||
|
||||
|
||||
float minDst = 999;
|
||||
for (int i = 0; i < numSpots; i ++) {
|
||||
float4 spot = spots[i];
|
||||
float r = spot.z;
|
||||
|
||||
float dst = length(spot.xy - pos);
|
||||
|
||||
|
||||
float minDstOld = minDst;
|
||||
// minDst = smoothMin(dst, minDst, smoothing * 0.001);
|
||||
|
||||
if ( dst <= r) {
|
||||
//alpha = max(alpha, spot.w);
|
||||
//float v = 1-dst/r;
|
||||
//alpha += v*v*spot.w;
|
||||
alpha = max(alpha,spot.w);
|
||||
}
|
||||
}
|
||||
alpha = 1-saturate(background + alpha);
|
||||
Result[id.xy] = float4(alpha, alpha, alpha, 1);//
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a06a7dddd79684a96a2169e2128e5f88
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,101 @@
|
|||
#pragma kernel CSMain
|
||||
#pragma kernel Normalize
|
||||
#include "../../Includes/SimplexNoise3.cginc"
|
||||
|
||||
static const int minMaxAccuracy = 1000000;
|
||||
RWTexture2D<float4> Result;
|
||||
uint resolution;
|
||||
|
||||
RWStructuredBuffer<int> minMax;
|
||||
float4 noiseParams_simple[3];
|
||||
float4 noiseParams_warp[3];
|
||||
float valueFloor;
|
||||
float4 params;
|
||||
|
||||
// Remap a value (with a known mininum and maximum) to a value between 0 and 1
|
||||
float remap01(float v, float minOld, float maxOld) {
|
||||
return saturate((v-minOld) / (maxOld-minOld));
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
float tilingNoise(float2 pos, float4 noiseParams[3], float warp) {
|
||||
static const int x1 =-1, y1=-1, x2=1, y2=1;
|
||||
static const float dx = x2 - x1;
|
||||
static const float dy = y2 - y1;
|
||||
static const float tau = 3.14159265359 * 2;
|
||||
|
||||
// Params
|
||||
float3 offset = warp;
|
||||
float3 offset3d = noiseParams[0].xyz;//
|
||||
int numLayers = int(noiseParams[0].w);
|
||||
float persistence = noiseParams[1].x;
|
||||
float lacunarity = noiseParams[1].y;
|
||||
float scale = noiseParams[1].z;
|
||||
float multiplier = noiseParams[1].w;
|
||||
|
||||
// web.archive.org/web/20160304043608/https://www.gamedev.net/blog/33/entry-2138456-seamless-noise/
|
||||
float nx = x1 + cos(pos.x * tau) * dx;
|
||||
float ny = y1 + cos(pos.y * tau) * dy;
|
||||
float nz = x1 + sin(pos.x * tau) * dx;
|
||||
float nw = y1 + sin (pos.y * tau) * dy;
|
||||
float4 pos4D = float4(nx, ny, nz, nw) / tau;
|
||||
float4 dir = normalize(pos4D);
|
||||
pos4D += dir * 0.1 * params.x;
|
||||
//pos4D += snoise(pos4D * params.w * 0.001);
|
||||
|
||||
float noise = 0;
|
||||
float amplitude = 1;
|
||||
float frequency = scale;
|
||||
|
||||
for (int i = 0; i < numLayers; i ++) {
|
||||
float layerVal = snoise((pos4D + warp) * frequency);//
|
||||
//layerVal = 1-abs(layerVal);
|
||||
//layerVal *= layerVal;
|
||||
noise += layerVal * amplitude;
|
||||
amplitude *= persistence;
|
||||
frequency *= lacunarity;
|
||||
}
|
||||
|
||||
return noise * multiplier;
|
||||
}
|
||||
|
||||
[numthreads(8,8,1)]
|
||||
void CSMain (uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id.x >= resolution || id.y >= resolution) {
|
||||
return;
|
||||
}
|
||||
|
||||
float2 pos = id.xy/(float)resolution;
|
||||
|
||||
float warpNoise = tilingNoise(pos, noiseParams_warp, 0) * 0.1;
|
||||
float noise = tilingNoise(pos, noiseParams_simple, warpNoise);
|
||||
|
||||
// keep inside range [0,1] as will be clamped in texture
|
||||
float approxMax = 2;
|
||||
noise = saturate((noise + approxMax * 0.5) / approxMax);
|
||||
|
||||
|
||||
Result[id.xy] = noise;
|
||||
|
||||
// keep track of min max (using int to support atomic operation)
|
||||
int val = (int)(noise * minMaxAccuracy);
|
||||
InterlockedMin(minMax[0],val);
|
||||
InterlockedMax(minMax[1],val);
|
||||
}
|
||||
|
||||
[numthreads(8,8,1)]
|
||||
void Normalize (uint3 id : SV_DispatchThreadID)
|
||||
{
|
||||
if (id.x >= resolution || id.y >= resolution) {
|
||||
return;
|
||||
}
|
||||
|
||||
float minVal = (float)minMax[0]/minMaxAccuracy;
|
||||
float maxVal = (float)minMax[1]/minMaxAccuracy;
|
||||
float4 normalizedValue = (Result[id.xy]-minVal)/(maxVal-minVal);
|
||||
|
||||
|
||||
Result[id.xy] = normalizedValue;
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2821ce0c209074cf9bb487300949b8f6
|
||||
ComputeShaderImporter:
|
||||
externalObjects: {}
|
||||
currentAPIMask: 65536
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue