本文整理汇总了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;
}
示例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;
}
示例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);
}