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


C# RenderTexture.Create方法代码示例

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


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

示例1: OnRenderImage

 // Called after all rendering is complete to render image. Postprocessing effects.
 protected void OnRenderImage(RenderTexture sourceTexture, RenderTexture destTexture)
 {
     RenderTexture tex1 = new RenderTexture(Screen.width, Screen.height, 24, RenderTextureFormat.ARGB32);
     tex1.Create();
     Graphics.Blit(sourceTexture, tex1, Mat1);
     Graphics.Blit(tex1, destTexture);
 }
开发者ID:ellioman,项目名称:ShaderProject,代码行数:8,代码来源:RenderPasses.cs

示例2: CactEyeCamera

        /*
         * Constructor
         * Input: The owning part's transform.
         * Purpose: This constructor will start up the owning part's camera object. The idea behind this
         * was to allow for multiple telescopes on the same craft.
         */
        public CactEyeCamera(Transform Position)
        {
            this.CameraTransform = Position;

            CameraWidth = (int)(Screen.width*0.4f);
            CameraHeight = (int)(Screen.height*0.4f);

            ScopeRenderTexture = new RenderTexture(CameraWidth, CameraHeight, 24);
            ScopeRenderTexture.Create();

            FullResolutionTexture = new RenderTexture(Screen.width, Screen.height, 24);
            FullResolutionTexture.Create();

            ScopeTexture2D = new Texture2D(CameraWidth, CameraHeight);
            FullTexture2D = new Texture2D(Screen.width, Screen.height);

            CameraSetup(0, "GalaxyCamera"); //As of KSP 1.0, the GalaxyCamera object was added. Thanks to MOARDv for figuring this one out.
            CameraSetup(1, "Camera ScaledSpace");
            CameraSetup(2, "Camera 01");
            CameraSetup(3, "Camera 00");
            CameraSetup(4, "Camera VE Underlay");
            CameraSetup(5, "Camera VE Overlay");

            skyboxRenderers = (from Renderer r in (FindObjectsOfType(typeof(Renderer)) as IEnumerable<Renderer>) where (r.name == "XP" || r.name == "XN" || r.name == "YP" || r.name == "YN" || r.name == "ZP" || r.name == "ZN") select r).ToArray<Renderer>();
            if (skyboxRenderers == null)
            {
                Debug.Log("CactEye 2: Logical Error: skyboxRenderers is null!");
            }

            scaledSpaceFaders = FindObjectsOfType(typeof(ScaledSpaceFader)) as ScaledSpaceFader[];
            if (scaledSpaceFaders == null)
            {
                Debug.Log("CactEye 2: Logical Error: scaledSpaceFaders is null!");
            }
        }
开发者ID:belug23,项目名称:CactEye-2,代码行数:41,代码来源:CactEyeCamera.cs

示例3: Start

	// Use this for initialization
	void Start ()
	{		
//		storedScreenWidth = Screen.width;
//		storedScreenHeight = Screen.height;
//		myRT = new RenderTexture(Screen.width, Screen.height, 24);
		
		storedScreenWidth = 1024;
		storedScreenHeight = 1024;
		myRT = new RenderTexture(1024, 1024, 24);
		
		myRT.format = RenderTextureFormat.ARGB32;
		myRT.filterMode = FilterMode.Point;
		myRT.isPowerOfTwo = false;
		myRT.isCubemap = false;
		myRT.Create();
		
		mat = new Material (
		"Shader \"Hidden/Invert\" {" +
		"SubShader {" +
		" Pass {" +
		" ZTest Always Cull Off ZWrite Off" +
		" SetTexture [_RenderTexy] { combine texture }" +
		" }" +
		"}" +
		"}"
		);
	}
开发者ID:ly774508966,项目名称:Light-Harvest-Unity3D,代码行数:28,代码来源:SyphonServerBridge.cs

示例4: CreateRendTexture

    public void CreateRendTexture(GameObject item)
    {
        RenderTexture rendTexture = new RenderTexture(256, 256, 16);
        rendTexture.Create();
        GameObject rendCamera = Instantiate(Resources.Load("InventoryCam")) as GameObject;
        rendCamera.transform.parent = position.transform;
        if(nextPos != null)
            rendCamera.transform.position = new Vector3(nextPos.transform.position.x+10f, nextPos.transform.position.y,
                                                        nextPos.transform.position.z);
        else
            rendCamera.transform.position = new Vector3(position.transform.position.x+10f, position.transform.position.y,
                                                  	  position.transform.position.z);

        nextPos = rendCamera;
        GameObject itemClone = Instantiate(item) as GameObject;
        itemClone.transform.parent = nextPos.transform;
        itemClone.transform.position = new Vector3(nextPos.transform.position.x, nextPos.transform.position.y,
                                              nextPos.transform.position.z+0.5f);

        itemClone.transform.rotation = new Quaternion(itemClone.transform.rotation.x, itemClone.transform.rotation.y,
                                                      itemClone.transform.rotation.z, itemClone.transform.rotation.w);

        itemClone.GetComponent<Renderer>().enabled = true;
        rendCamera.GetComponent<Camera>().targetTexture = rendTexture;
        GameObject inventoryImage = new GameObject();
        rendTexture.name = item.name+"texture";
        inventoryImage.name = item.name;
        itemClone.layer = 8;
        inventoryImage.transform.parent = canvasPos.transform;
        inventoryImage.AddComponent<RawImage>();
        inventoryImage.GetComponent<RawImage>().texture = rendTexture;
        itemClick.ItemClick (inventoryImage, true);
        itemClick.ItemClick (itemClone, false);
        rendTextCameras.Add(rendCamera.GetComponent<Camera>());
    }
开发者ID:WaterKH,项目名称:FrankensteinVendetta,代码行数:35,代码来源:RenderTextureScript.cs

示例5: Update

    void Update()
    {
        if (m_maincamera == null) m_maincamera = Camera.main;
        if (m_maincamera == null) return;

        Camera cam = GetComponent<Camera>();
        if(m_rt==null || m_resolution_scale!=m_resolution_scale_prev)
        {
            if (m_resolution_scale.x == 0.0f || m_resolution_scale.y==0.0f)
            {
                return;
            }

            m_resolution_scale_prev = m_resolution_scale;
            if(m_rt!=null)
            {
                m_rt.Release();
                m_rt = null;
            }
            m_rt = new RenderTexture(
                (int)(cam.pixelWidth * m_resolution_scale.x),
                (int)(cam.pixelHeight * m_resolution_scale.y),
                32,
                m_maincamera.hdr ? RenderTextureFormat.ARGBHalf : RenderTextureFormat.ARGB32);
            m_rt.filterMode = FilterMode.Trilinear;
            m_rt.Create();
            m_maincamera.targetTexture = m_rt;
            Debug.Log("resolution changed: " + m_rt.width + ", " + m_rt.height);
        }
    }
开发者ID:MrJoy,项目名称:RaymarchingOnUnity5,代码行数:30,代码来源:ResolutionScaler.cs

示例6: createOrResizeRenderTexture

	public void createOrResizeRenderTexture(){
		if(!testCameraExists()){
			return;
		}

		//if the render texture exists already, release it, and resize it.
		if(customRenderTexture != null){
				RenderTexture.active = null;
				customRenderTexture.Release();
				customRenderTexture.width = renderWidth;
				customRenderTexture.height = renderHeight;
				RenderTexture.active = customRenderTexture;
				GL.Clear(false, true, new Color(0, 0, 0, 0));
		}
		customRenderTexture = new RenderTexture(renderWidth, renderHeight, 0, RenderTextureFormat.ARGB32);
		customRenderTexture.filterMode = FilterMode.Point;
		customRenderTexture.Create();
		Syphon.SafeMaterial.SetPass(0);
		RenderTexture.active = customRenderTexture;
		GL.Clear(false, true, new Color(0, 0, 0, 0));
		RenderTexture.active = null;


		cameraInstance.targetTexture = customRenderTexture;


	}
开发者ID:ly774508966,项目名称:Kinect-Puppets-Unity,代码行数:27,代码来源:SyphonServerTextureCustomResolution.cs

示例7: Start

    // Use this for initialization
    void Start () {

        destTexture = new RenderTexture( srcTexture.width, srcTexture.height, 0, RenderTextureFormat.ARGB32 );
        destTexture.enableRandomWrite = true;
        destTexture.Create();

    }
开发者ID:Mymicky,项目名称:Unity5ComputeShaderTest,代码行数:8,代码来源:EdgeDetection.cs

示例8: Start

	void Start () 
	{
		mouseLook = GetComponent<MouseLook>();
		
		textureUI = new RenderTexture((int)Screen.width, (int)Screen.height, 24, RenderTextureFormat.ARGB32);
		textureUI.Create();
		cameraUI.targetTexture = textureUI;
		Shader.SetGlobalTexture("_UITexture", textureUI);

		textureNextPanorama = new RenderTexture((int)Screen.width, (int)Screen.height, 24, RenderTextureFormat.ARGB32);
		textureNextPanorama.Create();
		cameraNextPanorama.targetTexture = textureNextPanorama;
		Shader.SetGlobalTexture("_PanoramaNextTexture", textureNextPanorama);
		
		textureNone = new Texture2D(1, 1);
		textureNone.SetPixel(0, 0, new Color(1,0,0,0));
    textureNone.Apply();

		cursorRender = GetComponentInChildren<Renderer>();
		cursorRender.material.mainTexture = textureNone;

		Gate[] gateArray = GameObject.FindObjectsOfType<Gate>();
		List<Vector3> positionList = new List<Vector3>();
		for (int i = 0; i < gateArray.Length; ++i) {
			Gate gate = gateArray[i];
			if (gate.anotherGate != null && gate.transitionType == Gate.TransitionType.Fade) {
				positionList.Add(gate.transform.position);
			}
		}
		Vector3[] positionArray = positionList.ToArray();
		GameObject.FindObjectOfType<ParticleCloud>().SetPositionArray(positionArray);
	}
开发者ID:leon196,项目名称:TributeToMyst,代码行数:32,代码来源:Interface.cs

示例9: ResetRenderTexture

    public void ResetRenderTexture()
    {
        if (renderTexture != null)
            renderTexture.DiscardContents();

        renderTexture = new RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default);

        renderTexture.generateMips = false;
        renderTexture.useMipMap = false;
        renderTexture.wrapMode = TextureWrapMode.Clamp;
        //renderTexture.antiAliasing = 1;
        renderTexture.filterMode = FilterMode.Point;
        renderTexture.Create();

        //Graphics.SetRenderTarget (renderTexture);
        //GL.Clear (true, true, Color.clear);
        // XXX: Workaround unity issue, without this trick CameraClearFlags.Nothing won't work.
        renderTextureCamera.clearFlags = CameraClearFlags.SolidColor;
        renderTextureCamera.targetTexture = renderTexture;
        renderTextureCamera.Render();
        renderTextureCamera.clearFlags = CameraClearFlags.Nothing;
        renderTextureCamera.enabled = false;

        backgroundObject.GetComponent<MeshRenderer>().material.mainTexture = renderTexture;
    }
开发者ID:gorecode,项目名称:they-will-burn,代码行数:25,代码来源:SlaughterBackground.cs

示例10: Start

    IEnumerator Start () 
    {
        //disable Eraser on start
        isEraser=0;

        //Intialise brush size on start
        erasersize=pencilsize=currSize=2;

        //Intitalise brush color
        currColor = Color.red;

        //Initialise three points list
        three_point = new List<Vector3>();

        colorCircleRect = new Rect(Screen.width - 230f, Screen.height - 200f, 230f, 200f);
        UIRect = new Rect(0f, Screen.height - 100f,400f, 100f);
      //  GL.Clear(false, true, new Color(0.0f, 0.0f, 0.0f, 0.0f));
        //Create render texture and asssign it to camera..
        Cam.targetTexture = null;
      
        rt =new  RenderTexture(Screen.width, Screen.height, 0, RenderTextureFormat.Default);
      
        yield return rt.Create();
		Debug.Log((int)img.rectTransform.sizeDelta.x);
        Texture2D t = new Texture2D((int)img.rectTransform.sizeDelta.x, (int)img.rectTransform.sizeDelta.y);
        Graphics.Blit(t, rt);
        img.sprite = Sprite.Create(t, new Rect(Vector2.zero, new Vector2(t.width,t.height)), Vector2.one/2);
        yield return 0;
        Cam.targetTexture = rt;
        mCurr = CreatePlaneMesh(currSize *0.12f);
       // antialising.enabled = true;
        //bg.SetActive(false);
    }
开发者ID:Blueteak,项目名称:GGJ2016,代码行数:33,代码来源:drawing.cs

示例11: 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

示例12: GenerateToTexture

        /// <summary>
        /// Generates a texture containing the given graph's noise output.
        /// If this is being called very often, create a permanent render target and material and
        ///     use the other version of this method instead for much better performance.
        /// If an error occurred, outputs to the Unity debug console and returns "null".
        /// </summary>
        /// <param name="outputComponents">
        /// The texture output.
        /// For example, pass "rgb" or "xyz" to output the noise into the red, green, and blue channels
        ///     but not the alpha channel.
        /// </param>
        /// <param name="defaultColor">
        /// The color (generally 0-1) of the color components which aren't set by the noise.
        /// </param>
        public static Texture2D GenerateToTexture(Graph g, GraphParamCollection c, int width, int height,
												  string outputComponents, float defaultColor,
												  TextureFormat format = TextureFormat.RGBAFloat)
        {
            //Generate a shader from the graph and have Unity compile it.
            string shaderPath = Path.Combine(Application.dataPath, "gpuNoiseShaderTemp.shader");
            Shader shader = SaveShader(g, shaderPath, "TempGPUNoiseShader", outputComponents, defaultColor);
            if (shader == null)
            {
                return null;
            }

            //Render the shader's output into a render texture and copy the data to a Texture2D.
            RenderTexture target = new RenderTexture(width, height, 16, RenderTextureFormat.ARGBFloat);
            target.Create();
            Texture2D resultTex = new Texture2D(width, height, format, false, true);

            //Create the material and set its parameters.
            Material mat = new Material(shader);
            c.SetParams(mat);

            GraphUtils.GenerateToTexture(target, mat, resultTex);

            //Clean up.
            target.Release();
            if (!AssetDatabase.DeleteAsset(StringUtils.GetRelativePath(shaderPath, "Assets")))
            {
                Debug.LogError("Unable to delete temp file: " + shaderPath);
            }

            return resultTex;
        }
开发者ID:heyx3,项目名称:GPUNoiseForUnity,代码行数:46,代码来源:GraphEditorUtils.cs

示例13: UpdateReflection

    void UpdateReflection()
    {
        if(!rtex)
        {
            rtex = new RenderTexture(textureSize, textureSize, 16);
            rtex.hideFlags = HideFlags.HideAndDontSave;
            rtex.isPowerOfTwo = true;
            rtex.isCubemap = true;
            rtex.useMipMap = false;
            rtex.Create();

            reflectingMaterial.SetTexture("_Cube", rtex);
        }

        if(!cam)
        {
            GameObject go = new GameObject("CubemapCamera", typeof(Camera));
            go.hideFlags = HideFlags.HideAndDontSave;
            cam = go.camera;
            // cam.nearClipPlane = 0.05f;
            cam.farClipPlane = 150f;
            cam.enabled = false;
            cam.cullingMask = mask;
        }

        cam.transform.position = Camera.main.transform.position;
        cam.transform.rotation = Camera.main.transform.rotation;

        cam.RenderToCubemap(rtex, 63);
    }
开发者ID:hyakugei,项目名称:CarRacingGame,代码行数:30,代码来源:Generate2DReflection.cs

示例14: Start

 void Start()
 {
     buffer = new RenderTexture(Screen.width, Screen.height, 24, RenderTextureFormat.ARGB32);
     buffer.antiAliasing = 2;
     buffer.Create();
     GetComponent<Camera>().targetTexture = buffer;
     Shader.SetGlobalTexture(textureName, buffer);
 }
开发者ID:leon196,项目名称:UnityVJ,代码行数:8,代码来源:CameraToTexture.cs

示例15: Start

    void Start()
    {
        frame = new NPFrame2("Stuff", 3);

        donePow2 = new RenderTexture(Screen.width, Screen.height, 0, frame.GetTextureFormat, RenderTextureReadWrite.Linear);
        donePow2.enableRandomWrite = true;
        donePow2.Create();
    }
开发者ID:miberen,项目名称:P7-VGIS,代码行数:8,代码来源:HistEq.cs


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