Point Cloud Visualizer

add-ons
blender2-80

(carbon2) #1

Point Cloud Visualizer

Display, render and convert to mesh colored point cloud PLY files.

Display colored point cloud PLY in Blender’s 3d viewport. Optionally render point cloud to png sequence or convert to various mesh types with vertex colors for regular rendering.

Works with any PLY file with ‘x, y, z, nx, ny, nz, red, green, blue’ vertex values. Vertex normals and colors are optional. Color values must be in 0-255 range.

Point Cloud Visualizer

General info

Usage:
  • Install and activate addon in a usual way.
  • Add any object type to scene.
  • Go to 3d View Sidebar (N) > Point Cloud Visualizer panel, click file browser icon, select ply file, click Load PLY.
  • Click Draw button to display point cloud, Erase to hide point cloud. Adjust percentage of displayed points with Display and point size with Size.
  • Display point normals as lines - click Normal icon, adjust line length with Length next to it. Pro tip: for large clouds, set Display to some small percentage, adjust Length to appropriate value and then set Display back.
  • Transforming parent object transforms point cloud as well.
  • Illumination works only when vertex normals are present
  • When vertex colors are missing, cloud will be displayed in uniform gray, in this case you can enable Illumination to have better cloud view
  • Single point cloud can be rendered on transparent and composed over regular render
  • For rendering in regular render engine you can convert cloud to colored mesh
Display Options:
  • Display - percentage of displayed points
  • Size - point size in pixels
  • Normals - display point normals as lines, adjust line length with Length next to it
  • Illumination - enable extra illumination, works only when vertex normals can be loaded
  • Light Direction - light direction
  • Light Intensity - light intensity
  • Shadow Intensity - shadow intensity

Point cloud rendering

Currently only sigle point cloud per render/frame is supported. If you need more clouds at once, select another cloud parent and re-render with different suffix in Render subpanel. Output image is RGBA 8bit PNG - transparent background with colored point cloud, which can be composed over something else later.

Usage:
  • Load and display ply first.
  • Make a camera and adjust as needed.
  • Set render image size in Properties > Output > Dimensions. Resolution X, Y and % are used.
  • Set render path in Properties > Output > Output. Just path is used.
  • Select cloud parent object, set point size with Size or percentage of rendered points with Count
  • If Illumination is enabled it will be rendered as well
  • Hit Render or Animation
Render options:
  • Size - point render size in pixels
  • Count - percentage of rendered points
  • Suffix - rendered image filename suffix. If filename in Output path is defined result filename will be NAME_SUFFIX_######.png, if only path is given, result is SUFFIX_######.png
  • Leading Zeros - image filename frame number leading zeros count

Point cloud to mesh conversion:

Convert point cloud to mesh. May result in very large meshes, e.g. 1m point cloud to cubes = 8m poly mesh. Depending on what point cloud data is available and desired mesh type, some options may not be enabled.

  • Type - Instance mesh type, Vertex, Equilateral Triangle, Tetrahedron, Cube or Ico Sphere
  • All, Subset - Use all points or random subset of by given percentage
  • Size - Mesh instance size, internal instanced mesh has size 1.0 so if you set size to 0.01, resulting instances will have actual size of 0.01 event when cloud is scaled
  • Align To Normal - Align instance to point normal, e.g. tetrahedron point will align to normal, triangle plane will align to normal etc.
  • Colors - Assign point color to instance vertex colors, each instance will be colored by point color (except vertices)

Addon Preferences:

  • Default Color - Default color to be used upon loading PLY to cache when vertex colors are missing
  • Normal Color - Display color for vertex normals

Changelog:

  • 0.8.10 fixes
  • 0.8.9 ui tweaks, code cleanup
  • 0.8.8 refactored convert to mesh
  • 0.8.7 fixed vcols bug in convert
  • 0.8.6 ui tweaks, a few minor optimizations
  • 0.8.5 convert to mesh all or subset
  • 0.8.4 preferences, ui tweaks
  • 0.8.3 display normals
  • 0.8.2 fixed shader unknown attribute name
  • 0.8.1 fixed ply with alpha, fixed convert to mesh when normals or colors are missing
  • 0.8.0 convert to mesh
  • 0.7.2 ui tweaks
  • 0.7.1 viewport performance fixes
  • 0.7.0 ascii ply support
  • 0.6.6 fixed drawing after undo/redo
  • 0.6.5 point cloud illumination
  • 0.6.4 refactored draw handlers, fixed occasional crash on erase
  • 0.6.3 added percentage of rendered points, fixed render colors to look the same as in viewport
  • 0.6.2 fixed point size display in viewport, separated view and render point size
  • 0.6.1 single cloud rendering almost completely rewritten to be better and faster
  • 0.6.0 single cloud rendering
  • 0.5.2 refactored some logic, removed icons from buttons
  • 0.5.1 load ply without vertex colors, uniform grey will be used
  • 0.5.0 performance improvements using numpy for loading and processing data
  • 0.4.6 fixed crash when parent object is deleted while drawing, fixed removal of loaded data when parent is deleted
  • 0.4.5 added ‘Display’ percentage, better error handling during .ply loading
  • 0.4.0 almost complete rewrite for blender 2.80, performance improvements using shaders, simplified ui
  • 0.3.0 new ply loader, can be used with any binary ply file with vertex coordinates and colors
  • 0.2.0 display percentage
  • 0.1.0 first release
Known bugs:
  • If you duplicate object with cloud, duplicate will still control the original one until you load a different one. Currently there is no reliable way (as far as i know) to get unique id of an object and therefore no way to tell to which object stored properties (e.g. path to ply) belong.

Get it here:

direct link:
https://raw.githubusercontent.com/uhlik/bpy/master/view3d_point_cloud_visualizer.py


Meshroom Importer
Colored Pointcloud Rendering
(Spirou4D) #2

Congratulations carbon2,
One more time, a very useful addon!
Friendly yours.
Namaste. :eyebrowlift:
Spirou4D


(SniperKing) #3

It’s amazing !!! :cool:
Thanks


(irSindaco) #4

I’ve been looking for this for months now. Thanks carbon2, well done :slight_smile:


(urkokul) #5

Awesome. Thanks


(carbon2) #6

update: added display percentage


(nirenyang) #7

Nice point cloud tool. hope somedays blender can import huge color pointcloud like recap.


(SniperKing) #8

Great, this new feature :slight_smile:

For information, ambient occlusion works on the cloud (my first test with photoscan trial version) :wink:
OpenGL render don’t work. Why ? Do you have a solution ?



(carbon2) #9

opengl render (i guess) is out of reach from python, so i don’t think it is possible. 3d manipulators are not rendered too.


(SniperKing) #10

For turn around this problem, it’s possible to take bgl captures!!! It’s works perfectly ! :smiley:


(carbon2) #11

update: 0.3.0 new ply loader, can be used with any binary ply file with vertex coordinates and colors
from now it should load any binary ply with ‘x, y, z, red, green, blue’ vertex values. all other values are ignored. color values must be in 0-255 range.


(CHBB) #12

Awesome work!

But how to load a file automatically from python scripts? Setting the file path works:

bpy.data.objects[“empty”].point_cloud_visualizer.filepath = r’’‘path o\file.ply’’’

Loading the pc file by changing the default value for automatic loading to true is not working


(stephen_leger) #13

Hi carbon2,
Nice work !
For opengl render under python you may take a look at MesureIt or archipack [1], (sharing same codebase).
The trick is to use gl to draw over an image rather than on screen.
Keep in mind that blender gl api is likely to deeply change under 2.8 (complete rewrite, not yet done).

[1] archipack gl render


(carbon2) #14

i don’t think i understand, for rendering like on image right? not rendering to viewport, or there is some performance black magic, drawing all to in memory image and then the drawing image over viewport to speed things up…


(artao) #15

So I’m very excited about this add-on, as I NEED vert colors from point clouds for what I’m trying to do.
I’m using Mandelbulb 3D to generate point clouds of 3D fractals to import into Blender for volumetric rendering in cycles and renderman. Mandelbulb 3D bases the vert colors on the fractally calculated colors, which is important. “Faking” that sort of thing just isn’t really possible.
So I’ve installed this … I think … All I need is the second link you listed, yes? I tried downloading the .zip from the first GitHub link, but Blender wouldn’t accept that for an install.
When I try to load my .ply files, I’m told “Unable to load .ply”
Here is one of my point clouds I’m attempting to import. This is a pretty small one. Just a default formula for test export. Some of the point clouds .ply files are over 150 megs, and I’m sure I could easily go bigger.
https://drive.google.com/open?id=1Boa4KLp1Hwf4FEcY89GU-IM5kr1jV__x

I very much look forward to be able to use this add-on.

… I even tried running the .ply thru MeshLab and exporting it as Collada, but Blender still didn’t bring in the vert colors.


(carbon2) #16

the first link is my repo of all addons, it can’t be installed as a whole. the second link is addon itself.
but seems like you sorted it out and successfully installed addon, now the ply files. the ply you linked is ascii ply file and only binary ply files works in my addon. it has ply reader built in and it accepts only binary encoded ply files, so if you can save them as binary or in meshlab load your ascii ply, save as ply again, this time with binary encoding checked and you are good to go. i tested it with your file and works well.
by the way, with binary encoding you get much smaller file sizes…


(artao) #17

Okay thanks. That worked to get it into your visualizer, and the colors do indeed come through nicely.
Is there a way for me to apply that to a volumetric material?
While trying to figure if/how I could do that, it crashed and gave me this error, which I duly report:

Traceback (most recent call last):
File “C:\Users\freeman\AppData\Roaming\Blender Foundation\Blender\2.79\scripts\addons\view3d_point_cloud_visualizer.py”, line 299, in modal
context.area.tag_redraw()
AttributeError: ‘NoneType’ object has no attribute ‘tag_redraw’

location: <unknown location>:-1

ALSO! Thanks for the tip about the binary file. I didn’t realize Mandelbulb 3D was outputting text. And no, there is no binary option, sadly.


(carbon2) #18

can you provide some steps to reproduce the error? such errors does not say much. it might be for example, that you switched are type from viewport to something else while drawing pointcloud. documentation about drawing to viewport is kinda non existent…


(stephen_leger) #19

Hi carbon2,
bgl is able to draw over viewport and over any image.
No black magick here, in MesureIt, the code draw gl only part over a black empty image and then composite with regular render.
This way you may add gl over any regular render, regardless of render engine used.


(artao) #20

Sorry, no. It has only happened once, and I don’t remember exactly what series of steps I had done that resulted in that.
Any tips on using those vertex colors as the source for volumetric colors?
What I’m trying to do is use point clouds of fractals to create volumetrics in Blender, and really kinda need the colors from the fractals as well.