浏览代码

Bug fixes (#83)

* Fix profiling scope Obsolete code

* fix caustic shader null on load

* Removal of un-needed VolumeHolder

* Hid debugs behind Pipeline debug setting

* More caustics shader null checking

* Navmesh obsolete API change

* Fix for PostVolume prefab not instantiating on load

* Updated URP version

* used new 7.2.0 API for getting additional camera data

* Moved volume init code to later in the frame as it was being destroyed as it was being created if duplicate

* Revert "Navmesh obsolete API change"

This reverts commit 66baf983dc53f0c11d9ea14bd414e184efc739ec.
/main
GitHub 4 年前
当前提交
988f8ccd
共有 7 个文件被更改,包括 35 次插入87 次删除
  1. 29
      Assets/Scripts/GameSystem/DefaultVolume.cs
  2. 13
      Packages/com.verasl.water-system/Scripts/Rendering/WaterSystemFeature.cs
  3. 2
      Packages/com.verasl.water-system/Scripts/Rendering/WaterSystemFeature.cs.meta
  4. 10
      Packages/com.verasl.water-system/Scripts/Water.cs
  5. 7
      Packages/manifest.json
  6. 50
      Assets/Scripts/GameSystem/VolumeHolder.cs
  7. 11
      Assets/Scripts/GameSystem/VolumeHolder.cs.meta

29
Assets/Scripts/GameSystem/DefaultVolume.cs


public AssetReference[] qualityVolumes;
private int _currentQualityLevel;
private void OnEnable()
private void Start()
{
if (!Instance)
{

}
else if(Instance != this)
{
Debug.Log($"Extra Volume Manager cleaned up. GUID:{gameObject.GetInstanceID()}");
if(UniversalRenderPipeline.asset.debugLevel != PipelineDebugLevel.Disabled)
Debug.Log($"Extra Volume Manager cleaned up. GUID:{gameObject.GetInstanceID()}");
#if UNITY_EDITOR
DestroyImmediate(gameObject);
return;

}
if (UniversalRenderPipeline.asset.debugLevel == PipelineDebugLevel.Disabled) return;
if (volBaseComponent.sharedProfile != null && volQualityComponent.sharedProfile != null)
if (volBaseComponent.sharedProfile && volQualityComponent.sharedProfile)
Debug.Log(message: $"Updated volumes:\n" +
Debug.Log(message: "Updated volumes:\n" +
$"Total Volume Stack is now:\n");
"Total Volume Stack is now:\n");
}
}

Debug.Log("Loading volumes in editor.");
if(UniversalRenderPipeline.asset.debugLevel != PipelineDebugLevel.Disabled)
Debug.Log("Loading volumes in editor.");
var assetRef = qualityVolumes[index];
var obj = assetRef.editorAsset;
volQualityComponent.sharedProfile = obj as VolumeProfile;

[InitializeOnLoad]
public class StartupVolume
{
private static GameObject vol;
private static GameObject _vol;
var thing = AssetDatabase.LoadAssetAtPath("Assets/Objects/misc/DefaultVolume.prefab", typeof(GameObject)) as GameObject;
Debug.Log($"Creating Volume Manager");
vol = Object.Instantiate(thing);
vol.hideFlags = HideFlags.HideAndDontSave;
EditorApplication.delayCall += () =>
{
var obj = AssetDatabase.LoadAssetAtPath("Assets/objects/misc/DefaultVolume.prefab", typeof(GameObject)) as GameObject;
if (obj == null) return;
if(UniversalRenderPipeline.asset.debugLevel != PipelineDebugLevel.Disabled)
Debug.Log($"Creating Volume Manager");
_vol = Object.Instantiate(obj);
_vol.hideFlags = HideFlags.HideAndDontSave;
};
}
}
#endif

13
Packages/com.verasl.water-system/Scripts/Rendering/WaterSystemFeature.cs


class WaterFxPass : ScriptableRenderPass
{
private const string k_RenderWaterFXTag = "Render Water FX";
private ProfilingSampler m_WaterFX_Profile = new ProfilingSampler(k_RenderWaterFXTag);
private readonly ShaderTagId m_WaterFXShaderTag = new ShaderTagId("WaterFX");
private readonly Color m_ClearColor = new Color(0.0f, 0.5f, 0.5f, 0.5f); //r = foam mask, g = normal.x, b = normal.z, a = displacement
private FilteringSettings m_FilteringSettings;

public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
{
CommandBuffer cmd = CommandBufferPool.Get(k_RenderWaterFXTag);
using (new ProfilingSample(cmd, k_RenderWaterFXTag)) // makes sure we have profiling ability
using (new ProfilingScope(cmd, m_WaterFX_Profile)) // makes sure we have profiling ability
{
context.ExecuteCommandBuffer(cmd);
cmd.Clear();

class WaterCausticsPass : ScriptableRenderPass
{
private const string k_RenderWaterCausticsTag = "Render Water Caustics";
private ProfilingSampler m_WaterCaustics_Profile = new ProfilingSampler(k_RenderWaterCausticsTag);
public Material WaterCausticMaterial;
private static Mesh m_mesh;

return;
CommandBuffer cmd = CommandBufferPool.Get(k_RenderWaterCausticsTag);
using (new ProfilingSample(cmd, k_RenderWaterCausticsTag))
using (new ProfilingScope(cmd, m_WaterCaustics_Profile))
{
// Create mesh if needed
if (!m_mesh)

WaterCausticsPass m_CausticsPass;
public WaterSystemSettings settings = new WaterSystemSettings();
[SerializeField]
private Shader causticShader;
[SerializeField] private Shader causticShader;
private Material _causticMaterial;

m_CausticsPass = new WaterCausticsPass();
causticShader = causticShader ? causticShader : Shader.Find("Hidden/BoatAttack/Caustics");
if (causticShader == null) return;
_causticMaterial = _causticMaterial ? _causticMaterial : new Material(causticShader);
switch (settings.debug)

public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
renderer.EnqueuePass(m_WaterFxPass);
renderer.EnqueuePass(m_CausticsPass);
if(_causticMaterial == null)
renderer.EnqueuePass(m_CausticsPass);
}
/// <summary>

2
Packages/com.verasl.water-system/Scripts/Rendering/WaterSystemFeature.cs.meta


externalObjects: {}
serializedVersion: 2
defaultReferences:
- causticsMaterial: {fileID: 2100000, guid: 7e6ea000873112847bd146ddb78ac67d, type: 2}
- causticShader: {fileID: 4800000, guid: 90939d2e4b62841d29c136c866715501, type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:

10
Packages/com.verasl.water-system/Scripts/Water.cs


_depthCam = go.AddComponent<Camera>();
}
if (_depthCam.TryGetComponent<UniversalAdditionalCameraData>(out var additionalCamData))
{
additionalCamData.renderShadows = false;
additionalCamData.requiresColorOption = CameraOverrideOption.Off;
additionalCamData.requiresDepthOption = CameraOverrideOption.Off;
}
var additionalCamData = _depthCam.GetUniversalAdditionalCameraData();
additionalCamData.renderShadows = false;
additionalCamData.requiresColorOption = CameraOverrideOption.Off;
additionalCamData.requiresDepthOption = CameraOverrideOption.Off;
var t = _depthCam.transform;
var depthExtra = 4.0f;

7
Packages/manifest.json


"com.unity.build-report-inspector": "0.1.2-preview",
"com.unity.burst": "1.1.2",
"com.unity.cinemachine": "2.5.0",
"com.unity.ide.rider": "1.1.4",
"com.unity.ide.rider": "1.2.1",
"com.unity.ide.visualstudio": "2.0.0",
"com.unity.render-pipelines.universal": "7.1.8",
"com.unity.render-pipelines.universal": "7.2.1",
"com.unity.textmeshpro": "2.1.0-preview.4",
"com.unity.textmeshpro": "3.0.0-preview.1",
"com.unity.timeline": "1.2.11",
"com.unity.ugui": "1.0.0",
"net.peeweek.gameplay-ingredients": "https://github.com/peeweek/net.peeweek.gameplay-ingredients.git#2019.3.0",

50
Assets/Scripts/GameSystem/VolumeHolder.cs


using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
[CreateAssetMenu(fileName = "VolumeHolder", menuName = "Volume Holder", order = 0)]
public class VolumeHolder : ScriptableObject
{
[SerializeField]
public AssetReference[] _Volumes;
[FormerlySerializedAs("qualityIndicies")] [SerializeField]
public List<int> qualityIndices = new List<int>();
[FormerlySerializedAs("qualityVolumeIndicies")] [SerializeField]
public List<int> qualityVolumeIndices = new List<int>();
public bool ContainsKey(int key)
{
return qualityIndices.Contains(key);
}
public void Add(int key, int value)
{
qualityIndices.Add(key);
qualityVolumeIndices.Add(value);
}
public void SetKey(int key, int value)
{
if (qualityIndices.Contains(key))
{
qualityVolumeIndices[qualityIndices.IndexOf(key)] = value;
}
else
{
Add(key, value);
}
}
public int GetValue(int key)
{
if (qualityIndices.Contains(key))
{
return qualityVolumeIndices[qualityIndices.IndexOf(key)];
}
throw new Exception(message: $"{qualityIndices} does not contain key {key}");
}
}

11
Assets/Scripts/GameSystem/VolumeHolder.cs.meta


fileFormatVersion: 2
guid: bea894b80a78a4f9a9d5210e78f59e3b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存