Documentation ¶
Index ¶
- type Option
- func Opt2BBColor(getColor func(idx int) color.Color) Option
- func Opt2Cam(bb sdf.Box2) Option
- func Opt2EvalRange(min, max float64) Option
- func Opt2EvalScanCells(cells v2i.Vec) Option
- func Opt3BBColor(getColor func(idx int) color.Color) Option
- func Opt3Cam(camCenter v3.Vec, pitch, yaw, dist float64) Option
- func Opt3CamFov(fov float64) Option
- func Opt3Colors(surface, background, error color.RGBA) Option
- func Opt3LightDir(lightDir v3.Vec) Option
- func Opt3Mesh(meshGenerator render.Render3, smoothNormalsRadians float64) Option
- func Opt3NormalEps(normalEps float64) Option
- func Opt3RayConfig(scaleAndSigmoid, stepScale, epsilon float64, maxSteps int) Option
- func Opt3SwapYAndZ() Option
- func OptMBackoff(backOff backoff.BackOff) Option
- func OptMColorMode(colorMode int) Option
- func OptMPartialRenderEvery(duration time.Duration) Option
- func OptMResInv(resInv int) Option
- func OptMRunCommand(runCmd func() *exec.Cmd) Option
- func OptMSmoothCamera(smoothCamera bool) Option
- func OptMWatchFiles(filePaths []string) Option
- func OptMZoom(zoom float64) Option
- type Renderer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option = func(r *Renderer)
Option configures a Renderer to statically change its default behaviour.
func Opt2BBColor ¶
Opt2BBColor sets the bounding box colors for the different objects.
func Opt2Cam ¶
Opt2Cam sets the default camera for SDF2 (may grow to follow the aspect ratio of the screen). WARNING: Need to run again the main renderer to apply a change of this option.
func Opt2EvalRange ¶
Opt2EvalRange skips the initial scan of the SDF2 to find the minimum and maximum value, and can also be used to make the surface easier to see by setting them to a value close to 0.
func Opt2EvalScanCells ¶
Opt2EvalScanCells configures the initial scan of the SDF2 to find minimum and maximum values (defaults to 128x128 cells).
func Opt3BBColor ¶
Opt3BBColor sets the bounding box colors for the different objects.
func Opt3Cam ¶
Opt3Cam sets the default transform for the camera (pivot center, angles and distance). WARNING: Need to run again the main renderer to apply a change of this option.
func Opt3CamFov ¶
Opt3CamFov sets the default Field Of View for the camera (default 90º, in radians).
func Opt3Colors ¶
Opt3Colors changes rendering colors.
func Opt3LightDir ¶
Opt3LightDir sets the light direction for basic lighting simulation. Actually, two lights are simulated (the given one and the opposite one), as part of the surface would be hard to see otherwise
func Opt3Mesh ¶
Opt3Mesh enables and configures the 3D mesh renderer instead of the default raycast based renderer WARNING: Should be the last option applied (as some other options might modify the SDF3).
func Opt3NormalEps ¶
Opt3NormalEps sets the distance between samples used to compute the normals.
func Opt3RayConfig ¶
Opt3RayConfig sets the configuration for the raycast (balancing performance and quality). Rendering a pink pixel means that the ray reached maxSteps without hitting the surface or reaching the limit (consider increasing maxSteps (reduce performance), increasing epsilon or increasing stepScale (both reduce quality)).
func Opt3SwapYAndZ ¶
func Opt3SwapYAndZ() Option
Opt3SwapYAndZ sets the UP direction to Y+ instead of Z+ (or swaps it back).
func OptMBackoff ¶
func OptMBackoff(backOff backoff.BackOff) Option
OptMBackoff changes the default backoff algorithm used when trying to connect to the new code. WARNING: Need to run again the main renderer to apply a change of this option.
func OptMColorMode ¶
OptMColorMode changes the default color mode of the renderer WARNING: Need to run again the main renderer to apply a change of this option.
func OptMPartialRenderEvery ¶
OptMPartialRenderEvery changes the default duration between partial renders (loading a partial render takes a little time and slows down the full render if too frequent). WARNING: Need to run again the main renderer to apply a change of this option.
func OptMResInv ¶
OptMResInv changes the default image pixels per rendererd pixel WARNING: Need to run again the main renderer to apply a change of this option.
func OptMRunCommand ¶
OptMRunCommand replaces the default run command (go run -v .) with any other command generator. WARNING: Need to run again the main renderer to apply a change of this option.
func OptMSmoothCamera ¶
OptMSmoothCamera renders camera frames while dragging the mouse if enabled (2D/3D). Disabled by default. WARNING: Need to run again the main renderer to apply a change of this option.
func OptMWatchFiles ¶
OptMWatchFiles replaces the default set of files to watch for changes (["."]). WARNING: Need to run again the main renderer to apply a change of this option.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer is a SDF2/SDF3 renderer intended for fast development iterations that renders directly to a window. The first time, it starts the renderer process. It also starts listening for code changes. When a code change is detected, the app is recompiled (taking advantage of go's fast compilation times) by the renderer and communicates directly to the renderer, providing the new surface data to the previous window.
It allows very fast SDF updates (saving camera position) whenever the code changes, speeding up the modelling process. The renderer is mainly CPU-based (with a resolution parameter to control speed vs quality), as sdfx is also CPU-based. The scene is only rendered when something changes, as rendering SDFs with good quality is not real-time.
The SDF2 renderer is based on the PNG renderer, showing the image directly on screen (without creating the PNG file). The camera can be moved and scaled (using the mouse), rendering only the interesting part of the SDF.
SDF3s are raycasted from a perspective arc-ball camera that can be rotated around a pivot point, move its pivot and move closer or farther away from the pivot (using Blender-like mouse controls). Note that only the shown surface is actually rendered thanks to raycasting from the camera. This also means that the resulting surface can be much more detailed (depending on chosen resolution) than the triangle meshes generated by standard renderers.
TODO: Once merged, use max-resolution runtime-computed VoxelSdf2 and VoxelSdf3 to accelerate camera movements
It uses ebiten(https://github.com/hajimehoshi/ebiten) for rendering, which is cross-platform, so it could also be used to showcase a surface (without automatic updates) creating an application for desktop, web or mobile.
func NewRenderer ¶
NewRenderer see Renderer