Prevent anti-aliasing on full-screen

Hello,

I am working on a 2D “pixel perfect” project. Currently I am designing for a fixed resolution of 1200x675.

I would like to know how to prevent anti-aliasing when the build goes into full screen mode. I would like to release my project on a couple different platforms (xbox, steam), and I am hoping I can rely on the idea that the scaling the unity does will be enough to accommodate for different screen resolutions (though with the same aspect ratio).

For example, when i run the stand-alone player on my desktop, then enter full-screen mode, it seems like there is a bit of blurring. I have my sprites sent to point filtering, but I am wondering if there is yet another option in the player or build settings I should explore so that the graphics are as clean as possible when stretched.

I had briefly tried to adjust the quality settings only allowing for fatest, hoping that would force basic graphic scaling, but the build wound up running at 200fps, and caused a fair amount of strange behavior in the game.

Ok so basically, attach the following script (JS) to your camera;

#pragma strict

@script ExecuteInEditMode
@script AddComponentMenu ("Image Effects/Custom/Scaling")

public var filterMode : FilterMode;
public var scaling : float = 100;
enum Depth {
    none,
    sixteen,
    twentyfour
}
public var depth : Depth = Depth.twentyfour;

private var renderCamera : Camera;
private var cam : GameObject;
private var src : RenderTexture;

public function DepthCalc (d : Depth) : int
{
    if (d == Depth.none)
        return 0;
    else if (d == Depth.sixteen)
        return 16;
    else if (d == Depth.twentyfour)
        return 24;
    else
        return 0;
}

function Awake ()
{
    SetRenderCam ();
}

function SetRenderCam ()
{
    if (!renderCamera)
        renderCamera = GetComponent (Camera);

    if (GameObject.Find ("DisplayCamera")) 
        DestroyImmediate (GameObject.Find ("DisplayCamera"));
    cam = new GameObject ("DisplayCamera");
    cam.AddComponent (Camera);
    cam.GetComponent (Camera).cullingMask = 0;
    cam.GetComponent (Camera).depth = -2;
    cam.AddComponent (ScalingRender);

    var scale = cam.GetComponent (ScalingRender);
    var s = scaling / 100;
    src = new RenderTexture (Screen.width * s, Screen.height * s, DepthCalc (depth));
    src.filterMode = filterMode;
    renderCamera.targetTexture = src;
    scale.src = src;
}

You will also need this script somewhere in your assets folder (named “ScalingRender”);

#pragma strict

public var src : RenderTexture;

function OnRenderImage (srcn : RenderTexture, dest : RenderTexture)
{
    Graphics.Blit (src, dest);
}

There are a few issues with this, but it should be fine.

Note Make sure the scaling image effect is placed at the bottom of the stack on the camera for consistency with other post effects.

Building on the solution from @Namey5 , I have the following code in C#. I simplified it down to just one script for my needs. I hope it helps others. In my case, I build most of my game via code, so having something rendering in the game preview when I am not playing the game wasn’t something I needed to consider.

PixelPerfectRenderer.cs (Attach to your camera)

using UnityEngine;
using System.Collections;

public class PixelPerfectRenderer : MonoBehaviour {

    // PUBLIC VARS ----
    public FilterMode filterMode;
    public int scaling = 100;
    public Depth depth = Depth.twentyfour;

    // STRUCTS ----
    public enum Depth {
        none,
        sixteen,
        twentyfour
    };

    // PRIVATE VARS ----
    private Camera renderCamera;
    private RenderTexture src;

    private bool isFullScreen;

    // UNITY API ----
    void Awake () {

        isFullScreen = Screen.fullScreen;
        SetRenderCam();

	}

    void Update() {

        // have we toggled the windows/fullscreen mode?
        if(Screen.fullScreen != isFullScreen) {

            isFullScreen = !isFullScreen;
            SetRenderCam();

        }
    }

    void OnPreRender() {

        // this ensures that w/e the camera sees is rendered to our RenderTexture
        renderCamera.targetTexture = src;

    }

    void OnPostRender() {

        // for some reason we need to se the traget texture to null before we blit
        renderCamera.targetTexture = null;

        // casting null as a RenderTexture allows us to blit to the screen
        Graphics.Blit(src, null as RenderTexture);
    }

    // PUBLIC FUNCTIONS ----
    public int DepthCalc(Depth d) {

        if(d == Depth.none) {
            return 0;
        }

        if(d == Depth.sixteen) {
            return 16;
        }

        if(d == Depth.twentyfour) {
            return 24;
        }

        return 0;
    }

    public void SetRenderCam() {

        if (!renderCamera) {
            renderCamera = GetComponent<Camera>();
        }

        // we could use this to do scaling at different percentages
        int s = scaling / 100;

        src = new RenderTexture(Screen.width * s, Screen.height * s, DepthCalc(depth));

        src.filterMode = filterMode;

        renderCamera.targetTexture = src;

    }

}