Skip to content

Instantly share code, notes, and snippets.

@KumoKairo
Created December 25, 2017 18:05
Show Gist options
  • Save KumoKairo/acdc6c8ad26d231ed3827ac8a2f032e9 to your computer and use it in GitHub Desktop.
Save KumoKairo/acdc6c8ad26d231ed3827ac8a2f032e9 to your computer and use it in GitHub Desktop.
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