Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added basic VolumeManager support #242

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
8 changes: 8 additions & 0 deletions Assets/Samples/Volume Framework.meta

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

19 changes: 19 additions & 0 deletions Assets/Samples/Volume Framework/New Toon Sharpen Asset Test.asset
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 75c17d640843a4843b1b6073096ec297, type: 3}
m_Name: New Toon Sharpen Asset Test
m_EditorClassIdentifier:
_forceIncludedShaders:
- {fileID: 0}
Settings:
Order: 0
Amount: 10

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

8 changes: 8 additions & 0 deletions Assets/Samples/Volume Framework/Pipeline.meta

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 1f6a429550954192bf507d745572b8de, type: 3}
m_Name: VolumeFrameworkToonPipelineAsset
m_EditorClassIdentifier:
ForceIncludedShaders:
- {fileID: 4800000, guid: 32cf79821a574ca29fd7697e92aae19d, type: 3}
- {fileID: 4800000, guid: 11527595c9484fb09a4ee48b0e47204f, type: 3}
- {fileID: 4800000, guid: 48be904f99f74bee85d2e82c67910da8, type: 3}
- {fileID: 4800000, guid: 3774c88acba044f58195398345cfc7cd, type: 3}
- {fileID: 4800000, guid: 7be86da3d47840bd8b73ba28db1a2ca1, type: 3}
- {fileID: 4800000, guid: 2268c7f425a8453ba9e77607d402a9b4, type: 3}
- {fileID: 4800000, guid: 4aee5d6e842043a384557e2f0557f76c, type: 3}
GlobalRampSettings:
Threshold: 0
SpecularThreshold: 0.79
RimThreshold: -0.328
Mode: 2
Smoothness: 0.083
SpecularSmoothness: 0.367
RimSmoothness: 1.65
RampTexture: {fileID: 2800000, guid: 752a48c13df68ea4aae97103de1292d2, type: 3}
AdditionalLights:
DiffuseOffset: 0
SpecularOffset: 0
DistanceAttenuationFactor: 1
CameraRendererSettings:
AdditionalLights: 1
TiledLighting: 0
MaxLightsPerTile: 32
OverrideRenderTextureFormat: 0
RenderTextureFormat: 67
AllowHdr: 0
Stencil: 0
Msaa: 1
RenderScale: 1
MaxRenderTextureWidth: 0
MaxRenderTextureHeight: 0
RenderTextureFilterMode: 1
PrePass: 1
OpaqueTexture: 0
OpaqueLayerMask:
serializedVersion: 2
m_Bits: 4294967295
TransparentLayerMask:
serializedVersion: 2
m_Bits: 247
MotionVectorsZeroLayerMask:
serializedVersion: 2
m_Bits: 0
UseSrpBatching: 1
UseDynamicBatching: 0
ForceRenderToIntermediateBuffer: 0
NativeRenderPasses: 0
ForceStoreCameraDepth: 0
BakedLightingFeatures: -1
ShadowSettings:
Mode: 1
Threshold: 0.422
CrispAntiAliased: 1
Smoothness: 1
MaxDistance: 25
DistanceFade: 0.354
Pattern: {fileID: 2800000, guid: 370591c24596965498bac30a92b5a7cf, type: 3}
PatternScale: {x: 1, y: 0, z: 1}
ShadowMaps:
DepthBits: 16
Blur: 0
BlurEarlyBail: 1
BlurEarlyBailThreshold: 0.25
BlurScatter: 1
VsmPrecision: 0
SoftShadows:
Enabled: 1
Quality: 1
Mode: 0
EarlyBail: 0
Spread: 1.373
RotatedPoissonSamplingTexture: {fileID: 11700000, guid: 4adf240cd9847b14085d5b3253f0d979, type: 2}
LightBleedingReduction: 0.001
PrecisionCompensation: 0
Directional:
Enabled: 1
AtlasSize: 1024
CascadeCount: 4
CascadeRatio1: 0.299
CascadeRatio2: 0.58
CascadeRatio3: 0.85
DepthBias: 0.034
NormalBias: 0.03
SlopeBias: 1.37
Additional:
Enabled: 0
AtlasSize: 1024
Blobs:
AtlasSize: 128
Mode: 0
BakedShadowsAtlas: {fileID: 0}
Saturation: 1
ShadowPositionOffset: {x: 0, y: 0}
ReceiverPlaneY: 0
Extensions:
Extensions:
- {fileID: 11400000, guid: 91c04dff8aa908e4e951dac087bdf2ad, type: 2}
- {fileID: 11400000, guid: 1646ef03c10aee74d9d024dabb976ff3, type: 2}
PostProcessing:
Enabled: 1
Passes:
- {fileID: 11400000, guid: 9ade2ead8e7d2434b9b7f3e48c84c5ad, type: 2}

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

8 changes: 8 additions & 0 deletions Assets/Samples/Volume Framework/Scripts.meta

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

36 changes: 36 additions & 0 deletions Assets/Samples/Volume Framework/Scripts/ToonSharpenAssetTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using UnityEngine;
using UnityEngine.Rendering;

namespace DELTation.ToonRP.PostProcessing.BuiltIn
{
[CreateAssetMenu(menuName = Path + "Sharpen Test")]
public class ToonSharpenAssetTest : ToonPostProcessingPassAsset<ToonSharpenSettings>
{
private void Reset()
{
Settings = new ToonSharpenSettings
{
Amount = 0.8f,
};
}

public override int Order() => Settings.Order switch
{
ToonSharpenSettings.PassOrder.PreUpscale => ToonPostProcessingPassOrders.SharpenPreUpscale,
ToonSharpenSettings.PassOrder.PostUpscale => ToonPostProcessingPassOrders.SharpenPostUpscale,
_ => throw new ArgumentOutOfRangeException(),
};

public override IToonPostProcessingPass CreatePass() => new ToonSharpenTest();

protected override string[] ForceIncludedShaderNames() => new[] { ToonSharpenTest.ShaderName };


public override void CopySettingsToVolumeProfile(VolumeProfile profile)
{
ToonSharpenVolumeComponent component = GetOrAddVolumeComponent<ToonSharpenVolumeComponent>(profile);
component.Amount.value = Settings.Amount;
}
}
}

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

20 changes: 20 additions & 0 deletions Assets/Samples/Volume Framework/Scripts/ToonSharpenSettingsTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using UnityEngine;

namespace DELTation.ToonRP.PostProcessing.BuiltIn
{
[Serializable]
public struct ToonSharpenSettingsTest
{
public enum PassOrder
{
PreUpscale,
PostUpscale,
}

public PassOrder Order;

[Range(-0.0f, 10.0f)]
public float Amount;
}
}

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

51 changes: 51 additions & 0 deletions Assets/Samples/Volume Framework/Scripts/ToonSharpenTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;

namespace DELTation.ToonRP.PostProcessing.BuiltIn
{
public class ToonSharpenTest : ToonPostProcessingPassBase
GasimoCodes marked this conversation as resolved.
Show resolved Hide resolved
{
public const string ShaderName = "Hidden/Toon RP/Sharpen";
private static readonly int AmountId = Shader.PropertyToID("_Amount");
private readonly ToonPipelineMaterial _material = new(ShaderName, "Toon RP Sharpen Test");
private Camera _camera;
private ToonSharpenSettings _settings;

public override void Dispose()
{
base.Dispose();
_material.Dispose();
}

public override void Setup(CommandBuffer cmd, in ToonPostProcessingContext context)
{
base.Setup(cmd, in context);
_camera = context.Camera;
}

public override void Render(CommandBuffer cmd, RenderTargetIdentifier source,
RenderTargetIdentifier destination, bool destinationIsIntermediateTexture)
{
using (new ProfilingScope(cmd, NamedProfilingSampler.Get(ToonRpPassId.Sharpen)))
{
cmd.SetRenderTarget(destination, RenderBufferLoadAction.DontCare, RenderBufferStoreAction.Store);

var stack = VolumeManager.instance.stack;
var toonSharpen = stack.GetComponent<ToonSharpenVolumeComponent>();

if (_camera.cameraType == CameraType.Game)
{
Material material = _material.GetOrCreate();
material.SetFloat(AmountId, toonSharpen.Amount.value);
cmd.SetGlobalTexture(ToonBlitter.MainTexId, source);
ToonBlitter.Blit(cmd, material, destinationIsIntermediateTexture, 0);
}
else
{
ToonBlitter.BlitDefault(cmd, source, destinationIsIntermediateTexture);
}
}
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using UnityEngine;
using UnityEngine.Rendering;
using static DELTation.ToonRP.PostProcessing.BuiltIn.ToonSharpenSettingsTest;

[VolumeComponentMenu("ToonRP/Toon Sharpen")]
public class ToonSharpenVolumeComponent : VolumeComponent
{
public ClampedFloatParameter Amount = new ClampedFloatParameter(0f, 0f, 10f);
public EnumParameter<PassOrder> Order = new EnumParameter<PassOrder>(PassOrder.PreUpscale);
Delt06 marked this conversation as resolved.
Show resolved Hide resolved
public bool IsActive() => Amount.value > 0f;

protected override void OnEnable()
{
base.OnEnable();
displayName = "Toon Sharpen";
}

}

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

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

Loading