x


Camera OnPostRenderer on iPhone/iPad sometimes paints all the GL.Lines Black.

Hi I am using the following code to render a number of marks without inducing too much rendering overhead. It takes only one draw call. It works fine in the editor but at certain camera angles/positions on the iphone and ipad the drawn lines are drawn black instead of the desired colour.

var drawLines = true;
private var lineMaterial : Material;
private var stateLink : StateController;


function Awake () {
    lineMaterial = new Material( "Shader \"Lines/Colored Blended\" {" +
        "SubShader { Tags { \"Queue\" = \"Transparent+2\" \"RenderType\"=\"Transparent\"}" +
        "Pass {" +
        "   BindChannels { Bind \"Color\",color }" +
        "   Blend SrcAlpha OneMinusSrcAlpha" +
        "   ZWrite Off Cull Off Fog { Mode Off }" +
        "} } }");
    lineMaterial.hideFlags = HideFlags.HideAndDontSave;
    lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
    stateLink = GameObject.FindWithTag ("Engine").GetComponent(StateController);
}

function OnPostRender ()
{
    if(drawLines)
    {
        lineMaterial.SetPass(0);
        GL.Begin(GL.LINES);
        stateLink.drawTrajMarks();
        GL.End();
    }
}

function OnApplicationQuit () {
    DestroyImmediate(lineMaterial);
}

@script RequireComponent(Camera)

The line stateLink.drawTrajMarks(); calls functions which draw lines by calling positions from an number of different objects.

eg.

function drawTrajMarks()
{
    ...
    GL.Color(colour);
    for (var q = 0; q < circle2.length-1; q++)
    {
        GL.Vertex(circle2[q]+posnPnt );
        GL.Vertex(circle2[q+1]+posnPnt );
    }
...
}

I have tried a number of things to determine why the color goes black only at certain camera angles. I thought initially it was a z buffer order problem. But even if I change to ZTest always, at some camera angles the lines become black. I would be very interested in any pointers of where I should look next.

more ▼

asked Apr 29 '11 at 04:03 AM

cncguy gravatar image

cncguy
1k 21 25 36

I am also seeing this behavior in my project. Have you had any success in solving it?

I've discovered that the lines seem to draw more consistently with color if at least one particle from a particle system is visible on screen, but this doesn't work 100% of the time.

This post talks about the same issue: http://answers.unity3d.com/questions/254732/gllines-are-black-on-ipad-when-mesh-are-on-screen.html

Nov 04 '11 at 09:11 PM DanDixon

worked for me!

May 25 '12 at 03:42 AM pmsimard
(comments are locked)
10|3000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x36
x5

asked: Apr 29 '11 at 04:03 AM

Seen: 1013 times

Last Updated: May 25 '12 at 03:42 AM