# How to add a texture using GLSL shader

**URL:** <https://discourse.processing.org/t/how-to-add-a-texture-using-glsl-shader/36177>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [April 6, 2022, 7:57pm UTC](https://discourse.processing.org/t/how-to-add-a-texture-using-glsl-shader/36177 "2022-04-06T19:57:38Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mxbr632](https://avatars.discourse-cdn.com/v4/letter/m/e9bcb4/32.png) [@mxbr632](https://discourse.processing.org/u/mxbr632)\
**Post date:** [April 6, 2022, 7:57pm UTC](https://discourse.processing.org/t/how-to-add-a-texture-using-glsl-shader/36177/1 "2022-04-06T19:57:38Z")

</div>

Hi everyone,

Currently I’m trying to realize a pyramid using Ulam spiral ([https://youtu.be/a35KWEjRvc0?list=PLRqwX-V7Uu6ZCtELDdShWS5oZSA3z3HsO](https://youtu.be/a35KWEjRvc0?list=PLRqwX-V7Uu6ZCtELDdShWS5oZSA3z3HsO) , adapted in a P3d figure) for the pattern. The pyramid is composed of cubes representing a number. If the number is prime, the cube will appear of a certain color, if it is abundant, of another color… We are asked to make a texture where numbers are displayed. For this, we used PGraphics, and we get this result.

Pyramid and PGraphics:

 ![model](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/5/1/51ee03134101ee50efe9af502ad1de23f5332471.jpeg)

However, the teacher insisted on using the shader mode, with shaders written in GLSL for displaying the textures. However I don’t really have an idea how to do it. This must have been discussed once in lecture (not recorded) but I don’t really remember.

If anyone has a tutorial or an idea of how to get started right, it would be very helpful.

P.S: If this works, I could move on to the last step which is picking. Normally we have two figures at the end, and if we click (or mouse over) a block representing a number, the block of the other figure representing the same number will be highlighted.

Thank you so much for your time,  
Sincerely.
