Skip to content

Commit

Permalink
* disable post-processing, switch to simpler water shader (1 less dep…
Browse files Browse the repository at this point in the history
…th read) outside of "high quality" mode

* swapped FramerateDisplay calculation to end-of-frame to be more consistent across frames
  • Loading branch information
BeauPrime committed Jul 9, 2024
1 parent f46da11 commit 7d81b5d
Show file tree
Hide file tree
Showing 22 changed files with 109 additions and 50 deletions.
2 changes: 1 addition & 1 deletion Assets/Art/Materials/TileOutline.mat
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ Material:
- _ZWrite: 1
m_Colors:
- _BaseColor: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 0, g: 0.88235295, b: 1, a: 1}
- _Color: {r: 0.74509805, g: 0.9254902, b: 0.11764706, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _Flip: {r: 1, g: 1, b: 1, a: 1}
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/WaterSide00.mat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/WaterSide00_Deep.mat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/WaterSide01_Deep_Dirty.mat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/WaterSide01_Dirty.mat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/WaterTop00.mat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/WaterTop00_Deep.mat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
4 changes: 2 additions & 2 deletions Assets/Art/Materials/WaterTop01_Deep_Dirty.mat
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: WaterTop01_Deep_Dirty
m_Shader: {fileID: -6465566751694194690, guid: 27b042674da390c46a1ff4cc2317d5f2, type: 3}
m_Shader: {fileID: -6465566751694194690, guid: 9632bc2e27e39aa4a84db05a031e1ad6, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
4 changes: 2 additions & 2 deletions Assets/Art/Materials/WaterTop01_Dirty.mat
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ Material:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_Name: WaterTop01_Dirty
m_Shader: {fileID: -6465566751694194690, guid: 27b042674da390c46a1ff4cc2317d5f2, type: 3}
m_Shader: {fileID: -6465566751694194690, guid: 9632bc2e27e39aa4a84db05a031e1ad6, type: 3}
m_ValidKeywords: []
m_InvalidKeywords: []
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 1999
m_CustomRenderQueue: 2999
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/Waterfall00.mat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
m_CustomRenderQueue: 2450
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
2 changes: 1 addition & 1 deletion Assets/Art/Materials/Waterfall01_Dirty.mat
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Material:
m_LightmapFlags: 4
m_EnableInstancingVariants: 1
m_DoubleSidedGI: 0
m_CustomRenderQueue: 2000
m_CustomRenderQueue: 2450
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2528,7 +2528,7 @@
"m_Title": "Color",
"m_Position": {
"x": -334.0,
"y": -240.0
"y": -247.0
}
}

Expand Down Expand Up @@ -3710,8 +3710,8 @@
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": 1.0000038146972657,
"y": -180.99998474121095,
"x": 1.0,
"y": -188.0,
"width": 141.0,
"height": 34.0
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Assets/Code/Rendering/SimWorldCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void IRegistrationCallbacks.OnRegister() {
if (!settings.HighQualityMode) {
renderScale.PixelHeight = 660;
renderScale.Mode = CameraRenderScale.ScaleMode.PixelHeight;
CameraAux.renderPostProcessing = false;
//CameraAux.requiresDepthTexture = false;
//CameraAux.requiresDepthOption = CameraOverrideOption.Off;
//CameraAux.renderPostProcessing = false;
Expand Down
14 changes: 7 additions & 7 deletions Assets/Code/Rendering/WaterMaterialData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@ private void Awake() {
}

public void SetShaderMode(bool highQuality) {
//if (highQuality) {
// TopMaterial.ReplaceShader(FancyShader);
// TopDeepMaterial.ReplaceShader(FancyShader);
//} else {
// TopMaterial.ReplaceShader(SimpleShader);
// TopDeepMaterial.ReplaceShader(SimpleShader);
//}
if (highQuality) {
TopMaterial.ReplaceShader(FancyShader);
TopDeepMaterial.ReplaceShader(FancyShader);
} else {
TopMaterial.ReplaceShader(SimpleShader);
TopDeepMaterial.ReplaceShader(SimpleShader);
}
}

}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Code/Utils/InterpolatedMaterial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void OnDestroy() {

public void ReplaceShader(Shader shader) {
if (m_Range != null) {
for (int i = 1; i < m_Range.Length - 1; i++) {
for (int i = 0; i < m_Range.Length; i++) {
m_Range[i].shader = shader;
}
}
Expand Down
8 changes: 7 additions & 1 deletion Assets/Data/ReflectionBootData.asset
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ MonoBehaviour:
LookupInherit: 0
Assemblies:
- AssemblyName: Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
TypeCount: 11
TypeCount: 12
- AssemblyName: FieldDay.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
TypeCount: 1
Types:
Expand Down Expand Up @@ -193,6 +193,10 @@ MonoBehaviour:
Self: 0
MemberCount: 1
OverloadCount: 0
- TypeName: Zavala.World.SimWorldCamera
Self: 0
MemberCount: 1
OverloadCount: 0
- TypeName: Zavala.World.SimWorldUtility
Self: 0
MemberCount: 1
Expand Down Expand Up @@ -230,6 +234,8 @@ MonoBehaviour:
Type: 8
- MemberName: DebugMenu
Type: 8
- MemberName: CreateCameraDebug
Type: 8
- MemberName: BudgetDebugMenu
Type: 8
- MemberName: RegionUnlockDebugMenu
Expand Down
26 changes: 17 additions & 9 deletions Assets/FieldDay/Core/GameLoop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public sealed class GameLoop : MonoBehaviour, ICameraPreCullCallback, ICameraPos
// phase tracking
static internal GameLoopPhase s_CurrentPhase = GameLoopPhase.None;
static private ushort s_PrevUpdateFrameIndex = Frame.InvalidIndex;
static private bool m_ReadyForRender;
static private bool s_ReadyForRender;
static private bool s_Initialized;

// update masks
Expand Down Expand Up @@ -594,7 +594,7 @@ private void LateUpdate() {
Game.Scenes.Update();
Game.Rendering.PollScreenSettings();

m_ReadyForRender = true;
s_ReadyForRender = true;
}

private void OnGUI() {
Expand All @@ -609,23 +609,23 @@ private void OnGUI() {
}

void ICameraPreCullCallback.OnCameraPreCull(Camera camera, CameraCallbackSource source) {
if (!m_ReadyForRender) {
if (!s_ReadyForRender) {
return;
}

SetCurrentPhase(GameLoopPhase.PreCull);
}

void ICameraPreRenderCallback.OnCameraPreRender(Camera camera, CameraCallbackSource source) {
if (!m_ReadyForRender) {
if (!s_ReadyForRender) {
return;
}

SetCurrentPhase(GameLoopPhase.PreRender);
}

void ICameraPostRenderCallback.OnCameraPostRender(Camera camera, CameraCallbackSource source) {
if (!m_ReadyForRender) {
if (!s_ReadyForRender) {
return;
}

Expand Down Expand Up @@ -725,7 +725,7 @@ static private void HandlePreUpdate() {

DequeueNextValues();

m_ReadyForRender = false;
s_ReadyForRender = false;
}
}

Expand All @@ -745,7 +745,7 @@ static private void OnEndOfFrame() {
DequeueNextValues();
Game.Processes.FrameAdvanced();
OnFrameAdvance.Invoke(Frame.Index);
m_ReadyForRender = false;
s_ReadyForRender = false;
}

static private void DequeueNextValues() {
Expand Down Expand Up @@ -870,15 +870,15 @@ static public bool IsUpdating() {
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public bool IsRendering() {
return PhaseInRange(s_CurrentPhase, GameLoopPhase.PreCull, GameLoopPhase.PostRender);
return s_ReadyForRender || PhaseInRange(s_CurrentPhase, GameLoopPhase.PreCull, GameLoopPhase.PostRender);
}

/// <summary>
/// Is the game loop currently executing rendering steps.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
static public bool IsRenderingOrPreparingRendering() {
return PhaseInRange(s_CurrentPhase, GameLoopPhase.ApplicationPreRender, GameLoopPhase.PostRender);
return s_ReadyForRender || PhaseInRange(s_CurrentPhase, GameLoopPhase.ApplicationPreRender, GameLoopPhase.PostRender);
}

/// <summary>
Expand Down Expand Up @@ -970,6 +970,14 @@ static public bool IsFocused() {
}

#endregion // Pausing

#region Debug

private enum DebuggingFlags {
TraceExecution
}

#endregion // Debug
}

/// <summary>
Expand Down
3 changes: 2 additions & 1 deletion Assets/FieldDay/Profiling/FPSOverlay.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Canvas:
m_OverrideSorting: 0
m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_VertexColorAlwaysGammaSpace: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 32760
Expand Down Expand Up @@ -104,7 +105,7 @@ MonoBehaviour:
m_WarningTextColor: {r: 1, g: 0.92156863, b: 0.015686275, a: 1}
m_ForceEnabled: 0
m_TargetFramerate: 60
m_AveragingFrames: 8
m_AveragingFrames: 4
m_FramerateDropWarning: {fileID: 0}
m_FramerateDropTolerance: 0
m_FramerateDropWarningDuration: 3
Expand Down
19 changes: 18 additions & 1 deletion Assets/FieldDay/Profiling/FramerateDisplay.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Diagnostics;
using System.Text;
using TMPro;
Expand Down Expand Up @@ -41,6 +42,8 @@ public class FramerateDisplay : MonoBehaviour {
[NonSerialized] private long m_WarningThreshold;
[NonSerialized] private float m_WarningTimeLeft = 0;

private Coroutine m_EOFCoroutine;

static private FramerateDisplay s_Instance;
static private bool s_Initialized;

Expand Down Expand Up @@ -82,6 +85,8 @@ private void OnEnable() {
m_TextDisplay.SetText("-.-");
m_TextDisplay.color = m_DefaultTextColor;
m_FrameCooldown = 2;

m_EOFCoroutine = StartCoroutine(EndOfFrameCoroutine());
}

private void OnDisable() {
Expand All @@ -92,6 +97,9 @@ private void OnDisable() {
if (m_FramerateDropWarning != null) {
m_FramerateDropWarning.SetActive(false);
}

StopCoroutine(m_EOFCoroutine);
m_EOFCoroutine = null;
}

private void OnDestroy() {
Expand All @@ -108,7 +116,16 @@ private void OnApplicationPause(bool pause) {
}
}

private void LateUpdate() {

static private readonly WaitForEndOfFrame s_EOF = new WaitForEndOfFrame();
private IEnumerator EndOfFrameCoroutine() {
while(true) {
yield return s_EOF;
OnFrameEnd();
}
}

private void OnFrameEnd() {
long timestamp = Stopwatch.GetTimestamp();

if (m_FrameCooldown > 0) {
Expand Down
Loading

0 comments on commit 7d81b5d

Please sign in to comment.