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: 2360a902648b9a14b85a54db256230c9
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(PixelizeHexagonGrid))]
public sealed class PixelizeHexagonGridEditor : PostProcessEffectEditor<PixelizeHexagonGrid>
{
SerializedParameterOverride pixelSize;
SerializedParameterOverride useAutoScreenRatio;
SerializedParameterOverride pixelRatio;
SerializedParameterOverride pixelScaleX;
SerializedParameterOverride pixelScaleY;
SerializedParameterOverride gridWidth;
public override void OnEnable()
{
pixelSize = FindParameterOverride(x => x.pixelSize);
useAutoScreenRatio = FindParameterOverride(x => x.useAutoScreenRatio);
pixelRatio = FindParameterOverride(x => x.pixelRatio);
pixelScaleX = FindParameterOverride(x => x.pixelScaleX);
pixelScaleY = FindParameterOverride(x => x.pixelScaleY);
gridWidth = FindParameterOverride(x => x.gridWidth);
}
public override string GetDisplayTitle()
{
return XPostProcessingEditorUtility.DISPLAY_TITLE_PREFIX + base.GetDisplayTitle();
}
public override void OnInspectorGUI()
{
EditorUtilities.DrawHeaderLabel("Core Property");
PropertyField(pixelSize);
PropertyField(gridWidth);
}
}
}

View File

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

View File

@ -0,0 +1,78 @@
//----------------------------------------------------------------------------------------------------------
// 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(PixelizeHexagonGridRenderer), PostProcessEvent.BeforeStack, "X-PostProcessing/Pixelize/PixelizeHexagonGrid")]
public class PixelizeHexagonGrid : PostProcessEffectSettings
{
[Range(0.01f, 1.0f)]
public FloatParameter pixelSize = new FloatParameter { value = 0.05f };
[Range(0.01f, 5.0f)]
public FloatParameter gridWidth = new FloatParameter { value = 1.0f };
public BoolParameter useAutoScreenRatio = new BoolParameter { value = false };
[Range(0.2f, 5.0f)]
public FloatParameter pixelRatio = new FloatParameter { value = 1f };
[Range(0.2f, 5.0f)]
public FloatParameter pixelScaleX = new FloatParameter { value = 1f };
[Range(0.2f, 5.0f)]
public FloatParameter pixelScaleY = new FloatParameter { value = 1f };
}
public sealed class PixelizeHexagonGridRenderer : PostProcessEffectRenderer<PixelizeHexagonGrid>
{
private const string PROFILER_TAG = "X-PixelizeHexagonGrid";
private Shader shader;
public override void Init()
{
shader = Shader.Find("Hidden/X-PostProcessing/PixelizeHexagonGrid");
}
public override void Release()
{
base.Release();
}
static class ShaderIDs
{
internal static readonly int Params = Shader.PropertyToID("_Params");
}
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.pixelSize, settings.gridWidth));
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
cmd.EndSample(PROFILER_TAG);
}
}
}

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,165 @@
//----------------------------------------------------------------------------------------------------------
// 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
//----------------------------------------------------------------------------------------------------------
//reference :
// 1. https://www.shadertoy.com/view/ls23Dc
// 2. http://coding-experiments.blogspot.nl/2010/06/pixelation.html
Shader "Hidden/X-PostProcessing/PixelizeHexagonGrid"
{
HLSLINCLUDE
#include "../../../Shaders/StdLib.hlsl"
#include "../../../Shaders/XPostProcessing.hlsl"
half2 _Params;
#define _PixelSize _Params.x
#define _GridWidth _Params.y
float HexDist(float2 a, float2 b)
{
float2 p = abs(b - a);
float s = 0.5;
float c = 0.8660254;
float diagDist = s * p.x + c * p.y;
return max(diagDist, p.x) / c;
}
float2 NearestHex(float s, float2 st)
{
float h = 0.5 * s;
float r = 0.8660254 * s;
float b = s + 2.0 * h;
float a = 2.0 * r;
float m = h / r;
float2 sect = st / float2(2.0 * r, h + s);
float2 sectPxl = fmod(st, float2(2.0 * r, h + s));
float aSection = fmod(floor(sect.y), 2.0);
float2 coord = floor(sect);
if (aSection > 0.0)
{
if(sectPxl.y < (h - sectPxl.x * m))
{
coord -= 1.0;
}
else if(sectPxl.y < (-h + sectPxl.x * m))
{
coord.y -= 1.0;
}
}
else
{
if(sectPxl.x > r)
{
if(sectPxl.y < (2.0 * h - sectPxl.x * m))
{
coord.y -= 1.0;
}
}
else
{
if(sectPxl.y < (sectPxl.x * m))
{
coord.y -= 1.0;
}
else
{
coord.x -= 1.0;
}
}
}
float xoff = fmod(coord.y, 2.0) * r;
return float2(coord.x * 2.0 * r - xoff, coord.y * (h + s)) + float2(r * 2.0, s);
}
float4 FragHexGrid(VaryingsDefault i) : SV_Target
{
//cal hexagon uv
float pixelSize = _PixelSize * _ScreenParams.x * 0.2;
float2 nearest = NearestHex(pixelSize, i.texcoord * _ScreenParams.xy);
float4 finalColor = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, nearest / _ScreenParams.xy);
float dist = HexDist(i.texcoord * _ScreenParams.xy, nearest);
float interiorSize = pixelSize;
float interior = 1.0 - smoothstep(interiorSize - 0.8, interiorSize, dist * _GridWidth);
return float4(finalColor.rgb * interior, 1.0);
}
float2 HexPixelizeUV(float2 hexIndex)
{
int i = hexIndex.x;
int j = hexIndex.y;
float2 r;
r.x = i * _Params.x;
r.y = j * _Params.y + (i % 2.0) * _Params.y / 2.0;
return r;
}
//Solve index
float2 HexIndex(float2 uv, float size)
{
float2 r;
int it = int(floor(uv.x / size));
float yts = uv.y - float(it % 2.0) * _Params.y / 2.0;
int jt = int(floor((1.0 / _Params.y) * yts));
float xt = uv.x - it * size;
float yt = yts - jt * _Params.y;
int deltaj = (yt > _Params.y / 2.0) ? 1 : 0;
float fcond = size * (2.0 / 3.0) * abs(0.5 - yt / _Params.y);
if (xt > fcond)
{
r.x = it;
r.y = jt;
}
else
{
r.x = it - 1;
r.y = jt - (r.x % 2) + deltaj;
}
return r;
}
ENDHLSL
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment FragHexGrid
ENDHLSL
}
}
}

View File

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