gsdfaux

package
v0.0.0-...-a9b1306 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ColorConversionInigoQuilez

func ColorConversionInigoQuilez(characteristicDistance float32) func(float32) color.Color

ColorConversionInigoQuilez creates a new color conversion using Inigo Quilez's style. A good value for characteristic distance is the bounding box diagonal divided by 3. Returns red for NaN values.

func ColorConversionLinearGradient

func ColorConversionLinearGradient(gradientLength float32, c0, c1 color.Color) func(d float32) color.Color

ColorConversionLinearGradient creates a color conversion function that creates a gradient centered along d=0 that extends gradientLength.

func MakeGPUSDF2

func MakeGPUSDF2(s glbuild.Shader2D) (sdf gleval.SDF2, err error)

func RenderPNGFile

func RenderPNGFile(filename string, sdf gleval.SDF2, picHeight int, colorConversion func(float32) color.Color) error

RenderPNGFile renders a 2D SDF as an image and saves result to a PNG file with said filename. The image width is sized automatically from the image height argument to preserve SDF aspect ratio. If a nil color conversion function is passed then one is automatically chosen.

func RenderShader3D

func RenderShader3D(s glbuild.Shader3D, cfg RenderConfig) (err error)

RenderShader3D is an auxiliary function to aid users in getting setup in using gsdf quickly. Ideally users should implement their own rendering functions since applications may vary widely.

func UI

func UI(s glbuild.Shader3D, cfg UIConfig) error

Types

type RenderConfig

type RenderConfig struct {
	STLOutput    io.Writer
	VisualOutput io.Writer
	// Resolution decides the STL output resolution. It correlates with the minimum triangle size.
	Resolution float32
	UseGPU     bool
	Silent     bool
	// EnableCaching uses [gleval.BlockCachedSDF3] to omit potential evaluations.
	// Can cut down on times for very complex SDFs, mainly when using CPU.
	EnableCaching bool
	// contains filtered or unexported fields
}

type UIConfig

type UIConfig struct {
	Width, Height int
	Context       context.Context
}

Jump to

Keyboard shortcuts

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