Click here to Skip to main content
15,881,281 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Everyone,
C++
void mainRender()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    renderSTLs(); 

    glEnable(GL_ALPHA_TEST);
    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

 renderPoints();

}


I need to achieve mutual transparency. if alpha value for points is changed it should show the stls behind it. In the above case it is a success because the stls is rendered before the points, so the point can blend with stls. But if I Change the transparency value for stls points are not shown through it. I guess because there is nothing to blend with for stls before it is render.
I need both the cases to work. though changing the render function call by first calling renderPoints() and then renderSTLs() will make the stl transprency work.

how can both the transparency of points and stls works at the same time. I am stuck in this problem. Please somebody help.

Thank you,
Arpan
Posted
Comments
Santhosh G_ 27-Jun-13 12:13pm    
>> But if I Change the transparency value for stls points are not shown through it.
If alpha of stls set as 0.25, then what will the Alpha of lines. Is it1.0 ?

1 solution

C++
void mainRender()
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    renderSTLs(); 
 
    glEnable(GL_ALPHA_TEST);
    glEnable(GL_BLEND);
    if( bPointThroughSTL )
    {
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    }
    else
    { // Here alpha from Destination buffer( STL ) is used to blend with points.
      glBlendFun(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);

    }
 
    renderPoints();
}


glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_DST_ALPHA);
wont work because alpha value in destination buffer(FrameBuffer) will be always 1.0.

If you can prepare two textures with these STLs and points by rendering to texture method[http://www.songho.ca/opengl/gl_fbo.html], a shader can blend these textures as you required.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900