Beispiel #1
0
 internal unsafe FilterSource(FilePath path, FilterMode mode, git_filter_source* source)
 {
     SourceMode = mode;
     ObjectId = ObjectId.BuildFromPtr(&source->oid);
     Path = path.Native;
     Root = Proxy.git_repository_workdir(new IntPtr(source->repository)).Native;
 }
        /// <summary>
        ///     Generate an event filter function with the required semantics
        /// </summary>
        /// <param name="mode">Filter for event visibility</param>
        /// <returns>Comparison function</returns>
        public static Func<TypeDefinition, EventDefinition, bool> GetEventFilter(FilterMode mode)
        {
            Func<TypeDefinition, EventDefinition, bool> func = (TypeDefinition typeDef, EventDefinition evDef) =>
            {
                var lret = false;

                if (IsEnabled(mode, FilterMode.Public))
                {
                    lret = evDef.AddMethod.IsPublic;
                }
                if (!lret && IsEnabled(mode, FilterMode.Protected))
                {
                    if (evDef.AddMethod.IsAssembly && IsEnabled(mode, FilterMode.NotInternalProtected))
                    {
                        // skip internal events which could be protected
                    }
                    else
                    {
                        lret = evDef.AddMethod.IsFamily;
                    }
                }
                if (!lret && IsEnabled(mode, FilterMode.Private))
                {
                    lret = evDef.AddMethod.IsPrivate;
                }
                if (!lret && IsEnabled(mode, FilterMode.Internal))
                {
                    lret = evDef.AddMethod.IsAssembly;
                }

                return lret;
            };

            return func;
        }
		public ScreenNameQuery(string key, string value, FilterMode mode) : base(key, value, mode)
		{
			if (mode != FilterMode.Regex)
			{
				this.screenName = new ScreenName(value);
			}
		}
Beispiel #4
0
 /// <summary>
 /// Gets the filter value control with the specified FilterMode
 /// </summary>
 /// <param name="configurationValues">The configuration values.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="filterMode">The filter mode.</param>
 /// <returns></returns>
 public override Control FilterValueControl( Dictionary<string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode )
 {
     var control = new RockTextBox { ID = id };
     control.ID = string.Format( "{0}_ctlCompareValue", id );
     control.AddCssClass( "js-filter-control" );
     return control;
 }
        void BuildTexture()
        {
            if(Application.isPlaying)
            {
                if (resolutionType == Type.CustomResolution)
                {
                    customResolution.x = Mathf.Max(1, customResolution.x);
                    customResolution.x = Mathf.Min(Screen.width * 4, customResolution.x);
                    customResolution.y = Mathf.Max(1, customResolution.y);
                    customResolution.y = Mathf.Min(Screen.height * 4, customResolution.y);
                    customTexture = new RenderTexture(customResolution.x, customResolution.y, 32);
                }
                else if (resolutionType == Type.ScreenResolutionMultiplier)
                {
                    screenResolutionMultiplier = Mathf.Max(0, screenResolutionMultiplier);
                    screenResolutionMultiplier = Mathf.Min(4, screenResolutionMultiplier);
                    int width = Mathf.Max(1, Mathf.FloorToInt(screenResolutionMultiplier * Screen.width));
                    int height = Mathf.Max(1, Mathf.FloorToInt(screenResolutionMultiplier * Screen.height));
                    customTexture = new RenderTexture(width, height, 32);
                }
                customTexture.filterMode = filterMode;
                customTexture.name = "Custom Render Resolution Texture";
                customTexture.Create();
                targetCamera.targetTexture = customTexture;
                subScript.customTexture = customTexture;

                customResolutionLast = customResolution;
                filterModeLast = filterMode;
                screenResolutionMultiplierLast = screenResolutionMultiplier;
            }
        }
Beispiel #6
0
 /// <summary>
 ///     Builder constructor
 /// </summary>
 /// <param name="filterSize"></param>
 /// <param name="filterPower"></param>
 /// <param name="keepOption"></param>
 public DeblurBuilder(Size filterSize, double filterPower = 1, KeepOption keepOption = KeepOption.AverageAndDelta)
 {
     _filterMode = FilterMode.FilterSize;
     _filterSize = filterSize;
     _filterPower = filterPower;
     _keepOption = keepOption;
 }
    /// <summary>
    /// Get GIF texture list (This is a possibility of lock up)
    /// </summary>
    /// <param name="bytes">GIF file byte data</param>
    /// <param name="loopCount">out Animation loop count</param>
    /// <param name="width">out GIF image width (px)</param>
    /// <param name="height">out GIF image height (px)</param>
    /// <param name="filterMode">Textures filter mode</param>
    /// <param name="wrapMode">Textures wrap mode</param>
    /// <param name="debugLog">Debug Log Flag</param>
    /// <returns>GIF texture list</returns>
    public static List<GifTexture> GetTextureList (byte[] bytes, out int loopCount, out int width, out int height,
        FilterMode filterMode = FilterMode.Bilinear, TextureWrapMode wrapMode = TextureWrapMode.Clamp, bool debugLog = false)
    {
        loopCount = -1;
        width = 0;
        height = 0;

        // Set GIF data
        var gifData = new GifData ();
        if (SetGifData (bytes, ref gifData, debugLog) == false) {
            Debug.LogError ("GIF file data set error.");
            return null;
        }

        // Decode to textures from GIF data
        var gifTexList = new List<GifTexture> ();
        if (DecodeTexture (gifData, gifTexList, filterMode, wrapMode) == false) {
            Debug.LogError ("GIF texture decode error.");
            return null;
        }

        loopCount = gifData.appEx.loopCount;
        width = gifData.logicalScreenWidth;
        height = gifData.logicalScreenHeight;
        return gifTexList;
    }
 public void Upgrade()
 {
     if (this.version != 4)
     {
         Debug.Log("SpriteCollection '" + base.name + "' - Upgraded from version " + this.version.ToString());
         if (this.version == 0)
         {
             if (this.pixelPerfectPointSampled)
             {
                 this.filterMode = FilterMode.Point;
             }
             else
             {
                 this.filterMode = FilterMode.Bilinear;
             }
             this.userDefinedTextureSettings = true;
         }
         if (((this.version < 3) && (this.textureRefs != null)) && ((this.textureParams != null) && (this.textureRefs.Length == this.textureParams.Length)))
         {
             for (int i = 0; i < this.textureRefs.Length; i++)
             {
                 this.textureParams[i].texture = this.textureRefs[i];
             }
             this.textureRefs = null;
         }
         if (this.version < 4)
         {
             this.sizeDef.CopyFromLegacy(this.useTk2dCamera, this.targetOrthoSize, (float) this.targetHeight);
         }
         this.version = 4;
     }
 }
 /// <summary>
 /// Gets the filter value control.
 /// </summary>
 /// <param name="configurationValues">The configuration values.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="filterMode">The filter mode.</param>
 /// <returns></returns>
 public override Control FilterValueControl( Dictionary<string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode )
 {
     var control = base.FilterValueControl(configurationValues, id, required, filterMode );
     WorkflowTypePicker workflowTypePicker = (WorkflowTypePicker)control;
     workflowTypePicker.Required = required;
     workflowTypePicker.AllowMultiSelect = false;
     return control;
 }
Beispiel #10
0
 /// <summary>
 /// Initialize the Extension Filter
 /// </summary>
 /// <param name="pattern">pattern for the extension filter</param>
 /// <param name="mode">The <see cref="FilterMode"/> for Filter</param>
 internal ExtensionFilter(string pattern,FilterMode mode):base(mode)
 {
     if(pattern == null){
         pattern = "";
     }
     this._pattern = pattern;
     BuildRegex(_pattern.ToLower());
 }
Beispiel #11
0
 /// <summary>
 ///     Builder constructor
 /// </summary>
 /// <param name="filterKernel"></param>
 /// <param name="filterPower"></param>
 /// <param name="keepOption"></param>
 public FilterBuilder(Complex[,] filterKernel, double filterPower = 1,
     KeepOption keepOption = KeepOption.AverageAndDelta)
 {
     _filterMode = FilterMode.FilterKernel;
     _filterKernel = filterKernel;
     _filterPower = filterPower;
     _keepOption = keepOption;
 }
Beispiel #12
0
        private readonly KeepOption _keepOption; // energy save options

        #endregion Fields

        #region Constructors

        /// <summary>
        ///     Builder constructor
        /// </summary>
        /// <param name="filterStep"></param>
        /// <param name="filterPower"></param>
        /// <param name="keepOption"></param>
        public DeblurBuilder(int filterStep = 1, double filterPower = 1,
            KeepOption keepOption = KeepOption.AverageAndDelta)
        {
            _filterMode = FilterMode.FilterStep;
            _filterStep = filterStep;
            _filterPower = filterPower;
            _keepOption = keepOption;
        }
Beispiel #13
0
        /// <summary>
        /// To allow every rotation with the selected filter.
        /// </summary>
        private void CheckFilter()
        {
            if (Filter != _oldFilter)
            {
                ResetDictionary();

                _oldFilter = Filter;
            }
        }
Beispiel #14
0
 public RenderTexture GetTemporaryRenderTexture(int width, int height, int depthBuffer = 0, RenderTextureFormat format = RenderTextureFormat.ARGBHalf, FilterMode filterMode = FilterMode.Bilinear)
 {
     var rt = RenderTexture.GetTemporary(width, height, depthBuffer, format);
     rt.filterMode = filterMode;
     rt.wrapMode = TextureWrapMode.Clamp;
     rt.name = "RenderTextureUtilityTempTexture";
     m_TemporaryRTs.Add(rt);
     return rt;
 }
 public RenderTexture GetTemporaryRenderTexture(int width, int height, int depthBuffer = 0, RenderTextureFormat format = RenderTextureFormat.ARGBHalf, FilterMode filterMode = FilterMode.Bilinear)
 {
     RenderTexture temporary = RenderTexture.GetTemporary(width, height, depthBuffer, format);
     temporary.filterMode = filterMode;
     temporary.wrapMode = TextureWrapMode.Clamp;
     temporary.name = "RenderTextureUtilityTempTexture";
     this.m_TemporaryRTs.Add(temporary);
     return temporary;
 }
Beispiel #16
0
 public RenderTexture Get(int width, int height, int depthBuffer = 0, RenderTextureFormat format = RenderTextureFormat.ARGBHalf, RenderTextureReadWrite rw = RenderTextureReadWrite.Default, FilterMode filterMode = FilterMode.Bilinear, TextureWrapMode wrapMode = TextureWrapMode.Clamp, string name = "FactoryTempTexture")
 {
     var rt = RenderTexture.GetTemporary(width, height, depthBuffer, format);
     rt.filterMode = filterMode;
     rt.wrapMode = wrapMode;
     rt.name = name;
     m_TemporaryRTs.Add(rt);
     return rt;
 }
    /// <summary>
    /// Decode to textures from GIF data
    /// </summary>
    /// <param name="gifData">GIF data</param>
    /// <param name="gifTexList">GIF texture list</param>
    /// <param name="filterMode">Textures filter mode</param>
    /// <param name="wrapMode">Textures wrap mode</param>
    /// <returns>IEnumerator</returns>
    static IEnumerator DecodeTextureCoroutine(GifData gifData, List<GifTexture> gifTexList, FilterMode filterMode, TextureWrapMode wrapMode)
    {
        if (gifData.imageBlockList == null || gifData.imageBlockList.Count < 1) {
            yield break;
        }

        Color32? bgColor = GetGlobalBgColor (gifData);

        // Disposal Method
        // 0 (No disposal specified)
        // 1 (Do not dispose)
        // 2 (Restore to background color)
        // 3 (Restore to previous)
        ushort disposalMethod = 0;

        int imgBlockIndex = 0;
        foreach (var imgBlock in gifData.imageBlockList) {
            var decodedData = GetDecodedData (imgBlock);

            var colorTable = GetColorTable (gifData, imgBlock, ref bgColor);

            var graphicCtrlEx = GetGraphicCtrlExt (gifData, imgBlockIndex);

            int transparentIndex = GetTransparentIndex (graphicCtrlEx);

            // avoid lock up
            yield return 0;

            bool useBeforeTex = false;
            var tex = CreateTexture2D (gifData, gifTexList, imgBlockIndex, disposalMethod, filterMode, wrapMode, ref useBeforeTex);

            // Set pixel data
            int dataIndex = 0;
            // Reverse set pixels. because GIF data starts from the top left.
            for (int y = tex.height - 1; y >= 0; y--) {
                SetTexturePixelRow (tex, y, imgBlock, decodedData, ref dataIndex, colorTable, bgColor, transparentIndex, useBeforeTex);

                // avoid lock up
                //if (y % 10 == 0) {
                //    yield return 0;
                //}
            }
            tex.Apply ();

            float delaySec = GetDelaySec (graphicCtrlEx);

            // Add to GIF texture list
            gifTexList.Add (new GifTexture (tex, delaySec));

            disposalMethod = GetDisposalMethod (graphicCtrlEx);

            imgBlockIndex++;

            // avoid lock up
            yield return 0;
        }
    }
Beispiel #18
0
 public Stream Apply(Stream stream, FilterMode fm)
 {
     Rijndael des = Rijndael.Create();
     des.IV = iv;
     des.Key = key;
     ICryptoTransform crypt = fm == FilterMode.Write ? des.CreateEncryptor() : des.CreateDecryptor();
     CryptoStream cs = new CryptoStream(stream, crypt, fm == FilterMode.Write ? CryptoStreamMode.Write : CryptoStreamMode.Read);
     return cs;
 }
Beispiel #19
0
    /// <summary>
    /// Scales the texture data of the given texture.
    /// </summary>
    /// <param name="tex">Texure to scale</param>
    /// <param name="width">New width</param>
    /// <param name="height">New height</param>
    /// <param name="mode">Filtering mode</param>
    public static void scale(Texture2D tex, int width, int height, FilterMode mode = FilterMode.Trilinear)
    {
        Rect texR = new Rect(0, 0, width, height);
        _gpu_scale(tex, width, height, mode);

        // Update new texture
        tex.Resize(width, height);
        tex.ReadPixels(texR, 0, 0, true);
        tex.Apply(true);        //Remove this if you hate us applying textures for you :)
    }
Beispiel #20
0
    /// <summary>
    ///     Returns a scaled copy of given texture.
    /// </summary>
    /// <param name="tex">Source texure to scale</param>
    /// <param name="width">Destination texture width</param>
    /// <param name="height">Destination texture height</param>
    /// <param name="mode">Filtering mode</param>
    public static Texture2D scaled(Texture2D src, int width, int height, FilterMode mode = FilterMode.Trilinear)
    {
        Rect texR = new Rect(0, 0, width, height);
        _gpu_scale(src, width, height, mode);

        //Get rendered data back to a new texture
        Texture2D result = new Texture2D(width, height, TextureFormat.ARGB32, true);
        result.Resize(width, height);
        result.ReadPixels(texR, 0, 0, true);
        return result;
    }
Beispiel #21
0
 /// <summary>
 /// Gets the filter value control.
 /// </summary>
 /// <param name="configurationValues">The configuration values.</param>
 /// <param name="id">The identifier.</param>
 /// <param name="required">if set to <c>true</c> [required].</param>
 /// <param name="filterMode">The filter mode.</param>
 /// <returns></returns>
 public override Control FilterValueControl( Dictionary<string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode )
 {
     var control = base.FilterValueControl( configurationValues, id, required, filterMode );
     if ( control is AccountPicker )
     {
         var accountPicker = (AccountPicker)control;
         accountPicker.AllowMultiSelect = false;
         accountPicker.Required = required;
     }
     return control;
 }
Beispiel #22
0
        /// <summary>
        /// Gets the filter compare control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterCompareControl( Dictionary<string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode )
        {
            var lbl = new Label();
            lbl.ID = string.Format( "{0}_lIs", id );
            lbl.AddCssClass( "data-view-filter-label" );
            lbl.Text = "Is";

            // hide the compare control when in SimpleFilter mode
            lbl.Visible = filterMode != FilterMode.SimpleFilter;

            return lbl;
        }
Beispiel #23
0
        /// <summary>
        /// Creates a texture instance
        /// </summary>
        /// <param name="_Name"></param>
        /// <param name="_Width"></param>
        /// <param name="_Height"></param>
        /// <param name="_Format"></param>
        /// <param name="_bUseMipMaps">Create mip maps for the texture</param>
        /// <param name="_FilterMode">Filter mode to use to sample the texture</param>
        /// <param name="_WrapMode">Wrap mode to use to address the texture</param>
        /// <returns></returns>
        public NuajTexture2D( string _Name, int _Width, int _Height, TextureFormat _Format, bool _bUseMipMaps, FilterMode _FilterMode, TextureWrapMode _WrapMode )
        {
            Help.LogDebug( "Nuaj.Help.CreateTexture() \"" + _Name + "\" => " + _Width + "x" + _Height + "x" + _Format );
            if ( _Width < 1 || _Height < 1 )
                throw new Exception( "NuajTexture2D.ctor() => Invalid resolution !" );

            m_Texture = new Texture2D( _Width, _Height, _Format, _bUseMipMaps );
            m_Texture.name = _Name;
            m_Texture.filterMode = _FilterMode;
            m_Texture.wrapMode = _WrapMode;
            m_Texture.hideFlags = HideFlags.HideAndDontSave;
        }
Beispiel #24
0
		public BooleanQuery(string key, string value, FilterMode mode) : base(key, value, mode)
		{
			if (mode != FilterMode.Equal)
			{
				throw new FilterException("クエリ '" + key + "' は '=' 演算子でのみ使用できます。");
			}

			if (!bool.TryParse(value, out this.b))
			{
				throw new FilterException("クエリ '" + key + "' の値は、'true' または 'false' で指定してください。");
			}
		}
Beispiel #25
0
        void Awake()
        {
            _renderer = GetComponent<SpriteRenderer>();
            _animator = GetComponent<Animator>();

            _originalSprite = _renderer.sprite;

            _possibleRotations = new Dictionary<int, Sprite>();
            _currentKey = 0;

            _oldFilter = Filter;
            _useAnimator = _animator != null ? _animator.enabled : false;
        }
Beispiel #26
0
		protected Query(string key, string value, FilterMode mode)
		{
			this.Key = key;
			this.Value = value;
			this.Mode = mode;

			if (this.Mode == FilterMode.Regex)
			{
				// ReSharper disable DoNotCallOverridableMethodsInConstructor
				this.Regex = this.CreateRegex();
				// ReSharper restore DoNotCallOverridableMethodsInConstructor
			}
		}
Beispiel #27
0
        protected override void Create(string path, string root, FilterMode mode)
        {
            if (mode == FilterMode.Clean)
            {
                string filename = Path.GetFileName(path);
                string cachePath = Path.Combine(root, ".git", filename);

                if (File.Exists(cachePath))
                {
                    File.Delete(cachePath);
                }
            }
        }
Beispiel #28
0
 public MRT(int width, int height, RenderTextureFormat format = RenderTextureFormat.ARGBFloat, FilterMode filterMode = FilterMode.Point, TextureWrapMode wrapMode = TextureWrapMode.Repeat)
 {
     RTs = new RenderTexture[3];
     for(int i = 0, n = RTs.Length; i < n; i++) {
         int depth = (i == 0) ? 24 : 0;
         RTs[i] = new RenderTexture(width, height, depth);
         RTs[i].hideFlags = HideFlags.DontSave;
         RTs[i].format = format;
         RTs[i].filterMode = filterMode;
         RTs[i].wrapMode = wrapMode;
         RTs[i].Create();
     }
 }
Beispiel #29
0
	public static Dictionary<string, Filter> Load (XDocument doc, out FilterMode @default)
	{
		string value;
		@default = (value = (string)doc.Root.Attribute ("default")) != null ? (FilterMode)Enum.Parse (typeof (FilterMode), value) : FilterMode.Include;

		var rules = from rule in doc.Root.Elements ()
		            let mode = (FilterMode)Enum.Parse (typeof (FilterMode), rule.Name.LocalName)
		            let impl = (value = (string)rule.Attribute ("implementation")) != null ? (ImplementationType)Enum.Parse (typeof (ImplementationType), value) : ImplementationType.@class
		            select new Filter { TypeName = rule.Value, Mode = mode, ImplType = impl };


		return rules.ToDictionary<Filter,string> (r => r.TypeName);
	}
Beispiel #30
0
        public static DeviceSampler Create(Boolean normalizedCoords, AddressingMode addressingMode, FilterMode filterMode, Context context)
        {
            CLError error = new CLError();

            CLSampler sampler = OpenCLDriver.clCreateSampler(context.CLContext, normalizedCoords ? CLBool.True : CLBool.False, (CLAddressingMode)addressingMode, (CLFilterMode)filterMode, ref error);

            OpenCLError.Validate(error);

            return new DeviceSampler()
            {
                openCLSampler = sampler
            };
        }
        /// <summary>
        /// Filters the value control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            bool allowMultiple = configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean();

            var overrideConfigValues = new Dictionary <string, ConfigurationValue>();

            foreach (var keyVal in configurationValues)
            {
                overrideConfigValues.Add(keyVal.Key, keyVal.Value);
            }

            overrideConfigValues.AddOrReplace(ALLOW_MULTIPLE_KEY, new ConfigurationValue((true).ToString()));

            return(base.FilterValueControl(overrideConfigValues, id, required, filterMode));
        }
        /// <summary>
        /// Gets the filter value.
        /// </summary>
        /// <param name="filterControl">The filter control.</param>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override List <string> GetFilterValues(Control filterControl, Dictionary <string, ConfigurationValue> configurationValues, FilterMode filterMode)
        {
            var values = new List <string>();

            if (filterControl != null)
            {
                bool allowMultiple = configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean();

                try
                {
                    if (allowMultiple)
                    {
                        var filterValues = base.GetFilterValues(filterControl, configurationValues, filterMode);
                        if (filterValues != null)
                        {
                            filterValues.ForEach(v => values.Add(v));
                        }
                    }
                    else
                    {
                        values.Add(GetEditValue(filterControl.Controls[1].Controls[0], configurationValues));
                    }
                }
                catch
                {
                    // intentionally ignore
                }
            }

            return(values);
        }
Beispiel #33
0
 public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter, RenderTextureFormat format, RenderTextureReadWrite readWrite)
 {
     GetTemporaryRT(nameID, width, height, depthBuffer, filter, format, readWrite, 1);
 }
Beispiel #34
0
        public static RenderTexture CreateTexture(string name, int width, int height, int depth, RenderTextureFormat format, bool useMipmap, FilterMode filtermode, int antiAliasing)
        {
            RenderTexture renderTexture = new RenderTexture(width, height, depth, format);

            renderTexture.name         = name;
            renderTexture.useMipMap    = useMipmap;
            renderTexture.filterMode   = filtermode;
            renderTexture.antiAliasing = antiAliasing;
            renderTexture.Create();

            return(renderTexture);
        }
Beispiel #35
0
 /// <summary>
 /// Indicates that a filter is going to be applied for the given file for
 /// the given mode.
 /// </summary>
 /// <param name="path">The path of the file being filtered</param>
 /// <param name="root">The path of the working directory for the owning repository</param>
 /// <param name="mode">The filter mode</param>
 protected virtual void Create(string path, string root, FilterMode mode)
 {
 }
Beispiel #36
0
 public void GetTemporaryRTArray(int nameID, int width, int height, int slices, int depthBuffer, FilterMode filter, RenderTextureFormat format)
 {
     GetTemporaryRTArray(nameID, width, height, slices, depthBuffer, filter, GraphicsFormatUtility.GetGraphicsFormat(format, RenderTextureReadWrite.Default), 1, false);
 }
Beispiel #37
0
        public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter)
        {
            int antiAliasing = 1;
            RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default;
            RenderTextureFormat    format    = RenderTextureFormat.Default;

            this.GetTemporaryRT(nameID, width, height, depthBuffer, filter, format, readWrite, antiAliasing);
        }
Beispiel #38
0
        void Render(PostProcessRenderContext context, CommandBuffer cmd, int occlusionSource)
        {
            DoLazyInitialization(context);
            m_Settings.radius.value = Mathf.Max(m_Settings.radius.value, 1e-4f);

            // Material setup
            // Always use a quater-res AO buffer unless High/Ultra quality is set.
            bool  downsampling = (int)m_Settings.quality.value < (int)AmbientOcclusionQuality.High;
            float px           = m_Settings.intensity.value;
            float py           = m_Settings.radius.value;
            float pz           = downsampling ? 0.5f : 1f;
            float pw           = m_SampleCount[(int)m_Settings.quality.value];

            var sheet = m_PropertySheet;

            sheet.ClearKeywords();
            sheet.properties.SetVector(ShaderIDs.AOParams, new Vector4(px, py, pz, pw));
            sheet.properties.SetVector(ShaderIDs.AOColor, Color.white - m_Settings.color.value);

            // In forward fog is applied at the object level in the grometry pass so we need to
            // apply it to AO as well or it'll drawn on top of the fog effect.
            // Not needed in Deferred.
            if (context.camera.actualRenderingPath == RenderingPath.Forward && RenderSettings.fog)
            {
                sheet.EnableKeyword("APPLY_FORWARD_FOG");
                sheet.properties.SetVector(
                    ShaderIDs.FogParams,
                    new Vector3(RenderSettings.fogDensity, RenderSettings.fogStartDistance, RenderSettings.fogEndDistance)
                    );
            }

            // Texture setup
            int ts = downsampling ? 2 : 1;
            const RenderTextureFormat    kFormat = RenderTextureFormat.ARGB32;
            const RenderTextureReadWrite kRWMode = RenderTextureReadWrite.Linear;
            const FilterMode             kFilter = FilterMode.Bilinear;

            // AO buffer
            var rtMask       = ShaderIDs.OcclusionTexture1;
            int scaledWidth  = context.width / ts;
            int scaledHeight = context.height / ts;

            context.GetScreenSpaceTemporaryRT(cmd, rtMask, 0, kFormat, kRWMode, kFilter, scaledWidth, scaledHeight);

            // AO estimation
            cmd.BlitFullscreenTriangle(BuiltinRenderTextureType.None, rtMask, sheet, (int)Pass.OcclusionEstimationForward + occlusionSource);

            // Blur buffer
            var rtBlur = ShaderIDs.OcclusionTexture2;

            context.GetScreenSpaceTemporaryRT(cmd, rtBlur, 0, kFormat, kRWMode, kFilter);

            // Separable blur (horizontal pass)
            cmd.BlitFullscreenTriangle(rtMask, rtBlur, sheet, (int)Pass.HorizontalBlurForward + occlusionSource);
            cmd.ReleaseTemporaryRT(rtMask);

            // Separable blur (vertical pass)
            cmd.BlitFullscreenTriangle(rtBlur, m_Result, sheet, (int)Pass.VerticalBlur);
            cmd.ReleaseTemporaryRT(rtBlur);

            if (context.IsDebugOverlayEnabled(DebugOverlay.AmbientOcclusion))
            {
                context.PushDebugOverlay(cmd, m_Result, sheet, (int)Pass.DebugOverlay);
            }
        }
 public static extern void SetFilterModeNoDirty(Texture tex, FilterMode mode);
Beispiel #40
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            // show texture
            Texture t = target as Texture;

            if (t == null) // texture might be gone by now, in case this code is used for floating texture preview
            {
                return;
            }

            // Render target must be created before we can display it (case 491797)
            RenderTexture rt = t as RenderTexture;

            if (rt != null)
            {
                if (!SystemInfo.IsFormatSupported(rt.graphicsFormat, FormatUsage.Render))
                {
                    return; // can't do this RT format
                }
                rt.Create();
            }

            if (IsCubemap())
            {
                m_CubemapPreview.OnPreviewGUI(t, r, background);
                return;
            }

            // target can report zero sizes in some cases just after a parameter change;
            // guard against that.
            int texWidth  = Mathf.Max(t.width, 1);
            int texHeight = Mathf.Max(t.height, 1);

            float mipLevel   = GetMipLevelForRendering();
            float zoomLevel  = Mathf.Min(Mathf.Min(r.width / texWidth, r.height / texHeight), 1);
            Rect  wantedRect = new Rect(r.x, r.y, texWidth * zoomLevel, texHeight * zoomLevel);

            PreviewGUI.BeginScrollView(r, m_Pos, wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
            FilterMode oldFilter = t.filterMode;

            TextureUtil.SetFilterModeNoDirty(t, FilterMode.Point);
            Texture2D      t2d            = t as Texture2D;
            ColorWriteMask colorWriteMask = ColorWriteMask.All;

            switch (m_PreviewMode)
            {
            case PreviewMode.R:
                colorWriteMask = ColorWriteMask.Red | ColorWriteMask.Alpha;
                break;

            case PreviewMode.G:
                colorWriteMask = ColorWriteMask.Green | ColorWriteMask.Alpha;
                break;

            case PreviewMode.B:
                colorWriteMask = ColorWriteMask.Blue | ColorWriteMask.Alpha;
                break;
            }

            if (m_PreviewMode == PreviewMode.A)
            {
                EditorGUI.DrawTextureAlpha(wantedRect, t, ScaleMode.StretchToFill, 0, mipLevel);
            }
            else
            {
                if (t2d != null && t2d.alphaIsTransparency)
                {
                    EditorGUI.DrawTextureTransparent(wantedRect, t, ScaleMode.StretchToFill, 0, mipLevel, colorWriteMask);
                }
                else
                {
                    EditorGUI.DrawPreviewTexture(wantedRect, t, null, ScaleMode.StretchToFill, 0, mipLevel, colorWriteMask);
                }
            }

            // TODO: Less hacky way to prevent sprite rects to not appear in smaller previews like icons.
            if ((wantedRect.width > 32 && wantedRect.height > 32) && Event.current.type == EventType.Repaint)
            {
                string           path            = AssetDatabase.GetAssetPath(t);
                TextureImporter  textureImporter = AssetImporter.GetAtPath(path) as TextureImporter;
                SpriteMetaData[] spritesheet     = textureImporter != null ? textureImporter.spritesheet : null;

                if (spritesheet != null && textureImporter.spriteImportMode == SpriteImportMode.Multiple)
                {
                    Rect screenRect = new Rect();
                    Rect sourceRect = new Rect();
                    GUI.CalculateScaledTextureRects(wantedRect, ScaleMode.StretchToFill, (float)t.width / (float)t.height, ref screenRect, ref sourceRect);

                    int origWidth  = t.width;
                    int origHeight = t.height;
                    textureImporter.GetWidthAndHeight(ref origWidth, ref origHeight);
                    float definitionScale = (float)t.width / (float)origWidth;

                    HandleUtility.ApplyWireMaterial();
                    GL.PushMatrix();
                    GL.MultMatrix(Handles.matrix);
                    GL.Begin(GL.LINES);
                    GL.Color(new Color(1f, 1f, 1f, 0.5f));
                    foreach (SpriteMetaData sprite in spritesheet)
                    {
                        Rect spriteRect       = sprite.rect;
                        Rect spriteScreenRect = new Rect();
                        spriteScreenRect.xMin = screenRect.xMin + screenRect.width * (spriteRect.xMin / t.width * definitionScale);
                        spriteScreenRect.xMax = screenRect.xMin + screenRect.width * (spriteRect.xMax / t.width * definitionScale);
                        spriteScreenRect.yMin = screenRect.yMin + screenRect.height * (1f - spriteRect.yMin / t.height * definitionScale);
                        spriteScreenRect.yMax = screenRect.yMin + screenRect.height * (1f - spriteRect.yMax / t.height * definitionScale);
                        DrawRect(spriteScreenRect);
                    }
                    GL.End();
                    GL.PopMatrix();
                }
            }

            TextureUtil.SetFilterModeNoDirty(t, oldFilter);

            m_Pos = PreviewGUI.EndScrollView();
            if (mipLevel != 0)
            {
                EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 20), "Mip " + mipLevel);
            }
        }
Beispiel #41
0
        public override void PopulateCommandBuffer(CommandBuffer cb)
        {
            var settings = model.settings;
            // Material setup
            var blitMaterial = context.materialFactory.Get(k_BlitShaderString);
            var material     = context.materialFactory.Get(k_ShaderString);

            material.shaderKeywords = null;
            material.SetFloat(Uniforms._Intensity, settings.intensity);
            material.SetFloat(Uniforms._Radius, settings.radius);
            material.SetFloat(Uniforms._Downsample, settings.downsampling ? 0.5f : 1f);
            material.SetInt(Uniforms._SampleCount, (int)settings.sampleCount);
            int tw = context.width;
            int th = context.height;
            int ts = settings.downsampling ? 2 : 1;
            const RenderTextureFormat    kFormat = RenderTextureFormat.ARGB32;
            const RenderTextureReadWrite kRWMode = RenderTextureReadWrite.Linear;
            const FilterMode             kFilter = FilterMode.Bilinear;
            // AO buffer
            var rtMask = Uniforms._OcclusionTexture1;

            cb.GetTemporaryRT(rtMask, tw / ts, th / ts, 0, kFilter, kFormat, kRWMode);
            // AO estimation
            cb.Blit((Texture)null, rtMask, material, (int)occlusionSource);
            // Blur buffer
            var rtBlur = Uniforms._OcclusionTexture2;

            // Separable blur (horizontal pass)
            cb.GetTemporaryRT(rtBlur, tw, th, 0, kFilter, kFormat, kRWMode);
            cb.SetGlobalTexture(Uniforms._MainTex, rtMask);
            cb.Blit(rtMask, rtBlur, material, occlusionSource == OcclusionSource.GBuffer ? 4 : 3);
            cb.ReleaseTemporaryRT(rtMask);
            // Separable blur (vertical pass)
            rtMask = Uniforms._OcclusionTexture;
            cb.GetTemporaryRT(rtMask, tw, th, 0, kFilter, kFormat, kRWMode);
            cb.SetGlobalTexture(Uniforms._MainTex, rtBlur);
            cb.Blit(rtBlur, rtMask, material, 5);
            cb.ReleaseTemporaryRT(rtBlur);

            if (context.profile.debugViews.IsModeActive(DebugMode.AmbientOcclusion))
            {
                cb.SetGlobalTexture(Uniforms._MainTex, rtMask);
                cb.Blit(rtMask, BuiltinRenderTextureType.CameraTarget, material, 8);
                context.Interrupt();
            }
            else if (ambientOnlySupported)
            {
                cb.SetRenderTarget(m_MRT, BuiltinRenderTextureType.CameraTarget);
                cb.DrawMesh(GraphicsUtils.quad, Matrix4x4.identity, material, 0, 7);
            }
            else
            {
                var fbFormat = context.isHdr ? RenderTextureFormat.DefaultHDR : RenderTextureFormat.Default;
                int tempRT   = Uniforms._TempRT;
                cb.GetTemporaryRT(tempRT, context.width, context.height, 0, FilterMode.Bilinear, fbFormat);
                cb.Blit(BuiltinRenderTextureType.CameraTarget, tempRT, blitMaterial, 0);
                cb.SetGlobalTexture(Uniforms._MainTex, tempRT);
                cb.Blit(tempRT, BuiltinRenderTextureType.CameraTarget, material, 6);
                cb.ReleaseTemporaryRT(tempRT);
            }

            cb.ReleaseTemporaryRT(rtMask);
        }
        /// <summary>
        /// Gets the filter compare control.
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterCompareControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            bool allowMultiple = configurationValues != null && configurationValues.ContainsKey(ALLOW_MULTIPLE_KEY) && configurationValues[ALLOW_MULTIPLE_KEY].Value.AsBoolean();

            if (allowMultiple)
            {
                return(base.FilterCompareControl(configurationValues, id, required, filterMode));
            }
            else
            {
                var lbl = new Label();
                lbl.ID = string.Format("{0}_lIs", id);
                lbl.AddCssClass("data-view-filter-label");
                lbl.Text = "Is";

                // hide the compare control when in SimpleFilter mode
                lbl.Visible = filterMode != FilterMode.SimpleFilter;
                return(lbl);
            }
        }
Beispiel #43
0
        /// <summary>
        /// Gets the filter value control with the specified FilterMode
        /// </summary>
        /// <param name="configurationValues">The configuration values.</param>
        /// <param name="id">The identifier.</param>
        /// <param name="required">if set to <c>true</c> [required].</param>
        /// <param name="filterMode">The filter mode.</param>
        /// <returns></returns>
        public override Control FilterValueControl(Dictionary <string, ConfigurationValue> configurationValues, string id, bool required, FilterMode filterMode)
        {
            // only supports IsBlank and IsNotBlank, so don't show any value control
            var filterValueControl = base.FilterValueControl(configurationValues, id, required, filterMode);

            if (filterValueControl != null)
            {
                filterValueControl.Visible = false;
            }

            return(filterValueControl);
        }
Beispiel #44
0
 public void GetTemporaryRTArray(int nameID, int width, int height, int slices, int depthBuffer, FilterMode filter, RenderTextureFormat format, RenderTextureReadWrite readWrite, int antiAliasing, bool enableRandomWrite)
 {
     GetTemporaryRTArray(nameID, width, height, slices, depthBuffer, filter, GraphicsFormatUtility.GetGraphicsFormat(format, readWrite), antiAliasing, enableRandomWrite, false);
 }
Beispiel #45
0
 public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter)
 {
     GetTemporaryRT(nameID, width, height, depthBuffer, filter, SystemInfo.GetGraphicsFormat(DefaultFormat.LDR));
 }
    private void GradientCreator()
    {
        GUILayout.Label("Gradient Creator", bigLabel);
        GUILayout.Space(20);
        GUILayout.Label("This feature can be used to create textures for the Color Ramp Effect", EditorStyles.boldLabel);

        EditorGUILayout.GradientField("Gradient", gradient, GUILayout.Height(25));

        EditorGUILayout.BeginHorizontal();
        {
            GUILayout.Label("Texture Size:", GUILayout.MaxWidth(145));
            textureSizes = (TextureSizes)EditorGUILayout.EnumPopup(textureSizes, GUILayout.MaxWidth(200));
        }
        EditorGUILayout.EndHorizontal();

        int       textureSize = (int)textureSizes;
        Texture2D gradTex     = new Texture2D(textureSize, 1, TextureFormat.RGBA32, false);

        for (int i = 0; i < textureSize; i++)
        {
            gradTex.SetPixel(i, 0, gradient.Evaluate((float)i / (float)textureSize));
        }
        gradTex.Apply();

        GUILayout.Space(20);
        GUILayout.Label("Select the folder where new Gradient Textures will be saved", EditorStyles.boldLabel);
        HandleSaveFolderEditorPref("All1ShaderGradients", "Assets/AllIn1SpriteShader/Textures/GradientTextures", "Gradient");

        string prefSavedPath = PlayerPrefs.GetString("All1ShaderGradients") + "/";

        if (Directory.Exists(prefSavedPath))
        {
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label("Gradient Texture Filtering: ", GUILayout.MaxWidth(170));
                gradientFiltering = (FilterMode)EditorGUILayout.EnumPopup(gradientFiltering, GUILayout.MaxWidth(200));
            }
            EditorGUILayout.EndHorizontal();

            if (GUILayout.Button("Save Gradient Texture"))
            {
                string path = EditorUtility.SaveFilePanel("Save texture as PNG", prefSavedPath, "gradientTexture_1.png", "png");
                if (path.Length != 0)
                {
                    byte[] pngData = gradTex.EncodeToPNG();
                    if (pngData != null)
                    {
                        File.WriteAllBytes(path, pngData);
                    }
                    AssetDatabase.Refresh();

                    if (path.IndexOf("Assets/") >= 0)
                    {
                        string          subPath  = path.Substring(path.IndexOf("Assets/"));
                        TextureImporter importer = AssetImporter.GetAtPath(subPath) as TextureImporter;
                        if (importer != null)
                        {
                            Debug.Log("Gradient saved inside the project: " + subPath);
                            importer.filterMode = gradientFiltering;
                            importer.SaveAndReimport();
                        }
                    }
                    else
                    {
                        Debug.Log("Gradient saved outside the project: " + path);
                    }
                }
            }
        }
    }
Beispiel #47
0
 public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter, RenderTextureFormat format, RenderTextureReadWrite readWrite, int antiAliasing, bool enableRandomWrite)
 {
     GetTemporaryRT(nameID, width, height, depthBuffer, filter, format, readWrite, antiAliasing, enableRandomWrite, RenderTextureMemoryless.None);
 }
Beispiel #48
0
 public void GetTemporaryRTArray(int nameID, int width, int height, int slices, int depthBuffer, FilterMode filter, GraphicsFormat format)
 {
     GetTemporaryRTArray(nameID, width, height, slices, depthBuffer, filter, format, 1);
 }
Beispiel #49
0
 public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter, RenderTextureFormat format, RenderTextureReadWrite readWrite, int antiAliasing, bool enableRandomWrite, RenderTextureMemoryless memorylessMode, bool useDynamicScale)
 {
     GetTemporaryRT(nameID, width, height, depthBuffer, filter, GraphicsFormatUtility.GetGraphicsFormat(format, readWrite), antiAliasing, enableRandomWrite, memorylessMode, useDynamicScale);
 }
Beispiel #50
0
 public void GetTemporaryRTArray(int nameID, int width, int height, int slices, int depthBuffer, FilterMode filter, GraphicsFormat format, int antiAliasing, bool enableRandomWrite)
 {
     GetTemporaryRTArray(nameID, width, height, slices, depthBuffer, filter, format, antiAliasing, enableRandomWrite, false);
 }
Beispiel #51
0
 public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter, GraphicsFormat format, int antiAliasing)
 {
     GetTemporaryRT(nameID, width, height, depthBuffer, filter, format, antiAliasing, false, RenderTextureMemoryless.None);
 }
Beispiel #52
0
 extern public void GetTemporaryRTArray(int nameID, int width, int height, int slices, int depthBuffer, FilterMode filter, GraphicsFormat format, int antiAliasing, bool enableRandomWrite, bool useDynamicScale);
Beispiel #53
0
 public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter, GraphicsFormat format, int antiAliasing, bool enableRandomWrite, RenderTextureMemoryless memorylessMode)
 {
     GetTemporaryRT(nameID, width, height, depthBuffer, filter, format, antiAliasing, enableRandomWrite, memorylessMode, false);
 }
Beispiel #54
0
 public void GetTemporaryRT(int nameID, RenderTextureDescriptor desc, FilterMode filter)
 {
     GetTemporaryRTWithDescriptor(nameID, desc, filter);
 }
Beispiel #55
0
 extern public void GetTemporaryRT(int nameID, int width, int height, int depthBuffer, FilterMode filter, GraphicsFormat format, int antiAliasing, bool enableRandomWrite, RenderTextureMemoryless memorylessMode, bool useDynamicScale);
Beispiel #56
0
 extern private void GetTemporaryRTWithDescriptor(int nameID, RenderTextureDescriptor desc, FilterMode filter);
Beispiel #57
0
        /// <summary>
        /// Allocate a new fixed sized RTHandle.
        /// </summary>
        /// <param name="width">With of the RTHandle.</param>
        /// <param name="height">Heigh of the RTHandle.</param>
        /// <param name="slices">Number of slices of the RTHandle.</param>
        /// <param name="depthBufferBits">Bit depths of a depth buffer.</param>
        /// <param name="colorFormat">GraphicsFormat of a color buffer.</param>
        /// <param name="filterMode">Filtering mode of the RTHandle.</param>
        /// <param name="wrapMode">Addressing mode of the RTHandle.</param>
        /// <param name="dimension">Texture dimension of the RTHandle.</param>
        /// <param name="enableRandomWrite">Set to true to enable UAV random read writes on the texture.</param>
        /// <param name="useMipMap">Set to true if the texture should have mipmaps.</param>
        /// <param name="autoGenerateMips">Set to true to automatically generate mipmaps.</param>
        /// <param name="isShadowMap">Set to true if the depth buffer should be used as a shadow map.</param>
        /// <param name="anisoLevel">Anisotropic filtering level.</param>
        /// <param name="mipMapBias">Bias applied to mipmaps during filtering.</param>
        /// <param name="msaaSamples">Number of MSAA samples for the RTHandle.</param>
        /// <param name="bindTextureMS">Set to true if the texture needs to be bound as a multisampled texture in the shader.</param>
        /// <param name="useDynamicScale">Set to true to use hardware dynamic scaling.</param>
        /// <param name="memoryless">Use this property to set the render texture memoryless modes.</param>
        /// <param name="name">Name of the RTHandle.</param>
        /// <returns></returns>
        public RTHandle Alloc(
            int width,
            int height,
            int slices = 1,
            DepthBits depthBufferBits          = DepthBits.None,
            GraphicsFormat colorFormat         = GraphicsFormat.R8G8B8A8_SRGB,
            FilterMode filterMode              = FilterMode.Point,
            TextureWrapMode wrapMode           = TextureWrapMode.Repeat,
            TextureDimension dimension         = TextureDimension.Tex2D,
            bool enableRandomWrite             = false,
            bool useMipMap                     = false,
            bool autoGenerateMips              = true,
            bool isShadowMap                   = false,
            int anisoLevel                     = 1,
            float mipMapBias                   = 0f,
            MSAASamples msaaSamples            = MSAASamples.None,
            bool bindTextureMS                 = false,
            bool useDynamicScale               = false,
            RenderTextureMemoryless memoryless = RenderTextureMemoryless.None,
            string name = ""
            )
        {
            bool enableMSAA = msaaSamples != MSAASamples.None;

            if (!enableMSAA && bindTextureMS == true)
            {
                Debug.LogWarning("RTHandle allocated without MSAA but with bindMS set to true, forcing bindMS to false.");
                bindTextureMS = false;
            }

            // We need to handle this in an explicit way since GraphicsFormat does not expose depth formats. TODO: Get rid of this branch once GraphicsFormat'll expose depth related formats
            RenderTexture rt;

            if (isShadowMap || depthBufferBits != DepthBits.None)
            {
                RenderTextureFormat format = isShadowMap ? RenderTextureFormat.Shadowmap : RenderTextureFormat.Depth;
                rt = new RenderTexture(width, height, (int)depthBufferBits, format, RenderTextureReadWrite.Linear)
                {
                    hideFlags         = HideFlags.HideAndDontSave,
                    volumeDepth       = slices,
                    filterMode        = filterMode,
                    wrapMode          = wrapMode,
                    dimension         = dimension,
                    enableRandomWrite = enableRandomWrite,
                    useMipMap         = useMipMap,
                    autoGenerateMips  = autoGenerateMips,
                    anisoLevel        = anisoLevel,
                    mipMapBias        = mipMapBias,
                    antiAliasing      = (int)msaaSamples,
                    bindTextureMS     = bindTextureMS,
                    useDynamicScale   = m_HardwareDynamicResRequested && useDynamicScale,
                    memorylessMode    = memoryless,
                    name = CoreUtils.GetRenderTargetAutoName(width, height, slices, format, name, mips: useMipMap, enableMSAA: enableMSAA, msaaSamples: msaaSamples)
                };
            }
            else
            {
                rt = new RenderTexture(width, height, (int)depthBufferBits, colorFormat)
                {
                    hideFlags         = HideFlags.HideAndDontSave,
                    volumeDepth       = slices,
                    filterMode        = filterMode,
                    wrapMode          = wrapMode,
                    dimension         = dimension,
                    enableRandomWrite = enableRandomWrite,
                    useMipMap         = useMipMap,
                    autoGenerateMips  = autoGenerateMips,
                    anisoLevel        = anisoLevel,
                    mipMapBias        = mipMapBias,
                    antiAliasing      = (int)msaaSamples,
                    bindTextureMS     = bindTextureMS,
                    useDynamicScale   = m_HardwareDynamicResRequested && useDynamicScale,
                    memorylessMode    = memoryless,
                    name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, dimension, name, mips: useMipMap, enableMSAA: enableMSAA, msaaSamples: msaaSamples, dynamicRes: useDynamicScale)
                };
            }

            rt.Create();

            var newRT = new RTHandle(this);

            newRT.SetRenderTexture(rt);
            newRT.useScaling             = false;
            newRT.m_EnableRandomWrite    = enableRandomWrite;
            newRT.m_EnableMSAA           = enableMSAA;
            newRT.m_EnableHWDynamicScale = useDynamicScale;
            newRT.m_Name = name;

            newRT.referenceSize = new Vector2Int(width, height);

            return(newRT);
        }
Beispiel #58
0
 public void GetTemporaryRTArray(int nameID, int width, int height, int slices, int depthBuffer, FilterMode filter)
 {
     GetTemporaryRTArray(nameID, width, height, slices, depthBuffer, filter, SystemInfo.GetGraphicsFormat(DefaultFormat.LDR), 1, false);
 }
Beispiel #59
0
        static Texture2D LoadImage(string filename, TextureWrapMode wrapMode = TextureWrapMode.Clamp, FilterMode filterMode = FilterMode.Bilinear, bool useMipMaps = true, TextureFormat format = TextureFormat.ARGB32)
        {
            Texture2D texture = Resources.Load <Texture2D>(imageResourceFolder + Path.GetFileNameWithoutExtension(!string.IsNullOrEmpty(filename) ? filename : string.Empty));

            try
            {
                // Didn't find it in resources in the project so try to find it in the library manifest....
                if (null == texture)
                {
                    using (Stream stream = GetImageStream(imageNamespace + filename))
                    {
                        texture = new Texture2D(0, 0, format, useMipMaps);
                        if (!texture.LoadImage(GetImageBuffer(stream)))
                        {
                            throw new NotSupportedException(filename);
                        }

                        texture.wrapMode   = wrapMode;
                        texture.filterMode = filterMode;
                    }
                }
                else     // ensure it is read/write enabled...
                {
                    Texture2D invertedTexture = new Texture2D(texture.width, texture.height, texture.format, 1 < texture.mipmapCount);
                    invertedTexture.SetPixels32(texture.GetPixels32());
                    invertedTexture.Apply(true);
                    texture = invertedTexture;
                }
            }
            catch
            {
                // Something went wrong so make a magenta 4 pixel texture.
                texture = new Texture2D(2, 2, TextureFormat.ARGB32, false);
                texture.SetPixels(0, 0, 2, 2, Enumerable.Repeat(Color.magenta, 4).ToArray());
            }
            texture.Apply(true);

            return(texture);
        }
Beispiel #60
0
        // Internal function
        RTHandle AllocAutoSizedRenderTexture(
            int width,
            int height,
            int slices,
            DepthBits depthBufferBits,
            GraphicsFormat colorFormat,
            FilterMode filterMode,
            TextureWrapMode wrapMode,
            TextureDimension dimension,
            bool enableRandomWrite,
            bool useMipMap,
            bool autoGenerateMips,
            bool isShadowMap,
            int anisoLevel,
            float mipMapBias,
            MSAASamples msaaSamples,
            bool bindTextureMS,
            bool useDynamicScale,
            RenderTextureMemoryless memoryless,
            string name
            )
        {
            bool enableMSAA = msaaSamples != MSAASamples.None;

            // Here user made a mistake in setting up msaa/bindMS, hence the warning
            if (!enableMSAA && bindTextureMS == true)
            {
                Debug.LogWarning("RTHandle allocated without MSAA but with bindMS set to true, forcing bindMS to false.");
                bindTextureMS = false;
            }

            // MSAA Does not support random read/write.
            if (enableMSAA && (enableRandomWrite == true))
            {
                Debug.LogWarning("RTHandle that is MSAA-enabled cannot allocate MSAA RT with 'enableRandomWrite = true'.");
                enableRandomWrite = false;
            }

            // We need to handle this in an explicit way since GraphicsFormat does not expose depth formats. TODO: Get rid of this branch once GraphicsFormat'll expose depth related formats
            RenderTexture rt;

            if (isShadowMap || depthBufferBits != DepthBits.None)
            {
                RenderTextureFormat format        = isShadowMap ? RenderTextureFormat.Shadowmap : RenderTextureFormat.Depth;
                GraphicsFormat      stencilFormat = isShadowMap ? GraphicsFormat.None : GraphicsFormat.R8_UInt;
                rt = new RenderTexture(width, height, (int)depthBufferBits, format, RenderTextureReadWrite.Linear)
                {
                    hideFlags         = HideFlags.HideAndDontSave,
                    volumeDepth       = slices,
                    filterMode        = filterMode,
                    wrapMode          = wrapMode,
                    dimension         = dimension,
                    enableRandomWrite = enableRandomWrite,
                    useMipMap         = useMipMap,
                    autoGenerateMips  = autoGenerateMips,
                    anisoLevel        = anisoLevel,
                    mipMapBias        = mipMapBias,
                    antiAliasing      = (int)msaaSamples,
                    bindTextureMS     = bindTextureMS,
                    useDynamicScale   = m_HardwareDynamicResRequested && useDynamicScale,
                    memorylessMode    = memoryless,
                    stencilFormat     = stencilFormat,
                    name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, dimension, name, mips: useMipMap, enableMSAA: enableMSAA, msaaSamples: msaaSamples, dynamicRes: useDynamicScale)
                };
            }
            else
            {
                rt = new RenderTexture(width, height, (int)depthBufferBits, colorFormat)
                {
                    hideFlags         = HideFlags.HideAndDontSave,
                    volumeDepth       = slices,
                    filterMode        = filterMode,
                    wrapMode          = wrapMode,
                    dimension         = dimension,
                    enableRandomWrite = enableRandomWrite,
                    useMipMap         = useMipMap,
                    autoGenerateMips  = autoGenerateMips,
                    anisoLevel        = anisoLevel,
                    mipMapBias        = mipMapBias,
                    antiAliasing      = (int)msaaSamples,
                    bindTextureMS     = bindTextureMS,
                    useDynamicScale   = m_HardwareDynamicResRequested && useDynamicScale,
                    memorylessMode    = memoryless,
                    name = CoreUtils.GetRenderTargetAutoName(width, height, slices, colorFormat, dimension, name, mips: useMipMap, enableMSAA: enableMSAA, msaaSamples: msaaSamples, dynamicRes: useDynamicScale)
                };
            }

            rt.Create();

            var rth = new RTHandle(this);

            rth.SetRenderTexture(rt);
            rth.m_EnableMSAA           = enableMSAA;
            rth.m_EnableRandomWrite    = enableRandomWrite;
            rth.useScaling             = true;
            rth.m_EnableHWDynamicScale = useDynamicScale;
            rth.m_Name = name;
            m_AutoSizedRTs.Add(rth);
            return(rth);
        }