Retro VFX! (also airboarder works now) (#780)

* Super Retro VFX!

* Updated Screen Jump default

* also airboarder works now

---------

Co-authored-by: minenice55 <star.elementa@gmail.com>
This commit is contained in:
wookywok
2024-03-11 16:21:51 -05:00
committed by GitHub
parent bc93a7ab94
commit 92962fef26
915 changed files with 32248 additions and 73 deletions

View File

@ -0,0 +1,79 @@
//----------------------------------------------------------------------------------------------------------
// X-PostProcessing Library
// https://github.com/QianMo/X-PostProcessing-Library
// Copyright (C) 2020 QianMo. All rights reserved.
// Licensed under the MIT License
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
// http://opensource.org/licenses/MIT
//----------------------------------------------------------------------------------------------------------
using System;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
namespace XPostProcessing
{
[Serializable]
[PostProcess(typeof(EdgeDetectionRobertsRenderer), PostProcessEvent.AfterStack, "X-PostProcessing/EdgeDetection/EdgeDetectionRoberts")]
public class EdgeDetectionRoberts : PostProcessEffectSettings
{
[Range(0.05f, 5.0f)]
public FloatParameter edgeWidth = new FloatParameter { value = 0.3f };
[ColorUsageAttribute(true, true, 0f, 20f, 0.125f, 3f)]
public ColorParameter edgeColor = new ColorParameter { value = new Color(0.0f, 0.0f, 0.0f, 1) };
[Range(0.0f, 1.0f)]
public FloatParameter backgroundFade = new FloatParameter { value = 1f };
[ColorUsageAttribute(true, true, 0f, 20f, 0.125f, 3f)]
public ColorParameter backgroundColor = new ColorParameter { value = new Color(1.0f, 1.0f, 1.0f, 1) };
}
public sealed class EdgeDetectionRobertsRenderer : PostProcessEffectRenderer<EdgeDetectionRoberts>
{
private const string PROFILER_TAG = "X-EdgeDetectionRoberts";
private Shader shader;
public override void Init()
{
shader = Shader.Find("Hidden/X-PostProcessing/EdgeDetectionRoberts");
}
public override void Release()
{
base.Release();
}
static class ShaderIDs
{
internal static readonly int Params = Shader.PropertyToID("_Params");
internal static readonly int EdgeColor = Shader.PropertyToID("_EdgeColor");
internal static readonly int BackgroundColor = Shader.PropertyToID("_BackgroundColor");
}
public override void Render(PostProcessRenderContext context)
{
CommandBuffer cmd = context.command;
PropertySheet sheet = context.propertySheets.Get(shader);
cmd.BeginSample(PROFILER_TAG);
sheet.properties.SetVector(ShaderIDs.Params, new Vector2(settings.edgeWidth, settings.backgroundFade));
sheet.properties.SetColor(ShaderIDs.EdgeColor, settings.edgeColor);
sheet.properties.SetColor(ShaderIDs.BackgroundColor, settings.backgroundColor);
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
cmd.EndSample(PROFILER_TAG);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 2f2bae125e8b72241b38b94373f3c521
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 7f7f79c17cb05354299a5212692cbf40
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,57 @@
//----------------------------------------------------------------------------------------------------------
// X-PostProcessing Library
// https://github.com/QianMo/X-PostProcessing-Library
// Copyright (C) 2020 QianMo. All rights reserved.
// Licensed under the MIT License
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
// http://opensource.org/licenses/MIT
//----------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using UnityEditor.Rendering.PostProcessing;
using UnityEngine.Rendering.PostProcessing;
namespace XPostProcessing
{
[PostProcessEditor(typeof(EdgeDetectionRoberts))]
public sealed class EdgeDetectionRobertsEditor : PostProcessEffectEditor<EdgeDetectionRoberts>
{
SerializedParameterOverride edgeWidth;
SerializedParameterOverride backgroundFade;
SerializedParameterOverride edgeColor;
SerializedParameterOverride backgroundColor;
public override void OnEnable()
{
edgeWidth = FindParameterOverride(x => x.edgeWidth);
backgroundFade = FindParameterOverride(x => x.backgroundFade);
edgeColor = FindParameterOverride(x => x.edgeColor);
backgroundColor = FindParameterOverride(x => x.backgroundColor);
}
public override string GetDisplayTitle()
{
return XPostProcessingEditorUtility.DISPLAY_TITLE_PREFIX + base.GetDisplayTitle();
}
public override void OnInspectorGUI()
{
EditorUtilities.DrawHeaderLabel("Edge Property");
PropertyField(edgeWidth);
PropertyField(edgeColor, new GUIContent("Edge Color"));
EditorUtilities.DrawHeaderLabel("Background Property");
PropertyField(backgroundFade);
PropertyField(backgroundColor);
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3c23eb17650b5a04fbfa22af4d124dc3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,20 @@
# Edge Detection Roberts
## Source Code List
- [Shader Code](Shader/EdgeDetectionRoberts.shader)
- [C# Code](EdgeDetectionRoberts.cs)
- [Editor Code](Editor/EdgeDetectionRobertsEditor.cs)
## Property
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/EdgeDetection/EdgeDetectionRoberts/EdgeDetectionRobertsProperty.jpg)
## Gallery
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/EdgeDetection/EdgeDetectionRoberts/EdgeDetectionRoberts1.jpg)
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/EdgeDetection/EdgeDetectionRoberts/EdgeDetectionRoberts2.jpg)
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/EdgeDetection/EdgeDetectionRoberts/EdgeDetectionRoberts1.gif)
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/EdgeDetection/EdgeDetectionRoberts/EdgeDetectionRoberts2.gif)

View File

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 2e91a5e8cb0e98e47bfc1ae0f66565aa
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: fd37fad31c0692144ae95dbf78f1a7c1
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,210 @@
//----------------------------------------------------------------------------------------------------------
// X-PostProcessing Library
// https://github.com/QianMo/X-PostProcessing-Library
// Copyright (C) 2020 QianMo. All rights reserved.
// Licensed under the MIT License
// You may not use this file except in compliance with the License.You may obtain a copy of the License at
// http://opensource.org/licenses/MIT
//----------------------------------------------------------------------------------------------------------
Shader "Hidden/X-PostProcessing/EdgeDetectionRoberts"
{
HLSLINCLUDE
#include "../../../Shaders/StdLib.hlsl"
#include "../../../Shaders/XPostProcessing.hlsl"
half2 _Params;
half4 _EdgeColor;
half4 _BackgroundColor;
#define _EdgeWidth _Params.x
#define _BackgroundFade _Params.y
float intensity(in float4 color)
{
return sqrt((color.x * color.x) + (color.y * color.y) + (color.z * color.z));
}
float sobel(float stepx, float stepy, float2 center)
{
// get samples around pixel
float topLeft = intensity(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, center + float2(-stepx, stepy)));
float bottomLeft = intensity(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, center + float2(-stepx, -stepy)));
float topRight = intensity(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, center + float2(stepx, stepy)));
float bottomRight = intensity(SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, center + float2(stepx, -stepy)));
// Roberts Operator
//X = -1 0 Y = 0 -1
// 0 1 1 0
// Gx = sum(kernelX[i][j]*image[i][j])
float Gx = -1.0 * topLeft + 1.0 * bottomRight;
// Gy = sum(kernelY[i][j]*image[i][j]);
float Gy = -1.0 * topRight + 1.0 * bottomLeft;
float sobelGradient = sqrt((Gx * Gx) + (Gy * Gy));
return sobelGradient;
}
half4 Frag(VaryingsDefault i): SV_Target
{
half4 sceneColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
float sobelGradient = sobel(_EdgeWidth / _ScreenParams.x, _EdgeWidth / _ScreenParams.y, i.texcoord);
half4 backgroundColor = lerp(sceneColor, _BackgroundColor, _BackgroundFade);
float3 edgeColor = lerp(backgroundColor.rgb, _EdgeColor.rgb, sobelGradient);
return float4(edgeColor, 1);
}
ENDHLSL
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment Frag
ENDHLSL
}
}
//HLSLINCLUDE
//
//#include "../../../Shaders/StdLib.hlsl"
//#include "../../../Shaders/XPostProcessing.hlsl"
//
//
//
//half _Float1;
//half _Float2;
//half _Float3;
//half4 _Color1;
//
//struct v2f
//{
// float2 uvRoberts[5] : TEXCOORD0;
// float4 vertex : SV_POSITION;
//};
//v2f vert_Roberts(appdata v)
//{
// v2f o;
// o.vertex = UnityObjectToClipPos(v.vertex);
// o.uvRoberts[0] = v.uv + float2(-1, -1) * _MainTex_TexelSize * _SampleRange;
// o.uvRoberts[1] = v.uv + float2(1, -1) * _MainTex_TexelSize * _SampleRange;
// o.uvRoberts[2] = v.uv + float2(-1, 1) * _MainTex_TexelSize * _SampleRange;
// o.uvRoberts[3] = v.uv + float2(1, 1) * _MainTex_TexelSize * _SampleRange;
// o.uvRoberts[4] = v.uv;
// return o;
//}
//float Roberts(v2f i)
//{
// const float Gx[4] =
// {
// -1, 0,
// 0, 1
// };
// const float Gy[4] =
// {
// 0, -1,
// 1, 0
// };
// float edgex, edgey;
// for (int j = 0; j < 4; j++)
// {
// fixed4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvRoberts[j]);
// float lum = Luminance(col.rgb);
// edgex += lum * Gx[j];
// edgey += lum * Gy[j];
// }
// return 1 - abs(edgex) - abs(edgey);
//}
//fixed4 frag_Roberts(v2f i) : SV_Target
//{
// fixed4 col = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.uvRoberts[4]);
// float g = Roberts(i);
// g = pow(g, _EdgePower);
// col.rgb = lerp(_EdgeColor, _NonEdgeColor, g);
// return col;
//}
////half4 Frag(VaryingsDefault i): SV_Target
////{
////
//// half4 sceneColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoord);
//// half3 col = 0.5 + 0.5 * cos(_Time.y + i.texcoord.xyx + float3(0, 2, 4));
////
//// half3 finalColor = lerp(sceneColor.rgb, col, _Float1 * 0.1);
////
//// return half4(finalColor, 1.0);
////}
////
//ENDHLSL
//
//SubShader
//{
// Cull Off ZWrite Off ZTest Always
//
// Pass
// {
// HLSLPROGRAM
//
// #pragma vertex vert_Roberts
// #pragma fragment frag_Roberts
//
// ENDHLSL
//
// }
//}
}

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: a5e8504f7bef17d4fa9f7af959b51afb
ShaderImporter:
externalObjects: {}
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant: