ShaderProgram QML Type
シェーダープログラムをカプセル化します。詳細...
| Import Statement: | import Qt3D.Render 2.12 |
| In C++: | QShaderProgram |
| Status: | Deprecated |
この型は非推奨です。新しいコードでの使用は強く推奨しません。
プロパティ
- computeShaderCode : string
- computeShaderGraph : string
- format : enumeration
- fragmentShaderCode : string
- fragmentShaderGraph : string
- geometryShaderCode : string
- geometryShaderGraph : string
- log : string
- status : enumeration
- tessellationControlShaderCode : string
- tessellationControlShaderGraph : string
- tessellationEvaluationShaderCode : string
- tessellationEvaluationShaderGraph : string
- vertexShaderCode : string
- vertexShaderGraph : string
方法
- string loadSource(url sourceUrl)
詳細な説明
ShaderProgram クラスは、シェーダープログラムをカプセル化しています。シェーダープログラムは、頂点シェーダーやフラグメントシェーダーなど、いくつかの異なるシェーダーで構成されています。
Qt3Dは、シェーダーのイントロスペクションフェーズ中にデフォルトのユニフォームが検出された場合、それらを自動的に設定します。
| デフォルトのユニフォーム | 関連する Qt3D パラメータ名 | GLSL 宣言 | |||
|---|---|---|---|---|---|
| ModelMatrix | modelMatrix | uniform mat4 modelMatrix; | |||
| ViewMatrix | viewMatrix | uniform mat4 viewMatrix; | |||
| 投影行列 | projectionMatrix | uniform mat4 projectionMatrix; | |||
| ModelViewMatrix | modelView | uniform mat4 modelView; | |||
| ViewProjectionMatrix | viewProjectionMatrix | uniform mat4 ビュー投影行列; | |||
| ModelViewProjectionMatrix | modelViewProjection mvp | uniform mat4 modelViewProjection; uniform mat4 mvp; | |||
| InverseModelMatrix | inverseModelMatrix | uniform mat4 inverseModelMatrix; | |||
| 逆ビュー行列 | 逆ビュー行列 | uniform mat4 inverseViewMatrix; | |||
| 逆投影行列 | 逆投影行列 | uniform mat4 inverseProjectionMatrix; | |||
| モデルビュー行列の逆行列 | 逆モデルビュー行列 | uniform mat4 inverseModelView; | |||
| 逆ビュー投影行列 | 逆ビュー投影行列 | uniform mat4 inverseViewProjectionMatrix; | |||
| 逆モデルビュー投影行列 | 逆モデルビュー投影行列 | uniform mat4 inverseModelViewProjection; | |||
| モデル法線行列 | modelNormalMatrix | uniform mat3 modelNormalMatrix; | |||
| ModelViewNormalMatrix | modelViewNormal | uniform mat3 modelViewNormal; | |||
| ビューポート行列 | ビューポート行列 | uniform mat4 ビューポート行列; | |||
| 逆ビューポート行列 | inverseViewportMatrix | uniform mat4 inverseViewportMatrix; | |||
| アスペクト比 (サーフェスの幅 / サーフェスの高さ) | aspectRatioxml-ph-0000@deepl.internal (サーフェスの幅 / サーフェスの高さ) | uniform float aspectRatio; | |||
| 露光 | exposure | uniform float exposure; | |||
| ガンマ | ガンマ | 均一な浮動小数点ガンマ; | |||
| 時間 (ナノ秒単位) | time | uniform float time; | |||
| EyePosition | eyePosition | uniform vec3 eyePosition; | |||
| スキニングパレット | skinningPalette[0] | const int maxJoints = 100; uniform mat4 skinningPalette[maxJoints]; | |||
RHI サポート
Qt 3D のRHIバックエンドで使用するためのGLSL 450シェーダーコードを記述する場合、デフォルトのユニフォームは2つのユニフォームバッファオブジェクトとして提供されます。
これらのバインディング位置は、RenderView ユニフォームが 0、Command ユニフォームが 1 に設定されます。
#version 450 core
layout(location = 0) in vec3 vertexPosition;
layout(std140, binding = 0) uniform qt3d_render_view_uniforms {
mat4 viewMatrix;
mat4 projectionMatrix;
mat4 uncorrectedProjectionMatrix;
mat4 clipCorrectionMatrix;
mat4 viewProjectionMatrix;
mat4 inverseViewMatrix;
mat4 inverseProjectionMatrix;
mat4 inverseViewProjectionMatrix;
mat4 viewportMatrix;
mat4 inverseViewportMatrix;
vec4 textureTransformMatrix;
vec3 eyePosition;
float aspectRatio;
float gamma;
float exposure;
float time;
float yUpInNDC;
float yUpInFBO;
};
layout(std140, binding = 1) uniform qt3d_command_uniforms {
mat4 modelMatrix;
mat4 inverseModelMatrix;
mat4 modelViewMatrix;
mat3 modelNormalMatrix;
mat4 inverseModelViewMatrix;
mat4 modelViewProjection;
mat4 inverseModelViewProjectionMatrix;
};
void main()
{
gl_Position = (projectionMatrix * viewMatrix * modelMatrix * vertexPosition);
}ユーザー定義のユニフォームバッファオブジェクトについては、バインディングを 2 から開始するか、auto を指定してQt 3D に自動的にバインディングを決定させてください。異なるシェーダステージ間で一貫性を保つようにしてください。
#version 450 core
layout(std140, binding = auto) uniform my_uniforms {
vec4 myColor;
};
layout(location=0) out vec4 fragColor;
void main()
{
fragColor = myColor;
}ユニフォームへの値の供給に関しては、変更点はありません。
上記の例の場合、myColorの設定は次のように行えます:
Parameter { name: "myColor"; value: "blue" }テクスチャは、引き続き独立したユニフォームとして定義する必要があります。
#version 450 core
layout(binding=0) uniform sampler2D source;
layout(location=0) out vec4 fragColor;
void main()
{
fragColor = texture(source, vec2(0.5, 0.5));
}プロパティのドキュメント
computeShaderCode : string
このシェーダープログラムで使用されるコンピュートシェーダーのコードを保持します。
computeShaderGraph : string
このシェーダープログラムビルダーで使用されるコンピュートシェーダーグラフへのURLを保持します。
format : enumeration
ShaderProgram で提供されているコードの形式を採用しています。デフォルトはShaderProgram です。GLSL
fragmentShaderCode : string
このシェーダープログラムで使用されるフラグメントシェーダーコードを保持します。
fragmentShaderGraph : string
このシェーダープログラムビルダーで使用されるフラグメントシェーダーグラフへのURLを保持します。
geometryShaderCode : string
このシェーダープログラムで使用されるジオメトリシェーダーのコードを保持します。
geometryShaderGraph : string
このシェーダープログラムビルダーで使用されるジオメトリシェーダーグラフのURLを保持します。
log : string [read-only]
現在のシェーダープログラムのログを保持します。これは、シェーダープログラムのコンパイルエラーを診断する際に役立ちます。
status : enumeration [read-only]
現在のシェーダープログラムの状態を保持します。
tessellationControlShaderCode : string
このシェーダープログラムで使用されるテッセレーション制御シェーダーのコードを保持します。
tessellationControlShaderGraph : string
このシェーダープログラムビルダーで使用されるテッセレーション制御シェーダーグラフへのURLを保持します。
tessellationEvaluationShaderCode : string
このシェーダープログラムで使用されるテッセレーション評価シェーダーのコードを保持します。
tessellationEvaluationShaderGraph : string
このシェーダープログラムビルダーで使用されるテッセレーション評価シェーダーグラフへのURLを保持します。
vertexShaderCode : string
このシェーダープログラムで使用される頂点シェーダーのコードを格納します。
vertexShaderGraph : string
このシェーダープログラムビルダーで使用される頂点シェーダーグラフへのURLを保持します。
メソッドのドキュメント
string loadSource(url sourceUrl)
sourceUrl から読み込まれたシェーダーコードを返します。
© 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.