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


C# UnityEngine.RenderTexture类代码示例

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


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

示例1: MultiPassBlur

		protected virtual void MultiPassBlur(RenderTexture source, RenderTexture destination)
		{
			int w = Mathf.FloorToInt((float)source.width / Downscaling);
			int h = Mathf.FloorToInt((float)source.height / Downscaling);
			Vector2 horizontal = new Vector2(1f / w, 0f);
			Vector2 vertical = new Vector2(0f, 1f / h);
			RenderTexture rt1 = RenderTexture.GetTemporary(w, h, 0, source.format);
			RenderTexture rt2 = RenderTexture.GetTemporary(w, h, 0, source.format);

			Material.SetVector("_Direction", horizontal);
			Graphics.Blit(source, rt1, Material);
			Material.SetVector("_Direction", vertical);
			Graphics.Blit(rt1, rt2, Material);

			for (int i = 1; i < Passes; i++)
			{
				Material.SetVector("_Direction", horizontal);
				Graphics.Blit(rt2, rt1, Material);
				Material.SetVector("_Direction", vertical);
				Graphics.Blit(rt1, rt2, Material);
			}

			Graphics.Blit(rt2, destination);

			RenderTexture.ReleaseTemporary(rt1);
			RenderTexture.ReleaseTemporary(rt2);
		}
开发者ID:Thaon,项目名称:IRNBRU,代码行数:27,代码来源:GaussianBlur.cs

示例2: OnRenderImage

        public void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            CheckResources();
            originalTex = new Texture2D(source.width, source.height);

            // change texture. every white pixel should be transparent after this
            int y = 0;
            while (y < originalTex.height)
            {
                int x = 0;
                while (x < originalTex.width)
                {
                    Color colorAtPixel = new Color();
                    colorAtPixel = originalTex.GetPixel(x, y);
                    if (colorAtPixel[0] == 1 && colorAtPixel[1] == 1 && colorAtPixel[2] == 1 && colorAtPixel[3] == 1)
                    {
                        originalTex.SetPixel(x, y, Color.clear);
                    }
                    else
                    {
                        originalTex.SetPixel(x, y, new Color(colorAtPixel[0], colorAtPixel[1], colorAtPixel[2], colorAtPixel[3] ));
                    }
                    ++x;
                }
                ++y;
            }
            originalTex.Apply();

            transparentMaterial.SetTexture("_MainTex", originalTex);

            Graphics.Blit(source, destination, transparentMaterial, 0);
        }
开发者ID:unia-intsim-ws1516,项目名称:group07-tran-stifter,代码行数:32,代码来源:MakeWhiteTransparent.cs

示例3: OnRenderImage

        void OnRenderImage(RenderTexture source, RenderTexture destination)
        {
            if (_material == null)
            {
                _material = new Material(_shader);
                _material.hideFlags = HideFlags.DontSave;
            }

            var cam = GetComponent<Camera>();
            var aspect = new Vector4(cam.aspect, 1.0f / cam.aspect, 1, 0);

            _material.SetVector("_CameraAspect", aspect);
            _material.SetFloat("_LateralShift", _lateralShift);
            _material.SetFloat("_AxialStrength", _axialStrength);
            _material.SetFloat("_AxialShift", _axialShift);

            if (_axialStrength == 0)
            {
                _material.DisableKeyword("AXIAL_SAMPLE_LOW");
                _material.DisableKeyword("AXIAL_SAMPLE_HIGH");
            }
            else if (_axialQuality == QualityLevel.Low)
            {
                _material.EnableKeyword("AXIAL_SAMPLE_LOW");
                _material.DisableKeyword("AXIAL_SAMPLE_HIGH");
            }
            else
            {
                _material.DisableKeyword("AXIAL_SAMPLE_LOW");
                _material.EnableKeyword("AXIAL_SAMPLE_HIGH");
            }

            Graphics.Blit(source, destination, _material, 0);
        }
开发者ID:WondermSwift,项目名称:SpektrLightning,代码行数:34,代码来源:Fringe.cs

示例4: FlyingCamera

 public FlyingCamera(Part thatPart, RenderTexture screen, float aspect)
 {
     ourVessel = thatPart.vessel;
     ourPart = thatPart;
     screenTexture = screen;
     cameraAspect = aspect;
 }
开发者ID:Tahvohck,项目名称:RasterPropMonitor,代码行数:7,代码来源:FlyingCamera.cs

示例5: Cleanup

		public void Cleanup()
		{
			if (this.m_Camera)
			{
				UnityEngine.Object.DestroyImmediate(this.m_Camera.gameObject, true);
			}
			if (this.m_RenderTexture)
			{
				UnityEngine.Object.DestroyImmediate(this.m_RenderTexture);
				this.m_RenderTexture = null;
			}
			if (this.m_RenderTextureGammaCorrect)
			{
				UnityEngine.Object.DestroyImmediate(this.m_RenderTextureGammaCorrect);
				this.m_RenderTextureGammaCorrect = null;
			}
			Light[] light = this.m_Light;
			for (int i = 0; i < light.Length; i++)
			{
				Light light2 = light[i];
				if (light2)
				{
					UnityEngine.Object.DestroyImmediate(light2.gameObject, true);
				}
			}
		}
开发者ID:guozanhua,项目名称:UnityDecompiled,代码行数:26,代码来源:PreviewRenderUtility.cs

示例6: OnRenderImage

 protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     Material.SetVector("_RedClamp", Red);
     Material.SetVector("_GreenClamp", Green);
     Material.SetVector("_BlueClamp", Blue);
     Graphics.Blit(source, destination, Material);
 }
开发者ID:ChubbRck,项目名称:SFB,代码行数:7,代码来源:ChannelClamper.cs

示例7: OnRenderImage

        void OnRenderImage(RenderTexture src, RenderTexture dst)
        {
            if (m_material == null)
            {
                m_material = new Material(m_shader);
            }

            if (m_edge_highlighting)
            {
                m_material.EnableKeyword("ENABLE_EDGE_HIGHLIGHTING");
            }
            else
            {
                m_material.DisableKeyword("ENABLE_EDGE_HIGHLIGHTING");
            }

            if (m_mul_smoothness)
            {
                m_material.EnableKeyword("ENABLE_SMOOTHNESS_ATTENUAION");
            }
            else
            {
                m_material.DisableKeyword("ENABLE_SMOOTHNESS_ATTENUAION");
            }

            m_material.SetVector("_Color", GetLinearColor());
            m_material.SetVector("_Params1", new Vector4(m_fresnel_bias, m_fresnel_scale, m_fresnel_pow, m_intensity));
            m_material.SetVector("_Params2", new Vector4(m_edge_intensity, m_edge_threshold, m_edge_radius, 0.0f));
            Graphics.Blit(src, dst, m_material);
        }
开发者ID:nicegary,项目名称:Unity5Effects,代码行数:30,代码来源:RimLight.cs

示例8: PostScreenshot

        IEnumerator PostScreenshot()
        {
            yield return new WaitForEndOfFrame();

            var cam = Camera.current;
            var renderTexture = new RenderTexture(Screen.width, Screen.height, 24);
            cam.targetTexture = renderTexture;
            cam.Render();
            cam.targetTexture = null;

            Texture2D screenshot = new Texture2D(renderTexture.width, renderTexture.height, TextureFormat.RGB24, false);
            screenshot.ReadPixels(new Rect(0, 0, renderTexture.width, renderTexture.height), 0, 0);
            screenshot.Apply();
            Debug.Log("Screenshot taken...");

            Imvu.Login().Then(
                userModel => userModel.GetPersonalFeed()
            ).Then(
                feedCollection => {
                    return feedCollection.PostImage(screenshot);
                }
            ).Then(
                _ => Debug.Log("Screenshot posted!")
            ).Catch(
                error => Debug.Log(error.message)
            );
        }
开发者ID:SeruK,项目名称:Chatsent,代码行数:27,代码来源:FeedPostController.cs

示例9: OnRenderImage

        void OnRenderImage(RenderTexture src, RenderTexture dest)
        {
            int desiredDepth = Math.Max(src.depth, dest.depth);

            for (int i = 0; i < temp.Length; i++)
            {
                if (onRenderImageMethods.Count > i + 1)
                {
                    if (temp[i] != null &&
                        (temp[i].width != dest.width || temp[i].height != dest.height || temp[i].depth != desiredDepth || temp[i].format != dest.format))
                    {
                        Destroy(temp[i]);
                        temp[i] = null;
                    }
                    if (temp[i] == null)
                        temp[i] = new RenderTexture(dest.width, dest.height, desiredDepth, dest.format);
                }
            }

            var sequence = new List<RenderTexture>();
            sequence.Add(src);
            for (int i = 0; i < onRenderImageMethods.Count - 1; i++)
                sequence.Add(i % 2 == 0 ? temp[0] : temp[1]);
            sequence.Add(dest);

            for (int i = 0; i < onRenderImageMethods.Count; i++)
                onRenderImageMethods[i].Method.Invoke(onRenderImageMethods[i].Instance, new object[] { sequence[i], sequence[i + 1] });
        }
开发者ID:Colderrr,项目名称:ShootHoop,代码行数:28,代码来源:LSCopyCamImageEffect.cs

示例10: OnRenderImage

		protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			Material.SetVector("_Red", m_Channels[(int)RedSource]);
			Material.SetVector("_Green", m_Channels[(int)GreenSource]);
			Material.SetVector("_Blue", m_Channels[(int)BlueSource]);
			Graphics.Blit(source, destination, Material);
		}
开发者ID:davidlawson,项目名称:ggj2016,代码行数:7,代码来源:ChannelSwapper.cs

示例11: OnRenderImage

		void OnRenderImage(RenderTexture source, RenderTexture destination) {
			base.material.SetFloat("_Speed", speed);
			base.material.SetFloat("_Thickness", thickness);
			base.material.SetFloat("_Luminance", luminance);
			base.material.SetFloat("_Darkness", darkness);
			Graphics.Blit (source, destination, material);
		}
开发者ID:jjhesk,项目名称:unity-interview,代码行数:7,代码来源:PP_SecurityCamera.cs

示例12: OnRenderImage

		protected override void OnRenderImage(RenderTexture source, RenderTexture destination)
		{
			Material.SetVector("_Params", new Vector4(Sharpness * 0.01f, Darkness * 0.02f, Contrast * 0.01f, EdgeBlending * 0.01f));
			Material.SetVector("_Coeffs", ContrastCoeff);
			Material.SetVector("_Center", Center);
			Graphics.Blit(source, destination, Material);
		}
开发者ID:Fromfame,项目名称:RED,代码行数:7,代码来源:ContrastVignette.cs

示例13: Blur

        // flat blur
        void Blur(RenderTexture from  ,RenderTexture  to , int iterations  , int blurPass, float spread  )
        {
            RenderTexture tmp  = RenderTexture.GetTemporary (to.width, to.height, 0);

            if (iterations < 2) {
                dofBlurMaterial.SetVector ("offsets", new Vector4 (0.0f, spread * oneOverBaseSize, 0.0f, 0.0f));
                tmp.DiscardContents ();
                Graphics.Blit (from, tmp, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  0.0f, 0.0f, 0.0f));
                to.DiscardContents ();
                Graphics.Blit (tmp, to, dofBlurMaterial, blurPass);
            }
            else {
                dofBlurMaterial.SetVector ("offsets", new Vector4 (0.0f, spread * oneOverBaseSize, 0.0f, 0.0f));
                tmp.DiscardContents ();
                Graphics.Blit (from, tmp, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  0.0f, 0.0f, 0.0f));
                to.DiscardContents ();
                Graphics.Blit (tmp, to, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  spread * oneOverBaseSize, 0.0f, 0.0f));
                tmp.DiscardContents ();
                Graphics.Blit (to, tmp, dofBlurMaterial, blurPass);

                dofBlurMaterial.SetVector ("offsets", new Vector4 (spread / widthOverHeight * oneOverBaseSize,  -spread * oneOverBaseSize, 0.0f, 0.0f));
                to.DiscardContents ();
                Graphics.Blit (tmp, to, dofBlurMaterial, blurPass);
            }

            RenderTexture.ReleaseTemporary (tmp);
        }
开发者ID:haejoon,项目名称:realdedicated-unitylibrary,代码行数:34,代码来源:HeightDepthOfField.cs

示例14: PipeTextures

        protected void PipeTextures()
        {
            RefreshTextureScript rts = this.GetComponent<RefreshTextureScript>();
            if (rts != null) {
            this.source = rts.toReplace;

            } else {
            //grab original base texture. this is source.
            this.source = this.renderer.material.GetTexture("_MainTex");
            }
            if ((this.source as RenderTexture) != null) {
            RenderTexture s = this.source as RenderTexture;
            //create new destination texture.
            this.destination = new RenderTexture(s.width,s.height,s.depth);

            } else {
            this.destination = new RenderTexture(source.width,source.height,24);
            }

            //assign destination texture to existing shader.
            if (rts != null) {
            rts.toReplace = this.destination;
            } else {
            this.renderer.material.SetTexture("_MainTex",this.destination);
            }
        }
开发者ID:rlawther,项目名称:AmnesiaMuseumUnity,代码行数:26,代码来源:icMotionBlur.cs

示例15: OnRenderImage

		void OnRenderImage( RenderTexture source, RenderTexture destination )
		{
			if( CheckResources() == false )
			{
				Graphics.Blit( source, destination );
				return;
			}

			cloudsMaterial.SetFloat( "_ForwardIntegrator", m_distTravelledForward );

			Vector4 camPos = new Vector4( transform.position.x, transform.position.y, transform.position.z, 0.0f );
			cloudsMaterial.SetVector( "_CamPos", camPos );
			
			Vector4 camForward = new Vector4( transform.forward.x, transform.forward.y, transform.forward.z, 0.0f );
			cloudsMaterial.SetVector( "_CamForward", camForward );
			Vector4 camRight = new Vector4( transform.right.x, transform.right.y, transform.right.z, 0.0f );
			cloudsMaterial.SetVector( "_CamRight", camRight );

			/*
			Vector4 spherePos = Vector4.zero;
			if( sphere )
				spherePos.Set( sphere.position.x, sphere.position.y, sphere.position.z, 0.0f );
			cloudsMaterial.SetVector( "_SphereCenter", spherePos );
			*/

			cloudsMaterial.SetTexture( "_NoiseTex", noiseTexture );

			Graphics.Blit( source, destination, cloudsMaterial, 0 );

			cloudsMaterial.SetFloat( "_SamplesCurvature", m_samplesCurvature );
			//cloudsMaterial.SetFloat( "_CenterOfRot",  centerOfRot );

			float fov = Mathf.Max( Camera.main.aspect, 1.0f ) * Camera.main.fieldOfView * Mathf.Deg2Rad;
			cloudsMaterial.SetFloat( "_HalfFov", fov/2.0f );
		}
开发者ID:ideoservo,项目名称:volsample,代码行数:35,代码来源:Clouds.cs


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