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.

Spatial(3D)シェーダー

Spatial shaders are used for shading 3D objects. They are the most complex type of shader Godot offers. Spatial shaders are highly configurable with different render modes and different rendering options (e.g. Subsurface Scattering, Transmission, Ambient Occlusion, Rim lighting, etc.). Users can optionally write vertex, fragment, and light processor functions to affect how objects are drawn.

レンダリングモード

For visual examples of these render modes, see Standard Material 3D and ORM Material 3D.

レンダリングモード

説明

blend_mix

ミックスブレンドモード(アルファは透明度)、デフォルト。

blend_add

加算ブレンドモード。

blend_sub

減算ブレンドモード。

blend_mul

乗法ブレンドモード。

blend_premul_alpha

Premultiplied alpha blend mode (fully transparent = add, fully opaque = mix).

depth_draw_opaque

不透明なジオメトリに対してのみ深度を描画します(透明ではありません)。

depth_draw_always

常に深度を描画します(不透明および透明)。

depth_draw_never

深度の描画をしません。

depth_prepass_alpha

半透明ジオメトリでも深さの事前パス(デプスプリパス)を行います。

depth_test_disabled

深度テストを無効にします。

depth_test_default

Depth test will discard the pixel if it is behind other pixels. In Forward+ only, the pixel is also discarded if it's at the exact same depth as another pixel.

depth_test_inverted

Depth test will discard the pixel if it is in front of other pixels. Useful for stencil effects.

sss_mode_skin

Subsurface Scattering mode for skin (optimizes visuals for human skin, e.g. boosted red channel).

cull_back

背面(法線が視点と逆方向に向いている)を間引きます(デフォルト)。

cull_front

前面(法線が視点の方向に向いている)を間引きます。

cull_disabled

カリングは無効です(両面を描画)。

unshaded

Result is just albedo. No lighting/shading happens in material, making it faster to render.

wireframe

Geometry draws using lines (useful for troubleshooting). When using the Compatibility renderer, you must call RenderingServer.set_debug_generate_wireframes(true) before the mesh is loaded for wireframe rendering to work. In the Compatibility renderer, backface culling is always disabled in wireframe mode, while in the Forward+ and Mobile renderers, the cull mode is respected.

debug_shadow_splits

Directional shadows are drawn using different colors for each split (useful for troubleshooting).

diffuse_burley

拡散反射を物理ベース Burley (Disney PBS) で計算します (デフォルト)。

diffuse_lambert

拡散反射をランバートシェーディングで計算します。

diffuse_lambert_wrap

Lambert-wrap shading (roughness-dependent) for diffuse.

diffuse_toon

拡散反射をトゥーンシェーディングで計算します。

specular_schlick_ggx

Schlick-GGX for direct light specular lobes (default).

specular_toon

Toon for direct light specular lobes.

specular_disabled

Disable direct light specular lobes. Doesn't affect reflected light (use SPECULAR = 0.0 instead).

skip_vertex_transform

VERTEX, NORMAL, TANGENT, and BITANGENT need to be transformed manually in the vertex() function.

world_vertex_coords

VERTEX, NORMAL, TANGENT, and BITANGENT are modified in world space instead of model space.

ensure_correct_normals

Use when non-uniform scale is applied to mesh (note: currently unimplemented).

shadows_disabled

Disable computing shadows in shader. The shader will not receive shadows, but can still cast them.

ambient_light_disabled

環境光と輝度マップからの影響を無効にします。

shadow_to_opacity

ライティングはアルファを修正し、影のある領域は不透明になり、影のない領域は透明になります。 ARのカメラフィードに影を重ねるのに便利です。

vertex_lighting

Use vertex-based lighting instead of per-pixel lighting.

particle_trails

Enables the trails when used on particle geometry.

alpha_to_coverage

アルファによるアンチエイリアシングモード。詳細については こちら を参照してください。

alpha_to_coverage_and_one

アルファによるアンチエイリアシングモード。詳細については こちら を参照してください。

fog_disabled

Disable receiving depth-based or volumetric fog. Useful for blend_add materials like particles.

Stencil modes

注釈

Stencil support is experimental, use at your own risk. We will try to not break compatibility as much as possible, but if significant flaws are found in the API, it may change in the next minor version.

Stencil operations are a set of operations that allow writing to an efficient buffer in an hardware-accelerated manner. This is generally used to mask in or out parts of the scene.

Some of the most well-known uses are:

  • Outlines: Mask out the inner mesh that is being outlined to avoid inner outlines.

  • X-Ray: Display a mesh behind other objects.

  • Portals: Draw geometry that is normally "impossible" (non-Euclidian) by masking objects.

注釈

You can only read from the stencil buffer in the transparent pass. Any attempt to read in the opaque pass will fail, as it's currently not supported behavior.

Note that for compositor effects, the main renderer's stencil buffer can't be copied to a custom texture.

Stencil mode

説明

read

Read from the stencil buffer.

write

Write reference value to the stencil buffer.

write_if_depth_fail

Write reference value to the stencil buffer if the depth test fails.

compare_always

Always pass stencil test.

compare_equal

Pass stencil test if the reference value is equal to the stencil buffer value.

compare_not_equal

Pass stencil test if the reference value is not equal to the stencil buffer value.

compare_less

Pass stencil test if the reference value is less than the stencil buffer value.

compare_less_or_equal

Pass stencil test if the reference value is less than or equal to the stencil buffer value.

compare_greater

Pass stencil test if the reference value is greater than the stencil buffer value.

compare_greater_or_equal

Pass stencil test if the reference value is greater than or equal to the stencil buffer value.

ビルトイン

Values marked as in are read-only. Values marked as out can optionally be written to and will not necessarily contain sensible values. Values marked as inout provide a sensible default value, and can optionally be written to. Samplers cannot be written to so they are not marked.

Not all built-ins are available in all processing functions. To access a vertex built-in from the fragment() function, you can use a varying. The same applies for accessing fragment built-ins from the light() function.

グローバルビルトイン

グローバルビルトインは、カスタム関数を含め、どこでも使用できます。

ビルトイン

説明

in float TIME

Global time since the engine has started, in seconds. It repeats after every 3,600 seconds (which can be changed with the rollover setting). It's affected by time_scale but not by pausing. If you need a TIME variable that is not affected by time scale, add your own global shader uniform and update it each frame.

in float PI

A PI constant (3.141592). The ratio of a circle's circumference to its diameter and the number of radians in a half turn.

in float TAU

A TAU constant (6.283185). Equivalent to PI * 2 and the number of radians in a full turn.

in float E

An E constant (2.718281). Euler's number, the base of the natural logarithm.

in bool OUTPUT_IS_SRGB

true when output is in sRGB color space (this is true in the Compatibility renderer, false in Forward+ and Mobile).

in float CLIP_SPACE_FAR

Clip space far z value. In the Forward+ or Mobile renderers, it's 0.0. In the Compatibility renderer, it's -1.0.

in bool IS_MULTIVIEW

true when output is stereoscopic (XR), false when output is monoscopic.

in bool IN_SHADOW_PASS

true when the shader is being rendered in a shadow mapping pass, false otherwise. This can be used to render objects differently in shadow maps compared to their regular rendering.

頂点プロセッサーのビルトイン

Vertex data (VERTEX, NORMAL, TANGENT, and BITANGENT) are presented in model space (also called local space). If not written to, these values will not be modified and be passed through as they came, then transformed into view space to be used in fragment().

They can optionally be presented in world space by using the world_vertex_coords render mode.

ユーザーは、ビルトインのmodelview変換を無効にし(投影は後で行われます)、次のコードを使用して手動で実行できます。

shader_type spatial;
render_mode skip_vertex_transform;

void vertex() {
    VERTEX = (MODELVIEW_MATRIX * vec4(VERTEX, 1.0)).xyz;
    NORMAL = normalize((MODELVIEW_MATRIX * vec4(NORMAL, 0.0)).xyz);
    BINORMAL = normalize((MODELVIEW_MATRIX * vec4(BINORMAL, 0.0)).xyz);
    TANGENT = normalize((MODELVIEW_MATRIX * vec4(TANGENT, 0.0)).xyz);
}

Other built-ins, such as UV, UV2, and COLOR, are also passed through to the fragment() function if not modified.

ユーザーはビルトインの POSITION を使用して、モデルビューと投影変換をオーバーライドできます。シェーダー内のどこかで POSITION に書き込まれた場合、ユーザーはそれが常に有効値であることを確認する責任があります。 POSITION が使用される場合、 VERTEX の値は無視されプロジェクション計算は行われません。ただしフラグメントシェーダーに渡される値は依然として VERTEX から取得されます。

For instancing, the INSTANCE_CUSTOM variable contains the instance custom data. When using particles, this information is usually:

  • x: ラジアン単位の回転角度。

  • y: Phase during lifetime (0.0 to 1.0).

  • z: アニメーションフレーム。

This allows you to easily adjust the shader to a particle system using default particle material. When writing a custom particle shader, this value can be used as desired.

ビルトイン

説明

in vec2 VIEWPORT_SIZE

ビューポートのサイズ (ピクセル単位)。

in mat4 VIEW_MATRIX

ワールド空間からビュー空間への変換。

in mat4 INV_VIEW_MATRIX

ビュー空間からワールド空間への変換。

in mat4 MAIN_CAM_INV_VIEW_MATRIX

View space to world space transform of the camera used to draw the current viewport.

in mat4 INV_PROJECTION_MATRIX

クリップ空間からビュー空間への変換。

in vec3 NODE_POSITION_WORLD

ワールド空間内のノードの位置。

in vec3 NODE_POSITION_VIEW

ビュー空間内のノードの位置。

in vec3 CAMERA_POSITION_WORLD

Camera position, in world space. Represents the midpoint of the two eyes when in multiview/stereo rendering.

in vec3 CAMERA_DIRECTION_WORLD

ワールド空間内のカメラの方向。

in uint CAMERA_VISIBLE_LAYERS

Cull layers of the camera rendering the current pass.

in int INSTANCE_ID

インスタンス化のためのインスタンスID。

in vec4 INSTANCE_CUSTOM

インスタンスのカスタムデータ(主にパーティクル用)。

in int VIEW_INDEX

現在レンダリングしているビューの番号。モノラルレンダリングまたはステレオレンダリングの左目の場合は VIEW_MONO_LEFT (0)、ステレオレンダリングの右目の場合は VIEW_RIGHT (1) です。

in int VIEW_MONO_LEFT

モノラルまたは左目の場合の定数で、常に 0 です。

in int VIEW_RIGHT

右目の場合は定数で、常に 1 になります。

in vec3 EYE_OFFSET

Position offset for the eye being rendered, in view space. Only applicable for multiview rendering.

inout vec3 VERTEX

Position of the vertex, in model space. In world space if world_vertex_coords is used.

in int VERTEX_ID

頂点バッファー内の現在の頂点インデックス。

inout vec3 NORMAL

Normal in model space. In world space if world_vertex_coords is used.

inout vec3 TANGENT

Tangent in model space. In world space if world_vertex_coords is used.

inout vec3 BINORMAL

Binormal in model space. In world space if world_vertex_coords is used.

out vec4 POSITION

If written to on any branch, overrides final vertex position in clip space.

inout vec2 UV

UVメインチャネル。

inout vec2 UV2

UVセカンダリチャネル。

inout vec4 COLOR

Color from vertices. Limited to values between 0.0 and 1.0 for each channel and 8 bits per channel precision (256 possible levels). Alpha channel is supported. Values outside the allowed range are clamped, and values may be rounded due to precision limitations. Use CUSTOM0-CUSTOM3 to pass data with more precision if needed.

out float ROUGHNESS

頂点ライティング用の粗さ(ラフネス)。

inout float POINT_SIZE

ポイントレンダリングのポイントサイズ。

inout mat4 MODELVIEW_MATRIX

Model/local space to view space transform (use if possible).

inout mat3 MODELVIEW_NORMAL_MATRIX

in mat4 MODEL_MATRIX

Model/local space to world space transform.

in mat3 MODEL_NORMAL_MATRIX

inout mat4 PROJECTION_MATRIX

ビュー空間からクリップ空間への変換。

in uvec4 BONE_INDICES

in vec4 BONE_WEIGHTS

in vec4 CUSTOM0

Custom value from vertex primitive. When using extra UVs, xy is UV3 and zw is UV4.

in vec4 CUSTOM1

Custom value from vertex primitive. When using extra UVs, xy is UV5 and zw is UV6.

in vec4 CUSTOM2

Custom value from vertex primitive. When using extra UVs, xy is UV7 and zw is UV8.

in vec4 CUSTOM3

Custom value from vertex primitive.

out float Z_CLIP_SCALE

If written to on any branch, scales the vertex towards the camera to avoid clipping into things like walls. Lighting and shadows will continue to work correctly when this is written to, but screen-space effects like SSAO and SSR may break with lower scales. Try to keep this value as close to 1.0 as possible.

注釈

MODELVIEW_MATRIXMODEL_MATRIXVIEW_MATRIX の両方を合成したもので、浮動小数点の問題が発生する可能性がある場合に適しています。例えばオブジェクトがワールド原点から非常に離れている場合、分離された MODEL_MATRIXVIEW_MATRIX を使用すると浮動小数点の問題が発生する可能性があります。

注釈

INV_VIEW_MATRIX is the matrix used for rendering the object in that pass, unlike MAIN_CAM_INV_VIEW_MATRIX, which is the matrix of the camera in the scene. In the shadow pass, INV_VIEW_MATRIX's view is based on the camera that is located at the position of the light.

フラグメントプロセッサーのビルトイン

Godotフラグメントプロセッサ関数のデフォルトの用途は、オブジェクトのマテリアルプロパティを設定し、組み込みレンダラーに最終シェーディングを処理させることです。ただし、これらのプロパティをすべて使用する必要はありません。これらのプロパティに書き込みを行わない場合、Godotは対応する機能を最適化します。

ビルトイン

説明

in vec2 VIEWPORT_SIZE

ビューポートのサイズ (ピクセル単位)。

in vec4 FRAGCOORD

Coordinate of pixel center in screen space. xy specifies position in window. Upper-left of the viewport is the origin, (0.0, 0.0). Bottom-right of the viewport is (1.0, 1.0). z specifies fragment depth. It is also used as the output value for the fragment depth unless DEPTH is written to.

in bool FRONT_FACING

true if current face is front facing, false otherwise.

in vec3 VIEW

フラグメント位置からカメラへの正規化されたベクトル (ビュー空間内)。これは遠近法カメラと直交カメラの両方で同じです。

in vec2 UV

UV that comes from the vertex() function.

in vec2 UV2

UV2 that comes from the vertex() function.

in vec4 COLOR

COLOR that comes from the vertex() function.

in vec2 POINT_COORD

Point coordinate for drawing points with POINT_SIZE.

in mat4 MODEL_MATRIX

Model/local space to world space transform.

in mat3 MODEL_NORMAL_MATRIX

Model/local space to world space transform for normals. This is the same as MODEL_MATRIX by default unless the object is scaled non-uniformly, in which case this is set to transpose(inverse(mat3(MODEL_MATRIX))).

in mat4 VIEW_MATRIX

ワールド空間からビュー空間への変換。

in mat4 INV_VIEW_MATRIX

ビュー空間からワールド空間への変換。

in mat4 PROJECTION_MATRIX

ビュー空間からクリップ空間への変換。

in mat4 INV_PROJECTION_MATRIX

クリップ空間からビュー空間への変換。

in vec3 NODE_POSITION_WORLD

ワールド空間内のノードの位置。

in vec3 NODE_POSITION_VIEW

ビュー空間内のノードの位置。

in vec3 CAMERA_POSITION_WORLD

Camera position, in world space. Represents the midpoint of the two eyes when in multiview/stereo rendering.

in vec3 CAMERA_DIRECTION_WORLD

ワールド空間内のカメラの方向。

in uint CAMERA_VISIBLE_LAYERS

Cull layers of the camera rendering the current pass.

in vec3 VERTEX

Position of the fragment (pixel), in view space. It is the VERTEX value from vertex() interpolated between the face's vertices and transformed into view space. If skip_vertex_transform is enabled, it may not be in view space.

inout vec3 LIGHT_VERTEX

ライトとシャドウの計算に使われる位置を変更するための VERTEX の書き込み可能なバージョン。これに書き込んでもフラグメント自体の位置は変わりません。

in int VIEW_INDEX

The view that we are rendering. Used to distinguish between views in multiview/stereo rendering. VIEW_MONO_LEFT (0) for Mono (not multiview) or left eye, VIEW_RIGHT (1) for right eye.

in int VIEW_MONO_LEFT

モノラルまたは左目の場合の定数で、常に 0 です。

in int VIEW_RIGHT

右目の場合は定数で、常に 1 になります。

in vec3 EYE_OFFSET

Position offset for the eye being rendered, in view space. Only applicable for multiview rendering.

sampler2D SCREEN_TEXTURE

Godot 4では削除されました。代わりに sampler2Dhint_screen_texture を使用してください。

in vec2 SCREEN_UV

Screen UV coordinate for the current pixel.

sampler2D DEPTH_TEXTURE

Godot 4では削除されました。代わりに sampler2Dhint_ depth_texture を使用してください。

out float DEPTH

Custom depth value (range [0.0, 1.0]). If DEPTH is written to in any shader branch, then you are responsible for setting DEPTH for all other branches. Otherwise, the graphics API will leave them uninitialized.

inout vec3 NORMAL

Normal that comes from the vertex() function, in view space. If skip_vertex_transform is enabled, it may not be in view space.

inout vec3 TANGENT

Tangent that comes from the vertex() function, in view space. If skip_vertex_transform is enabled, it may not be in view space.

inout vec3 BINORMAL

Binormal that comes from the vertex() function, in view space. If skip_vertex_transform is enabled, it may not be in view space.

out vec3 NORMAL_MAP

Set normal here in tangent space if reading normal from a texture instead of NORMAL. The blue channel is ignored, as it's reconstructed in the engine instead. This allows normal maps with RGTC compression to work.

out float NORMAL_MAP_DEPTH

Depth from NORMAL_MAP. Defaults to 1.0.

out vec3 BENT_NORMAL_MAP

Set bent normal map here in tangent space to enable bent normals. This is used to improve specular occlusion, and requires a specially authored bent normal map. The blue channel is ignored, as it's reconstructed in the engine instead. This allows bent normal maps with RGTC compression to work.

out vec3 ALBEDO

Albedo (default white). Base color.

out float ALPHA

Alpha (range [0.0, 1.0]). If read from or written to, the material will go to the transparent pipeline.

out float ALPHA_SCISSOR_THRESHOLD

If written to on any branch, values below a certain amount of alpha are discarded.

out float ALPHA_HASH_SCALE

Alpha hash scale when using the alpha hash transparency mode. Defaults to 1.0. Higher values result in more visible pixels in the dithering pattern.

out float ALPHA_ANTIALIASING_EDGE

The threshold below which alpha to coverage antialiasing should be used. Defaults to 0.0. Requires the alpha_to_coverage render mode. Should be set to a value lower than ALPHA_SCISSOR_THRESHOLD to be effective.

out vec2 ALPHA_TEXTURE_COORDINATE

The texture coordinate to use for alpha-to-coverge antialiasing. Requires the alpha_to_coverage render mode. Typically set to UV * vec2(albedo_texture_size) where albedo_texture_size is the size of the albedo texture in pixels.

out float PREMUL_ALPHA_FACTOR

Premultiplied alpha factor. Only effective if render_mode blend_premul_alpha; is used. This should be written to when using a shaded material with premultiplied alpha blending for interaction with lighting. This is not required for unshaded materials.

out float METALLIC

Metallic (range [0.0, 1.0]).

out float SPECULAR

Specular (not physically accurate to change). Defaults to 0.5. 0.0 disables reflections.

out float ROUGHNESS

Roughness (range [0.0, 1.0]).

out float RIM

Rim (range [0.0, 1.0]). If used, Godot calculates rim lighting. Rim size depends on ROUGHNESS.

out float RIM_TINT

Rim Tint, range from 0.0 (white) to 1.0 (albedo). If used, Godot calculates rim lighting.

out float CLEARCOAT

Small specular blob added on top of the existing one. If used, Godot calculates clearcoat.

out float CLEARCOAT_GLOSS

Gloss of clearcoat. If used, Godot calculates clearcoat.

out float ANISOTROPY

接線空間に応じてスペキュラーblobを歪ませます。

out vec2 ANISOTROPY_FLOW

歪みの方向。フローマップで使用します。

out float SSS_STRENGTH

Strength of subsurface scattering. If used, subsurface scattering will be applied to the object.

out vec4 SSS_TRANSMITTANCE_COLOR

Color of subsurface scattering transmittance. If used, subsurface scattering transmittance will be applied to the object.

out float SSS_TRANSMITTANCE_DEPTH

Depth of subsurface scattering transmittance. Higher values allow the effect to reach deeper into the object.

out float SSS_TRANSMITTANCE_BOOST

Boosts the subsurface scattering transmittance if set above 0.0. This makes the effect show up even on directly lit surfaces

inout vec3 BACKLIGHT

Color of backlighting (works like direct light, but it's received even if the normal is slightly facing away from the light). If used, backlighting will be applied to the object. Can be used as a cheaper approximation of subsurface scattering.

out float AO

Strength of ambient occlusion. For use with pre-baked AO.

out float AO_LIGHT_AFFECT

How much ambient occlusion affects direct light (range [0.0, 1.0], default 0.0).

out vec3 EMISSION

Emission color (can go over (1.0, 1.0, 1.0) for HDR).

out vec4 FOG

If written to on any branch, blends final pixel color with FOG.rgb based on FOG.a.

out vec4 RADIANCE

If written to on any branch, blends environment map radiance with RADIANCE.rgb based on RADIANCE.a.

out vec4 IRRADIANCE

If written to on any branch, blends environment map irradiance with IRRADIANCE.rgb based on IRRADIANCE.a.

注釈

ALPHA が書き込まれるときに半透明パイプラインを通過するシェーダーは、透明度のソートの問題を引き起こす可能性があります。詳細と問題を回避する方法については、3Dレンダリングの制限 - 透明度の並べ替え をお読みください。

ライトプロセッサーのビルトイン

Writing light processor functions is completely optional. You can skip the light() function by using the unshaded render mode. If no light function is written, Godot will use the material properties written to in the fragment() function to calculate the lighting for you (subject to the render mode).

The light() function is called for every light in every pixel. It is called within a loop for each light type.

Below is an example of a custom light() function using a Lambertian lighting model:

void light() {
    if (LIGHT_IS_AREA) {
        // Area light GGX shading.
        DIFFUSE_LIGHT += LIGHT_AREA_DIFFUSE_MULTIPLIER * ATTENUATION * LIGHT_COLOR;
        SPECULAR_LIGHT += LIGHT_AREA_SPECULAR_MULTIPLIER * ATTENUATION * LIGHT_COLOR * SPECULAR_AMOUNT;
    } else {
        // Used for all other light types (directional, omni, spot).
        DIFFUSE_LIGHT += clamp(dot(NORMAL, LIGHT), 0.0, 1.0) * ATTENUATION * LIGHT_COLOR / PI;
    }
}

ライトを一緒に追加する場合は、上書きするのではなく、+= を使用して DIFFUSE_LIGHT にライトの関与を追加します。

警告

The light() function won't be run if the vertex_lighting render mode is enabled, or if Rendering > Quality > Shading > Force Vertex Shading is enabled in the Project Settings. (It's enabled by default on mobile platforms.)

ビルトイン

説明

in vec2 VIEWPORT_SIZE

ビューポートのサイズ (ピクセル単位)。

in vec4 FRAGCOORD

Coordinate of pixel center in screen space. xy specifies position in window. Upper-left of the viewport is the origin, (0.0, 0.0). Bottom-right of the viewport is (1.0, 1.0). z specifies fragment depth. It is also used as the output value for the fragment depth unless DEPTH is written to.

in mat4 MODEL_MATRIX

Model/local space to world space transform.

in mat4 INV_VIEW_MATRIX

ビュー空間からワールド空間への変換。

in mat4 VIEW_MATRIX

ワールド空間からビュー空間への変換。

in mat4 PROJECTION_MATRIX

ビュー空間からクリップ空間への変換。

in mat4 INV_PROJECTION_MATRIX

クリップ空間からビュー空間への変換。

in vec3 NORMAL

ビュー空間内の法線ベクトル。

in vec2 SCREEN_UV

Screen UV coordinate for the current pixel.

in vec2 UV

UV that comes from the vertex() function.

in vec2 UV2

UV2 that comes from the vertex() function.

in vec3 VIEW

ビュー空間内のカメラ視線ベクトル。

in vec3 LIGHT

Light vector, in view space.

in vec3 LIGHT_COLOR

Light color multiplied by light energy multiplied by PI. The PI multiplication is present because physically-based lighting models include a division by PI.

in float SPECULAR_AMOUNT

For OmniLight3D and SpotLight3D, 2.0 multiplied by light_specular. For DirectionalLight3D, 1.0.

in bool LIGHT_IS_DIRECTIONAL

true if this pass is a DirectionalLight3D.

in float ATTENUATION

距離または影に基づく減衰。

in vec3 ALBEDO

ベースアルベド。

in vec3 BACKLIGHT

in float METALLIC

メタリック (金属感)。

in float ROUGHNESS

ラフネス (粗さ)。

out vec3 DIFFUSE_LIGHT

拡散反射光の結果。

out vec3 SPECULAR_LIGHT

鏡面反射光の結果。

out float ALPHA

Alpha (range [0.0, 1.0]). If written to on any branch, the material will go through the transparent pipeline.

注釈

ALPHA が書き込まれるときに半透明パイプラインを通過するシェーダーは、透明度のソートの問題を引き起こす可能性があります。詳細と問題を回避する方法については、3Dレンダリングの制限 - 透明度の並べ替え をお読みください。

半透明なマテリアルは影を落としたり、 hint_screen_texturehint_depth_texture のUniformに表示したりすることもできません。これにより半透明マテリアルがスクリーン空間の反射や屈折に現れるのを防ぎます。 SDFGI 半透明なマテリアルでは鋭い反射は表示されません (半透明なマテリアルでは粗い反射のみが表示されます)。