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 /
This question was closed Dec 01, 2014 at 02:10 PM by SaraCecilia for the following reason:

Duplicate Question

avatar image
1
Question by Sam-K · Dec 01, 2014 at 01:33 PM · graphicsopenglpolygon

GL.Lines Drawing over objects

Im facing a problem using Open GL. I have two images to show. What i want to achieve is in the first image which is made in Cocos2d. Second one i made with unity. alt text

alt text

The Alpha shaded layer is made in GL. In cocos ihave the option to set Z. In unity when i Set/change the Z of the layer. It comes on top of everything. e.g a building z is 10 other is 5 and if i set the z of the layer to 6 i should come between but there are only two options either it appears on top of all or below which means we cant see it ..

any solution to this ??? My code for this is

 static void CreateLineMaterial(){
         if( !lineMaterial ) {
             lineMaterial = new Material( "Shader \"Lines/Colored Blended\" {" +
                                         "SubShader { Pass { " +
                                         "    Blend SrcAlpha OneMinusSrcAlpha " +
                                         "    ZWrite Off Cull Off Fog { Mode Off } " +
                                         "    BindChannels {" +
                                         "      Bind \"vertex\", vertex Bind \"color\", color }" +
                                         "} } }" );
             lineMaterial.hideFlags = HideFlags.HideAndDontSave;
             lineMaterial.shader.hideFlags = HideFlags.HideAndDontSave;
         }
     }
 
     public IsoShader (List<Vector2> p1, List<Vector2> p2, List<Vector2> p3, List<Vector2> p4)
     {
 
         boundaryPoint1 = new List<Vector2>(p1);
         boundaryPoint2 = new List<Vector2>(p2);
         boundaryPoint3 = new List<Vector2>(p3);
         boundaryPoint4 = new List<Vector2>(p4);
     }
 
 
     void OnPostRender()
     {
         CreateLineMaterial();
         lineMaterial.SetPass( 0 );
 
         if(boundaryPoint1 != null)
         {
             GL.PushMatrix();
             GL.Begin(GL.TRIANGLES);
             GL.Color(color);
             Draw();
             GL.End();
             GL.PopMatrix();
         }
     }
 
     public float zIndex;
     void Draw()
     {
         float scale = gState.world.isoView.transform.localScale.x;    
         for(int i=0; i<boundaryPoint1.Count; i++)
             GL.Vertex3(scale * boundaryPoint1[i].x + gState.world.isoView.transform.position.x, scale * boundaryPoint1[i].y + gState.world.isoView.transform.position.y,zIndex);
         for(int i=0; i<boundaryPoint2.Count; i++)
             GL.Vertex3(scale * boundaryPoint2[i].x + gState.world.isoView.transform.position.x, scale * boundaryPoint2[i].y + gState.world.isoView.transform.position.y,zIndex);
         for(int i=0; i<boundaryPoint3.Count; i++)
             GL.Vertex3(scale * boundaryPoint3[i].x + gState.world.isoView.transform.position.x, scale * boundaryPoint3[i].y + gState.world.isoView.transform.position.y,zIndex);
         for(int i=0; i<boundaryPoint4.Count; i++)
             GL.Vertex3(scale * boundaryPoint4[i].x + gState.world.isoView.transform.position.x, scale * boundaryPoint4[i].y + gState.world.isoView.transform.position.y,zIndex);
     }


I dont know how to do this with GL. For now im moving onto Graphics Library in Unity. Create a mesh programatically. Assing Material/ Transparent Shader and then do the required task. But i read some where that GL Library is faster than Graphics library is that so ?

Regards Usama

screen shot 2014-12-01 at 3.28.28 pm.png (400.1 kB)
screen shot 2014-12-01 at 3.30.15 pm.png (389.3 kB)
Comment
Add comment · Show 1
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 Sam-K · Dec 02, 2014 at 06:45 AM 0
Share

As you can see i am drawing a transparent shape. but the shader draws an opaque one. I changed the render type to transparent but still it draws a black opaque shape. How to make it draw alpha blended shape ? should i add color property in the shader or its fine using seperately ?

1 Reply

  • Sort: 
avatar image
1

Answer by SaraCecilia · Dec 01, 2014 at 02:10 PM

http://answers.unity3d.com/questions/434827/gllines-over-game-objects.html

Comment
Add comment · 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

Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Create a screen shatter effect 0 Answers

How to recover Auto Graphics API for Android back to default? 0 Answers

Visually testing on Ubuntu Server? 0 Answers

Generating a sphere with irregularities 1 Answer

Can a Unity app render to an external surface? 1 Answer


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