Advertisement
cybercritic

TinyPixelPerfect Camera

Aug 25th, 2019
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TinyPixelPerfect : MonoBehaviour
  6. {
  7.     private Material postprocessMaterial;
  8.     public int Width = 32;
  9.     public int Height = 32;
  10.  
  11.     private void Start()
  12.     {
  13.         postprocessMaterial = new Material(Shader.Find("Custom/TinyPixelPerfect"));
  14.     }
  15.  
  16.     //method which is automatically called by unity after the camera is done rendering
  17.     void OnRenderImage(RenderTexture source, RenderTexture destination)
  18.     {
  19.         postprocessMaterial.SetFloat("x", (float)this.Width);
  20.         postprocessMaterial.SetFloat("y", (float)this.Height);
  21.  
  22.         //draws the pixels from the source texture to the destination texture
  23.         Graphics.Blit(source, destination, postprocessMaterial);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement