当前位置:网站首页>Drawing method using GL under URP
Drawing method using GL under URP
2022-07-28 15:14:00 【ttod】
First, in the URP Next ,OnPostRender Will not be executed automatically . If you want to implement , Add code similar to the following :
void OnEnable()
{
RenderPipelineManager.endCameraRendering += EndCameraRendering;
}
void OnDisable()
{
RenderPipelineManager.endCameraRendering -= EndCameraRendering;
}
void EndCameraRendering(ScriptableRenderContext context, Camera camera)
{
OnPostRender();
}
void OnPostRender()
{
// Draw code
}But in that case , It seems that the method doesn't need to be called OnPostRender, And the script does not need to be hung with Camera Component's GameObject On . The thing to note is that , This OnPostRender Will be in all Camera It works , If you need to use a specific Camera Drawing , Should be right EndCameraRendering Provided in the method Camera Parameters to judge , Look at this Camera Is it the camera you want to use . Similar to the following :
void EndCameraRendering(ScriptableRenderContext context, Camera camera)
{
if (camera == camMain) SceneHeightRender();
if (camera == camUI) UIHeightRender();
}First, let's take a look at the writing reference of two-dimensional drawing lines :
void UIHeightRender()
{
if (!mat) return;
if (heights == null || heights.Length < 2) return;
mat.SetColor("_Color", colorCurve);
mat.SetPass(0);
GL.PushMatrix();
GL.LoadOrtho();
GL.Begin(GL.LINE_STRIP);
for (int i = 0; i < heights.Length; i++)
{
GL.Vertex3(wUnit * (i + 10), heights[i] * hUnit * multi, 0);
}
GL.End();
GL.PopMatrix();
}Let's take another look at the writing reference of 3D rendering :
void SceneHeightRender()
{
if (!mat) return;
if (monitoringPoints == null || monitoringPoints.Length < 2) return;
GL.PushMatrix();
GL.MultMatrix(Matrix4x4.TRS(Vector3.zero, Quaternion.identity, Vector3.one));
mat.SetColor("_Color",colorSegment);
mat.SetPass(0);
foreach (MonitoringPoint monitoringPoint in monitoringPoints)
{
GL.Begin(GL.LINES);
GL.Vertex(monitoringPoint.position);
GL.Vertex(monitoringPoint.position + Vector3.up * monitoringPoint.height);
GL.End();
}
mat.SetColor("_Color", colorBase);
mat.SetPass(0);
GL.Begin(GL.LINE_STRIP);
foreach (MonitoringPoint monitoringPoint in monitoringPoints)
{
GL.Vertex(monitoringPoint.position);
}
GL.End();
if (tops == null || tops.Length < 2) return;
mat.SetColor("_Color", colorCurve);
mat.SetPass(0);
GL.Begin(GL.LINE_STRIP);
foreach (Vector3 top in tops)
{
GL.Vertex(top);
}
GL.End();
GL.PopMatrix();
} There is a main point to pay attention to , Namely
mat.SetColor("_Color", color);
mat.SetPass(0);
The execution order of these two methods should not be reversed , Otherwise, the drawing color may be wrong .
That's it :)
边栏推荐
猜你喜欢

7/13(水塘抽样)

Talk about low code / zero code tools

模板注入总结

Hard disk partition method

MLX90640 红外热成像仪传感器模块开发笔记(八)

Untitled may

苹果iPhone手机APP应用图标隐藏怎么找回恢复显示在iPhone苹果手机桌面显示被隐藏的应用APP图标到iPhone苹果手机桌面?

DataTables warning: table id=campaignTable - Cannot reinitialise DataTable.解决

chrome插件调试

Introduction to mqtt protocol
随机推荐
拓展运算符是深拷贝还是浅拷贝
shellcode编写学习-环境
云计算需要考虑的安全技术列举
3438. Number system conversion
SQL labs detailed problem solving process (less1-less10)
PS modify the length and width pixels and file size of photos
35道MySQL面试必问题图解,小白都能看懂
SQL error [1810] [22008]: ora-01810: format code occurs twice
3715. Minimum number of exchanges
Install biological sequence de redundancy software CD hit
Wonderful frog -- how simple can it be to abandon the float and use the navigation bar set by the elastic box
Instructions for common symbols in kotlin
22、 TF coordinate transformation (II): static coordinate transformation
SQL learning
为什么企业需要用户自治的数字身 份
10、 C enum enumeration
Examples of Pareto optimality and Nash equilibrium
Instant experience | further improve application device compatibility with cts-d
shellcode编写(未完)
网络安全应急响应具体操作流程