# Pass vertexBuffer-like data to shadestyle code

**URL:** <https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201>\
**Category:** How to?\
**Created:** [February 11, 2021, 3:41pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201 "2021-02-11T15:41:41Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 11, 2021, 3:41pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/1 "2021-02-11T15:41:42Z")

</div>

What is the best way to pass a sequence of consistently formatted data as a shadestyle parameter? (or some other way entirely)  
I want to be able to iterate over it in the fragmentTransform, but it is more than just a single type that I can put in an array.  
What is the best (fastest) way to do this?  
(Currently I am using multiple arrays of equal length)

---

<div class="post-metadata">

**Author:** ![ricardo](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/ricardo/32/8_2.png) [@ricardo](https://openrndr.discourse.group/u/ricardo)\
**Post date:** [February 13, 2021, 10:12am UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/2 "2021-02-13T10:12:31Z")

</div>

[This](https://guide.openrndr.org/advancedDrawing/customRendering.html) entry in the guide is what you’re looking for. You can pass custom attributes as `attribute("factor", FLOAT32)`and access it in the vertexTransform as `a_factor` and in the fragmentTransform as `va_factor`. If you use instancing, then you’ll get a value back from it. In the case you don’t use instancing it will be an array afaik.

---

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 13, 2021, 11:43am UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/3 "2021-02-13T11:43:13Z")

</div>

My problem is I’m already using instancing, but I want every instance to be able to access the entirety of several arrays, some of which are arrays of floats, which can’t be passed as a parameter afaik

---

<div class="post-metadata">

**Author:** ![ricardo](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/ricardo/32/8_2.png) [@ricardo](https://openrndr.discourse.group/u/ricardo)\
**Post date:** [February 13, 2021, 1:29pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/4 "2021-02-13T13:29:09Z")

</div>

According to the [source code](https://github.com/openrndr/openrndr/blob/2a0b7da7307a663a91b73d2e31290410c7d25fcf/openrndr-core/src/main/kotlin/org/openrndr/draw/ShadeStyle.kt#L133) you can pass uniform arrays.

---

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 13, 2021, 2:10pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/5 "2021-02-13T14:10:35Z")

</div>

I completely missed the overload with `DoubleArray`. Thanks for linking that. I was trying to use `toTypedArray` and it was not working.

---

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 13, 2021, 2:21pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/6 "2021-02-13T14:21:18Z")

</div>

Actually, the overload with DoubleArray isn’t available for me. I am using openrndr 0.3.44. Do I need to update or is something wrong for me?

---

<div class="post-metadata">

**Author:** ![ricardo](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/ricardo/32/8_2.png) [@ricardo](https://openrndr.discourse.group/u/ricardo)\
**Post date:** [February 13, 2021, 2:44pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/7 "2021-02-13T14:44:09Z")

</div>

According to [git blame](https://github.com/openrndr/openrndr/blame/2a0b7da7307a663a91b73d2e31290410c7d25fcf/openrndr-core/src/main/kotlin/org/openrndr/draw/ShadeStyle.kt#L231) it was added 19 days ago and the last release candidate version is 23 days old, ergo you need to use the current code on `master` branch. You can check [this](https://github.com/openrndr/orx#create-and-use-local-builds-of-the-library) short description on how to set that up.

---

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 13, 2021, 4:16pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/8 "2021-02-13T16:16:00Z")

</div>

Thank you, that worked, however one of the other changes in the snapshot are causing me trouble.  
The `Application.cursorVisible` property used to prevent the cursor from moving, whereas now if you move it too far, it comes out the side of the window. I can’t find a way to cause the old behavior, will I have to just implement this myself?  
Sorry for the constant questions, if there is a correct place to ask this please let me know.

---

<div class="post-metadata">

**Author:** ![edwin](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@edwin](https://openrndr.discourse.group/u/edwin)\
**Post date:** [February 15, 2021, 3:07pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/9 "2021-02-15T15:07:59Z")

</div>

This is the right place to ask questions! Personally I am more responsive on our Slack but I try to get the Discourse ingrained in my system.

I changed the `cursorVisible` behavior after reading this: [How do I change the cursor image (or stop cursor jumping back to centre)?](https://openrndr.discourse.group/t/how-do-i-change-the-cursor-image-or-stop-cursor-jumping-back-to-centre/176) . I didn’t expect this to be a desired feature but I understand it is now. I will look into something that serves both.

---

<div class="post-metadata">

**Author:** ![ricardo](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/ricardo/32/8_2.png) [@ricardo](https://openrndr.discourse.group/u/ricardo)\
**Post date:** [February 15, 2021, 4:10pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/10 "2021-02-15T16:10:10Z")

</div>

Like @edwin said it’s the right place! Here’s the [slack](https://openrndr.slack.com/) link. Just create new posts when the question diverges from the current, because then you can tag one of the replies as the answer to the post and help other users with the same questions.

---

<div class="post-metadata">

**Author:** ![edwin](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@edwin](https://openrndr.discourse.group/u/edwin)\
**Post date:** [February 15, 2021, 10:02pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/11 "2021-02-15T22:02:38Z")

</div>

[Add disableCursor support · openrndr/openrndr@96a7ba6 · GitHub](https://github.com/openrndr/openrndr/commit/96a7ba6cfcae6f11e5883acacec409f3229c4920) adds the old mode back in. This can be enabled through `disableCursor = true` in `configure {}`

---

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 16, 2021, 2:39am UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/12 "2021-02-16T02:39:48Z")

</div>

Thanks for getting this out so fast

---

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 16, 2021, 2:48am UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/13 "2021-02-16T02:48:53Z")

</div>

Would it be possible to also have this as a property of Application so that it can be toggled during runtime?

---

<div class="post-metadata">

**Author:** ![edwin](https://avatars.discourse-cdn.com/v4/letter/e/73ab20/32.png) [@edwin](https://openrndr.discourse.group/u/edwin)\
**Post date:** [February 27, 2021, 3:33pm UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/14 "2021-02-27T15:33:58Z")

</div>

> <https://github.com/openrndr/openrndr/commit/4af2e2bb0a27d46f4375065d19c2f83f6aa7e7d2>

You can now set `hideCursor` and `cursorHideMode` in the configuration and at run-time. `disableCursor` has been removed to make way for an api that is compatible with the old one.

---

<div class="post-metadata">

**Author:** ![Ouroboros](https://avatars.discourse-cdn.com/v4/letter/o/67e7ee/32.png) [@Ouroboros](https://openrndr.discourse.group/u/Ouroboros)\
**Post date:** [February 28, 2021, 2:54am UTC](https://openrndr.discourse.group/t/pass-vertexbuffer-like-data-to-shadestyle-code/201/15 "2021-02-28T02:54:17Z")

</div>

This is a really good solution, thanks for doing this.
