Skip to content

Instantly share code, notes, and snippets.

@bitlather
Created July 18, 2020 16:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bitlather/9b4dcd1b0f5e76be414aa3a65eb743d1 to your computer and use it in GitHub Desktop.
Save bitlather/9b4dcd1b0f5e76be414aa3a65eb743d1 to your computer and use it in GitHub Desktop.
Pixellated unity renderer by wtfmig
// Downloaded from https://pastebin.com/5mkBeZ5S
//PIXELBOY BY @WTFMIG
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/PixelBoy")]
public class PixelBoy : MonoBehaviour
{
public int w = 720;
int h;
protected void Start()
{
if (!SystemInfo.supportsImageEffects)
{
enabled = false;
return;
}
}
void Update() {
float ratio = ((float)Camera.main.pixelHeight / (float)Camera.main.pixelWidth);
h = Mathf.RoundToInt(w * ratio);
}
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
source.filterMode = FilterMode.Point;
RenderTexture buffer = RenderTexture.GetTemporary(w, h, -1);
buffer.filterMode = FilterMode.Point;
Graphics.Blit(source, buffer);
Graphics.Blit(buffer, destination);
RenderTexture.ReleaseTemporary(buffer);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment