- Home /
Question by
Blink123123 · Oct 11, 2013 at 07:32 AM ·
c#materialshadersgl
Gl.Lines appearing over objects
lineMaterial = new Material(
@"Shader ""Lines/Colored Blended"" {
SubShader {
Tags { ""RenderType""=""Opaque"" }
Pass {
Blend SrcAlpha OneMinusSrcAlpha
ZWrite On
ZTest LEqual
Cull Off
Fog { Mode Off }
BindChannels {
Bind ""vertex"", vertex Bind ""color"", color
}
}
}
}"
);
This the the lineMaterial used in my Gl.Lines. The problem is it appears above my gameobjects why is that? and how can I fix it?
Comment
void OnPostRender() {
// variables
int currentLevel = gridProperties.GetCurrentLevel() * GRID_WIDTH;
// set the current material
CreateLine$$anonymous$$aterial();
line$$anonymous$$aterial.SetPass(0);
// start drawing the grid with selected color
GL.Begin(GL.LINES);
GL.Color(gridColor);
// draw lines for the Y and Z axis
for(int i = 0; i <= gridGridLength; i += GRID_SIZE) {
GL.Vertex3(temp.x, currentLevel, temp.z + i);
GL.Vertex3(gridGridLength, currentLevel, temp.z + i);
GL.Vertex3(temp.x + i, currentLevel, temp.z);
GL.Vertex3(temp.x + i, currentLevel, gridGridLength);
}
// draw lines for the Y and Z axis on the upper and lower layer if needed
if(additionalLayers) {
for(int i = 0; i <= gridGridLength; i += GRID_SIZE) {
// change color for upper layer
GL.Color(gridUpperNeighborColor);
// draw lower layer
GL.Vertex3(temp.x, currentLevel + GRID_WIDTH, temp.z + i);
GL.Vertex3(gridGridLength, currentLevel + GRID_WIDTH, temp.z + i);
GL.Vertex3(temp.x + i, currentLevel + GRID_WIDTH, temp.z);
GL.Vertex3(temp.x + i, currentLevel + GRID_WIDTH, gridGridLength);
// change color for lower layer
GL.Color(gridLowerNeighborColor);
// draw upper layer
GL.Vertex3(temp.x, currentLevel - GRID_WIDTH, temp.z + i);
GL.Vertex3(gridGridLength, currentLevel - GRID_WIDTH, temp.z + i);
GL.Vertex3(temp.x + i, currentLevel - GRID_WIDTH, temp.z);
GL.Vertex3(temp.x + i, currentLevel - GRID_WIDTH, gridGridLength);
}
}
// end drawing
GL.End();
}
Your answer
Follow this Question
Related Questions
Add two radius on the same shader 1 Answer
Blend 2 linerender colors at point of interception 0 Answers
Reductional Shader, (vegetation / fall) 0 Answers
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers