コード例 #1
0
ファイル: TextureUtility.cs プロジェクト: looki666/Green-Hell
        public static RenderTexture CreateRenderTexture(this TextureUtility.RenderTextureDesc desc)
        {
            RenderTexture renderTexture = new RenderTexture(desc.Width, desc.Height, desc.Depth, desc.Format, desc.ColorSpace)
            {
                name             = desc.Name,
                volumeDepth      = desc.VolumeDepth,
                antiAliasing     = desc.Antialiasing,
                hideFlags        = desc.Flags,
                filterMode       = desc.Filter,
                wrapMode         = desc.Wrap,
                autoGenerateMips = desc.GenerateMipmaps,
                useMipMap        = desc.UseMipmaps,
                mipMapBias       = desc.MipmapBias
            };

            if (desc.EnableRandomWrite)
            {
                renderTexture.Release();
                renderTexture.enableRandomWrite = true;
                renderTexture.Create();
            }
            else
            {
                renderTexture.Create();
            }
            return(renderTexture);
        }
コード例 #2
0
        private void CreateRenderTargets()
        {
            this.DisposeTextures();
            int width  = Mathf.RoundToInt((float)this.Camera.CameraComponent.pixelWidth);
            int height = Mathf.RoundToInt((float)this.Camera.CameraComponent.pixelHeight);

            TextureUtility.RenderTextureDesc desc = new TextureUtility.RenderTextureDesc("[UWS] DynamicWaterCameraData - Displacement")
            {
                Width        = width,
                Height       = height,
                Antialiasing = this._Antialiasing,
                Format       = this._DisplacementFormat
            };
            TextureUtility.RenderTextureDesc desc2 = new TextureUtility.RenderTextureDesc("[UWS] DynamicWaterCameraData - Normals")
            {
                Width        = width,
                Height       = height,
                Antialiasing = this._Antialiasing,
                Format       = this._NormalFormat
            };
            TextureUtility.RenderTextureDesc desc3 = new TextureUtility.RenderTextureDesc("[UWS] DynamicWaterCameraData - Foam")
            {
                Width        = width,
                Height       = height,
                Antialiasing = this._Antialiasing,
                Format       = this._FoamFormat
            };
            TextureUtility.RenderTextureDesc desc4 = new TextureUtility.RenderTextureDesc("[UWS] DynamicWaterCameraData - Diffuse")
            {
                Width        = width,
                Height       = height,
                Antialiasing = this._Antialiasing,
                Format       = this._DiffuseFormat
            };
            TextureUtility.RenderTextureDesc desc5 = new TextureUtility.RenderTextureDesc("[UWS] DynamicWaterCameraData - Total Displacement")
            {
                Width        = 256,
                Height       = 256,
                Antialiasing = 1,
                Format       = this._TotalDisplacementFormat
            };
            this._Textures.Add(0, desc.CreateRenderTexture());
            this._Textures.Add(1, desc.CreateRenderTexture());
            this._Textures.Add(2, desc2.CreateRenderTexture());
            this._Textures.Add(3, desc3.CreateRenderTexture());
            this._Textures.Add(4, desc3.CreateRenderTexture());
            this._Textures.Add(5, desc4.CreateRenderTexture());
            this._Textures.Add(7, desc5.CreateRenderTexture());
        }