Documentation
¶
Index ¶
- type Camera
- func (c *Camera) AspectRatio() float32
- func (c *Camera) AutoExposure() bool
- func (c *Camera) AutoFocus() bool
- func (c *Camera) Delete()
- func (c *Camera) Exposure() float32
- func (c *Camera) FoV() sprec.Angle
- func (c *Camera) FoVMode() FoVMode
- func (c *Camera) FocusRange() (float32, float32)
- func (c *Camera) MaximumExposure() float32
- func (c *Camera) MinimumExposure() float32
- func (c *Camera) SetAspectRatio(ratio float32)
- func (c *Camera) SetAutoExposure(enabled bool)
- func (c *Camera) SetAutoFocus(enabled bool)
- func (c *Camera) SetExposure(exposure float32)
- func (c *Camera) SetFoV(angle sprec.Angle)
- func (c *Camera) SetFoVMode(mode FoVMode)
- func (c *Camera) SetFocusRange(near, far float32)
- func (c *Camera) SetMaximumExposure(maxExposure float32)
- func (c *Camera) SetMinimumExposure(minExposure float32)
- type CubeTexture
- type CubeTextureDefinition
- type DataFormat
- type Engine
- func (e *Engine) Create()
- func (e *Engine) CreateCubeTexture(definition CubeTextureDefinition) *CubeTexture
- func (e *Engine) CreateMeshTemplate(definition MeshTemplateDefinition) *MeshTemplate
- func (e *Engine) CreatePBRMaterial(definition PBRMaterialDefinition) *Material
- func (e *Engine) CreateScene() *Scene
- func (e *Engine) CreateTwoDTexture(definition TwoDTextureDefinition) *TwoDTexture
- func (e *Engine) Destroy()
- type Filter
- type FoVMode
- type IndexFormat
- type InternalFormat
- type Light
- func (l *Light) Delete()
- func (l *Light) Intensity() sprec.Vec3
- func (l *Light) Mode() LightMode
- func (l *Light) ReflectionTexture() *CubeTexture
- func (l *Light) RefractionTexture() *CubeTexture
- func (l *Light) SetIntensity(intensity sprec.Vec3)
- func (l *Light) SetMode(mode LightMode)
- func (l *Light) SetReflectionTexture(texture *CubeTexture)
- func (l *Light) SetRefractionTexture(texture *CubeTexture)
- type LightMode
- type Material
- type Mesh
- type MeshTemplate
- type MeshTemplateDefinition
- type Node
- type PBRMaterialDefinition
- type Primitive
- type Scene
- func (s *Scene) CreateAmbientLight() *Light
- func (s *Scene) CreateCamera() *Camera
- func (s *Scene) CreateDirectionalLight() *Light
- func (s *Scene) CreateMesh(template *MeshTemplate) *Mesh
- func (s *Scene) Delete()
- func (s *Scene) Render(viewport Viewport, camera *Camera)
- func (s *Scene) RenderFramebuffer(framebuffer render.Framebuffer, viewport Viewport, camera *Camera)
- func (s *Scene) Sky() *Sky
- type ShaderCollection
- type ShaderSet
- type Sky
- type SubMeshTemplateDefinition
- type ToneMapping
- type TwoDTexture
- type TwoDTextureDefinition
- type VertexFormat
- type Viewport
- type Wrap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶
type Camera struct { Node // contains filtered or unexported fields }
Camera represents a 3D camera.
func (*Camera) AspectRatio ¶
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 ¶
AutoExposure returns whether this camera will try and automatically adjust the exposure setting to maintain a proper brightness of the final image.
func (*Camera) AutoFocus ¶
AutoFocus returns whether this camera will try and automatically focus on objects.
func (*Camera) 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 ¶
FocusRange changes the range from near to far in which the image will be in focus.
func (*Camera) MaximumExposure ¶ added in v0.3.0
MaximumExposure returns the maximum exposure that the camera may use during AutoExposure.
func (*Camera) MinimumExposure ¶ added in v0.3.0
MinimumExposure returns the maximum exposure that the camera may use during AutoExposure.
func (*Camera) SetAspectRatio ¶
SetAspectRatio changes the aspect ratio of this camera.
func (*Camera) SetAutoExposure ¶
SetAutoExposure changes whether this cammera should attempt to do automatic exposure adjustment.
func (*Camera) SetAutoFocus ¶
SetAutoFocus changes whether this camera should attempt to automatically focus on object in the scene.
func (*Camera) SetExposure ¶
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) SetFoVMode ¶
SetFoVMode changes the field-of-view mode of this camera.
func (*Camera) SetFocusRange ¶
SetFocusRange changes the focus range for this camera.
func (*Camera) SetMaximumExposure ¶ added in v0.3.0
SetMaximumExposure changes the maximum exposure for this camera.
func (*Camera) SetMinimumExposure ¶ added in v0.3.0
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 MinFilter Filter MagFilter Filter 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 DataFormatRGBA32F )
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine represents an entrypoint to 3D graphics rendering.
func (*Engine) CreateCubeTexture ¶
func (e *Engine) CreateCubeTexture(definition CubeTextureDefinition) *CubeTexture
CreateCubeTexture creates a new CubeTexture using the specified definition.
func (*Engine) CreateMeshTemplate ¶
func (e *Engine) CreateMeshTemplate(definition MeshTemplateDefinition) *MeshTemplate
CreateMeshTemplate creates a new MeshTemplate using the specified definition.
func (*Engine) CreatePBRMaterial ¶
func (e *Engine) CreatePBRMaterial(definition PBRMaterialDefinition) *Material
CreatePBRMaterial creates a new Material that is based on PBR definition.
func (*Engine) CreateScene ¶
CreateScene creates a new 3D Scene. Entities managed within a given scene are isolated within that scene.
func (*Engine) CreateTwoDTexture ¶
func (e *Engine) CreateTwoDTexture(definition TwoDTextureDefinition) *TwoDTexture
CreateTwoDTexture creates a new TwoDTexture using the specified definition.
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
const ( IndexFormatU16 IndexFormat = 1 + iota IndexFormatU32 )
type InternalFormat ¶
type InternalFormat int
const ( InternalFormatRGBA8 InternalFormat = 1 + iota InternalFormatRGBA32F )
type Light ¶
type Light struct { Node // contains filtered or unexported fields }
Light represents a light emitting object in the scene.
func (*Light) ReflectionTexture ¶ added in v0.4.0
func (l *Light) ReflectionTexture() *CubeTexture
ReflectionTexture returns the texture that is used to calculate the lighting on an object as a result of reflected light rays.
func (*Light) RefractionTexture ¶ added in v0.4.0
func (l *Light) RefractionTexture() *CubeTexture
RefractionTexture returns the texture that is used to calculate the lighting on an object as a result of refracted light rays.
func (*Light) SetIntensity ¶
SetIntensity changes the light intensity.
func (*Light) SetReflectionTexture ¶ added in v0.4.0
func (l *Light) SetReflectionTexture(texture *CubeTexture)
SetReflectionTexture changes the reflection texture.
func (*Light) SetRefractionTexture ¶ added in v0.4.0
func (l *Light) SetRefractionTexture(texture *CubeTexture)
SetRefractionTexture changes the refraction texture.
type Material ¶
type Material struct {
// contains filtered or unexported fields
}
Material determines the appearance of a mesh on the screen.
type Mesh ¶
type Mesh struct { Node // contains filtered or unexported fields }
Mesh represents an instance of a 3D mesh.
type MeshTemplate ¶
type MeshTemplate struct {
// contains filtered or unexported fields
}
MeshTemplate represents the definition of a mesh. Multiple mesh instances can be created off of one template reusing resources.
func (*MeshTemplate) Delete ¶
func (t *MeshTemplate) Delete()
Delete releases any resources allocated by this template.
type MeshTemplateDefinition ¶
type MeshTemplateDefinition struct { VertexData []byte VertexFormat VertexFormat IndexData []byte IndexFormat IndexFormat SubMeshes []SubMeshTemplateDefinition }
MeshTemplateDefinition contains everything needed to create a new MeshTemplate.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node represents a positioning of some entity in the 3D scene.
func (*Node) SetPosition ¶
SetPosition changes this entity's position.
func (*Node) SetRotation ¶
SetRotation changes this entity's rotation.
type PBRMaterialDefinition ¶
type PBRMaterialDefinition struct { BackfaceCulling bool AlphaBlending bool AlphaTesting bool AlphaThreshold float32 Metalness float32 MetalnessTexture *TwoDTexture Roughness float32 RoughnessTexture *TwoDTexture AlbedoColor sprec.Vec4 AlbedoTexture *TwoDTexture NormalScale float32 NormalTexture *TwoDTexture }
PBRMaterialDefinition contains the information needed to create a PBR Material.
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) CreateAmbientLight ¶
CreateAmbientLight creates a new ambient light object to be used within this scene.
func (*Scene) CreateCamera ¶
CreateCamera creates a new camera object to be used with this scene.
func (*Scene) CreateDirectionalLight ¶
CreateDirectionalLight creates a new directional light object to be used within this scene.
func (*Scene) CreateMesh ¶
func (s *Scene) CreateMesh(template *MeshTemplate) *Mesh
CreateMesh creates a new mesh instance from the specified template and places it in the scene.
func (*Scene) Delete ¶
func (s *Scene) Delete()
Delete removes this scene and releases all entities allocated for it.
func (*Scene) Render ¶
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, camera *Camera)
Render draws this scene to the specified viewport looking through the specified camera.
type ShaderCollection ¶ added in v0.4.0
type ShaderCollection struct { ExposureSet func() ShaderSet PostprocessingSet func(mapping ToneMapping) ShaderSet DirectionalLightSet func() ShaderSet AmbientLightSet func() ShaderSet SkyboxSet func() ShaderSet SkycolorSet func() ShaderSet PBRShaderSet func(definition PBRMaterialDefinition) ShaderSet }
type Sky ¶
type Sky struct {
// contains filtered or unexported fields
}
Sky represents the Scene's background.
func (*Sky) BackgroundColor ¶
BackgroundColor returns the color of the background.
func (*Sky) SetBackgroundColor ¶
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 SubMeshTemplateDefinition ¶
type SubMeshTemplateDefinition struct { Primitive Primitive IndexOffset int IndexCount int Material *Material }
SubMeshTemplateDefinition represents a portion of a mesh that is drawn with a specific material.
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 WrapS Wrap WrapT Wrap MinFilter Filter MagFilter Filter UseAnisotropy 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 }
type Viewport ¶
Viewport represents an area on the screen to which rendering will occur.
func NewViewport ¶
NewViewport creates a new Viewport with the specified parameters.