Skip to content

Instantly share code, notes, and snippets.

@KumoKairo
Created December 25, 2017 17:31
Show Gist options
  • Save KumoKairo/f33d02b493b8a29b9e84899473aec127 to your computer and use it in GitHub Desktop.
Save KumoKairo/f33d02b493b8a29b9e84899473aec127 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class Gameboy : MonoBehaviour
{
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, dst, identityMaterial);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment