UnityEngine.Texture2D.GetPixelBilinear C# (CSharp) Method

GetPixelBilinear() public method

Returns filtered pixel color at normalized coordinates (u, v).

public GetPixelBilinear ( float u, float v ) : Color
u float
v float
return Color
        public Color GetPixelBilinear(float u, float v)
        {
            Color color;
            INTERNAL_CALL_GetPixelBilinear(this, u, v, out color);
            return color;
        }

Usage Example

コード例 #1
0
        private static Vector4 GetChannels(Texture2D tex, float u, float v, int miplevel, int w, int h, float rangeX, float rangeY) {
            if (tex == null)
                return Vector4.zero;


            if (miplevel == 0) {
                return tex.GetPixelBilinear(u, v);
            }

            // Averages the result over the area within the 'pixel' for this mip level
            // this is similar, but not quite exactly the same as trilinear filtering.
            Vector4 value = Vector4.zero;

            for (int x = -miplevel; x < miplevel; x++) {
                for (int y = -miplevel; y < miplevel; y++) {
                    float um = u + (x * rangeX);
                    float vm = v - (y * rangeY);

                    value += (Vector4) tex.GetPixelBilinear(um, vm);
                }
            }

            int t = miplevel * 2;
            value /= t * t;

            return value;
        }
All Usage Examples Of UnityEngine.Texture2D::GetPixelBilinear