[Paraview] [EXTERNAL] Re: OSPRay textures and materials mapping

David E DeMarle dave.demarle at kitware.com
Thu May 31 08:17:22 EDT 2018


I'll remove the need for them at some point, but for 5.5 they are helpful.
So yes discourse is a good place for safe keeping.

On Wed, May 30, 2018, 8:53 PM Scott, W Alan <wascott at sandia.gov> wrote:

> Dave,
>
> Would this be a good set of scripts to put in our brand new, squeeky clean
> Tips and Tricks section of Discourse?
>
>
>
> https://discourse.paraview.org/
>
>
>
> Alan
>
>
>
>
>
>
>
> *From:* ParaView [mailto:paraview-bounces at public.kitware.com] *On Behalf
> Of *David E DeMarle
> *Sent:* Tuesday, May 22, 2018 12:10 PM
> *To:* Jonathan Borduas <jonathan.borduas at caboma.com>
> *Cc:* paraview at public.kitware.com
> *Subject:* [EXTERNAL] Re: [Paraview] OSPRay textures and materials mapping
>
>
>
> And here is a python schell script to make step 4 (create the lookuptable)
> automatic.
>
>
>
> apartment = FindSource("sample_apartment.obj")
>
> vtklevel = apartment.GetClientSideObject()
>
> lut = GetColorTransferFunction('MaterialIds')
>
> arr = vtklevel.GetOutput().GetFieldData().GetAbstractArray(0)
>
> lut.InterpretValuesAsCategories = 1
>
> ll = []
>
> for x in range(0, arr.GetNumberOfTuples()):
>
> ll.append(str(x))
>
> ll.append(arr.GetValue(x))
>
>
>
>
>
>
> David E DeMarle
> Kitware, Inc.
> Principal Engineer
> 21 Corporate Drive
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
>
>
> On Tue, May 22, 2018 at 1:51 PM, David E DeMarle <dave.demarle at kitware.com>
> wrote:
>
> On Tue, May 22, 2018 at 12:34 PM, David E DeMarle <
> dave.demarle at kitware.com> wrote:
>
>
>
> On Tue, May 22, 2018 at 10:34 AM, Jonathan Borduas <
> jonathan.borduas at caboma.com> wrote:
>
> Hi David,
>
> I was able to complete all the steps. As you probably know, the step four
> was tedious.
>
> However I couldn’t get the result I wanted since I couldn’t assign the
> right textures to the right areas. Is there a mechanism to assign the
> texture just like we assign materials ?
> I guess this is what you mean by “multi-texture isn’t implemented yet”. I
> could probably extract all objects using a connectivity filter and then
> manually assign the textures, but again it is a tedious process for complex
> objects.
>
>
>
> Better to do it in the code. We read in all of the texture coordinates
> when we read the .obj and all of the texture files when we read the .mtl ->
> we just aren't using the right set of texture coordinates in all cases yet.
> That is most of what I mean by multitexture.
>
>
>
> Is there a roadmap as to when the multi-texture could be implemented ?
>
>
>
> I'm hoping for 5.6 in a couple of months time. Although this is important
> it may very well slip because of other priorities.
>
>
>
>
>
>
> In the meantime, this python programmable filter is a workaround.
>
>
>
> pdi = self.GetInput()
>
> pdo = self.GetOutput()
>
> pdo.ShallowCopy(pdi)
>
>
>
> arraynames = []
>
> arrays = {}
>
> *for* a *in* range(0,pdi.GetPointData().GetNumberOfArrays()):
>
>   array = pdi.GetPointData().GetArray(a)
>
>   *if* array.GetNumberOfComponents() != 2:
>
>     *continue*
>
>   arrname = array.GetName()
>
>   pdo.GetPointData().RemoveArray(arrname)
>
>   arraynames.append(arrname)
>
>   arrays[arrname] = array
>
>
>
> tcoords = vtk.vtkFloatArray()
>
> tcoords.SetName("TCoords")
>
> tcoords.SetNumberOfComponents(2)
>
> pdo.GetPointData().SetTCoords(tcoords)
>
> # todo numpy this to make it 100x faster
>
> *for* p *in* range(0, pdi.GetNumberOfPoints()):
>
>   tcoord = [0,0]
>
>   *for* arrname *in* arrays:
>
>     candidate = arrays[arrname].GetTuple2(p)
>
>     *if* candidate[0] == -1 *and* candidate[1] == -1:
>
>       *continue*
>
>     tcoord = candidate
>
>   tcoords.InsertNextTuple2(tcoord[0],tcoord[1])
>
>
>
>
>
>
>
> It would be great to have readers that can load texture/Geometry/Materials
> files such as .obj (.mtl and .png), .fbx and .dwg.
>
>
>
> Agreed.
>
>
>
> Best regards,
>
>
>
> Jonathan Borduas
>
>
>
> *From:* David E DeMarle <dave.demarle at kitware.com>
> *Sent:* Friday, May 18, 2018 10:58 AM
> *To:* Jonathan Borduas <jonathan.borduas at caboma.com>
> *Cc:* paraview at public.kitware.com
> *Subject:* Re: [Paraview] OSPRay textures and materials mapping
>
>
>
> Hi Jonathan.
>
>
>
> Yes you can do that.
>
>
>
> 1) File->Load OSPRay Materials, switch the file type from "OSPRay Material
> Files (*.json)"  to "Wavefront Material FIles (*.mtl)". That will let you
> load all of the materials and textures. They should all show up in the
> Material list.
>
>
>
> 2) The OSPRay Material selection (on Display section of Properties Tab
> advanced) will have all of the individual materials listed in it + a few
> others including "Value Indexed" which is all the way at the bottom. Choose
> that it means "use the categorical color lookup table to decide what
> material to use for each block and or polygon"
>
>
>
> 3) Now change the scalar array to color by to "Material Id", a cell
> aligned array which has the material index to use for each cell.
>
>
>
> 4) Make up a categorical lookup table.
>
>    open spreadsheet view, switch to Field Data, look at the Material Names.
>
>    open the color map editor for the "Material Id", click on Interpret
> Values As Categories and the color will change from bluewhitered to
> extremely YELLOW.
>
>    add annotations, value 0 should be the name of the first entry in the
> Material Names array.
>
>
>
> Notes:
>
> * I have the trivial script somewhere that I used for the SC17 demo that
> makes up the lookup table for you. I'll try and dig that up.
>
> * in general it isn't a 1:1 match between mtl and ospray, in particular
> multitextures are not yet implemented
>
> * along those lines, the mtl parser I whipped up
> $PVSRC/VTK/Rendering/OSPRay/vtkMaterialLibrary::InternalParseMTL recognizes
> a "type" extension outside of mtl that lets you bring in ospray's nice
> materials instead of the default OBJMaterial. Glass and Metal are
> particularly nice.
>
>
>
> At some point I'll get around to making this all automatic. Patches are
> welcome in the meantime.
>
>
>
> good luck
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> David E DeMarle
> Kitware, Inc.
> Principal Engineer
> 21 Corporate Drive
> <https://maps.google.com/?q=21+Corporate+Drive+%0D%0AClifton+Park,+NY+12065&entry=gmail&source=g>
> Clifton Park, NY 12065-8662
> Phone: 518-881-4909
>
>
>
> On Fri, May 18, 2018 at 10:25 AM, Jonathan Borduas <
> jonathan.borduas at caboma.com> wrote:
>
> Hi,
>
> I tried rendering an .obj file running OSPRay that was exported from PCon
> Planner Version 7.7 Patch 1. The original file is a .dwg
>
>
>
> I used the PathThracer mode. However, attached to the .obj there is an
> .mtl file containing 50+ materials and 50+ texture (.png) files.
>
> I didn’t find an automated way to map all polydata of the .obj with their
> respective material and texture file and rendering them using OSPRay.
>
> It seems that I have to assign the material and texture to each polydata
> one-by-one.
>
>
>
> Is there a feature that will automatically map the respective textures and
> materials ?
>
> Here is the link to download the original .dwg file.
> https://www.easterngraphics.com/pcon/en/wp-content/uploads/2015/03/sample_apartment.dwg
>
> You will need to export it to .obj using PCon Planner Version 7.7 Patch 1
> with the File/Export/Geometry menu.
> I couldn’t share the .obj  file since the size is 60mb+
>
>
>
> Thank you
>
>
>
> Jonathan Borduas
>
>
>
>
> _______________________________________________
> 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 ParaView Wiki at:
> http://paraview.org/Wiki/ParaView
>
> Search the list archives at: http://markmail.org/search/?q=ParaView
>
> Follow this link to subscribe/unsubscribe:
> https://public.kitware.com/mailman/listinfo/paraview
>
>
>
>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/paraview/attachments/20180531/f0ddb517/attachment.html>


More information about the ParaView mailing list