Shader

package
v0.0.0-...-20ed0ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2025 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

A custom shader program implemented in the Godot shading language, saved with the .gdshader extension.

This class is used by a ShaderMaterial and allows you to write your own custom behavior for rendering visual items or updating particle information. For a detailed explanation and usage, please see the tutorials linked below.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsShader() Instance
}

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this Extension

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsRefCounted

func (self *Extension[T]) AsRefCounted() [1]gd.RefCounted

func (*Extension[T]) AsResource

func (self *Extension[T]) AsResource() Resource.Instance

func (*Extension[T]) AsShader

func (self *Extension[T]) AsShader() Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Instance

type Instance [1]gdclass.Shader

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsRefCounted

func (self Instance) AsRefCounted() [1]gd.RefCounted

func (Instance) AsResource

func (self Instance) AsResource() Resource.Instance

func (Instance) AsShader

func (self Instance) AsShader() Instance

func (Instance) Code

func (self Instance) Code() string

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

func (Instance) GetDefaultTextureParameter

func (self Instance) GetDefaultTextureParameter(name string) Texture.Instance

Returns the texture that is set as default for the specified parameter.

Note: 'name' must match the name of the uniform in the code exactly.

Note: If the sampler array is used use 'index' to access the specified texture.

func (Instance) GetMode

func (self Instance) GetMode() Mode

Returns the shader mode for the shader.

func (Instance) GetShaderUniformList

func (self Instance) GetShaderUniformList() []struct{}

Returns the list of shader uniforms that can be assigned to a ShaderMaterial, for use with ShaderMaterial.SetShaderParameter and ShaderMaterial.GetShaderParameter. The parameters returned are contained in dictionaries in a similar format to the ones returned by Object.GetPropertyList.

If argument 'get_groups' is true, parameter grouping hints are also included in the list.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) InspectNativeShaderCode

func (self Instance) InspectNativeShaderCode()

Only available when running in the editor. Opens a popup that visualizes the generated shader code, including all variants and internal shader code. See also Material.InspectNativeShaderCode.

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) SetCode

func (self Instance) SetCode(value string)

SetCode sets the property returned by [GetCode].

func (Instance) SetDefaultTextureParameter

func (self Instance) SetDefaultTextureParameter(name string, texture Texture.Instance)

Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the ShaderMaterial.

Note: 'name' must match the name of the uniform in the code exactly.

Note: If the sampler array is used use 'index' to access the specified texture.

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Mode

type Mode int //gd:Shader.Mode
const (
	// Mode used to draw all 3D objects.
	ModeSpatial Mode = 0
	// Mode used to draw all 2D objects.
	ModeCanvasItem Mode = 1
	// Mode used to calculate particle information on a per-particle basis. Not used for drawing.
	ModeParticles Mode = 2
	// Mode used for drawing skies. Only works with shaders attached to [Sky] objects.
	//
	// [Sky]: https://pkg.go.dev/graphics.gd/classdb/Sky
	ModeSky Mode = 3
	// Mode used for setting the color and density of volumetric fog effect.
	ModeFog Mode = 4
)

type MoreArgs

type MoreArgs [1]gdclass.Shader

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) GetDefaultTextureParameter

func (self MoreArgs) GetDefaultTextureParameter(name string, index int) Texture.Instance

Returns the texture that is set as default for the specified parameter.

Note: 'name' must match the name of the uniform in the code exactly.

Note: If the sampler array is used use 'index' to access the specified texture.

func (MoreArgs) GetShaderUniformList

func (self MoreArgs) GetShaderUniformList(get_groups bool) []struct{}

Returns the list of shader uniforms that can be assigned to a ShaderMaterial, for use with ShaderMaterial.SetShaderParameter and ShaderMaterial.GetShaderParameter. The parameters returned are contained in dictionaries in a similar format to the ones returned by Object.GetPropertyList.

If argument 'get_groups' is true, parameter grouping hints are also included in the list.

func (MoreArgs) SetDefaultTextureParameter

func (self MoreArgs) SetDefaultTextureParameter(name string, texture Texture.Instance, index int)

Sets the default texture to be used with a texture uniform. The default is used if a texture is not set in the ShaderMaterial.

Note: 'name' must match the name of the uniform in the code exactly.

Note: If the sampler array is used use 'index' to access the specified texture.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL