星鸿阁

 找回密码
 立即注册
搜索
热搜: 活动 交友 动画
查看: 943|回复: 0

在URP中渲染贴图(摘自官方原文)

[复制链接]

2250

主题

2760

帖子

9610

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
9610
发表于 2020-9-30 10:00:07 | 显示全部楼层 |阅读模式
Rendering to a Render Texture
In the Universal Render Pipeline (URP), a Camera can render to the screen or to a Render Texture. Rendering to a screen is the default and is the most common use case, but rendering to a Render Texture allows you to create effects such as CCTV camera monitors.
If you have a Camera that is rendering to a Render Texture, you must have a second Camera that then renders that Render Texture to the screen. In URP, all Cameras that render to Render Textures perform their render loops before all Cameras that render to the screen. This ensures that the Render Textures are ready to render to the screen. For more information on Camera rendering order in URP, see Rendering order and overdraw.
Rendering to a Render Texture, and then rendering that Render Texture to the screen
Create a Render Texture Asset in your Project using Assets > Create > Render Texture. Create a Quad in your Scene. Create a Material in your Project, and select it. In the Inspector, drag the Render Texture to the Material's Base Map field. In the Scene view, drag the Material on to the Quad. Create a Camera in your Scene. Its Render Mode defaults to Base, making it a Base Camera. Select the Base Camera. In the Inspector, scroll to the Output section. Set the Camera’s Output Target to Texture, and drag the Render Texture on to the Texture field. Create another Camera in your Scene. Its Render Mode defaults to Base, making it a Base Camera. Place the Quad within the view of the new Base Camera.
The first Camera renders its view to the Render Texture. The second Camera renders the Scene including the Render Texture to the screen.
You can set the Output Target for a Camera in a script by setting the cameraOutput property of the Camera's Universal Additional Camera Data component, like this:
myUniversalAdditionalCameraData.cameraOutput = CameraOutput.Texture;myCamera.targetTexture = myRenderTexture;
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|starfluidga

GMT+8, 2024-12-30 07:25 , Processed in 0.015386 second(s), 20 queries .

Made by Liga 星鸿阁

Copyright © 2020-2048, LigaStudio.

快速回复 返回顶部 返回列表