# \[SOLVED\] Apply a shader to a geometry

**URL:** <https://discourse.processing.org/t/solved-apply-a-shader-to-a-geometry/4556>\
**Category:** Coding Questions\
**Created:** [October 17, 2018, 10:53am UTC](https://discourse.processing.org/t/solved-apply-a-shader-to-a-geometry/4556 "2018-10-17T10:53:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmichelini](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fmichelini/32/1983_2.png) [@fmichelini](https://discourse.processing.org/u/fmichelini)\
**Post date:** [October 17, 2018, 10:53am UTC](https://discourse.processing.org/t/solved-apply-a-shader-to-a-geometry/4556/1 "2018-10-17T10:53:53Z")

</div>

I’m currently trying to add a shader to a 3D geometry, but it gets applied to the canvas instead.  
I can’t understand what I am missing, any help would be very appreciated.

Here’s my code: [https://codepen.io/kekkorider/full/yRvbzm/](https://codepen.io/kekkorider/full/yRvbzm/)

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 17, 2018, 1:37pm UTC](https://discourse.processing.org/t/solved-apply-a-shader-to-a-geometry/4556/2 "2018-10-17T13:37:02Z")

</div>

i just try that first time, but  
https://codepen.io/dollee/embed/preview/XEdqyM?height=300&slug-hash=XEdqyM&default-tabs=js,result&host=https://codepen.io  
works, and when you include  
`orbitControl();`  
and exchange  
`rect(0,0,width,height);`  
with  
`box(40);`  
ok

---

<div class="post-metadata">

**Author:** ![fmichelini](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/fmichelini/32/1983_2.png) [@fmichelini](https://discourse.processing.org/u/fmichelini)\
**Post date:** [October 17, 2018, 2:44pm UTC](https://discourse.processing.org/t/solved-apply-a-shader-to-a-geometry/4556/3 "2018-10-17T14:44:29Z")

</div>

Thanks for your reply @kll

I managed to figure out what was the problem: the vertex shader was totally wrong.  
First i needed the `uProjectionMatrix` and `uModelViewMatrix` uniforms, than I had to calculate `gl_Position` with this formula:

```auto
gl_Position = uProjectionMatrix * uModelViewMatrix * vec4(aPosition, 1.0);

```

Not it’s working like a charm!
