gbuffer

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package gbuffer contains the Handler interface and implementation for managing G-Buffer textures and pipeline keys used in the scene's GI rendering passes.

Index

Constants

This section is empty.

Variables

View Source
var GPUGBufferOutputSource string

GPUGBufferOutputSource is the canonical WGSL definition of the GBufferOutput struct. Matches GPUGBufferOutput layout exactly (48 bytes, std430 aligned).

Functions

This section is empty.

Types

type GBufferHandler

type GBufferHandler = Handler

GBufferHandler is a backward-compatible alias for Handler.

func NewGBufferHandler

func NewGBufferHandler(opts ...GBufferHandlerOption) GBufferHandler

NewGBufferHandler creates a new Handler using the legacy constructor name.

type GBufferHandlerOption

type GBufferHandlerOption = HandlerOption

GBufferHandlerOption is a backward-compatible alias for HandlerOption.

type GPUGBufferOutput

type GPUGBufferOutput struct {
	Position [4]float32
	Normal   [4]float32
	Albedo   [4]float32
}

GPUGBufferOutput is the GPU-aligned representation of a single G-Buffer fragment output. Size: 48 bytes (3 × vec4<f32>).

func (*GPUGBufferOutput) Marshal

func (g *GPUGBufferOutput) Marshal() []byte

Marshal serializes the GPUGBufferOutput struct into a byte buffer.

func (*GPUGBufferOutput) Size

func (g *GPUGBufferOutput) Size() int

Size returns the size of the GPUGBufferOutput struct in bytes.

type Handler added in v0.4.1

type Handler interface {
	// Enabled returns whether the G-Buffer subsystem has been GPU-initialized
	// and is ready for rendering.
	Enabled() bool

	// SetEnabled sets whether the G-Buffer subsystem is GPU-initialized.
	SetEnabled(enabled bool)

	// SetSlot selects the active texture slot.
	SetSlot(slot int)

	// ScreenWidth returns the current screen width in pixels used for texture sizing.
	ScreenWidth() int

	// ScreenHeight returns the current screen height in pixels used for texture sizing.
	ScreenHeight() int

	// PipelineKey retrieves the pipeline key associated with the given name.
	PipelineKey(name string) string

	// PipelineKeys returns the full map of pipeline keys.
	PipelineKeys() map[string]string

	// SetPipelineKey stores a pipeline key under the given name.
	SetPipelineKey(name, key string)

	// NormalTexture returns the RGBA16Float texture storing world-space normals and roughness.
	NormalTexture() *wgpu.Texture

	// SetNormalTexture sets the normal MRT texture.
	SetNormalTexture(t *wgpu.Texture)

	// NormalTextureView returns the texture view for the normal texture.
	NormalTextureView() *wgpu.TextureView

	// SetNormalTextureView sets the texture view for the normal texture.
	SetNormalTextureView(tv *wgpu.TextureView)

	// AlbedoTexture returns the RGBA8Unorm texture storing albedo and metallic.
	AlbedoTexture() *wgpu.Texture

	// SetAlbedoTexture sets the albedo MRT texture.
	SetAlbedoTexture(t *wgpu.Texture)

	// AlbedoTextureView returns the texture view for the albedo texture.
	AlbedoTextureView() *wgpu.TextureView

	// SetAlbedoTextureView sets the texture view for the albedo texture.
	SetAlbedoTextureView(tv *wgpu.TextureView)

	// DepthTexture returns the Depth24Plus texture used for depth testing.
	DepthTexture() *wgpu.Texture

	// SetDepthTexture sets the depth texture for the G-Buffer pass.
	SetDepthTexture(t *wgpu.Texture)

	// DepthTextureView returns the texture view for the G-Buffer depth texture.
	DepthTextureView() *wgpu.TextureView

	// SetDepthTextureView sets the texture view for the G-Buffer depth texture.
	SetDepthTextureView(tv *wgpu.TextureView)

	// Resize updates the screen dimensions for texture sizing.
	Resize(width, height int)
}

Handler defines the interface for the scene's G-Buffer subsystem.

The Handler manages the multiple render target (MRT) textures that store per-pixel geometric and material data written during the G-Buffer pre-pass. These textures are consumed by downstream screen-space effect passes such as SSAO and SSR. GPU resources are initialized lazily by the owning scene when GI features are first enabled.

Thread safety is provided by the owning scene's mutex — the handler itself does not perform internal locking.

func NewHandler added in v0.4.1

func NewHandler(opts ...HandlerOption) Handler

NewHandler creates a new Handler with sensible defaults and any provided options applied.

type HandlerOption added in v0.4.1

type HandlerOption func(*handlerImpl)

HandlerOption is a functional option for configuring a Handler during construction via NewHandler.

func WithScreenSize

func WithScreenSize(width, height int) HandlerOption

WithScreenSize sets the initial screen dimensions used for G-Buffer texture allocation.

Jump to

Keyboard shortcuts

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