Particle system updates (custom shaders, web support), FreeCAD -> X3D exporter, documentation (exe size, 2D, easy link to API), geometry shader fixes

Posted on

Particle system
FreeCAD -> X3D, in Castle Model Viewer
Geometry shaders example
Michalis:)

Forgive us for a calm August without the usual weekly announcements, as Michalis spent most of the month on a family vacation. Stay tuned for an upcoming news post about a feature he made when his wife wasn’t watching: Android and iOS compatibility with Delphi 🙂

Until then, here are a number of announcements you can enjoy right now — with big thanks to everyone using the engine and building the ecosystem around it:

  1. Kagamma (Trung Le) has updated his GPU-based particle system for Castle Game Engine. New features, announced on the forum thread, are:
    • Custom shaders: Influence particle position and look using a PLUG system similar to our shader effects. See docs.
    • Web target support: see demo online.
    • Modify the built-in particle mesh in editor.
    • Rotation type support.
  2. Kagamma (Trung Le) also updated his alternative approach for particles in our engine: particles designed in Effekseer version 1.80.5 are now supported. Download the updated shared libraries for Windows, Linux and Android from here.

  3. Marco Mora posted about a new exporter from FreeCAD to X3D with Castle Game Engine extensions. See his forum post for a description and screenshots and the repository here. You can see pretty mirrors on the screenshot, using our X3D extension for mirrors on flat objects. Enjoy and post your feedback in the forum!

  4. We have documented how to optimize executable size (for all platforms) and committed a fix (no need for exports) that makes the generated Linux executables much smaller (~45%) out-of-the-box.

  5. We reworked the creating 2D games page of our manual. This was waiting too long for a “big 2D tutorial” — which may still come some day, but in the meantime, the existing page is hopefully sufficient: it presents a short 2D overview and refers to other pages (since a lot of engine concepts are just the same for 2D and 3D usage).

  6. As a small feature on our website, you can now use URLs like this:

    https://castle-engine.io/api?id=PASCAL-IDENTIFIER

    … and it will automatically redirect to the proper API docs of a given identifier. For example, use

    https://castle-engine.io/api?id=TCastleWindow

    to redirect to

    https://castle-engine.io/apidoc/html/CastleWindow.TCastleWindow.html

    This is nice when writing URLs from outside of our website, e.g. from Markdown files in our source code. Of course, you can also just “spell out” the full URL like https://castle-engine.io/apidoc/html/CastleWindow.TCastleWindow.html there, but using the shorter https://castle-engine.io/api?id=TCastleWindow is

    • A bit easier. You don’t need to think about which unit TCastleWindow is in. This is resolved when we handle the redirect.

    • More future-proof. If we ever move the identifier TCastleWindow from one unit to another, the simple URL https://castle-engine.io/api?id=TCastleWindow will continue to work.

    Note: if you update documentation on our website, this is not necessary! In AsciiDoctor files, just use cgeref:TCastleWindow[] and it will display a proper link to TCastleWindow, showing a warning (in development mode) if TCastleWindow is not found. See cge-www README about developing our website.

  7. Geometry shaders received a number of fixes under the hood. Everything works again, and the code is cleaner than ever 🙂

  8. Important fix for XML reading with Delphi — this was crashing our explore_impressive_castle demo.

  9. Fixed applying transformations if you modify TCastleTransform.Exists often. Previously, setting Exists to true during rendering but flipping it to false during updating was causing a surprising effect: we rendered old transformations. Now the rendering always shows the current transformation.

  10. Trying to open a 2nd TCastleWindow on the web, Android or other platforms that don’t support it will now result in a clear exception, with a message instructing you to check “Application.MultipleWindowsPossible“. This makes the situation cleaner than the previous “opening 2nd window works by accident, overriding the previous window rendering”. Demo is inside multiple_windows_and_viewports.

Enjoying the engine? Please support us on Patreon!

Comments on the forum ➤

Web: water, terrain, shadow maps, alpha treatment, keys on losing focus

Posted on

Terrain + water demo on web
Shadow maps on web
Walking Adventure - tree on web
Platformer on web
Chromatic aberration on web

Rendering to texture (FBO, our TGLRenderToTexture) works now on the web.

This enables a few features on the web:

We also fixed alpha treatment on the web.

  • This fixes a few subtle bugs, as in various edge-cases we wrote to the color buffer pixels with alpha < 1. This happened e.g. when displaying hearts in the platformer demo (source code in examples/2d_games/platformer/), cat hair in model viewer, tree leaves in the walking adventure demo (source code in examples/3d_games/walking_adventure/).

  • This was harmless on non-web platforms (where pixel alpha of the color buffer is used only for eventual blending with incoming colors; nothing cares what is the final calculated alpha left in the buffer). But on web, in the past, our canvas was using “blending with page background (typically white)”.

  • This is fixed now, making the web rendering work just like other platforms. See comment here for more information.

We now correctly “reset” keys pressed state after you switch a browser page or application:

  • Previously, switching tabs or applications by key combo like Ctrl+Tab, Alt+Tab could leave the engine thinking that “Ctrl” or “Tab” are pressed.

  • This had some consequences, e.g. TCastleWalkNavigation will refuse movement by AWSD if it thinks that you hold down Ctrl/Alt modifier. (And it will do “run” if it thinks you hold down Shift!)

  • This is fixed now, we react to blur event by switching all keys “up”.

We have also fixed both terrain and water shaders for Chromium-based browsers (like Vivaldi or Google Chrome). They needed highp in certain shaders to work reliably (water waves, terrain textures smooth), as they multiply bigger floats with small floats.

As always, we hope you have fun developing games with Castle Game Engine! And if you like what we do, we appreciate support on Patreon!

Comments on the forum ➤

Web: bump mapping, clip planes, fog, terrain, occlusion culling; also Unholy Society demo on web updated

Posted on

Unholy Society - web build - wedding
Steep parallax mapping
Occlusion culling - web build
Explore impressive castle - web build

Shaders on web fixes:

Our shaders on the web platform can render now all our effects:

  1. Bump mapping (normal maps). As shown by demos:
  2. ClipPlane X3D node, useful to clip part of 3D/2D content when rendering. The node can be instantiated using Pascal class TClipPlaneNode or by writing X3D file like this:

    Save this as my_cut_model.x3dv and open (using our Castle Model Viewer, or from Pascal load it using our TCastleScene). In effect, you will see my_model.gltf but cut by a 3D plane. To be precise, the plane equation is Ax+By+Cz+D=0 with the (A,B,C,D) values given by the ClipPlane.plane vector above. The points we render are ones that satisfy Ax+By+Cz+D>=0, so they are in half-space determined by the plane.

  3. Fog.

  4. TCastleTerrain shader.
    • Used by terrain example (source code).
    • Note: Water used in this demo doesn’t work on web yet — we need to fix our FBO on web.
  5. Shader effects using varying, like “time to shader” in Castle Model Viewer (Mobile) on web.

The above features failed to work in the past due to a bug in ANGLE, library used to processes shaders (and optionally render) in both Firefox and Chromium-based browsers (I test with Vivaldi).

Occlusion culling on web:

We have fixed how occlusion culling works on the web. We needed to account for the fact that occlusion queries on the web can run for multiple frames.

See the running demo here: occlusion_culling (source code).

Unholy Society demo on web:

We have updated The Unholy Society web demo. We fixed audio, comic bubbles size, “pope call” animation (using ClipPlane, see above). Overall, at this point the complete game works on the web and yes, you can just play it for free here 🙂

Note that the web version doesn’t support persistent savegames (reloading the page will reset the game state), which is of course something we plan to fix soon.

Enjoy and please support us on Patreon to make it possible to continue improving the engine!

Comments on the forum ➤