このページでは

CubeMapTexture QML Type

3Dシーンで使用するためのキューブマップテクスチャを定義します。詳細...

Import Statement: import QtQuick3D
Inherits:

Texture

詳細な説明

CubeMapTextureは、キューブマップテクスチャを表すTextureです。 キューブマップテクスチャには 6 つの面(X+、X-、Y+、Y-、Z+、Z-)があり、各面は個別の 2D 画像です。CubeMapTexture を使用すると、custom materials およびpost-processing effects が、シェーダー内でキューブマップテクスチャを扱うことができます。また、キューブマップは、シーン環境の「skybox 」を定義するためにも使用できます。

CustomMaterial {
    property TextureInput customTexture: TextureInput {
        texture: CubeMapTexture {
            source: "cubemap.ktx"
        }
    }
    fragmentShader: "shader.frag"
}

ここで、shader.fragは、customTexture がGLSL型samplerCube を持つサンプラーユニフォームであると仮定して実装できます。これは、texture() GLSL関数が、そのサンプラーのテクスチャ座標としてvec3 を受け取ることを意味します。もしTexture を使用していた場合、型はsampler2D になっていたでしょう。

void MAIN()
{
    vec4 c = texture(customTexture, NORMAL);
    BASE_COLOR = vec4(c.rgb, 1.0);
}

キューブマップを含むコンテナからテクスチャを取得する場合、面 0(X+)のみが読み込まれ、2D テクスチャとなります。一方、同じアセットから `CubeMapTexture` を取得すると、6 面すべてが読み込まれ、キューブマップテクスチャとなります。

CubeMapTextureは、そのすべてのプロパティをTextureから継承しています。重要な違いは、source が、キューブマップを含む画像ファイル、または画像ファイルのリストを参照しなければならないという点です。実際には、単一のファイルとは、6つの面画像を含むKTXコンテナを意味します。

6つの個別の画像からCubeMapTextureを生成するには、2つの方法があります。1つは、X+、X-、Y+、Y-、Z+、Z-の順でファイル名をセミコロン区切りで指定する方法です:

CubeMapTexture {
    source: "maps/right.jpg;maps/left.jpg;maps/top.jpg;maps/bottom.jpg;maps/front.jpg;maps/back.jpg"
}

あるいは、「%p」というプレースホルダーを含む文字列として指定する方法です。この場合、「%p」は「posx」、「negx」、「posy」、「negy」、「posz」、「negz」という文字列に置き換えられ、6つのファイル名が生成されます:

CubeMapTexture {
    source: "maps/sky_%p.png"
    // equivalent to:
    // source: "maps/sky_posx.png;maps/sky_negx.png;maps/sky_posy.png;maps/sky_negy.png;maps/sky_posz.png;maps/sky_negz.png"
}

注: sourceItem やtextureData などの他の手段による画像データの読み込みは 、現時点では CubeMapTexture ではサポートされていません。

Texture 、CustomMaterial 、およびEffectも参照してください 。

© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.