Created
December 25, 2017 18:05
-
-
Save KumoKairo/acdc6c8ad26d231ed3827ac8a2f032e9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
using UnityEngine; | |
public class Gameboy : MonoBehaviour | |
{ | |
public Material gameboyMaterial; | |
public Material identityMaterial; | |
private RenderTexture _downscaledRenderTexture; | |
private void OnEnable() | |
{ | |
var camera = GetComponent<Camera>(); | |
int height = 144; | |
int width = Mathf.RoundToInt(camera.aspect * height); | |
_downscaledRenderTexture = new RenderTexture(width, height, 16); | |
_downscaledRenderTexture.filterMode = FilterMode.Point; | |
} | |
private void OnDisable() | |
{ | |
Destroy(_downscaledRenderTexture); | |
} | |
private void OnRenderImage(RenderTexture src, RenderTexture dst) | |
{ | |
Graphics.Blit(src, _downscaledRenderTexture, gameboyMaterial); | |
Graphics.Blit(_downscaledRenderTexture, dst, identityMaterial); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment