Add RetroSuite-3D shader components
This commit is contained in:
55
Assets/Scripts/ImageEffects/Dither.cs
Normal file
55
Assets/Scripts/ImageEffects/Dither.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
/// <summary>
|
||||
/// RetroSuite-3D by oxysoft
|
||||
/// https://github.com/oxysoft/RetroSuite3D
|
||||
/// </summary>
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Dither")]
|
||||
public class Dither : MonoBehaviour
|
||||
{
|
||||
Material mMaterial;
|
||||
Shader shader;
|
||||
|
||||
public Texture2D pattern;
|
||||
[Range(0f, 1f)]
|
||||
public float threshold = .45f;
|
||||
[Range(0f, 1f)]
|
||||
public float strength = .45f;
|
||||
|
||||
Material Material
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mMaterial == null)
|
||||
{
|
||||
shader = Shader.Find("Oxysoft/Dither");
|
||||
mMaterial = new Material(shader) { hideFlags = HideFlags.DontSave };
|
||||
}
|
||||
|
||||
return mMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRenderImage(RenderTexture src, RenderTexture dest)
|
||||
{
|
||||
if (Material)
|
||||
{
|
||||
Material.SetTexture("_Dither", pattern);
|
||||
Material.SetInt("_Width", pattern.width);
|
||||
Material.SetInt("_Height", pattern.height);
|
||||
Material.SetFloat("_Threshold", threshold);
|
||||
Material.SetFloat("_Strength", strength);
|
||||
|
||||
Graphics.Blit(src, dest, Material);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (mMaterial)
|
||||
DestroyImmediate(mMaterial);
|
||||
}
|
||||
}
|
||||
12
Assets/Scripts/ImageEffects/Dither.cs.meta
Normal file
12
Assets/Scripts/ImageEffects/Dither.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56014676381a3cb418a607d72c29f23c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences:
|
||||
- pattern: {fileID: 2800000, guid: b269ce72120fe344fba7e2418d7188dd, type: 3}
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/Scripts/ImageEffects/Posterize.cs
Normal file
51
Assets/Scripts/ImageEffects/Posterize.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
/// <summary>
|
||||
/// RetroSuite-3D by oxysoft
|
||||
/// https://github.com/oxysoft/RetroSuite3D
|
||||
/// </summary>
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Posterize")]
|
||||
public class Posterize : MonoBehaviour
|
||||
{
|
||||
Material mMaterial;
|
||||
Shader shader;
|
||||
|
||||
public int redComponent = 8;
|
||||
public int greenComponent = 8;
|
||||
public int blueComponent = 8;
|
||||
|
||||
Material Material
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mMaterial == null)
|
||||
{
|
||||
shader = Shader.Find("Oxysoft/Posterize");
|
||||
mMaterial = new Material(shader) { hideFlags = HideFlags.DontSave };
|
||||
}
|
||||
|
||||
return mMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRenderImage(RenderTexture src, RenderTexture dest)
|
||||
{
|
||||
if (Material)
|
||||
{
|
||||
Material.SetInt("_Red", redComponent);
|
||||
Material.SetInt("_Green", greenComponent);
|
||||
Material.SetInt("_Blue", blueComponent);
|
||||
|
||||
Graphics.Blit(src, dest, Material);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (mMaterial)
|
||||
DestroyImmediate(mMaterial);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ImageEffects/Posterize.cs.meta
Normal file
11
Assets/Scripts/ImageEffects/Posterize.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53ccac51293442343b69d759bb128bb3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/Scripts/ImageEffects/RetroPixelMax.cs
Normal file
53
Assets/Scripts/ImageEffects/RetroPixelMax.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
/// <summary>
|
||||
/// RetroSuite-3D by oxysoft
|
||||
/// https://github.com/oxysoft/RetroSuite3D
|
||||
/// </summary>
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Retro Pixel Max")]
|
||||
public class RetroPixelMax : MonoBehaviour
|
||||
{
|
||||
Material mMaterial;
|
||||
Shader shader;
|
||||
|
||||
[Header("Colors")]
|
||||
public Color[] colors;
|
||||
|
||||
Material Material
|
||||
{
|
||||
get
|
||||
{
|
||||
if (mMaterial == null)
|
||||
{
|
||||
shader = Shader.Find("Oxysoft/RetroPixelMax");
|
||||
mMaterial = new Material(shader) { hideFlags = HideFlags.DontSave };
|
||||
}
|
||||
|
||||
return mMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRenderImage(RenderTexture src, RenderTexture dest)
|
||||
{
|
||||
if (Material && colors.Length > 0)
|
||||
{
|
||||
Material.SetInt("_ColorCount", colors.Length);
|
||||
Material.SetColorArray("_Colors", colors);
|
||||
|
||||
Graphics.Blit(src, dest, Material);
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics.Blit(src, dest);
|
||||
}
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
if (mMaterial)
|
||||
DestroyImmediate(mMaterial);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ImageEffects/RetroPixelMax.cs.meta
Normal file
11
Assets/Scripts/ImageEffects/RetroPixelMax.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fb98cc8cfedcc5644a7af767e0a0d81e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/Scripts/ImageEffects/RetroSize.cs
Normal file
29
Assets/Scripts/ImageEffects/RetroSize.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
/// <summary>
|
||||
/// RetroSuite-3D by oxysoft
|
||||
/// https://github.com/oxysoft/RetroSuite3D
|
||||
/// </summary>
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Camera))]
|
||||
[AddComponentMenu("Image Effects/Retro Size")]
|
||||
public class RetroSize : MonoBehaviour
|
||||
{
|
||||
[Header("Resolution")]
|
||||
public int horizontalResolution = 160;
|
||||
public int verticalResolution = 144;
|
||||
|
||||
public void OnRenderImage(RenderTexture src, RenderTexture dest)
|
||||
{
|
||||
horizontalResolution = Mathf.Clamp(horizontalResolution, 1, 2048);
|
||||
verticalResolution = Mathf.Clamp(verticalResolution, 1, 2048);
|
||||
|
||||
var scaled = RenderTexture.GetTemporary(horizontalResolution, verticalResolution);
|
||||
scaled.filterMode = FilterMode.Point;
|
||||
|
||||
Graphics.Blit(src, scaled);
|
||||
Graphics.Blit(scaled, dest);
|
||||
RenderTexture.ReleaseTemporary(scaled);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ImageEffects/RetroSize.cs.meta
Normal file
11
Assets/Scripts/ImageEffects/RetroSize.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e55f8c08e9740c04eb673d7bcc594299
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user