-
We have a new class TCastleTransform that can be used to group and transform scenes, using properties like Translation, Rotation, Scale, Direction, Up.
-
This class replaces previous classes
T3D
,T3DList
,T3DTransform
,T3DOrient
,T3DCustomTransform
, merging all their functionality. The ability to “group and transform” is so basic feature that the previous split into multiple classes was uncomfortable. -
This way you can freely switch between adjusting rotation directly (using
Rotation
, as axis vector + angle) orDirection
andUp
(that specify rotation versus a default orientation of your models, which is of course configurable). -
The
TCastleTransform
class is now an ancestor of TCastleScene. So you can easily transformTCastleScene
e.g. byScene.Translation := Vector3(1, 2, 3);
. -
The
TCastleTransform
class is also used as the ancestor ofSceneManager.Items
list. So you can easily transform your whole world, e.g. scale everything down bySceneManager.Items.Scale := Vector3(0.1, 0.1, 0.1);
. (Be careful though — transforming theSceneManager.MainScene
is not supported yet, so you cannot use the above example if you useSceneManager.MainScene
for default camera.) -
Also,
TCastleTransform
has a nice name, correctly suggesting that it’s useful for both 3D and 2D games š As usual, 2D in our engine is just a special case of 3D, and I’m writing everything to be comfortable for both use-cases.
-
-
The GLFeatures.EnableFixedFunction is now
false
on desktops with modern GPUs (with OpenGL >= 2.0). This means that the rendering, by default, uses modern implementation that is more flexible and can be even faster.Remember that, in order to see even better shading, you can use “Phong shading”, either for the whole scene (
Scene.Attributes.PhongShading := true;
) or only for a particular shape (Shape.Shading := shPhong;
), see shading methods documentation. By default we use Gouraud shading, which is uglier but faster.The new rendering method (based purely on shaders) should generally produce the same or better results as the old method (which was using a mix of fixed-function and shader approaches). It is more flexible, and may be even faster on modern GPUs. But there are some possible “gotchas”:
-
If you have implemented custom rendering using immediate-mode OpenGL commands (in overridden LocalRender, or Window.OnRender) then you possibly depend on some deprecated state being set by the engine.
The simplest solution is this case will be to reenable
GLFeatures.EnableFixedFunction
for now. Just setGLFeatures.EnableFixedFunction := true
in Window.OnOpen or Application.OnInitialize (you want to do this early, but after OpenGL context is created).The more long-term solution is to upgrade your custom rendering to work with the new system. In most cases, you should not render things yourself using OpenGL — instead handle everything by loading appropriate 3D models into TCastleScene. The models can be in X3D format, with shader effects and many other fancy stuff. In general, let us know on the forum if you have a specialized need and are not sure how to upgrade.
-
The fixed-function Gouraud shading was using two-sided lighting. The new shader pipeline makes one-sided lighting in case of Gouraud shading, for speed.
One solution is to flip the side that receives lighting by flipping the
ccw
field at your geometry node (likeIndexedFaceSet
). The other solution is to use the “Phong shading” (that always does two-sided lighting), either for the whole scene or only for the particular shape — see instructions above. -
Finally, some old GPUs with buggy OpenGL implementations may be affected by this. We tried to protect from this (
GLFeatures.EnableFixedFunction
remains true if OpenGL version is less than 2, even if GL supports extensions for GLSL)/ But if you find a case whenGLFeatures.EnableFixedFunction
really needs to be enabled even on OpenGL > 2 (because otherwise rendering using shaders is buggy), please submit it to us (through the forum or as an issue on GitHub).Please attach the OpenGL version (and renderer and vendor) on your system — you can see it in the output of GLInformationString function, which is also dumped to the log file if you use InitializeLog in your game. You can also see it in the view3dscene message for Help->OpenGL Information.
Note: If you use shadow volumes, they will still use fixed-function pipeline. This, and some other planned improvements to renderer, is documented here — contributions to improve this are welcome!
-
More comfortable transformation of scenes, fixed-function disabled by default