forked from sin365/AxibugEmuOnline
Compare commits
2 Commits
3e1f5b9de8
...
f9a2e82cd0
Author | SHA1 | Date | |
---|---|---|---|
|
f9a2e82cd0 | ||
|
ed91d48cc8 |
@ -1,106 +1,106 @@
|
|||||||
using AxibugEmuOnline.Client;
|
using AxibugEmuOnline.Client;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Rendering.PostProcessing;
|
using UnityEngine.Rendering.PostProcessing;
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
[PostProcess(typeof(FixingPixelArtGrilleRenderer), PostProcessEvent.BeforeStack, "Filter/FixingPixelArtGrille")]
|
[PostProcess(typeof(FixingPixelArtGrilleRenderer), PostProcessEvent.BeforeStack, "Filter/FixingPixelArtGrille")]
|
||||||
public sealed class FixingPixelArtGrille : FilterEffect
|
public sealed class FixingPixelArtGrille : FilterEffect
|
||||||
{
|
{
|
||||||
public override string Name => nameof(FixingPixelArtGrille);
|
public override string Name => nameof(FixingPixelArtGrille);
|
||||||
|
|
||||||
public ParameterOverride<EnumMaskStyle> MaskStyle = new ParameterOverride<EnumMaskStyle> { value = EnumMaskStyle.ApertureGrille };
|
public ParameterOverride<EnumMaskStyle> MaskStyle = new ParameterOverride<EnumMaskStyle> { value = EnumMaskStyle.ApertureGrille };
|
||||||
|
|
||||||
[Tooltip("Emulated input resolution\nOptimize for resize")]
|
[Tooltip("Emulated input resolution\nOptimize for resize")]
|
||||||
public Vector2Parameter DrawResolution = new Vector2Parameter
|
public Vector2Parameter DrawResolution = new Vector2Parameter
|
||||||
{
|
{
|
||||||
value = new Vector2(272, 240)
|
value = new Vector2(272, 240)
|
||||||
};
|
};
|
||||||
|
|
||||||
[Tooltip("Hardness of scanline")]
|
[Tooltip("Hardness of scanline")]
|
||||||
[Range(-32, 0)]
|
[Range(-32, 0)]
|
||||||
public FloatParameter HardScan = new FloatParameter { value = -10 };
|
public FloatParameter HardScan = new FloatParameter { value = -10 };
|
||||||
|
|
||||||
[Tooltip("Hardness of pixels in scanline")]
|
[Tooltip("Hardness of pixels in scanline")]
|
||||||
[Range(-6, 0)]
|
[Range(-6, 0)]
|
||||||
public FloatParameter HardPix = new FloatParameter { value = -2 };
|
public FloatParameter HardPix = new FloatParameter { value = -2 };
|
||||||
|
|
||||||
[Tooltip("Hardness of short vertical bloom")]
|
[Tooltip("Hardness of short vertical bloom")]
|
||||||
[Range(-8, 0)]
|
[Range(-8, 0)]
|
||||||
public FloatParameter HardBloomScan = new FloatParameter { value = -4.0f };
|
public FloatParameter HardBloomScan = new FloatParameter { value = -4.0f };
|
||||||
|
|
||||||
[Tooltip("Hardness of short horizontal bloom")]
|
[Tooltip("Hardness of short horizontal bloom")]
|
||||||
[Range(-4, 0)]
|
[Range(-4, 0)]
|
||||||
public FloatParameter HardBloomPix = new FloatParameter { value = -1.5f };
|
public FloatParameter HardBloomPix = new FloatParameter { value = -1.5f };
|
||||||
|
|
||||||
[Tooltip("Amount of small bloom effect")]
|
[Tooltip("Amount of small bloom effect")]
|
||||||
[Range(0, 1)]
|
[Range(0, 1)]
|
||||||
public FloatParameter BloomAmount = new FloatParameter { value = 1 / 16f };
|
public FloatParameter BloomAmount = new FloatParameter { value = 1 / 16f };
|
||||||
|
|
||||||
[Tooltip("Display warp")]
|
[Tooltip("Display warp")]
|
||||||
public Vector2Parameter Warp = new Vector2Parameter { value = new Vector2(1f / 64f, 1f / 24f) };
|
public Vector2Parameter Warp = new Vector2Parameter { value = new Vector2(1f / 64f, 1f / 24f) };
|
||||||
|
|
||||||
[Tooltip("Amount of shadow mask Light")]
|
[Tooltip("Amount of shadow mask Light")]
|
||||||
[Range(1, 3)]
|
[Range(1, 3)]
|
||||||
public FloatParameter MaskLight = new FloatParameter { value = 1.5f };
|
public FloatParameter MaskLight = new FloatParameter { value = 1.5f };
|
||||||
[Range(0.1f, 1)]
|
[Range(0.1f, 1)]
|
||||||
[Tooltip("Amount of shadow mask Dark")]
|
[Tooltip("Amount of shadow mask Dark")]
|
||||||
public FloatParameter MaskDrak = new FloatParameter { value = 0.5f };
|
public FloatParameter MaskDrak = new FloatParameter { value = 0.5f };
|
||||||
|
|
||||||
public enum EnumMaskStyle
|
public enum EnumMaskStyle
|
||||||
{
|
{
|
||||||
TVStyle,
|
TVStyle,
|
||||||
ApertureGrille,
|
ApertureGrille,
|
||||||
StretchedVGA,
|
StretchedVGA,
|
||||||
VGAStyle
|
VGAStyle
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class FixingPixelArtGrilleRenderer : PostProcessEffectRenderer<FixingPixelArtGrille>
|
public sealed class FixingPixelArtGrilleRenderer : PostProcessEffectRenderer<FixingPixelArtGrille>
|
||||||
{
|
{
|
||||||
private Shader shader;
|
private Shader shader;
|
||||||
private Material material;
|
private Material material;
|
||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
shader = Shader.Find("PostEffect/FixingPixcelArtGrille");
|
shader = Shader.Find("PostEffect/FixingPixcelArtGrille");
|
||||||
material = new Material(shader);
|
material = new Material(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Render(PostProcessRenderContext context)
|
public override void Render(PostProcessRenderContext context)
|
||||||
{
|
{
|
||||||
material.SetVector("_iResolution", new Vector4(Screen.width, Screen.height, 0, 0));
|
material.SetVector("_iResolution", new Vector4(Screen.width, Screen.height, 0, 0));
|
||||||
var res = settings.DrawResolution;
|
var res = settings.DrawResolution;
|
||||||
material.SetVector("_res", new Vector4(res.value.x, res.value.y, 0, 0));
|
material.SetVector("_res", new Vector4(res.value.x, res.value.y, 0, 0));
|
||||||
material.SetFloat("_hardScan", settings.HardScan.value);
|
material.SetFloat("_hardScan", settings.HardScan.value);
|
||||||
material.SetFloat("_hardPix", settings.HardPix.value);
|
material.SetFloat("_hardPix", settings.HardPix.value);
|
||||||
material.SetFloat("_hardBloomScan", settings.HardBloomScan.value);
|
material.SetFloat("_hardBloomScan", settings.HardBloomScan.value);
|
||||||
material.SetFloat("_hardBloomPix", settings.HardBloomPix.value);
|
material.SetFloat("_hardBloomPix", settings.HardBloomPix.value);
|
||||||
material.SetFloat("_bloomAmount", settings.BloomAmount.value);
|
material.SetFloat("_bloomAmount", settings.BloomAmount.value);
|
||||||
material.SetVector("_warp", settings.Warp.value);
|
material.SetVector("_warp", settings.Warp.value);
|
||||||
material.SetFloat("_maskDark", settings.MaskDrak.value);
|
material.SetFloat("_maskDark", settings.MaskDrak.value);
|
||||||
material.SetFloat("_maskLight", settings.MaskLight.value);
|
material.SetFloat("_maskLight", settings.MaskLight.value);
|
||||||
|
|
||||||
material.DisableKeyword("_MASKSTYLE_VGASTYLE");
|
material.DisableKeyword("_MASKSTYLE_VGASTYLE");
|
||||||
material.DisableKeyword("_MASKSTYLE_TVSTYLE");
|
material.DisableKeyword("_MASKSTYLE_TVSTYLE");
|
||||||
material.DisableKeyword("_MASKSTYLE_APERTUREGRILLE");
|
material.DisableKeyword("_MASKSTYLE_APERTUREGRILLE");
|
||||||
material.DisableKeyword("_MASKSTYLE_STRETCHEDVGA");
|
material.DisableKeyword("_MASKSTYLE_STRETCHEDVGA");
|
||||||
|
|
||||||
switch (settings.MaskStyle.value)
|
switch (settings.MaskStyle.value)
|
||||||
{
|
{
|
||||||
case FixingPixelArtGrille.EnumMaskStyle.VGAStyle:
|
case FixingPixelArtGrille.EnumMaskStyle.VGAStyle:
|
||||||
material.EnableKeyword("_MASKSTYLE_VGASTYLE");
|
material.EnableKeyword("_MASKSTYLE_VGASTYLE");
|
||||||
break;
|
break;
|
||||||
case FixingPixelArtGrille.EnumMaskStyle.TVStyle:
|
case FixingPixelArtGrille.EnumMaskStyle.TVStyle:
|
||||||
material.EnableKeyword("_MASKSTYLE_TVSTYLE");
|
material.EnableKeyword("_MASKSTYLE_TVSTYLE");
|
||||||
break;
|
break;
|
||||||
case FixingPixelArtGrille.EnumMaskStyle.ApertureGrille:
|
case FixingPixelArtGrille.EnumMaskStyle.ApertureGrille:
|
||||||
material.EnableKeyword("_MASKSTYLE_APERTUREGRILLE");
|
material.EnableKeyword("_MASKSTYLE_APERTUREGRILLE");
|
||||||
break;
|
break;
|
||||||
case FixingPixelArtGrille.EnumMaskStyle.StretchedVGA:
|
case FixingPixelArtGrille.EnumMaskStyle.StretchedVGA:
|
||||||
material.EnableKeyword("_MASKSTYLE_STRETCHEDVGA");
|
material.EnableKeyword("_MASKSTYLE_STRETCHEDVGA");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.command.Blit(context.source, context.destination, material);
|
context.command.Blit(context.source, context.destination, material);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user