Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
Cubemap
繼承: ImageTextureLayered < TextureLayered < Texture < Resource < RefCounted < Object
代表立方體的六個方形紋理。通常用作天空盒。
說明
立方體貼圖由 6 個紋理組成,按層組織,通常用於在 3D 渲染中充當反射(見 ReflectionProbe)。使用立方體貼圖可以使物體看起來像是在反射周圍的環境。這通常比其他反射方法提供更好的效能。
該資源通常作為自訂著色器中的 uniform 使用。少數核心 Godot 方法會用到 Cubemap 資源。
要自己建立這樣的紋理檔案,請使用 Godot 編輯器的匯入預設重新匯入影像檔案。要使用程式碼建立 Cubemap,請對 Cubemap 類的實例呼叫 ImageTextureLayered.create_from_images()。
預期的影像順序是 X+、X-、Y+、Y-、Z+、Z-(Godot 的座標系統中 Y+ 是“上”、Z- 是“前”)。你可以從下列範本中挑選一個作為基礎:
注意:Godot 不支援在 PanoramaSkyMaterial 中使用立方體貼圖。要將立方體貼圖用作天空盒,請使用 轉換為 ShaderMaterial 資源下拉選項將預設的 PanoramaSkyMaterial 轉換為 ShaderMaterial,然後將其程式碼替換為:
shader_type sky;
uniform samplerCube source_panorama : filter_linear, source_color, hint_default_black;
uniform float exposure : hint_range(0, 128) = 1.0;
void sky() {
// 如果立方體貼圖是從其他引擎匯入的,可能需要通過將下面的
// 某一個 `EYEDIR` 分量替換為 `-EYEDIR` 來進行翻轉。
vec3 eyedir = vec3(EYEDIR.x, EYEDIR.y, EYEDIR.z);
COLOR = texture(source_panorama, eyedir).rgb * exposure;
}
替換著色器程式碼並儲存後,請在屬性檢視器中 ShaderMaterial 的 Shader Parameters 部分指定匯入的立方體貼圖資源。
另外,你可以使用 這個工具將立方體貼圖轉換為等距矩形天空圖,這樣就可以像往常一樣使用 PanoramaSkyMaterial 了。
方法
create_placeholder() const |
方法說明
Resource create_placeholder() const 🔗
建立該資源的預留位置版本(PlaceholderCubemap)。