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

Posted on

Occlusion query demo on Android
Occlusion query demo
Occlusion query demo on desktop

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:

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, just like on the desktop. See e.g. 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 on mobile.

Comments on the forum (6) ➀

We now use dedicated GPU automatically for all new projects

Posted on

"Lynch" game in CGE editor

Many laptops come now with 2 GPUs: a slower one that consumes less battery and a “dedicated” GPU consuming more battery but capable of much better speeds, esp. when used with non-trivial 3D data. The CGE editor and your applications automatically use the “dedicated” GPU now.

More information about this feature, the documentation how to disable it, and how to upgrade your existing projects to follow: Dedicated GPU.

Comments on the forum (3) ➀

User interface features: render with mask (new TCastleMask component), better slider default look, new option ProtectedSidesScaling

Posted on

Mask at runtime
Mask at design-time
view3dcene new sliders
  1. New component TCastleMask allows to define a mask (using an arbitrary UI control) and use this mask to limit rendering the children.

    The mask may be any UI control (or a composition of it). The colors do not matter, only which pixels are drawn by the mask. E.g. you can define a mask using

    The masked children, in turn, can also be any UI control. So you can filter rendering of anything, even if it’s interactive (like a button) or 3D (like a viewport).

    TCastleMask.MaskRendering determines if the children are rendered where the mask is visible or (on the contrary) where the mask is not visible.

    See the example examples/user_interface/mask for demonstration.

  2. I improved the default look of our sliders (TCastleFloatSlider, TCastleIntegerSlider).

    These sliders are quite useful, esp. for various demos and tools (view3dscene uses them to test animations and lights). Well, they no longer look ugly πŸ™‚ and their design allows an optional label inside (useful to communicate to user exact numerical value behind the slider).

  3. I implemented a special way of treating protected sides for images. By default they do normal 9-slice scaling but a new option allows to scale corners horizontally to match the image height: TCastleImagePersistent.ProtectedSidesScaling, pssMatchHeight.

    Admittedly it’s a bit easier to see than to explain with words, so if you’re curious, just try it out with an image like SliderBackground that has exactly circular left and right endings. Thanks to the new option, they will stay circular, no matter how you resize the slider.

Comments on the forum (3) ➀

Convert SVG to X3D using X_ITE, to display SVG as geometry in Castle Game Engine

Posted on

Zrzut ekranu z 2023-02-25 00-59-48
Zrzut ekranu z 2023-02-25 00-59-28
Zrzut ekranu z 2023-02-25 00-59-58
Zrzut ekranu z 2023-02-25 01-00-15

X_ITE is an open-source JavaScript library to display X3D (and a number of other formats) in a web browser, using WebGL. It was recently extended to import additional formats, and render them straight away or convert to X3D. The supported formats are now: X3D, VRML, glTF (GLB), OBJ, STL, and SVG.

There is an accompanying online converter to X3D and a command-line converter x3d-tidy that perform the conversion using X_ITE underneath.

In a way, this is similar to what we do in Castle Game Engine, where we also load everything (like glTF) to X3D nodes, give you an online converter and a command-line and GUI converter.

But there’s also a big added value: X_ITE supports SVG. SVG (scalable graphics, create it e.g. in Inkscape) gets converted into proper geometry in X3D, so it remains scalable and can be used as part of your 2D or 3D game in CGE! This is what I enjoy about being part of an ecosystem and open formats like X3D — we get new features “for free” thanks to cooperation with others.

Note that in the generated X3D file, all objects will be placed at the same depth, Z = 0, at least right now. You may have to fix it to avoid Z-fighting in case SVG layers overlap. For simple cases, it is possible to do this by just manually editing the X3D file in any text editor. Assigning meaningful names to your objects in SVG, e.g. using Inkscape “Object Properties”, also helps. I have done it with a non-trivial SVG file (our engine logo) and the manual effort was ~easy πŸ™‚

See the result of my play in demo-models/svg. It shows how to fix Z, I also add a shader effect to discard pixels outside of a circle in the middle, to “cut off” stuff that should not be visible in a circular engine logo.

I encourage you to test the converter and explore X_ITE in general. Many thanks go to Holger Seelig for an amazing work on this!

Comments on the forum (3) ➀

Rendering of lines and points from glTF, more options for line nodes in X3D

Posted on

Lines from glTF, test model from https://github.com/KhronosGroup/glTF-Sample-Models/issues/124
Points in glTF
Lines in glTF

This is probably not the most sexy graphic effect announcement :), but the lines and points are useful to visualize a lot of things.

We have improved our glTF support to properly import points, lines (lines, line strips, line loops), and their materials.

We have also improved our X3D nodes capabilities by introducing TIndexedLineSetNode.Mode and TLineSetNode.Mode. This allows to comfortably and efficiently define lines, line strips, line loops in X3D.

Comments on the forum ➀

Using OpenGL “core” profile by default on macOS

Posted on

fps_game example on mac
System Information with OpenGL 4.1 on mac
shadow maps on mac
shadow volumes on mac
shaders on mac
view3dscene on mac with OpenGL 4.1

Thanks to recent rendering code improvements, we can finally request “core” profile on macOS, to get latest OpenGL version (4.1 in my case) instead of being stuck with legacy OpenGL 2.1 on mac.

We request now a modern context on mac, both with TCastleWindow and TCastleControl. This applies to all our software — CGE editor, view3dscene, all your applications you build with CGE.

Comments on the forum ➀

Shadow volumes and shadow maps work on mobile (OpenGL ES) and we have a new TCastleRenderUnlitMesh utility class

Posted on

Shadow maps on OpenGLES
Shadow volumes on OpenGLES
Debug visualization of octree in view3dscene

You can use the new TCastleRenderUnlitMesh utility class to render unlit 3D objects easily. It has a nice API when you want to render a set of vertexes and then forget about them — sometimes this is easier than setting up the shapes in TCastleScene. It may be especially useful for rendering debug 3D geometry, in fact view3dscene is already using it for this purpose.

An example usage is in test_rendering_opengl_capabilities example, in unit gamemymesh.pas.

Moreover, thanks to this class (and some other improvements I’ll describe in subsequent posts) we have upgraded our shadow volumes code, making it simpler and working with mobile OpenGL ES, without losing any performance. You can test shadow volumes on OpenGLES e.g. using examples/viewport_and_scenes/shadows or by creating a new project from “3D FPS Game” template.

And while we’re at it, our shadow maps code was also fixed. It now works on OpenGLES in much the same way it does on desktop OpenGL.

Note: This is not the end of shadow maps upgrades. They are still not as straightforward to activate as they should be, and they don’t cast shadows on multiple scenes. More work on shadow maps is coming πŸ™‚

Comments on the forum ➀

Watch my DelphiCon 2023 presentation in 3 hours, watch my GIC 2022 presentation now :)

Posted on

GIC 2022

First, a reminder that our DelphiCon presentation is in ~3 hours, 2:00 PM in Central Standard Time. See DelphiCon 2023 to register, you can also just watch the live stream on Embarcadero YouTube. I hope you will enjoy it! I will be of course present during the presentation, go ahead and fire questions at me:) See also more talk information here.

Second: Game Industry Conference recently published a recording of my presentation there, from October 2022. It’s just 30 minutes, and it’s really a very different talk from DelphiCon, I talk about the engine high-level decisions (like glTF, X3D), motivation, thoughts on making open-source game engines (declarative, evangelism). The slides from GIC presentation are also available. So, if you can’t wait to see me :), I encourage to watch GIC 2022 talk now:

Comments on the forum ➀

Join DelphiCon 2023 and watch Castle Game Engine presentation this Thursday

Posted on

Michalis at DelphiCon 2023

I have a lot of pending news from recent engine developments (big refactor to rendering, lots of OpenGLES improvements, Tiled improvements) but for today, the most important thing:

Join Embarcadero DelphiCon 2023, an event celebrating 28 Years of Delphi, and listen to our talk “Getting Physical in Your Games with Castle Game Engine” on Thursday (February 16, 2:00 PM in Central Standard Time). As always be careful to recalculate timezones, personally I found it easiest to register and then add particular event to the calendar by clicking on the appropriate link, and then I can let my calendar software do all timezone calculations πŸ™‚

You can also just watch the event on Embarcadero YouTube, they stream it live.

My talk focuses on new features coming in 7.0-alpha.3, with a special emphasis on physics. I spend a significant part of this talk doing funny things with physics :), there is also a nice overview of CGE usage for 3D in general, I also fall in love with a particular sound effect. My talk is prerecorded this time, and as such I can already spoil that it was impossible to fit everything into my 1-hour slot, and I will be releasing some “bonus” videos afterwards, if you can’t get enough of my rambling and will want more after DelphiCon πŸ™‚

And while I show there everything in Delphi, since it’s DelphiCon, it is really all the same if you’re an FPC/Lazarus user!

My talk description:

Castle Game Engine is an open-source cross-platform 3D and 2D game engine. We’re aiming at a huge engine release “7.0” shortly after Delphicon 2023. As such, I’d like to show the latest juicy stuff we’ve been working on: physics, shadows, rendering huge maps, using engine as part of VCL or FMX form. The session will start with an introduction to using the engine with Delphi. Everyone interested in making games using Delphi is welcome!

Comments on the forum ➀

Support us on Patreon (and get stickers!), Ethereum, Open Collective and other options

Posted on

Castle Game Engine stickers

While technically I’m busy on shadow-volumes-new branch (despite the name, it has spiraled into a number of generally useful rendering code refactors; rendering on both modern and ancient GPUs will benefit, as various things are improved and the code gets simpler too)…

…let me make a non-technical post πŸ™‚

We really appreciate your donations and, going forward, this is ideally the way to fund the development of the engine, The main goal of donations is simply to cover the cost of people, so that they can work on the engine full-time, which in turn just translates to more features, faster. Right now we have 1/2 developer on a payroll (Andrzej KilijaΕ„ski, paid from Michalis Kamburelis own pocket) and hiring him was a great decision β€” having Andrzej made a big difference, the engine progress in recent years owes much to his work. Imagine we can have 10x of that πŸ™‚

Our recommended way to donate is a monthly subscription on Patreon. Patreon offers a number of traditional payment methods.

On top of making things easy, Patreon also offers a unique reward for donors: 4 physical sticker with CGE logo that you receive after 3 monthly donations at 10 USD tier. See the photo πŸ™‚ They ship worldwide, I tested πŸ™‚

But there are other options, always listed here. These include:

  1. If crypto-currencies are your thing, you can donate using:

    Ethereum: send to this address: 0x0b0e37c7391C7268DEc9c0De63bA5A3b1B42baCe

    Bitcoin: send to this address: 1FuJkCsKpHLL3E5nCQ4Y99bFprYPytd9HN

  2. GitHub Sponsors

  3. Open Collective

Whichever option, whichever tier you choose — big thank you!

I’m serious about developing the engine, I’m serious about making something that enables you to develop great games with open-source software. We are doing it… wow, I just found the oldest news post from 2004. So 18+ years now. The engine is now old enough to drink and do other adult stuff πŸ™‚ And you can see at our regular news, for so many years that we don’t stop and we don’t plan to stop. I hope you enjoy this journey and want to support us along the way. Financial funding is, in the long-term, something that allows to work on the engine just as a regular thing, with as much people and time we can afford. Your support really changes what we can achieve and how fast we can do it.

Enjoy creating games with Castle Game Engine!

Comments on the forum ➀