WasVisible: query visibility of scenes and shapes, RobustNegativeScale: support lighting with negative scales

Posted on

Detect visibility
  1. You can easily query whether the scene or shape was (potentially, at least partially) visible in the last rendering event. This accounts for both frustum culling and occlusion culling.

    Use TCastleScene.WasVisible, TAbstractShapeNode.WasVisible for this.

    Demo is in examples/viewport_and_scenes/test_was_visible.

    See forum thread for history behind this feature.

  2. You can use TCastleRenderOptions.RobustNegativeScale to make lighting work correctly even when combined with negative scale. By default, using negative scale causes trouble for lit objects (as the normal vectors are not coming from the right side) and backface culling. Using the RobustNegativeScale makes them reliable (at a small cost at rendering time).

Comments on the forum ➤

glTF improvements (normal scale, camera fix), mixing glTF with X3D using IMPORT / EXPORT

Posted on

normalScale in X3D
IMPORT / EXPORT to connect X3D and glTF
  1. In both glTF and X3D we implement now a feature to “emphasize / deemphasize normal map”.

    In glTF this is in material.normalTextureInfo.scale, in X3D this is in normalScale parameter of Material or PhysicalMaterial.

    The intuitive meaning of it is:

    • value = 1 is the default, regular bump mapping behavior.
    • values < 1 make normal map effect deemphasized (normal vectors in tangent space have XY scaled down, so they go to (0,0,1) in tangent space, as if the normal map was not used). Value = 0 cancels the normal map effect completely.
    • values > 1 make normal map effect emphasized (normal vectors in tangent space have XY larger).

    Demo file is in x3d-tests repo: pbr/enhanced_phong_material/bump_mapping_normalscale.x3dv.

  2. glTF camera import was fixed.

    We mistakenly imported slightly wrong field of view and slightly wrong position. Usually these 2 bugs cancelled each other… almost 🙂

  3. You can now use IMPORT / EXPORT to selectively take (and reuse as many times as you wish) parts of inner glTF models inside outer X3D file.

    I have documented this with details and examples in new section Interoperability with X3D inside our glTF docs.

Comments on the forum ➤

FreeBSD build

Posted on

FreeBSD - CGE editor
FreeBSD - CGE editor
FreeBSD - CGE game

I was playing with latest FreeBSD (after listening to an excellent talk about the troubles with FreeBSD which nicely discusses non-technical problems in large open-source volunteer-led project).

Naturally, I tested Castle Game Engine on FreeBSD and it works flawlessly 🙂

I made a release of current CGE for FreeBSD.

This was done just by

The editor, build tool just work, based on FPC and Lazarus that are available in FreeBSD ports (install just by pkg install fpc, pkg install editors/lazarus).

Note: This release is not rebuild automatically, unlike current Linux and Windows releases. But, well, let me know — we can make it rebuild automatically, if there’s interest! Otherwise, in a few weeks, this will be inevitably outdated. Of course you can always rebuild CGE from sources yourself on FreeBSD.

P.S. Don’t worry about low FPS on a screenshot — this was done in a virtual machine.

Comments on the forum ➤

Physically based rendering (PBR) in X3D, using glTF with X3D 4.0 (recording of my webinar)

Posted on

A recording of my presentation last Tuesday about X3D 4, PBR, glTF, and CGE is available. Watch it here:

The plan of the presentation, along with various links that I mention in the talk, is here.

This the 3rd YouTube movie from me this week. Do you think I can finally become an Influencer? 🙂 My cat says I do a great job!

Comments on the forum ➤

Background (skybox, sky/ground color gradients) in Castle Game Engine – presentation video on YouTube and Vimeo

Posted on

Enjoy a new video that demonstrates how to set up background (skybox etc.) in CGE editor:

Also, I uploaded our last 2 movies to the Castle Game Engine page on Vimeo. Should we use both YouTube and Vimeo? I will let you decide using the likes and comments 🙂 Here’s the embedded version of the same video on Vimeo:

Comments on the forum (3) ➤

Design lights using Castle Game Engine: new light components and related features, with video!

Posted on

Lights in Castle Game Engine editor

We’re proud to announce a big new feature in Castle Game Engine: new light components that allow to easily manipulate lights (from the editor and from Pascal code) and a number of related improvements.

I’ve made a video presentation that describes everything, enjoy! And read below the movie for more information.

New features details:

  1. New components to define light nodes: TCastlePointLight, TCastleSpotLight, TCastleDirectionalLight. Descendants of TCastleTransform, which can be easily added and manipulated from the editor and from Pascal code.

  2. New properties to control lights: TCastleRenderOptions.ReceiveSceneLights, TCastleRenderOptions.ReceiveGlobalLights, TCastleScene.CastGlobalLights.

  3. TCastleRenderOptions.PhongShading is now by default true. In short, it means that the lights look pretty. If you want to use Gouraud shading for efficiency, just change Scene.RenderOptions.PhongShading (see TCastleRenderOptions.PhongShading) to false.

    Note: using some features (normal maps, PBR, shadow maps) requires Phong shading anyway, and will override this.

    Note: Do not confuse Phong shading with Phong lighting model.

  4. TCastleRenderOptions.DefaultMaxLightsPerShape is now by default a big number: 64 instead of previous 8. Remember that each light has a cost, esp. as we use classic “forward rendering” right now in CGE. So try to limit the number of lights that affect given shape anyway, try to stay well below the 64 limit. The simplest way to do this is to use reasonable Radius on point and spot lights, and limit the number of directional lights that affect all scenes.

  5. SpotLight defaults adjusted, matching also X3D 4.0 changes: beamWidth by default is now pi * 3 / 16, so it shows a small falloff until cutOffAngle.

  6. Proper calculation and optimization of lights radius when lights are in a different scene than shape they shine on.

Coming soon: TCastleEnvironmentLight and shadows properties on lights, to easily activate shadow maps.

Do you enjoy this feature? Please support us on Patreon.

Comments on the forum ➤

Web3D webinar this Tuesday, Steam Deck test, documentation updates, PasVulkan tests

Posted on

Unholy Society using CGE running on Steam Deck

This weekend news post will cover a few things 🙂

  1. I will give a talk about X3D, X3D 4, PBR (Physically-based Rendering), and how it connects with glTF 2.0 and Castle Game Engine this Tuesday, 29th March. Head on to the Web3D site to register, the talk is free and open to join for everyone. Plan of the talk is here.

  2. Thanks to Liam Dawe from Gaming On Linux, we have The Unholy Society, developed entirely in Castle Game Engine, running on Steam Deck! See the photo.

  3. I was testing PasVulkan on my Linux system.

    This was in preparation for working on Vulkan renderer for CGE. While we don’t plan to add Vulkan support for CGE in 7.0 release, but it is something I definitely want to start in 2022. So I wanted to test and see how PasVulkan works, and we’ll likely use the Vulkan header from PasVulkan: src/Vulkan.pas.

    I made it work on Linux. If anyone else on Linux wants to try — my PR that adds necessary script for Linux is here. It should of course work on Windows too, out of the box.

  4. Documentation:

    1. Improved (updated various tasks, clearer list) the roadmap page

    2. Added 2 sections to the Coding Conventions:

      1. Fix warnings (let the compiler help you write reliable code),
      2. Backward compatibility is important; having a consistent (easy to learn) API and useful features is even more important.
    3. Improved (simplified, updated) the macOS page.

Comments on the forum ➤

New Castle Tester – running all engine automatic tests on all platforms (desktop, mobile, Nintendo Switch…) with all compilers (FPC, Delphi)

Posted on

Castle Game Engine Automatic Tests

This screenshot will not win the #screenshotsaturday hashtag, but it took a lot of effort to achieve 🙂

Thanks to Andrzej Kilijański we have a big upgrade to our automatic tests application, available as always in tests/ subdirectory of CGE. Instead of using FpcUnit, the application can now use our own testing framework CastleTester that

  1. Is deliberately very compatible with FpcUnit (in fact, using some of its code).

  2. Tightly integrated with CGE, providing easy UI using CGE to run and display all tests results, and some extra utilities like CreateWindowForTest.

  3. Compiles and runs with both FPC and Delphi. All our tests now pass with both compilers. We made a number of fixes to Delphi support thanks to this (FPC support was being tested and flawless since a long time).

  4. Compiles and runs for all platforms we support. E.g. you can run the testsuite on Android, iOS, Nintendo Switch this way, by building the castle-tester for these platforms — just like any other CGE application.

As always, both Jenkins and GitHub Actions run all these tests automatically after every push. Jenkins even runs them with both FPC and Delphi 11.

Comments on the forum ➤

Mirrored Repeat mode, TextureProperties.BoundaryModeS/T/R support

Posted on

TextureProperties on 3D texture
TextureProperties - various boundary modes, including mirrored repeat
  1. Thanks to Matthias (Free Pascal meets SDL) we now support “mirrored repeat” mode for textures, for both glTF and X3D models. We also support X3D TTexturePropertiesNode.BoundaryModeS/T/R properties, which allow to request a wrapping mode — clamp, repeat, or mirrored repeat. (see TBoundaryMode)

    The way you would request it in Pascal is by creating and adjusting TTexturePropertiesNode like this:

    You can experiment with the example code that builds a mesh using Pascal to add there TextureProperties as above.

    Example X3D file utilizing it is in demo-models, file texturing_advanced/texture_boundary_modes.x3dv.

    Example glTF file using this is in Khronos glTF-Sample-Models, open glTF or GLB in dir 2.0/TextureSettingsTest.

  2. Another related fix is that we fixed the default values of TTexturePropertiesNode.MinificationFilter, TTexturePropertiesNode.MagnificationFilter. By default, they now indicate to use minification/magnification specified in MyScene.RenderOptions, which means that merely adding a TTexturePropertiesNode doesn’t make the filtering uglier. This was fixed in X3D 4.0 some time ago (after my request) and CGE now follows, so we have a saner default.

The documentation about TextureProperties node was extended to mention it all.

Comments on the forum ➤

Creating Debian Packages with Castle Game Engine build tool

Posted on

cge+debian

Debian is a popular Linux distribution, also serving as a base for other Debian-based distributions like Ubuntu. You can now easily create a Debian package, .deb file, from any game!

  • From Castle Game Engine Editor use menu option Run -> Package Format -> Debian Package (DEB) and then Run -> Package.

  • Or use command-line build tool with --package-format=deb option. The full command may look like this:

To install the resulting package using command-line you can execute sudo apt install ./xxx.deb. Once installed, you can see it in all applications listing currently-installed packages (like Synaptic). You can remove the package using e.g. Synaptic or just sudo apt purge xxx.

While it will work out-of-the-box, to have a really good package you should make sure you filled some information in the project manifest:

  1. Be sure to specify the project author

  2. Specify an icon, in XPM or PNG formats.

  3. Specify sections, categories and comment to have the package and application look best.

This feature was mostly developed by Eugene Loza (thousand thanks!) with some additions from Michalis. It’s not a secret that we’re both using Debian OS as the main operating system and as such most of CGE was probably created on Debian or Debian-derivatives 🙂 So we’re very happy with this integration.

Comments on the forum ➤