Documentation
¶
Index ¶
- Variables
- func GetShaderWeight(id string) int
- func HasXBR(shaderIDs []string) bool
- func IsPreprocess(id string) bool
- type EffectContext
- type Manager
- func (m *Manager) ApplyPreprocessEffects(src *ebiten.Image, par float64, shaderIDs []string, screenW, screenH int) (*ebiten.Image, Picture)
- func (m *Manager) ApplyShaders(dst, src *ebiten.Image, shaderIDs []string, picture Picture) bool
- func (m *Manager) Frame() int
- func (m *Manager) IncrementFrame()
- func (m *Manager) LoadShader(id string) error
- func (m *Manager) PreloadShaders(ids []string)
- func (m *Manager) ReleaseGameBuffers()
- func (m *Manager) ResetBuffers()
- func (m *Manager) SetAspectRatioMode(mode string)
- type Picture
- type ShaderInfo
- type XBRScaler
Constants ¶
This section is empty.
Variables ¶
var AvailableShaders = []ShaderInfo{ { ID: "xbr", Name: "Pixel Smoothing (xBR)", Description: "Smooth edges while preserving pixel art details", Preprocess: true, Context: ContextGame, }, { ID: "ghosting", Name: "Phosphor Persistence", Description: "Ghost trails from slow CRT phosphor decay", Preprocess: true, Context: ContextGame, }, { ID: "overscan", Name: "Overscan Crop", Description: "Crop the simulated overscan border", Preprocess: true, Context: ContextGame, }, { ID: "crt", Name: "CRT", Description: "Curved screen with RGB separation and vignette", Weight: 25, Context: ContextAll, }, { ID: "scanlines", Name: "Scanlines", Description: "Horizontal scanline effect", Weight: 400, Context: ContextAll, }, { ID: "bloom", Name: "Phosphor Glow", Description: "Bright pixels glow into neighbors like CRT phosphors", Weight: 550, Context: ContextAll, }, { ID: "lcd", Name: "LCD Grid", Description: "Visible pixel grid with RGB subpixels like handhelds", Weight: 300, Context: ContextAll, }, { ID: "colorbleed", Name: "Color Bleed", Description: "Horizontal color bleeding from composite video", Weight: 800, Context: ContextAll, }, { ID: "dotmatrix", Name: "Dot Matrix", Description: "Circular pixels like CRT phosphor dots", Weight: 350, Context: ContextAll, }, { ID: "ntsc", Name: "NTSC Artifacts", Description: "Color fringing at edges from NTSC encoding", Weight: 850, Context: ContextAll, }, { ID: "rainbow", Name: "NTSC Rainbow", Description: "Rainbow artifacts from dithering on composite video", Weight: 845, Context: ContextAll, }, { ID: "gamma", Name: "CRT Gamma", Description: "Non-linear brightness curve of CRT displays", Weight: 900, Context: ContextAll, }, { ID: "halation", Name: "Halation", Description: "Light bleeding behind CRT glass", Weight: 500, Context: ContextAll, }, { ID: "rfnoise", Name: "RF Noise", Description: "Subtle static grain from RF connection", Weight: 50, Context: ContextAll, }, { ID: "rollingband", Name: "Rolling Band", Description: "Scrolling dark band for bad reception look", Weight: 80, Context: ContextAll, }, { ID: "vhs", Name: "VHS Distortion", Description: "Wobble and tracking artifacts like VHS tape", Weight: 100, Context: ContextAll, }, { ID: "interlace", Name: "Interlace", Description: "Alternating scanline fields for 480i look", Weight: 380, Context: ContextAll, }, { ID: "hsoft", Name: "Horizontal Softness", Description: "Bandwidth-limited horizontal blur like analog video", Weight: 770, Context: ContextAll, }, { ID: "vblur", Name: "Vertical Blur", Description: "Electron beam softness causing scanline bleed", Weight: 760, Context: ContextAll, }, { ID: "monochrome", Name: "Monochrome", Description: "Black and white conversion", Weight: 700, Context: ContextAll, }, { ID: "sepia", Name: "Sepia", Description: "Warm brownish tint like old photographs", Weight: 650, Context: ContextAll, }, }
AvailableShaders lists all shaders that can be enabled
Functions ¶
func GetShaderWeight ¶
GetShaderWeight returns the weight for a shader ID (0 if unknown)
func IsPreprocess ¶
IsPreprocess returns true if the shader ID is a preprocessing effect
Types ¶
type EffectContext ¶
type EffectContext int
EffectContext describes where an effect can be applied
const ( ContextGame EffectContext = 1 << iota ContextUI ContextAll = ContextGame | ContextUI )
func GetShaderContext ¶
func GetShaderContext(id string) EffectContext
GetShaderContext returns the context for a shader ID (0 if unknown)
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager handles shader compilation, caching, and application
func NewManager ¶
NewManager creates a new shader manager with the given pixel aspect ratio (used by xBR scaling to compute display aspect ratio per frame).
func (*Manager) ApplyPreprocessEffects ¶
func (m *Manager) ApplyPreprocessEffects(src *ebiten.Image, par float64, shaderIDs []string, screenW, screenH int) (*ebiten.Image, Picture)
ApplyPreprocessEffects runs the native-frame effects pipeline and returns a screen-sized image with the picture's placement in it. src must be the native-resolution game frame and par the pixel aspect ratio delivered with it. The frame is cropped (overscan), promoted to screen size (xBR when enabled, otherwise a plain scale), then ghosted. None of these are Kage shaders.
func (*Manager) ApplyShaders ¶
ApplyShaders draws src to dst with the specified shader chain applied. If shaderIDs is empty, src is drawn directly to dst. picture is the placement of the game picture within src, which the scanline shaders lay their lines over. Note: Preprocessing effects (xBR, ghosting) should be applied via ApplyPreprocessEffects before calling this function. Returns true if shaders were applied, false if direct draw was used.
func (*Manager) IncrementFrame ¶
func (m *Manager) IncrementFrame()
IncrementFrame advances the frame counter for animated shaders
func (*Manager) LoadShader ¶
LoadShader compiles and caches a shader by ID
func (*Manager) PreloadShaders ¶
PreloadShaders loads all shaders in the given list
func (*Manager) ReleaseGameBuffers ¶ added in v0.7.0
func (m *Manager) ReleaseGameBuffers()
ReleaseGameBuffers frees the buffers only gameplay uses: the ghosting and scale buffers and the xBR buffers. The shader chain buffers are kept since the UI uses them too. Call when gameplay ends.
func (*Manager) ResetBuffers ¶
func (m *Manager) ResetBuffers()
ResetBuffers clears all effect buffers. Call when switching games.
func (*Manager) SetAspectRatioMode ¶
SetAspectRatioMode sets the aspect ratio mode used for scaling, forwarding it to the xBR scaler.
type Picture ¶ added in v0.6.0
Picture is the placement of the game picture within a screen-sized image, in pixels, with any letterbox or pillarbox bars outside it. Shaders that draw a line structure place it over the picture's rows.
func FullPicture ¶ added in v0.6.0
FullPicture is the placement of a picture covering the whole of a screen-sized image of the size.
type ShaderInfo ¶
type ShaderInfo struct {
ID string // Unique identifier used in config
Name string // Display name for UI
Description string // Brief description of the effect
Weight int // Higher weight = applied earlier in chain
Preprocess bool // True for preprocessing effects (xBR, ghosting)
Context EffectContext // Where this effect can be applied
}
ShaderInfo describes an available shader effect
type XBRScaler ¶
type XBRScaler struct {
// contains filtered or unexported fields
}
XBRScaler handles xBR pixel art scaling with cascaded 2x passes. Supports 2x (1 pass), 4x (2 passes), and 8x (3 passes) scaling, with fewer passes when a pass's output would exceed the maximum image size. Buffers are pooled and reused to avoid per-frame GPU allocations, and only the buffers of the passes run are kept.
func NewXBRScaler ¶
NewXBRScaler creates a new xBR scaler instance with the given pixel aspect ratio.
func (*XBRScaler) Apply ¶
Apply runs xBR scaling on the source and returns a screen-sized image. Automatically selects 2x, 4x, or 8x scaling based on screen size, then drops passes whose output would exceed the maximum image size; with no pass left the source is scaled to the screen directly. par is the pixel aspect ratio delivered with this frame, used for the final scale.
func (*XBRScaler) Picture ¶ added in v0.6.0
Picture returns the placement of the picture Apply last drew.
func (*XBRScaler) Release ¶ added in v0.7.0
func (x *XBRScaler) Release()
Release frees every buffer. Call when gameplay ends; the next Apply creates the buffers again.
func (*XBRScaler) SetAspectRatioMode ¶
SetAspectRatioMode sets the aspect ratio scaling mode ("dar", "4:3", "1:1", "stretch").