glslfilter

package module
v0.0.0-...-10a8ea6 Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: MIT Imports: 14 Imported by: 0

README

GLSL Image Filter

I've had the mind to create a filter that would make tiled blend passes simple since I published Digital Evolution 14 years ago. I recently came back around to it; I've a lot more experience with graphics and shaders now and it seemed sensible to make something using shader code.

I actually originally was going to write it in Vulkan, but I wanted to skip the boilerplate and the fact that you need to compile shader code to SPIR-V first - while SPIR-V is sensible, it complicates the code here. OpenGL lets me defer that functionality to the driver.

If you just want to try it out, build glslfilter-glfw and see /demo/crt-singlestage and/or /demo/divergence

image image

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFragmentShader

func LoadFragmentShader(fragmentShaderPath string) (string, error)

func LoadTextureData

func LoadTextureData(path string) (texture *image.RGBA, err error)

Types

type Definition

type Definition struct {
	Render struct {
		Width  int
		Height int
	}
	Stages []struct {
		FragmentShaderPath string `yaml:"fragmentShaderPath"`
		Textures           []TextureDefinition
		Uniforms           []UniformDefinition
	}
}

func LoadDefinition

func LoadDefinition(definitionString []byte) (definition Definition, err error)

func LoadDefinitionFromFile

func LoadDefinitionFromFile(reader io.Reader) (definition Definition, err error)

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(viewportDimensions image.Rectangle, debug bool, drawToScreen bool) (engine *Engine, err error)

func (*Engine) GetLastRenderImage

func (engine *Engine) GetLastRenderImage() *image.RGBA

func (*Engine) Init

func (engine *Engine) Init(stages []*FilterStage) (err error)

func (*Engine) Render

func (engine *Engine) Render() error

type FilterStage

type FilterStage struct {
	// contains filtered or unexported fields
}

func NewFilterStage

func NewFilterStage(fragmentShaderSource string, textures []Texture, uniformDefinitions []UniformDefinition) (stage *FilterStage, err error)

type ScalarTypeName

type ScalarTypeName uint
const (
	Float ScalarTypeName
	Int
	Uint
)

type Texture

type Texture struct {
	Data        *image.RGBA
	BindingName string
	Filter      int32
}

type TextureDefinition

type TextureDefinition struct {
	Path   string
	Name   string
	Filter TextureFilterType
}

type TextureFilterType

type TextureFilterType int32

func (*TextureFilterType) UnmarshalYAML

func (filterType *TextureFilterType) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

type Uniform

type Uniform struct {
	Type  UniformType
	Value interface{}
}

type UniformDefinition

type UniformDefinition struct {
	Name  string
	Type  UniformType
	Value interface{}
}

type UniformType

type UniformType struct {
	ScalarType ScalarTypeName
	VectorSize int
	IsArray    bool
}

func (*UniformType) UnmarshalYAML

func (uniformType *UniformType) UnmarshalYAML(unmarshal func(interface{}) error) (err error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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