Pointclouds in TouchDesigner - 2019-11-30 12:37

Pointclouds in TouchDesigner

Link to main site

great tut,
what about converting heightmaps or TOPs into pointclouds following the same approach used to covert SOPs? I’m trying to figure out a proper way to edit the CHOP shuffle script with no success.

Any hints?
Best

Hi Franz,

if they are already in the TOP domain you could just use them accordingly - maybe though I misunderstand what you are doing.

Best
Markus

Hi Markus,

I’m sorry my question was inaccurate; I’m not looking for generic displacement techniques,
instead I’m looking for a method to transform a regular image or heightmap in a proper Point Cloud matrix following the same approach used in the tut with SOPs, but this time using TOPs.

This could be useful for example, to apply textures to “napoleon” model or other *.ply / *.obj stuff.

Am I missing or misinterpreting somenthing?

Hey Franzrosati,
have a look at this little component.
It has an IN for black and white heightmaps and saves out EXR pointclouds.
Give it a try and let me know if it works for you. It is working for me in Build 33840 (experimental)
An Issue I have to think about for a moment is that the resulting Pointcloud is square, not in the proportion of the input Heightmap. I have an idea how to fix that and if it is right, will post an update…

Best
Stefan

MX_HeightMap_to_Cloud_2

So the problem is, that the aspect ratio of the source image has to be calculated into the pointcloud file.
It made a quick fix for the example image, not sure if that works for all aspects though.

MX_HeightMap_to_Cloud_3.tox

ah! Now I get it - the reorder is absolutely the right approach.

btw If you turn on Dither on the 2 Ramps, the points are scattered a bit and it removes the “gridedness” of the pointcloud…

Cheers
Markus

awesome!
So simple and effective, I was stuck in the reordering process trying to solve with some GLSL but this is perfect!
Also: new TOPs display mode rocks.

You can then use the Point Transform COMP in the Point Clouds tab in the palette to do a 3D transform on each point. It’s second input is a weight factor per-point that you would put in the red channel, leading to amusing tangents.

thanks Greg,
I’ll port everything on the experimental version soon, at the moment I’m still working on the standard version

Great Tutorial, but I’m stuck with some trouble with the conversion of the obj to the Open-exr, when I transform the null to sopTo I got the warning " Unknown attribute ‘N’ ", Any hints to how to fix it?
Thanks

Hey,

it seems like that the Normal Attributes are assigned as vertex and not point attributes.
Adding an Attribute SOP beforehand and enabling Create Normals should fix that.

Cheers
Markus

Thanks Snaut, It work perfectly.

I know I’m a bit late to the party, but I ran into a problem with the tutorial. I was following along with it, and I just want to say, you do a GREAT job of explaining WHY you are taking certain steps that is VERY helpful.

Anyways, I’m at the point where I’m trying to normalize the values coming out of the point cloud file that you walk through creating, the .EXR. And inside the normalization component, the point cloud shows up in the GLSL shader, but the point locations are “blurred”, so in the tutorial you say to go inside the GLSL shader properties, and change the option “Input extend mode UV” from “zero” to “Hold.” In the tutorial, this fixes the point cloud, but in my example, all the points just disappear. I went back and I double checked settings to make sure I did it right, and all my images and property settings and GLSL code are copied just like you do in the tutorial.

Screen Shot 2020-04-02 at 8.23.52 PM|690x426

Then, I decided to try and load up the assets to the class to see if I could figure out the guts without bothering anybody. The first thing I did was use your exported .EXR file in my own project to rule out my .OBJ conversion process, but your file gave me the same problem with disappearing points as stated above, so I figured it was something with the GLSL code or something else. So the next step I took was to check out your GLSL code, but I must have a different version than what this was originally made with, because I get some GLSL errors from some syntax errors, like "ERROR: 0:11: ‘input’ : Reserved word. "

I would be incredibly grateful for any help, or nudge in the right direction, as I REALLY want to figure this out. I’ve spent the last 2 weeks diving head first into Touch Designer, and loving it so far!

napolean.7.toe (13.1 KB)

Hi @sargentpilcher,

very happy to hear that you are enjoying TouchDesigner!

I’ve updated the git and fixed the issue with name input in the shader - so that shouldn’t be a problem anymore.

Then I found a change that I hadn’t thought of and fixed it as well: The alpha channel in the TOP viewer is now used as a kind of display flag for each point if in the point viewer mode. Hence with the adjustments, alpha turns out to be 0 and therefor Napoleon disappears.
So if you add alpha to the color at the end of the shader:

// Example Pixel Shader

// uniform float exampleUniform;

out vec4 fragColor;
void main()
{
	vec4 posInput = texture(sTD2DInputs[0], vUV.st);
	vec4 minInput = texture(sTD2DInputs[1], vUV.st);
	vec4 maxInput = texture(sTD2DInputs[2], vUV.st);
	
	// center everything
	vec4 centerOffset = (maxInput - minInput) / 2.0 + minInput; 
	vec4 color = posInput - centerOffset;

	// we need to set alpha to 1 in order for the points to show up in the viewer.
	color.a = 1;
	fragColor = TDOutputSwizzle(color);
}

everything should work as expected.
I have to step through and make some adjustments to the video to clarify these changes…

Best
Markus

1 Like

Thank you so much, it worked perfectly! I got it working now, this is badass!!

Hello, thank you for the tutorial.

I am trying to use your tutorial for my own model but I’ve gotten the errors in my sopto “Unknown attribute ‘N’” and “Unknown attribute ‘UV’”.
I tried the attribute create before the null to fix the " Unknown attribute ‘N’", and while it did fix the problem it also rounded out my model.
I exported my .obj file from maya

Hi @DeAndrea,

in the current version of TouchDesigner you can load obj files directly into the Point File In TOP and make use of the Point File Select to fetch other geometry attributes like normals or textures from there. The whole conversion is not necessary anymore.

Cheers
Markus

Hi! Thank you so much for the tutorial im new to TD and i actually understood almost everything well and gave me a solid general understanding of point clouds! However with the new version im a bit confused, after loding another obj file directly into the Point File In and using a Point File Select i get nothing on the screen? in the rgb options i only get x y z and no normals. Can you please enlighten me on what’s happening and how to fix it? Thanks for the hard work again.

Hi @Raghidj,

if you load an obj that comes without any Normals attached, you would have to go through the manual process to create those normals using the File In SOP
The File In SOP has a parameter Computer Normals if None Exist which you should be toggling on. From here you can follow the instructions in the video on how to convert from SOP to CHOP to TOP and then save the result as a multilayered exr file.
In the video I am also creating a glsl shader to scale the pointcloud and move into the origin, but all of this is now available through a Palette component: PointClouds/pointTransform. The Post page let’s you scale and transform the model properly.

Hope this helps
Cheers
Markus