View difference between Paste ID: 5mkBeZ5S and E5yLEbsr
SHOW: | | - or go back to the newest paste.
1
//PIXELBOY BY @WTFMIG EAT A BUTT WORLD BAHAHAHAHA POOP MY PANTS
2
using UnityEngine;
3
using System.Collections;
4
5
[ExecuteInEditMode]
6
[AddComponentMenu("Image Effects/PixelBoy")]
7
public class PixelBoy : MonoBehaviour
8
{
9
    public int w = 720;
10
    int h;
11
    protected void Start()
12
    {
13
        if (!SystemInfo.supportsImageEffects)
14
        {
15
            enabled = false;
16
            return;
17
        }
18
    }
19
    void Update() {
20
21
        float ratio = ((float)Camera.main.pixelHeight / (float)Camera.main.pixelWidth);
22
        h = Mathf.RoundToInt(w * ratio);
23
        
24
    }
25
    void OnRenderImage(RenderTexture source, RenderTexture destination)
26
    {
27
        source.filterMode = FilterMode.Point;
28
        RenderTexture buffer = RenderTexture.GetTemporary(w, h, -1);
29
        buffer.filterMode = FilterMode.Point;
30
        Graphics.Blit(source, buffer);
31
        Graphics.Blit(buffer, destination);
32
        RenderTexture.ReleaseTemporary(buffer);
33
    }
34
}