0.2.0-dev Download ZIP
42 lines ·3.2 KB Raw
| 1 | <?xml version="1.0" encoding="UTF-8" ?> |
| 2 | <class name="Cubemap" inherits="ImageTextureLayered" api_type="core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd"> |
| 3 | <brief_description> |
| 4 | Six square textures representing the faces of a cube. Commonly used as a skybox. |
| 5 | </brief_description> |
| 6 | <description> |
| 7 | A cubemap is made of 6 textures organized in layers. They are typically used for faking reflections in 3D rendering (see [ReflectionProbe]). It can be used to make an object look as if it's reflecting its surroundings. This usually delivers much better performance than other reflection methods. |
| 8 | This resource is typically used as a uniform in custom shaders. Few core Godot methods make use of [Cubemap] resources. |
| 9 | To create such a texture file yourself, reimport your image files using the Godot Editor import presets. To create a Cubemap from code, use [method ImageTextureLayered.create_from_images] on an instance of the Cubemap class. |
| 10 | The expected image order is X+, X-, Y+, Y-, Z+, Z- (in Godot's coordinate system, so Y+ is "up" and Z- is "forward"). You can use one of the following templates as a base: |
| 11 | - [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/tutorials/assets_pipeline/img/cubemap_template_2x3.webp]2×3 cubemap template (default layout option)[/url] |
| 12 | - [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/tutorials/assets_pipeline/img/cubemap_template_3x2.webp]3×2 cubemap template[/url] |
| 13 | - [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/tutorials/assets_pipeline/img/cubemap_template_1x6.webp]1×6 cubemap template[/url] |
| 14 | - [url=https://raw.githubusercontent.com/godotengine/godot-docs/master/tutorials/assets_pipeline/img/cubemap_template_6x1.webp]6×1 cubemap template[/url] |
| 15 | [b]Note:[/b] Godot doesn't support using cubemaps in a [PanoramaSkyMaterial]. To use a cubemap as a skybox, convert the default [PanoramaSkyMaterial] to a [ShaderMaterial] using the [b]Convert to ShaderMaterial[/b] resource dropdown option, then replace its code with the following: |
| 16 | [codeblock lang=text] |
| 17 | shader_type sky; |
| 18 | |
| 19 | uniform samplerCube source_panorama : filter_linear, source_color, hint_default_black; |
| 20 | uniform float exposure : hint_range(0, 128) = 1.0; |
| 21 | |
| 22 | void sky() { |
| 23 | // If importing a cubemap from another engine, you may need to flip one of the `EYEDIR` components below |
| 24 | // by replacing it with `-EYEDIR`. |
| 25 | vec3 eyedir = vec3(EYEDIR.x, EYEDIR.y, EYEDIR.z); |
| 26 | COLOR = texture(source_panorama, eyedir).rgb * exposure; |
| 27 | } |
| 28 | [/codeblock] |
| 29 | After replacing the shader code and saving, specify the imported Cubemap resource in the Shader Parameters section of the ShaderMaterial in the inspector. |
| 30 | Alternatively, you can use [url=https://danilw.github.io/GLSL-howto/cubemap_to_panorama_js/cubemap_to_panorama.html]this tool[/url] to convert a cubemap to an equirectangular sky map and use [PanoramaSkyMaterial] as usual. |
| 31 | </description> |
| 32 | <tutorials> |
| 33 | </tutorials> |
| 34 | <methods> |
| 35 | <method name="create_placeholder" qualifiers="const"> |
| 36 | <return type="Resource" /> |
| 37 | <description> |
| 38 | Creates a placeholder version of this resource ([PlaceholderCubemap]). |
| 39 | </description> |
| 40 | </method> |
| 41 | </methods> |
| 42 | </class> |