/// <summary> /// Creates a new instance of type "WritableTexture". /// </summary> /// <param name="texType">Defines the type of the render texture.</param> /// <param name="colorFormat">The color format of the texture, <see cref="ImagePixelFormat"/></param> /// <param name="width">Width in px.</param> /// <param name="height">Height in px.</param> /// <param name="generateMipMaps">Defines if mipmaps are created.</param> /// <param name="filterMode">Defines the filter mode <see cref="TextureFilterMode"/>.</param> /// <param name="wrapMode">Defines the wrapping mode <see cref="TextureWrapMode"/>.</param> /// <param name="compareMode">The textures compare mode. If uncertain, leaf on NONE, this is only important for depth (shadow) textures (<see cref="TextureCompareMode"/>).</param> /// <param name="compareFunc">The textures compare function. If uncertain, leaf on LEESS, this is only important for depth (shadow) textures and if the CompareMode isn't NONE (<see cref="Compare"/>)</param> public WritableTexture(RenderTargetTextureTypes texType, ImagePixelFormat colorFormat, int width, int height, bool generateMipMaps = true, TextureFilterMode filterMode = TextureFilterMode.Linear, TextureWrapMode wrapMode = TextureWrapMode.Repeat, TextureCompareMode compareMode = TextureCompareMode.None, Compare compareFunc = Compare.Less) { SessionUniqueIdentifier = Suid.GenerateSuid(); PixelFormat = colorFormat; Width = width; Height = height; DoGenerateMipMaps = generateMipMaps; FilterMode = filterMode; WrapMode = wrapMode; TextureType = texType; CompareMode = compareMode; CompareFunc = compareFunc; }
/// <summary> /// Sets a RenderTexture into the correct position in the RederTexture array. /// </summary> /// <param name="src">The source RenderTexture.</param> /// <param name="tex">The type of the texture.</param> public void SetTexture(WritableTexture src, RenderTargetTextureTypes tex) { RenderTextures[(int)tex] = src ?? throw new ArgumentException("Texture from source target is null!"); }
/// <summary> /// Sets a RenderTexture from another RenderTarget at the correct position in the RenderTexure array. /// </summary> /// <param name="src">The source RenderTarget.</param> /// <param name="tex">The type of the texture.</param> public void SetTextureFromRenderTarget(RenderTarget src, RenderTargetTextureTypes tex) { var srcTex = src.RenderTextures[(int)tex]; RenderTextures[(int)tex] = srcTex ?? throw new ArgumentException("Texture from source target is null!"); }