procedure CalculateImageRightSize(
const Image: TCastleImage; const GUITexture: boolean;
out ImageRightSize: TCastleImage; out ImageRightSizeFree: boolean);
var
Sizing: TTextureSizing;
begin
if GUITexture then
Sizing := tsAny else
Sizing := tsScalablePowerOf2;
if IsTextureSized(Image, Sizing) then
begin
ImageRightSize := Image;
ImageRightSizeFree := false;
end else
begin
ImageRightSize := ResizeToTextureSize(Image, Sizing);
ImageRightSizeFree := true;
end;
end;
Because when textures do not have “power of 2”, we cannot use mipmaps, which makes them look unacceptably bad in some cases (when the texture may be arbitrarily small on the screen; this commonly happens in 3D, but also in some 2D uses).
Other game engines also either resize, or they don’t create mipmaps – in either case, some use-case is hurt.
You can always disable this feature:
-
If you use
TCastleImageTransform
, setMipmaps
property tofalse
. -
If you have access to X3D nodes like
TImageTextureNode
, you can setTextureProperties.guiTexture
totrue
, like this:
var
MyImageTexture: TImageTextureNode;
MyTextureProperties: TTexturePropertiesNode;
begin
... // initialize MyImageTexture
MyTextureProperties := TTexturePropertiesNode.Create;
MyTextureProperties.GuiTexture := true;
MyImageTexture.TextureProperties := MyTextureProperties;
end;
- Note that in some cases, we disable this by default. E.g. when using
TCastleImageControl
, or when loading image or sprite sheet toTCastleScene
.
Please put more context in your questions, so that we can help better Terse question like this makes it harder for me to advise the solution, as I have to guess in what context did you encounter this problem.
If you want specific advise how to deactivate it in your case, please describe / show code how you are using the texture.