Created
July 18, 2020 16:12
-
-
Save bitlather/9b4dcd1b0f5e76be414aa3a65eb743d1 to your computer and use it in GitHub Desktop.
Pixellated unity renderer by wtfmig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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