<div dir="ltr">Your custom shader has to be written to work with depth peeling. When in a depth peeling pass it needs to do some texture lookups and discard fragments based on those lookups. I've included the general gist below. I use string replacements to handle it but you are free to use other approaches as long as the end result in a depth peeling pass has something like the following in it.<div><br></div><div><div>Thanks</div><div>Ken</div></div><div><br></div><div><div>  // are we using depth peeling?</div><div>  vtkInformation *info = actor->GetPropertyKeys();</div><div>  if (info && info->Has(vtkDepthPeelingPass::OpaqueZTextureUnit()))</div><div>    {</div><div>    vtkShaderProgram::Substitute(FSSource, "//VTK::DepthPeeling::Dec",</div><div>      "uniform vec2 screenSize;\n"</div><div>      "uniform sampler2D opaqueZTexture;\n"</div><div>      "uniform sampler2D translucentZTexture;\n");</div><div>    // the .0000001 below is an epsilon.  It turns out that</div><div>    // graphics cards can render the same polygon two times</div><div>    // in a row with different z values. I suspect it has to</div><div>    // do with how rasterization of the polygon is broken up.</div><div>    // A different breakup across fragment shaders can result in</div><div>    // very slightly different z values for some of the pixels.</div><div>    // The end result is that with depth peeling, you can end up</div><div>    // counting/accumulating pixels of the same surface twice</div><div>    // simply due to this randomness in z values. So we introduce</div><div>    // an epsilon into the transparent test to require some</div><div>    // minimal z separation between pixels</div><div>    vtkShaderProgram::Substitute(FSSource, "//VTK::DepthPeeling::Impl",</div><div>      "float odepth = texture2D(opaqueZTexture, gl_FragCoord.xy/screenSize).r;\n"</div><div>      "  if (gl_FragCoord.z >= odepth) { discard; }\n"</div><div>      "  float tdepth = texture2D(translucentZTexture, gl_FragCoord.xy/screenSize).r;\n"</div><div>      "  if (gl_FragCoord.z <= tdepth + .0000001) { discard; }\n"</div><div><br></div><div><div><br></div></div></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 23, 2016 at 7:08 PM, Brad Hollister <span dir="ltr"><<a href="mailto:behollis@sci.utah.edu" target="_blank">behollis@sci.utah.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
We have a problem with transparent foreground polys occluding geometry.<br>
<br>
We're trying to use depth peeling to handle foreground polygons with transparency. However, while depth peeling is enabled, GetLastRenderingUsedDepthPeeling() returns false.<br>
<br>
(The polygons also intersect other similar polygons so that some parts of them are in front of others, while other parts of the same poly may be behind others. Another reason to use depth peeling as opposed to depth sorting, in our opinion.)<br>
<br>
We also require custom shaders, using vtkOpenGLPolyDataMapper::SetVertexShader(), etc. From the test code @ <a href="http://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Rendering/OpenGL2/Testing/Cxx/TestUserShader2.cxx" rel="noreferrer" target="_blank">http://www.vtk.org/gitweb?p=VTK.git;a=blob;f=Rendering/OpenGL2/Testing/Cxx/TestUserShader2.cxx</a>, it looks as though custom shaders can't be used with depth peeling in VTK.<br>
<br>
Thus, is there another way to enable depth peeling or to have transparent foreground polys in our usage scenario?<br>
<br>
Regards,<br>
Brad<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtk-developers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtk-developers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtk-developers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtk-developers</a><br>
<br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Ken Martin PhD<div>Chairman & CFO<br>Kitware Inc.<br>28 Corporate Drive<br>Clifton Park NY 12065<br>518 371 3971<div><br></div><div><span style="font-size:10pt;font-family:Tahoma,sans-serif">This communication,
including all attachments, contains confidential and legally privileged
information, and it is intended only for the use of the addressee.  Access to this email by anyone else is
unauthorized. If you are not the intended recipient, any disclosure, copying,
distribution or any action taken in reliance on it is prohibited and may be
unlawful. If you received this communication in error please notify us
immediately and destroy the original message. 
Thank you.</span></div></div></div>
</div>