FilterMode.Trilinear

Unity · Версия 2020.3 LTS · Scripting · FilterMode

FilterMode.Trilinear

Описание

Трилинейная фильтрация — выборки текстур усредняются, а также смешиваются между уровнями MIP-карт.

Для текстур без MIP-карт этот параметр аналогичен Билинейный.

Смотрите так же: Texture.filterMode, texture assets.

//Этот скрипт изменяет режим фильтрации вашей текстуры, которую вы прикрепляете, когда нажимаете клавишу пробела в Mode . Он переключается между режимами точечного, билинейного и трилинейного фильтра.
//Прикрепите этот скрипт к GameObject
//Нажмите на GameObject и прикрепите текстуру к моей текстуре поле в Инспекторе.
// Применяем текстуру к игровым объектам (нажмите и перетащите текстуру на GameObject a> в режиме Редактор) в вашей Сцене, чтобы увидеть, как она меняет режимы в игре.

using UnityEngine;

public class Example : MonoBehaviour
{
    //Remember to assign a Texture in the Inspector window to ensure this works
    public Texture m_MyTexture;

    void Update()
    {
        //Press the space key to switch between Filter Modes
        if (Input.GetKeyDown(KeyCode.Space))
        {
            //Switch the Texture's Filter Mode
            m_MyTexture.filterMode = SwitchFilterModes();
            //Output the current Filter Mode to the console
            Debug.Log("Filter mode : " + m_MyTexture.filterMode);
        }
    }

    //Switch between Filter Modes when the user clicks the ButtonFilterMode SwitchFilterModes()
    {
        //Switch the Filter Mode of the Texture when user clicks the Button
        switch (m_MyTexture.filterMode)
        {
            //If the FilterMode is currently Bilinear, switch it to Point on the Button click
            case FilterMode.Bilinear:
                m_MyTexture.filterMode = FilterMode.Point;
                break;

            //If the FilterMode is currently Point, switch it to Trilinear on the Button click
            case FilterMode.Point:
                m_MyTexture.filterMode = FilterMode.Trilinear;
                break;

            //If the FilterMode is currently Trilinear, switch it to Bilinear on the Button click
            case FilterMode.Trilinear:
                m_MyTexture.filterMode = FilterMode.Bilinear;
                break;
        }
        //Return the new TextureFilterMode
        return m_MyTexture.filterMode;
    }
}

Обновлено 17 ноября 2026 г.