为哪个相机绘制
画之前的摄像机参数的设置
画之前的pass的设置
画之前的shader用到的变量设置
画在哪里
画之后干什么

画之前的摄像机参数的设置

1.4 configuring the view and projection matrices
the idea is that we render from the point of view of the light source, which means that we are using the spotlight as if it were a camera.
thus, we have to provide appropriate view and projection matrices.
https://catlikecoding.com/unity/tutorials/scriptable-render-pipeline/spotlight-shadows/

once we have the matrices, set them up by invoking SetViewProjectionMatrices on the shadow command buffer, execute it, and clear it.

shader中也要设置:


SetupCameraProperties
https://catlikecoding.com/unity/tutorials/scriptable-render-pipeline/custom-pipeline/

note that the orientation of the camera currently does not affect how the skybox gets rendered.
we pass the camera to DrawSkybox, but that is only used to determine whether the skybox should be drawn at all,
which is controlled via the camera clear flags.

to correctly render the skybox——and the entire scene——we have to setup the view-projection matrix.
this transformation matrix combines the camera’s position and orientation——the view matrix——with the camera’s perspective or orthographic projection——the projection matrix.
u can see this matrix in the frame debugger. it is unity_MatrixVP,
one of the shader properties used when something is drawn.

at the moment, the unity_MatrixVP matrix is always the same.
we have to apply the camera’s properties to the context, via the SetupCameraProperties method.
that sets up the matrix as well as some other properties.

画之前的pass的设置


如果需要天空盒,clearFlags,type,以及RenderSettings中有天空盒,才进行pass压入。

执行:

对多个pass进行排序:





画之前的shader用到的变量设置


画在哪里

void SetRenderPassAttachments(CommandBuffer cmd, ScriptableRenderPass renderPass, ref CameraData cameraData, ref bool firstTimeStereo){Camera camera = cameraData.camera;ClearFlag cameraClearFlag = GetCameraClearFlag(ref cameraData);// Invalid configuration - use current attachment setup// Note: we only check color buffers. This is only technically correct because for shadowmaps and depth only passes// we bind depth as color and Unity handles it underneath. so we never have a situation that all color buffers are null and depth is bound.uint validColorBuffersCount = RenderingUtils.GetValidColorBufferCount(renderPass.colorAttachments);if (validColorBuffersCount == 0)return;// We use a different code path for MRT since it calls a different version of API SetRenderTargetif (RenderingUtils.IsMRT(renderPass.colorAttachments)){// In the MRT path we assume that all color attachments are REAL color attachments,// and that the depth attachment is a REAL depth attachment too.// Determine what attachments need to be cleared. ----------------bool needCustomCameraColorClear = false;bool needCustomCameraDepthClear = false;int cameraColorTargetIndex = RenderingUtils.IndexOf(renderPass.colorAttachments, m_CameraColorTarget);if (cameraColorTargetIndex != -1 && (m_FirstTimeCameraColorTargetIsBound || (cameraData.isXRMultipass && m_XRRenderTargetNeedsClear) )){m_FirstTimeCameraColorTargetIsBound = false; // register that we did clear the camera target the first time it was boundfirstTimeStereo = true;// Overlay cameras composite on top of previous ones. They don't clear.// MTT: Commented due to not implemented yet//                    if (renderingData.cameraData.renderType == CameraRenderType.Overlay)//                        clearFlag = ClearFlag.None;// We need to specifically clear the camera color target.// But there is still a chance we don't need to issue individual clear() on each render-targets if they all have the same clear parameters.needCustomCameraColorClear = (cameraClearFlag & ClearFlag.Color) != (renderPass.clearFlag & ClearFlag.Color)|| CoreUtils.ConvertSRGBToActiveColorSpace(camera.backgroundColor) != renderPass.clearColor;if(cameraData.isXRMultipass && m_XRRenderTargetNeedsClear)// For multipass mode, if m_XRRenderTargetNeedsClear == true, then both color and depth buffer need clearing (not just color)needCustomCameraDepthClear = (cameraClearFlag & ClearFlag.Depth) != (renderPass.clearFlag & ClearFlag.Depth);m_XRRenderTargetNeedsClear = false; // register that the XR camera multi-pass target does not need clear any more (until next call to BeginXRRendering)}// Note: if we have to give up the assumption that no depthTarget can be included in the MRT colorAttachments, we might need something like this:// int cameraTargetDepthIndex = IndexOf(renderPass.colorAttachments, m_CameraDepthTarget);// if( !renderTargetAlreadySet && cameraTargetDepthIndex != -1 && m_FirstTimeCameraDepthTargetIsBound)// { ...// }if (renderPass.depthAttachment == m_CameraDepthTarget && m_FirstTimeCameraDepthTargetIsBound)// note: should be split m_XRRenderTargetNeedsClear into m_XRColorTargetNeedsClear and m_XRDepthTargetNeedsClear and use m_XRDepthTargetNeedsClear here?{m_FirstTimeCameraDepthTargetIsBound = false;//firstTimeStereo = true; // <- we do not call this here as the first render pass might be a shadow pass (non-stereo)needCustomCameraDepthClear = (cameraClearFlag & ClearFlag.Depth) != (renderPass.clearFlag & ClearFlag.Depth);//m_XRRenderTargetNeedsClear = false; // note: is it possible that XR camera multi-pass target gets clear first when bound as depth target?//       in this case we might need need to register that it does not need clear any more (until next call to BeginXRRendering)}// Perform all clear operations needed. ----------------// We try to minimize calls to SetRenderTarget().// We get here only if cameraColorTarget needs to be handled separately from the rest of the color attachments.if (needCustomCameraColorClear){// Clear camera color render-target separately from the rest of the render-targets.if ((cameraClearFlag & ClearFlag.Color) != 0)SetRenderTarget(cmd, renderPass.colorAttachments[cameraColorTargetIndex], renderPass.depthAttachment, ClearFlag.Color, CoreUtils.ConvertSRGBToActiveColorSpace(camera.backgroundColor));if ((renderPass.clearFlag & ClearFlag.Color) != 0){uint otherTargetsCount = RenderingUtils.CountDistinct(renderPass.colorAttachments, m_CameraColorTarget);var nonCameraAttachments = m_TrimmedColorAttachmentCopies[otherTargetsCount];int writeIndex = 0;for (int readIndex = 0; readIndex < renderPass.colorAttachments.Length; ++readIndex){if (renderPass.colorAttachments[readIndex] != m_CameraColorTarget && renderPass.colorAttachments[readIndex] != 0){nonCameraAttachments[writeIndex] = renderPass.colorAttachments[readIndex];++writeIndex;}}if (writeIndex != otherTargetsCount)Debug.LogError("writeIndex and otherTargetsCount values differed. writeIndex:" + writeIndex + " otherTargetsCount:" + otherTargetsCount);SetRenderTarget(cmd, nonCameraAttachments, m_CameraDepthTarget, ClearFlag.Color, renderPass.clearColor);}}// Bind all attachments, clear color only if there was no custom behaviour for cameraColorTarget, clear depth as needed.ClearFlag finalClearFlag = ClearFlag.None;finalClearFlag |= needCustomCameraDepthClear ? (cameraClearFlag & ClearFlag.Depth) : (renderPass.clearFlag & ClearFlag.Depth);finalClearFlag |= needCustomCameraColorClear ? 0 : (renderPass.clearFlag & ClearFlag.Color);// Only setup render target if current render pass attachments are different from the active ones.if (!RenderingUtils.SequenceEqual(renderPass.colorAttachments, m_ActiveColorAttachments) || renderPass.depthAttachment != m_ActiveDepthAttachment || finalClearFlag != ClearFlag.None){int lastValidRTindex = RenderingUtils.LastValid(renderPass.colorAttachments);if (lastValidRTindex >= 0){int rtCount = lastValidRTindex + 1;var trimmedAttachments = m_TrimmedColorAttachmentCopies[rtCount];for (int i = 0; i < rtCount; ++i)trimmedAttachments[i] = renderPass.colorAttachments[i];SetRenderTarget(cmd, trimmedAttachments, renderPass.depthAttachment, finalClearFlag, renderPass.clearColor);}}}else{// Currently in non-MRT case, color attachment can actually be a depth attachment.RenderTargetIdentifier passColorAttachment = renderPass.colorAttachment;RenderTargetIdentifier passDepthAttachment = renderPass.depthAttachment;// When render pass doesn't call ConfigureTarget we assume it's expected to render to camera target// which might be backbuffer or the framebuffer render textures.if (!renderPass.overrideCameraTarget){// Default render pass attachment for passes before main rendering is current active// early return so we don't change current render target setup.if (renderPass.renderPassEvent < RenderPassEvent.BeforeRenderingOpaques)return;passColorAttachment = m_CameraColorTarget;passDepthAttachment = m_CameraDepthTarget;}ClearFlag finalClearFlag = ClearFlag.None;Color finalClearColor;if (passColorAttachment == m_CameraColorTarget && (m_FirstTimeCameraColorTargetIsBound || (cameraData.isXRMultipass && m_XRRenderTargetNeedsClear))){m_FirstTimeCameraColorTargetIsBound = false; // register that we did clear the camera target the first time it was boundfinalClearFlag |= (cameraClearFlag & ClearFlag.Color);finalClearColor = CoreUtils.ConvertSRGBToActiveColorSpace(camera.backgroundColor);firstTimeStereo = true;if (m_FirstTimeCameraDepthTargetIsBound || (cameraData.isXRMultipass && m_XRRenderTargetNeedsClear)){// m_CameraColorTarget can be an opaque pointer to a RenderTexture with depth-surface.// We cannot infer this information here, so we must assume both camera color and depth are first-time bound here (this is the legacy behaviour).m_FirstTimeCameraDepthTargetIsBound = false;finalClearFlag |= (cameraClearFlag & ClearFlag.Depth);}m_XRRenderTargetNeedsClear = false; // register that the XR camera multi-pass target does not need clear any more (until next call to BeginXRRendering)}else{finalClearFlag |= (renderPass.clearFlag & ClearFlag.Color);finalClearColor = renderPass.clearColor;}// Condition (m_CameraDepthTarget!=BuiltinRenderTextureType.CameraTarget) below prevents m_FirstTimeCameraDepthTargetIsBound flag from being reset during non-camera passes (such as Color Grading LUT). This ensures that in those cases, cameraDepth will actually be cleared during the later camera pass.if (   (m_CameraDepthTarget!=BuiltinRenderTextureType.CameraTarget ) && (passDepthAttachment == m_CameraDepthTarget || passColorAttachment == m_CameraDepthTarget) && m_FirstTimeCameraDepthTargetIsBound )// note: should be split m_XRRenderTargetNeedsClear into m_XRColorTargetNeedsClear and m_XRDepthTargetNeedsClear and use m_XRDepthTargetNeedsClear here?{m_FirstTimeCameraDepthTargetIsBound = false;finalClearFlag |= (cameraClearFlag & ClearFlag.Depth);//firstTimeStereo = true; // <- we do not call this here as the first render pass might be a shadow pass (non-stereo)// finalClearFlag |= (cameraClearFlag & ClearFlag.Color);  // <- m_CameraDepthTarget is never a color-surface, so no need to add this here.//m_XRRenderTargetNeedsClear = false; // note: is it possible that XR camera multi-pass target gets clear first when bound as depth target?//       in this case we might need need to register that it does not need clear any more (until next call to BeginXRRendering)}elsefinalClearFlag |= (renderPass.clearFlag & ClearFlag.Depth);// Only setup render target if current render pass attachments are different from the active onesif (passColorAttachment != m_ActiveColorAttachments[0] || passDepthAttachment != m_ActiveDepthAttachment || finalClearFlag != ClearFlag.None)SetRenderTarget(cmd, passColorAttachment, passDepthAttachment, finalClearFlag, finalClearColor);}}


URP中摄像机参数的设置相关推荐

  1. [Oracle][Standby][PDB]在PDB中修改参数,设置范围为 SPFILE,报 ORA-65099错误

    [Oracle][Standby][PDB]在PDB中修改参数,设置范围为 SPFILE,报 ORA-65099错误 在Data Gaurd 的 Standby (或 CDB 是 Read Only ...

  2. allegro标注尺寸设置_Allegro中尺寸标注参数的设置-EDA/PCB-与非网

    Allegro中尺寸标注有很强大的功能,包括线性标注,角度标注,引线标注等.下面介绍一下Allegro中尺寸标注参数的设置.执行Manufacture– Dimension/Draft– Parame ...

  3. python opencv 摄像头_opencv python中摄像头参数的设置

    我正在使用Windows7 64位操作系统以及Python3和OpenCV.我的电脑连接到以下型号的两个罗技网络摄像头: 1)罗技高清网络摄像头C615 2) 罗技QuickCam Pro 9000 ...

  4. 3DSMax怎么设置摄像机参数_3DSMax设置摄像机参数 小白教程

    3DMax是一款制作建模与动画制作软件,也可以进行动画的制作,但是需要借助摄机的帮助,那3DSMax怎么设置摄像机参数呢?下面小编给大家详细的介绍一下吧 3DSMax怎么设置摄像机参数?有很多小伙伴不 ...

  5. JM、H.264中一些参数的设置和含义

    一·参数说明  这一节阐述的是encoder.cfg 中的参数对编码过程的影响  要注意的是encoder.cfg 中的参数跟input 结构体中的变量是一一对应的 StartFrame:从视频流的第 ...

  6. Simulink中传递函数transfer fcn中迟滞参数如何设置

    小编希望借助simulink中的transfer fcn传递函数对突变的信号进行平滑的处理,后来发现对于transfer fcn中分母上的一个参数直接相关,模型如下: 然后模型采用定步长运行,运行步长 ...

  7. matplotlib中cmap与color参数的设置

    颜色的三种模式 连续型 sequential, 颜色渐变,可以用于定量数据从低到高的变化 极端型Diverging,生成深色强调两端.浅色表示中部的颜色,可用来标注数据中的离群点. 离散型Qualit ...

  8. unittest---unittest中verbosity参数设置

    我们在做自动化测试的时候,有时候想要很清楚的看到每条用例执行的详细信息,我们可以通过unittest中verbosity参数进行设置 verbosity参数设置 verbosity表示在只执行用例的过 ...

  9. c语言控制迭代次数,LR中的迭代次数设置

    在参数化时,对于一次压力测试中均只能用一次的资源应该怎么参数化呢?就是说这些资源用了一次就不能在用了的. --参数化时,在select  next row选择unique,update value o ...

最新文章

  1. Python time 100 天以后的日期
  2. Android 打造自己的个性化应用(四):仿墨迹天气实现--自定义扩展名的zip格式的皮肤...
  3. oracle复制sequence,oracle sequence语句重置方介绍
  4. 【Apache POI】Java 读取Excel文件
  5. service sshd start启动失败,Badly formatted port number.
  6. IOS 支付宝支付开发流程
  7. 基础矩阵,本质矩阵,单应性矩阵讲解,在ORB-SLAM相机的位姿初始化的应用
  8. 丢失Android系统库或者Conversion to Dalvik format failed with error 1错误的解决
  9. 信道编码:编码FEC 前向纠错码
  10. EMD EEMD CEEMD CEEMDAN IEEMDAN 附赠EEMD代码
  11. Latex 公式左对齐
  12. 爬虫pyquery查找节点
  13. 内存卡损坏怎么修复?分享实际经验
  14. ELO(埃洛匹配分制度)Java篇
  15. 反驳生命的起点是rna_生命起源学说或将被改写?“天外来客”陨石给科学家带来新发现!...
  16. java 程序员 基石
  17. 许家印马不停蹄 恒大造车提速
  18. 公司将软件测试外包已成普遍现象?
  19. 【Maven实战技巧】「插件使用专题」Maven-Archetype插件创建自定义maven项目骨架
  20. 6-6 实验6_9_素数分解 (100分)

热门文章

  1. Excel技能树系列01:电子表格发展史
  2. 为甚TCP的3次握手不是2次握手(思考实验)
  3. East!模拟赛 Round 1 题目,题解在上三篇博客。
  4. VB 任意随机数(N-M)的通用函数(单取、多取存入数组、排序等功能) 内附随机数介绍
  5. win10系统下修改pdf文件默认阅读器
  6. java8 日期范围内 日/周/月/季度/年 的日期结果集
  7. Nvidia发布基于插值光栅化的微分渲染器(DIB-R)生成3D对象模型
  8. Latex插入灰白相间的跨页长表格
  9. PS之调色技巧,正面负冲技巧
  10. android 未root手机获取应用的sqlite数据库