Documentation
¶
Overview ¶
inputs/image.go
Index ¶
- type Buffer
- func (b *Buffer) BindForWriting()
- func (b *Buffer) ChannelRes() [3]float32
- func (b *Buffer) Destroy()
- func (b *Buffer) GetCType() string
- func (b *Buffer) GetSamplerType() string
- func (b *Buffer) GetTextureID() uint32
- func (b *Buffer) Resize(width, height int)
- func (b *Buffer) SwapBuffers()
- func (b *Buffer) UnbindForWriting()
- func (b *Buffer) Update(uniforms *Uniforms)
- func (b *Buffer) UpdateTextureParameters(wrap, filter string, sampler api.Sampler)
- type CubeMapChannel
- type IChannel
- type ImageChannel
- type MicChannel
- func (c *MicChannel) ChannelRes() [3]float32
- func (c *MicChannel) Destroy()
- func (c *MicChannel) GetCType() string
- func (c *MicChannel) GetSamplerType() string
- func (c *MicChannel) GetTextureID() uint32
- func (c *MicChannel) ProcessAudio(monoSamples []float32)
- func (c *MicChannel) SampleRate() int
- func (c *MicChannel) Update(uniforms *Uniforms)
- type Uniforms
- type VolumeChannel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Buffer ¶
type Buffer struct {
// Render pass specific state that will be set by the renderer
ShaderProgram uint32
PassInputs []IChannel
QuadVAO uint32
// contains filtered or unexported fields
}
Buffer manages two sets of FBOs and textures for double-buffering. This allows for effects where a shader pass reads from the output of the previous frame.
func NewBuffer ¶
NewBuffer creates the necessary OpenGL resources for a render buffer. It initializes two framebuffers and two textures for double buffering.
func (*Buffer) BindForWriting ¶
func (b *Buffer) BindForWriting()
BindForWriting binds the current write-target FBO.
func (*Buffer) ChannelRes ¶
func (*Buffer) GetSamplerType ¶
func (*Buffer) GetTextureID ¶
GetTextureID returns the ID of the texture that should be read from (the result of the previous frame).
func (*Buffer) SwapBuffers ¶
func (b *Buffer) SwapBuffers()
SwapBuffers toggles the read/write indices. This is called after the buffer has been rendered to.
func (*Buffer) UnbindForWriting ¶
func (b *Buffer) UnbindForWriting()
UnbindForWriting unbinds the FBO.
type CubeMapChannel ¶
type CubeMapChannel struct {
// contains filtered or unexported fields
}
CubeMapChannel represents a cube map texture input.
func NewCubeMapChannel ¶
NewCubeMapChannel creates and initializes a new OpenGL cube map texture from six images.
func (*CubeMapChannel) ChannelRes ¶
func (c *CubeMapChannel) ChannelRes() [3]float32
func (*CubeMapChannel) Destroy ¶
func (c *CubeMapChannel) Destroy()
func (*CubeMapChannel) GetCType ¶
func (c *CubeMapChannel) GetCType() string
func (*CubeMapChannel) GetSamplerType ¶
func (c *CubeMapChannel) GetSamplerType() string
func (*CubeMapChannel) GetTextureID ¶
func (c *CubeMapChannel) GetTextureID() uint32
func (*CubeMapChannel) Update ¶
func (c *CubeMapChannel) Update(uniforms *Uniforms)
type IChannel ¶
type IChannel interface {
// GetCType return the ctype of the input
GetCType() string
// Update is called once per frame, passing in the global uniforms.
Update(uniforms *Uniforms)
// GetTextureID returns the OpenGL texture ID that should be bound.
GetTextureID() uint32
// ChannelRes returns the resolution of the input channel as a vec3.
ChannelRes() [3]float32
// Destroy releases any resources held by the channel.
Destroy()
// GetSamplerType returns the GLSL sampler type (e.g., "sampler2D", "samplerCube").
GetSamplerType() string
}
IChannel defines the contract for any Shadertoy input channel (iChannel0-3).
func GetChannels ¶
func GetChannels(shaderInputs []*api.ShadertoyChannel, width, height int, vao uint32, buffers map[string]*Buffer, options *options.ShaderOptions, ad audio.AudioDevice) ([]IChannel, error)
type ImageChannel ¶
type ImageChannel struct {
// contains filtered or unexported fields
}
ImageChannel represents a static image texture input.
func NewImageChannel ¶
NewImageChannel creates and initializes a new OpenGL texture from an image.
func (*ImageChannel) ChannelRes ¶
func (c *ImageChannel) ChannelRes() [3]float32
func (*ImageChannel) Destroy ¶
func (c *ImageChannel) Destroy()
func (*ImageChannel) GetCType ¶
func (c *ImageChannel) GetCType() string
IChannel Interface Implementation
func (*ImageChannel) GetSamplerType ¶
func (c *ImageChannel) GetSamplerType() string
func (*ImageChannel) GetTextureID ¶
func (c *ImageChannel) GetTextureID() uint32
func (*ImageChannel) Update ¶
func (c *ImageChannel) Update(uniforms *Uniforms)
type MicChannel ¶
type MicChannel struct {
// contains filtered or unexported fields
}
MicChannel acts as a consumer of an audio stream.
func NewMicChannel ¶
func NewMicChannel(options *options.ShaderOptions, sampler api.Sampler, ad audio.AudioDevice) (*MicChannel, error)
NewMicChannel creates a channel that gets data from the default microphone.
func NewMicChannelWithDevice ¶
func NewMicChannelWithDevice(device audio.AudioDevice, options *options.ShaderOptions, sampler api.Sampler) (*MicChannel, error)
func (*MicChannel) ChannelRes ¶
func (c *MicChannel) ChannelRes() [3]float32
func (*MicChannel) Destroy ¶
func (c *MicChannel) Destroy()
Destroy just calls Stop() on the device.
func (*MicChannel) GetCType ¶
func (c *MicChannel) GetCType() string
IChannel Interface Implementation
func (*MicChannel) GetSamplerType ¶
func (c *MicChannel) GetSamplerType() string
func (*MicChannel) GetTextureID ¶
func (c *MicChannel) GetTextureID() uint32
func (*MicChannel) ProcessAudio ¶
func (c *MicChannel) ProcessAudio(monoSamples []float32)
ProcessAudio performs the FFT on the provided mono samples and stores the result in the channel's internal textureData buffer. This should be called from the main render thread before Update.
func (*MicChannel) SampleRate ¶
func (c *MicChannel) SampleRate() int
SampleRate returns the sample rate of the audio device.
func (*MicChannel) Update ¶
func (c *MicChannel) Update(uniforms *Uniforms)
Update reads from the shared buffer for FFT analysis.
type Uniforms ¶
type Uniforms struct {
Time float32
Mouse [4]float32
Frame int32 // Frame count for animations or effects
TimeDelta float32
FrameRate float32
ChannelTime [4]float32
SampleRate float32
ChannelResolution [4][3]float32
}
Uniforms holds the global shader values that dynamic channels might need.
type VolumeChannel ¶
type VolumeChannel struct {
// contains filtered or unexported fields
}
VolumeChannel represents a 3D volume texture input.
func NewVolumeChannel ¶
func NewVolumeChannel(vol *api.VolumeData, sampler api.Sampler) (*VolumeChannel, error)
NewVolumeChannel creates and initializes a new OpenGL 3D texture from parsed .bin volume data.
func (*VolumeChannel) ChannelRes ¶
func (c *VolumeChannel) ChannelRes() [3]float32
func (*VolumeChannel) Destroy ¶
func (c *VolumeChannel) Destroy()
func (*VolumeChannel) GetCType ¶
func (c *VolumeChannel) GetCType() string
IChannel Interface Implementation
func (*VolumeChannel) GetSamplerType ¶
func (c *VolumeChannel) GetSamplerType() string
func (*VolumeChannel) GetTextureID ¶
func (c *VolumeChannel) GetTextureID() uint32
func (*VolumeChannel) Update ¶
func (c *VolumeChannel) Update(uniforms *Uniforms)