当前位置: 首页>>代码示例>>C#>>正文


C# RenderTexture.MarkRestoreExpected方法代码示例

本文整理汇总了C#中UnityEngine.RenderTexture.MarkRestoreExpected方法的典型用法代码示例。如果您正苦于以下问题:C# RenderTexture.MarkRestoreExpected方法的具体用法?C# RenderTexture.MarkRestoreExpected怎么用?C# RenderTexture.MarkRestoreExpected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.RenderTexture的用法示例。


在下文中一共展示了RenderTexture.MarkRestoreExpected方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: PaintTexture

    void PaintTexture(RenderTexture _canvas, Material _brush, float _size, float _posX, float _posY)
    {
        Debug.Log (string.Format("_size = {0}, _posX = {1}, _posY = {2}",_size,_posX,_posY));

        float halfSize = _size / 2F;

        _canvas.MarkRestoreExpected ();
        Graphics.SetRenderTarget(_canvas);

        GL.PushMatrix();

        _brush.SetPass (0);

        GL.LoadOrtho();

        GL.Begin(GL.QUADS);

        GL.TexCoord(new Vector3(0, 0, 0));
        GL.Vertex3(_posX - halfSize, _posY - halfSize, 0);

        GL.TexCoord(new Vector3(0, 1, 0));
        GL.Vertex3(_posX - halfSize, _posY + halfSize, 0);

        GL.TexCoord(new Vector3(1, 1, 0));
        GL.Vertex3(_posX + halfSize, _posY + halfSize, 0);

        GL.TexCoord(new Vector3(1, 0, 0));
        GL.Vertex3(_posX + halfSize, _posY - halfSize, 0);

        GL.End();

        GL.PopMatrix();

        Graphics.SetRenderTarget(null);
    }
开发者ID:DeanLu,项目名称:SnowBall,代码行数:35,代码来源:Paint.cs

示例2: Clear

    void Clear(RenderTexture _canvas, Material _brush)
    {
        _canvas.MarkRestoreExpected ();
        Graphics.SetRenderTarget(_canvas);

        GL.Clear(false, true, Color.clear);

        Graphics.SetRenderTarget(null);
    }
开发者ID:DeanLu,项目名称:SnowBall,代码行数:9,代码来源:Paint.cs

示例3: WriteCoc

        private void WriteCoc ( RenderTexture fromTo, bool fgDilate) {
            dofHdrMaterial.SetTexture("_FgOverlap", null);

            if (nearBlur && fgDilate) {

                int rtW = fromTo.width/2;
                int rtH = fromTo.height/2;

                // capture fg coc
                RenderTexture temp2 = RenderTexture.GetTemporary (rtW, rtH, 0, fromTo.format);
                Graphics.Blit (fromTo, temp2, dofHdrMaterial, 4);

                // special blur
                float fgAdjustment = internalBlurWidth * foregroundOverlap;

                dofHdrMaterial.SetVector ("_Offsets", new Vector4 (0.0f, fgAdjustment , 0.0f, fgAdjustment));
                RenderTexture temp1 = RenderTexture.GetTemporary (rtW, rtH, 0, fromTo.format);
                Graphics.Blit (temp2, temp1, dofHdrMaterial, 2);
                RenderTexture.ReleaseTemporary(temp2);

                dofHdrMaterial.SetVector ("_Offsets", new Vector4 (fgAdjustment, 0.0f, 0.0f, fgAdjustment));
                temp2 = RenderTexture.GetTemporary (rtW, rtH, 0, fromTo.format);
                Graphics.Blit (temp1, temp2, dofHdrMaterial, 2);
                RenderTexture.ReleaseTemporary(temp1);

                // "merge up" with background COC
                dofHdrMaterial.SetTexture("_FgOverlap", temp2);
                fromTo.MarkRestoreExpected(); // only touching alpha channel, RT restore expected
                Graphics.Blit (fromTo, fromTo, dofHdrMaterial,  13);
                RenderTexture.ReleaseTemporary(temp2);
            }
            else {
                // capture full coc in alpha channel (fromTo is not read, but bound to detect screen flip)
				fromTo.MarkRestoreExpected(); // only touching alpha channel, RT restore expected
                Graphics.Blit (fromTo, fromTo, dofHdrMaterial,  0);
            }
        }
开发者ID:CenzyGames,项目名称:Save-your-date-new,代码行数:37,代码来源:DepthOfField.cs

示例4: Vignette

	private void Vignette (float amount, RenderTexture from, RenderTexture to)
	{
		if (lensFlareVignetteMask)
		{
			screenBlend.SetTexture ("_ColorBuffer", lensFlareVignetteMask);
			to.MarkRestoreExpected(); // using blending, RT restore expected
			Graphics.Blit (from == to ? null : from, to, screenBlend, from == to ? 7 : 3);
		}
		else if (from != to)
		{
			Graphics.SetRenderTarget (to);
			GL.Clear(false, true, Color.black); // clear destination to avoid RT restore
			Graphics.Blit (from, to);
		}
	}
开发者ID:EfremovCompany,项目名称:CursGameUnity,代码行数:15,代码来源:Bloom.cs

示例5: BlendFlares

	private void BlendFlares (RenderTexture from, RenderTexture to)
	{
		lensFlareMaterial.SetVector ("colorA", new Vector4 (flareColorA.r, flareColorA.g, flareColorA.b, flareColorA.a) * lensflareIntensity);
		lensFlareMaterial.SetVector ("colorB", new Vector4 (flareColorB.r, flareColorB.g, flareColorB.b, flareColorB.a) * lensflareIntensity);
		lensFlareMaterial.SetVector ("colorC", new Vector4 (flareColorC.r, flareColorC.g, flareColorC.b, flareColorC.a) * lensflareIntensity);
		lensFlareMaterial.SetVector ("colorD", new Vector4 (flareColorD.r, flareColorD.g, flareColorD.b, flareColorD.a) * lensflareIntensity);
		to.MarkRestoreExpected(); // additive blending, RT restore expected
		Graphics.Blit (from, to, lensFlareMaterial);
	}
开发者ID:EfremovCompany,项目名称:CursGameUnity,代码行数:9,代码来源:Bloom.cs

示例6: AddTo

	private void AddTo (float intensity_, RenderTexture from, RenderTexture to)
	{
		screenBlend.SetFloat ("_Intensity", intensity_);
		to.MarkRestoreExpected(); // additive blending, RT restore expected
		Graphics.Blit (from, to, screenBlend, 9);
	}
开发者ID:EfremovCompany,项目名称:CursGameUnity,代码行数:6,代码来源:Bloom.cs

示例7: RenderHighlighting


//.........这里部分代码省略.........
			int w = Screen.width;
			int h = Screen.height;
			int depth = 24;			// because stencil will be rendered to the highlightingBuffer.depthBuffer

			// If frameBuffer.depthBuffer is available
			if (isDepthAvailable)
			{
				w = frameBuffer.width;
				h = frameBuffer.height;
				depth = 0;			// because stencil will be rendered to frameBuffer.depthBuffer
			}

			// Setup highlightingBuffer RenderTexture
			highlightingBuffer = RenderTexture.GetTemporary(w, h, depth, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, aa);
			if (!highlightingBuffer.IsCreated())
			{
				highlightingBuffer.filterMode = FilterMode.Point;
				highlightingBuffer.useMipMap = false;
				highlightingBuffer.wrapMode = TextureWrapMode.Clamp;
			}

			// Clear highlightingBuffer colorBuffer and clear depthBuffer only in case frameBuffer depth data is not available
			RenderTexture.active = highlightingBuffer;
			GL.Clear((isDepthAvailable ? false : true), true, Color.clear);

			// Use depth data from frameBuffer in case it is available. Use highlightingBuffer.depthBuffer otherwise
			RenderBuffer depthBuffer = isDepthAvailable ? frameBuffer.depthBuffer : highlightingBuffer.depthBuffer;
			
			if (!shaderCameraGO)
			{
				shaderCameraGO = new GameObject("HighlightingCamera");
				shaderCameraGO.hideFlags = HideFlags.HideAndDontSave;
				shaderCamera = shaderCameraGO.AddComponent<Camera>();
				shaderCamera.enabled = false;
			}
			
			shaderCamera.CopyFrom(refCam);
			//shaderCamera.projectionMatrix = mainCam.projectionMatrix;		// Uncomment this line if you have problems using Highlighting System with custom projection matrix on your camera
			shaderCamera.cullingMask = layerMask;
			shaderCamera.rect = new Rect(0f, 0f, 1f, 1f);
			shaderCamera.renderingPath = RenderingPath.Forward;
			shaderCamera.depthTextureMode = DepthTextureMode.None;
			shaderCamera.hdr = false;
			shaderCamera.useOcclusionCulling = false;
			shaderCamera.backgroundColor = new Color(0, 0, 0, 0);
			shaderCamera.clearFlags = CameraClearFlags.Nothing;
			shaderCamera.SetTargetBuffers(highlightingBuffer.colorBuffer, depthBuffer);

			// Get rid of "Tiled GPU Perf warning" if we're not in debug mode
			#if !DEBUG_ENABLED
			frameBuffer.MarkRestoreExpected();
			#endif
			shaderCamera.Render();

			// Extinguish all highlighters
			for (int i = 0; i < highlighters.Count; i++)
			{
				highlighters[i].Extinguish();
			}

			// Highlighting buffer rendering finished. Reset currently active HighlightingBase
			current = null;

			// Create two buffers for blurring the image
			int width = highlightingBuffer.width / _downsampleFactor;
			int height = highlightingBuffer.height / _downsampleFactor;
			RenderTexture buffer = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, 1);
			RenderTexture buffer2 = RenderTexture.GetTemporary(width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Default, 1);
			if (!buffer.IsCreated())
			{
				buffer.useMipMap = false;
				buffer.wrapMode = TextureWrapMode.Clamp;
			}
			if (!buffer2.IsCreated())
			{
				buffer2.useMipMap = false;
				buffer2.wrapMode = TextureWrapMode.Clamp;
			}
			
			// Copy highlighting buffer to the smaller texture
			Graphics.Blit(highlightingBuffer, buffer, blitMaterial);
			
			// Blur the small texture
			bool oddEven = true;
			for (int i = 0; i < iterations; i++)
			{
				if (oddEven) { FourTapCone(buffer, buffer2, i); }
				else { FourTapCone(buffer2, buffer, i); }
				oddEven = !oddEven;
			}
			
			// Upscale blurred texture and cut stencil from it
			Graphics.SetRenderTarget(highlightingBuffer.colorBuffer, depthBuffer);
			cutMaterial.SetTexture(ShaderPropertyID._MainTex, oddEven ? buffer : buffer2);
			DoubleBlit(cutMaterial, 0, cutMaterial, 1);

			// Cleanup
			RenderTexture.ReleaseTemporary(buffer);
			RenderTexture.ReleaseTemporary(buffer2);
		}
开发者ID:joexi,项目名称:UnityShader,代码行数:101,代码来源:HighlightingBase.cs

示例8: WriteCoc

 private void WriteCoc(RenderTexture fromTo, bool fgDilate)
 {
     this.dofHdrMaterial.SetTexture("_FgOverlap", null);
     if (this.nearBlur && fgDilate)
     {
         int width = fromTo.width / 2;
         int height = fromTo.height / 2;
         RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, fromTo.format);
         Graphics.Blit(fromTo, temporary, this.dofHdrMaterial, 4);
         float num = this.internalBlurWidth * this.foregroundOverlap;
         this.dofHdrMaterial.SetVector("_Offsets", new Vector4(0f, num, 0f, num));
         RenderTexture temporary2 = RenderTexture.GetTemporary(width, height, 0, fromTo.format);
         Graphics.Blit(temporary, temporary2, this.dofHdrMaterial, 2);
         RenderTexture.ReleaseTemporary(temporary);
         this.dofHdrMaterial.SetVector("_Offsets", new Vector4(num, 0f, 0f, num));
         temporary = RenderTexture.GetTemporary(width, height, 0, fromTo.format);
         Graphics.Blit(temporary2, temporary, this.dofHdrMaterial, 2);
         RenderTexture.ReleaseTemporary(temporary2);
         this.dofHdrMaterial.SetTexture("_FgOverlap", temporary);
         fromTo.MarkRestoreExpected();
         Graphics.Blit(fromTo, fromTo, this.dofHdrMaterial, 13);
         RenderTexture.ReleaseTemporary(temporary);
     }
     else
     {
         fromTo.MarkRestoreExpected();
         Graphics.Blit(fromTo, fromTo, this.dofHdrMaterial, 0);
     }
 }
开发者ID:GameDiffs,项目名称:TheForest,代码行数:29,代码来源:DepthOfField.cs

示例9: CreateHelperTextures

	private void CreateHelperTextures()
	{
		const int size = 32;
		const int maxSize = size - 1;
		int width = size * size;
		int height = size;

		ReleaseTextures();

		blendCacheLut = new RenderTexture( width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear ) { hideFlags = HideFlags.HideAndDontSave };
		blendCacheLut.name = "BlendCacheLut";
		blendCacheLut.wrapMode = TextureWrapMode.Clamp;
		blendCacheLut.useMipMap = false;
		blendCacheLut.anisoLevel = 0;
		blendCacheLut.Create();

		midBlendLUT = new RenderTexture( width, height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear ) { hideFlags = HideFlags.HideAndDontSave };
		midBlendLUT.name = "MidBlendLut";
		midBlendLUT.wrapMode = TextureWrapMode.Clamp;
		midBlendLUT.useMipMap = false;
		midBlendLUT.anisoLevel = 0;
		midBlendLUT.Create();
	#if UNITY_4
		midBlendLUT.MarkRestoreExpected();
	#endif

		normalLut = new Texture2D( width, height, TextureFormat.RGB24, false, true ) { hideFlags = HideFlags.HideAndDontSave };
		normalLut.name = "NormalLut";
		normalLut.hideFlags = HideFlags.DontSave;
		normalLut.anisoLevel = 1;
		normalLut.filterMode = FilterMode.Bilinear;
		Color32[] colors = new Color32[ width * height ];
		for ( int z = 0; z < size; z++ )
		{
			int zoffset = z * size;
			for ( int y = 0; y < size; y++ )
			{
				int yoffset = zoffset + y * width;
				for ( int x = 0; x < size; x++ )
				{
					float fr = x / ( float ) maxSize;
					float fg = y / ( float ) maxSize;
					float fb = z / ( float ) maxSize;
					byte br = ( byte ) ( fr * 255 );
					byte bg = ( byte ) ( fg * 255 );
					byte bb = ( byte ) ( fb * 255 );
					colors[ yoffset + x ] = new Color32( br, bg, bb, 255 );
				}
			}
		}
		normalLut.SetPixels32( colors );
		normalLut.Apply();
	}
开发者ID:Avatarchik,项目名称:Off-Peak,代码行数:53,代码来源:AmplifyColorBase.cs

示例10: CreateHelperTextures

	private void CreateHelperTextures()
	{
		ReleaseTextures();

		blendCacheLut = new RenderTexture( LutWidth, LutHeight, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear ) { hideFlags = HideFlags.HideAndDontSave };
		blendCacheLut.name = "BlendCacheLut";
		blendCacheLut.wrapMode = TextureWrapMode.Clamp;
		blendCacheLut.useMipMap = false;
		blendCacheLut.anisoLevel = 0;
		blendCacheLut.Create();

		midBlendLUT = new RenderTexture( LutWidth, LutHeight, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear ) { hideFlags = HideFlags.HideAndDontSave };
		midBlendLUT.name = "MidBlendLut";
		midBlendLUT.wrapMode = TextureWrapMode.Clamp;
		midBlendLUT.useMipMap = false;
		midBlendLUT.anisoLevel = 0;
		midBlendLUT.Create();
	#if UNITY_4
		midBlendLUT.MarkRestoreExpected();
	#endif

		CreateDefaultLut();
	}
开发者ID:cuongngo90,项目名称:Unity-SpriteShader,代码行数:23,代码来源:AmplifyColorBase.cs

示例11: UpdateRTT

    void UpdateRTT()
    {
        RenderCam = gameObject.GetComponent<Camera> ();
        Buffer = new RenderTexture (horizontalResolution, verticalResolution, 16);
        Buffer.generateMips = false;
        Buffer.filterMode = FilterMode.Point;
        //Buffer.antiAliasing = BufferAA;
        Buffer.name = "Pixel Buffer!";
        RenderCam.targetTexture = Buffer;
        if (BufferAA > 1) {
            AABuffer = new RenderTexture(Mathf.CeilToInt(horizontalResolution*AAMulti),Mathf.CeilToInt(verticalResolution*AAMulti),16);

            AABuffer.filterMode = FilterMode.Bilinear;
            AABuffer.generateMips = false;
            AABuffer.antiAliasing = 1;// BufferAA;

            Buffer.name = "AA Pixel Buffer!";
            RenderCam.targetTexture = AABuffer;
            Buffer.MarkRestoreExpected ();

        }
        if (pixelScale == 5)
            OutlinePixelScaling = 2f;
        if (pixelScale == 4)
            OutlinePixelScaling = 1.666f;
        if (pixelScale == 3)
            OutlinePixelScaling = 1.25f;
        if (pixelScale == 2)
            OutlinePixelScaling = .9f;
        if (pixelScale == 1)
            OutlinePixelScaling = .5f;
        if (Application.platform == RuntimePlatform.OSXWebPlayer || Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.WebGLPlayer) {
            OutlinePixelScaling *= -.05f;
        }
        //OutlinePixelScaling *= 1.5f;
        if (!enableOutlines)
            OutlinePixelScaling = 0;
        if(BufferAA == 1)
            OutlinePixelScaling *= 1.1f;
        Shader.SetGlobalFloat("_DitherScale", 24f/2*(768f/Screen.height)*pixelScale  );
        if (!isOrthographic) {
            Shader.SetGlobalFloat ("_OutlineWidth", (shaderOutlineWidth / 2f) * (768f / Screen.height));
        }
        if(isOrthographic)
        {

            Shader.SetGlobalFloat ("_OutlineWidth", (shaderOutlineWidth / 2f)* (768f/Screen.height) * (Camera.main.orthographicSize/90)*OutlinePixelScaling );
            Shader.SetGlobalVector("_DitherScale", new Vector4(Screen.width/256f/pixelScale, Screen.height/256f/pixelScale,0,0) );
            //Debug.Log (Screen.width/256f);
        }
        #if UNITY_EDITOR
        if(!Application.isPlaying && isOrthographic)
            Shader.SetGlobalFloat ("_OutlineWidth", (shaderOutlineWidth * 2f )* (768f/Screen.height));
        #endif

        if(BufferMat)
            BufferMat.mainTexture = Buffer;
        OldAA = BufferAA;
        OldSize = new Vector2 (horizontalResolution,verticalResolution);
        OldOutlines = enableOutlines;
    }
开发者ID:Howard-Day,项目名称:PixelArt,代码行数:61,代码来源:PixelArt.cs


注:本文中的UnityEngine.RenderTexture.MarkRestoreExpected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。