api

package
v0.0.0-...-9afce65 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRawAPIShaderData

func GetRawAPIShaderData(shaderID string) (string, error)

GetRawAPIShaderData fetches the JSON data for a given Shadertoy ID. It sends a POST request to the Shadertoy API endpoint with specific browser-like headers and returns the raw JSON string response.

Types

type BufferRenderPass

type BufferRenderPass struct {
	Code      string
	Inputs    []*ShadertoyChannel
	BufferIdx string
	Name      string
}

BufferRenderPass represents a processed buffer pass.

type Input

type Input struct {
	Channel int     `json:"channel"`
	CType   string  `json:"ctype"`
	Src     string  `json:"src"`
	Sampler Sampler `json:"sampler"`
}

type Output

type Output struct {
	Id      int `json:"id"`
	Channel int `json:"channel"`
}

type RenderPass

type RenderPass struct {
	Inputs  []Input  `json:"inputs"`
	Outputs []Output `json:"outputs"`
	Code    string   `json:"code"`
	Name    string   `json:"name"`
	Type    string   `json:"type"`
}

type Sampler

type Sampler struct {
	Filter   string `json:"filter"`
	Wrap     string `json:"wrap"`
	VFlip    string `json:"vflip"`
	SRGB     string `json:"srgb"`
	Internal string `json:"internal"`
}

type Shader

type Shader struct {
	Info       ShaderInfo   `json:"info"`
	RenderPass []RenderPass `json:"renderpass"`
}

type ShaderArgs

type ShaderArgs struct {
	// ShaderCode string
	CommonCode string
	// Inputs     []*ShadertoyChannel
	Buffers  map[string]*BufferRenderPass
	Title    string
	Complete bool
}

ShaderArgs holds the final, processed arguments for a Shadertoy implementation.

func ShaderArgsFromJSON

func ShaderArgsFromJSON(shaderData *ShadertoyResponse, useCache bool) (*ShaderArgs, error)

ShaderArgsFromJSON builds the final ShaderArgs from the raw API response.

type ShaderInfo

type ShaderInfo struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Username string `json:"username"`
}

type ShaderPasses

type ShaderPasses map[string]*ShaderArgs

type ShadertoyChannel

type ShadertoyChannel struct {
	CType     string
	Channel   int
	Sampler   Sampler
	Data      image.Image    // For textures
	Volume    *VolumeData    // For 3D volume textures
	CubeData  [6]image.Image // For cubemaps
	BufferRef string         // Buffer name that will be attached to this input channel
	MusicFile string         // For audio input channels
}

ShadertoyChannel represents a generic input channel.

type ShadertoyResponse

type ShadertoyResponse struct {
	Shader *Shader `json:"Shader"`
	Error  string  `json:"Error,omitempty"`
	IsAPI  bool    `json:"isAPI,omitempty"` // Indicates if this is an API response
}

func ShaderFromID

func ShaderFromID(apikey string, idOrURL string, useCache bool) (*ShadertoyResponse, error)

ShaderFromID fetches a shader's JSON data from Shadertoy.com by its ID.

type VolumeData

type VolumeData struct {
	Width       uint32
	Height      uint32
	Depth       uint32
	NumChannels uint8
	Layout      uint8  // Currently unused, but parsed for completeness
	Format      uint16 // 0 for I8, 10 for F32
	Data        []byte
}

VolumeData holds the parsed data and metadata for a 3D volume texture.

Jump to

Keyboard shortcuts

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