[vtkusers] Weird render bug with depth peeling and background texture

Benjamin Hopfer greenb3ret at gmail.com
Wed Mar 18 02:59:06 EDT 2015


Can anyone tell me how to proceed in a good way?

Report the bug? Where?

Kind Regards,
Benjamin

On Tue, Mar 10, 2015 at 4:46 PM, Benjamin Hopfer <greenb3ret at gmail.com>
wrote:

> I have a very weird problem with the render window. It only occurs if:
>
>  - vtkRenderer was set to display a background texture at least once since
> program start
>  - The background texture has a transformation (scaling for repeat)
>  - Depth peeling is enabled
>  - At least one transparent actor is displayed.
>
> I'm pretty sure this is a bug, but I wanted to get your insight first,
> before reporting it.
> I attached a minimal working example below. You can use any png file for
> texture.png. I used a 2x2 pixel PNG with (0,0) and (1,1) black and the
> other two white (checker board).
>
> I have uploaded the output of the code: http://imgur.com/a/olUW2
>
>  - The first image is the "expected" outcome, which I retrieved by
> disabling depth peeling ("renderer->SetUseDepthPeeling(1);" is commeted out)
>  - The second image is the outcome after running the example below
> unchanged
>  - The third image shows what happens if zooming is done. Basically, the
> scene is restricted to the left lower part.
>
> It seems like the transformation of the texture is somehow also applied to
> the render window?
>
> Any insights on this? (Im running vtk 6 on Windows 8.1)
>
> Kind Regards,
> Benjamin
>
> 8<--------------------------- Minimal example
> -----------------------------------------
> #include <vtkActor.h>
> #include <vtkConeSource.h>
> #include <vtkNew.h>
> #include <vtkPNGReader.h>
> #include <vtkProperty.h>
> #include <vtkPolyData.h>
> #include <vtkPolyDataMapper.h>
> #include <vtkRenderer.h>
> #include <vtkRenderWindow.h>
> #include <vtkRenderWindowInteractor.h>
> #include <vtkSTLReader.h>
> #include <vtkTexture.h>
> #include <vtkTransform.h>
>
> int main(int argc, char** argv)
> {
>   // Any texture will work. I use a 2 by 2 pixel checkerboard pattern
>   vtkNew<vtkPNGReader> pngReader;
>   pngReader->SetFileName("texture.png");
>   pngReader->Update();
>
>   // Setting up the texture
>   // IMPORTANT: Without a transformation on the texture, the bug will not
> occur.
>   // (You can turn of texture repeating, but I transform to have a
> repeating texture)
>   vtkNew<vtkTexture> texture;
>   texture->SetInputConnection(pngReader->GetOutputPort());
>   texture->SetRepeat(true);
>
>   vtkNew<vtkTransform> trans;
>   trans->Scale(2.0, 3.0, 1.0);
>   texture->SetTransform(trans.Get());
>
>   // Adding a transparent cone. Any geometry will work.
>   // IMPORTANT: If the geometry is not transparent, the bug will not occur
>   vtkNew<vtkConeSource> coneSrc;
>   vtkNew<vtkPolyDataMapper> coneMapper;
>   coneMapper->SetInputConnection(coneSrc->GetOutputPort());
>   vtkNew<vtkActor> coneActor;
>   coneActor->SetMapper(coneMapper.Get());
>   coneActor->GetProperty()->SetOpacity(0.5);
>
>   // Create the renderer
>   // IMPORTANT: If depth peeling is not enabled, the bug will not occur.
>   vtkNew<vtkRenderer> renderer;
>   renderer->SetUseDepthPeeling(1);
>   renderer->TexturedBackgroundOn();
>   renderer->SetBackgroundTexture(texture.Get());
>   renderer->AddActor(coneActor.Get());
>
>   // Create the render window
>   // IMPORTANT: If AlphaBitPlanes is off, the bug will not occur. (But no
> depth peeling either).
>   vtkNew<vtkRenderWindow> renderWindow;
>   renderWindow->AlphaBitPlanesOn();
>   renderWindow->AddRenderer(renderer.Get());
>
>   // Create the interactor and start up
>   vtkNew<vtkRenderWindowInteractor> renderInteract;
>   renderInteract->SetRenderWindow(renderWindow.Get());
>   renderWindow->Render();
>   renderInteract->Start();
>
>   return 0;
> }
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20150318/096203ad/attachment.html>


More information about the vtkusers mailing list