CubeMapTexture QML Type

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

Import Statement: import QtQuick3D
Inherits:

Texture

詳細な説明

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

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

ここで shader.frag は、customTexture がサンプラー均一で、GLSL タイプが asamplerCube であると仮定して実装できます。これは、texture() GLSL 関数が、そのサンプラーのテクスチャ座標としてvec3 を取ることを意味します。もしTexture を使ったら、タイプはsampler2D になったでしょう。

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

Cubemapを持つコンテナからTextureをソーシングすると、面0(X+)だけがロードされ、2Dテクスチャになります。一方、同じアセットから CubeMapTexture をソーシングすると、6 面すべてがロードされ、Cubemap テクスチャになります。

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

6 個の画像から CubeMapTexture を取得するには、2 つの方法があります。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 "は "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"
}

注: CubeMapTexture では、sourceItemtextureData のような他の方法による画像データの取得は、現時点ではサポートされていません。

TextureCustomMaterialEffectも参照して ください。

© 2025 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.