Shader

Inherits: Resource < Reference < Object Inherited By: VisualShader A custom shader program.

Description

ShaderMaterial. Shaders allow you to write your own custom behavior for rendering objects or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.

Tutorials

  • Shaders
  • Introduction to shaders

    Properties

    Methods

    Enumerations

    Mode:
  • MODE_SPATIAL = 0 —- Mode used to draw all 3D objects.
  • MODE_CANVAS_ITEM = 1 —- Mode used to draw all 2D objects.
  • MODE_PARTICLES = 2 —- Mode used to calculate particle information on a per-particle basis. Not used for drawing.

    Property Descriptions

  • String code Returns the shader’s code as the user has written it, not the full generated code used internally.

  • String custom_defines Returns the shader’s custom defines. Custom defines can be used in Godot to add GLSL preprocessor directives (e.g: extensions) required for the shader logic. Note: Custom defines are not validated by the Godot shader parser, so care should be taken when using them.

    Method Descriptions

  • Texture get_default_texture_param ( String param ) const Returns the texture that is set as default for the specified parameter. Note: param must match the name of the uniform in the code exactly.

  • Mode get_mode ( ) const MODE_CANVAS_ITEM, MODE_SPATIAL or MODE_PARTICLES.

  • bool has_param ( String name ) const true if the shader has this param defined as a uniform in its code. Note: param must match the name of the uniform in the code exactly.

  • set_default_texture_param ( String param, Texture texture ) ShaderMaterial. Note: param must match the name of the uniform in the code exactly.