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,8 @@
fileFormatVersion: 2
guid: b44794f1979005e499326ad8e8533fec
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,64 @@
//----------------------------------------------------------------------------------------------------------
// 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(PixelizeLed))]
public sealed class PixelizeLedEditor : PostProcessEffectEditor<PixelizeLed>
{
SerializedParameterOverride pixelSize;
SerializedParameterOverride useAutoScreenRatio;
SerializedParameterOverride pixelRatio;
SerializedParameterOverride BackgroundColor;
SerializedParameterOverride ledRadius;
public override void OnEnable()
{
pixelSize = FindParameterOverride(x => x.pixelSize);
ledRadius = FindParameterOverride(x => x.ledRadius);
useAutoScreenRatio = FindParameterOverride(x => x.useAutoScreenRatio);
pixelRatio = FindParameterOverride(x => x.pixelRatio);
BackgroundColor = FindParameterOverride(x => x.BackgroundColor);
}
public override string GetDisplayTitle()
{
return XPostProcessingEditorUtility.DISPLAY_TITLE_PREFIX + base.GetDisplayTitle();
}
public override void OnInspectorGUI()
{
EditorUtilities.DrawHeaderLabel("Core Property");
PropertyField(pixelSize);
PropertyField(ledRadius);
PropertyField(useAutoScreenRatio);
if (useAutoScreenRatio.value.boolValue == false)
{
PropertyField(pixelRatio);
}
EditorUtilities.DrawHeaderLabel("Pixel Scale");
PropertyField(BackgroundColor);
}
}
}

View File

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

View File

@ -0,0 +1,89 @@
//----------------------------------------------------------------------------------------------------------
// 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(PixelizeLedV2Renderer), PostProcessEvent.BeforeStack, "X-PostProcessing/Pixelize/PixelizeLed")]
public class PixelizeLed : PostProcessEffectSettings
{
[Range(0.01f, 1.0f)]
public FloatParameter pixelSize = new FloatParameter { value = 0.5f };
[Range(0.01f, 1.0f)]
public FloatParameter ledRadius = new FloatParameter { value = 1.0f };
[ColorUsageAttribute(true, true, 0f, 20f, 0.125f, 3f)]
public ColorParameter BackgroundColor = new ColorParameter { value = new Color(0.0f, 0.0f, 0.0f) };
public BoolParameter useAutoScreenRatio = new BoolParameter { value = true };
[Range(0.2f, 5.0f)]
public FloatParameter pixelRatio = new FloatParameter { value = 1f };
}
public sealed class PixelizeLedV2Renderer : PostProcessEffectRenderer<PixelizeLed>
{
private const string PROFILER_TAG = "X-PixelizeLed";
private Shader shader;
public override void Init()
{
shader = Shader.Find("Hidden/X-PostProcessing/PixelizeLed");
}
public override void Release()
{
base.Release();
}
static class ShaderIDs
{
internal static readonly int Params = Shader.PropertyToID("_Params");
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);
float size = (1.01f - settings.pixelSize) * 300f;
float ratio = settings.pixelRatio;
if (settings.useAutoScreenRatio)
{
ratio = (float)(context.width / (float)context.height);
if (ratio == 0)
{
ratio = 1f;
}
}
sheet.properties.SetVector(ShaderIDs.Params, new Vector4(size, ratio, settings.ledRadius));
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: 2adfd539c4f87f148b8c618d20355086
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,18 @@
# Pixelize Led
## Source Code List
- [Shader Code](Shader/PixelizeLed.shader)
- [C# Code](PixelizeLed.cs)
- [Editor Code](Editor/PixelizeLedEditor.cs)
## Property
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/Pixelize/PixelizeLed/PixelizeLedProperty.jpg)
## Gallery
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/Pixelize/PixelizeLed/PixelizeLed.jpg)
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/Pixelize/PixelizeLed/PixelizeLed.gif)
![](https://raw.githubusercontent.com/QianMo/X-PostProcessing-Gallery/master/Media/Pixelize/PixelizeLed/PixelizeLed-2.gif)

View File

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

View File

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

View File

@ -0,0 +1,75 @@
//----------------------------------------------------------------------------------------------------------
// 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/PixelizeLed"
{
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment Frag
#include "../../../Shaders/StdLib.hlsl"
#include "../../../Shaders/XPostProcessing.hlsl"
half4 _Params;
half4 _BackgroundColor;
#define _PixelSize _Params.x
#define _PixelRatio _Params.y
#define _LedRadius _Params.z
float2 RectPixelizeUV(half2 uv)
{
float pixelScale = 1.0 / _PixelSize;
//除以缩放系数在向上取整再乘以缩放系数得到分段UV
float2 coord = half2(pixelScale * floor(uv.x / (pixelScale)), (pixelScale * _PixelRatio ) * floor(uv.y / (pixelScale *_PixelRatio)));
return coord;
}
float4 Frag(VaryingsDefault i) : SV_Target
{
// 实现矩形像素效果
float2 uv = RectPixelizeUV(i.texcoord);
float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
// 计算矩形像素坐标
half2 coord = i.texcoord * half2(_PixelSize, _PixelSize / _PixelRatio);
// 横纵坐标强度渐变
half ledX = abs(sin(coord.x * 3.1415)) * 1.5;
half ledY = abs(sin(coord.y * 3.1415)) * 1.5;
// 求解LedValue
half ledValue = ledX * ledY;
// led半径校正
half radius = step(ledValue, _LedRadius);
//最终颜色 = 基础led颜色 + 渐变led颜色 + 背景颜色
color = ((1 - radius) * color) + ((color * ledValue) * radius) + radius * (1- ledValue)* _BackgroundColor;
return color;
}
ENDHLSL
}
}
}

View File

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