Skip to content

Commit 69d406a

Browse files
committed
Added multi-injection support.
Fixed a bug in rendering with a render scale. Changed README accordingly.
1 parent ced5807 commit 69d406a

22 files changed

Lines changed: 260 additions & 170 deletions

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
### Added
99
- Added the main functionality for custom post-processing as renderer future for URP.
1010
- Added a scene normal texture renderer feature as a temporary workaround till URP 10 is out.
11-
- Added a shader include file to facilitate creating post process shaders.
11+
- Added a shader include file to facilitate creating post process shaders.

Editor/CustomPostProcessSettingsEditor.cs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ internal class CustomPostProcessSettingsEditor : PropertyDrawer {
1515
/// <summary>
1616
/// This will contain a list of all available renderers for each injection point.
1717
/// </summary>
18-
private Dictionary<CustomPostProcessInjectPoint, List<Type>> _availableRenderers;
18+
private Dictionary<CustomPostProcessInjectionPoint, List<Type>> _availableRenderers;
1919

2020
/// <summary>
2121
/// Contains 3 Reorderable list for each settings property.
@@ -42,7 +42,7 @@ private string GetName(Type type){
4242
/// <summary>
4343
/// Intialize a reoderable list
4444
/// </summary>
45-
void InitList(ref ReorderableList reorderableList, List<string> elements, string headerName, CustomPostProcessInjectPoint injectPoint, CustomPostProcess feature){
45+
void InitList(ref ReorderableList reorderableList, List<string> elements, string headerName, CustomPostProcessInjectionPoint injectionPoint, CustomPostProcess feature){
4646
reorderableList = new ReorderableList(elements, typeof(string), true, true, true, true);
4747

4848
reorderableList.drawHeaderCallback = (rect) => EditorGUI.LabelField(rect, headerName, EditorStyles.boldLabel);
@@ -58,7 +58,7 @@ void InitList(ref ReorderableList reorderableList, List<string> elements, string
5858
{
5959
var menu = new GenericMenu();
6060

61-
foreach (var type in _availableRenderers[injectPoint])
61+
foreach (var type in _availableRenderers[injectionPoint])
6262
{
6363
if (!elements.Contains(type.AssemblyQualifiedName))
6464
menu.AddItem(new GUIContent(GetName(type)), false, () => {
@@ -97,9 +97,9 @@ private void Init(SerializedProperty property){
9797
if(!propertyStates.ContainsKey(path)){
9898
var state = new DrawerState();
9999
var feature = property.serializedObject.targetObject as CustomPostProcess;
100-
InitList(ref state.listAfterOpaqueAndSky, feature.settings.renderersAfterOpaqueAndSky, "After Opaque and Sky", CustomPostProcessInjectPoint.AfterOpaqueAndSky, feature);
101-
InitList(ref state.listBeforePostProcess, feature.settings.renderersBeforePostProcess, "Before Post Process", CustomPostProcessInjectPoint.BeforePostProcess, feature);
102-
InitList(ref state.listAfterPostProcess, feature.settings.renderersAfterPostProcess, "After Post Process", CustomPostProcessInjectPoint.AfterPostProcess, feature);
100+
InitList(ref state.listAfterOpaqueAndSky, feature.settings.renderersAfterOpaqueAndSky, "After Opaque and Sky", CustomPostProcessInjectionPoint.AfterOpaqueAndSky, feature);
101+
InitList(ref state.listBeforePostProcess, feature.settings.renderersBeforePostProcess, "Before Post Process", CustomPostProcessInjectionPoint.BeforePostProcess, feature);
102+
InitList(ref state.listAfterPostProcess, feature.settings.renderersAfterPostProcess, "After Post Process", CustomPostProcessInjectionPoint.AfterPostProcess, feature);
103103
propertyStates.Add(path, state);
104104
}
105105

@@ -141,17 +141,22 @@ private void forceRecreate(CustomPostProcess feature){
141141
/// </summary>
142142
private void populateRenderers(){
143143
if(_availableRenderers != null) return;
144-
_availableRenderers = new Dictionary<CustomPostProcessInjectPoint, List<Type>>(){
145-
{ CustomPostProcessInjectPoint.AfterOpaqueAndSky, new List<Type>() },
146-
{ CustomPostProcessInjectPoint.BeforePostProcess, new List<Type>() },
147-
{ CustomPostProcessInjectPoint.AfterPostProcess , new List<Type>() }
144+
_availableRenderers = new Dictionary<CustomPostProcessInjectionPoint, List<Type>>(){
145+
{ CustomPostProcessInjectionPoint.AfterOpaqueAndSky, new List<Type>() },
146+
{ CustomPostProcessInjectionPoint.BeforePostProcess, new List<Type>() },
147+
{ CustomPostProcessInjectionPoint.AfterPostProcess , new List<Type>() }
148148
};
149149
foreach(var type in TypeCache.GetTypesDerivedFrom<CustomPostProcessRenderer>()){
150150
if(type.IsAbstract) continue;
151151
var attributes = type.GetCustomAttributes(typeof(CustomPostProcessAttribute), false);
152152
if(attributes.Length != 1) continue;
153153
CustomPostProcessAttribute attribute = attributes[0] as CustomPostProcessAttribute;
154-
_availableRenderers[attribute.InjectPoint].Add(type);
154+
if(attribute.InjectionPoint.HasFlag(CustomPostProcessInjectionPoint.AfterOpaqueAndSky))
155+
_availableRenderers[CustomPostProcessInjectionPoint.AfterOpaqueAndSky].Add(type);
156+
if(attribute.InjectionPoint.HasFlag(CustomPostProcessInjectionPoint.BeforePostProcess))
157+
_availableRenderers[CustomPostProcessInjectionPoint.BeforePostProcess].Add(type);
158+
if(attribute.InjectionPoint.HasFlag(CustomPostProcessInjectionPoint.AfterPostProcess))
159+
_availableRenderers[CustomPostProcessInjectionPoint.AfterPostProcess].Add(type);
155160
}
156161
}
157162

0 commit comments

Comments
 (0)