TOP as a source for instancing geometry?

Hi,

I’m thinking about making a noise applied to a SOP, that is a source for instancing faster.

SOP noise is pretty slow for big objects, so I’m converting the SOP object to a TOP (RGB channels = XYZ positions) where a fast GLSL transform can be applied. Then however I have to convert the TOP to a CHOP which is second slow operation I’m trying to avoid. Is this possible to make TOP->CHOP conversion faster, or connect a TOP as a source for instancing?

These days I’m never 100% clear on what folks are after - so pardon some thoughts that may or may not be on target.

First things first - you might first make sure that you’re using nextframe in your TOP to CHOP operation - that often makes a big difference in moving a texture to a CHOP.

Before moving to a GL approach, I’d think about using a noise CHOP in conjunction with your point positions from a SOP. That would look like converting the SOP to a CHOP and then adding your noise transformation as a CHOP operation before instancing. Like all things, this has limitations, but you can do a few thousand samples in a noise CHOP before starting to bottle neck too much.
base_noise_with_CHOPs.tox (2.82 KB)

If that’s really not cutting the mustard you might try sampling a TOP first. Like you’ve mentioned, you could convert your SOP to a texture, combine with noise, then use a vertex shader to displace your instances. There are a few catches here to be wary of:

  • sampling is still a slow operation in the grand scheme of things, but it’s harder to see that slow-down
  • your shader will be more frustrating after 16000 instances. TOPs are limited to a 16000x16000 resolution (mostly a hardware limitation these days - though some cards support higher texture sizes) - that also means that the SOP you can convert into CHOP data will be constrained to 16000 points - unless you break up the geometry into multiple pieces. texture() lookups are fussy beasts and while your TDInstanceID() is provided as an integer, the texture() call takes a normalized vec2 for lookup. So you’ll need to think through how you’re handling your look up to correctly apply your transformation to your instances.That’s easier with grids, but harder more complex source geometry.
    base_noiseTOP_as_position.tox (4.64 KB)

If you need to avoid the bottleneck sampling you can always do the whole operation in your vertex stage. This is going to be a fast option, though it’s worth pointing out that the documentation about shader writing says:

derivative.ca/wiki099/index … _functions
I haven’t seen major slowdowns even when using on very dense meshes - but it’s still in the documentation. This approach could apply displacement to your instances based on their original location + the displacement - only worth pointing out that you could still use a SOP to CHOP method for extracting starting locations for your instances, then do the transformation in the vertex stage. This skips converting to a texture, and the limitation of texture resolutions on current GPUs.
base_built_in_noise.tox (4.76 KB)

Finally, unless you have a complex model that you’re instancing you could also think of using point sprites for this operation - it’s significantly cheaper in the long run and easier to set-up.

Fingers crossed that there’s an approach in here that will work for you.

Thanks Matthew I had no idea you could use GLSL to call instances. I was using the chop to instance this whole time. I’m a little unclear about how you went about sampling more than 16000 particles. It seems like the chop to top doesn’t handle full images, only a strip of pixels. Any advice on how to get past that limitation?

It’s on the crop page of the top to chop.

Here are some fast examples to see rows, columns, or full image.
base_top_to_chop.tox (2.02 KB)

@raganmd: I’m not building anything specific at the moment, I’m trying to understand possibilities and limits of instancing and noise.

The examples you attached are great and even answered one case I was asking about in another topic. I’m adding those to my little library of techniques. Thanks! :slight_smile:

You might also look over these:

matthewragan.com/make-some-nois … hdesigner/

vimeo.com/230346333

I think both of these might be interesting to you.