clojure-art

meow 2015-12-20T14:55:36.000062Z

@mikera: Saw your twitter reply. Gonna take a look at clisk.

meow 2015-12-20T15:27:22.000063Z

@mikera: Would love to chat about this with you. Also interested in how to improve mesh performance. You've worked a lot on matrices and such. I want to really push the limits on mesh subdivision modeling and could really use your expertise.

2015-12-20T15:27:57.000064Z

Sure.... a lot of performance stuff depends on representation though

2015-12-20T15:30:10.000065Z

The reason that core.matrix+vectorz-clj is 10-20x faster than core.matrix+clojure vectors is by using unboxed primitives with Java arrays rather than the much more heavyweight approach of boxed numbers in persistent vectors

2015-12-20T15:30:43.000066Z

Upshot is: you'll probably need to look at alternative representations if you really want max performance

meow 2015-12-20T15:40:20.000067Z

Right. And I'd rather not reinvent the wheel there as I don't really have the experience or expertise to do so.

meow 2015-12-20T15:40:57.000068Z

Have you looked at how the gmesh is represented in http://thi.ng?

meow 2015-12-20T15:41:41.000069Z

Pretty simple use of clojure sets and vectors and a Vec3 type.

meow 2015-12-20T15:43:05.000070Z

Am curious to know if something similar could be constructed using core.matrix+vectorz-clj?

meow 2015-12-20T15:45:05.000071Z

@mikera: I'm adding clisk to my cad code so I can play with it more based on your example. Thank you for making it so easy. :simple_smile:

meow 2015-12-20T15:53:26.000072Z

I guess what I'm really asking is can you recommend an alternative representation for polygon meshes that would support the type of manipulations I'm doing?

2015-12-20T16:09:11.000073Z

Well - I'd probably take a look at using something like a dense Nx3 matrix to represent a large set of points. Would be backed by a single Java array, so very fast for memory access, cache line efficiency etc.

2015-12-20T16:10:00.000074Z

If you want to translate / transform points in bulk that is probably going to be the most efficient representation

meow 2015-12-20T16:12:20.000075Z

Yeah, the catmull-clark smoothing function is a good example as it creates new vertices/faces/edges and "moves" previous ones.

meow 2015-12-20T16:13:57.000076Z

I also want to do more generative creation of meshes way beyond the simple stuff that I've been doing with platonic solids as seeds.

meow 2015-12-20T16:14:23.000077Z

I want to make use of the L-system and cellular automata code I worked on prior to this.

2015-12-20T16:14:30.000078Z

Makes sense. Basically you want arbitrary transformations on point clouds etc.?

2015-12-20T16:14:43.000079Z

And the ability to turn these into solids etc?

meow 2015-12-20T16:14:45.000080Z

And creation.

2015-12-20T16:15:06.000081Z

Yup makes sense

meow 2015-12-20T16:15:15.000082Z

Yes, I like the idea that they can be 3d printed in real life - so the mesh needs to be watertight, etc.

meow 2015-12-20T16:15:37.000083Z

But I also want to create immersive worlds of these things for VR.

2015-12-20T16:15:43.000084Z

You'll need to do quite a bit of index tracking too then

2015-12-20T16:15:58.000085Z

Since a lot of vertices will be shared

meow 2015-12-20T16:16:11.000086Z

Yes.

2015-12-20T16:17:45.000087Z

I guess some of this depends on how much you are willing to put up with mutability

meow 2015-12-20T16:17:49.000088Z

If you look at the gmesh in http://thi.ng it uses a "winged edge data structure" like the Wings3D modeling software. But that's just an overly fancy way of saying that it has some indexes to keep track of its data. There are faces, vertices and edges and everything else is an index.

2015-12-20T16:18:21.000089Z

Yup that is a good way of doing things

2015-12-20T16:19:14.000090Z

It also mirrors how a lot of the operations will actually go to the GPU

meow 2015-12-20T16:20:04.000091Z

I just used (op/colorize-clisk clisk/vnoise) on the latest shape I was playing around with. Cool. Got a new toy to play with. Thanks! :simple_smile:

2015-12-20T16:20:35.000092Z

Cool, enjoy! If you want interesting textures check out tweegeemee on twitter

2015-12-20T16:20:47.000093Z

Nearly all of these work as 3D textures

meow 2015-12-20T16:21:10.000094Z

Cursive can't resolve your namespace trickery, sadly. 😞

2015-12-20T16:21:45.000095Z

The only issue I see it that you will need to subdivide a lot if you want the finer details of the textures to show, since we are still only doing per-face colouring

2015-12-20T16:21:51.000096Z

Haha

2015-12-20T16:21:59.000097Z

Yes that is a bit of an evil hack....

meow 2015-12-20T16:22:22.000098Z

Yeah, I follow that tweegeemee bot - cool stuff.

meow 2015-12-20T16:24:13.000099Z

I plan to add per-vertex coloring at some point. Won't be hard to do - just have so many things on my todo list.

meow 2015-12-20T16:24:57.000100Z

And I'm still surprised how much I can achieve with just simple coloring of the face.

meow 2015-12-20T16:25:28.000101Z

So I'm still playing around with lowpoly and per-face coloring as interesting limitations.

meow 2015-12-20T16:27:44.000102Z

@mikera: What is your interest in all of this? Where are you trying to go with your work? And are you interested in any collaboration?

2015-12-20T16:28:40.000103Z

It's more of a fun sideline for me (my main work is around data science / machine learning). happy to collaborate though where I have time.

2015-12-20T16:28:58.000104Z

I also have an interest in game programming, so I'm interested in tools that may help this

meow 2015-12-20T16:31:59.000105Z

What I like about this is that its just a bunch of polygons - they can be used for 2d/3d rendering, printing, VR, games, etc.

meow 2015-12-20T16:32:19.000106Z

So I have an interest in all of that.

meow 2015-12-20T16:33:30.000107Z

What I want to do is create the building blocks that make it easy to create/manipulate/distort polygon meshes in an artistic/inventive way for use in a wide variety of applications.

meow 2015-12-20T16:36:42.000108Z

So if I wanted a high-performance "dense Nx3 matrix" as you recommended, where would be the best place to start? Is there anything similar that you could point me to?

2015-12-20T16:47:22.000109Z

Well the raw data structures are already there in vectorz-clj

2015-12-20T16:47:37.000110Z

something like

2015-12-20T16:47:46.000111Z

(use 'clojure.core.matrix)

2015-12-20T16:48:10.000112Z

(def points (new-array :vectorz [100 3]))

2015-12-20T16:48:48.000114Z

Then you can do something like

2015-12-20T16:49:22.000115Z

(defn translate! [pts dx] (add! pts dx))

2015-12-20T16:50:08.000116Z

And other similar bulk operations for scaling etc.

2015-12-20T16:52:00.000117Z

For subdivision etc. you'd need to track indices and "join" extra points onto the array as needed

meow 2015-12-20T16:52:59.000118Z

In http://thi.ng the main function is add-face which updates all the indexes as each face is added.

meow 2015-12-20T16:53:33.000119Z

Everything is immutable so any mesh op creates a new mesh.

2015-12-20T16:54:04.000121Z

Immutable is nice.... I think that's definitely the best way to go for the overall API

meow 2015-12-20T16:54:20.000122Z

A face is a vector of points in counter-clockwise order.

2015-12-20T16:54:27.000123Z

You probably want mutability for some of the internal calculation however, that would be my guess

2015-12-20T16:55:05.000124Z

If performance is an important concern, that is :simple_smile:

meow 2015-12-20T16:55:45.000126Z

That's what I haven't really done with Clojure.

meow 2015-12-20T16:56:11.000127Z

I've only been working with clojure for 7 months now.

meow 2015-12-20T16:56:33.000128Z

And haven't done any Java - mostly Python.

meow 2015-12-20T16:57:10.000129Z

Some js, and lots of other languages before Python, but mostly OO stuff.

meow 2015-12-20T16:58:25.000130Z

I will look at vectorz-clj and do some experimenting.

2015-12-20T16:58:35.000131Z

Mutability isn't very idiomatic in Clojure for sure

2015-12-20T16:58:57.000132Z

But it is sometimes justified if you really need the best performance

2015-12-20T16:59:18.000133Z

in core.matrix the API prefers immutable operation like (add a b)

2015-12-20T16:59:37.000134Z

But there are mutable vesions for people who need them, like (add! a b) which mutates a

meow 2015-12-20T17:03:48.000135Z

Sweet. I will definitely check it out.

meow 2015-12-20T17:04:35.000136Z

Gonna be away for a while soon but will look at this later today or tomorrow.