x


using openGL to render simple line

i have this script, and works great except i want solid white line material. i tried to use it without the material but i get strange results, grid lines in the editor view start changing?

how to get solid white line is the question, and is it reliable to use this method?

 static var lineMaterial : Material;
    static function 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; 
    } 
} 

function OnPostRender() 
{ 
    CreateLineMaterial(); 
    lineMaterial.SetPass( 0 ); 
    GL.Begin( GL.LINES ); 
    GL.Color( Color(1,1,1,0.5) ); 
    GL.Vertex3( 0, 0, 0 ); 
    GL.Vertex3( 1, 0, 0 ); 
    GL.Vertex3( 0, 1, 0 ); 
    GL.Vertex3( 1, 1, 0 ); 
    GL.Color( Color(0,0,0,0.5) ); 
    GL.Vertex3( 0, 0, 0 ); 
    GL.Vertex3( 0, 1, 0 ); 
    GL.Vertex3( 1, 0, 0 ); 
    GL.Vertex3( 1, 1, 0 ); 
    GL.End(); 
} 
more ▼

asked Jun 24 '10 at 08:34 PM

pretender gravatar image

pretender
497 121 134 145

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

1) Why not use Line Renderer.

2) If you want solid lines, perhaps change the shader to get rid of blending? You say "solid white line" but your post render code seems to want to go from white 50% alpha to black 50% alpha.

more ▼

answered Jun 24 '10 at 09:17 PM

Tetrad gravatar image

Tetrad
7.2k 27 37 89

(comments are locked)
10|3000 characters needed characters left
Your answer
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:

x808
x265
x122
x113
x32

asked: Jun 24 '10 at 08:34 PM

Seen: 3368 times

Last Updated: Jun 24 '10 at 08:34 PM