Open CL Structure output to GL Point structure?

gutsblow's picture

Hello, I have a mesh and I am wondering if we can write a structure using open cl based on those vertices for gl point structure. I tried but it didnt work. Any ideas? Thank you in advance.

cwright's picture
Re: Open CL Structure output to GL Point structure?

can you provide the kernel you used, or the resulting structure?

have you tried using a standard Mesh Renderer, and the Polygon Mode patch (so turn vertices into points)?

gutsblow's picture
Re: Open CL Structure output to GL Point structure?

Hello,

The reason why I didn't use GL tools polygon mode patch is, I want to connect the points with line structure with a conditional.

It is basically iterated gl points with voise values limited by a range patch. The lines are gl lines which disable if the distance between the two points exceeds a certain distance. I implemented it with iterators in the video above, but it is very slow. I also tried iterating only the noise values and outputting as a structure which didnt work becaue of a bug in gl tools.(check my previous post). So I am thinking may be its possible to use an open cl kernel to build a structure so that I can render gl point structure and gl line structure. I really appreciate yo taking time for this. Thank you!

gtoledo3's picture
Re: Open CL Structure output to GL Point structure?

You should probably upload the code, or if privacy is desired, send it into Chris maybe?

Here's my take... I'm not sure how you could be feeding a mesh creator output (you do say "I have a mesh"), to GL Point, or if that's exactly the way that something like that is intended to work. A mesh output doesn't necessarily output a structure...it outputs QCMesh! An OpenCL Kernel is another case.

For what it looks like you're doing, I don't even think that Apple themselves particularly intends for that kind of thing to be done with OpenCL (but maybe it can be done anyway?) Look at the Mouse Ribbon example.

In that example, Javascript is used to create vertices to feed a mesh creator, which is then linked to a Mesh renderer. Now, look at the qtz I'm attaching.

Check off the Kineme GL Quad, then checkoff the OpenCL mesh setup... Look familiar? I threw in the points and lines for fun. ( It should open with the Kineme Quad as default... looking just like the CL Mesh).

As is, I don't see Apple using the actual mesh output to write coordinates in the way that you are conceiving of this working; not to say it isn't possible.

Consider the fact that I'm running a Kineme GL Quad coming off of the Javascript in this attachment, avoiding OpenCL altogether! Looks pretty much like the OpenCL mesh renderer in this scenario, doesn't it! Again, do a little a/b on this.

This is an interesting case of a non-Apple patch being more compatible cross system for a given function than the Apple route. It's not as if I can throw in an OpenCL plugin that will make this work on older OS versions... but I can do it with the Kineme GL Tools, and javascript.

OpenCL has some really killer possibilities... and I think it would be really cool to see something like a Collada file turned into a point structure... but if you just want a point look on a mesh, Chris's comment is a big indicator of the process you may want to consider - just putting a model in a GL Tools Polygon mode patch, if you want vertices to show as points. I'm not sure if there's a reason to turn the mesh into a structure, and then feed that into a GL Point structure renderer, when you can put the model inside of a Polygon mode environment in a few second's time.

You can also consider using the Mesh Vertices display, which looks kind of like a Kineme GL Point with the anti-aliasing setting set to false.

gutsblow's picture
Re: Open CL Structure output to GL Point structure?

Hello George,

First of all thank you for your detailed reply. What I intended to do is, take any mesh (anything) and get its vertices using the mesh component and then create a structure using OpenCL kernel. I observed that OpenCL outputs data as structures and it contains arrays too. So my idea is to connect them directly to GL Point without the need of javascript. More accurately, I want to add random noise per vertex and output it as a structure so that I can render it with GL Point/GL Line. I am also uploading the actual QC with iterators so that you can get a better idea (Mind, its very very slow and the qtz is a bit messy) of what I am talking. Also, I would love to hear any suggestions of doing this in a better way as the speed is so bad. Can it be done with GLSL? Thank you in Advance.

PreviewAttachmentSize
CubeLock.qtz36.27 KB

gutsblow's picture
Re: Open CL Structure output to GL Point structure?

Actually, everything you suggested works amazing for wireframe/points but not like my case where a point is connected to every other point in the composition with a gl line. Later on, I added a conditional so that it is connected to every other point which is less than a certain distance from it. I really suck at explaining things but hopefully this should help you understand and have a look into the composition. Thank you!

gtoledo3's picture
Re: Open CL Structure output to GL Point structure?

Absolutely man! I look at the OpenCL everyday... it actually requires learning which is pretty cool! It had gotten to where in QC Land I had tapped out most of the patches, so it had me spending time learning Objective-C and Cocoa, and more about 3D modeling (though there are so many stock patches that I can even forget ones exist that I've even USED before... this happened to me today actually!)... so the OpenCL is kind of a great experience to see exactly what can and can't be done!

I'm going to have some pleasure in checking this spin of what you are doing out, as I thought your original render/take on this was AWESOME looking...really eye catching. I almost question the need to change it, but I can see wanting to figure out if there's a big performance gain.

Even the grid examples actually use Javascript to make the Mesh, and once it's a created mesh, it seems like the paradigm is just to deform it with additional OpenCL kernels, or introduce texturing, then feed it to the Mesh Render. It will be interesting to see exactly what can be pulled off... for me it's just a matter of there only being so much time in te day to be able to spend on it :)

gutsblow's picture
Re: Open CL Structure output to GL Point structure?

Thank you! The reason why I wanted to change the current composition to the "structure" format because, I am planning on exporting the raw position data and it is not possible if I have consumers in my iterators. Thus, I created a structure composite of iterated noise values, but due to a bug in GL Tools QC crashes everytime I input the structure to gl point structure (check my previous thread about GL Tools bug,QTZ attached). But, after researching around for a while, I am thinking about the possibilities of running the whole simulation in realtime(that would be awesome by the way)! I hope that's not something too much to ask for...

gtoledo3's picture
Re: Open CL Structure output to GL Point structure?

Hmm. I'm not 100% sure, because I haven't followed the other thread ( I remember looking at the qtz for a few minutes...). I haven't used published outputs on the iterator much at all, beyond to see it work.

This had me curious to experiment some with using the output function on the iterator. I don't know if this is really helpful in any way to you... It makes a structure out of the values coming out of an iterator. It doesn't look quite like what I remember your render looking like, but it's been an interesting little foray in looking at publishing the outputs of an iterator.

PreviewAttachmentSize
Cube Lock With Published Iterator Outputs.qtz45.01 KB

gutsblow's picture
Re: Open CL Structure output to GL Point structure?

That looks really beautiful by the way, especially after 50 sec of patch time it looks really elegant. May be a nice screensaver!

But coming back to the topic, after looking into the composition, I figured that you are taking only one iterated value from the iterated output and are feeding into the javascript patch as float values but not as structures. In the attached composition, I gave the structure from the iterator as an input to the javascript patch and then to the gl point patch. But, I can't get it to work with three dimensions.

Now, after working with QC or a while now, I wish there is a way to iterate things other than the javascript patch to create structures. Javascript is painfully slow. I implemented this patch in processing with 200 particles and I was able to achieve 40-50 fps(opengl mode). Usually, QC is very fast compared to processing, until the point where i have to use javascript. Even in the composition you sent me, I get somewhere around 8-20 fps.

PreviewAttachmentSize
iteration_structure_0.qtz6.67 KB

usefuldesign.au's picture
Re: Open CL Structure output to GL Point structure?

I'm kind of coming in on this sideways b/c i'm still on QC3 (oh the pain ;) ) but it's a topic I come back to all the time when I have a burst of QC activity. Taking a 3D model and parsing it to data structures for realtime animation.

I avoid Javascript too for fps. I have been considering pre-processing point data in JS to make edge ("line") data though and saving the structure with file tools. OpenCL looks like the perfect tool for fast data processing (like noise or conditional based sorting) and separating data into useful sets and structures (points, lines and faces).

So far I've been doing my processing (sort by distance etc) in Excel and then parse to XML and bring it into QC that way. It's good to look at all the data in one window to get a heads up — but slow also. Working in Excel has become tedious and I'm definitely looking to take a step up from that. I started a correspondence with a sketch-up model warehouse contributor and he pointed out DXF files can be made in plain text same way as XML but include edges and faces. Import to 3D app then export as collada or other.

I am actually trying to go the other way, from a 3D model to point, edge & face sets I can handle in arrays/structures. Spent the last few days looking into CIFilters and multi dimensional geometry* to try and get an appreciation of the possibilities of GPU based processing but it's all a bit too deep so far to see a point of entry. :/

I'm wondering, for example can I process a line (as defined by two points) in a CIFilter so that a set of lines are drawn from a determined point to sub-division points on the inputted line? Or does CIFilter only process on a by pixel basis?

I know Kineme3D and SL Meshes allows the part by part animation of scenes but I prefer to work a more primitive level to attack particular visualisation methods (not having the skill or stomach for GLSL) and methods to generate point and line data from models need to be established for sure, gutsblow. Feels like it's coming soon. I'm going to try exporting to DXF and then parsing to XML this week. SL and OpenCL should be the best solution it's just a matter of getting the structures talking to each other, right? Can't be that hard. That's what OpenCL is about it's not just for Meshes.

Here's a basic example of bringing in point data instead of a 3D model using Kineme3D (or mesh for SL). The point data came from Alex at Tangible who started a 3D thread that's been ongoing: http://kineme.net/Discussion/GeneralDiscussion/GeodesicDome The excel file comparing point to point distances is 10Mb so wont bother uploading unless anybody asks for it.

Change the "GD Normalized… Data.txt" file to .xml extension. (Kineme.net doesn't allow xml uploads).

*Found a good maths site though: http://www.math.umn.edu/~nykamp/m2374/readings/

PreviewAttachmentSize
RAW data II.qtz10.59 KB
GD Normalised 3D Point Data.txt30.81 KB