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


C# RenderTexture类代码示例

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


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

示例1: Terrain

 public Terrain(Device device, String texture, int pitch, Renderer renderer)
 {
     HeightMap = new System.Drawing.Bitmap(@"Data/Textures/"+texture);
     WaterShader = new WaterShader(device);
     TerrainShader = new TerrainShader(device);
     _width = HeightMap.Width-1;
     _height = HeightMap.Height-1;
     _pitch = pitch;
     _terrainTextures = new ShaderResourceView[4];
     _terrainTextures[0] = new Texture(device, "Sand.png").TextureResource;
     _terrainTextures[1] = new Texture(device, "Grass.png").TextureResource;
     _terrainTextures[2] = new Texture(device, "Ground.png").TextureResource;
     _terrainTextures[3] = new Texture(device, "Rock.png").TextureResource;
     _reflectionClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 0.0f);
     _refractionClippingPlane = new Vector4(0.0f, -1.0f, 0.0f, 0.0f);
     _noClippingPlane = new Vector4(0.0f, 1.0f, 0.0f, 10000);
     _reflectionTexture = new RenderTexture(device, renderer.ScreenSize);
     _refractionTexture = new RenderTexture(device, renderer.ScreenSize);
     _renderer = renderer;
     _bitmap = new Bitmap(device,_refractionTexture.ShaderResourceView,renderer.ScreenSize, new Vector2I(100, 100), 0);
     _bitmap.Position = new Vector2I(renderer.ScreenSize.X - 100, 0);
     _bitmap2 = new Bitmap(device, _reflectionTexture.ShaderResourceView, renderer.ScreenSize, new Vector2I(100, 100), 0);
     _bitmap2.Position = new Vector2I(renderer.ScreenSize.X - 100, 120);
     _bumpMap = _renderer.TextureManager.Create("OceanWater.png");
     _skydome = new ObjModel(device, "skydome.obj", renderer.TextureManager.Create("Sky.png"));
     BuildBuffers(device);
     WaveTranslation = new Vector2(0,0);
 }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:28,代码来源:Terrain.cs

示例2: OnRenderImage

	protected virtual void OnRenderImage(RenderTexture source, RenderTexture destination)
	{
		material.SetVector("_RedClamp", red);
		material.SetVector("_GreenClamp", green);
		material.SetVector("_BlueClamp", blue);
		Graphics.Blit(source, destination, material);
	}
开发者ID:Fromfame,项目名称:RED,代码行数:7,代码来源:CC_ChannelClamper.cs

示例3: OnRenderImage

    void OnRenderImage( RenderTexture source ,   RenderTexture destination  )
    {
        #if UNITY_EDITOR
        FindShaders ();
        CheckSupport ();
        CreateMaterials ();
        #endif

        agonyTint = Mathf.Clamp01 (agonyTint - Time.deltaTime * 2.75f);

        RenderTexture tempRtLowA = RenderTexture.GetTemporary (source.width / 4, source.height / 4,0, rtFormat);
        RenderTexture tempRtLowB = RenderTexture.GetTemporary (source.width / 4, source.height / 4, 0,rtFormat);

        // prepare data

        apply.SetColor ("_ColorMix", colorMix);
        apply.SetVector ("_Parameter",new Vector4 (colorMixBlend * 0.25f,  0.0f, 0.0f, 1.0f - intensity - agonyTint));

        // downsample & blur

        Graphics.Blit (source, tempRtLowA, apply, agonyTint < 0.5f ? 1 : 5);
        Graphics.Blit (tempRtLowA, tempRtLowB, apply, 2);
        Graphics.Blit (tempRtLowB, tempRtLowA, apply, 3);

        // apply

        apply.SetTexture ("_Bloom", tempRtLowA);
        Graphics.Blit (source, destination, apply, QualityManager.quality > Quality.Medium ? 4 : 0);

        RenderTexture.ReleaseTemporary (tempRtLowA);
        RenderTexture.ReleaseTemporary (tempRtLowB);
    }
开发者ID:cn00,项目名称:U3D5_CSharp_AngryBots,代码行数:32,代码来源:MobileBloom.cs

示例4: LateUpdate

 void LateUpdate()
 {
     if(_isActive != isActive)
     {
         _isActive = isActive;
         if(isActive)
         {
             depthTexture = new RenderTexture(TextureSize,TextureSize, 16, RenderTextureFormat.ARGB32);
             depthTexture.filterMode = FilterMode.Point;
         }else
         {
             RenderTexture.DestroyImmediate(depthTexture);
         }
     }
     if(isActive)
     {
         depthCamera.cullingMask = casterLayer;
         depthCamera.orthographicSize = Size;
         depthCamera.farClipPlane = Far;
         depthCamera.Render();
         Matrix4x4 depthProjectionMatrix = depthCamera.projectionMatrix;
         Matrix4x4 depthViewMatrix = depthCamera.worldToCameraMatrix;
         Matrix4x4 depthVP = depthProjectionMatrix * depthViewMatrix ;
         Matrix4x4 depthVPBias = biasMatrix * depthVP;
         Shader.SetGlobalMatrix("_depthVPBias", depthVPBias);
         Shader.SetGlobalMatrix("_depthV", depthViewMatrix);
         Shader.SetGlobalTexture("_kkShadowMap", depthCamera.targetTexture);
         Shader.SetGlobalFloat("_bias", Bias);
         Shader.SetGlobalFloat("_strength", 1 - Strength);
         Shader.SetGlobalFloat("_texmapScale", 1f/TextureSize);
         Shader.SetGlobalFloat("_farplaneScale", 1/Far);
     }
 }
开发者ID:kokichi88,项目名称:shadowmapping,代码行数:33,代码来源:GenerateDepthTexture2.cs

示例5: Create

 // Make a material that points to the target texture.  Texture scale
 // and offset will be controlled by rect.
 public void Create(RenderTexture target) {
   meshRenderer.material = new Material(Shader.Find("Cardboard/GUIScreen")) {
     mainTexture = target,
     mainTextureOffset = rect.position,
     mainTextureScale = rect.size
   };
 }
开发者ID:CaminhoneiroHell,项目名称:demo_cardboard,代码行数:9,代码来源:CardboardOnGUIWindow.cs

示例6: OnRenderImage

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

		int rtW = source.width >> downsample;
		int rtH = source.height >> downsample;

		// downsample
		RenderTexture rt = RenderTexture.GetTemporary (rtW, rtH, 0, source.format);

		rt.filterMode = FilterMode.Bilinear;

		Graphics.Blit (source, rt, material, 0);

		Debug.Log("MSKFNAN");

		if (!winner) {
			material.SetVector("iResolution",new Vector4(Screen.width,Screen.height,0,0));
			material.SetFloat("distFromOrigin", DistFromOrigin );
			material.SetVector("buddyPos",BuddyBoy.transform.position);
			material.SetFloat("distFromPath", DistFromPath );
			material.SetVector("camForward",BuddyBoy.transform.forward);
			material.SetVector("camRight",BuddyBoy.transform.right);
			material.SetVector("camUp",BuddyBoy.transform.up);
		}

		Graphics.Blit (rt, destination);
		RenderTexture.ReleaseTemporary (rt);
    }
开发者ID:rbrt,项目名称:GGJ16,代码行数:33,代码来源:ShaderToy.cs

示例7: OnRenderImage

	void OnRenderImage (RenderTexture source, RenderTexture destination){

		Graphics.Blit(source,destination,mat);
		//mat is the material which contains the shader
		//we are passing the destination RenderTexture to


		int width = Screen.width;
		int height = Screen.height;

		Debug.Log (width.ToString ());
		Debug.Log (height.ToString ());

		Texture2D tex = new Texture2D(width, height);
		tex.ReadPixels(new Rect(0, 0, width, height), 0, 0);


		if (flag == true) {
			string[] blue = new string[width * height];

			for (int i = 0; i < height; i++) {
				for (int j=0; j < width; j++) {
					blue[(i * width) + j]  = tex.GetPixel (j, i).b.ToString ();
				}
			}
			string output = string.Join(",", blue);
			File.WriteAllText ("/Users/mettinger/Desktop/temp/output.txt", output);
			flag = false;
		}
		Debug.Log (tex.GetPixel(x,y).b.ToString());
	
	}
开发者ID:mettinger,项目名称:unity,代码行数:32,代码来源:PostProcessDepthGrayscale.cs

示例8: OnRenderImage

 // Called by camera to apply image effect
 void OnRenderImage(RenderTexture source, RenderTexture destination)
 {
     base.material.SetFloat("_Intense1", intense1);
     base.material.SetFloat("_Intense2", intense2);
     base.material.SetFloat("_Count", count);
     Graphics.Blit (source, destination, material);
 }
开发者ID:lightnarcissus,项目名称:Hashtagger,代码行数:8,代码来源:PP_Scanlines.cs

示例9: OnRenderImage

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

        if (_noise > 0.01f || _invert > 0.01f || _whiteout > 0.01f)
        {
            if (_noise > 0.01f)
            {
                _material.EnableKeyword("NOISE_ON");
                _material.SetFloat("_NoiseThreshold", Mathf.Clamp01(1.0f - _noise * 1.2f));
                _material.SetFloat("_NoiseDisplace", 0.01f + Mathf.Pow(_noise, 3) * 0.1f);
            }
            else
            {
                _material.DisableKeyword("NOISE_ON");
            }

            _material.SetFloat("_Invert", _invert);
            _material.SetFloat("_Whiteout", _whiteout);

            Graphics.Blit(source, destination, _material);
        }
        else
        {
            Graphics.Blit(source, destination);
        }
    }
开发者ID:Garridus,项目名称:VJ04,代码行数:30,代码来源:VJ04Vfx.cs

示例10: CreateTextures

    public void CreateTextures()
    {
        if (texW == 0) texW = 1;//TODO rm
        if (texH == 0) texH = 1;
        if (texW == 0) throw new System.Exception("texW must be > 0");
        if (texH == 0) throw new System.Exception("texH must be > 0");
        texelSize = new Vector2(1f / texW, 1f / texH);
        maxTexelDistance = texelSize.magnitude;

        //Create textures
        texCur = new RenderTexture(texW, texH, 0, RenderTextureFormat.RFloat);
        texCur.enableRandomWrite = true;
        texCur.generateMips = false;
        texCur.Create();
        texDest = new RenderTexture(texW, texH, 0, RenderTextureFormat.RFloat);
        texDest.enableRandomWrite = true;
        texDest.generateMips = false;
        texCur.filterMode = FilterMode.Point;
        texDest.Create();

        //Clear textures
        Graphics.SetRenderTarget(texCur);
        GL.Clear(true, true, Color.white);
        Graphics.SetRenderTarget(texDest);
        GL.Clear(true, true, Color.white);
        Graphics.SetRenderTarget(null);

        //Instantiate material
        renderMaterial = new Material(visibilityOverlayMaterial);
        renderMaterial.SetTexture("_Mask", texCur);
    }
开发者ID:XZelnar,项目名称:PlanetoidMapGen,代码行数:31,代码来源:MapChunkVisibilityOverlay.cs

示例11: ComputeFocusScores

    public static void ComputeFocusScores(RenderTexture instanceIdBuffer, RenderTexture depthBuffer)
    {
        //ComputeShaderManager.Get.ComputeColorInfo.SetBuffer(3, "_ClearBuffer", GPUBuffers.Get.ProteinFocusScore);
        //ComputeShaderManager.Get.ComputeColorInfo.Dispatch(3, Mathf.CeilToInt(SceneManager.Get.NumLipidInstances / 64.0f), 1, 1);

        ComputeShaderManager.Get.ComputeColorInfo.SetBuffer(3, "_ClearBuffer", GPUBuffers.Get.ProteinFocusScore);
        ComputeShaderManager.Get.ComputeColorInfo.Dispatch(3, Mathf.CeilToInt(SceneManager.Get.NumProteinInstances / 64.0f), 1, 1);
        

        //*************************************************//

        GPUBuffers.Get.IngredientsColorInfo.SetData(CPUBuffers.Get.IngredientsDisplayInfo.ToArray());
        GPUBuffers.Get.IngredientGroupsColorInfo.SetData(CPUBuffers.Get.IngredientGroupsDisplayInfo.ToArray());

        ComputeShaderManager.Get.ComputeColorInfo.SetInt("_Width", instanceIdBuffer.width);
        ComputeShaderManager.Get.ComputeColorInfo.SetInt("_Height", instanceIdBuffer.height);


        ComputeShaderManager.Get.ComputeColorInfo.SetTexture(4, "_DepthBuffer", depthBuffer);
        ComputeShaderManager.Get.ComputeColorInfo.SetTexture(4, "_InstanceIdBuffer", instanceIdBuffer);

        //ComputeShaderManager.Get.ComputeColorInfo.SetBuffer(4, "_IngredientsInfo", GPUBuffers.Get.IngredientsInfo);
        //ComputeShaderManager.Get.ComputeColorInfo.SetBuffer(4, "_LipidInstancesInfo", GPUBuffers.Get.LipidInstancesInfo);
        ComputeShaderManager.Get.ComputeColorInfo.SetBuffer(4, "_ProteinInstancesInfo", GPUBuffers.Get.ProteinInstancesInfo);
        ComputeShaderManager.Get.ComputeColorInfo.SetBuffer(4, "_RWProteinFocusScore", GPUBuffers.Get.IngredientsColorInfo);

        ComputeShaderManager.Get.ComputeColorInfo.Dispatch(4, Mathf.CeilToInt(instanceIdBuffer.width / 8.0f), Mathf.CeilToInt(instanceIdBuffer.height / 8.0f), 1);
    }
开发者ID:matmuze,项目名称:cellVIEW_color,代码行数:28,代码来源:ColorCompositeUtils.cs

示例12: OnRenderImage

    // Called by camera to apply image effect
    void OnRenderImage(RenderTexture source, RenderTexture destination)
    {
        material.SetFloat("_PixelWidth", pixelWidth);
        material.SetFloat("_PixelHeight", pixelHeight);

        Graphics.Blit (source, destination, material, 0);
    }
开发者ID:vorrin,项目名称:samurai,代码行数:8,代码来源:Pixelated.cs

示例13: Start

    // Use this for initialization
    void Start()
    {
        //eyeDistance_s = S3DVM.eyeDistance;
        //focalDistance_s = S3DVM.focalDistance;

        camera = GetComponent<Camera>();

        //leftEye = new GameObject ("leftEye");
        //rightEye = new GameObject ("rightEye");

        //leftEye.AddComponent<Camera>();
        //rightEye.AddComponent<Camera>();

        //leftEye.GetComponent<Camera>().CopyFrom (camera);
        //rightEye.GetComponent<Camera>().CopyFrom (camera);

        FrontRT = new RenderTexture ((int)(Screen.width*textureResolution), (int)(Screen.height*textureResolution), 24);
        BackRT = new RenderTexture ((int)(Screen.width*textureResolution), (int)(Screen.height*textureResolution), 24);

        FrontCam.GetComponent<Camera>().targetTexture = FrontRT;
        BackCam.GetComponent<Camera>().targetTexture = BackRT;

        MergedCameras.SetTexture ("_FrontTex", FrontRT);
        MergedCameras.SetTexture ("_BackTex", BackRT);
    }
开发者ID:merlinsaw,项目名称:diplom,代码行数:26,代码来源:CameraMapping.cs

示例14: CaptureCamera

    /// <summary>
    /// 对相机截图。 
    /// </summary>
    /// <returns>The screenshot2.</returns>
    /// <param name="camera">Camera.要被截屏的相机</param>
    /// <param name="rect">Rect.截屏的区域</param>
    Texture2D CaptureCamera(Camera camera, Rect rect)
    {
        // 创建一个RenderTexture对象
        Debug.Log(rect.width + " " + rect.height);
        RenderTexture rt = new RenderTexture((int)rect.width, (int)rect.height, 0);
        // 临时设置相关相机的targetTexture为rt, 并手动渲染相关相机
        camera.targetTexture = rt;
        camera.Render();
        //--- 如果这样加上第二个相机,可以实现只截图某几个指定的相机一起看到的图像。
        //camera2.targetTexture = rt;
        //camera2.Render();
        //-------------------------------------------------------------------
        // 激活这个rt, 并从中中读取像素。
        RenderTexture.active = rt;
        Texture2D screenShot = new Texture2D((int)rect.width, (int)rect.height, TextureFormat.RGB24, false);
        screenShot.ReadPixels(rect, 0, 0);// 注:这个时候,它是从RenderTexture.active中读取像素
        screenShot.Apply();

        // 重置相关参数,以使用camera继续在屏幕上显示
        camera.targetTexture = null;
        //ps: camera2.targetTexture = null;
        RenderTexture.active = null; // JC: added to avoid errors
        GameObject.Destroy(rt);
        CacheFactory.SaveToPicture(screenShot, "/ScreenShot.png",CacheFactory.PictureType.JPG);
        return screenShot;
    }
开发者ID:xiaozhuzhaoge,项目名称:QinCloudSuper,代码行数:32,代码来源:Screenshot.cs

示例15: Render4TapQuad

    // =============================================================================
    // =============================================================================
    // METHODS STATIC --------------------------------------------------------------
    private static void Render4TapQuad( RenderTexture dest, float offsetX, float offsetY )
    {
        GL.Begin( GL.QUADS );

        // Direct3D needs interesting texel offsets!
        Vector2 off = Vector2.zero;
        if( dest != null )
        {
            off = dest.GetTexelOffset()*0.75f;
        }

        Set4TexCoords( off.x, off.y, offsetX, offsetY );
        GL.Vertex3( 0f, 0f, 0.1f );

        Set4TexCoords( 1.0f + off.x, off.y, offsetX, offsetY );
        GL.Vertex3( 1f, 0f, 0.1f );

        Set4TexCoords( 1.0f + off.x, 1.0f + off.y, offsetX, offsetY );
        GL.Vertex3( 1f, 1f, 0.1f );

        Set4TexCoords( off.x, 1.0f + off.y, offsetX, offsetY );
        GL.Vertex3( 0f, 1f, 0.1f );

        GL.End();
    }
开发者ID:Jonas90,项目名称:iss,代码行数:28,代码来源:FunkyGlowingThingsEffect.cs


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