# beginShape and custom shaders

**URL:** <https://discourse.processing.org/t/beginshape-and-custom-shaders/35021>\
**Category:** Coding Questions\
**Created:** [February 7, 2022, 10:30am UTC](https://discourse.processing.org/t/beginshape-and-custom-shaders/35021 "2022-02-07T10:30:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matthewortega](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matthewortega/32/309_2.png) [@matthewortega](https://discourse.processing.org/u/matthewortega)\
**Post date:** [February 7, 2022, 10:30am UTC](https://discourse.processing.org/t/beginshape-and-custom-shaders/35021/1 "2022-02-07T10:30:14Z")

</div>

I have written a custom shader to be applied to shapes, and is applying correctly. For some reason, if I create custom shape using beginShape() the shader is not applied even though it hasn’t been reset. Any pointers on what is need to apply the same shader to custom shapes would be appreciated. Here is the sketch:

https://openprocessing.org/sketch/1471103/embed/?

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [February 7, 2022, 11:03pm UTC](https://discourse.processing.org/t/beginshape-and-custom-shaders/35021/2 "2022-02-07T23:03:48Z")

</div>

Shaders do work with beginShape/endShape, so the problem is probably with your shader logic. You are most likely making a bad assumption about vertex coordinates or something:

https://editor.p5js.org/Kumu-Paul/full/2Wm-GJx3s

---

<div class="post-metadata">

**Author:** ![KumuPaul](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kumupaul/32/13072_2.png) [@KumuPaul](https://discourse.processing.org/u/KumuPaul)\
**Post date:** [February 7, 2022, 11:51pm UTC](https://discourse.processing.org/t/beginshape-and-custom-shaders/35021/3 "2022-02-07T23:51:19Z")

</div>

Specifically it looks like the issue is that you aren’t specifying UV coordinates for your vertices.

---

<div class="post-metadata">

**Author:** ![matthewortega](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/matthewortega/32/309_2.png) [@matthewortega](https://discourse.processing.org/u/matthewortega)\
**Post date:** [February 8, 2022, 10:58am UTC](https://discourse.processing.org/t/beginshape-and-custom-shaders/35021/4 "2022-02-08T10:58:16Z")

</div>

@KumuPaul thanks a bunch, seems to have fixed it. In Processing java I believe you don’t need to supply the UV coordinates, maybe autogenerated? Anyway, happy its not a larger bug. 🙂
