Skip to content

Commit f454f61

Browse files
committed
新增【ColorAdjustment色彩调整】系列后处理特效 | add ColorAdjustment Effect Series
新增【ColorAdjustment色彩调整】系列后处理特效 | add ColorAdjustment Effect Series
1 parent da4ef68 commit f454f61

File tree

105 files changed

+2684
-4
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

105 files changed

+2684
-4
lines changed

Assets/Example/ExampleScene.unity

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,6 +2786,38 @@ MonoBehaviour:
27862786
Culture=neutral, PublicKeyToken=null
27872787
- assemblyQualifiedName: XPostProcessing.GlitchWaveJitter, Assembly-CSharp, Version=0.0.0.0,
27882788
Culture=neutral, PublicKeyToken=null
2789+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentBleachBypass, Assembly-CSharp,
2790+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2791+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentBrightness, Assembly-CSharp,
2792+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2793+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentContrast, Assembly-CSharp,
2794+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2795+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentContrastV2, Assembly-CSharp,
2796+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2797+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentContrastV3, Assembly-CSharp,
2798+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2799+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentHue, Assembly-CSharp, Version=0.0.0.0,
2800+
Culture=neutral, PublicKeyToken=null
2801+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentLensFilter, Assembly-CSharp,
2802+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2803+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentSaturation, Assembly-CSharp,
2804+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2805+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentTechnicolor, Assembly-CSharp,
2806+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2807+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentTint, Assembly-CSharp, Version=0.0.0.0,
2808+
Culture=neutral, PublicKeyToken=null
2809+
- assemblyQualifiedName: XPostProcessing.ColorAdjustmentWhiteBalance, Assembly-CSharp,
2810+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2811+
- assemblyQualifiedName: XPostProcessing.AuroraVignette, Assembly-CSharp, Version=0.0.0.0,
2812+
Culture=neutral, PublicKeyToken=null
2813+
- assemblyQualifiedName: XPostProcessing.RapidOldTVVignette, Assembly-CSharp, Version=0.0.0.0,
2814+
Culture=neutral, PublicKeyToken=null
2815+
- assemblyQualifiedName: XPostProcessing.RapidOldTVVignetteV2, Assembly-CSharp,
2816+
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
2817+
- assemblyQualifiedName: XPostProcessing.RapidVignette, Assembly-CSharp, Version=0.0.0.0,
2818+
Culture=neutral, PublicKeyToken=null
2819+
- assemblyQualifiedName: XPostProcessing.RapidVignetteV2, Assembly-CSharp, Version=0.0.0.0,
2820+
Culture=neutral, PublicKeyToken=null
27892821
--- !u!4 &1536011139 stripped
27902822
Transform:
27912823
m_PrefabParentObject: {fileID: 400000, guid: 901490205d4d95e4d8fd461462b7c61a, type: 3}

Assets/X-PostProcessing/Effects/ColorAdjustmentBleachBypass.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+

2+
//----------------------------------------------------------------------------------------------------------
3+
// X-PostProcessing Library
4+
// https://github.com/QianMo/X-PostProcessing-Library
5+
// Copyright (C) 2020 QianMo. All rights reserved.
6+
// Licensed under the MIT License
7+
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
8+
// http://opensource.org/licenses/MIT
9+
//----------------------------------------------------------------------------------------------------------
10+
11+
using System;
12+
using UnityEngine;
13+
using UnityEngine.Rendering.PostProcessing;
14+
15+
16+
namespace XPostProcessing
17+
{
18+
19+
[Serializable]
20+
[PostProcess(typeof(ColorAdjustmentBleachBypassRenderer), PostProcessEvent.AfterStack, "X-PostProcessing/ColorAdjustment/BleachBypass")]
21+
public class ColorAdjustmentBleachBypass : PostProcessEffectSettings
22+
{
23+
24+
[Range(0.0f, 1.0f)]
25+
public FloatParameter Indensity = new FloatParameter { value = 0.5f };
26+
27+
}
28+
29+
public sealed class ColorAdjustmentBleachBypassRenderer : PostProcessEffectRenderer<ColorAdjustmentBleachBypass>
30+
{
31+
private Shader shader;
32+
private const string PROFILER_TAG = "X-ColorAdjustmentBleachBypass";
33+
34+
35+
public override void Init()
36+
{
37+
shader = Shader.Find("Hidden/X-PostProcessing/ColorAdjustment/BleachBypass");
38+
}
39+
40+
public override void Release()
41+
{
42+
base.Release();
43+
}
44+
45+
static class ShaderIDs
46+
{
47+
internal static readonly int Indensity = Shader.PropertyToID("_Indensity");
48+
}
49+
50+
public override void Render(PostProcessRenderContext context)
51+
{
52+
context.command.BeginSample(PROFILER_TAG);
53+
PropertySheet sheet = context.propertySheets.Get(shader);
54+
55+
56+
sheet.properties.SetFloat(ShaderIDs.Indensity, settings.Indensity);
57+
58+
59+
context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
60+
context.command.EndSample(PROFILER_TAG);
61+
}
62+
}
63+
}
64+

Assets/X-PostProcessing/Effects/ColorAdjustmentBleachBypass/ColorAdjustmentBleachBypass.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/X-PostProcessing/Effects/ColorAdjustmentBleachBypass/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+

2+
//----------------------------------------------------------------------------------------------------------
3+
// X-PostProcessing Library
4+
// https://github.com/QianMo/X-PostProcessing-Library
5+
// Copyright (C) 2020 QianMo. All rights reserved.
6+
// Licensed under the MIT License
7+
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
8+
// http://opensource.org/licenses/MIT
9+
//----------------------------------------------------------------------------------------------------------
10+
11+
using System.Collections;
12+
using System.Collections.Generic;
13+
using UnityEngine;
14+
using UnityEditor;
15+
16+
using UnityEditor.Rendering.PostProcessing;
17+
using UnityEngine.Rendering.PostProcessing;
18+
19+
namespace XPostProcessing
20+
{
21+
[PostProcessEditor(typeof(ColorAdjustmentBleachBypass))]
22+
public sealed class ColorAdjustmentBleachBypassEditor : PostProcessEffectEditor<ColorAdjustmentBleachBypass>
23+
{
24+
25+
SerializedParameterOverride Indensity;
26+
27+
28+
public override void OnEnable()
29+
{
30+
Indensity = FindParameterOverride(x => x.Indensity);
31+
}
32+
33+
public override string GetDisplayTitle()
34+
{
35+
return XPostProcessingEditorUtility.DISPLAY_TITLE_PREFIX + base.GetDisplayTitle();
36+
}
37+
38+
public override void OnInspectorGUI()
39+
{
40+
PropertyField(Indensity);
41+
}
42+
43+
}
44+
}
45+

Assets/X-PostProcessing/Effects/ColorAdjustmentBleachBypass/Editor/ColorAdjustmentBleachBypassEditor.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/X-PostProcessing/Effects/ColorAdjustmentBleachBypass/Shader.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
//----------------------------------------------------------------------------------------------------------
3+
// X-PostProcessing Library
4+
// https://github.com/QianMo/X-PostProcessing-Library
5+
// Copyright (C) 2020 QianMo. All rights reserved.
6+
// Licensed under the MIT License
7+
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
8+
// http://opensource.org/licenses/MIT
9+
//----------------------------------------------------------------------------------------------------------
10+
11+
Shader "Hidden/X-PostProcessing/ColorAdjustment/BleachBypass"
12+
{
13+
HLSLINCLUDE
14+
15+
#include "../../../Shaders/StdLib.hlsl"
16+
#include "../../../Shaders/XPostProcessing.hlsl"
17+
18+
uniform half _Indensity;
19+
20+
half luminance(half3 color)
21+
{
22+
return dot(color, half3(0.222, 0.707, 0.071));
23+
}
24+
25+
//reference : https://developer.download.nvidia.com/shaderlibrary/webpages/shader_library.html
26+
half4 Frag(VaryingsDefault i): SV_Target
27+
{
28+
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
29+
half lum = luminance(color.rgb);
30+
half3 blend = half3(lum, lum, lum);
31+
half L = min(1.0, max(0.0, 10.0 * (lum - 0.45)));
32+
half3 result1 = 2.0 * color.rgb * blend;
33+
half3 result2 = 1.0 - 2.0 * (1.0 - blend) * (1.0 - color.rgb);
34+
half3 newColor = lerp(result1, result2, L);
35+
36+
return lerp(color, half4(newColor, color.a), _Indensity);
37+
}
38+
39+
ENDHLSL
40+
41+
SubShader
42+
{
43+
Cull Off ZWrite Off ZTest Always
44+
45+
Pass
46+
{
47+
HLSLPROGRAM
48+
49+
#pragma vertex VertDefault
50+
#pragma fragment Frag
51+
52+
ENDHLSL
53+
54+
}
55+
}
56+
}
57+
58+

Assets/X-PostProcessing/Effects/ColorAdjustmentBleachBypass/Shader/ColorAdjustmentBleachBypass.shader.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/X-PostProcessing/Effects/ColorAdjustmentBrightness.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+

2+
//----------------------------------------------------------------------------------------------------------
3+
// X-PostProcessing Library
4+
// https://github.com/QianMo/X-PostProcessing-Library
5+
// Copyright (C) 2020 QianMo. All rights reserved.
6+
// Licensed under the MIT License
7+
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
8+
// http://opensource.org/licenses/MIT
9+
//----------------------------------------------------------------------------------------------------------
10+
11+
using System;
12+
using UnityEngine;
13+
using UnityEngine.Rendering;
14+
using UnityEngine.Rendering.PostProcessing;
15+
16+
17+
namespace XPostProcessing
18+
{
19+
20+
[Serializable]
21+
[PostProcess(typeof(ColorAdjustmentBrightnessRenderer), PostProcessEvent.AfterStack, "X-PostProcessing/ColorAdjustment/Brightness")]
22+
public class ColorAdjustmentBrightness : PostProcessEffectSettings
23+
{
24+
[Range(-0.9f ,1f)]
25+
public FloatParameter brightness = new FloatParameter { value = 0f };
26+
}
27+
28+
public sealed class ColorAdjustmentBrightnessRenderer : PostProcessEffectRenderer<ColorAdjustmentBrightness>
29+
{
30+
private Shader shader;
31+
private const string PROFILER_TAG = "X-ColorAdjustmentBrightness";
32+
33+
public override void Init()
34+
{
35+
shader = Shader.Find("Hidden/X-PostProcessing/ColorAdjustment/Brightness");
36+
}
37+
38+
public override void Release()
39+
{
40+
base.Release();
41+
}
42+
43+
static class ShaderIDs
44+
{
45+
internal static readonly int brightness = Shader.PropertyToID("_Brightness");
46+
}
47+
48+
public override void Render(PostProcessRenderContext context)
49+
{
50+
CommandBuffer cmd = context.command;
51+
PropertySheet sheet = context.propertySheets.Get(shader);
52+
cmd.BeginSample(PROFILER_TAG);
53+
54+
sheet.properties.SetFloat(ShaderIDs.brightness, settings.brightness + 1f);
55+
56+
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
57+
58+
cmd.EndSample(PROFILER_TAG);
59+
}
60+
}
61+
}
62+

Assets/X-PostProcessing/Effects/ColorAdjustmentBrightness/ColorAdjustmentBrightness.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/X-PostProcessing/Effects/ColorAdjustmentBrightness/Editor.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)