graphics

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 19 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShowLightView bool

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) 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
	// TODO: Use a Box shape instead
	InnerRadius       float64
	OuterRadius       float64
	ReflectionTexture *CubeTexture
	RefractionTexture *CubeTexture
}

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 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) 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) 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) 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) 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) 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.

type CubeTexture

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

CubeTexture represents a cube texture.

func (*CubeTexture) Delete

func (t *CubeTexture) Delete()

Delete releases any resources allocated for this texture.

type CubeTextureDefinition

type CubeTextureDefinition struct {
	Dimension int

	Filtering       Filter
	GenerateMipmaps bool
	GammaCorrection bool

	InternalFormat InternalFormat
	DataFormat     DataFormat
	FrontSideData  []byte
	BackSideData   []byte
	LeftSideData   []byte
	RightSideData  []byte
	TopSideData    []byte
	BottomSideData []byte
}

CubeTextureDefinition contains all the information needed to create a CubeTexture.

type DataFormat

type DataFormat int
const (
	DataFormatRGBA8 DataFormat = 1 + iota
	DataFormatRGBA16F
	DataFormatRGBA32F
)

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 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) 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) EmitRange added in v0.14.0

func (l *DirectionalLight) EmitRange() float64

EmitRange returns the distance that this light source covers.

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) 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) SetEmitRange added in v0.14.0

func (l *DirectionalLight) SetEmitRange(emitRange float64)

SetEmitRange changes the distance that this light source covers.

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
	Orientation dprec.Quat
	EmitColor   dprec.Vec3
	EmitRange   float64
}

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) *Engine

func (*Engine) Create

func (e *Engine) Create()

Create initializes this 3D engine.

func (*Engine) CreateCubeTexture

func (e *Engine) CreateCubeTexture(definition CubeTextureDefinition) *CubeTexture

CreateCubeTexture creates a new CubeTexture using the specified definition.

func (*Engine) CreateMaterialDefinition added in v0.9.0

func (e *Engine) CreateMaterialDefinition(info MaterialDefinitionInfo) *MaterialDefinition

CreateMaterialDefinition creates a new MaterialDefinition 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) CreatePBRMaterialDefinition added in v0.9.0

func (e *Engine) CreatePBRMaterialDefinition(info PBRMaterialInfo) *MaterialDefinition

CreatePBRMaterialDefinition creates a new Material that is based on PBR definition. TODO: Remove this and create a PBR builder over MaterialDefinitionInfo.

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) CreateShading added in v0.16.0

func (e *Engine) CreateShading(info ShadingInfo) Shading

func (*Engine) CreateTwoDTexture

func (e *Engine) CreateTwoDTexture(definition TwoDTextureDefinition) *TwoDTexture

CreateTwoDTexture creates a new TwoDTexture using the specified definition.

func (*Engine) Debug added in v0.10.0

func (e *Engine) Debug() *Debug

func (*Engine) Destroy

func (e *Engine) Destroy()

Destroy releases resources allocated by this 3D engine.

func (*Engine) PBRShading added in v0.9.0

func (e *Engine) PBRShading() Shading

PBRShading returns the Shading implementaton for phisically-based rendering.

type Filter

type Filter int
const (
	FilterNearest Filter = iota
	FilterLinear
	FilterAnisotropic
)

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 IndexFormat

type IndexFormat int

IndexFormat specifies the data type that is used to represent individual indices.

const (
	IndexFormatU16 IndexFormat = 1 + iota
	IndexFormatU32
)

type InternalFormat

type InternalFormat int
const (
	InternalFormatRGBA8 InternalFormat = 1 + iota
	InternalFormatRGBA16F
	InternalFormatRGBA32F
)

type Material

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

Material determines the appearance of a mesh on the screen.

type MaterialDefinition added in v0.9.0

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

MaterialDefinition represents a particular material template. Multiple meshes can share the same MaterialDefinition though their Material instances will differ.

func (*MaterialDefinition) AlphaBlending added in v0.9.0

func (d *MaterialDefinition) AlphaBlending() bool

AlphaBlending returns whether the mesh will be checked for translucency and will be mixed with the background.

func (*MaterialDefinition) AlphaTesting added in v0.9.0

func (d *MaterialDefinition) AlphaTesting() bool

AlphaTesting returns whether the mesh will be checked for transparent sections.

func (*MaterialDefinition) AlphaThreshold added in v0.9.0

func (d *MaterialDefinition) AlphaThreshold() float32

AlphaThreshold returns the alpha value below which a pixel will be considered transparent.

func (*MaterialDefinition) BackfaceCulling added in v0.9.0

func (d *MaterialDefinition) BackfaceCulling() bool

BackfaceCulling returns whether the back face of triangles should be skipped during rendering.

func (*MaterialDefinition) SetAlphaBlending added in v0.9.0

func (d *MaterialDefinition) SetAlphaBlending(blending bool)

SetAlphaBlending changes whether alpha blending will be performed.

func (*MaterialDefinition) SetAlphaTesting added in v0.9.0

func (d *MaterialDefinition) SetAlphaTesting(testing bool)

SetAlphaTesting changes whether alpha testing will be performed.

func (*MaterialDefinition) SetAlphaThreshold added in v0.9.0

func (d *MaterialDefinition) SetAlphaThreshold(threshold float32)

SetAlphaThreshold changes the alpha threshold.

func (*MaterialDefinition) SetBackfaceCulling added in v0.9.0

func (d *MaterialDefinition) SetBackfaceCulling(culling bool)

SetBackfaceCulling changes the back face culling configuration of this material definition.

type MaterialDefinitionInfo added in v0.9.0

type MaterialDefinitionInfo struct {
	BackfaceCulling bool
	AlphaTesting    bool
	AlphaBlending   bool
	AlphaThreshold  float32
	Vectors         []sprec.Vec4
	TwoDTextures    []render.Texture
	CubeTextures    []render.Texture
	Shading         Shading
}

MaterialDefinitionInfo contains the information needed to create a MaterialDefinition.

type Mesh

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

Mesh represents an instance of a 3D mesh.

func (*Mesh) Delete

func (m *Mesh) Delete()

Delete removes this mesh from the scene.

func (*Mesh) SetMatrix added in v0.9.0

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

type MeshConfig added in v0.16.0

type MeshConfig struct {
	HasArmature bool
}

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 (t *MeshDefinition) Delete()

Delete releases any resources owned by this MeshDefinition.

type MeshDefinitionInfo added in v0.9.0

type MeshDefinitionInfo struct {
	VertexData           []byte
	VertexFormat         VertexFormat
	IndexData            []byte
	IndexFormat          IndexFormat
	Fragments            []MeshFragmentDefinitionInfo
	BoundingSphereRadius float64
}

MeshDefinitionInfo contains everything needed to create a new MeshDefinition.

func (*MeshDefinitionInfo) NeedsArmature added in v0.9.0

func (i *MeshDefinitionInfo) NeedsArmature() bool

NeedsArmature returns whether the mesh described by this info object will require an Armature to be visualized.

type MeshFragmentDefinitionInfo added in v0.9.0

type MeshFragmentDefinitionInfo struct {
	Primitive   Primitive
	IndexOffset int
	IndexCount  int
	Material    *MaterialDefinition
}

MeshFragmentDefinitionInfo represents the definition of a portion of a mesh that is drawn with a specific material and primitives.

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 PBRGeometryShaderConfig added in v0.9.0

type PBRGeometryShaderConfig struct {
	HasArmature      bool
	HasAlphaTesting  bool
	HasVertexColors  bool
	HasAlbedoTexture bool
}

type PBRMaterialInfo added in v0.9.0

type PBRMaterialInfo struct {
	BackfaceCulling          bool
	AlphaBlending            bool
	AlphaTesting             bool
	AlphaThreshold           float32
	Metallic                 float32
	Roughness                float32
	MetallicRoughnessTexture *TwoDTexture
	AlbedoColor              sprec.Vec4
	AlbedoTexture            *TwoDTexture
	NormalScale              float32
	NormalTexture            *TwoDTexture
}

PBRMaterialInfo contains the information needed to create a PBR Material.

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
}

PointLightInfo contains the information needed to create a PointLight.

type PostprocessingShaderConfig added in v0.9.0

type PostprocessingShaderConfig struct {
	ToneMapping ToneMapping
}

type Primitive

type Primitive int

Primitive represents the basic shape unit that is described by indices (for example: triangles).

const (
	PrimitivePoints Primitive = 1 + iota
	PrimitiveLines
	PrimitiveLineStrip
	PrimitiveLineLoop
	PrimitiveTriangles
	PrimitiveTriangleStrip
	PrimitiveTriangleFan
)

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) 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) 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(viewport Viewport)

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

func (*Scene) RenderFramebuffer added in v0.4.0

func (s *Scene) RenderFramebuffer(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) Sky

func (s *Scene) Sky() *Sky

Sky returns this scene's sky object. You can use the Sky object to control the background appearance.

type ShaderCollection added in v0.4.0

type ShaderCollection struct {
	BuildGeometry func(meshConfig MeshConfig, fn shading.GeometryFunc) render.ProgramCode
	BuildForward  func(meshConfig MeshConfig, fn shading.ForwardFunc) render.ProgramCode

	ShadowMappingSet    func(cfg ShadowMappingShaderConfig) render.ProgramCode
	PBRGeometrySet      func(cfg PBRGeometryShaderConfig) render.ProgramCode
	DirectionalLightSet func() render.ProgramCode
	AmbientLightSet     func() render.ProgramCode
	PointLightSet       func() render.ProgramCode
	SpotLightSet        func() render.ProgramCode
	SkyboxSet           func() render.ProgramCode
	SkycolorSet         func() render.ProgramCode
	DebugSet            func() render.ProgramCode
	ExposureSet         func() render.ProgramCode
	PostprocessingSet   func(cfg PostprocessingShaderConfig) render.ProgramCode
}

type Shading added in v0.9.0

type Shading interface {

	// ShadowPipeline constructs a render Pipeline for the specified mesh and
	// material definitions to be used in the shadow pass.
	ShadowPipeline(meshDef *MeshDefinition, fragmentDef *meshFragmentDefinition) render.Pipeline

	// GeometryPipeline constructs a render Pipeline for the specified mesh and
	// material definitions to be used in the geometry pass.
	GeometryPipeline(meshDef *MeshDefinition, fragmentDef *meshFragmentDefinition) render.Pipeline

	// EmissivePipeline constructs a render Pipeline for the specified mesh and
	// material definitions to be used in the emissive pass.
	EmissivePipeline(meshDef *MeshDefinition, fragmentDef *meshFragmentDefinition) render.Pipeline

	// ForwardPipeline constructs a render Pipeline for the specified mesh and
	// material definitions to be used in the forward pass.
	ForwardPipeline(meshDef *MeshDefinition, fragmentDef *meshFragmentDefinition) render.Pipeline
}

Shading represents an algorithm for shading a particular mesh and material.

type ShadingInfo added in v0.16.0

type ShadingInfo struct {
	ShadowFunc   shading.ShadowFunc
	GeometryFunc shading.GeometryFunc
	EmissiveFunc shading.EmissiveFunc
	ForwardFunc  shading.ForwardFunc
	LightingFunc shading.LightingFunc
}

type ShadowMappingShaderConfig added in v0.9.0

type ShadowMappingShaderConfig struct {
	HasArmature bool
}

type Sky

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

Sky represents the Scene's background.

func (*Sky) BackgroundColor

func (s *Sky) BackgroundColor() sprec.Vec3

BackgroundColor returns the color of the background.

func (*Sky) SetBackgroundColor

func (s *Sky) SetBackgroundColor(color sprec.Vec3)

SetBackgroundColor changes the color of the background.

func (*Sky) SetSkybox

func (s *Sky) SetSkybox(skybox *CubeTexture)

SetSkybox sets a cube texture to be used as the background. If nil is specified, then a texture will not be used and instead the background color will be drawn instead.

func (*Sky) Skybox

func (s *Sky) Skybox() *CubeTexture

// Skybox returns the cube texture to be used as the background. // If one has not been set, this method returns nil.

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
}

SpotLightInfo contains the information needed to create a SpotLight.

type StaticMesh added in v0.11.0

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

type StaticMeshInfo added in v0.11.0

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

type ToneMapping added in v0.4.0

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

type TwoDTexture

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

TwoDTexture represents a two-dimensional texture.

func (*TwoDTexture) Delete

func (t *TwoDTexture) Delete()

Delete releases any resources allocated for this texture.

type TwoDTextureDefinition

type TwoDTextureDefinition struct {
	Width  int
	Height int

	Wrapping        Wrap
	Filtering       Filter
	GenerateMipmaps bool
	GammaCorrection bool

	InternalFormat InternalFormat
	DataFormat     DataFormat
	Data           []byte
}

TwoDTextureDefinition contains all the information needed to create a TwoDTexture.

type VertexFormat

type VertexFormat struct {
	HasCoord            bool
	CoordOffsetBytes    int
	CoordStrideBytes    int
	HasNormal           bool
	NormalOffsetBytes   int
	NormalStrideBytes   int
	HasTangent          bool
	TangentOffsetBytes  int
	TangentStrideBytes  int
	HasTexCoord         bool
	TexCoordOffsetBytes int
	TexCoordStrideBytes int
	HasColor            bool
	ColorOffsetBytes    int
	ColorStrideBytes    int
	HasWeights          bool
	WeightsOffsetBytes  int
	WeightsStrideBytes  int
	HasJoints           bool
	JointsOffsetBytes   int
	JointsStrideBytes   int
}

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

type Viewport

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

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

func NewViewport

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

NewViewport creates a new Viewport with the specified parameters.

type Wrap

type Wrap int
const (
	WrapClampToEdge Wrap = iota
	WrapRepeat
	WrapMirroredRepat
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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