graphics

package
v0.20.1 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2024 License: MIT Imports: 23 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AmbientLight

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

func (*AmbientLight) Active added in v0.10.0

func (l *AmbientLight) Active() bool

func (*AmbientLight) Delete added in v0.19.0

func (l *AmbientLight) Delete()

func (*AmbientLight) Position added in v0.20.0

func (l *AmbientLight) Position() dprec.Vec3

func (*AmbientLight) SetActive added in v0.10.0

func (l *AmbientLight) SetActive(active bool)

type AmbientLightInfo added in v0.10.0

type AmbientLightInfo struct {
	Position          dprec.Vec3
	InnerRadius       float64
	OuterRadius       float64
	ReflectionTexture render.Texture
	RefractionTexture render.Texture
	CastShadow        bool // TODO: Implement SSAO
}

type Armature added in v0.9.0

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

func (*Armature) BoneCount added in v0.9.0

func (a *Armature) BoneCount() int

func (*Armature) SetBone added in v0.9.0

func (a *Armature) SetBone(index int, matrix sprec.Mat4)

type ArmatureInfo added in v0.9.0

type ArmatureInfo struct {
	InverseMatrices []sprec.Mat4
}

type BloomStage added in v0.20.0

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

BloomStage is a stage that produces a bloom overlay texture.

func (*BloomStage) Allocate added in v0.20.0

func (s *BloomStage) Allocate()

func (*BloomStage) BloomTexture added in v0.20.0

func (s *BloomStage) BloomTexture() render.Texture

BloomTexture returns the texture that contains the bloom overlay.

func (*BloomStage) Iterations added in v0.20.0

func (s *BloomStage) Iterations() int

Iterations returns the number of blur iterations that are performed on the bloom overlay texture.

func (*BloomStage) PostRender added in v0.20.0

func (s *BloomStage) PostRender()

func (*BloomStage) PreRender added in v0.20.0

func (s *BloomStage) PreRender(width, height uint32)

func (*BloomStage) Release added in v0.20.0

func (s *BloomStage) Release()

func (*BloomStage) Render added in v0.20.0

func (s *BloomStage) Render(ctx StageContext)

func (*BloomStage) SetIterations added in v0.20.0

func (s *BloomStage) SetIterations(iterations int)

SetIterations sets the number of blur iterations that should be performed on the bloom overlay texture.

type BloomStageInput added in v0.20.0

type BloomStageInput struct {
	HDRTexture StageTextureParameter
}

BloomStageInput is used to configure a BloomStage.

type Camera

type Camera struct {
	Node
	// contains filtered or unexported fields
}

Camera represents a 3D camera.

func (*Camera) AspectRatio

func (c *Camera) AspectRatio() float32

AspectRatio returns the aspect ratio to be maintained when rendering with this camera. This setting works in combination with FoVMode and FoV settings.

func (*Camera) AutoExposure

func (c *Camera) AutoExposure() bool

AutoExposure returns whether this camera will try and automatically adjust the exposure setting to maintain a proper brightness of the final image.

func (*Camera) AutoExposureSpeed added in v0.9.0

func (c *Camera) AutoExposureSpeed() float32

AutoExposureSpeed returns how fast the camera will adjust its exposure.

func (*Camera) AutoFocus

func (c *Camera) AutoFocus() bool

AutoFocus returns whether this camera will try and automatically focus on objects.

func (*Camera) CascadeDistances added in v0.20.0

func (c *Camera) CascadeDistances() []float32

CascadeDistances returns the distances at which the shadow maps of this camera will be split into cascades.

func (*Camera) CascadeFar added in v0.20.0

func (c *Camera) CascadeFar(index int) float32

CascadeFar returns the far distance of the specified cascade index.

func (*Camera) CascadeNear added in v0.20.0

func (c *Camera) CascadeNear(index int) float32

CascadeNear returns the near distance of the specified cascade index.

func (*Camera) Delete

func (c *Camera) Delete()

Delete removes this camera from the scene.

func (*Camera) Exposure

func (c *Camera) Exposure() float32

Exposure returns the exposure setting of this camera.

func (*Camera) Far added in v0.19.0

func (c *Camera) Far() float32

Far returns the distance to the far clipping plane.

func (*Camera) FoV

func (c *Camera) FoV() sprec.Angle

FoV returns the field-of-view angle for this camera.

func (*Camera) FoVMode

func (c *Camera) FoVMode() FoVMode

FoVMode returns the mode of field-of-view. This determines how the FoV setting is used to calculate the final image in the vertical and horizontal directions.

func (*Camera) FocusRange

func (c *Camera) FocusRange() (float32, float32)

FocusRange changes the range from near to far in which the image will be in focus.

func (*Camera) MaximumExposure added in v0.3.0

func (c *Camera) MaximumExposure() float32

MaximumExposure returns the maximum exposure that the camera may use during AutoExposure.

func (*Camera) MinimumExposure added in v0.3.0

func (c *Camera) MinimumExposure() float32

MinimumExposure returns the maximum exposure that the camera may use during AutoExposure.

func (*Camera) Near added in v0.19.0

func (c *Camera) Near() float32

Near returns the distance to the near clipping plane.

func (*Camera) SetAspectRatio

func (c *Camera) SetAspectRatio(ratio float32)

SetAspectRatio changes the aspect ratio of this camera.

func (*Camera) SetAutoExposure

func (c *Camera) SetAutoExposure(enabled bool)

SetAutoExposure changes whether this cammera should attempt to do automatic exposure adjustment.

func (*Camera) SetAutoExposureSpeed added in v0.9.0

func (c *Camera) SetAutoExposureSpeed(speed float32)

SetAutoExposureSpeed changes the speed at which the camera will automatically adjust its exposure.

func (*Camera) SetAutoFocus

func (c *Camera) SetAutoFocus(enabled bool)

SetAutoFocus changes whether this camera should attempt to automatically focus on object in the scene.

func (*Camera) SetCascadeDistances added in v0.20.0

func (c *Camera) SetCascadeDistances(distances []float32)

SetCascadeDistances changes the distances at which the shadow maps of this camera will be split into cascades.

func (*Camera) SetExposure

func (c *Camera) SetExposure(exposure float32)

SetExposure changes the exposure setting of this camera. Smaller values mean that the final image will be darker and higher values mean that the final image will be brighter with 1.0 being the starting point.

func (*Camera) SetFar added in v0.19.0

func (c *Camera) SetFar(far float32)

SetFar changes the distance to the far clipping plane.

func (*Camera) SetFoV

func (c *Camera) SetFoV(angle sprec.Angle)

SetFoV changes the field-of-view angle setting of this camera.

func (*Camera) SetFoVMode

func (c *Camera) SetFoVMode(mode FoVMode)

SetFoVMode changes the field-of-view mode of this camera.

func (*Camera) SetFocusRange

func (c *Camera) SetFocusRange(near, far float32)

SetFocusRange changes the focus range for this camera.

func (*Camera) SetMaximumExposure added in v0.3.0

func (c *Camera) SetMaximumExposure(maxExposure float32)

SetMaximumExposure changes the maximum exposure for this camera.

func (*Camera) SetMinimumExposure added in v0.3.0

func (c *Camera) SetMinimumExposure(minExposure float32)

SetMinimumExposure changes the maximum exposure for this camera.

func (*Camera) SetNear added in v0.19.0

func (c *Camera) SetNear(near float32)

SetNear changes the distance to the near clipping plane.

type Debug added in v0.10.0

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

func (*Debug) Line added in v0.10.0

func (d *Debug) Line(start, end, color dprec.Vec3)

func (*Debug) Reset added in v0.10.0

func (d *Debug) Reset()

func (*Debug) Triangle added in v0.10.0

func (d *Debug) Triangle(p1, p2, p3, color dprec.Vec3)

type DebugLine added in v0.20.0

type DebugLine struct {
	Start sprec.Vec3
	End   sprec.Vec3
	Color sprec.Vec3
}

type DepthSourceStage added in v0.20.0

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

DepthSourceStage is a stage that provides a depth source texture.

func (*DepthSourceStage) Allocate added in v0.20.0

func (s *DepthSourceStage) Allocate()

func (*DepthSourceStage) DepthTexture added in v0.20.0

func (s *DepthSourceStage) DepthTexture() render.Texture

DepthTexture returns the texture that contains the depth information.

func (*DepthSourceStage) PostRender added in v0.20.0

func (s *DepthSourceStage) PostRender()

func (*DepthSourceStage) PreRender added in v0.20.0

func (s *DepthSourceStage) PreRender(width, height uint32)

func (*DepthSourceStage) Release added in v0.20.0

func (s *DepthSourceStage) Release()

func (*DepthSourceStage) Render added in v0.20.0

func (s *DepthSourceStage) Render(ctx StageContext)

type DirectionalLight

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

func (*DirectionalLight) Active added in v0.10.0

func (l *DirectionalLight) Active() bool

Active returns whether this light will be applied.

func (*DirectionalLight) CastShadow added in v0.20.0

func (l *DirectionalLight) CastShadow() bool

CastShadow returns whether this light will cast a shadow.

func (*DirectionalLight) Delete added in v0.10.0

func (l *DirectionalLight) Delete()

Delete removes this light from the scene.

func (*DirectionalLight) EmitColor added in v0.14.0

func (l *DirectionalLight) EmitColor() dprec.Vec3

EmitColor returns the linear color of this light.

func (*DirectionalLight) Position added in v0.14.0

func (l *DirectionalLight) Position() dprec.Vec3

Position returns the location of this light source.

func (*DirectionalLight) Rotation added in v0.14.0

func (l *DirectionalLight) Rotation() dprec.Quat

Rotation returns the orientation of this light source.

func (*DirectionalLight) SetActive added in v0.10.0

func (l *DirectionalLight) SetActive(active bool)

SetActive changes whether this light will be applied.

func (*DirectionalLight) SetCastShadow added in v0.20.0

func (l *DirectionalLight) SetCastShadow(castShadow bool)

SetCastShadow changes whether this light will cast a shadow.

func (*DirectionalLight) SetEmitColor added in v0.14.0

func (l *DirectionalLight) SetEmitColor(color dprec.Vec3)

SetEmitColor changes the linear color of this light. The values can be outside the [0.0, 1.0] range for higher intensity.

func (*DirectionalLight) SetPosition added in v0.14.0

func (l *DirectionalLight) SetPosition(position dprec.Vec3)

SetPosition changes the position of this light source.

func (*DirectionalLight) SetRotation added in v0.14.0

func (l *DirectionalLight) SetRotation(rotation dprec.Quat)

SetRotation changes the orientation of this light source.

type DirectionalLightInfo added in v0.10.0

type DirectionalLightInfo struct {
	Position   dprec.Vec3
	Rotation   dprec.Quat
	EmitColor  dprec.Vec3
	CastShadow bool
}

type Engine

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

Engine represents an entrypoint to 3D graphics rendering.

func NewEngine added in v0.4.0

func NewEngine(api render.API, shaders ShaderCollection, shaderBuilder ShaderBuilder, opts ...Option) *Engine

func (*Engine) API added in v0.19.0

func (e *Engine) API() render.API

func (*Engine) Create

func (e *Engine) Create()

Create initializes this 3D engine.

func (*Engine) CreateMaterial added in v0.19.0

func (e *Engine) CreateMaterial(info MaterialInfo) *Material

CreateMaterial creates a new Material from the specified info object.

func (*Engine) CreateMeshDefinition added in v0.9.0

func (e *Engine) CreateMeshDefinition(info MeshDefinitionInfo) *MeshDefinition

CreateMeshDefinition creates a new MeshDefinition using the specified info object.

func (*Engine) CreateMeshGeometry added in v0.19.0

func (e *Engine) CreateMeshGeometry(info MeshGeometryInfo) *MeshGeometry

CreateMeshGeometry creates a new MeshGeometry using the specified info object.

func (*Engine) CreateScene

func (e *Engine) CreateScene() *Scene

CreateScene creates a new 3D Scene. Entities managed within a given scene are isolated within that scene.

func (*Engine) CreateShader added in v0.19.0

func (e *Engine) CreateShader(info ShaderInfo) *Shader

CreateShader creates a new custom Shader using the specified info object.

func (*Engine) CreateSkyDefinition added in v0.19.0

func (e *Engine) CreateSkyDefinition(info SkyDefinitionInfo) *SkyDefinition

CreateSkyDefinition creates a new SkyDefinition using the specified info object.

func (*Engine) Debug deprecated added in v0.10.0

func (e *Engine) Debug() *Debug

Debug allows the rendering of debug lines on the screen.

Deprecated: Figure out how to fix/improve this. Maybe not needed anymore with custom shaders and forward passes?

func (*Engine) Destroy

func (e *Engine) Destroy()

Destroy releases resources allocated by this 3D engine.

type ExposureProbeStage added in v0.20.0

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

ExposureProbeStage is a stage that measures the brightness of the scene and adjusts the exposure of the camera accordingly.

func (*ExposureProbeStage) Allocate added in v0.20.0

func (s *ExposureProbeStage) Allocate()

func (*ExposureProbeStage) PostRender added in v0.20.0

func (s *ExposureProbeStage) PostRender()

func (*ExposureProbeStage) PreRender added in v0.20.0

func (s *ExposureProbeStage) PreRender(width, height uint32)

func (*ExposureProbeStage) Release added in v0.20.0

func (s *ExposureProbeStage) Release()

func (*ExposureProbeStage) Render added in v0.20.0

func (s *ExposureProbeStage) Render(ctx StageContext)

type ExposureProbeStageInput added in v0.20.0

type ExposureProbeStageInput struct {
	HDRTexture StageTextureParameter
}

ExposureProbeStageInput is used to configure an ExposureProbeStage.

type FoVMode

type FoVMode string

FoVMode determines how the camera field of view is calculated in the horizontal and vertical directions.

const (
	// FoVModeAnamorphic will abide to the aspect ratio setting
	// and will pillerbox the image if necessary.
	FoVModeAnamorphic FoVMode = "anamorphic"

	// FoVModeHorizontalPlus will apply the FoV setting to the
	// vertical direction and will adjust the horizontal direction
	// accordingly to preserve the screen's aspect ratio.
	FoVModeHorizontalPlus FoVMode = "horizontal-plus"

	// FoVModeVertialMinus will apply the FoV setting to the
	// horizontal direction and will adjust the vertical direction
	// accordingly to preserve the screen's aspect ratio.
	FoVModeVertialMinus FoVMode = "vertical-minus"

	// FoVModePixelBased will use an orthogonal projection that
	// will match in side the screen pixel size.
	FoVModePixelBased FoVMode = "pixel-based"
)

type ForwardConstraints added in v0.19.0

type ForwardConstraints struct {

	// HasArmature specifies whether the mesh has an armature.
	HasArmature bool
}

ForwardConstraints contains the constraints imposed on the forward shader construction process.

type ForwardSourceStage added in v0.20.0

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

ForwardSourceStage is a stage that provides source textures for a forward pass renderer.

func (*ForwardSourceStage) Allocate added in v0.20.0

func (s *ForwardSourceStage) Allocate()

func (*ForwardSourceStage) HDRTexture added in v0.20.0

func (s *ForwardSourceStage) HDRTexture() render.Texture

HDRTexture returns the texture that contains the high dynamic range color information.

func (*ForwardSourceStage) PostRender added in v0.20.0

func (s *ForwardSourceStage) PostRender()

func (*ForwardSourceStage) PreRender added in v0.20.0

func (s *ForwardSourceStage) PreRender(width, height uint32)

func (*ForwardSourceStage) Release added in v0.20.0

func (s *ForwardSourceStage) Release()

func (*ForwardSourceStage) Render added in v0.20.0

func (s *ForwardSourceStage) Render(ctx StageContext)

type ForwardStage added in v0.20.0

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

func (*ForwardStage) Allocate added in v0.20.0

func (s *ForwardStage) Allocate()

func (*ForwardStage) PostRender added in v0.20.0

func (s *ForwardStage) PostRender()

func (*ForwardStage) PreRender added in v0.20.0

func (s *ForwardStage) PreRender(width, height uint32)

func (*ForwardStage) Release added in v0.20.0

func (s *ForwardStage) Release()

func (*ForwardStage) Render added in v0.20.0

func (s *ForwardStage) Render(ctx StageContext)

type ForwardStageInput added in v0.20.0

type ForwardStageInput struct {
	HDRTexture   StageTextureParameter
	DepthTexture StageTextureParameter
}

type GeometryConstraints added in v0.19.0

type GeometryConstraints struct {

	// HasArmature specifies whether the mesh has an armature.
	HasArmature bool

	// HasNormals specifies whether the mesh has normals.
	HasNormals bool

	// HasTexCoords specifies whether the mesh has texture coordinates.
	HasTexCoords bool

	// HasVertexColors specifies whether the mesh has vertex colors.
	HasVertexColors bool
}

GeometryConstraints contains the constraints imposed on the geometry shader construction process.

type GeometrySourceStage added in v0.20.0

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

GeometrySourceStage is a stage that provides source textures for a geometry pass renderer.

func (*GeometrySourceStage) AlbedoMetallicTexture added in v0.20.0

func (s *GeometrySourceStage) AlbedoMetallicTexture() render.Texture

AlbedoMetallicTexture returns the texture that contains the albedo color in the RGB channels and the metallic factor in the A channel.

func (*GeometrySourceStage) Allocate added in v0.20.0

func (s *GeometrySourceStage) Allocate()

func (*GeometrySourceStage) NormalRoughnessTexture added in v0.20.0

func (s *GeometrySourceStage) NormalRoughnessTexture() render.Texture

NormalRoughnessTexture returns the texture that contains the normal vector in the RGB channels and the roughness factor in the A channel.

func (*GeometrySourceStage) PostRender added in v0.20.0

func (s *GeometrySourceStage) PostRender()

func (*GeometrySourceStage) PreRender added in v0.20.0

func (s *GeometrySourceStage) PreRender(width, height uint32)

func (*GeometrySourceStage) Release added in v0.20.0

func (s *GeometrySourceStage) Release()

func (*GeometrySourceStage) Render added in v0.20.0

func (s *GeometrySourceStage) Render(ctx StageContext)

type GeometryStage added in v0.20.0

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

GeometryStage is a render stage that renders the geometry of the scene.

func (*GeometryStage) Allocate added in v0.20.0

func (s *GeometryStage) Allocate()

func (*GeometryStage) PostRender added in v0.20.0

func (s *GeometryStage) PostRender()

func (*GeometryStage) PreRender added in v0.20.0

func (s *GeometryStage) PreRender(width, height uint32)

func (*GeometryStage) Release added in v0.20.0

func (s *GeometryStage) Release()

func (*GeometryStage) Render added in v0.20.0

func (s *GeometryStage) Render(ctx StageContext)

type GeometryStageInput added in v0.20.0

type GeometryStageInput struct {
	AlbedoMetallicTexture  StageTextureParameter
	NormalRoughnessTexture StageTextureParameter
	DepthTexture           StageTextureParameter
}

GeometryStageInput is used to configure a new GeometryStage.

type LightingStage added in v0.20.0

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

LightingStage is responsible for rendering the lighting of the scene.

func (*LightingStage) Allocate added in v0.20.0

func (s *LightingStage) Allocate()

func (*LightingStage) PostRender added in v0.20.0

func (s *LightingStage) PostRender()

func (*LightingStage) PreRender added in v0.20.0

func (s *LightingStage) PreRender(width, height uint32)

func (*LightingStage) Release added in v0.20.0

func (s *LightingStage) Release()

func (*LightingStage) Render added in v0.20.0

func (s *LightingStage) Render(ctx StageContext)

type LightingStageInput added in v0.20.0

type LightingStageInput struct {
	AlbedoMetallicTexture  StageTextureParameter
	NormalRoughnessTexture StageTextureParameter
	DepthTexture           StageTextureParameter
	HDRTexture             StageTextureParameter
}

LightingStageInput is the input data for the LightingStage.

type Material

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

Material determines the appearance of a mesh on the screen.

func (*Material) Name added in v0.19.0

func (m *Material) Name() string

func (*Material) Property added in v0.19.0

func (m *Material) Property(name string) any

Property returns the property with the specified name. If the property is not found, nil is returned.

func (*Material) Sampler added in v0.19.0

func (m *Material) Sampler(name string) render.Sampler

Sampler returns the sampler with the specified name. If the sampler is not found, nil is returned.

func (*Material) SetProperty added in v0.19.0

func (m *Material) SetProperty(name string, value any)

SetProperty sets the property with the specified name.

func (*Material) SetSampler added in v0.19.0

func (m *Material) SetSampler(name string, sampler render.Sampler)

SetSampler sets the sampler with the specified name.

func (*Material) SetTexture added in v0.19.0

func (m *Material) SetTexture(name string, texture render.Texture)

SetTexture sets the texture with the specified name.

func (*Material) Texture added in v0.19.0

func (m *Material) Texture(name string) render.Texture

Texture returns the texture with the specified name. If the texture is not found, nil is returned.

type MaterialInfo added in v0.19.0

type MaterialInfo struct {

	// Name specifies the name of the material.
	Name string

	// GeometryPasses specifies a list of geometry passes to be applied.
	// This is used for opaque materials that go through deferred shading.
	GeometryPasses []MaterialPassInfo

	// ShadowPasses specifies a list of shadow passes to be applied.
	// This should be omitted if the material does not cast shadows.
	ShadowPasses []MaterialPassInfo

	// ForwardPasses specifies a list of forward passes to be applied.
	// This is useful when dealing with translucent materials or when special
	// effects are needed.
	ForwardPasses []MaterialPassInfo

	// SkyPasses specifies a list of sky passes to be applied.
	// This is used for materials that are used to render the sky.
	SkyPasses []MaterialPassInfo

	// PostprocessingPasses specifies a list of postprocess passes to be applied.
	PostprocessingPasses []MaterialPassInfo
}

MaterialInfo contains the information needed to create a Material.

type MaterialPassInfo added in v0.19.0

type MaterialPassInfo struct {

	// Layer controls the render ordering of this pass. Lower values will be
	// rendered first. Having too many layers can affect performance.
	Layer int32

	// Culling specifies the culling mode.
	Culling opt.T[render.CullMode]

	// FrontFace specifies the front face orientation.
	FrontFace opt.T[render.FaceOrientation]

	// DepthTest specifies whether depth testing should be enabled.
	DepthTest opt.T[bool]

	// DepthWrite specifies whether depth writing should be enabled.
	DepthWrite opt.T[bool]

	// DepthComparison specifies the depth comparison function.
	DepthComparison opt.T[render.Comparison]

	// Blending specifies whether the output will be mixed with the
	// background. Useful for unlit/emissive special effects.
	Blending opt.T[bool]

	// Shader is the forward shader that will be used to render the material.
	Shader *Shader
}

MaterialPassInfo contains the information representing the rendering behavior of a material during a pass.

type Mesh

type Mesh struct {
	Node
	// contains filtered or unexported fields
}

Mesh represents an instance of a 3D mesh.

func (*Mesh) Active added in v0.19.0

func (m *Mesh) Active() bool

func (*Mesh) Delete

func (m *Mesh) Delete()

Delete removes this mesh from the scene.

func (*Mesh) SetActive added in v0.19.0

func (m *Mesh) SetActive(active bool)

func (*Mesh) SetMatrix added in v0.9.0

func (m *Mesh) SetMatrix(matrix dprec.Mat4)

type MeshDefinition added in v0.9.0

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

MeshDefinition represents the definition of a mesh. Multiple mesh instances can be created off of one template reusing resources.

func (*MeshDefinition) Delete added in v0.9.0

func (d *MeshDefinition) Delete()

Delete releases any resources owned by this MeshDefinition.

func (*MeshDefinition) Material added in v0.19.0

func (d *MeshDefinition) Material(index int) *Material

Material returns the material at the specified index.

func (*MeshDefinition) MaterialCount added in v0.19.0

func (d *MeshDefinition) MaterialCount() int

MaterialCount returns the number of materials defined for this MeshDefinition.

func (*MeshDefinition) SetMaterial added in v0.19.0

func (d *MeshDefinition) SetMaterial(index int, material *Material)

SetMaterial sets the material at the specified index.

type MeshDefinitionInfo added in v0.9.0

type MeshDefinitionInfo struct {
	Geometry  *MeshGeometry
	Materials []*Material
}

MeshDefinitionInfo contains everything needed to create a new MeshDefinition.

type MeshGeometry added in v0.19.0

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

MeshGeometry represents the raw geometry of a mesh, without any materials or shading.

func (*MeshGeometry) Delete added in v0.19.0

func (g *MeshGeometry) Delete()

Delete releases the resources that are associated with this mesh geometry.

func (*MeshGeometry) Fragment added in v0.19.0

func (g *MeshGeometry) Fragment(index int) *MeshGeometryFragment

Fragment returns the fragment at the specified index.

func (*MeshGeometry) FragmentCount added in v0.19.0

func (g *MeshGeometry) FragmentCount() int

FragmentCount returns the number of fragments that make up this mesh.

Each fragment represents a portion of the mesh that is drawn with a specific material and topology, through the exact material is not specified here.

type MeshGeometryBuilder added in v0.19.0

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

MeshGeometryBuilder is a helper for constructing a MeshDefinitionInfo.

func NewMeshGeometryBuilder added in v0.19.0

func NewMeshGeometryBuilder(opts ...MeshGeometryBuilderOption) *MeshGeometryBuilder

NewMeshGeometryBuilder creates a new MeshGeometryBuilder with the provided options.

func (*MeshGeometryBuilder) BuildInfo added in v0.19.0

func (mb *MeshGeometryBuilder) BuildInfo() MeshGeometryInfo

BuildInfo returns the MeshGeometryInfo that has been constructed by the builder.

func (*MeshGeometryBuilder) Fragment added in v0.19.0

func (mb *MeshGeometryBuilder) Fragment(topology render.Topology, indexOffset, indexCount uint32)

Fragment adds a mesh fragment to the mesh.

func (*MeshGeometryBuilder) Index added in v0.19.0

func (mb *MeshGeometryBuilder) Index(index uint32) uint32

Index adds an index to the mesh.

func (*MeshGeometryBuilder) IndexLine added in v0.19.0

func (mb *MeshGeometryBuilder) IndexLine(a, b uint32) (uint32, uint32)

IndexLine adds two indices to the mesh.

func (*MeshGeometryBuilder) IndexOffset added in v0.19.0

func (mb *MeshGeometryBuilder) IndexOffset() uint32

IndexOffset returns the index of the first index that will be added by the next call to Index.

func (*MeshGeometryBuilder) IndexQuad added in v0.19.0

func (mb *MeshGeometryBuilder) IndexQuad(a, b, c, d uint32) (uint32, uint32)

IndexQuad adds indices to the mesh to form a quad based off of two triangles.

func (*MeshGeometryBuilder) IndexTriangle added in v0.19.0

func (mb *MeshGeometryBuilder) IndexTriangle(a, b, c uint32) (uint32, uint32)

IndexTriangle adds indices to the mesh to form a triangle.

func (*MeshGeometryBuilder) Transform added in v0.19.0

func (mb *MeshGeometryBuilder) Transform(transform sprec.Mat4)

Transform sets the transformation matrix that will be applied to future vertices added to the mesh.

func (*MeshGeometryBuilder) Vertex added in v0.19.0

func (mb *MeshGeometryBuilder) Vertex() VertexBuilder

Vertex returns a builder for the next vertex to be added to the mesh.

func (*MeshGeometryBuilder) VertexOffset added in v0.19.0

func (mb *MeshGeometryBuilder) VertexOffset() uint32

VertexOffset returns the index of the first vertex that will be added by the next call to Vertex.

type MeshGeometryBuilderOption added in v0.19.0

type MeshGeometryBuilderOption func(*MeshGeometryBuilder)

MeshGeometryBuilderOption is a function that modifies a MeshGeometryBuilder.

func MeshGeometryBuilderWithColors added in v0.19.0

func MeshGeometryBuilderWithColors() MeshGeometryBuilderOption

MeshGeometryBuilderWithColors is a MeshGeometryBuilderOption that enables the construction of vertices with colors.

func MeshGeometryBuilderWithCoords added in v0.19.0

func MeshGeometryBuilderWithCoords() MeshGeometryBuilderOption

MeshGeometryBuilderWithCoords is a MeshGeometryBuilderOption that enables the construction of vertices with coordinates.

func MeshGeometryBuilderWithJoints added in v0.19.0

func MeshGeometryBuilderWithJoints() MeshGeometryBuilderOption

MeshGeometryBuilderWithJoints is a MeshGeometryBuilderOption that enables the construction of vertices with joint indices.

func MeshGeometryBuilderWithNormals added in v0.19.0

func MeshGeometryBuilderWithNormals() MeshGeometryBuilderOption

MeshGeometryBuilderWithNormals is a MeshGeometryBuilderOption that enables the construction of vertices with normals.

func MeshGeometryBuilderWithTangents added in v0.19.0

func MeshGeometryBuilderWithTangents() MeshGeometryBuilderOption

MeshGeometryBuilderWithTangents is a MeshGeometryBuilderOption that enables the construction of vertices with tangents.

func MeshGeometryBuilderWithTexCoords added in v0.19.0

func MeshGeometryBuilderWithTexCoords() MeshGeometryBuilderOption

MeshGeometryBuilderWithTexCoords is a MeshGeometryBuilderOption that enables the construction of vertices with texture coordinates.

func MeshGeometryBuilderWithWeights added in v0.19.0

func MeshGeometryBuilderWithWeights() MeshGeometryBuilderOption

MeshGeometryBuilderWithWeights is a MeshGeometryBuilderOption that enables the construction of vertices with joint weights.

type MeshGeometryFragment added in v0.19.0

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

MeshGeometryFragment represents a portion of a mesh that is drawn with a specific material and topology.

func (*MeshGeometryFragment) Name added in v0.19.0

func (g *MeshGeometryFragment) Name() string

Name returns the name of the fragment.

func (*MeshGeometryFragment) Topology added in v0.19.0

func (g *MeshGeometryFragment) Topology() render.Topology

Topology returns the topology that is used to draw the fragment.

type MeshGeometryFragmentInfo added in v0.19.0

type MeshGeometryFragmentInfo struct {
	Name            string
	Topology        render.Topology
	IndexByteOffset uint32
	IndexCount      uint32
}

MeshGeometryFragmentInfo contains the information needed to represent a fragment of a mesh.

type MeshGeometryIndexBuffer added in v0.19.0

type MeshGeometryIndexBuffer struct {
	Data   []byte
	Format render.IndexFormat
}

MeshGeometryIndexBuffer represents a buffer that contains index data.

type MeshGeometryInfo added in v0.19.0

type MeshGeometryInfo struct {
	VertexBuffers        []MeshGeometryVertexBuffer
	VertexFormat         MeshGeometryVertexFormat
	IndexBuffer          MeshGeometryIndexBuffer
	Fragments            []MeshGeometryFragmentInfo
	BoundingSphereRadius float64
	MinDistance          opt.T[float64]
	MaxDistance          opt.T[float64]
}

MeshGeometryInfo contains everything needed to create a new MeshGeometry.

type MeshGeometryVertexAttribute added in v0.19.0

type MeshGeometryVertexAttribute struct {
	BufferIndex uint32
	ByteOffset  uint32
	Format      render.VertexAttributeFormat
}

MeshGeometryVertexAttribute describes a single attribute of a vertex.

type MeshGeometryVertexBuffer added in v0.19.0

type MeshGeometryVertexBuffer struct {
	ByteStride uint32
	Data       []byte
}

MeshGeometryVertexBuffer represents a buffer that contains vertex data.

type MeshGeometryVertexFormat added in v0.19.0

MeshGeometryVertexFormat describes the data that is contained in a single vertex.

type MeshInfo added in v0.9.0

type MeshInfo struct {
	Definition *MeshDefinition
	Armature   *Armature
}

type Node

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

Node represents a positioning of some entity in the 3D scene.

func (*Node) SetMatrix added in v0.9.0

func (n *Node) SetMatrix(matrix dprec.Mat4)

SetMatrix changes the model matrix of this node. Keep in mind that this is a somewhat slow operation and should only be performed only once per frame. This is also the reason why there is no getter for this method. Clients are expected to track matrices outside this type if needed.

type Option added in v0.20.0

type Option func(*config)

Option is a configuration function that can be used to customize the behavior of the graphics engine.

func WithDirectionalShadowMapCascadeCount added in v0.20.0

func WithDirectionalShadowMapCascadeCount(count int) Option

WithDirectionalShadowMapCascadeCount configures the maximum number of cascades that the directional shadow maps will have.

This value cannot be smaller than 1 and larger than 4 and will be clamped.

func WithDirectionalShadowMapCount added in v0.20.0

func WithDirectionalShadowMapCount(count int) Option

WithDirectionalShadowMapCount configures the graphics engine to use the specified number of directional shadow maps.

This value controls the number of directional lights that can have shadows at the same time.

func WithDirectionalShadowMapSize added in v0.20.0

func WithDirectionalShadowMapSize(size int) Option

WithDirectionalShadowMapSize configures the graphics engine to use the specified size for the directional shadow maps. The size needs to be a power of two.

func WithPointShadowMapCount added in v0.20.0

func WithPointShadowMapCount(count int) Option

WithPointShadowMapCount configures the graphics engine to use the specified number of point light shadow maps.

This value controls the number of point lights that can have shadows at the same time.

func WithPointShadowMapSize added in v0.20.0

func WithPointShadowMapSize(size int) Option

WithPointShadowMapSize configures the graphics engine to use the specified size for the point light shadow maps. The size needs to be a power of two.

func WithSpotShadowMapCount added in v0.20.0

func WithSpotShadowMapCount(count int) Option

WithSpotShadowMapCount configures the graphics engine to use the specified number of spot light shadow maps.

This value controls the number of spot lights that can have shadows at the same time.

func WithSpotShadowMapSize added in v0.20.0

func WithSpotShadowMapSize(size int) Option

WithSpotShadowMapSize configures the graphics engine to use the specified size for the spot light shadow maps. The size needs to be a power of two.

func WithStageBuilder added in v0.20.0

func WithStageBuilder(builder StageBuilderFunc) Option

WithStageBuilder configures the graphics engine to use the specified stage builder function.

type PointLight added in v0.10.0

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

PointLight represents a light source that is positioned at a point in space and emits light evenly in all directions up to a range.

func (*PointLight) Active added in v0.10.0

func (l *PointLight) Active() bool

Active returns whether this light will be applied.

func (*PointLight) Delete added in v0.10.0

func (l *PointLight) Delete()

Delete removes this light from the scene.

func (*PointLight) EmitColor added in v0.10.0

func (l *PointLight) EmitColor() dprec.Vec3

EmitColor returns the linear color of this light.

func (*PointLight) EmitRange added in v0.10.0

func (l *PointLight) EmitRange() float64

EmitRange returns the distance that this light source covers.

func (*PointLight) Position added in v0.10.0

func (l *PointLight) Position() dprec.Vec3

Position returns the location of this light source.

func (*PointLight) SetActive added in v0.10.0

func (l *PointLight) SetActive(active bool)

SetActive changes whether this light will be applied.

func (*PointLight) SetEmitColor added in v0.10.0

func (l *PointLight) SetEmitColor(color dprec.Vec3)

SetEmitColor changes the linear color of this light. The values can be outside the [0.0, 1.0] range for higher intensity.

func (*PointLight) SetEmitRange added in v0.10.0

func (l *PointLight) SetEmitRange(emitRange float64)

SetEmitRange changes the distance that this light source covers.

func (*PointLight) SetPosition added in v0.10.0

func (l *PointLight) SetPosition(position dprec.Vec3)

SetPosition changes the position of this light source.

type PointLightInfo added in v0.10.0

type PointLightInfo struct {
	Position   dprec.Vec3
	EmitRange  float64
	EmitColor  dprec.Vec3
	CastShadow bool // TODO: Implement shadow casting
}

PointLightInfo contains the information needed to create a PointLight.

type PostprocessingShaderConfig added in v0.9.0

type PostprocessingShaderConfig struct {
	ToneMapping ToneMapping
	Bloom       bool
}

type Scene

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

Scene represents a collection of 3D render entities that comprise a single visual scene.

func (*Scene) ActiveCamera added in v0.9.0

func (s *Scene) ActiveCamera() *Camera

ActiveCamera returns the currently active camera for this scene.

func (*Scene) CreateAmbientLight

func (s *Scene) CreateAmbientLight(info AmbientLightInfo) *AmbientLight

CreateAmbientLight creates a new AmbientLight object to be used within this scene.

func (*Scene) CreateArmature added in v0.9.0

func (s *Scene) CreateArmature(info ArmatureInfo) *Armature

CreateArmature creates an armature to be used with meshes.

func (*Scene) CreateCamera

func (s *Scene) CreateCamera() *Camera

CreateCamera creates a new camera object to be used with this scene.

func (*Scene) CreateDirectionalLight

func (s *Scene) CreateDirectionalLight(info DirectionalLightInfo) *DirectionalLight

CreateDirectionalLight creates a new DirectionalLight object to be used within this scene.

func (*Scene) CreateMesh

func (s *Scene) CreateMesh(info MeshInfo) *Mesh

CreateMesh creates a new mesh instance from the specified template and places it in the scene.

func (*Scene) CreatePointLight added in v0.9.0

func (s *Scene) CreatePointLight(info PointLightInfo) *PointLight

CreatePointLight creates a new PointLight object to be used within this scene.

func (*Scene) CreateSky added in v0.19.0

func (s *Scene) CreateSky(info SkyInfo) *Sky

CreateSky creates a new Sky object to be used within this scene.

func (*Scene) CreateSpotLight added in v0.10.0

func (s *Scene) CreateSpotLight(info SpotLightInfo) *SpotLight

CreateSpotLight creates a new SpotLight object to be used within this scene.

func (*Scene) CreateStaticMesh added in v0.11.0

func (s *Scene) CreateStaticMesh(info StaticMeshInfo)

CreateStaticMesh creates a new static mesh to be rendered in this scene.

Static meshes cannot be removed from a scene but are rendered more efficiently.

func (*Scene) Delete

func (s *Scene) Delete()

Delete removes this scene and releases all entities allocated for it.

func (*Scene) Engine added in v0.19.0

func (s *Scene) Engine() *Engine

Engine returns the graphics engine that owns this scene.

func (*Scene) Point added in v0.15.0

func (s *Scene) Point(viewport Viewport, camera *Camera, position dprec.Vec3) dprec.Vec2

func (*Scene) Ray added in v0.9.0

func (s *Scene) Ray(viewport Viewport, camera *Camera, x, y int) (dprec.Vec3, dprec.Vec3)

func (*Scene) Render

func (s *Scene) Render(framebuffer render.Framebuffer, viewport Viewport)

Render draws this scene to the specified viewport looking through the specified camera.

func (*Scene) SetActiveCamera added in v0.9.0

func (s *Scene) SetActiveCamera(camera *Camera)

SetActiveCamera changes the active camera for this scene.

func (*Scene) Time added in v0.19.0

func (s *Scene) Time() float32

func (*Scene) Update added in v0.19.0

func (s *Scene) Update(elapsedTime time.Duration)

type Shader added in v0.19.0

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

Shader represents a custom shader program.

type ShaderBuilder added in v0.19.0

type ShaderBuilder interface {

	// BuildCode creates the program code for a custom shader.
	BuildCode(constraints ShaderConstraints, shader *lsl.Shader) render.ProgramCode

	// BuildGeometryCode creates the program code for a geometry pass.
	BuildGeometryCode(constraints GeometryConstraints, shader *lsl.Shader) render.ProgramCode

	// BuildShadowCode creates the program code for a shadow pass.
	BuildShadowCode(constraints ShadowConstraints, shader *lsl.Shader) render.ProgramCode

	// BuildForwardCode creates the program code for a shadow pass.
	BuildForwardCode(constraints ForwardConstraints, shader *lsl.Shader) render.ProgramCode
}

ShaderBuilder abstracts the process of building a shader program. The implementation of this interface will depend on the rendering backend.

type ShaderCollection added in v0.4.0

type ShaderCollection struct {
	AmbientLightSet     func() render.ProgramCode
	PointLightSet       func() render.ProgramCode
	SpotLightSet        func() render.ProgramCode
	DirectionalLightSet func() render.ProgramCode

	DebugSet func() render.ProgramCode

	ExposureSet func() render.ProgramCode

	BloomDownsampleSet func() render.ProgramCode
	BloomBlurSet       func() render.ProgramCode

	PostprocessingSet func(cfg PostprocessingShaderConfig) render.ProgramCode
}

type ShaderConstraints added in v0.19.0

type ShaderConstraints struct {

	// LoadGeometryPreset specifies whether the shader should load the geometry
	// preset.
	LoadGeometryPreset bool

	// LoadSkyPreset specifies whether the shader should load the sky preset.
	LoadSkyPreset bool

	// HasOutput0 specifies whether the shader has an output for the first
	// render target.
	HasOutput0 bool

	// HasOutput1 specifies whether the shader has an output for the second
	// render target.
	HasOutput1 bool

	// HasOutput2 specifies whether the shader has an output for the third
	// render target.
	HasOutput2 bool

	// HasOutput3 specifies whether the shader has an output for the fourth
	// render target.
	HasOutput3 bool

	// HasCoords specifies whether the mesh has coordinates.
	HasCoords bool

	// HasNormals specifies whether the mesh has normals.
	HasNormals bool

	// HasTangents specifies whether the mesh has tangents.
	HasTangents bool

	// HasTexCoords specifies whether the mesh has texture coordinates.
	HasTexCoords bool

	// HasVertexColors specifies whether the mesh has vertex colors.
	HasVertexColors bool

	// HasArmature specifies whether the mesh has an armature.
	HasArmature bool
}

ShaderConstraints contains the constraints imposed on the shader construction process.

type ShaderInfo added in v0.19.0

type ShaderInfo struct {

	// ShaderType specifies the type of the shader.
	ShaderType ShaderType

	// SourceCode is the source code of the shader.
	SourceCode string

	// SkipValidation specifies whether the engine should skip shader validation.
	//
	// This is useful when the shader is known to be valid and the validation
	// process is not needed.
	SkipValidation bool
}

ShaderInfo contains the information needed to create a custom Shader.

type ShaderType added in v0.19.0

type ShaderType uint8

ShaderType specifies the type of a shader.

const (
	ShaderTypeGeometry ShaderType = iota
	ShaderTypeShadow
	ShaderTypeForward
	ShaderTypeSky
	ShaderTypePostprocess
)

type ShadowConstraints added in v0.19.0

type ShadowConstraints struct {

	// HasArmature specifies whether the mesh has an armature.
	HasArmature bool
}

ShadowConstraints contains the constraints imposed on the shadow shader construction process.

type ShadowStage added in v0.20.0

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

ShadowStage is a stage that renders shadows.

func (*ShadowStage) Allocate added in v0.20.0

func (s *ShadowStage) Allocate()

func (*ShadowStage) PostRender added in v0.20.0

func (s *ShadowStage) PostRender()

func (*ShadowStage) PreRender added in v0.20.0

func (s *ShadowStage) PreRender(width, height uint32)

func (*ShadowStage) Release added in v0.20.0

func (s *ShadowStage) Release()

func (*ShadowStage) Render added in v0.20.0

func (s *ShadowStage) Render(ctx StageContext)

type ShapeBuilder added in v0.19.0

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

ShapeBuilder is responsible for creating meshes made of a single material.

func NewShapeBuilder added in v0.19.0

func NewShapeBuilder() *ShapeBuilder

NewShapeBuilder creates a new simple mesh builder.

func (*ShapeBuilder) BuildGeometryInfo added in v0.19.0

func (mb *ShapeBuilder) BuildGeometryInfo() MeshGeometryInfo

BuildGeometryInfo returns the geometry info of the built mesh.

func (*ShapeBuilder) BuildMeshDefinitionInfo added in v0.19.0

func (mb *ShapeBuilder) BuildMeshDefinitionInfo(geometry *MeshGeometry) MeshDefinitionInfo

BuildInfo returns the mesh definition info of the built mesh.

func (*ShapeBuilder) Solid added in v0.19.0

func (mb *ShapeBuilder) Solid(material *Material) SolidShapeBuilder

Solid creates a new fragment composed of solid triangles.

func (*ShapeBuilder) Wireframe added in v0.19.0

func (mb *ShapeBuilder) Wireframe(material *Material) WireframeShapeBuilder

Wireframe creates a new fragment composed of lines.

type Sky

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

func (*Sky) Active added in v0.19.0

func (s *Sky) Active() bool

func (*Sky) Definition added in v0.19.0

func (s *Sky) Definition() *SkyDefinition

func (*Sky) Delete added in v0.19.0

func (s *Sky) Delete()

func (*Sky) SetActive added in v0.19.0

func (s *Sky) SetActive(active bool)

type SkyConstraints added in v0.19.0

type SkyConstraints struct {
}

SkyConstraints contains the constraints imposed on the sky shader construction process.

type SkyDefinition added in v0.19.0

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

SkyDefinition represents a sky that can be rendered in the scene.

func (*SkyDefinition) Delete added in v0.19.0

func (d *SkyDefinition) Delete()

Delete deletes the sky definition and releases its resources.

func (*SkyDefinition) Material added in v0.19.0

func (d *SkyDefinition) Material() *Material

Material returns the material that is used to render the sky.

func (*SkyDefinition) SetMaterial added in v0.19.0

func (d *SkyDefinition) SetMaterial(material *Material)

SetMaterial sets the material that is used to render the sky.

type SkyDefinitionInfo added in v0.19.0

type SkyDefinitionInfo struct {

	// Material is the material that is used to render the sky.
	Material *Material
}

SkyDefinitionInfo holds the information required to create a new sky definition.

type SkyInfo added in v0.19.0

type SkyInfo struct {
	Definition *SkyDefinition
}

type SolidShapeBuilder added in v0.19.0

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

SolidShapeBuilder is responsible for creating solid mesh triangles.

func (SolidShapeBuilder) Cone added in v0.19.0

func (mb SolidShapeBuilder) Cone(position sprec.Vec3, rotation sprec.Quat, radius float32, height float32, segments int) SolidShapeBuilder

Cone creates a new cone solid shape.

func (SolidShapeBuilder) Cuboid added in v0.19.0

func (mb SolidShapeBuilder) Cuboid(position sprec.Vec3, rotation sprec.Quat, dimensions sprec.Vec3) SolidShapeBuilder

Cuboid creates a new cuboid solid shape.

func (SolidShapeBuilder) Cylinder added in v0.19.0

func (mb SolidShapeBuilder) Cylinder(position sprec.Vec3, rotation sprec.Quat, radius float32, height float32, segments int) SolidShapeBuilder

Cylinder creates a new cylinder solid shape.

func (SolidShapeBuilder) Sphere added in v0.19.0

func (mb SolidShapeBuilder) Sphere(position sprec.Vec3, radius float32, segments int) SolidShapeBuilder

Sphere creates a new sphere solid shape.

type SpotLight added in v0.10.0

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

SpotLight represents a light source that is positioned at a point in space and emits a light cone in down the -Z axis up to a range.

func (*SpotLight) Active added in v0.10.0

func (l *SpotLight) Active() bool

Active returns whether this light will be applied.

func (*SpotLight) Delete added in v0.10.0

func (l *SpotLight) Delete()

Delete removes this light from the scene.

func (*SpotLight) EmitColor added in v0.10.0

func (l *SpotLight) EmitColor() dprec.Vec3

EmitColor returns the linear color of this light.

func (*SpotLight) EmitRange added in v0.10.0

func (l *SpotLight) EmitRange() float64

EmitRange returns the distance that this light source covers.

func (*SpotLight) Position added in v0.10.0

func (l *SpotLight) Position() dprec.Vec3

Position returns the location of this light source.

func (*SpotLight) Rotation added in v0.14.0

func (l *SpotLight) Rotation() dprec.Quat

Rotation returns the orientation of this light source.

func (*SpotLight) SetActive added in v0.10.0

func (l *SpotLight) SetActive(active bool)

SetActive changes whether this light will be applied.

func (*SpotLight) SetEmitColor added in v0.10.0

func (l *SpotLight) SetEmitColor(color dprec.Vec3)

SetEmitColor changes the linear color of this light. The values can be outside the [0.0, 1.0] range for higher intensity.

func (*SpotLight) SetEmitRange added in v0.10.0

func (l *SpotLight) SetEmitRange(emitRange float64)

SetEmitRange changes the distance that this light source covers.

func (*SpotLight) SetPosition added in v0.10.0

func (l *SpotLight) SetPosition(position dprec.Vec3)

SetPosition changes the position of this light source.

func (*SpotLight) SetRotation added in v0.10.0

func (l *SpotLight) SetRotation(rotation dprec.Quat)

SetRotation changes the orientation of this light source.

type SpotLightInfo added in v0.10.0

type SpotLightInfo struct {
	Position           dprec.Vec3
	Rotation           dprec.Quat
	EmitRange          float64
	EmitOuterConeAngle dprec.Angle
	EmitInnerConeAngle dprec.Angle
	EmitColor          dprec.Vec3
	CastShadow         bool // TODO: Implement shadow casting
}

SpotLightInfo contains the information needed to create a SpotLight.

type Stage added in v0.20.0

type Stage interface {

	// Allocate is called once in the beginning to initialize any graphics
	// resources.
	Allocate()

	// Release is called once in the end to release any graphics resources.
	Release()

	// PreRender is called before the stage renders its content. The width and
	// height are in pixels and will never be zero or less.
	PreRender(width, height uint32)

	// Render is called whenever the stage should render its content.
	Render(ctx StageContext)

	// PostRender is called after all commands have been queued to the render API.
	PostRender()
}

Stage represents a render stage (e.g. geometry, lighting, post-processing).

func DefaultStageBuilder added in v0.20.0

func DefaultStageBuilder(provider *StageProvider) []Stage

DefaultStageBuilder is a default implementation of a stage builder.

type StageBuilderFunc added in v0.20.0

type StageBuilderFunc func(provider *StageProvider) []Stage

StageBuilderFunc is a function that creates a list of stages.

type StageContext added in v0.20.0

type StageContext struct {

	// Scene is the scene that should be rendered by the stage.
	Scene *Scene

	// Camera is the camera that should be used to render the stage.
	Camera *Camera

	// CameraPosition is the position of the camera in world space.
	CameraPosition dprec.Vec3

	// CameraPlacement is the uniform buffer segment that contains the camera
	// data.
	CameraPlacement ubo.UniformPlacement

	// CameraFrustum is the frustum of the camera in world space.
	CameraFrustum spatial.HexahedronRegion

	// VisibleAmbientLights is a list of ambient lights that are visible in the
	// scene.
	VisibleAmbientLights []*AmbientLight

	// VisiblePointLights is a list of point lights that are visible in the scene.
	VisiblePointLights []*PointLight

	// VisibleSpotLights is a list of spot lights that are visible in the scene.
	VisibleSpotLights []*SpotLight

	// VisibleDirectionalLights is a list of directional lights that are visible
	// in the scene.
	VisibleDirectionalLights []*DirectionalLight

	// VisibleMeshes is a list of meshes that are visible in the scene.
	VisibleMeshes []*Mesh

	// VisibleStaticMeshIndices is a list of indices of static meshes that are
	// visible in the scene.
	VisibleStaticMeshIndices []uint32

	// DebugLines is a list of debug lines that should be rendered by the stage.
	//
	// FIXME: Figure out a different way to do this. Maybe make it easy for
	// users to emulate debug lines through forward pass and mutatable meshes?
	DebugLines []DebugLine

	// Viewport is the area of the screen that the stage should render to.
	// The width and height of the viewport will match the width and height
	// that were passed to the PreRender method call.
	Viewport render.Area

	// Framebuffer is the screen framebuffer. A stage would not normally use
	// this unless it is the last stage in the rendering pipeline.
	Framebuffer render.Framebuffer

	// CommandBuffer is the command buffer that the stage should use to queue
	// rendering commands.
	CommandBuffer render.CommandBuffer

	// UniformBuffer is the uniform buffer that the stage should use to set
	// uniform data.
	UniformBuffer *ubo.UniformBlockBuffer
}

StageContext represents the context that is passed to a render stage.

type StageProvider added in v0.20.0

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

func (*StageProvider) CreateBloomStage added in v0.20.0

func (p *StageProvider) CreateBloomStage(input BloomStageInput) *BloomStage

CreateBloomStage creates a new BloomStage using the specified input object.

func (*StageProvider) CreateDepthSourceStage added in v0.20.0

func (p *StageProvider) CreateDepthSourceStage() *DepthSourceStage

CreateDepthSourceStage creates a new DepthSourceStage.

func (*StageProvider) CreateExposureProbeStage added in v0.20.0

func (p *StageProvider) CreateExposureProbeStage(input ExposureProbeStageInput) *ExposureProbeStage

CreateExposureProbeStage creates a new ExposureProbeStage using the specified input object.

func (*StageProvider) CreateForwardSourceStage added in v0.20.0

func (p *StageProvider) CreateForwardSourceStage() *ForwardSourceStage

CreateForwardSourceStage creates a new ForwardSourceStage.

func (*StageProvider) CreateForwardStage added in v0.20.0

func (p *StageProvider) CreateForwardStage(input ForwardStageInput) *ForwardStage

CreateForwardStage creates a new ForwardStage using the specified input object.

func (*StageProvider) CreateGeometrySourceStage added in v0.20.0

func (p *StageProvider) CreateGeometrySourceStage() *GeometrySourceStage

CreateGeometrySourceStage creates a new GeometrySourceStage.

func (*StageProvider) CreateGeometryStage added in v0.20.0

func (p *StageProvider) CreateGeometryStage(input GeometryStageInput) *GeometryStage

CreateGeometryStage creates a new GeometryStage using the specified input object.

func (*StageProvider) CreateLightingStage added in v0.20.0

func (p *StageProvider) CreateLightingStage(input LightingStageInput) *LightingStage

CreateLightingStage creates a new LightingStage using the specified input object.

func (*StageProvider) CreateShadowStage added in v0.20.0

func (p *StageProvider) CreateShadowStage() *ShadowStage

CreateShadowStage creates a new ShadowStage using the specified input object.

func (*StageProvider) CreateToneMappingStage added in v0.20.0

func (p *StageProvider) CreateToneMappingStage(input ToneMappingStageInput) *ToneMappingStage

CreateToneMappingStage creates a new ToneMappingStage using the specified input object.

type StageTextureParameter added in v0.20.0

type StageTextureParameter func() render.Texture

StageTextureParameter is a function that returns a texture that is used as a parameter to a render stage.

type StaticMesh added in v0.11.0

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

func (*StaticMesh) Active added in v0.19.0

func (m *StaticMesh) Active() bool

func (*StaticMesh) SetActive added in v0.19.0

func (m *StaticMesh) SetActive(active bool)

type StaticMeshInfo added in v0.11.0

type StaticMeshInfo struct {
	Definition *MeshDefinition
	Matrix     dprec.Mat4
}

type TextureBindingInfo added in v0.19.0

type TextureBindingInfo struct {

	// Texture specifies the texture to be used.
	Texture render.Texture

	// Wrapping specifies the texture wrapping mode.
	Wrapping render.WrapMode

	// Filtering specifies the texture filtering mode.
	Filtering render.FilterMode

	// Mipmapping specifies whether mipmapping should be enabled and whether
	// mipmaps should be generated.
	Mipmapping bool
}

TextureBindingInfo contains the information needed to bind a texture to a material.

type ToneMapping added in v0.4.0

type ToneMapping string
const (
	ReinhardToneMapping    ToneMapping = "reinhard"
	ExponentialToneMapping ToneMapping = "exponential"
)

type ToneMappingStage added in v0.20.0

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

ToneMappingStage is a stage that applies tone mapping to the input HDR texture and outputs the result to the framebuffer.

func (*ToneMappingStage) Allocate added in v0.20.0

func (s *ToneMappingStage) Allocate()

func (*ToneMappingStage) PostRender added in v0.20.0

func (s *ToneMappingStage) PostRender()

func (*ToneMappingStage) PreRender added in v0.20.0

func (s *ToneMappingStage) PreRender(width, height uint32)

func (*ToneMappingStage) Release added in v0.20.0

func (s *ToneMappingStage) Release()

func (*ToneMappingStage) Render added in v0.20.0

func (s *ToneMappingStage) Render(ctx StageContext)

func (*ToneMappingStage) SetToneMapping added in v0.20.0

func (s *ToneMappingStage) SetToneMapping(toneMapping ToneMapping)

SetToneMapping sets the tone mapping algorithm that should be used when rendering the output of the stage.

func (*ToneMappingStage) ToneMapping added in v0.20.0

func (s *ToneMappingStage) ToneMapping() ToneMapping

ToneMapping represents the tone mapping algorithm that should be used when rendering the output of the stage.

type ToneMappingStageInput added in v0.20.0

type ToneMappingStageInput struct {
	HDRTexture   StageTextureParameter
	BloomTexture opt.T[StageTextureParameter]
}

type VertexBuilder added in v0.19.0

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

VertexBuilder is a helper for constructing a vertex for a mesh.

func (VertexBuilder) Color added in v0.19.0

func (vb VertexBuilder) Color(r, g, b, a float32) VertexBuilder

Color sets the color of the vertex.

func (VertexBuilder) ColorVec4 added in v0.19.0

func (vb VertexBuilder) ColorVec4(vec sprec.Vec4) VertexBuilder

ColorVec4 sets the color of the vertex.

func (VertexBuilder) Coord added in v0.19.0

func (vb VertexBuilder) Coord(x, y, z float32) VertexBuilder

Coord sets the coordinate of the vertex.

func (VertexBuilder) CoordVec3 added in v0.19.0

func (vb VertexBuilder) CoordVec3(vec sprec.Vec3) VertexBuilder

CoordVec3 sets the coordinate of the vertex.

func (VertexBuilder) Joints added in v0.19.0

func (vb VertexBuilder) Joints(a, b, c, d uint8) VertexBuilder

Joints sets the joint indices of the vertex.

func (VertexBuilder) Normal added in v0.19.0

func (vb VertexBuilder) Normal(x, y, z float32) VertexBuilder

Normal sets the normal of the vertex.

func (VertexBuilder) NormalVec3 added in v0.19.0

func (vb VertexBuilder) NormalVec3(vec sprec.Vec3) VertexBuilder

NormalVec3 sets the normal of the vertex.

func (VertexBuilder) Tangent added in v0.19.0

func (vb VertexBuilder) Tangent(x, y, z float32) VertexBuilder

Tangent sets the tangent of the vertex.

func (VertexBuilder) TangentVec3 added in v0.19.0

func (vb VertexBuilder) TangentVec3(vec sprec.Vec3) VertexBuilder

TangentVec3 sets the tangent of the vertex.

func (VertexBuilder) TexCoord added in v0.19.0

func (vb VertexBuilder) TexCoord(x, y float32) VertexBuilder

TexCoord sets the texture coordinate of the vertex.

func (VertexBuilder) TexCoordVec2 added in v0.19.0

func (vb VertexBuilder) TexCoordVec2(vec sprec.Vec2) VertexBuilder

TexCoordVec2 sets the texture coordinate of the vertex.

func (VertexBuilder) Weights added in v0.19.0

func (vb VertexBuilder) Weights(a, b, c, d float32) VertexBuilder

Weights sets the joint weights of the vertex.

func (VertexBuilder) WeightsVec4 added in v0.19.0

func (vb VertexBuilder) WeightsVec4(vec sprec.Vec4) VertexBuilder

WeightsVec4 sets the joint weights of the vertex.

type Viewport

type Viewport struct {
	X      uint32
	Y      uint32
	Width  uint32
	Height uint32
}

Viewport represents an area on the screen to which rendering will occur.

func NewViewport

func NewViewport(x, y, width, height uint32) Viewport

NewViewport creates a new Viewport with the specified parameters.

type WireframeShapeBuilder added in v0.19.0

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

WireframeShapeBuilder is responsible for creating solid mesh lines.

func (WireframeShapeBuilder) Arc added in v0.19.0

func (mb WireframeShapeBuilder) Arc(position sprec.Vec3, rotation sprec.Quat, radius float32, from, to sprec.Angle, segments int) WireframeShapeBuilder

func (WireframeShapeBuilder) Circle added in v0.19.0

func (mb WireframeShapeBuilder) Circle(position sprec.Vec3, rotation sprec.Quat, radius float32, segments int) WireframeShapeBuilder

func (WireframeShapeBuilder) Line added in v0.19.0

Line creates a new line segment.

Directories

Path Synopsis
lsl
Package lsl provides a simple interface to the Lacking Shader Language.
Package lsl provides a simple interface to the Lacking Shader Language.

Jump to

Keyboard shortcuts

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