Publish gravity fog through generic Eve fields
This commit is contained in:
parent
84429ad6eb
commit
6f0375f4ad
22 changed files with 293 additions and 230 deletions
|
|
@ -529,6 +529,12 @@ namespace Aetheria.Editor
|
|||
var reflection = LoadAuthoredAsset<Cubemap>(bundle, assetNames, "Assets/Textures/studio2.hdr");
|
||||
if (reflection == null)
|
||||
throw new InvalidOperationException("Aetheria Eve bundle has no provider reflection cubemap.");
|
||||
var gravityFog = LoadAuthoredAsset<Shader>(bundle, assetNames, "Assets/Shaders/Raymarching/CloudShader.shader");
|
||||
if (gravityFog == null || !gravityFog.isSupported)
|
||||
throw new InvalidOperationException("Aetheria Eve bundle has no supported gravity-fog volume shader.");
|
||||
var dither = LoadAuthoredAsset<Texture2D>(bundle, assetNames, "Assets/Resources/LDR_LLL1_0.png");
|
||||
if (dither == null)
|
||||
throw new InvalidOperationException("Aetheria Eve bundle has no pre-generated volume dither texture.");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public sealed class AetheriaRenderSplatLayerRenderer : MonoBehaviour
|
|||
return false;
|
||||
}
|
||||
|
||||
public void Render(AetheriaRuntimeRenderSplatsViewportDocument document, int width, int height)
|
||||
public void Render(EveFieldsSplatsDocument document, int width, int height)
|
||||
{
|
||||
if (document == null) return;
|
||||
ResolveRenderer();
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.PluginFields;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
|
||||
|
|
@ -43,7 +44,7 @@ public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
|
|||
[SerializeField]
|
||||
private AetheriaSceneRenderSplatFixture[] fixtures = Array.Empty<AetheriaSceneRenderSplatFixture>();
|
||||
|
||||
public AetheriaRuntimeRenderSplatsViewportDocument BuildDocument(AetheriaRuntimeViewportBounds viewport)
|
||||
public EveFieldsSplatsDocument BuildDocument(AetheriaRuntimeViewportBounds viewport)
|
||||
{
|
||||
viewport ??= new AetheriaRuntimeViewportBounds();
|
||||
var normalizedViewport = Normalize(viewport);
|
||||
|
|
@ -58,13 +59,19 @@ public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
|
|||
foreach (var fixture in fixtures ?? Array.Empty<AetheriaSceneRenderSplatFixture>())
|
||||
fixture.AddTo(builder, layerIndices);
|
||||
|
||||
return new AetheriaRuntimeRenderSplatsViewportDocument
|
||||
return new EveFieldsSplatsDocument
|
||||
{
|
||||
PublishedAtUtc = DateTimeOffset.UtcNow.ToString("O"),
|
||||
SimulationTimeSeconds = Application.isPlaying ? Time.timeAsDouble : 0,
|
||||
RunId = "scene",
|
||||
ZoneName = string.IsNullOrWhiteSpace(documentName) ? gameObject.scene.name : documentName,
|
||||
Viewport = normalizedViewport,
|
||||
Viewport = new EveFieldsViewport
|
||||
{
|
||||
MinX = normalizedViewport.MinX,
|
||||
MinY = normalizedViewport.MinY,
|
||||
MaxX = normalizedViewport.MaxX,
|
||||
MaxY = normalizedViewport.MaxY
|
||||
},
|
||||
Layers = layers,
|
||||
Splats = builder.Build()
|
||||
};
|
||||
|
|
@ -81,7 +88,7 @@ public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
|
|||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRenderSplatLayerDefinition[] BuildLayers()
|
||||
private static EveFieldsSplatLayer[] BuildLayers()
|
||||
{
|
||||
return new[]
|
||||
{
|
||||
|
|
@ -96,14 +103,14 @@ public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
|
|||
};
|
||||
}
|
||||
|
||||
private static AetheriaRuntimeRenderSplatLayerDefinition Layer(
|
||||
private static EveFieldsSplatLayer Layer(
|
||||
string key,
|
||||
string displayName,
|
||||
int channel,
|
||||
string blendMode = AetheriaRuntimeRenderSplatBlendModes.Add,
|
||||
string graphicsFormat = "R16_SFloat")
|
||||
{
|
||||
return new AetheriaRuntimeRenderSplatLayerDefinition
|
||||
return new EveFieldsSplatLayer
|
||||
{
|
||||
LayerKey = key,
|
||||
DisplayName = displayName,
|
||||
|
|
@ -163,9 +170,9 @@ public sealed class AetheriaSceneRenderSplatSource : MonoBehaviour
|
|||
_sourceFlags.Add(splat.SourceFlags);
|
||||
}
|
||||
|
||||
public AetheriaRuntimeRenderSplatSoa Build()
|
||||
public EveFieldsSplatSoa Build()
|
||||
{
|
||||
return new AetheriaRuntimeRenderSplatSoa
|
||||
return new EveFieldsSplatSoa
|
||||
{
|
||||
Count = _centerX.Count,
|
||||
CenterX = _centerX.ToArray(),
|
||||
|
|
|
|||
|
|
@ -1,12 +1,13 @@
|
|||
using System;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.PluginFields;
|
||||
using GameCult.Mesh;
|
||||
|
||||
public sealed class AetheriaUnityGameViewportDocuments : IDisposable
|
||||
{
|
||||
private readonly CultMeshReactiveDocument<AetheriaRuntimeZoneContactsDocument> _contacts;
|
||||
private readonly CultMeshReactiveDocument<AetheriaRuntimeObjectsViewportDocument> _objectsViewport;
|
||||
private readonly CultMeshReactiveDocument<AetheriaRuntimeRenderSplatsViewportDocument> _renderSplatsViewport;
|
||||
private readonly CultMeshReactiveDocument<EveFieldsSplatsDocument> _renderSplatsViewport;
|
||||
|
||||
private AetheriaUnityGameViewportDocuments(
|
||||
AetheriaClientState state,
|
||||
|
|
@ -30,7 +31,7 @@ public sealed class AetheriaUnityGameViewportDocuments : IDisposable
|
|||
|
||||
public AetheriaRuntimeZoneContactsDocument CurrentContacts => _contacts?.Current;
|
||||
public AetheriaRuntimeObjectsViewportDocument CurrentObjectsViewport => _objectsViewport?.Current;
|
||||
public AetheriaRuntimeRenderSplatsViewportDocument CurrentRenderSplatsViewport => _renderSplatsViewport?.Current;
|
||||
public EveFieldsSplatsDocument CurrentRenderSplatsViewport => _renderSplatsViewport?.Current;
|
||||
|
||||
public static AetheriaUnityGameViewportDocuments OpenMap(
|
||||
AetheriaClientState state,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.PluginFields;
|
||||
using UnityEngine;
|
||||
|
||||
public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
|
||||
|
|
@ -40,7 +41,7 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
public AetheriaRuntimeRenderSplatsViewportDocument CurrentDocument =>
|
||||
public EveFieldsSplatsDocument CurrentDocument =>
|
||||
_viewportDocuments?.CurrentRenderSplatsViewport;
|
||||
|
||||
public bool RenderInLateUpdate
|
||||
|
|
|
|||
|
|
@ -506,6 +506,13 @@ public class DaemonRuntimeDocumentTests
|
|||
Assert.IsTrue(ContainsSurfaceProp(surface.Surface.Root, "entityViewSchema",
|
||||
EveEntitySoaViewDocument.SchemaId));
|
||||
Assert.IsFalse(ContainsSurfaceKind(surface.Surface.Root, "world.entity3d"));
|
||||
Assert.IsTrue(ContainsSurfaceKind(surface.Surface.Root, "field.volume3d"));
|
||||
Assert.IsTrue(ContainsSurfaceProp(surface.Surface.Root, "materialAssetRef",
|
||||
"shader.environment.gravity-fog"));
|
||||
Assert.IsTrue(ContainsSurfaceProp(surface.Surface.Root, "documentSchema",
|
||||
AetheriaRuntimeDaemonSchemas.RenderSplatsViewport));
|
||||
Assert.IsFalse(ContainsSurfaceValueFragment(surface.Surface.Root, "_Nebula"),
|
||||
"The semantic Eve surface must not own Unity shader property names.");
|
||||
Assert.AreEqual(EveEntitySoaViewDocument.SchemaId, portable.Schema);
|
||||
Assert.AreEqual(42, portable.Generation);
|
||||
Assert.AreEqual(AetheriaRuntimeDaemonSoaColumnKinds.Position, portable.Columns.Single().Semantic);
|
||||
|
|
@ -708,6 +715,13 @@ public class DaemonRuntimeDocumentTests
|
|||
Assert.IsTrue(assetManifest.Assets.Any(asset =>
|
||||
asset.Ref.AssetKey == "prefab.entity.ship" &&
|
||||
asset.Ref.Kind == AetheriaRuntimeAssetKinds.Prefab));
|
||||
Assert.IsTrue(assetManifest.Assets.Any(asset =>
|
||||
asset.Ref.AssetKey == "shader.environment.gravity-fog" &&
|
||||
asset.Ref.Kind == AetheriaRuntimeAssetKinds.Shader &&
|
||||
asset.Ref.Metadata["unity.volume.texturePort.surfaceHeight"] == "_NebulaSurfaceHeight"));
|
||||
Assert.IsTrue(assetManifest.Assets.Any(asset =>
|
||||
asset.Ref.AssetKey == "texture.environment.volume-dither" &&
|
||||
asset.Ref.Kind == AetheriaRuntimeAssetKinds.Texture));
|
||||
var editorTuiSurface = result.EditorTuiSurface;
|
||||
Assert.AreEqual("aetheria.daemon", editorTuiSurface.ProviderId);
|
||||
Assert.AreEqual("editor.daemon", editorTuiSurface.ProviderKind);
|
||||
|
|
@ -6224,6 +6238,14 @@ public class DaemonRuntimeDocumentTests
|
|||
component.Children.Any(child => ContainsSurfaceKind(child, kind));
|
||||
}
|
||||
|
||||
private static bool ContainsSurfaceValueFragment(AetheriaRuntimeSurfaceComponent component, string fragment)
|
||||
{
|
||||
if (component.Props.Values.Any(value =>
|
||||
value != null && value.IndexOf(fragment, StringComparison.Ordinal) >= 0))
|
||||
return true;
|
||||
return component.Children.Any(child => ContainsSurfaceValueFragment(child, fragment));
|
||||
}
|
||||
|
||||
private static bool ContainsSurfaceStateBinding(
|
||||
AetheriaRuntimeSurfaceComponent component,
|
||||
string targetProp,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.PluginFields;
|
||||
using GameCult.Mesh;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
|
|
@ -357,7 +358,7 @@ public class SectorMap : MonoBehaviour
|
|||
return InfluenceSplatRasterizer;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument BuildInfluenceSplatDocument(int factionIndex)
|
||||
private EveFieldsSplatsDocument BuildInfluenceSplatDocument(int factionIndex)
|
||||
{
|
||||
var zones = (_sectorMap?.Zones ?? Array.Empty<AetheriaRuntimeSectorMapZone>()).ToArray();
|
||||
var minX = zones.Length > 0 ? zones.Min(zone => zone.X) : -1;
|
||||
|
|
@ -420,10 +421,10 @@ public class SectorMap : MonoBehaviour
|
|||
sourceFlags.Add(0);
|
||||
}
|
||||
|
||||
return new AetheriaRuntimeRenderSplatsViewportDocument
|
||||
return new EveFieldsSplatsDocument
|
||||
{
|
||||
Schema = AetheriaRuntimeDaemonSchemas.RenderSplatsViewport,
|
||||
Viewport = new AetheriaRuntimeViewportBounds
|
||||
Viewport = new EveFieldsViewport
|
||||
{
|
||||
MinX = minX - padding,
|
||||
MinY = minY - padding,
|
||||
|
|
@ -432,7 +433,7 @@ public class SectorMap : MonoBehaviour
|
|||
},
|
||||
Layers = new[]
|
||||
{
|
||||
new AetheriaRuntimeRenderSplatLayerDefinition
|
||||
new EveFieldsSplatLayer
|
||||
{
|
||||
LayerKey = AetheriaRuntimeRenderSplatLayerKeys.Influence,
|
||||
DisplayName = "Sector Influence",
|
||||
|
|
@ -441,7 +442,7 @@ public class SectorMap : MonoBehaviour
|
|||
GraphicsFormat = "R16_SFloat"
|
||||
}
|
||||
},
|
||||
Splats = new AetheriaRuntimeRenderSplatSoa
|
||||
Splats = new EveFieldsSplatSoa
|
||||
{
|
||||
Count = centerX.Count,
|
||||
CenterX = centerX,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
using System;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using GameCult.Eve.PluginFields;
|
||||
using UnityEngine;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
|
|
@ -222,7 +223,7 @@ public class VolumeSampling : MonoBehaviour
|
|||
NebulaTint = ResolveLayerTexture(AetheriaRuntimeRenderSplatLayerKeys.FogTint, NebulaTint);
|
||||
}
|
||||
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument ResolveSceneSplatDocument(Vector2 center, Vector2 size)
|
||||
private EveFieldsSplatsDocument ResolveSceneSplatDocument(Vector2 center, Vector2 size)
|
||||
{
|
||||
if (SceneSplatSource == null)
|
||||
SceneSplatSource = GetComponent<AetheriaSceneRenderSplatSource>();
|
||||
|
|
@ -231,7 +232,7 @@ public class VolumeSampling : MonoBehaviour
|
|||
: null;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument ResolveRuntimeSplatDocument(Vector2 center, Vector2 size)
|
||||
private EveFieldsSplatsDocument ResolveRuntimeSplatDocument(Vector2 center, Vector2 size)
|
||||
{
|
||||
if (SplatViewportSource == null)
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -5,6 +5,13 @@ Shader "Aetheria/CloudShader"
|
|||
Properties
|
||||
{
|
||||
_MainTex("MainTex",2D) = "white"{}
|
||||
[HideInInspector] _DitheringTex("DitheringTex", 2D) = "white" {}
|
||||
[HideInInspector] _NebulaSurfaceHeight("NebulaSurfaceHeight", 2D) = "black" {}
|
||||
[HideInInspector] _NebulaPatchHeight("NebulaPatchHeight", 2D) = "black" {}
|
||||
[HideInInspector] _NebulaPatch("NebulaPatch", 2D) = "black" {}
|
||||
[HideInInspector] _NebulaTint("NebulaTint", 2D) = "black" {}
|
||||
[HideInInspector] _CloudTex("CloudTex", 2D) = "black" {}
|
||||
[HideInInspector] _CompositeOpacity("CompositeOpacity", Range(0, 1)) = 1
|
||||
}
|
||||
|
||||
SubShader
|
||||
|
|
@ -86,7 +93,6 @@ Shader "Aetheria/CloudShader"
|
|||
float density = c.a;
|
||||
if (density <= 0.0f)
|
||||
{
|
||||
result.intTransmittance = 0;
|
||||
return;
|
||||
}
|
||||
float extinction = _ExtinctionCoefficient * density / (1-fade);
|
||||
|
|
@ -94,7 +100,7 @@ Shader "Aetheria/CloudShader"
|
|||
float clampedExtinction = max(extinction, 1e-7);
|
||||
float transmittance = exp(-extinction * stepsize);
|
||||
|
||||
float3 luminance = c.rgb * _NebulaLuminance;
|
||||
float3 luminance = c.rgb * _NebulaLuminance * density;
|
||||
float3 integScatt = (luminance - luminance * transmittance) / clampedExtinction;
|
||||
float depthWeight = result.intTransmittance * (1-transmittance); //Is it a better idea to use (1-transmittance) * intTransmittance as depth weight?
|
||||
|
||||
|
|
@ -168,7 +174,6 @@ Shader "Aetheria/CloudShader"
|
|||
//float sceneDepth = Linear01Depth(depthSample);
|
||||
//bool occluded = GetRaymarchEndFromSceneDepth(sceneDepth, raymarchEnd);
|
||||
float3 viewDir = normalize(worldPos.xyz - _WorldSpaceCameraPos);
|
||||
|
||||
//float blue = tex2D(_DitheringTex, screenPos * _DitheringCoords.xy + _DitheringCoords.zw).r;
|
||||
float dither = tex2D(_DitheringTex, screenUV * _DitheringCoords.xy).r;
|
||||
float offset = -fmod(_RaymarchOffset + dither, 1.0f); //final offset combined. The value will be multiplied by sample step in GetDensity.
|
||||
|
|
@ -285,6 +290,7 @@ Shader "Aetheria/CloudShader"
|
|||
sampler2D _CloudTex; //The full resolution cloud tex we generated.
|
||||
sampler2D _CameraDepthTexture;
|
||||
float4 _ProjectionExtents;
|
||||
float _CompositeOpacity;
|
||||
|
||||
struct v2f
|
||||
{
|
||||
|
|
@ -312,7 +318,7 @@ Shader "Aetheria/CloudShader"
|
|||
float distance;
|
||||
float density;
|
||||
unpack(currSample.a, distance, density);
|
||||
return half4(currSample.rgb, saturate(density));
|
||||
return half4(currSample.rgb * _CompositeOpacity, saturate(density) * _CompositeOpacity);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue