For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Lines with scalable thickness

Anton Shabalin's picture

Hello everyone! 

I need to make OCCT to draw lines with scalable thickness. Is there any standard methods in OpenCASCADE to do that ?

I know that it can be solved using geometry shader like this:

​Any ideas ?


Benjamin Bihler's picture

Hi Anton,

if you want to change the thickness of a AIS_InteractiveObject representing a wire, you can use for example:

Handle(Prs3d_LineAspect) aspect =
        new Prs3d_LineAspect(Quantity_NOC_VIOLETRED3,
                Aspect_TypeOfLine::Aspect_TOL_SOLID, 4.0);



Anton Shabalin's picture

Thank you for the answer.

But it is not what I am looking for. When I am scaling the scene I want to see scaled lines.

So I think the best way to do this is to create a geometry shader. But I am stuck now with a simple thing:

const char vertexShader[] =\
           " void main()""\n"
           " {""\n"
           "    gl_Position  = occProjectionMatrix * occWorldViewMatrix * occModelWorldMatrix * occVertex;""\n"
           " }";

const char fragmentShader[] = \
        " void main()""\n"
        " { ""\n"
        "    occFragColor = vec4(0.0, 0.0, 1.0, 1.0);""\n"
        " }";

    gp_Pnt2d p0(0.0,0.0);
    gp_Pnt2d p1(20.0,0.0);

    Handle(Geom2d_Line) line = GCE2d_MakeLine(p0, p1);
    Handle(Geom2d_TrimmedCurve) lineTrim = new Geom2d_TrimmedCurve(line, 0.0, p0.Distance(p1));

    TopoDS_Edge edge = BRepBuilderAPI_MakeEdge2d(lineTrim);
    Handle(AIS_Shape) edgeShape = new AIS_Shape(edge);
    Handle(Graphic3d_ShaderObject) vs_object = Graphic3d_ShaderObject::CreateFromSource(Graphic3d_TOS_VERTEX, TCollection_AsciiString(vertexShader) );
    Handle(Graphic3d_ShaderObject) fs_object = Graphic3d_ShaderObject::CreateFromSource(Graphic3d_TOS_FRAGMENT, TCollection_AsciiString(fragmentShader) );

    Handle(Graphic3d_ShaderProgram) shaderProg = new Graphic3d_ShaderProgram();


    edgeShape->Attributes()->SetShaderProgram(shaderProg, Graphic3d_ASPECT_LINE, true);

    Context()->Display(edgeShape, false);

It seems to me that shader program don't work. What am I doing wrong ? 

Anyone ?

Kirill's picture

I have registered a bug for this issue:

You can setup aspects manually instead of helper method Prs3d_Drawer::SetShaderProgram() to workaround bug in it.

Anton Shabalin's picture

Thank you for the answer!

I am already solved the problem - I set WireAspect manually. It works.

And I wonder why there is no geometry shader in OCCT yet. Because when I added it to OpenGL_ShaderProgram and to Graphic3d_TypeOfShaderObject it worked properly.

I hope that devs will add geometry shader to official release soon.

Kirill's picture

Graphic3d does not provide definition of Geometry Shader for a simple reason - there was no a use case for it yet.
Adding support for it should be quite straightforward though.

Contributions are welcome - Open CASCADE Technology is free and open source!
But you can at least register bugs / feature request on bugtracker, if you are using OCCT in your projects.