# Chapter 19, large amount of textures?

**URL:** <https://forums.kodeco.com/t/chapter-19-large-amount-of-textures/205942>\
**Category:** Metal by Tutorials\
**Created:** [August 17, 2024, 12:24pm UTC](https://forums.kodeco.com/t/chapter-19-large-amount-of-textures/205942 "2024-08-17T12:24:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![charleskerr64](https://s3.amazonaws.com/cdn.raywenderlich.com/community/forum-assets/noun-game-ghost-878668.png) [@charleskerr64](https://forums.kodeco.com/u/charleskerr64)\
**Post date:** [August 17, 2024, 12:24pm UTC](https://forums.kodeco.com/t/chapter-19-large-amount-of-textures/205942/1 "2024-08-17T12:24:28Z")

</div>

I want to do something like Chapter 19, using a height map to generate maps. However, I have significantly more “terrain types”, so need to pass more then 3 texture types. Is there a way to pass an array of textures or something? Or must I pass each one as a parameters (and limited to the number of buffer indices, 31)) ?

---

<div class="post-metadata">

**Author:** ![caroline](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caroline/32/111867_2.png) [@caroline](https://forums.kodeco.com/u/caroline)\
**Post date:** [August 19, 2024, 12:47am UTC](https://forums.kodeco.com/t/chapter-19-large-amount-of-textures/205942/2 "2024-08-19T00:47:26Z")

</div>

You can use argument buffers with a resource heap, which is described in Chapter 25. This is rather 🤯 and needs a lot of concentration. I would suggest that as well as following Chapter 25, you watch all the Apple Metal videos on Argument Buffers and also Resource Heaps.

There is a good amount of Apple sample codes too. You could start with [Encoding Argument Buffers on the GPU | Apple Developer Documentation](https://developer.apple.com/documentation/metal/buffers/encoding_argument_buffers_on_the_gpu) where the app loads 66 textures into a heap.

 ![Screenshot 2024-08-19 at 10.47.02 am](https://files.chunter.kodeco.com/original/3X/7/9/79cd1a25befe212773731f2ec769df75e8cd9fe2.jpeg)

---

<div class="post-metadata">

**Author:** ![caroline](https://assets.chunter.kodeco.com/user_avatar/forums.kodeco.com/caroline/32/111867_2.png) [@caroline](https://forums.kodeco.com/u/caroline)\
**Post date:** [August 19, 2024, 1:00am UTC](https://forums.kodeco.com/t/chapter-19-large-amount-of-textures/205942/3 "2024-08-19T01:00:13Z")

</div>

You can also use `texture2d_array` instead of argument buffers, which might be easier to start with.

Chapter 31 has a project which renders rocks, with one of three random textures. These textures are held in a `texture2d_array`.

 ![Screenshot 2024-08-19 at 10.55.27 am](https://files.chunter.kodeco.com/original/3X/9/1/9188f319392557ce78b7e7c82742000d446812ac.jpeg)

In the screenshot, the current rock is being rendered with index 1 in the array.

Take a look at **Nature.swift** , `TextureController.loadTextureArray(textureNames:)` and **Nature.metal**.
