Render Problem with GL
Posted: 15 Mar 2021, 16:46
When I use GL to render some line in OnRenderObject(),get some unexpected screen as below.
Red Block is cursor render by GL.
In the second pic, the red block is front of NoesisUI, but hidden by door.
And the door is hidden by NoesisUI.
I think the prombe is the ZTest of NoesisUI?
All the girds and red block should be overlay by UI.
The Shader:
In the second pic, the red block is front of NoesisUI, but hidden by door.
And the door is hidden by NoesisUI.
I think the prombe is the ZTest of NoesisUI?
All the girds and red block should be overlay by UI.
Code: Select all
void OnRenderObject()
{
if(!_IsEnable)
return;
if (!_LineMaterial)
{
_LineMaterial = new Material(Shader.Find("Lines/Colored Blended"));
}
if (_HitCellPoint_InWorld.HasValue)
{
// set the current material
_LineMaterial.SetPass(0);
GL.Begin(GL.QUADS);
GL.Color(new Color(255, 0, 0));
GL.Vertex3(_HitCellPoint_InWorld.Value.x, _HitCellPoint_InWorld.Value.y, _HitCellPoint_InWorld.Value.z);
GL.Vertex3(_HitCellPoint_InWorld.Value.x + 1, _HitCellPoint_InWorld.Value.y, _HitCellPoint_InWorld.Value.z);
GL.Vertex3(_HitCellPoint_InWorld.Value.x + 1, _HitCellPoint_InWorld.Value.y, _HitCellPoint_InWorld.Value.z + 1);
GL.Vertex3(_HitCellPoint_InWorld.Value.x, _HitCellPoint_InWorld.Value.y, _HitCellPoint_InWorld.Value.z + 1);
GL.End();
GL.End();
}
}
Code: Select all
Shader "Lines/Colored Blended"
{
SubShader
{
Pass
{
Blend SrcAlpha OneMinusSrcAlpha
//ZWrite On
//ZTest Always
Cull Off
Fog {
Mode Off
}
BindChannels {
Bind "vertex", vertex Bind "color", color
}
}
}
}