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


C# Camera.RenderWithShader方法代码示例

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


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

示例1: GetHitXY

	public Color32 GetHitXY(Camera targetCamera, int x, int y)
	{
		RenderTexture rTex = new RenderTexture(Screen.width, Screen.height, 24);
		Texture2D screen = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
		
		RenderTexture oldTex = targetCamera.targetTexture;
		RenderTexture oldActive = RenderTexture.active;
		Color oldBack = targetCamera.backgroundColor;
		
		targetCamera.targetTexture = rTex;
		targetCamera.backgroundColor = Color.black;
		RenderTexture.active = rTex;
		targetCamera.RenderWithShader(altShader, tagName);
		screen.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
		
		targetCamera.backgroundColor = oldBack;
		targetCamera.targetTexture = oldTex;
		RenderTexture.active = oldActive;

		Destroy(rTex);
		
		Color32 result = screen.GetPixel(x, y);
		return result;
	}
开发者ID:MedStarSiTEL,项目名称:UnityTrauma,代码行数:24,代码来源:TextureClick.cs

示例2: UpdateOcclusionCamera

    RenderTexture UpdateOcclusionCamera(Camera source, Camera target, Shader replacement)
    {
        if(target.targetTexture) {
            Debug.LogError("Didn't expect existing render texture: " + target.name);
            RenderTexture.ReleaseTemporary(target.targetTexture);
            target.targetTexture = null;
        }

        // Start by copying everything from src, but then override quite a few things.
        target.CopyFrom(source);

        var pr = source.pixelRect;
        var rt = target.targetTexture = RenderTexture.GetTemporary(
            Mathf.RoundToInt(pr.width),
            Mathf.RoundToInt(pr.height),
            Application.isPlaying ? 24 : 16, // this avoids a bug that corrupts scene view depth
            RenderTextureFormat.ARGB2101010
        );

        target.renderingPath = RenderingPath.Forward;
        target.depthTextureMode = DepthTextureMode.None;
        target.clearFlags = CameraClearFlags.SolidColor;
        target.backgroundColor = Color.white;
        target.useOcclusionCulling = false;
        target.cullingMask = cullingMask;
        target.farClipPlane = maxDistance + 5f;

        target.RenderWithShader(replacement, "Special");

        return rt;
    }
开发者ID:CG-F15-6-Rutgers,项目名称:UnityProjects,代码行数:31,代码来源:WrinkleMapsDriver.cs

示例3: RenderReflectionFor

    private void RenderReflectionFor(Camera cam, Camera reflectCamera)
    {
        if(!reflectCamera)
            return;

        SaneCameraSettings(reflectCamera);

        reflectCamera.backgroundColor = clearColor;

        GL.SetRevertBackfacing(true);

        Transform reflectiveSurface = reflectiveSurfaceHeight;

        Vector3 eulerA = cam.transform.eulerAngles;

        reflectCamera.transform.eulerAngles = new Vector3(-eulerA.x, eulerA.y, eulerA.z);
        reflectCamera.transform.position = cam.transform.position;

        Vector3 pos = reflectiveSurface.transform.position;
        pos.y = reflectiveSurface.position.y;
        Vector3 normal = reflectiveSurface.transform.up;
        float d = -Vector3.Dot(normal, pos) - clipPlaneOffset;
        Vector4 reflectionPlane = new Vector4(normal.x, normal.y, normal.z, d);

        Matrix4x4 reflection = Matrix4x4.zero;
        reflection = CalculateReflectionMatrix(reflection, reflectionPlane);
        oldpos = cam.transform.position;
        Vector3 newpos = reflection.MultiplyPoint (oldpos);

        reflectCamera.worldToCameraMatrix = cam.worldToCameraMatrix * reflection;

        Vector4 clipPlane = CameraSpacePlane(reflectCamera, pos, normal, 1.0f);

        Matrix4x4 projection =  cam.projectionMatrix;
        projection = CalculateObliqueMatrix(projection, clipPlane);
        reflectCamera.projectionMatrix = projection;

        reflectCamera.transform.position = newpos;
        Vector3 euler = cam.transform.eulerAngles;
        reflectCamera.transform.eulerAngles = new Vector3(-euler.x, euler.y, euler.z);

        reflectCamera.RenderWithShader (replacementShader, "Reflection");

        GL.SetRevertBackfacing(false);
    }
开发者ID:foolhead,项目名称:E01_CASA,代码行数:45,代码来源:Floor_ReflectionScriptCamera.cs


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