Isoline wiring: map screen and minimap draw through IsolineRenderer from one IsolineView; IsolinesUI, the map gravity cameras and their RT, and the dead isoline assets are deleted (aetheria-release, cut isoline-wiring)
IsolineView (execution order 100) owns one view's frame: grid from the pose camera (world-anchored), levels from MapPresenter.ContourRange, terms from ZoneRenderer.Terms, look, cell size and capacities from the new GameSettings.MapIsolines and MinimapIsolines (values written into Settings.asset). The map's Gravity Lines Image keeps Map Gravity Lines.mat on UI/MaskedWorldSpaceUI with a per-view material instance; the minimap's Gravity Fields RawImage takes the target as its texture. Overflow is logged in debug builds only, from a Stats readback that never feeds rendering. Deleted: IsolinesUI.shader, Isolines.shader, Zone.mat, Minimap Gravity Lines.mat, MinimapGravity.renderTexture, both Map Gravity cameras, MapRenderer's gravity camera path, ZoneRenderer.MapGravityMaterials and MapPresenter's material writes. The layer-9 Gravity Field quad and the fog and slime cameras stay. Smokes: capacity guard; grid is world-anchored; shipped capacities hold; overflow message; per-view captures and cost through IsolineView.Grid and Settings.asset; the old field-camera and blit legs are gone; GravityFieldParityVerify checks the layer-9 cameras and both views' wiring. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
b5146fbf79
commit
1a57d89a6c
26 changed files with 550 additions and 1124 deletions
5
.changeset/isoline-wiring.md
Normal file
5
.changeset/isoline-wiring.md
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
default: patch
|
||||
---
|
||||
|
||||
The map screen and the minimap draw gravity contours and slope rays as smooth anti-aliased lines, and the rays flow slowly downhill into each well.
|
||||
|
|
@ -8,11 +8,10 @@ Material:
|
|||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Map Gravity Lines
|
||||
m_Shader: {fileID: 4800000, guid: f5505d3747493e24c91b7cb141fd7b8c, type: 3}
|
||||
m_Shader: {fileID: 4800000, guid: 16ca943590e909145a2f5b7aaeef334e, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords:
|
||||
- SCREEN_SPACE
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
|
|
@ -49,7 +48,7 @@ Material:
|
|||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MainTex:
|
||||
m_Texture: {fileID: 8400000, guid: ed3d896ce7cb4a84aa4de8515a60f59c, type: 2}
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _MetallicGlossMap:
|
||||
|
|
@ -64,55 +63,34 @@ Material:
|
|||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
- _TintTex:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Angle2Fade: 1.1
|
||||
- _Angle2Width: 0.5
|
||||
- _AngleFade: 1.15
|
||||
- _AngleWidth: 0.05
|
||||
- _BumpScale: 1
|
||||
- _ClipDistance: 1000
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DangerSteepness: 1.5
|
||||
- _DepthRange: 228.79605
|
||||
- _DetailGamma: 1
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _HeightRange: 50
|
||||
- _LineFade: 5
|
||||
- _LineWidth: 0.3
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Scale: 2.6924083
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _StartDepth: 2.310401
|
||||
- _StartHeight: 0
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _TintExponent: 3
|
||||
- _TintIntensity: 4.54
|
||||
- _UVSec: 0
|
||||
- _UseScreenSpace: 1
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _AngleColor: {r: 0.248, g: 0, b: 0.21104322, a: 1}
|
||||
- _Color: {r: 0, g: 0.4, b: 0.6, a: 1}
|
||||
- _DangerColor: {r: 2.9960785, g: 0.26666668, b: 0, a: 1}
|
||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
|
|
|
|||
|
|
@ -1,111 +0,0 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Minimap Gravity Lines
|
||||
m_Shader: {fileID: 4800000, guid: f5505d3747493e24c91b7cb141fd7b8c, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_LightmapFlags: 4
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
- _BumpMap:
|
||||
m_Texture: {fileID: 0}
|
||||
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}
|
||||
- _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}
|
||||
- _DetailTex:
|
||||
m_Texture: {fileID: 8400000, guid: ed3d896ce7cb4a84aa4de8515a60f59c, type: 2}
|
||||
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: 8400000, guid: ed3d896ce7cb4a84aa4de8515a60f59c, type: 2}
|
||||
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}
|
||||
- _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}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _Angle2Fade: 1.1
|
||||
- _Angle2Width: 0.5
|
||||
- _AngleFade: 1.15
|
||||
- _AngleWidth: 0.05
|
||||
- _BumpScale: 1
|
||||
- _ClipDistance: 1000
|
||||
- _ColorMask: 15
|
||||
- _Cutoff: 0.5
|
||||
- _DangerSteepness: 1.5
|
||||
- _DepthRange: 228.79605
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _HeightRange: 50
|
||||
- _LineFade: 5
|
||||
- _LineWidth: 0.15
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _Scale: 10
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _StartDepth: 2.310401
|
||||
- _StartHeight: 0
|
||||
- _Stencil: 0
|
||||
- _StencilComp: 8
|
||||
- _StencilOp: 0
|
||||
- _StencilReadMask: 255
|
||||
- _StencilWriteMask: 255
|
||||
- _UVSec: 0
|
||||
- _UseScreenSpace: 0
|
||||
- _UseUIAlphaClip: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _AngleColor: {r: 1.4980392, g: 0, b: 1.2705883, a: 0.5019608}
|
||||
- _Color: {r: 0, g: 0.4, b: 0.6, a: 1}
|
||||
- _DangerColor: {r: 2.670157, g: 0.22367807, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
m_AllowLocking: 1
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a92fc6d958edb9f46b6e58134f609cc0
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
%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: Zone
|
||||
m_Shader: {fileID: 4800000, guid: 0ec0ecdb30ff1614698ae885ebcd873d, 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}
|
||||
- _DetailAlbedoMap:
|
||||
m_Texture: {fileID: 0}
|
||||
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: 8400000, guid: ed3d896ce7cb4a84aa4de8515a60f59c, type: 2}
|
||||
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}
|
||||
- _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}
|
||||
m_Floats:
|
||||
- _AngleFade: 5
|
||||
- _AngleWidth: 100
|
||||
- _BumpScale: 1
|
||||
- _ClipDistance: 1000
|
||||
- _Cutoff: 0.5
|
||||
- _DangerSteepness: 5
|
||||
- _DepthRange: 268.43512
|
||||
- _DetailNormalMapScale: 1
|
||||
- _DstBlend: 0
|
||||
- _GlossMapScale: 1
|
||||
- _Glossiness: 0.5
|
||||
- _GlossyReflections: 1
|
||||
- _HeightRange: 50
|
||||
- _LineFade: 5
|
||||
- _LineWidth: 100
|
||||
- _Metallic: 0
|
||||
- _Mode: 0
|
||||
- _OcclusionStrength: 1
|
||||
- _Parallax: 0.02
|
||||
- _SmoothnessTextureChannel: 0
|
||||
- _SpecularHighlights: 1
|
||||
- _SrcBlend: 1
|
||||
- _StartDepth: 423.4922
|
||||
- _StartHeight: 0
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _AngleColor: {r: 0.103773594, g: 0, b: 0.088093735, a: 1}
|
||||
- _Color: {r: 0, g: 0.4, b: 0.6, a: 1}
|
||||
- _DangerColor: {r: 2.9803922, g: 0.2509804, b: 0, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 90cead50364300d47bb35194fb52c117
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 2100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!84 &8400000
|
||||
RenderTexture:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: MinimapGravity
|
||||
m_ImageContentsHash:
|
||||
serializedVersion: 2
|
||||
Hash: 00000000000000000000000000000000
|
||||
m_IsAlphaChannelOptional: 0
|
||||
serializedVersion: 6
|
||||
m_Width: 128
|
||||
m_Height: 128
|
||||
m_AntiAliasing: 1
|
||||
m_MipCount: -1
|
||||
m_DepthStencilFormat: 0
|
||||
m_ColorFormat: 49
|
||||
m_MipMap: 0
|
||||
m_GenerateMips: 1
|
||||
m_SRGB: 0
|
||||
m_UseDynamicScale: 0
|
||||
m_UseDynamicScaleExplicit: 0
|
||||
m_BindMS: 0
|
||||
m_EnableCompatibleFormat: 1
|
||||
m_EnableRandomWrite: 0
|
||||
m_TextureSettings:
|
||||
serializedVersion: 2
|
||||
m_FilterMode: 1
|
||||
m_Aniso: 0
|
||||
m_MipBias: 0
|
||||
m_WrapU: 1
|
||||
m_WrapV: 1
|
||||
m_WrapW: 1
|
||||
m_Dimension: 2
|
||||
m_VolumeDepth: 1
|
||||
m_ShadowSamplingMode: 2
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ed3d896ce7cb4a84aa4de8515a60f59c
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Resources/Settings.asset
(Stored with Git LFS)
BIN
Assets/Resources/Settings.asset
(Stored with Git LFS)
Binary file not shown.
|
|
@ -2586,7 +2586,6 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 488792361}
|
||||
- {fileID: 970624070}
|
||||
- {fileID: 2095741462}
|
||||
m_Father: {fileID: 1665127616}
|
||||
|
|
@ -4349,89 +4348,6 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 314890516}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &326516964
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 326516965}
|
||||
- component: {fileID: 326516967}
|
||||
m_Layer: 0
|
||||
m_Name: Map Gravity
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
--- !u!4 &326516965
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 326516964}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 0, y: 10, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 826773974}
|
||||
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
|
||||
--- !u!20 &326516967
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 326516964}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 2
|
||||
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 1
|
||||
orthographic size: 1000
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 512
|
||||
m_RenderingPath: 1
|
||||
m_TargetTexture: {fileID: 0}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 0
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!1 &332734005
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -6866,109 +6782,6 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 480176636}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!1 &488792360
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 488792361}
|
||||
- component: {fileID: 488792362}
|
||||
- component: {fileID: 488792363}
|
||||
m_Layer: 0
|
||||
m_Name: Map Gravity
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &488792361
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 488792360}
|
||||
serializedVersion: 2
|
||||
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 0, y: 10, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 199435031}
|
||||
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
|
||||
--- !u!20 &488792362
|
||||
Camera:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 488792360}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_ClearFlags: 2
|
||||
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
|
||||
m_projectionMatrixMode: 1
|
||||
m_GateFitMode: 2
|
||||
m_FOVAxisMode: 0
|
||||
m_Iso: 200
|
||||
m_ShutterSpeed: 0.005
|
||||
m_Aperture: 16
|
||||
m_FocusDistance: 10
|
||||
m_FocalLength: 50
|
||||
m_BladeCount: 5
|
||||
m_Curvature: {x: 2, y: 11}
|
||||
m_BarrelClipping: 0.25
|
||||
m_Anamorphism: 0
|
||||
m_SensorSize: {x: 36, y: 24}
|
||||
m_LensShift: {x: 0, y: 0}
|
||||
m_NormalizedViewPortRect:
|
||||
serializedVersion: 2
|
||||
x: 0
|
||||
y: 0
|
||||
width: 1
|
||||
height: 1
|
||||
near clip plane: 0.3
|
||||
far clip plane: 1000
|
||||
field of view: 60
|
||||
orthographic: 1
|
||||
orthographic size: 1000
|
||||
m_Depth: 0
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 512
|
||||
m_RenderingPath: 1
|
||||
m_TargetTexture: {fileID: 8400000, guid: ed3d896ce7cb4a84aa4de8515a60f59c, type: 2}
|
||||
m_TargetDisplay: 0
|
||||
m_TargetEye: 3
|
||||
m_HDR: 1
|
||||
m_AllowMSAA: 0
|
||||
m_AllowDynamicResolution: 0
|
||||
m_ForceIntoRT: 0
|
||||
m_OcclusionCulling: 0
|
||||
m_StereoConvergence: 10
|
||||
m_StereoSeparation: 0.022
|
||||
--- !u!114 &488792363
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 488792360}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 7ec4eea2d4fa2f64f80e17d11987e6f6, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Target: {fileID: 2115559090}
|
||||
CopyXPosition: 1
|
||||
CopyYPosition: 0
|
||||
CopyZPosition: 1
|
||||
CopyRotation: 0
|
||||
PixelSnapCamera: {fileID: 0}
|
||||
PixelSnapIncrement: 1
|
||||
--- !u!1001 &495677244
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -9337,11 +9150,9 @@ MonoBehaviour:
|
|||
ZoneRenderer: {fileID: 1009503731}
|
||||
Title: {fileID: 1130044038}
|
||||
MapOverlayCamera: {fileID: 1075335643}
|
||||
GravityCamera: {fileID: 326516967}
|
||||
TintCamera: {fileID: 166261018}
|
||||
InfluenceCamera: {fileID: 439363415}
|
||||
OverlayDisplay: {fileID: 250585913}
|
||||
GravityDisplay: {fileID: 800990059}
|
||||
TintDisplay: {fileID: 218215088}
|
||||
InfluenceDisplay: {fileID: 1390179643}
|
||||
Scale: 1
|
||||
|
|
@ -11937,6 +11748,7 @@ GameObject:
|
|||
- component: {fileID: 800990061}
|
||||
- component: {fileID: 800990060}
|
||||
- component: {fileID: 800990059}
|
||||
- component: {fileID: 800990062}
|
||||
m_Layer: 5
|
||||
m_Name: Gravity Lines
|
||||
m_TagString: Untagged
|
||||
|
|
@ -12001,6 +11813,23 @@ RectTransform:
|
|||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &800990062
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 800990058}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 440d14bb8b58a5846adb6e754fa8f803, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::IsolineView
|
||||
View: 0
|
||||
PoseCamera: {fileID: 1075335643}
|
||||
ZoneRenderer: {fileID: 1009503731}
|
||||
Extract: {fileID: 7200000, guid: 31ef7108234b45d4f8639d22197cea27, type: 3}
|
||||
Render: {fileID: 7200000, guid: 2ee6aee2e7c44b04596a297e59623668, type: 3}
|
||||
--- !u!1 &803284854
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
@ -12443,7 +12272,6 @@ Transform:
|
|||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 326516965}
|
||||
- {fileID: 1075335641}
|
||||
- {fileID: 166261017}
|
||||
- {fileID: 439363414}
|
||||
|
|
@ -15378,7 +15206,6 @@ MonoBehaviour:
|
|||
- {fileID: 1537342003}
|
||||
- {fileID: 39508929}
|
||||
MinimapCameras:
|
||||
- {fileID: 488792362}
|
||||
- {fileID: 970624071}
|
||||
- {fileID: 2095741464}
|
||||
FarPlaneDistanceMultiplier: 1
|
||||
|
|
@ -15490,9 +15317,6 @@ MonoBehaviour:
|
|||
type: 3}
|
||||
CloudPrefab: {fileID: 2914522964471179774, guid: 4084aa3d08e52e04f880ad13daa409b4,
|
||||
type: 3}
|
||||
MapGravityMaterials:
|
||||
- {fileID: 2100000, guid: 841e4091d19548347bd59115047b4e49, type: 2}
|
||||
- {fileID: 2100000, guid: a92fc6d958edb9f46b6e58134f609cc0, type: 2}
|
||||
GravityField: {fileID: 2100000, guid: 44a8bbb89acb4e34c9f41a9da5842bb4, type: 2}
|
||||
Tour: 0
|
||||
TourSwitchTime: 10
|
||||
|
|
@ -33311,6 +33135,7 @@ GameObject:
|
|||
- component: {fileID: 2352149241570183590}
|
||||
- component: {fileID: 2352149241570183608}
|
||||
- component: {fileID: 2352149241570183591}
|
||||
- component: {fileID: 2352149241570183609}
|
||||
m_Layer: 5
|
||||
m_Name: Gravity Fields
|
||||
m_TagString: Untagged
|
||||
|
|
@ -33349,7 +33174,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 1344c3c82d62a2a41a3576d8abb8e3ea, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 2100000, guid: a92fc6d958edb9f46b6e58134f609cc0, type: 2}
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 0
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
|
|
@ -33372,6 +33197,23 @@ CanvasRenderer:
|
|||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2352149241570183589}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &2352149241570183609
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2352149241570183589}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 440d14bb8b58a5846adb6e754fa8f803, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier: Assembly-CSharp::IsolineView
|
||||
View: 1
|
||||
PoseCamera: {fileID: 970624071}
|
||||
ZoneRenderer: {fileID: 1009503731}
|
||||
Extract: {fileID: 7200000, guid: 31ef7108234b45d4f8639d22197cea27, type: 3}
|
||||
Render: {fileID: 7200000, guid: 2ee6aee2e7c44b04596a297e59623668, type: 3}
|
||||
--- !u!1 &2352149241830964824
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ public static class CapabilityPresentationSmoke
|
|||
// The scene's map: an entity registers its icon with the ZoneRenderer's presenter, so each instance carries a quad.
|
||||
var mapRenderer = new GameObject("Smoke Zone Renderer").AddComponent<ZoneRenderer>();
|
||||
mapRenderer.Settings = AssetDatabase.LoadAssetAtPath<GameSettings>("Assets/Resources/Settings.asset");
|
||||
mapRenderer.MapGravityMaterials = new Material[0];
|
||||
Awaken(mapRenderer);
|
||||
(GameObject Object, EntityInstance Instance, TractorBeam Beam) Bound(string name, Entity entity)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -369,32 +369,61 @@ namespace Aetheria.EditorTools
|
|||
return found;
|
||||
}
|
||||
|
||||
// Both isoline views: the map screen's Gravity Lines Image (UI/MaskedWorldSpaceUI, posed by MapRenderer.MapOverlayCamera) and
|
||||
// the minimap's Gravity Fields RawImage (no material, posed by the minimap camera that targets Minimap).
|
||||
static void CheckIsolineViews(MapRenderer map, ZoneRenderer renderer)
|
||||
{
|
||||
var views = UnityEngine.Object.FindObjectsByType<IsolineView>(FindObjectsInactive.Include, FindObjectsSortMode.None);
|
||||
if (views.Length != 2) Fail("wiring", $"{views.Length} IsolineViews in ARPG.unity, expected 2");
|
||||
foreach (var kind in new[] { IsolineView.Kind.Map, IsolineView.Kind.Minimap })
|
||||
{
|
||||
var view = views.FirstOrDefault(v => v.View == kind);
|
||||
if (view == null) { Fail("wiring", $"no {kind} IsolineView in ARPG.unity"); continue; }
|
||||
if (view.ZoneRenderer != renderer) Fail("wiring", $"{kind} IsolineView.ZoneRenderer is not the scene's ZoneRenderer");
|
||||
if (view.Extract == null || view.Render == null) Fail("wiring", $"{kind} IsolineView lacks its compute shaders");
|
||||
if (kind == IsolineView.Kind.Map)
|
||||
{
|
||||
if (view.name != "Gravity Lines" || !(view.GetComponent<UnityEngine.UI.Graphic>() is UnityEngine.UI.Image image))
|
||||
Fail("wiring", "the Map IsolineView is not on the Image named Gravity Lines");
|
||||
else if (image.material == null || image.material.shader.name != "UI/MaskedWorldSpaceUI")
|
||||
Fail("wiring", "Gravity Lines does not draw with a UI/MaskedWorldSpaceUI material");
|
||||
if (map == null || view.PoseCamera != map.MapOverlayCamera) Fail("wiring", "the Map IsolineView's PoseCamera is not MapRenderer.MapOverlayCamera");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (view.name != "Gravity Fields" || !(view.GetComponent<UnityEngine.UI.Graphic>() is UnityEngine.UI.RawImage raw))
|
||||
Fail("wiring", "the Minimap IsolineView is not on the RawImage named Gravity Fields");
|
||||
else if (raw.material.shader.name != "UI/Default")
|
||||
Fail("wiring", "Gravity Fields draws with a material other than UI/Default");
|
||||
var pose = renderer == null ? null : renderer.MinimapCameras.FirstOrDefault(c => c.targetTexture != null && c.targetTexture.name == "Minimap");
|
||||
if (pose == null || view.PoseCamera != pose) Fail("wiring", "the Minimap IsolineView's PoseCamera is not the minimap camera that targets Minimap");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void CheckWiring(GameSettings settings)
|
||||
{
|
||||
var scene = EditorSceneManager.OpenScene("Assets/Scenes/ARPG.unity", OpenSceneMode.Single);
|
||||
try
|
||||
{
|
||||
var gravityTargets = new[] { "Fog Surface Displacement", "Slime Gravity", "MinimapGravity" };
|
||||
var seen = 0;
|
||||
// The layer-9 cameras are exactly the fog's and the slime's: the isolines read no camera (cut isoline-wiring).
|
||||
var gravityTargets = new[] { "Fog Surface Displacement", "Slime Gravity" };
|
||||
var seen = new List<string>();
|
||||
foreach (var camera in UnityEngine.Object.FindObjectsByType<Camera>(FindObjectsInactive.Include, FindObjectsSortMode.None))
|
||||
{
|
||||
if (camera.targetTexture == null || !gravityTargets.Contains(camera.targetTexture.name)) continue;
|
||||
seen++;
|
||||
if (camera.cullingMask != 1 << GravityLowering.FieldLayer)
|
||||
Fail("wiring", $"camera {camera.name} (target {camera.targetTexture.name}) culls mask {camera.cullingMask}, not layer {GravityLowering.FieldLayer} alone");
|
||||
if (camera.name == "Map Gravity") Fail("wiring", "a camera named Map Gravity is back in ARPG.unity");
|
||||
if (camera.cullingMask != 1 << GravityLowering.FieldLayer) continue;
|
||||
seen.Add(camera.targetTexture != null ? camera.targetTexture.name : "(no target) " + camera.name);
|
||||
}
|
||||
if (seen < gravityTargets.Length) Fail("wiring", $"only {seen} gravity cameras found in ARPG.unity");
|
||||
if (seen.Count != gravityTargets.Length || gravityTargets.Any(t => !seen.Contains(t)))
|
||||
Fail("wiring", $"the layer-9 cameras are [{string.Join(", ", seen)}], not exactly [{string.Join(", ", gravityTargets)}]");
|
||||
|
||||
// The patch texture is half-float: it holds the patch layers only, the nebula reads gravity from the R32 surface.
|
||||
if (CheckPatchCameras("ARPG.unity") != 1) Fail("wiring", "ARPG.unity does not have exactly 1 Fog Patch Displacement camera");
|
||||
|
||||
// The map screen's gravity camera has no target until MapRenderer gives it one at run time.
|
||||
var map = UnityEngine.Object.FindFirstObjectByType<MapRenderer>(FindObjectsInactive.Include);
|
||||
if (map == null || map.GravityCamera == null) Fail("wiring", "no MapRenderer.GravityCamera in ARPG.unity");
|
||||
else if (map.GravityCamera.cullingMask != 1 << GravityLowering.FieldLayer)
|
||||
Fail("wiring", $"MapRenderer.GravityCamera culls mask {map.GravityCamera.cullingMask}, not layer {GravityLowering.FieldLayer} alone");
|
||||
|
||||
var renderer = UnityEngine.Object.FindFirstObjectByType<ZoneRenderer>(FindObjectsInactive.Include);
|
||||
CheckIsolineViews(map, renderer);
|
||||
if (renderer == null) Fail("wiring", "no ZoneRenderer in ARPG.unity");
|
||||
else if (renderer.GravityField == null || renderer.GravityField.shader.name != "Brushes/Gravity Field")
|
||||
Fail("wiring", "ZoneRenderer.GravityField is not a Brushes/Gravity Field material");
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@ namespace Aetheria.EditorTools
|
|||
/// contours and iso-angle rays into IsolineExtractor's buffer. Each check reads the buffer back (here only; the runtime
|
||||
/// never reads back) and compares it with what the field says: the real zone's own lowered terms, judged by Zone.GetHeight,
|
||||
/// and synthetic well sets whose answer is a formula over the same records (GravityField on the records read back from
|
||||
/// the buffer). It also writes before.png and segments.png (the minimap field through today's line shader, and the
|
||||
/// extracted segments over the same frame) and reports the cost of an extraction; neither is gated.
|
||||
/// the buffer). It also writes segments.png (the extracted segments over the real zone's 128 x 128 frame) and
|
||||
/// reports the cost of an extraction; neither is gated.
|
||||
///
|
||||
/// Renders and dispatches compute, so it needs a graphics device: run WITHOUT -nographics.
|
||||
/// Unity -batchmode -projectPath <repo> -executeMethod Aetheria.EditorTools.IsolineExtractSmoke.Run -logFile <path>
|
||||
|
|
@ -378,6 +378,7 @@ namespace Aetheria.EditorTools
|
|||
Guarded("along-line", AlongLine);
|
||||
Guarded("ray window", RayWindow);
|
||||
Guarded("overflow", Overflow);
|
||||
Guarded("capacity guard", CapacityGuard);
|
||||
|
||||
EditorSceneManager.OpenScene("Assets/Scenes/ARPG.unity", OpenSceneMode.Single);
|
||||
var settings = AssetDatabase.LoadAssetAtPath<GameSettings>("Assets/Resources/Settings.asset")
|
||||
|
|
@ -698,6 +699,22 @@ namespace Aetheria.EditorTools
|
|||
finally { Free(terms); }
|
||||
}
|
||||
|
||||
// The extractor's one capacity limit: the chain table may not pass 2^23 slots, so a capacity above 2^21 throws before
|
||||
// anything is allocated, and 2^21 itself constructs (finding cut-isoline-chain-arclength.s2.capacity-guard-unpinned).
|
||||
static void CapacityGuard()
|
||||
{
|
||||
const int Limit = 1 << 21;
|
||||
try
|
||||
{
|
||||
new IsolineExtractor(Shader, Limit + 1).Release();
|
||||
Fail("capacity guard", $"a capacity of {Limit + 1} constructed; the guard must refuse above {Limit}");
|
||||
}
|
||||
catch (ArgumentOutOfRangeException) { }
|
||||
try { new IsolineExtractor(Shader, Limit).Release(); }
|
||||
catch (ArgumentOutOfRangeException) { Fail("capacity guard", $"a capacity of {Limit} was refused"); }
|
||||
Info($"capacity guard: {Limit + 1} refused, {Limit} constructs");
|
||||
}
|
||||
|
||||
// ---- the analytic sample ----------------------------------------------------------------------------------------------
|
||||
|
||||
// Per sample of the grid: d against the law (truthD, Zone.GetHeight for the real zone; the CPU closed form over the same
|
||||
|
|
@ -729,37 +746,6 @@ namespace Aetheria.EditorTools
|
|||
|
||||
static Vector2 At(Orbit orbit) => new Vector2(orbit.Position.x, orbit.Position.y);
|
||||
|
||||
// Renders the field through a downward orthographic camera that culls layer 9 only; the world frame of the texels is
|
||||
// asked of the camera, as GravityFieldParityVerify does.
|
||||
static RenderTexture RenderField(Camera camera, int width, int height, out Vector2 origin, out Vector2 perTexel)
|
||||
{
|
||||
var target = new RenderTexture(width, height, 0, RenderTextureFormat.RFloat) { filterMode = FilterMode.Point };
|
||||
target.Create();
|
||||
var previousTarget = camera.targetTexture;
|
||||
var previousMask = camera.cullingMask;
|
||||
var previousClear = camera.clearFlags;
|
||||
var previousColor = camera.backgroundColor;
|
||||
camera.targetTexture = target;
|
||||
camera.cullingMask = 1 << GravityLowering.FieldLayer;
|
||||
camera.clearFlags = CameraClearFlags.SolidColor;
|
||||
camera.backgroundColor = Color.black;
|
||||
camera.allowHDR = false;
|
||||
camera.allowMSAA = false;
|
||||
camera.Render();
|
||||
Vector2 Texel(float x, float y)
|
||||
{
|
||||
var p = camera.ViewportToWorldPoint(new Vector3((x + .5f) / width, (y + .5f) / height, 100f));
|
||||
return new Vector2(p.x, p.z);
|
||||
}
|
||||
origin = Texel(0, 0);
|
||||
perTexel = new Vector2(Texel(1, 0).x - origin.x, Texel(0, 1).y - origin.y);
|
||||
camera.targetTexture = previousTarget;
|
||||
camera.cullingMask = previousMask;
|
||||
camera.clearFlags = previousClear;
|
||||
camera.backgroundColor = previousColor;
|
||||
return target;
|
||||
}
|
||||
|
||||
// The planet's family: sun, planet and planetoid in one 256 x 256 window; contours from depth 0 to the deepest body's
|
||||
// depth, as MapPresenter.Draw sets the map's range.
|
||||
static readonly Vector2 ZoneCentre = new Vector2(300f, -50f);
|
||||
|
|
@ -1047,32 +1033,9 @@ namespace Aetheria.EditorTools
|
|||
|
||||
static void CapturesAndCost(Zone zone, Orbit[] orbits, GravityLowering.GravityTerms terms)
|
||||
{
|
||||
// before.png: the ARPG scene's own Map Gravity camera draws the minimap field (as authored, 128 x 128, here over
|
||||
// the fixture zone), and Minimap Gravity Lines.mat draws it as it does today.
|
||||
var mapCamera = UnityEngine.Object.FindObjectsByType<Camera>(FindObjectsInactive.Include, FindObjectsSortMode.None)
|
||||
.FirstOrDefault(c => c.name == "Map Gravity") ?? throw new InvalidOperationException("No camera named Map Gravity in ARPG.unity.");
|
||||
var camera = mapCamera;
|
||||
camera.transform.position = new Vector3(ZoneCentre.x, camera.transform.position.y, ZoneCentre.y);
|
||||
var field = RenderField(camera, 128, 128, out var origin, out var perTexel);
|
||||
var linesAsset = AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI/Minimap Gravity Lines.mat")
|
||||
?? throw new InvalidOperationException("No Minimap Gravity Lines.mat.");
|
||||
// segments.png: the extracted segments over the real zone's 128 x 128 frame, contours cyan and rays magenta.
|
||||
TopFrame(ZoneCentre, ZoneHalf, 128, 128, out var origin, out var perTexel);
|
||||
var range = Math.Max(1f, orbits.Max(o => -zone.GetHeight(new float2(o.Position.x, o.Position.y))));
|
||||
var lines = new Material(linesAsset);
|
||||
lines.SetTexture("_DetailTex", field);
|
||||
lines.SetFloat("_StartDepth", 0f);
|
||||
lines.SetFloat("_DepthRange", range);
|
||||
var picture = new RenderTexture(CaptureSize, CaptureSize, 0, RenderTextureFormat.ARGB32);
|
||||
var previous = RenderTexture.active;
|
||||
RenderTexture.active = picture;
|
||||
GL.Clear(true, true, Color.black);
|
||||
Graphics.Blit(Texture2D.whiteTexture, picture, lines);
|
||||
var before = new Texture2D(CaptureSize, CaptureSize, TextureFormat.RGBA32, false);
|
||||
before.ReadPixels(new Rect(0, 0, CaptureSize, CaptureSize), 0, 0);
|
||||
before.Apply();
|
||||
RenderTexture.active = previous;
|
||||
File.WriteAllBytes(Path.Combine(_out, "before.png"), before.EncodeToPNG());
|
||||
|
||||
// segments.png: the extracted segments over the same frame, contours cyan and rays magenta.
|
||||
var levels = new IsolineExtractor.IsolineLevels(0f, range, SlopeEpsilon);
|
||||
var result = Extract(terms, origin, perTexel, new Vector2Int(128, 128), levels, 1 << 18);
|
||||
var raster = new Texture2D(CaptureSize, CaptureSize, TextureFormat.RGBA32, false);
|
||||
|
|
@ -1082,12 +1045,8 @@ namespace Aetheria.EditorTools
|
|||
Line(raster, Pixel(s.a), Pixel(s.b), IsRay(s.key) ? new Color32(255, 0, 220, 255) : new Color32(0, 170, 255, 255));
|
||||
raster.Apply();
|
||||
File.WriteAllBytes(Path.Combine(_out, "segments.png"), raster.EncodeToPNG());
|
||||
Info($"captures: {Path.Combine(_out, "before.png")}, {Path.Combine(_out, "segments.png")}; 128 x 128 field extracted {result.Written} segments (requested {result.Requested}), frame centre {ZoneCentre}, half {camera.orthographicSize}, range {range:G6}");
|
||||
UnityEngine.Object.DestroyImmediate(before);
|
||||
Info($"capture: {Path.Combine(_out, "segments.png")}; 128 x 128 field extracted {result.Written} segments (requested {result.Requested}), frame centre {ZoneCentre}, half {ZoneHalf}, range {range:G6}");
|
||||
UnityEngine.Object.DestroyImmediate(raster);
|
||||
UnityEngine.Object.DestroyImmediate(lines);
|
||||
picture.Release();
|
||||
UnityEngine.Object.DestroyImmediate(picture);
|
||||
|
||||
// cost: paired interleaved medians of one Extract at 128 x 128 and at 1920 x 1080, each timed to a fence (the
|
||||
// count read back). Wall clock around the recorded dispatches and the fence; the GPU recorder only advances
|
||||
|
|
@ -1130,8 +1089,6 @@ namespace Aetheria.EditorTools
|
|||
recorder.enabled = false;
|
||||
small.Release();
|
||||
large.Release();
|
||||
field.Release();
|
||||
UnityEngine.Object.DestroyImmediate(field);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,9 +28,10 @@ namespace Aetheria.EditorTools
|
|||
{
|
||||
const string Tag = "[IsolineRenderSmoke]";
|
||||
const float SlopeEpsilon = 1e-3f;
|
||||
// The shipped sizes: segments the extractor and the screen scratch hold, and tile-list entries the pool holds.
|
||||
const int ShippedSegments = 1 << 20;
|
||||
const int ShippedPool = 1 << 22;
|
||||
// The fixtures' sizes (hand-made segments, stress, tactical and flow): segments the extractor and the screen scratch hold,
|
||||
// and tile-list entries the pool holds. The views' own are GameSettings.MapIsolines and MinimapIsolines.
|
||||
const int FixtureSegments = 1 << 20;
|
||||
const int FixturePool = 1 << 22;
|
||||
|
||||
// Margin rule (lodur:ruling:deterministic-bound-margin): a bound sits at the geometric mean of the shipped reading and
|
||||
// the least claimed mutant's reading, at least 1.2 apart on each side. Each constant's comment gives both readings
|
||||
|
|
@ -43,6 +44,9 @@ namespace Aetheria.EditorTools
|
|||
const float PerspectiveSBound = 33.5f;
|
||||
const float WrongWayBound = 0.045f;
|
||||
const float FlowLagBound = 3.5f;
|
||||
// Cost gate (cut isoline-wiring): Extract plus Draw per view at its shipped settings, 1.2 x the readings of 08b1a13cd
|
||||
// (map 1920 x 1080 2.289 ms, minimap 0.329 ms; F:/aeth-wt/isoline-chain-g.IsolineRenderSmoke.log, GTX 1070 D3D11).
|
||||
const double MapCostBound = 2.75, MinimapCostBound = 0.40;
|
||||
|
||||
static bool _ok = true;
|
||||
static string _out;
|
||||
|
|
@ -282,7 +286,11 @@ namespace Aetheria.EditorTools
|
|||
Guarded("flow follows depth near the real-zone saddle", () => FlowOnRealZone(zone, orbits, terms));
|
||||
Guarded("dashes match true arclength", () => DashesMatchTrueArclength(zone, orbits, terms));
|
||||
Guarded("stress field and the shipped pool", StressAndPool);
|
||||
Guarded("captures and cost", () => CapturesAndCost(zone, orbits, terms));
|
||||
var views = new IsolineExtractor.IsolineLevels(0f, ContourRange(zone, orbits), SlopeEpsilon);
|
||||
Guarded("grid is world-anchored", () => GridIsWorldAnchored(settings, terms, views));
|
||||
Guarded("shipped capacities hold", () => ShippedCapacitiesHold(settings, terms, views));
|
||||
Guarded("overflow message", () => OverflowMessageNamesTheNumbers(settings, terms, views));
|
||||
Guarded("captures and cost", () => CapturesAndCost(zone, orbits, terms, settings));
|
||||
Info(_ok ? "PASS" : "FAIL: see errors above");
|
||||
}
|
||||
catch (Exception e)
|
||||
|
|
@ -567,7 +575,7 @@ namespace Aetheria.EditorTools
|
|||
static Frame RecordFrame(in GravityLowering.GravityTerms terms, Vector2 origin, Vector2 perTexel, Vector2Int size,
|
||||
IsolineExtractor.IsolineLevels levels, View view, IsolineLook look, string name, float time = 0f)
|
||||
{
|
||||
var renderer = new IsolineRenderer(ExtractShader, RenderShader, ShippedSegments, ShippedPool);
|
||||
var renderer = new IsolineRenderer(ExtractShader, RenderShader, FixtureSegments, FixturePool);
|
||||
var target = HalfTarget(view.W, view.H);
|
||||
try
|
||||
{
|
||||
|
|
@ -584,7 +592,7 @@ namespace Aetheria.EditorTools
|
|||
|
||||
static Seg[] ExtractThrough(in GravityLowering.GravityTerms terms, Vector2 origin, Vector2 perTexel, Vector2Int size, IsolineExtractor.IsolineLevels levels)
|
||||
{
|
||||
var extractor = new IsolineExtractor(ExtractShader, ShippedSegments);
|
||||
var extractor = new IsolineExtractor(ExtractShader, FixtureSegments);
|
||||
var command = new CommandBuffer { name = "IsolineSQuality" };
|
||||
try
|
||||
{
|
||||
|
|
@ -709,8 +717,8 @@ namespace Aetheria.EditorTools
|
|||
var rayLook = IsolineLook.Default;
|
||||
rayLook.Contour.W = 0f; rayLook.Contour.G = 0f; rayLook.Contour.Bloom = 0f; rayLook.Ray.Bloom = 0f;
|
||||
rayLook.Ray.Period = period; rayLook.Ray.Speed = speed;
|
||||
var shippedFrame = Draw(view, segs, rayLook, false, levels: levels, pool: ShippedPool);
|
||||
var referenceFrame = Draw(view, reference, rayLook, false, levels: levels, pool: ShippedPool);
|
||||
var shippedFrame = Draw(view, segs, rayLook, false, levels: levels, pool: FixturePool);
|
||||
var referenceFrame = Draw(view, reference, rayLook, false, levels: levels, pool: FixturePool);
|
||||
var shippedRuns = DashRuns(segs, chains, view, shippedFrame, ppx);
|
||||
var referenceRuns = DashRuns(segs, chains, view, referenceFrame, ppx);
|
||||
Info($"dashes {name} pose, loops included: run length px shipped {Pcts(DashRuns(segs, chains, view, shippedFrame, ppx, true))}; reference {Pcts(DashRuns(segs, chains, view, referenceFrame, ppx, true))}");
|
||||
|
|
@ -731,8 +739,8 @@ namespace Aetheria.EditorTools
|
|||
// the operator's pictures: Soul's flow pose in the default look, shipped and reference
|
||||
var flowLook = IsolineLook.Default;
|
||||
flowLook.Ray.Period = period; flowLook.Ray.Speed = speed;
|
||||
SaveFrame("flow-after.png", Draw(view, segs, flowLook, false, levels: levels, pool: ShippedPool));
|
||||
SaveFrame("flow-reference.png", Draw(view, reference, flowLook, false, levels: levels, pool: ShippedPool));
|
||||
SaveFrame("flow-after.png", Draw(view, segs, flowLook, false, levels: levels, pool: FixturePool));
|
||||
SaveFrame("flow-reference.png", Draw(view, reference, flowLook, false, levels: levels, pool: FixturePool));
|
||||
}
|
||||
}
|
||||
finally { view.Dispose(); }
|
||||
|
|
@ -1166,7 +1174,7 @@ namespace Aetheria.EditorTools
|
|||
// Rays only, over the real zone's saddle: raw dir against the depth change along +s judged by Zone.GetHeight.
|
||||
static void FlowOnRealZone(Zone zone, Orbit[] orbits, GravityLowering.GravityTerms terms)
|
||||
{
|
||||
var renderer = new IsolineRenderer(ExtractShader, RenderShader, ShippedSegments, ShippedPool);
|
||||
var renderer = new IsolineRenderer(ExtractShader, RenderShader, FixtureSegments, FixturePool);
|
||||
var view = Ortho(Saddle, 240f, 512, 512);
|
||||
var target = new RenderTexture(512, 512, 0, RenderTextureFormat.ARGBFloat, RenderTextureReadWrite.Linear) { enableRandomWrite = true, filterMode = FilterMode.Point };
|
||||
target.Create();
|
||||
|
|
@ -1259,7 +1267,7 @@ namespace Aetheria.EditorTools
|
|||
{
|
||||
var terms = IsolineExtractSmoke.WellsFrom(StressWells(out var range));
|
||||
var view = Ortho(new Vector2(960f, 540f), 540f, 1920, 1080);
|
||||
var renderer = new IsolineRenderer(ExtractShader, RenderShader, ShippedSegments, ShippedPool);
|
||||
var renderer = new IsolineRenderer(ExtractShader, RenderShader, FixtureSegments, FixturePool);
|
||||
var target = new RenderTexture(1920, 1080, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear) { enableRandomWrite = true };
|
||||
target.Create();
|
||||
var command = new CommandBuffer { name = "IsolineStress" };
|
||||
|
|
@ -1272,10 +1280,10 @@ namespace Aetheria.EditorTools
|
|||
var stats = new uint[6];
|
||||
renderer.Stats.GetData(stats);
|
||||
var (_, counts) = ReadExtraction(renderer.Extractor);
|
||||
Info($"stress 1920 x 1080: Stats [{string.Join(", ", stats)}], extraction Count [{counts[0]}, {counts[1]}] (capacity {ShippedSegments}), pool use {stats[1]} of {ShippedPool} ({stats[1] / (double)ShippedPool:P1})");
|
||||
Info($"stress 1920 x 1080: Stats [{string.Join(", ", stats)}], extraction Count [{counts[0]}, {counts[1]}] (capacity {FixtureSegments}), pool use {stats[1]} of {FixturePool} ({stats[1] / (double)FixturePool:P1})");
|
||||
if (stats[2] != 0) Fail("pool guard", $"the shipped pool truncated {stats[2]} entries at the stress field");
|
||||
if (stats[4] != counts[0] || stats[5] != counts[1]) Fail("pool guard", $"Stats[4..5] {stats[4]},{stats[5]} differ from the extractor's {counts[0]},{counts[1]}");
|
||||
if (counts[1] > ShippedSegments) Fail("pool guard", $"the stress field requests {counts[1]} segments > capacity {ShippedSegments}");
|
||||
if (counts[1] > FixtureSegments) Fail("pool guard", $"the stress field requests {counts[1]} segments > capacity {FixtureSegments}");
|
||||
Save("stress.png", target, 1920, 1080);
|
||||
}
|
||||
finally
|
||||
|
|
@ -1314,21 +1322,6 @@ namespace Aetheria.EditorTools
|
|||
Info($"wrote {path}");
|
||||
}
|
||||
|
||||
static void SaveBlit(string name, RenderTexture picture)
|
||||
{
|
||||
var read = new Texture2D(picture.width, picture.height, TextureFormat.RGBA32, false);
|
||||
var previous = RenderTexture.active;
|
||||
RenderTexture.active = picture;
|
||||
read.ReadPixels(new Rect(0, 0, picture.width, picture.height), 0, 0);
|
||||
read.Apply();
|
||||
RenderTexture.active = previous;
|
||||
var path = Path.Combine(_out, name);
|
||||
File.WriteAllBytes(path, read.EncodeToPNG());
|
||||
UnityEngine.Object.DestroyImmediate(read);
|
||||
_wrote += path + "\n";
|
||||
Info($"wrote {path}");
|
||||
}
|
||||
|
||||
static RenderTexture HalfTarget(int w, int h)
|
||||
{
|
||||
var t = new RenderTexture(w, h, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear) { enableRandomWrite = true };
|
||||
|
|
@ -1336,134 +1329,239 @@ namespace Aetheria.EditorTools
|
|||
return t;
|
||||
}
|
||||
|
||||
static void CapturesAndCost(Zone zone, Orbit[] orbits, GravityLowering.GravityTerms terms)
|
||||
// The pose cameras are ARPG.unity's own (cut isoline-wiring): the map screen's MapOverlayCamera and the minimap camera whose
|
||||
// target is Minimap. A pose is a position over a world point, a half height and an aspect; everything else is the scene's.
|
||||
static Camera MapPoseCamera() => UnityEngine.Object.FindFirstObjectByType<MapRenderer>(FindObjectsInactive.Include)?.MapOverlayCamera
|
||||
?? throw new InvalidOperationException("No MapRenderer.MapOverlayCamera in ARPG.unity.");
|
||||
|
||||
static Camera MinimapPoseCamera() => UnityEngine.Object.FindFirstObjectByType<ZoneRenderer>(FindObjectsInactive.Include)?.MinimapCameras
|
||||
.FirstOrDefault(c => c.targetTexture != null && c.targetTexture.name == "Minimap")
|
||||
?? throw new InvalidOperationException("No minimap camera targeting Minimap in ARPG.unity.");
|
||||
|
||||
static Camera Pose(Camera camera, Vector2 centre, float halfHeight, float aspect)
|
||||
{
|
||||
camera.transform.position = new Vector3(centre.x, camera.transform.position.y, centre.y);
|
||||
camera.orthographicSize = halfHeight;
|
||||
camera.aspect = aspect;
|
||||
return camera;
|
||||
}
|
||||
|
||||
static Matrix4x4 ViewProjection(Camera camera) => GL.GetGPUProjectionMatrix(camera.projectionMatrix, true) * camera.worldToCameraMatrix;
|
||||
|
||||
// One view's frame as IsolineView draws it: the pose camera's grid at the view's CellPixels and its view-projection.
|
||||
sealed class ViewFrame
|
||||
{
|
||||
public Vector2 Origin, PerTexel;
|
||||
public Vector2Int Size;
|
||||
public Matrix4x4 ViewProjection;
|
||||
}
|
||||
|
||||
static ViewFrame FrameOf(Camera camera, Vector2Int target, int cellPixels)
|
||||
{
|
||||
IsolineView.Grid(camera, target, cellPixels, out var origin, out var perTexel, out var size);
|
||||
return new ViewFrame { Origin = origin, PerTexel = perTexel, Size = size, ViewProjection = ViewProjection(camera) };
|
||||
}
|
||||
|
||||
static void RecordFrame(IsolineRenderer renderer, in GravityLowering.GravityTerms terms, ViewFrame frame, IsolineExtractor.IsolineLevels levels,
|
||||
RenderTexture target, IsolineLook look, float time = 0f)
|
||||
{
|
||||
var command = new CommandBuffer { name = "IsolineFrame" };
|
||||
renderer.Record(command, terms, frame.Origin, frame.PerTexel, frame.Size, levels, frame.ViewProjection, target, look, time);
|
||||
Graphics.ExecuteCommandBuffer(command);
|
||||
command.Release();
|
||||
}
|
||||
|
||||
// Stats of a view's frame at a pose on a renderer of the given capacities. Requested counts (Stats[5] segments, Stats[0] tile
|
||||
// entries) keep counting past a capacity, so any capacity reads them.
|
||||
static uint[] PoseStats(Camera camera, Vector2Int target, GameSettings.IsolineViewSettings view, in GravityLowering.GravityTerms terms,
|
||||
IsolineExtractor.IsolineLevels levels, int segmentCapacity, int poolCapacity)
|
||||
{
|
||||
var renderer = new IsolineRenderer(ExtractShader, RenderShader, segmentCapacity, poolCapacity);
|
||||
var picture = HalfTarget(target.x, target.y);
|
||||
try
|
||||
{
|
||||
RecordFrame(renderer, terms, FrameOf(camera, target, view.CellPixels), levels, picture, view.Look);
|
||||
var stats = new uint[6];
|
||||
renderer.Stats.GetData(stats);
|
||||
return stats;
|
||||
}
|
||||
finally
|
||||
{
|
||||
renderer.Release();
|
||||
picture.Release();
|
||||
UnityEngine.Object.DestroyImmediate(picture);
|
||||
}
|
||||
}
|
||||
|
||||
// Per view at its largest pose (map 3840 x 2160, minimap 256 x 256) on the real zone: the requested segments and tile entries
|
||||
// fit within half of the capacities Settings.asset ships, so a pan or a zoom never reaches them. Logs the readings the
|
||||
// capacities were sized from (the next power of two at or above twice each).
|
||||
static void ShippedCapacitiesHold(GameSettings settings, GravityLowering.GravityTerms terms, IsolineExtractor.IsolineLevels levels)
|
||||
{
|
||||
var map = settings.MapIsolines;
|
||||
var mini = settings.MinimapIsolines;
|
||||
var mapStats = PoseStats(Pose(MapPoseCamera(), ZoneCentre, 1100f, 16f / 9f), new Vector2Int(3840, 2160), map, terms, levels, map.SegmentCapacity, map.PoolCapacity);
|
||||
var miniStats = PoseStats(Pose(MinimapPoseCamera(), ZoneCentre, 1000f, 1f), new Vector2Int(256, 256), mini, terms, levels, mini.SegmentCapacity, mini.PoolCapacity);
|
||||
static long Pow2(uint v) { long p = 1; while (p < 2L * v) p <<= 1; return p; }
|
||||
Info($"shipped capacities: map 3840 x 2160 requested segments {mapStats[5]} (capacity {map.SegmentCapacity}, sizing rule gives {Pow2(mapStats[5])}), tile entries {mapStats[0]} (pool {map.PoolCapacity}, rule {Pow2(mapStats[0])}); " +
|
||||
$"minimap 256 x 256 requested segments {miniStats[5]} (capacity {mini.SegmentCapacity}, rule {Pow2(miniStats[5])}), tile entries {miniStats[0]} (pool {mini.PoolCapacity}, rule {Pow2(miniStats[0])})");
|
||||
void Hold(string view, uint[] stats, GameSettings.IsolineViewSettings v)
|
||||
{
|
||||
if (stats[5] > v.SegmentCapacity / 2) Fail("shipped capacities hold", $"{view}: {stats[5]} requested segments exceed half the segment capacity {v.SegmentCapacity}");
|
||||
if (stats[0] > v.PoolCapacity / 2) Fail("shipped capacities hold", $"{view}: {stats[0]} tile entries exceed half the pool {v.PoolCapacity}");
|
||||
var message = IsolineView.OverflowMessage(stats, v.SegmentCapacity, v.PoolCapacity);
|
||||
if (message != null) Fail("overflow message", $"{view}: a shipped reading overflowed: {message}");
|
||||
}
|
||||
Hold("map", mapStats, map);
|
||||
Hold("minimap", miniStats, mini);
|
||||
}
|
||||
|
||||
// OverflowMessage over the real zone, once with a renderer of segment capacity 100 (pool ample, so only the extraction overflows) and
|
||||
// once with a pool of 100 (segments ample): each names requested, written, truncated and both capacities. A message that
|
||||
// compared written to the segment capacity (written never passes it) would read null for the first.
|
||||
static void OverflowMessageNamesTheNumbers(GameSettings settings, GravityLowering.GravityTerms terms, IsolineExtractor.IsolineLevels levels)
|
||||
{
|
||||
var camera = Pose(MinimapPoseCamera(), ZoneCentre, 1000f, 1f);
|
||||
var target = new Vector2Int(256, 256);
|
||||
var view = settings.MinimapIsolines;
|
||||
var segments = PoseStats(camera, target, view, terms, levels, 100, 1 << 20);
|
||||
var segmentMessage = IsolineView.OverflowMessage(segments, 100, 1 << 20);
|
||||
Info($"overflow message at segment capacity 100: Stats [{string.Join(", ", segments)}]: {segmentMessage ?? "(null)"}");
|
||||
if (segments[2] != 0 || segments[4] != 100) Fail("overflow message", $"the segment fixture is vacuous: truncated {segments[2]}, written {segments[4]}");
|
||||
if (segmentMessage == null) Fail("overflow message", "a renderer of segment capacity 100 over the real zone read as no overflow");
|
||||
else foreach (var number in new uint[] { segments[5], segments[4], 100 })
|
||||
if (!segmentMessage.Contains(number.ToString())) Fail("overflow message", $"the segment message does not name {number}: {segmentMessage}");
|
||||
var pool = PoseStats(camera, target, view, terms, levels, 1 << 18, 100);
|
||||
var poolMessage = IsolineView.OverflowMessage(pool, 1 << 18, 100);
|
||||
Info($"overflow message at pool 100: Stats [{string.Join(", ", pool)}]: {poolMessage ?? "(null)"}");
|
||||
if (pool[2] == 0) Fail("overflow message", "the pool fixture is vacuous: nothing was truncated");
|
||||
if (poolMessage == null) Fail("overflow message", "a pool of 100 over the real zone read as no overflow");
|
||||
else foreach (var number in new uint[] { pool[0], pool[1], pool[2], 100 })
|
||||
if (!poolMessage.Contains(number.ToString())) Fail("overflow message", $"the pool message does not name {number}: {poolMessage}");
|
||||
}
|
||||
|
||||
// The grid is anchored to the world lattice of its step, so a pan moves no contour: the same pose and the pose moved by
|
||||
// (0.37, 0.61) of a step give the same segments wherever both grids reach, compared bit for bit on a, b, depths, slopes and
|
||||
// key (s is a chain property and cell a grid index: both depend on where a grid ends). Shipped reads 0 differing; the mutant
|
||||
// takes its origin from the camera frame's first pixel centre without the snap and must read more.
|
||||
static void GridIsWorldAnchored(GameSettings settings, GravityLowering.GravityTerms terms, IsolineExtractor.IsolineLevels levels)
|
||||
{
|
||||
var view = settings.MapIsolines;
|
||||
var target = new Vector2Int(1920, 1080);
|
||||
var camera = MapPoseCamera();
|
||||
var extractor = new IsolineExtractor(ExtractShader, FixtureSegments);
|
||||
try
|
||||
{
|
||||
void GridAt(Vector2 centre, bool snap, out Vector2 origin, out Vector2 perTexel, out Vector2Int size)
|
||||
{
|
||||
Pose(camera, centre, 1100f, 16f / 9f);
|
||||
IsolineView.Grid(camera, target, view.CellPixels, out origin, out perTexel, out size);
|
||||
if (snap) return;
|
||||
var first = camera.ViewportToWorldPoint(new Vector3(.5f / target.x, .5f / target.y, 100f));
|
||||
origin = new Vector2(first.x, first.z);
|
||||
}
|
||||
(Vector2 lo, Vector2 hi) Reach(Vector2 o, Vector2 p, Vector2Int n)
|
||||
{
|
||||
var end = o + new Vector2((n.x - 1) * p.x, (n.y - 1) * p.y);
|
||||
return (Vector2.Min(o, end), Vector2.Max(o, end));
|
||||
}
|
||||
HashSet<(Vector4, Vector4, uint)> Inside(Vector2 o, Vector2 p, Vector2Int n, Vector2 lo, Vector2 hi)
|
||||
{
|
||||
var command = new CommandBuffer { name = "IsolineAnchored" };
|
||||
extractor.Extract(command, terms, o, p, n, levels);
|
||||
Graphics.ExecuteCommandBuffer(command);
|
||||
command.Release();
|
||||
var (segments, _) = ReadExtraction(extractor);
|
||||
bool In(Vector2 q) => q.x >= lo.x && q.x <= hi.x && q.y >= lo.y && q.y <= hi.y;
|
||||
return new HashSet<(Vector4, Vector4, uint)>(segments.Where(s => In(s.a) && In(s.b))
|
||||
.Select(s => (new Vector4(s.a.x, s.a.y, s.b.x, s.b.y), new Vector4(s.depthA, s.depthB, s.slopeA, s.slopeB), s.key)));
|
||||
}
|
||||
int Differing(bool snap)
|
||||
{
|
||||
GridAt(ZoneCentre, snap, out var o1, out var p1, out var n1);
|
||||
GridAt(ZoneCentre + new Vector2(.37f * Mathf.Abs(p1.x), .61f * Mathf.Abs(p1.y)), snap, out var o2, out var p2, out var n2);
|
||||
var r1 = Reach(o1, p1, n1);
|
||||
var r2 = Reach(o2, p2, n2);
|
||||
var lo = Vector2.Max(r1.lo, r2.lo);
|
||||
var hi = Vector2.Min(r1.hi, r2.hi);
|
||||
var a = Inside(o1, p1, n1, lo, hi);
|
||||
var b = Inside(o2, p2, n2, lo, hi);
|
||||
var differing = a.Count(x => !b.Contains(x)) + b.Count(x => !a.Contains(x));
|
||||
Info($"grid anchor ({(snap ? "shipped" : "no-snap mutant")}): {a.Count} and {b.Count} segments inside both grids, {differing} differing");
|
||||
if (a.Count < 1000) Fail("grid is world-anchored", $"only {a.Count} segments lie inside both grids: the fixture is vacuous");
|
||||
return differing;
|
||||
}
|
||||
var shipped = Differing(true);
|
||||
if (shipped != 0) Fail("grid is world-anchored", $"{shipped} segments differ between a pose and the pose moved by a fraction of a step");
|
||||
if (Differing(false) == 0) Fail("grid is world-anchored", "the no-snap mutant reads 0 differing: the fixture does not separate it");
|
||||
}
|
||||
finally { extractor.Release(); }
|
||||
}
|
||||
|
||||
static void CapturesAndCost(Zone zone, Orbit[] orbits, GravityLowering.GravityTerms terms, GameSettings settings)
|
||||
{
|
||||
var range = ContourRange(zone, orbits);
|
||||
var levels = new IsolineExtractor.IsolineLevels(0f, range, SlopeEpsilon);
|
||||
var look = IsolineLook.Default;
|
||||
var minimapMaterial = AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI/Minimap Gravity Lines.mat") ?? throw new InvalidOperationException("No Minimap Gravity Lines.mat.");
|
||||
var mapMaterial = AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI/Map Gravity Lines.mat") ?? throw new InvalidOperationException("No Map Gravity Lines.mat.");
|
||||
var map = settings.MapIsolines;
|
||||
var mini = settings.MinimapIsolines;
|
||||
|
||||
// minimap: the ARPG scene's own Map Gravity camera draws the 128 x 128 field over the fixture zone
|
||||
var sceneCamera = UnityEngine.Object.FindObjectsByType<Camera>(FindObjectsInactive.Include, FindObjectsSortMode.None)
|
||||
.FirstOrDefault(c => c.name == "Map Gravity") ?? throw new InvalidOperationException("No camera named Map Gravity in ARPG.unity.");
|
||||
sceneCamera.transform.position = new Vector3(ZoneCentre.x, sceneCamera.transform.position.y, ZoneCentre.y);
|
||||
var minimapField = RenderField(sceneCamera, 128, 128, out var miniOrigin, out var miniPerTexel);
|
||||
sceneCamera.aspect = 1f; // the minimap camera renders into a square texture; its matrices must say so off-target too
|
||||
Blit(minimapMaterial, minimapField, 256, 256, range, 10f, "minimap-before.png");
|
||||
var miniRenderer = new IsolineRenderer(ExtractShader, RenderShader, ShippedSegments, ShippedPool);
|
||||
// minimap: the ARPG scene's own minimap pose over the fixture zone, a 256 x 256 target at the shipped settings
|
||||
var miniFrame = FrameOf(Pose(MinimapPoseCamera(), ZoneCentre, 1000f, 1f), new Vector2Int(256, 256), mini.CellPixels);
|
||||
var miniRenderer = new IsolineRenderer(ExtractShader, RenderShader, mini.SegmentCapacity, mini.PoolCapacity);
|
||||
var miniTarget = HalfTarget(256, 256);
|
||||
var miniVp = GL.GetGPUProjectionMatrix(sceneCamera.projectionMatrix, true) * sceneCamera.worldToCameraMatrix;
|
||||
RecordAndSave(miniRenderer, terms, miniOrigin, miniPerTexel, new Vector2Int(128, 128), levels, miniVp, miniTarget, look, "minimap-after.png");
|
||||
RecordFrame(miniRenderer, terms, miniFrame, levels, miniTarget, mini.Look);
|
||||
Save("minimap-after.png", miniTarget, 256, 256);
|
||||
|
||||
// map screen: a screen-sized field over the same zone, ortho size = height * Scale / 2, material _Scale = Scale / 2
|
||||
var mapView = Ortho(ZoneCentre, 1100f, 1920, 1080);
|
||||
var mapField = RenderField(mapView.Camera, 1920, 1080, out var mapOrigin, out var mapPerTexel);
|
||||
var mapScale = 2200f / 1080f;
|
||||
Blit(mapMaterial, mapField, 1920, 1080, range, mapScale / 2f, "map-before.png");
|
||||
var mapRenderer = new IsolineRenderer(ExtractShader, RenderShader, ShippedSegments, ShippedPool);
|
||||
// map screen: a 1920 x 1080 target at the shipped settings, 2200 u over the height
|
||||
var mapFrame = FrameOf(Pose(MapPoseCamera(), ZoneCentre, 1100f, 1920f / 1080f), new Vector2Int(1920, 1080), map.CellPixels);
|
||||
var mapRenderer = new IsolineRenderer(ExtractShader, RenderShader, map.SegmentCapacity, map.PoolCapacity);
|
||||
var mapTarget = HalfTarget(1920, 1080);
|
||||
RecordAndSave(mapRenderer, terms, mapOrigin, mapPerTexel, new Vector2Int(1920, 1080), levels, mapView.ViewProjection, mapTarget, look, "map-after.png");
|
||||
var (mapSegments, mapCounts) = ReadExtraction(mapRenderer.Extractor);
|
||||
RecordFrame(mapRenderer, terms, mapFrame, levels, mapTarget, map.Look);
|
||||
Save("map-after.png", mapTarget, 1920, 1080);
|
||||
var (_, mapCounts) = ReadExtraction(mapRenderer.Extractor);
|
||||
var mapStats = new uint[6];
|
||||
mapRenderer.Stats.GetData(mapStats);
|
||||
Info($"map 1920 x 1080 real zone: Stats [{string.Join(", ", mapStats)}], extraction Count [{mapCounts[0]}, {mapCounts[1]}] (capacity {ShippedSegments}); pool use {mapStats[1]} of {ShippedPool}");
|
||||
if (mapStats[2] != 0 || mapCounts[1] > ShippedSegments) Fail("pool guard", $"map: truncated {mapStats[2]}, requested {mapCounts[1]}");
|
||||
Info($"map 1920 x 1080 real zone: Stats [{string.Join(", ", mapStats)}], extraction Count [{mapCounts[0]}, {mapCounts[1]}] (capacity {map.SegmentCapacity}); pool use {mapStats[1]} of {map.PoolCapacity}");
|
||||
if (mapStats[2] != 0 || mapCounts[1] > map.SegmentCapacity) Fail("pool guard", $"map: truncated {mapStats[2]}, requested {mapCounts[1]}");
|
||||
if (mapStats[4] != mapCounts[0] || mapStats[5] != mapCounts[1]) Fail("pool guard", "map: Stats[4..5] differ from the extractor's Count");
|
||||
|
||||
// tactical: the follow lens at pitch 55 over the zone, from a 1024 x 1024 field of it
|
||||
// tactical: the follow lens at pitch 55 over the zone, from a 1024 x 1024 field of it (a fixture renderer: not a shipped view yet)
|
||||
var fixture = new IsolineRenderer(ExtractShader, RenderShader, FixtureSegments, FixturePool);
|
||||
var tacticalCamera = Ortho(ZoneCentre, ZoneHalf, 1024, 1024);
|
||||
var tacticalField = RenderField(tacticalCamera.Camera, 1024, 1024, out var tOrigin, out var tPerTexel);
|
||||
var tacticalView = Tactical(new Vector2(380f, -100f), 900f, 55f, 20f, 1280, 720);
|
||||
var tacticalTarget = HalfTarget(1280, 720);
|
||||
RecordAndSave(mapRenderer, terms, tOrigin, tPerTexel, new Vector2Int(1024, 1024), levels, tacticalView.ViewProjection, tacticalTarget, look, "tactical.png");
|
||||
RecordAndSave(fixture, terms, tOrigin, tPerTexel, new Vector2Int(1024, 1024), levels, tacticalView.ViewProjection, tacticalTarget, IsolineLook.Default, "tactical.png");
|
||||
|
||||
// flowing rays: six phases of one dash period around the saddle, from a 512 x 512 field
|
||||
var flowView = Ortho(Saddle, 300f, 512, 512);
|
||||
var flowField = RenderField(flowView.Camera, 512, 512, out var fOrigin, out var fPerTexel);
|
||||
var flowLook = look;
|
||||
var flowLook = mini.Look;
|
||||
flowLook.Ray.Period = 60f;
|
||||
flowLook.Ray.Speed = 1f;
|
||||
var flowTarget = HalfTarget(512, 512);
|
||||
var flowRenderer = new IsolineRenderer(ExtractShader, RenderShader, ShippedSegments, ShippedPool);
|
||||
for (var phase = 0; phase < 6; phase++)
|
||||
RecordAndSave(flowRenderer, terms, fOrigin, fPerTexel, new Vector2Int(512, 512), levels, flowView.ViewProjection, flowTarget, flowLook, $"flow-{phase}.png", phase / 6f);
|
||||
RecordAndSave(fixture, terms, fOrigin, fPerTexel, new Vector2Int(512, 512), levels, flowView.ViewProjection, flowTarget, flowLook, $"flow-{phase}.png", phase / 6f);
|
||||
|
||||
Info($"cost camera field render (the path the extractor replaces), wall clock to a fence, median of 31: 128 x 128 {FieldRenderMs(sceneCamera, 128, 128):F3} ms; 1920 x 1080 {FieldRenderMs(mapView.Camera, 1920, 1080):F3} ms");
|
||||
Cost("256 x 256 (minimap)", miniRenderer, terms, new Vector2Int(128, 128), minimapField, miniOrigin, miniPerTexel, levels, miniVp, miniTarget, look, minimapMaterial, 10f, range);
|
||||
Cost("1920 x 1080 (map)", mapRenderer, terms, new Vector2Int(1920, 1080), mapField, mapOrigin, mapPerTexel, levels, mapView.ViewProjection, mapTarget, look, mapMaterial, mapScale / 2f, range);
|
||||
Info("old path at 08b1a13cd (F:\\aeth-wt\\isoline-chain-g.IsolineRenderSmoke.log, GTX 1070 D3D11): map camera field 1.188 + blit 0.378 = 1.566 ms; minimap 0.383 + 0.079 = 0.462 ms; new path at that commit: map Extract 1.234 + renderer 1.055 = 2.289 ms, minimap 0.167 + 0.162 = 0.329 ms");
|
||||
var miniCost = Cost("256 x 256 (minimap)", miniRenderer, terms, miniFrame, levels, miniTarget, mini.Look);
|
||||
var mapCost = Cost("1920 x 1080 (map)", mapRenderer, terms, mapFrame, levels, mapTarget, map.Look);
|
||||
if (mapCost > MapCostBound) Fail("cost gate", $"map Extract plus Draw {mapCost:F3} ms > {MapCostBound} ms");
|
||||
if (miniCost > MinimapCostBound) Fail("cost gate", $"minimap Extract plus Draw {miniCost:F3} ms > {MinimapCostBound} ms");
|
||||
var stressTerms = IsolineExtractSmoke.WellsFrom(StressWells(out var stressRange));
|
||||
var stressField = RenderField(mapView.Camera, 1920, 1080, out _, out _); // the old material's input; it only times the blit
|
||||
var stressView = Ortho(new Vector2(960f, 540f), 540f, 1920, 1080);
|
||||
Cost("1920 x 1080 (stress)", mapRenderer, stressTerms, new Vector2Int(1920, 1080), stressField, new Vector2(.5f, .5f), Vector2.one,
|
||||
new IsolineExtractor.IsolineLevels(0f, stressRange, SlopeEpsilon), stressView.ViewProjection, mapTarget, look, mapMaterial, mapScale / 2f, stressRange);
|
||||
var stressFrame = new ViewFrame { Origin = new Vector2(.5f, .5f), PerTexel = Vector2.one, Size = new Vector2Int(1920, 1080), ViewProjection = stressView.ViewProjection };
|
||||
Cost("1920 x 1080 (stress, reported not gated)", fixture, stressTerms, stressFrame, new IsolineExtractor.IsolineLevels(0f, stressRange, SlopeEpsilon), mapTarget, IsolineLook.Default);
|
||||
stressTerms.Buffer.Release();
|
||||
Info("captures:\n" + _wrote);
|
||||
|
||||
foreach (var r in new[] { miniRenderer, mapRenderer, flowRenderer }) r.Release();
|
||||
foreach (var t in new[] { miniTarget, mapTarget, tacticalTarget, flowTarget, minimapField, mapField, tacticalField, flowField, stressField })
|
||||
foreach (var r in new[] { miniRenderer, mapRenderer, fixture }) r.Release();
|
||||
foreach (var t in new[] { miniTarget, mapTarget, tacticalTarget, flowTarget, tacticalField, flowField })
|
||||
{
|
||||
t.Release();
|
||||
UnityEngine.Object.DestroyImmediate(t);
|
||||
}
|
||||
mapView.Dispose(); tacticalCamera.Dispose(); tacticalView.Dispose(); flowView.Dispose(); stressView.Dispose();
|
||||
}
|
||||
|
||||
// Wall clock of one camera render of the gravity field (the path the extractor replaces) into an RFloat target of the same
|
||||
// size, timed to a 1 pixel readback: median of 31 after 2 warm-ups.
|
||||
static double FieldRenderMs(Camera camera, int w, int h)
|
||||
{
|
||||
var target = new RenderTexture(w, h, 0, RenderTextureFormat.RFloat) { filterMode = FilterMode.Point };
|
||||
target.Create();
|
||||
var previousTarget = camera.targetTexture;
|
||||
var previousMask = camera.cullingMask;
|
||||
var previousClear = camera.clearFlags;
|
||||
var previousColour = camera.backgroundColor;
|
||||
camera.targetTexture = target;
|
||||
camera.cullingMask = 1 << GravityLowering.FieldLayer;
|
||||
camera.clearFlags = CameraClearFlags.SolidColor;
|
||||
camera.backgroundColor = Color.black;
|
||||
var one = new Texture2D(1, 1, TextureFormat.RFloat, false);
|
||||
var times = new List<double>();
|
||||
for (var i = -2; i < 31; i++)
|
||||
{
|
||||
var clock = Stopwatch.StartNew();
|
||||
camera.Render();
|
||||
var previous = RenderTexture.active;
|
||||
RenderTexture.active = target;
|
||||
one.ReadPixels(new Rect(0, 0, 1, 1), 0, 0);
|
||||
RenderTexture.active = previous;
|
||||
clock.Stop();
|
||||
if (i >= 0) times.Add(clock.Elapsed.TotalMilliseconds);
|
||||
}
|
||||
camera.targetTexture = previousTarget;
|
||||
camera.cullingMask = previousMask;
|
||||
camera.clearFlags = previousClear;
|
||||
camera.backgroundColor = previousColour;
|
||||
UnityEngine.Object.DestroyImmediate(one);
|
||||
target.Release();
|
||||
UnityEngine.Object.DestroyImmediate(target);
|
||||
return Median(times);
|
||||
}
|
||||
|
||||
// Today's look: the field through a gravity-lines material into an ARGB32 target.
|
||||
static void Blit(Material asset, RenderTexture field, int w, int h, float range, float scale, string name)
|
||||
{
|
||||
var lines = new Material(asset);
|
||||
lines.SetTexture("_DetailTex", field);
|
||||
lines.SetFloat("_StartDepth", 0f);
|
||||
lines.SetFloat("_DepthRange", range);
|
||||
lines.SetFloat("_Scale", scale);
|
||||
var picture = new RenderTexture(w, h, 0, RenderTextureFormat.ARGB32);
|
||||
var previous = RenderTexture.active;
|
||||
RenderTexture.active = picture;
|
||||
GL.Clear(true, true, Color.black);
|
||||
Graphics.Blit(Texture2D.whiteTexture, picture, lines);
|
||||
RenderTexture.active = previous;
|
||||
SaveBlit(name, picture);
|
||||
picture.Release();
|
||||
UnityEngine.Object.DestroyImmediate(picture);
|
||||
UnityEngine.Object.DestroyImmediate(lines);
|
||||
tacticalCamera.Dispose(); tacticalView.Dispose(); flowView.Dispose(); stressView.Dispose();
|
||||
}
|
||||
|
||||
static void RecordAndSave(IsolineRenderer renderer, in GravityLowering.GravityTerms terms, Vector2 origin, Vector2 perTexel, Vector2Int size,
|
||||
|
|
@ -1476,29 +1574,22 @@ namespace Aetheria.EditorTools
|
|||
Save(name, target, target.width, target.height);
|
||||
}
|
||||
|
||||
// GPU time per kernel and Extract. The recorder reads 0 in batchmode (no frame loop), so each pass is timed to a fence
|
||||
// (a Stats readback) on the wall clock: the kernels are recorded as prefixes (0..6 of Args Clear Bin Scan Scatter Shade),
|
||||
// each prefix repeated Reps times in one command buffer, and a kernel's cost is the paired difference of two
|
||||
// neighbouring prefixes in the same iteration. Median of 31 interleaved iterations, ms per pass; the old material blit
|
||||
// at the same size is timed beside them through a 1 pixel readback.
|
||||
static void Cost(string label, IsolineRenderer renderer, GravityLowering.GravityTerms terms, Vector2Int size, RenderTexture field, Vector2 origin, Vector2 perTexel,
|
||||
IsolineExtractor.IsolineLevels levels, Matrix4x4 viewProjection, RenderTexture target, IsolineLook look,
|
||||
Material oldMaterial, float oldScale, float oldRange)
|
||||
// GPU time per kernel, Extract and Extract plus Draw at a view's shipped settings. The recorder reads 0 in batchmode (no frame
|
||||
// loop), so each pass is timed to a fence (a Stats readback) on the wall clock: the kernels are recorded as prefixes (0..6 of
|
||||
// Args Clear Bin Scan Scatter Shade), each prefix repeated Reps times in one command buffer, and a kernel's cost is the paired
|
||||
// difference of two neighbouring prefixes in the same iteration. Median of 31 interleaved iterations, ms per pass. Returns the
|
||||
// Extract median plus the renderer total, the definition of the 08b1a13cd readings the gate is set from (each one fenced);
|
||||
// the same two recorded in one pass (renderer.Record, one fence) are reported beside it.
|
||||
static double Cost(string label, IsolineRenderer renderer, GravityLowering.GravityTerms terms, ViewFrame frame, IsolineExtractor.IsolineLevels levels,
|
||||
RenderTexture target, IsolineLook look)
|
||||
{
|
||||
const int Reps = 8, Iterations = 31;
|
||||
var blitTarget = new RenderTexture(target.width, target.height, 0, RenderTextureFormat.ARGB32);
|
||||
var lines = new Material(oldMaterial);
|
||||
lines.SetTexture("_DetailTex", field);
|
||||
lines.SetFloat("_StartDepth", 0f);
|
||||
lines.SetFloat("_DepthRange", oldRange);
|
||||
lines.SetFloat("_Scale", oldScale);
|
||||
var one = new Texture2D(1, 1, TextureFormat.RGBA32, false);
|
||||
var recorder = Recorder.Get("IsolineRender");
|
||||
recorder.enabled = true;
|
||||
var scratch = new uint[6];
|
||||
// fill the buffers once so the kernel prefixes have segments
|
||||
var fill = new CommandBuffer();
|
||||
renderer.Extractor.Extract(fill, terms, origin, perTexel, size, levels);
|
||||
renderer.Extractor.Extract(fill, terms, frame.Origin, frame.PerTexel, frame.Size, levels);
|
||||
Graphics.ExecuteCommandBuffer(fill);
|
||||
fill.Release();
|
||||
|
||||
|
|
@ -1514,30 +1605,23 @@ namespace Aetheria.EditorTools
|
|||
return clock.Elapsed.TotalMilliseconds / Reps;
|
||||
}
|
||||
void StatsFence() => renderer.Stats.GetData(scratch);
|
||||
void PixelFence()
|
||||
{
|
||||
var previous = RenderTexture.active;
|
||||
RenderTexture.active = blitTarget;
|
||||
one.ReadPixels(new Rect(0, 0, 1, 1), 0, 0);
|
||||
RenderTexture.active = previous;
|
||||
}
|
||||
var prefixes = Enumerable.Range(0, 7).Select(_ => new List<double>()).ToArray();
|
||||
var extract = new List<double>();
|
||||
var blit = new List<double>();
|
||||
var full = new List<double>();
|
||||
var sampleAlone = new List<double>();
|
||||
for (var iteration = -2; iteration < Iterations; iteration++)
|
||||
{
|
||||
for (var k = 0; k <= 6; k++)
|
||||
{
|
||||
var stop = k;
|
||||
var t = Time(c => renderer.Draw(c, renderer.Extractor.Segments, renderer.Extractor.Count, levels, viewProjection, target, look, 0f, false, 0, stop), StatsFence);
|
||||
var t = Time(c => renderer.Draw(c, renderer.Extractor.Segments, renderer.Extractor.Count, levels, frame.ViewProjection, target, look, 0f, false, 0, stop), StatsFence);
|
||||
if (iteration >= 0) prefixes[k].Add(t);
|
||||
}
|
||||
// Sample alone first: it clears Count, so the full Extract after it leaves the segments the next prefixes draw
|
||||
var sa = Time(c => renderer.Extractor.Extract(c, terms, origin, perTexel, size, levels, IsolineExtractor.Stage.Sample), () => renderer.Extractor.Count.GetData(new uint[2]));
|
||||
var e = Time(c => renderer.Extractor.Extract(c, terms, origin, perTexel, size, levels), () => renderer.Extractor.Count.GetData(new uint[2]));
|
||||
var b = Time(c => c.Blit(Texture2D.whiteTexture, blitTarget, lines), PixelFence);
|
||||
if (iteration >= 0) { extract.Add(e); blit.Add(b); sampleAlone.Add(sa); }
|
||||
var sa = Time(c => renderer.Extractor.Extract(c, terms, frame.Origin, frame.PerTexel, frame.Size, levels, IsolineExtractor.Stage.Sample), () => renderer.Extractor.Count.GetData(new uint[2]));
|
||||
var e = Time(c => renderer.Extractor.Extract(c, terms, frame.Origin, frame.PerTexel, frame.Size, levels), () => renderer.Extractor.Count.GetData(new uint[2]));
|
||||
var f = Time(c => renderer.Record(c, terms, frame.Origin, frame.PerTexel, frame.Size, levels, frame.ViewProjection, target, look, 0f), StatsFence);
|
||||
if (iteration >= 0) { extract.Add(e); full.Add(f); sampleAlone.Add(sa); }
|
||||
}
|
||||
var names = new[] { "Args", "Clear", "Bin", "Scan", "Scatter", "Shade" };
|
||||
var parts = new List<string>();
|
||||
|
|
@ -1550,12 +1634,11 @@ namespace Aetheria.EditorTools
|
|||
parts.Add($"{names[k - 1]} {m:F3}");
|
||||
}
|
||||
var total = Median(prefixes[6].Select((v, i) => v - prefixes[0][i]).ToList());
|
||||
Info($"cost {label}: ms per pass, median of {Iterations} interleaved iterations x {Reps} reps, wall clock to a fence, kernel = paired difference of prefixes: {string.Join(", ", parts)}; renderer total {total:F3} (kernel sum {sum:F3}); Extract {Median(extract):F3} (Sample alone {Median(sampleAlone):F3}); old material blit {Median(blit):F3}; fence alone {Median(prefixes[0]):F3}; recorder {(recorder.isValid ? recorder.gpuElapsedNanoseconds / 1e6 + " ms" : "unmeasured (no frame loop)")}");
|
||||
var recordMs = Median(full);
|
||||
var extractMs = Median(extract);
|
||||
Info($"cost {label}: ms per pass, median of {Iterations} interleaved iterations x {Reps} reps, wall clock to a fence, kernel = paired difference of prefixes: {string.Join(", ", parts)}; renderer total {total:F3} (kernel sum {sum:F3}); Extract {Median(extract):F3} (Sample alone {Median(sampleAlone):F3}); Extract plus Draw {extractMs + total:F3} (sum of the two medians, the definition of the 08b1a13cd readings), recorded in one pass {recordMs:F3}; fence alone {Median(prefixes[0]):F3}; recorder {(recorder.isValid ? recorder.gpuElapsedNanoseconds / 1e6 + " ms" : "unmeasured (no frame loop)")}");
|
||||
recorder.enabled = false;
|
||||
blitTarget.Release();
|
||||
UnityEngine.Object.DestroyImmediate(blitTarget);
|
||||
UnityEngine.Object.DestroyImmediate(lines);
|
||||
UnityEngine.Object.DestroyImmediate(one);
|
||||
return extractMs + total;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ public static class MapBeltPerf
|
|||
}, pack, new GalaxyZone { Name = "Perf", Owner = null }, null);
|
||||
|
||||
var transforms = new float4[count];
|
||||
var presenter = new MapPresenter(new Material[0], AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI/MapAsteroid.mat"), 4, 4, 3f);
|
||||
var presenter = new MapPresenter(AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI/MapAsteroid.mat"), 4, 4, 3f);
|
||||
presenter.RegisterBelt(beltKey, transforms);
|
||||
var baseBelt = new MapBeltPerfBase(zone, zone.AsteroidBelts[beltKey], 4, 4, 3f);
|
||||
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ public static class MapPresenterSmoke
|
|||
ship.Direction = float2(Mathf.Sin(40 * Mathf.Deg2Rad), Mathf.Cos(40 * Mathf.Deg2Rad));
|
||||
typeof(Ship).GetProperty("Rotation", Any).GetSetMethod(true).Invoke(ship, new object[] { new CultMath.quaternion(pose.x, pose.y, pose.z, pose.w) });
|
||||
|
||||
var map = new MapPresenter(new Material[0], AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI/MapAsteroid.mat"), 4, 4, 3f);
|
||||
var map = new MapPresenter(AssetDatabase.LoadAssetAtPath<Material>("Assets/Materials/UI/MapAsteroid.mat"), 4, 4, 3f);
|
||||
var roots = new GameObject("Smoke Roots").transform;
|
||||
EntityInstance Bound(Entity entity)
|
||||
{
|
||||
|
|
@ -152,7 +152,6 @@ public static class MapPresenterSmoke
|
|||
instance.MapIcon = NewIcon(body.transform, flatIcons);
|
||||
var zoneRenderer = new GameObject("Smoke Zone Renderer").AddComponent<ZoneRenderer>();
|
||||
zoneRenderer.Settings = settings;
|
||||
zoneRenderer.MapGravityMaterials = new Material[0];
|
||||
Awaken(zoneRenderer);
|
||||
typeof(ZoneRenderer).GetProperty("Map").GetSetMethod(true).Invoke(zoneRenderer, new object[] { map });
|
||||
instance.SetEntity(zoneRenderer, entity);
|
||||
|
|
|
|||
|
|
@ -24,6 +24,18 @@ public class GameSettings : ScriptableObject
|
|||
public int AsteroidMeshCount = 5;
|
||||
public float MinimapAsteroidSize = 3;
|
||||
public float MinimapIconSize = 1f / 32;
|
||||
// One isoline view's settings (IsolineView reads them every frame). The look is the operator's to tune by eye;
|
||||
// CellPixels is the target pixels per field sample; the capacities are sized from the smokes' readings (IsolineRenderSmoke
|
||||
// 'shipped capacities hold'): the next power of two at or above twice the worst reading at the view's largest pose.
|
||||
[Serializable]
|
||||
public struct IsolineViewSettings
|
||||
{
|
||||
public IsolineLook Look;
|
||||
public int CellPixels;
|
||||
public int SegmentCapacity;
|
||||
public int PoolCapacity;
|
||||
}
|
||||
public IsolineViewSettings MapIsolines, MinimapIsolines;
|
||||
// Tactical view (rulings tactical-view-distinct-mode, tactical-view-in-runs-slow-time): one wheel notch multiplies the
|
||||
// camera distance by this, in either view. Every feel constant here (step, band, detent, ease, pitch) is a placeholder
|
||||
// the operator tunes by eye.
|
||||
|
|
|
|||
|
|
@ -19,11 +19,9 @@ public class MapRenderer : MonoBehaviour
|
|||
public ZoneRenderer ZoneRenderer;
|
||||
public TextMeshProUGUI Title;
|
||||
public Camera MapOverlayCamera;
|
||||
public Camera GravityCamera;
|
||||
public Camera TintCamera;
|
||||
public Camera InfluenceCamera;
|
||||
public Image OverlayDisplay;
|
||||
public Image GravityDisplay;
|
||||
public Image TintDisplay;
|
||||
public Image InfluenceDisplay;
|
||||
public float Scale;
|
||||
|
|
@ -32,7 +30,6 @@ public class MapRenderer : MonoBehaviour
|
|||
|
||||
private RectTransform _rect;
|
||||
private RenderTexture _mapTexture;
|
||||
private RenderTexture _gravityTexture;
|
||||
private RenderTexture _tintTexture;
|
||||
private RenderTexture _influenceTexture;
|
||||
private int2 _size;
|
||||
|
|
@ -47,7 +44,6 @@ public class MapRenderer : MonoBehaviour
|
|||
{
|
||||
_init = true;
|
||||
MapOverlayCamera.gameObject.SetActive(true);
|
||||
GravityCamera.gameObject.SetActive(true);
|
||||
TintCamera.gameObject.SetActive(true);
|
||||
InfluenceCamera.gameObject.SetActive(true);
|
||||
Title.text = $"Zone: {GameManager.Zone.GalaxyZone.Name}";
|
||||
|
|
@ -61,7 +57,6 @@ public class MapRenderer : MonoBehaviour
|
|||
ReleaseTextures();
|
||||
}
|
||||
MapOverlayCamera.gameObject.SetActive(false);
|
||||
GravityCamera.gameObject.SetActive(false);
|
||||
TintCamera.gameObject.SetActive(false);
|
||||
InfluenceCamera.gameObject.SetActive(false);
|
||||
GameManager.ZoneRenderer.Map.OpenMapScreen(false);
|
||||
|
|
@ -71,8 +66,6 @@ public class MapRenderer : MonoBehaviour
|
|||
{
|
||||
_mapTexture.Release();
|
||||
_mapTexture = null;
|
||||
_gravityTexture.Release();
|
||||
_gravityTexture = null;
|
||||
_tintTexture.Release();
|
||||
_tintTexture = null;
|
||||
_influenceTexture.Release();
|
||||
|
|
@ -95,10 +88,6 @@ public class MapRenderer : MonoBehaviour
|
|||
MapOverlayCamera.targetTexture = _mapTexture;
|
||||
OverlayDisplay.material.SetTexture("_DetailTex", _mapTexture);
|
||||
|
||||
_gravityTexture = new RenderTexture(_size.x, _size.y, 0, RenderTextureFormat.RFloat);
|
||||
GravityCamera.targetTexture = _gravityTexture;
|
||||
GravityDisplay.material.SetTexture("_DetailTex", _gravityTexture);
|
||||
|
||||
_tintTexture = new RenderTexture(_size.x / 2, _size.y / 2, 0, RenderTextureFormat.RGB111110Float);
|
||||
TintCamera.targetTexture = _tintTexture;
|
||||
TintDisplay.material.SetTexture("_DetailTex", _tintTexture);
|
||||
|
|
@ -113,10 +102,6 @@ public class MapRenderer : MonoBehaviour
|
|||
MapOverlayCamera.transform.position = pos;
|
||||
MapOverlayCamera.orthographicSize = _size.y * Scale * .5f;
|
||||
|
||||
GravityCamera.transform.position = pos;
|
||||
GravityCamera.orthographicSize = _size.y * Scale * .5f;
|
||||
GravityDisplay.material.SetFloat("_Scale", Scale / 2);
|
||||
|
||||
TintCamera.transform.position = pos;
|
||||
TintCamera.orthographicSize = _size.y * Scale * .5f;
|
||||
|
||||
|
|
|
|||
168
Assets/Scripts/Zone Display/IsolineView.cs
Normal file
168
Assets/Scripts/Zone Display/IsolineView.cs
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// One view's isoline frame (campaign aetheria-release, cut isoline-wiring): when it draws, on which grid, at which levels, with
|
||||
/// which look and capacities, and how its target reaches the UI. The map screen's 'Gravity Lines' Image and the minimap's
|
||||
/// 'Gravity Fields' RawImage each carry one; both own one IsolineRenderer and one target and differ only in PoseCamera, Graphic and
|
||||
/// GameSettings entry. IsolineExtractor and IsolineRenderer still own every segment and pixel; nothing here reads the lines back.
|
||||
///
|
||||
/// Runs after ZoneRenderer.LateUpdate and MapRenderer.LateUpdate (order 100), so the pose camera and MapPresenter.ContourRange are this
|
||||
/// frame's. The pose camera is axis-aligned (orthographic, looking straight down, never rotated: CopyTransform.CopyRotation is off).
|
||||
/// </summary>
|
||||
[DefaultExecutionOrder(100)]
|
||||
[RequireComponent(typeof(Graphic))]
|
||||
public sealed class IsolineView : MonoBehaviour
|
||||
{
|
||||
public enum Kind { Map, Minimap }
|
||||
|
||||
public Kind View;
|
||||
public Camera PoseCamera;
|
||||
public ZoneRenderer ZoneRenderer;
|
||||
public ComputeShader Extract;
|
||||
public ComputeShader Render;
|
||||
|
||||
const float SlopeEpsilon = 1e-3f;
|
||||
const int OverflowEvery = 120;
|
||||
static readonly int DetailTex = Shader.PropertyToID("_DetailTex");
|
||||
// One overflow warning per view per session.
|
||||
static readonly bool[] Warned = new bool[2];
|
||||
|
||||
Graphic _graphic;
|
||||
Material _template, _instance;
|
||||
IsolineRenderer _renderer;
|
||||
RenderTexture _target;
|
||||
CommandBuffer _command;
|
||||
int _capacities;
|
||||
bool _readbackPending;
|
||||
|
||||
/// <summary>
|
||||
/// The sample grid of a view: cellPixels target pixels per sample, the origin snapped down (against the step's sign) to the
|
||||
/// world lattice of that step per axis, and two samples more than the target spans so the view stays covered wherever the
|
||||
/// snap lands. Panning therefore never moves a contour, and the grid's size is fixed for a target size. The frame is read
|
||||
/// through ViewportToWorldPoint at pixel centres, as the smokes' field renders were.
|
||||
/// </summary>
|
||||
public static void Grid(Camera camera, Vector2Int target, int cellPixels, out Vector2 origin, out Vector2 perTexel, out Vector2Int size)
|
||||
{
|
||||
Vector2 At(float x, float y)
|
||||
{
|
||||
var p = camera.ViewportToWorldPoint(new Vector3((x + .5f) / target.x, (y + .5f) / target.y, 100f));
|
||||
return new Vector2(p.x, p.z);
|
||||
}
|
||||
var first = At(0, 0);
|
||||
var perPixel = new Vector2(At(1, 0).x - first.x, At(0, 1).y - first.y);
|
||||
perTexel = perPixel * cellPixels;
|
||||
// the view's edge (the first pixel's outer edge) is where the first sample must not lie past
|
||||
var edge = first - perPixel * .5f;
|
||||
origin = new Vector2(Snap(edge.x, perTexel.x), Snap(edge.y, perTexel.y));
|
||||
size = new Vector2Int(Mathf.CeilToInt(target.x / (float)cellPixels) + 2, Mathf.CeilToInt(target.y / (float)cellPixels) + 2);
|
||||
}
|
||||
|
||||
// The lattice point of step a at or behind v, against the direction the grid runs in.
|
||||
static float Snap(float v, float a) => a > 0 ? Mathf.Floor(v / a) * a : Mathf.Ceil(v / a) * a;
|
||||
|
||||
/// <summary>The overflow warning for a view's last frame, or null when nothing overflowed: stats is IsolineRenderer.Stats
|
||||
/// (tile entries requested, written, truncated, segments drawn, extraction Count[0] written and Count[1] requested).</summary>
|
||||
public static string OverflowMessage(uint[] stats, int segmentCapacity, int poolCapacity)
|
||||
{
|
||||
if (stats[5] <= stats[4] && stats[2] == 0) return null;
|
||||
return $"isolines overflowed: segments requested {stats[5]}, written {stats[4]} of capacity {segmentCapacity}; tile entries requested {stats[0]}, written {stats[1]}, truncated {stats[2]} of pool {poolCapacity}. Raise the capacities in Settings.asset.";
|
||||
}
|
||||
|
||||
GameSettings.IsolineViewSettings Settings => View == Kind.Map ? ZoneRenderer.Settings.MapIsolines : ZoneRenderer.Settings.MinimapIsolines;
|
||||
|
||||
void Awake() => _graphic = GetComponent<Graphic>();
|
||||
|
||||
void OnDisable() => Release();
|
||||
|
||||
void OnDestroy() => Release();
|
||||
|
||||
void LateUpdate()
|
||||
{
|
||||
if (!ActionGameManager.RunLive || PoseCamera == null || !PoseCamera.isActiveAndEnabled) return;
|
||||
var terms = ZoneRenderer.Terms;
|
||||
if (terms.Buffer == null) return;
|
||||
var settings = Settings;
|
||||
var size = TargetSize();
|
||||
Ensure(settings, size);
|
||||
|
||||
Grid(PoseCamera, size, Mathf.Max(settings.CellPixels, 1), out var origin, out var perTexel, out var grid);
|
||||
var levels = new IsolineExtractor.IsolineLevels(0f, ZoneRenderer.Map.ContourRange, SlopeEpsilon);
|
||||
var viewProjection = GL.GetGPUProjectionMatrix(PoseCamera.projectionMatrix, true) * PoseCamera.worldToCameraMatrix;
|
||||
_command.Clear();
|
||||
_renderer.Record(_command, terms, origin, perTexel, grid, levels, viewProjection, _target, settings.Look, Time.unscaledTime);
|
||||
Graphics.ExecuteCommandBuffer(_command);
|
||||
|
||||
if (Debug.isDebugBuild && !Warned[(int)View] && !_readbackPending && Time.frameCount % OverflowEvery == 0)
|
||||
{
|
||||
_readbackPending = true;
|
||||
AsyncGPUReadback.Request(_renderer.Stats, request => ReadStats(request, settings));
|
||||
}
|
||||
}
|
||||
|
||||
// The map is screen-sized (the display samples it in screen space); the minimap is the square its square pose camera renders.
|
||||
Vector2Int TargetSize()
|
||||
{
|
||||
if (View == Kind.Map) return new Vector2Int(Screen.width, Screen.height);
|
||||
var rect = RectTransformUtility.PixelAdjustRect(_graphic.rectTransform, _graphic.canvas);
|
||||
var side = Mathf.Max(16, Mathf.CeilToInt(Mathf.Max(rect.width, rect.height)));
|
||||
return new Vector2Int(side, side);
|
||||
}
|
||||
|
||||
void Ensure(GameSettings.IsolineViewSettings settings, Vector2Int size)
|
||||
{
|
||||
var capacities = settings.SegmentCapacity ^ (settings.PoolCapacity << 1);
|
||||
if (_renderer != null && capacities != _capacities) Release();
|
||||
if (_renderer == null)
|
||||
{
|
||||
_renderer = new IsolineRenderer(Extract, Render, settings.SegmentCapacity, settings.PoolCapacity);
|
||||
_command = new CommandBuffer { name = "Isolines " + View };
|
||||
_capacities = capacities;
|
||||
}
|
||||
if (_target != null && _target.width == size.x && _target.height == size.y) return;
|
||||
if (_target != null) { _target.Release(); Destroy(_target); }
|
||||
_target = new RenderTexture(size.x, size.y, 0, RenderTextureFormat.ARGBHalf, RenderTextureReadWrite.Linear) { enableRandomWrite = true, name = "Isolines " + View };
|
||||
_target.Create();
|
||||
if (View == Kind.Map)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_template = _graphic.material;
|
||||
_instance = Instantiate(_template);
|
||||
_graphic.material = _instance;
|
||||
}
|
||||
_instance.SetTexture(DetailTex, _target);
|
||||
_graphic.SetMaterialDirty();
|
||||
}
|
||||
else ((RawImage)_graphic).texture = _target;
|
||||
}
|
||||
|
||||
void ReadStats(AsyncGPUReadbackRequest request, GameSettings.IsolineViewSettings settings)
|
||||
{
|
||||
_readbackPending = false;
|
||||
if (request.hasError || Warned[(int)View]) return;
|
||||
var stats = request.GetData<uint>().ToArray();
|
||||
var message = OverflowMessage(stats, settings.SegmentCapacity, settings.PoolCapacity);
|
||||
if (message == null) return;
|
||||
Warned[(int)View] = true;
|
||||
Debug.LogWarning($"{View} {message}", this);
|
||||
}
|
||||
|
||||
void Release()
|
||||
{
|
||||
if (_graphic != null)
|
||||
{
|
||||
if (_instance != null) _graphic.material = _template;
|
||||
if (_graphic is RawImage raw) raw.texture = null;
|
||||
}
|
||||
if (_instance != null) Destroy(_instance);
|
||||
_instance = null;
|
||||
_renderer?.Release();
|
||||
_renderer = null;
|
||||
_command?.Release();
|
||||
_command = null;
|
||||
if (_target != null) { _target.Release(); Destroy(_target); }
|
||||
_target = null;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/Zone Display/IsolineView.cs.meta
Normal file
2
Assets/Scripts/Zone Display/IsolineView.cs.meta
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 440d14bb8b58a5846adb6e754fa8f803
|
||||
|
|
@ -11,7 +11,7 @@ using float4 = CultMath.float4;
|
|||
using quaternion = CultMath.quaternion;
|
||||
|
||||
// The one owner of map-space projection (ruling map-icons-placed-in-2d): where every map icon and belt asteroid is
|
||||
// drawn, its yaw, its size, its fade, and the contour's depth range. Icons are not world objects: each is a mesh,
|
||||
// drawn, its yaw, its size, its fade, and the contour's depth range (ContourRange, which IsolineView reads). Icons are not world objects: each is a mesh,
|
||||
// a material instance and an authored rotation read once from the icon child at registration (the child is then
|
||||
// destroyed), drawn every frame on the Minimap layer at the map plane from sim state through DrawAhead. Roll and
|
||||
// pitch never reach an icon, and field depth never decides whether one is seen. Both map cameras (the minimap's
|
||||
|
|
@ -46,7 +46,6 @@ public class MapPresenter
|
|||
|
||||
private readonly List<Icon> _icons = new List<Icon>();
|
||||
private readonly Dictionary<Entity, Icon> _entityIcons = new Dictionary<Entity, Icon>();
|
||||
private readonly Material[] _gravityMaterials;
|
||||
private readonly int _layer = LayerMask.NameToLayer("Minimap");
|
||||
private float _minimapScale = 1, _mapScreenScale, _tacticalScale;
|
||||
private bool _mapScreenOpen;
|
||||
|
|
@ -54,10 +53,9 @@ public class MapPresenter
|
|||
private readonly Vector4 _spriteSheet;
|
||||
private readonly float _asteroidSize;
|
||||
|
||||
public MapPresenter(Material[] gravityMaterials, Material asteroidMaterial, int spriteColumns, int spriteRows,
|
||||
public MapPresenter(Material asteroidMaterial, int spriteColumns, int spriteRows,
|
||||
float asteroidSize)
|
||||
{
|
||||
_gravityMaterials = gravityMaterials;
|
||||
_asteroidMaterial = asteroidMaterial;
|
||||
_spriteSheet = new Vector4(spriteColumns, spriteRows, 0, 0);
|
||||
_asteroidSize = asteroidSize;
|
||||
|
|
@ -65,6 +63,9 @@ public class MapPresenter
|
|||
|
||||
// The icon size: the map screen's scale while it is open, else the tactical scale while the schematic shows, else
|
||||
// the minimap's zoom.
|
||||
// The deepest drawn planet's field depth, at least 1; set by Draw.
|
||||
public float ContourRange { get; private set; } = 1f;
|
||||
|
||||
public float IconSize => _mapScreenOpen ? _mapScreenScale : _tacticalScale > 0 ? _tacticalScale : _minimapScale;
|
||||
public void SetTacticalScale(float scale) => _tacticalScale = scale;
|
||||
public void SetMinimapScale(float scale) => _minimapScale = scale;
|
||||
|
|
@ -190,7 +191,7 @@ public class MapPresenter
|
|||
}
|
||||
|
||||
// Every registered icon and belt for this frame, from sim state at the drawn time; and the contour's depth range,
|
||||
// the deepest drawn planet's field depth (the map gravity materials' normalisation, not a camera bound).
|
||||
// the deepest drawn planet's field depth (the isolines' normalisation, not a camera bound).
|
||||
public void Draw(Zone zone, float lead)
|
||||
{
|
||||
var size = IconSize;
|
||||
|
|
@ -224,12 +225,7 @@ public class MapPresenter
|
|||
IconDraws++;
|
||||
}
|
||||
|
||||
var depthRange = Mathf.Max(maxDepth, 1f);
|
||||
foreach (var material in _gravityMaterials)
|
||||
{
|
||||
material.SetFloat("_StartDepth", 0f);
|
||||
material.SetFloat("_DepthRange", depthRange);
|
||||
}
|
||||
ContourRange = Mathf.Max(maxDepth, 1f);
|
||||
|
||||
foreach (var belt in _belts.Values) DrawBelt(belt);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,6 @@ public class ZoneRenderer : MonoBehaviour
|
|||
public ItemPickup WeaponPickup;
|
||||
public MineInstance MinePrefab;
|
||||
public VapourCloudInstance CloudPrefab;
|
||||
public Material[] MapGravityMaterials;
|
||||
// The gravity field's material (Brushes/Gravity Field): GravityLowering makes the one quad that draws it.
|
||||
public Material GravityField;
|
||||
|
||||
|
|
@ -104,6 +103,8 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
// The one owner of map-space projection: every map icon and belt sprite is drawn by it.
|
||||
public MapPresenter Map { get; private set; }
|
||||
// The gravity terms Update lowered at the drawn time; IsolineView extracts the map's and minimap's isolines from them.
|
||||
public GravityLowering.GravityTerms Terms { get; private set; }
|
||||
public Zone Zone { get; private set; }
|
||||
public ItemManager ItemManager { get; set; }
|
||||
|
||||
|
|
@ -172,13 +173,12 @@ public class ZoneRenderer : MonoBehaviour
|
|||
foreach (var camera in MinimapCameras)
|
||||
camera.orthographicSize = value;
|
||||
Map.SetMinimapScale(value * Settings.MinimapIconSize);
|
||||
// MinimapGravityQuad.transform.localScale = value * 2 * Vector3.one;
|
||||
}
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
Map = new MapPresenter(MapGravityMaterials, MapAsteroidMaterial, AsteroidSpritesheetWidth,
|
||||
Map = new MapPresenter(MapAsteroidMaterial, AsteroidSpritesheetWidth,
|
||||
AsteroidSpritesheetHeight, Settings.MinimapAsteroidSize);
|
||||
}
|
||||
|
||||
|
|
@ -578,7 +578,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
{
|
||||
if (!ActionGameManager.RunLive) return;
|
||||
var lead = ActionGameManager.Clock.Lead;
|
||||
GravityLowering.Lower(Zone, lead, ref _gravityWells);
|
||||
Terms = GravityLowering.Lower(Zone, lead, ref _gravityWells);
|
||||
foreach (var loot in _floatingItems.Values)
|
||||
{
|
||||
loot.ViewOrigin = DrawAhead.Position(PerspectiveEntity, lead);
|
||||
|
|
@ -634,10 +634,6 @@ public class ZoneRenderer : MonoBehaviour
|
|||
wormhole.icon.gameObject.SetActive(distance > _minimapDistance);
|
||||
wormhole.icon.transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(difference.y, difference.x) * Mathf.Rad2Deg - 90);
|
||||
}
|
||||
|
||||
// var gravPos = MinimapGravityQuad.transform.position;
|
||||
// MinimapGravityQuad.transform.position = gravPos;
|
||||
// MinimapTintQuad.transform.position = gravPos - Vector3.up*10;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,131 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Shader "Unlit/Isolines"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Texture", 2D) = "white" {}
|
||||
[HDR] _Color ("Color", Color) = (.5,.5,.5,1)
|
||||
[HDR] _AngleColor ("Angle Color", Color) = (.5,.5,.5,1)
|
||||
[HDR] _DangerColor ("Danger Color", Color) = (.5,.5,.5,1)
|
||||
_StartDepth("Start Depth", Float) = 0
|
||||
_DepthRange("Height Range", Float) = 100
|
||||
_LineWidth("Line Width", Float) = .1
|
||||
_LineFade("Line Fade", Float) = .1
|
||||
_AngleWidth("Angle Width", Float) = .1
|
||||
_AngleFade("Angle Fade", Float) = .1
|
||||
_DangerSteepness("Danger Steepness", Float) = .1
|
||||
//_ClipDistance("Clip Distance", Float) = 10
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
LOD 100
|
||||
Blend One One
|
||||
Cull Off Lighting Off ZWrite Off
|
||||
|
||||
Pass
|
||||
{
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma only_renderers d3d11
|
||||
#pragma target 5.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct appdata
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uvw : TEXCOORD1;
|
||||
float4 vertex : SV_POSITION;
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
float4 _MainTex_TexelSize;
|
||||
float4 _Color;
|
||||
float4 _AngleColor;
|
||||
float4 _DangerColor;
|
||||
float _StartDepth;
|
||||
float _DepthRange;
|
||||
float _LineWidth;
|
||||
float _LineFade;
|
||||
float _AngleWidth;
|
||||
float _AngleFade;
|
||||
float _DangerSteepness;
|
||||
//float _ClipDistance;
|
||||
|
||||
v2f vert (appdata v)
|
||||
{
|
||||
v2f o;
|
||||
o.vertex = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
||||
o.uvw = mul (unity_ObjectToWorld, v.vertex).xy;
|
||||
return o;
|
||||
}
|
||||
|
||||
float2 calcGrad (float2 uv, float me)
|
||||
{
|
||||
float n = -tex2D(_MainTex, float2(uv.x, uv.y + _MainTex_TexelSize.y)).x;
|
||||
float e = -tex2D(_MainTex, float2(uv.x + _MainTex_TexelSize.x, uv.y)).x;
|
||||
return float2(e-me,n-me);
|
||||
}
|
||||
|
||||
fixed4 frag (v2f IN) : SV_Target
|
||||
{
|
||||
//clip(1-length(IN.uvw)/_ClipDistance);
|
||||
// sample the texture
|
||||
half h = -tex2D(_MainTex, IN.uv).r;
|
||||
float4 col = float4(0,0,0,0);
|
||||
float blend = smoothstep(_StartDepth, _StartDepth + _DepthRange / 32, -h);
|
||||
|
||||
// Calculate the direction in which the surface is facing
|
||||
float2 plan = calcGrad(IN.uv, h);
|
||||
|
||||
float planmag = length(plan);
|
||||
|
||||
float dangerblend = smoothstep(0,_DangerSteepness, planmag * _ScreenParams.y / unity_OrthoParams.y);
|
||||
|
||||
// Loop over isolines, computing a pseudo distance field for a number of height values
|
||||
float spacing = _DepthRange / 20;
|
||||
for (int ih = 1; ih <= 21; ih++) {
|
||||
float isoline = abs(h + _StartDepth + (ih*spacing));
|
||||
//float2 isograd = float2(ddx(isoline), ddy(isoline));
|
||||
//float isomag = length(isograd);
|
||||
col += (1-smoothstep(_LineWidth, _LineWidth * _LineFade, isoline / planmag * _ScreenParams.y)) * lerp(_Color,_DangerColor,dangerblend) * blend; // Isoline
|
||||
}
|
||||
|
||||
float angle = atan2(plan.y,plan.x) / 3.1415926536 + 1;
|
||||
|
||||
float2 plannorm = normalize(plan);
|
||||
float2 plan2uv = IN.uv + float2(-plannorm.y * _MainTex_TexelSize.x, plannorm.x * _MainTex_TexelSize.y);
|
||||
float2 plan2 = calcGrad(plan2uv, -tex2D(_MainTex, plan2uv).r);
|
||||
float angle2 = atan2(plan2.y,plan2.x) / 3.1415926536 + 1;
|
||||
float angmag = abs(angle-angle2);
|
||||
angmag = min(angmag,0.025);
|
||||
//angmag = clamp(angmag,0.005,0.05);
|
||||
|
||||
// Loop over isoangles
|
||||
for (float ia = 0.5; ia < 13; ia++) {
|
||||
float isoline = abs(angle - ia / 6.0);// ;
|
||||
//float2 isograd = float2(ddx_fine(isoline), ddy_fine(isoline));
|
||||
//float isomag = min(length(isograd),0.025); // isomag is huge over atan2 boundary so clamp it to avoid false positives
|
||||
col += (1-smoothstep(_AngleWidth, _AngleWidth * _AngleFade, isoline / angmag * _ScreenParams.y)) * lerp(_AngleColor,_DangerColor,dangerblend) * blend; // Isoline
|
||||
}
|
||||
|
||||
//return float4(1,0,0,1);
|
||||
return col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0ec0ecdb30ff1614698ae885ebcd873d
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -1,212 +0,0 @@
|
|||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
Shader "UI/Isolines"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
_DetailTex ("Detail Texture", 2D) = "white" {}
|
||||
// _TintTex ("Tint Texture", 2D) = "black" {}
|
||||
// _TintIntensity("Tint Intensity", Float) = 1
|
||||
// _TintExponent("Tint Exponent", Float) = 1
|
||||
[HDR] _Color ("Color", Color) = (.5,.5,.5,1)
|
||||
[HDR] _AngleColor ("Angle Color", Color) = (.5,.5,.5,1)
|
||||
[HDR] _DangerColor ("Danger Color", Color) = (.5,.5,.5,1)
|
||||
_StartDepth("Start Depth", Float) = 0
|
||||
_DepthRange("Height Range", Float) = 100
|
||||
_LineWidth("Line Width", Float) = .1
|
||||
_LineFade("Line Fade", Float) = .1
|
||||
_AngleWidth("Angle Width", Float) = .1
|
||||
_AngleFade("Angle Fade", Float) = .1
|
||||
// _Angle2Width("Angle 2 Width", Float) = .1
|
||||
// _Angle2Fade("Angle 2 Fade", Float) = .1
|
||||
_DangerSteepness("Danger Steepness", Float) = .1
|
||||
_Scale("Scale", Float) = 1
|
||||
|
||||
_StencilComp ("Stencil Comparison", Float) = 8
|
||||
_Stencil ("Stencil ID", Float) = 0
|
||||
_StencilOp ("Stencil Operation", Float) = 0
|
||||
_StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
_StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
_ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
[Toggle(SCREEN_SPACE)] _UseScreenSpace ("Screen Space Detail Texture", Float) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Blend SrcAlpha OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Default"
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile_local _ UNITY_UI_ALPHACLIP
|
||||
#pragma shader_feature SCREEN_SPACE
|
||||
|
||||
struct appdata_t
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct v2f
|
||||
{
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
#ifdef SCREEN_SPACE
|
||||
float4 screenPos : TEXCOORD1;
|
||||
#endif
|
||||
//float2 detailtexcoord : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
sampler2D _MainTex;
|
||||
float4 _MainTex_ST;
|
||||
sampler2D _TintTex;
|
||||
sampler2D _DetailTex;
|
||||
float4 _DetailTex_ST;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
float4 _DetailTex_TexelSize;
|
||||
fixed4 _Color;
|
||||
fixed4 _AngleColor;
|
||||
fixed4 _DangerColor;
|
||||
float _TintIntensity;
|
||||
float _TintExponent;
|
||||
float _StartDepth;
|
||||
float _DepthRange;
|
||||
float _LineWidth;
|
||||
float _LineFade;
|
||||
float _AngleWidth;
|
||||
float _AngleFade;
|
||||
// float _Angle2Width;
|
||||
// float _Angle2Fade;
|
||||
float _DangerSteepness;
|
||||
float _Scale;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
v2f OUT;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
OUT.vertex = UnityObjectToClipPos(v.vertex);
|
||||
|
||||
OUT.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
#ifdef SCREEN_SPACE
|
||||
OUT.screenPos = ComputeScreenPos( OUT.vertex );
|
||||
#endif
|
||||
|
||||
//OUT.detailtexcoord = TRANSFORM_TEX(OUT.worldPosition.xy, _MainTex);
|
||||
|
||||
OUT.color = v.color * _Color;
|
||||
return OUT;
|
||||
}
|
||||
|
||||
// Sample heightmap texture to find the gradient of the distance field
|
||||
float2 calcGrad (float2 uv, float me)
|
||||
{
|
||||
float n = -tex2D(_DetailTex, float2(uv.x, uv.y + _DetailTex_TexelSize.y)).x;
|
||||
float e = -tex2D(_DetailTex, float2(uv.x + _DetailTex_TexelSize.x, uv.y)).x;
|
||||
return float2(e-me,n-me);
|
||||
}
|
||||
|
||||
fixed4 frag(v2f IN) : SV_Target
|
||||
{
|
||||
half4 color = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd);
|
||||
|
||||
#ifdef SCREEN_SPACE
|
||||
float2 q = IN.screenPos.xy / IN.screenPos.w;
|
||||
#else
|
||||
float2 q = IN.texcoord;
|
||||
#endif
|
||||
|
||||
float height = -tex2D(_DetailTex, q).r;
|
||||
//half4 c = tex2D(_TintTex, q);
|
||||
|
||||
float4 col = float4(0,0,0,0);
|
||||
float blend = smoothstep(_StartDepth, _StartDepth + _DepthRange / 32, -height);
|
||||
|
||||
// Calculate the direction in which the surface is facing
|
||||
// Can replace with float2(ddx_fine(h),ddy_fine(h)) for more speed but lower quality
|
||||
float2 plan = calcGrad(q, height);
|
||||
|
||||
float slope = length(plan);
|
||||
|
||||
float dangerblend = smoothstep(0,_DangerSteepness, pow(slope / _Scale, 2));
|
||||
|
||||
half4 linecol = lerp(_Color,_DangerColor,dangerblend) * blend;
|
||||
// Loop over isolines to sum their color contribution,
|
||||
// Computing a distance field for a number of height values
|
||||
float spacing = _DepthRange / 20;
|
||||
for (int ih = 1; ih <= 21; ih++) {
|
||||
float isoline = abs(height + _StartDepth + (ih*spacing));
|
||||
col += (1-smoothstep(_LineWidth, _LineWidth * _LineFade, isoline / slope)) * linecol; // Isoline
|
||||
}
|
||||
|
||||
float angle = atan2(plan.y,plan.x) / 3.1415926536 + 1;
|
||||
|
||||
// float2 plannorm = normalize(plan);
|
||||
// float2 plan2uv = q + float2(-plannorm.y * _DetailTex_TexelSize.x * 2, plannorm.x * _DetailTex_TexelSize.y * 2);
|
||||
// float2 plan2 = calcGrad(plan2uv, -tex2D(_DetailTex, plan2uv).r);
|
||||
// float angle2 = atan2(plan2.y,plan2.x) / 3.1415926536 + 1;
|
||||
// float angmag = abs(angle-angle2);
|
||||
// angmag = min(angmag,0.025);
|
||||
half4 angcol = blend * (slope / _Scale) * (lerp(_AngleColor, _DangerColor, dangerblend));
|
||||
// + pow(c,_TintExponent) * _TintIntensity
|
||||
// Loop over angle isolines
|
||||
for (float ia = 0.5; ia < 13; ia++) {
|
||||
float isoline = abs(angle - ia / 6.0);
|
||||
float l = 1-smoothstep(_AngleWidth, _AngleWidth * _AngleFade, isoline);
|
||||
l *= smoothstep(-_StartDepth - _DepthRange, -_StartDepth, height);
|
||||
col += l * angcol;
|
||||
// col += (1-smoothstep(_Angle2Width, _Angle2Width * _Angle2Fade, isoline / angmag)) * _AngleColor * blend; // Isoline
|
||||
}
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color * col;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
fileFormatVersion: 2
|
||||
guid: f5505d3747493e24c91b7cb141fd7b8c
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue