mirror of
https://github.com/RHeavenStudio/HeavenStudio.git
synced 2025-06-13 13:17:39 +02:00
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:
8
Assets/X-PostProcessing/Effects/PixelizeQuad/Editor.meta
Normal file
8
Assets/X-PostProcessing/Effects/PixelizeQuad/Editor.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61c4768d0351ad24495a1202309c164d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,63 @@
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
// 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(PixelizeQuad))]
|
||||
public sealed class PixelizeQuadEditor : PostProcessEffectEditor<PixelizeQuad>
|
||||
{
|
||||
|
||||
SerializedParameterOverride pixelSize;
|
||||
SerializedParameterOverride useAutoScreenRatio;
|
||||
SerializedParameterOverride pixelRatio;
|
||||
SerializedParameterOverride pixelScaleX;
|
||||
SerializedParameterOverride pixelScaleY;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public override string GetDisplayTitle()
|
||||
{
|
||||
return XPostProcessingEditorUtility.DISPLAY_TITLE_PREFIX + base.GetDisplayTitle();
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorUtilities.DrawHeaderLabel("Core Property");
|
||||
PropertyField(pixelSize);
|
||||
PropertyField(useAutoScreenRatio);
|
||||
|
||||
if (useAutoScreenRatio.value.boolValue == false)
|
||||
{
|
||||
PropertyField(pixelRatio);
|
||||
}
|
||||
|
||||
|
||||
EditorUtilities.DrawHeaderLabel("Pixel Scale");
|
||||
PropertyField(pixelScaleX);
|
||||
PropertyField(pixelScaleY);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 93b7ec932becebd4398f80d2b1e2164f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
86
Assets/X-PostProcessing/Effects/PixelizeQuad/PixelizeQuad.cs
Normal file
86
Assets/X-PostProcessing/Effects/PixelizeQuad/PixelizeQuad.cs
Normal file
@ -0,0 +1,86 @@
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
// 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(PixelizeQuadRenderer), PostProcessEvent.BeforeStack, "X-PostProcessing/Pixelize/PixelizeQuad")]
|
||||
public class PixelizeQuad : PostProcessEffectSettings
|
||||
{
|
||||
|
||||
[Range(0.01f, 1.0f)]
|
||||
public FloatParameter pixelSize = new FloatParameter { value = 0.5f };
|
||||
|
||||
public BoolParameter useAutoScreenRatio = new BoolParameter { value = true };
|
||||
|
||||
[Range(0.2f, 5.0f)]
|
||||
public FloatParameter pixelRatio = new FloatParameter { value = 1f };
|
||||
|
||||
[Range(0.2f, 5.0f), Tooltip("像素缩放X")]
|
||||
public FloatParameter pixelScaleX = new FloatParameter { value = 1f };
|
||||
|
||||
[Range(0.2f, 5.0f), Tooltip("像素缩放Y")]
|
||||
public FloatParameter pixelScaleY = new FloatParameter { value = 1f };
|
||||
}
|
||||
|
||||
public sealed class PixelizeQuadRenderer : PostProcessEffectRenderer<PixelizeQuad>
|
||||
{
|
||||
private const string PROFILER_TAG = "X-PixelizeQuad";
|
||||
private Shader shader;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
shader = Shader.Find("Hidden/X-PostProcessing/PixelizeQuad");
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
float size = (1.01f - settings.pixelSize) * 200f;
|
||||
sheet.properties.SetFloat("_PixelSize", size);
|
||||
|
||||
|
||||
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.pixelScaleX, settings.pixelScaleY));
|
||||
|
||||
|
||||
cmd.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
|
||||
cmd.EndSample(PROFILER_TAG);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcc23458a58ff384c82bd27e09aa0cc6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
Assets/X-PostProcessing/Effects/PixelizeQuad/README.md
Normal file
16
Assets/X-PostProcessing/Effects/PixelizeQuad/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
|
||||
# Pixelize Quad
|
||||
|
||||
## Source Code List
|
||||
- [Shader Code](Shader/PixelizeQuad.shader)
|
||||
- [C# Code](PixelizeQuad.cs)
|
||||
- [Editor Code](Editor/PixelizeQuadEditor.cs)
|
||||
|
||||
|
||||
## Property
|
||||

|
||||
|
||||
## Gallery
|
||||

|
||||
|
||||

|
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b213252f58037e84c9426babd7dae6ef
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/X-PostProcessing/Effects/PixelizeQuad/Shader.meta
Normal file
8
Assets/X-PostProcessing/Effects/PixelizeQuad/Shader.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19176c3e8e0acdb47963975981b96378
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,59 @@
|
||||
//----------------------------------------------------------------------------------------------------------
|
||||
// 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/PixelizeQuad"
|
||||
{
|
||||
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;
|
||||
#define _PixelSize _Params.x
|
||||
#define _PixelRatio _Params.y
|
||||
#define _PixelScaleX _Params.z
|
||||
#define _PixelScaleY _Params.w
|
||||
|
||||
float2 RectPixelizeUV( half2 uv)
|
||||
{
|
||||
float pixelScale = 1.0 / _PixelSize;
|
||||
// Divide by the scaling factor, round up, and multiply by the scaling factor to get the segmented UV
|
||||
float2 coord = half2(pixelScale * _PixelScaleX * floor(uv.x / (pixelScale *_PixelScaleX)), (pixelScale * _PixelRatio *_PixelScaleY) * floor(uv.y / (pixelScale *_PixelRatio * _PixelScaleY)));
|
||||
|
||||
return coord;
|
||||
}
|
||||
|
||||
|
||||
|
||||
float4 Frag(VaryingsDefault i) : SV_Target
|
||||
{
|
||||
|
||||
float2 uv = RectPixelizeUV(i.texcoord);
|
||||
|
||||
float4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, uv);
|
||||
|
||||
return color;
|
||||
|
||||
}
|
||||
|
||||
ENDHLSL
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4c378672ba36c664cb86ab729efb01da
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user