Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
2
Question by cncguy · Apr 29, 2011 at 04:03 AM · glonpostrender

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.

Comment
Add comment · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image DanDixon · Nov 04, 2011 at 09:11 PM 0
Share

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

avatar image pmsimard · May 25, 2012 at 03:42 AM 0
Share

worked for me!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Petr Benysek · Jan 20, 2014 at 03:55 PM

I've had the same problem on Android (in Win Editor colors were working fine)... After several hours of experimenting, I've found that mesh instantiation as well as some other mesh operations can get OpenGL into a weird state where it stops listening to GL.Color command.

In my case, solution was quite easy (at last!): call GL.InvalidateState(); before other GL commands.

Hope that helps. :)

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Z4urce · Oct 01, 2014 at 09:41 AM 0
Share

Nice! It definitely works.

Your answer

Hint: You can notify a user about this post by typing @username

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

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Use Gl.Lines to connect Vector3 points in world space 1 Answer

Drawing semi-transparent objects with GL.Begin(GL.QUADS) 3 Answers

GL - Shader not working in Android 1 Answer

GL.Quads not correctly displaying color. It's all black 0 Answers

OpenGL function don't work well on Unity 2017.2.0f3, But worked well on Unity 2017.1.1f1 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges