:github_url: hide .. _class_RDShaderSource: RDShaderSource ============== **繼承:** :ref:`RefCounted` **<** :ref:`Object` 著色器原始程式碼(由 :ref:`RenderingDevice` 使用)。 .. rst-class:: classref-introduction-group 說明 ---- 文字形式的著色器原始程式碼。 另見 :ref:`RDShaderFile`\ 。\ **RDShaderSource** 應該僅用於 :ref:`RenderingDevice` API。不應將其與 Godot 自己的 :ref:`Shader` 資源,Godot 的各種節點會使用後者來進行高階著色器程式設計。 .. rst-class:: classref-reftable-group 屬性 ---- .. table:: :widths: auto +------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------+ | :ref:`ShaderLanguage` | :ref:`language` | ``0`` | +------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------+ | :ref:`String` | :ref:`source_compute` | ``""`` | +------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------+ | :ref:`String` | :ref:`source_fragment` | ``""`` | +------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------+ | :ref:`String` | :ref:`source_tesselation_control` | ``""`` | +------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------+ | :ref:`String` | :ref:`source_tesselation_evaluation` | ``""`` | +------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------+ | :ref:`String` | :ref:`source_vertex` | ``""`` | +------------------------------------------------------------+---------------------------------------------------------------------------------------------------+--------+ .. rst-class:: classref-reftable-group 方法 ---- .. table:: :widths: auto +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | :ref:`String` | :ref:`get_stage_source`\ (\ stage\: :ref:`ShaderStage`\ ) |const| | +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | |void| | :ref:`set_stage_source`\ (\ stage\: :ref:`ShaderStage`, source\: :ref:`String`\ ) | +-----------------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 屬性說明 -------- .. _class_RDShaderSource_property_language: .. rst-class:: classref-property :ref:`ShaderLanguage` **language** = ``0`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_language**\ (\ value\: :ref:`ShaderLanguage`\ ) - :ref:`ShaderLanguage` **get_language**\ (\ ) 著色器的編寫語言。 .. rst-class:: classref-item-separator ---- .. _class_RDShaderSource_property_source_compute: .. rst-class:: classref-property :ref:`String` **source_compute** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stage_source**\ (\ stage\: :ref:`ShaderStage`, source\: :ref:`String`\ ) - :ref:`String` **get_stage_source**\ (\ stage\: :ref:`ShaderStage`\ ) |const| 著色器計算階段的原始程式碼。 .. rst-class:: classref-item-separator ---- .. _class_RDShaderSource_property_source_fragment: .. rst-class:: classref-property :ref:`String` **source_fragment** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stage_source**\ (\ stage\: :ref:`ShaderStage`, source\: :ref:`String`\ ) - :ref:`String` **get_stage_source**\ (\ stage\: :ref:`ShaderStage`\ ) |const| 著色器片段階段的原始程式碼。 .. rst-class:: classref-item-separator ---- .. _class_RDShaderSource_property_source_tesselation_control: .. rst-class:: classref-property :ref:`String` **source_tesselation_control** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stage_source**\ (\ stage\: :ref:`ShaderStage`, source\: :ref:`String`\ ) - :ref:`String` **get_stage_source**\ (\ stage\: :ref:`ShaderStage`\ ) |const| 著色器曲面細分控制階段的原始程式碼。 .. rst-class:: classref-item-separator ---- .. _class_RDShaderSource_property_source_tesselation_evaluation: .. rst-class:: classref-property :ref:`String` **source_tesselation_evaluation** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stage_source**\ (\ stage\: :ref:`ShaderStage`, source\: :ref:`String`\ ) - :ref:`String` **get_stage_source**\ (\ stage\: :ref:`ShaderStage`\ ) |const| 著色器曲面細分求值階段的原始程式碼。 .. rst-class:: classref-item-separator ---- .. _class_RDShaderSource_property_source_vertex: .. rst-class:: classref-property :ref:`String` **source_vertex** = ``""`` :ref:`🔗` .. rst-class:: classref-property-setget - |void| **set_stage_source**\ (\ stage\: :ref:`ShaderStage`, source\: :ref:`String`\ ) - :ref:`String` **get_stage_source**\ (\ stage\: :ref:`ShaderStage`\ ) |const| 著色器頂點階段的原始程式碼。 .. rst-class:: classref-section-separator ---- .. rst-class:: classref-descriptions-group 方法說明 -------- .. _class_RDShaderSource_method_get_stage_source: .. rst-class:: classref-method :ref:`String` **get_stage_source**\ (\ stage\: :ref:`ShaderStage`\ ) |const| :ref:`🔗` 返回指定著色器階段 ``stage`` 的原始程式碼。等價於獲取 :ref:`source_compute`\ 、\ :ref:`source_fragment`\ 、\ :ref:`source_tesselation_control`\ 、\ :ref:`source_tesselation_evaluation` 或 :ref:`source_vertex`\ 。 .. rst-class:: classref-item-separator ---- .. _class_RDShaderSource_method_set_stage_source: .. rst-class:: classref-method |void| **set_stage_source**\ (\ stage\: :ref:`ShaderStage`, source\: :ref:`String`\ ) :ref:`🔗` Sets ``source`` code for the specified shader ``stage``. Equivalent to setting one of :ref:`source_compute`, :ref:`source_fragment`, :ref:`source_tesselation_control`, :ref:`source_tesselation_evaluation` or :ref:`source_vertex`. \ **Note:** If you set the compute shader source code using this method directly, remember to remove the Godot-specific hint ``#[compute]``. .. |virtual| replace:: :abbr:`virtual (本方法通常需要使用者覆寫才能生效。)` .. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)` .. |const| replace:: :abbr:`const (本方法沒有副作用。不會修改該實例的任何成員變數。)` .. |vararg| replace:: :abbr:`vararg (本方法除了這裡描述的參數外,還可以接受任意數量的參數。)` .. |constructor| replace:: :abbr:`constructor (本方法用於建構一個型別。)` .. |static| replace:: :abbr:`static (本方法無需實例即可呼叫,因此可以直接使用類別名稱呼叫。)` .. |operator| replace:: :abbr:`operator (本方法描述將本型別作為左運算元時可用的有效運算子。)` .. |bitfield| replace:: :abbr:`BitField (此值是由下列旗標組成的位元遮罩整數。)` .. |void| replace:: :abbr:`void (無回傳值。)`