[vtkusers] Infinite sea plane - what's the best way?

Ken Martin ken.martin at kitware.com
Tue Apr 10 15:15:45 EDT 2018


Probably add it as a mode in the vtkSkybox class. Implementation in
vtkOpenGLSkybox just have to change a small bit of shader logic there to
compute a texture coordinate for a floor as opposed to a skybox or a
photosphere.

On Tue, Apr 10, 2018 at 2:19 PM, David E DeMarle <dave.demarle at kitware.com>
wrote:

> On Tuesday, April 10, 2018, 2:05:15 PM GMT+12, Jesse Kinross-Smith <
>> Jesse.Kinross-Smith at bentley.com> wrote:
>>
>> So I need to create an infinite textured plane to represent the sea.
>>
>> vtkPlaneSource seems like the right object, but I can’t seem to get any
>> of the examples to display anything.
>>
>> A colleague tried a while back also but said he could only get it to work
>> with OpenGL not OpenGL2.
>>
>>
> That is odd. OpenGL2 has been the default for a while now and it is tested
> nightly on many platforms. Need more information about what is specifically
> going wrong to diagnose what is wrong in your setup.
>
>
>> Anyone able to offer any ideas?
>>
>> I’ve got a rectilinear grid working, but it’s not ideal, really need an
>> infinite textured plane.
>>
>>
>>
> VTK doesn't really have the concept of boundless shapes to my knowledge.
>
> It is very likely you could do this with OpenGL2 and programmable shaders.
> The shader(s) would evaluate the plane equation, determine a depth and u/v
> coordinate for each fragment and then reject or pass and color the fragment
> based on the depth test. vtkOSPRay would have a different implementation.
>
> Using VTK 8.1.0, C++
>>
>>
>>
>> void CModelView::vtkRenderImageToPlane(const CString& inputFilename,
>> float x, float y, float z)
>>
>> {
>>
>>        USES_CONVERSION;
>>
>>        std::string filename = W2A(inputFilename);
>>
>>
>>
>>        // Read the image which will be the texture,
>>
>>        Image_Type imageType = GetImageType(inputFilename);
>>
>>        vtkAlgorithmOutput* ImageOutput = NULL;
>>
>>        vtkSmartPointer<vtkPNGReader> pNGReader = NULL;
>>
>>        vtkSmartPointer<vtkJPEGReader> jPEGReader = NULL;
>>
>>        vtkSmartPointer<vtkBMPReader> bMPReader = NULL;
>>
>>        switch (imageType)
>>
>>        {
>>
>>               case Image_Type::PNG:
>>
>>               {
>>
>>                       pNGReader = vtkSmartPointer<vtkPNGReader>::New();
>>
>>                       pNGReader->SetFileName(filename.c_str());
>>
>>                       pNGReader->Update();
>>
>>                       ImageOutput = pNGReader->GetOutputPort();
>>
>>               }
>>
>>               break;
>>
>>               case Image_Type::JPG:
>>
>>               {
>>
>>                       jPEGReader = vtkSmartPointer<vtkJPEGReader>::New();
>>
>>                       jPEGReader->SetFileName(filename.c_str());
>>
>>                       jPEGReader->Update();
>>
>>                       ImageOutput = jPEGReader->GetOutputPort();
>>
>>               }
>>
>>               break;
>>
>>               case Image_Type::BMP:
>>
>>               {
>>
>>                       bMPReader = vtkSmartPointer<vtkBMPReader>::New();
>>
>>                       bMPReader->SetFileName(filename.c_str());
>>
>>                       bMPReader->Update();
>>
>>                       ImageOutput = bMPReader->GetOutputPort();
>>
>>               }
>>
>>               break;
>>
>>        }
>>
>>        if (ImageOutput == NULL || (pNGReader == NULL && jPEGReader ==
>> NULL && bMPReader == NULL))
>>
>>               return;
>>
>>
>>
>>        // Create a plane
>>
>>        vtkSmartPointer<vtkPlaneSource> plane = vtkSmartPointer<
>> vtkPlaneSource>::New();
>>
>>        plane->SetNormal(0.0, 0.0, 1.0);
>>
>>        plane->SetCenter(0, 0, 0);
>>
>>        //plane->SetResolution(100, 100);
>>
>>        //plane->SetPoint1(100000, -100000, 0);
>>
>>        //plane->SetPoint2(-100000, 100000, 0);
>>
>>
>>
>>        // Apply the texture
>>
>>        vtkSmartPointer<vtkTexture> texture = vtkSmartPointer<vtkTexture
>> >::New();
>>
>>        texture->SetInputConnection(ImageOutput);
>>
>>        texture->InterpolateOn();
>>
>>        texture->RepeatOn();
>>
>>
>>
>>        vtkSmartPointer<vtkTextureMapToPlane> texturePlane =
>> vtkSmartPointer<vtkTextureMapToPlane>::New();
>>
>>        texturePlane->SetInputConnection(plane->GetOutputPort());
>>
>>
>>
>>        vtkSmartPointer<vtkPolyDataMapper> planeMapper = vtkSmartPointer<
>> vtkPolyDataMapper>::New();
>>
>>        planeMapper->SetInputConnection(texturePlane->GetOutputPort());
>>
>>
>>
>>        vtkSmartPointer<vtkActor> texturedPlane = vtkSmartPointer<vtkActor
>> >::New();
>>
>>        texturedPlane->SetMapper(planeMapper);
>>
>>        texturedPlane->SetTexture(texture);
>>
>>        texturedPlane->GetProperty()->SetOpacity(0.7);
>>
>>        texturedPlane->SetPickable(FALSE);
>>
>>
>>
>>        // Visualize the textured plane
>>
>>        m_vtkRenderer->AddActor(texturedPlane);
>>
>>
>>
>> }
>>
>>
>>
>> --
>>
>> Jesse Kinross-Smith
>>
>> Senior Software Engineer - BSW
>>
>> Bentley Systems, Fremantle
>>
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> https://vtk.org/mailman/listinfo/vtkusers
>>
>> _______________________________________________
>> Powered by www.kitware.com
>>
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>>
>> Please keep messages on-topic and check the VTK FAQ at:
>> http://www.vtk.org/Wiki/VTK_FAQ
>>
>> Search the list archives at: http://markmail.org/search/?q=vtkusers
>>
>> Follow this link to subscribe/unsubscribe:
>> https://vtk.org/mailman/listinfo/vtkusers
>>
>>
>
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/
> opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> https://vtk.org/mailman/listinfo/vtkusers
>
>


-- 
Ken Martin PhD
Distinguished Engineer
Kitware Inc.
101 East Weaver Street
Carrboro, North Carolina
27510 USA

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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180410/32161ae3/attachment.html>


More information about the vtkusers mailing list