Kraken Logo

Kraken Engine

DocumentationGuidesShowcaseCommunity
Ctrl
K
Navigating the Docs
Building Docs
Overview
Anchor
AnimationController
Audio
Batcher
Body
Camera
Capsule
CastHit
CharacterBody
Circle
Collision
Color
DistanceJoint
Effect
Event
FilterJoint
Flip (Texture)
Font
ImageLayer
InputAction
Joint
Layer
Line
Map
MapObject
Mask
MotorJoint
MouseJoint
ObjectGroup
Orchestrator
PixelArray
PolarCoordinate
Polygon
PrismaticJoint
Rect
RevoluteJoint
RigidBody
Sample
Sampler
Shader
SheetStrip
StaticBody
Stream
Style
Terrain (TileSet)
Text
TextProperties
Texture
Tile (TileLayer)
Tile (TileSet)
TileLayer
TileResult (TileLayer)
TileSet
Timer
Transform
Tween
Vec2
Vertex
WeldJoint
WheelJoint
World

Built bydurkisneer1.Kraken Engine is open source and available onGitHub.

  1. Docs
  2. Classes
  3. Shader

Shader

Encapsulates a GPU shader and its associated render state. Access via the 'shaders' submodule.

Constructor

  • Shader(fragment_base_path: str | PathLike[str], uniform_buffer_count: int = 0, sampler_count: int = 1, storage_buffer_sizes: Sequence[int] = []) → ShaderShader(fragment_base_path: str | PathLike[str], uniform_buffer_count: int = 0, sampler_count: int = 1, storage_buffer_sizes: Sequence[int] = []) → Shader

Encapsulates a GPU shader and its associated render state.

Methods


Bind

bind() → Nonebind() → None

Binds this shader state to the current render pass, making it active for subsequent draw calls.

Raises

  • RuntimeError : If the shader state cannot be bound.

Unbind

unbind() → Noneunbind() → None

Unbinds the current shader state, reverting to the default render state.

Set Uniform

set_uniform(binding: int, data: Buffer) → Noneset_uniform(binding: int, data: Buffer) → None

Set uniform data for the fragment shader at the specified binding point.

Args

  • binding : Uniform buffer binding index.
  • data : Buffer-compatible object containing the uniform bytes.

Raises

  • TypeError : If the object does not provide compatible uniform data.
  • RuntimeError : If the uniform data cannot be set.

Set Storage Buffer Data

set_storage_buffer_data(binding: int, data: Buffer) → Noneset_storage_buffer_data(binding: int, data: Buffer) → None

Sets the data for a data storage buffer for the fragment shader at the specified binding.

Currently untested with GLSL.

Args

  • binding : Shader storage buffer binding.
  • data : Buffer-compatible object containing the bytes to be given to the shader buffer.

Raises

  • TypeError : If the object does not provide compatible storage buffer data.
  • RuntimeError : If the storage buffer data cannot be set.

Set Texture Sampler

set_texture_sampler(binding: int, texture: Texture, sampler: Sampler) → Noneset_texture_sampler(binding: int, texture: Texture, sampler: Sampler) → None

Set the texture and sampler used for a fragment shader texture binding.

Args

  • binding : Sampler binding index.
  • texture : Texture to bind. Must have the ShaderSampled usage flag.
  • sampler : Sampler to use for the texture.

Raises

  • RuntimeError : If the texture is not usable as a shader resource.
  • ValueError : If the binding index is out of range.
PreviousSampler
NextSheetStrip

On this page

ConstructorMethodsBindUnbindSet UniformSet Storage Buffer DataSet Texture Sampler