<div dir="ltr">I should clarify, there may be alpha bitplane issues with the Qt code, I'm not sure. Just be warned that the renderer reporting it did not use depth peeling may not be 100% accurate :-)<div><br></div><div>Ken</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 25, 2016 at 9:20 AM, Ken Martin <span dir="ltr"><<a href="mailto:ken.martin@kitware.com" target="_blank">ken.martin@kitware.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">There was a bug in VTK 7 where it was not reporting depth peeling as being used when really it was being used.<div><br></div><div>To make a long story long :-) I do not like Renderer having an ivar and maintaining state about depth peeling. I feel like the render passes should not pollute the core graphics objects with specifics about them (even though I myself have done it many times) So I started removing/not updating the LastRenderUsedDepthPeeling code. One of the recent VTK releases went out with that method not reporting correctly.  It is fixed in master as of a while ago.  I still think it is a bad method but at least in master it should report correctly. </div><div><br></div><div>Thanks</div><div>Ken</div><div><br></div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 24, 2016 at 1: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">This should help. However, it looks like depth peeling isn't being enable regardless of using custom shaders.<br>
<br>
I just saw this old email thread:<br>
<br>
<a href="http://www.vtk.org/pipermail/vtkusers/2010-August/062106.html" rel="noreferrer" target="_blank">http://www.vtk.org/pipermail/vtkusers/2010-August/062106.html</a><br>
<br>
We're using QVTK / Python bindings. Is there a problem with depth peeling and the Python modules?<br>
<br>
Regards,<br>
Brad<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Date: Thu, 24 Mar 2016 08:26:30 -0400<br>
From: Ken Martin <<a href="mailto:ken.martin@kitware.com" target="_blank">ken.martin@kitware.com</a>><br>
To: Brad Hollister <<a href="mailto:behollis@sci.utah.edu" target="_blank">behollis@sci.utah.edu</a>><br>
Cc: VTK Developers <<a href="mailto:vtk-developers@vtk.org" target="_blank">vtk-developers@vtk.org</a>><br>
Subject: Re: [vtk-developers] transparent foreground polygons<br>
        occluding background geometry<br>
Message-ID:<br>
        <<a href="mailto:CANXz0Sb_qKZkgny0eymo6xZJuw-w653VtP0nr843NR7MAQ8V9A@mail.gmail.com" target="_blank">CANXz0Sb_qKZkgny0eymo6xZJuw-w653VtP0nr843NR7MAQ8V9A@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="utf-8"<br>
<br>
Your custom shader has to be written to work with depth peeling. When in a<br>
depth peeling pass it needs to do some texture lookups and discard<br>
fragments based on those lookups. I've included the general gist below. I<br>
use string replacements to handle it but you are free to use other<br>
approaches as long as the end result in a depth peeling pass has something<br>
like the following in it.<br>
<br>
Thanks<br>
Ken<br>
<br>
 // are we using depth peeling?<br>
 vtkInformation *info = actor->GetPropertyKeys();<br>
 if (info && info->Has(vtkDepthPeelingPass::OpaqueZTextureUnit()))<br>
   {<br>
   vtkShaderProgram::Substitute(FSSource, "//VTK::DepthPeeling::Dec",<br>
     "uniform vec2 screenSize;\n"<br>
     "uniform sampler2D opaqueZTexture;\n"<br>
     "uniform sampler2D translucentZTexture;\n");<br>
   // the .0000001 below is an epsilon.  It turns out that<br>
   // graphics cards can render the same polygon two times<br>
   // in a row with different z values. I suspect it has to<br>
   // do with how rasterization of the polygon is broken up.<br>
   // A different breakup across fragment shaders can result in<br>
   // very slightly different z values for some of the pixels.<br>
   // The end result is that with depth peeling, you can end up<br>
   // counting/accumulating pixels of the same surface twice<br>
   // simply due to this randomness in z values. So we introduce<br>
   // an epsilon into the transparent test to require some<br>
   // minimal z separation between pixels<br>
   vtkShaderProgram::Substitute(FSSource, "//VTK::DepthPeeling::Impl",<br>
     "float odepth = texture2D(opaqueZTexture,<br>
gl_FragCoord.xy/screenSize).r;\n"<br>
     "  if (gl_FragCoord.z >= odepth) { discard; }\n"<br>
     "  float tdepth = texture2D(translucentZTexture,<br>
gl_FragCoord.xy/screenSize).r;\n"<br>
     "  if (gl_FragCoord.z <= tdepth + .0000001) { discard; }\n"<br>
<br>
<br>
<br>
<br>
On Wed, Mar 23, 2016 at 7:08 PM, Brad Hollister <<a href="mailto:behollis@sci.utah.edu" target="_blank">behollis@sci.utah.edu</a>><br>
wrote:<br>
<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<br>
transparency. However, while depth peeling is enabled,<br>
GetLastRenderingUsedDepthPeeling() returns false.<br>
<br>
(The polygons also intersect other similar polygons so that some parts of<br>
them are in front of others, while other parts of the same poly may be<br>
behind others. Another reason to use depth peeling as opposed to depth<br>
sorting, in our opinion.)<br>
<br>
We also require custom shaders, using<br>
vtkOpenGLPolyDataMapper::SetVertexShader(), etc. From the test code @<br>
<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>,<br>
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<br>
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<br>
<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>
<br>
</blockquote>
<br>
<br>
-- <br>
Ken Martin PhD<br>
Chairman & CFO<br>
Kitware Inc.<br>
28 Corporate Drive<br>
Clifton Park NY 12065<br>
<a href="tel:518%20371%203971" value="+15183713971" target="_blank">518 371 3971</a><br>
</blockquote>
_______________________________________________<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><span class="HOEnZb"><font color="#888888">
</font></span></blockquote></div><span class="HOEnZb"><font color="#888888"><br><br clear="all"><div><br></div>-- <br><div>Ken Martin PhD<div>Chairman & CFO<br>Kitware Inc.<br>28 Corporate Drive<br>Clifton Park NY 12065<br><a href="tel:518%20371%203971" value="+15183713971" target="_blank">518 371 3971</a><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>
</font></span></div>
</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>