Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Turn off antialising in render texture

Discussion in 'Scripting' started by idcsteve, Dec 7, 2018.

  1. idcsteve

    idcsteve

    Joined:
    Jul 11, 2016
    Posts:
    12
    Hi,

    I'm trying to render a texture with antialiasing turned off, but I can't seem to do so without turning off antialiasing in the whole project.

    I am creating a render texture with the following code:

    Code (CSharp):
    1.  
    2. int width = 1280;
    3. int height = 720;
    4. int
    5. int antiAliasing = 1;
    6. var rt = RenderTexture.GetTemporary(width, height, depth, format, readWrite, antiAliasing);
    When I use the quality settings to set MSAA to 4, I have antialiasing on all textures. If I turn of MSAA, I get no antialiasing at all.

    Does anyone have any suggestions?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,936
    You're conflating project-scope anti-aliasing with texture-scope filter mode.

    To do what I think you want, you need this codelet:

    Code (csharp):
    1.  rt.filterMode = FilterMode.Point;
    That changes the filter mode on the RT, not on the entire project.
     
  3. idcsteve

    idcsteve

    Joined:
    Jul 11, 2016
    Posts:
    12
    Thanks very much Kurt. I'll try it out and see how it goes.
     
  4. idcsteve

    idcsteve

    Joined:
    Jul 11, 2016
    Posts:
    12
    Turns out (after much head-scratching, crying, and a brief stint in a mental facility o_O) that the problem was actually the HDR setting on the camera. It looked like antialiasing, but it was the HDR that was actually killing me. All sorted now!