# Mobile (OpenGLES) rendering upgrades: occlusion culling, anisotropic filtering, 3D textures, shadows; plus new occlusion query demo

**URL:** https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764
**Category:** News
**Created:** [March 12, 2023, 6:23pm UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764 "2023-03-12T18:23:09Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 12, 2023, 6:23pm UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764/1 "2023-03-12T18:23:09Z")

</div>

| |
| |
| |

Our OpenGL and OpenGLES code is now more streamlined, which allowed to “unlock” various rendering features on OpenGLES.

This means we will use some features from OpenGL ES 3.0, if it is available:

- [Occlusion Culling](https://castle-engine.io/occlusion_culling), that is also showcased in a new demo [examples/viewport\_and\_scenes/occlusion\_culling](https://github.com/castle-engine/castle-engine/tree/master/examples/viewport_and_scenes/occlusion_culling).

- 3D textures (example data in [demo-models, look in texturing\_advanced subdirectory](https://github.com/castle-engine/demo-models)).

- Using glBlitFramebuffer to get FBO results to image.

- Modern way to query OpenGLES extensions by index.

- Fixed, and more efficient than ever on mobile, shadow maps using shadow samplers in OpenGLES 3. I already mentioned [shadow volumes and shaow maps improvements on mobile in past news](https://castle-engine.io/wp/2023/02/19/shadow-volumes-and-shadow-maps-work-on-mobile-opengl-es-and-we-have-a-new-tcastlerenderunlitmesh-utility-class/).

- Loading [DDS](https://castle-engine.io/x3d_implementation_texturing.php#section_dds) and [KTX](https://castle-engine.io/x3d_implementation_texturing.php#section_ktx) with explicit mipmaps (using `GL_TEXTURE_MAX_LEVEL`).

Note that we still _require_ only OpenGL ES 2.0. The OpenGL ES 3.0 features are optional for us.

Moreover:

- Anisotropic filtering is now supported on OpenGLES, through an [almost universally-available extension](https://www.khronos.org/opengl/wiki/Ubiquitous_Extension), just like on the desktop. See e.g. [anisotropic\_filtering](https://github.com/castle-engine/castle-engine/tree/master/examples/viewport_and_scenes/anisotropic_filtering) demo. (Yeah, we should have a more comfortable way to adjust anisotropic filtering visually — I have 2 ideas about this, will explore them.)

- We also fixed support for rendering shapes that require 32-bit indexes. While OpenGLES 2.0 guarantees only 16-bit indexes (OpenGLES 3.0 bumps it to 32-bit), we now automatically deal with it inside a renderer, if necessary doing additional processing to enable bigger meshes even for OpenGLES 2.0. This can be tested using [fps\_game](https://github.com/castle-engine/castle-engine/tree/master/examples/fps_game) on mobile.

---

<div class="post-metadata">

### Author: ![sledge](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/s/a587f6/32.png) [@sledge](https://forum.castle-engine.io/u/sledge)
#### Post date: [March 12, 2023, 7:18pm UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764/2 "2023-03-12T19:18:44Z")

</div>

So much progress !

I needed to search a bit. Does “Occlusion Query” also inculdes “Occlusion culling” ? From my understanding:

- OC = don’t draw objects that are outside the camera frame
- OQ = don’t draw objects that are behind others, that are not visible

Does CGE has both features ?

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 12, 2023, 10:52pm UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764/3 "2023-03-12T22:52:34Z")

</div>

The terminology we use is:

- “Occlusion Query” and “Occlusion Culling” are synonyms, in practice. They mean we remove objects obscured by others. E.g. if you look at a wall, and behind this wall is a monster, and you _would_ see the monster if only the wall was transparent, but the wall is opaque… the “Occlusion Query” and “Occlusion Culling” allow to not render the monster. See [Occlusion Query | Manual | Castle Game Engine](https://castle-engine.io/occlusion_query) . It is similar to [https://developer.nvidia.com/gpugems/gpugems/part-v-performance-and-practicalities/chapter-29-efficient-occlusion-culling](https://developer.nvidia.com/gpugems/gpugems/part-v-performance-and-practicalities/chapter-29-efficient-occlusion-culling) and Unity usage of the term.

- Hiding things that are not in “camera frame” is called “frustum culling”. This is also similar to Unity (and I guess all/most other 3D engines) usage of this term, from what I know.

CGE does:

- _“frustum culling”_ by default. You can control it using `TCastleScene.SceneFrustumCulling`, `TCastleScene.ShapeFrustumCulling` , see [Castle Game Engine: CastleScene: Class TCastleScene](https://castle-engine.io/apidoc/html/CastleScene.TCastleScene.html) .

- _“occlusion culling”_ if you activate it, following [Occlusion Query | Manual | Castle Game Engine](https://castle-engine.io/occlusion_query) (`RenderOptions.OcclusionQuery := true`). See new “examples/viewport\_and\_scenes/occlusion\_query” demo.

- note that we also have _“distance culling”_, esp. nice when you have dense fog that limits visibility beyond a certain distance. See “examples/viewport\_and\_scenes/fog\_and\_distance\_culling” demo.

---

<div class="post-metadata">

### Author: ![sledge](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/s/a587f6/32.png) [@sledge](https://forum.castle-engine.io/u/sledge)
#### Post date: [March 13, 2023, 8:11am UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764/4 "2023-03-13T08:11:48Z")

</div>

Okay. Got it. Thanks for making it clear 👍. “distance culling” is really something useful !

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [March 13, 2023, 9:58am UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764/5 "2023-03-13T09:58:01Z")

</div>

Note that, as I saw both Godot and Unity using terms “occlusion culling”, and I like it more too (it’s a more general term, and consistent with “frustum culling”) → I will do some renames in our terminology to be simpler, and just use “occlusion culling” term in CGE more (instead of “occlusion query”).

---

<div class="post-metadata">

### Author: ![sledge](https://forum.castle-engine.io/letter_avatar_proxy/v4/letter/s/a587f6/32.png) [@sledge](https://forum.castle-engine.io/u/sledge)
#### Post date: [March 13, 2023, 9:45pm UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764/6 "2023-03-13T21:45:27Z")

</div>

Nevertheless … we all learn from here. If we need to search something specific, we know the name now (or we know some more terms) 🙂

---

<div class="post-metadata">

### Author: ![michalis](https://forum.castle-engine.io/user_avatar/forum.castle-engine.io/michalis/32/3_2.png) [@michalis](https://forum.castle-engine.io/u/michalis)
#### Post date: [June 30, 2023, 10:56pm UTC](https://forum.castle-engine.io/t/mobile-opengles-rendering-upgrades-occlusion-culling-anisotropic-filtering-3d-textures-shadows-plus-new-occlusion-query-demo/764/9 "2023-06-30T22:56:09Z")

</div>

> [@michalis](#):
>
> Note that, as I saw both Godot and Unity using terms “occlusion culling”, and I like it more too (it’s a more general term, and consistent with “frustum culling”) → I will do some renames in our terminology to be simpler, and just use “occlusion culling” term in CGE more (instead of “occlusion query”).

Note that the renames to “occlusion culling” are finished now, along with renderer improvements just announced on [Big renderer improvements: Correct and automatic blending sorting, more powerful batching (now cross-scene), easier and more reliable occlusion culling and occlusion sorting – Castle Game Engine](https://castle-engine.io/wp/2023/06/30/big-renderer-improvements-correct-and-automatic-blending-sorting-more-powerful-batching-now-cross-scene-easier-and-more-reliable-occlusion-culling-and-occlusion-sorting/) . So CGE naming is consistent at least with Unity and Godot.
