Documentation ¶
Index ¶
- Constants
- func AddInput(ctx vk.APIContext, gr *vk.GraphicsPipeline, kind MeshKind)
- func DescribeWhiteImage(ctx vk.APIContext) (desc vk.ImageDescription)
- func GetDefaultSampler(ctx vk.APIContext, dev *vk.Device) *vk.Sampler
- type AABB
- type Animation
- type BoundShader
- type Channel
- type ChannelTarget
- type Compute
- type Copier
- func (c *Copier) CopyFromImage(src *vk.Image, imRange vk.ImageRange, kind string, finalLayout vk.ImageLayout) (content []byte)
- func (c *Copier) CopyToBuffer(dst *vk.Buffer, content []byte)
- func (c *Copier) CopyToImage(dst *vk.Image, kind string, content []byte, imRange vk.ImageRange, ...)
- func (c *Copier) CopyWhiteImage(dst *vk.Image)
- func (c *Copier) Dispose()
- func (c *Copier) SetLayout(dst *vk.Image, imRange vk.ImageRange, finalLayout vk.ImageLayout)
- type DrawContext
- type Frame
- type ImageBuilder
- type ImageIndex
- type Joint
- type Material
- type MaterialIndex
- type MaterialInfo
- type MaterialProperties
- func (mp MaterialProperties) GetColor(prop Property, defaultValue mgl32.Vec4) mgl32.Vec4
- func (mp MaterialProperties) GetFactor(prop Property, defaultValue float32) float32
- func (mp MaterialProperties) GetImage(prop Property) ImageIndex
- func (mp MaterialProperties) SetColor(prop Property, val mgl32.Vec4) MaterialProperties
- func (mp MaterialProperties) SetFactor(prop Property, val float32) MaterialProperties
- func (mp MaterialProperties) SetImage(prop Property, im ImageIndex) MaterialProperties
- type Mesh
- type MeshBuilder
- func (mb *MeshBuilder) AddCube(tr mgl32.Mat4)
- func (mb *MeshBuilder) AddIcosahedron(tr mgl32.Mat4)
- func (mb *MeshBuilder) AddIndex(points ...uint32) (index int)
- func (mb *MeshBuilder) AddPlane(tr mgl32.Mat4)
- func (mb *MeshBuilder) AddVertex(position mgl32.Vec3) *VertexBuilder
- func (mb *MeshBuilder) GetPositions() (positions []float32)
- type MeshIndex
- type MeshKind
- type Model
- func (m *Model) Bounds(index NodeIndex, transform mgl32.Mat4, includeChild bool) (aabb AABB)
- func (m *Model) Dispose()
- func (m *Model) FindMaterial(name string) MaterialIndex
- func (m *Model) FindNode(nodeName string) NodeIndex
- func (m *Model) GetImage(idx ImageIndex) *vk.Image
- func (m *Model) GetImageView(idx ImageIndex) (view *vk.ImageView, sampler *vk.Sampler)
- func (m *Model) GetMaterial(idx MaterialIndex) Material
- func (m *Model) GetMesh(idx MeshIndex) Mesh
- func (m *Model) GetNode(idx NodeIndex) Node
- func (m *Model) GetSkin(index SkinIndex) *Skin
- func (m *Model) NodeCount() int
- func (m *Model) VertexBuffers(kind MeshKind) []*vk.Buffer
- type ModelBuilder
- func (mb *ModelBuilder) AddDecalMaterial(name string, props MaterialProperties) MaterialIndex
- func (mb *ModelBuilder) AddImage(kind string, content []byte, usage vk.ImageUsageFlags) ImageIndex
- func (mb *ModelBuilder) AddMaterial(name string, props MaterialProperties) MaterialIndex
- func (mb *ModelBuilder) AddMesh(mesh *MeshBuilder) MeshIndex
- func (mb *ModelBuilder) AddNode(name string, parent *NodeBuilder, transform mgl32.Mat4) *NodeBuilder
- func (mb *ModelBuilder) AddSkin(skin Skin) SkinIndex
- func (mb *ModelBuilder) AddWhite() ImageIndex
- func (mb *ModelBuilder) FindMaterial(name string) (index MaterialIndex)
- func (mb *ModelBuilder) ToModel(ctx vk.APIContext, dev *vk.Device) *Model
- type Node
- type NodeBuilder
- func (nb *NodeBuilder) AddChild(child ...*NodeBuilder) *NodeBuilder
- func (nb *NodeBuilder) ForNodes(action func(n *NodeBuilder, parent *NodeBuilder, index int))
- func (nb *NodeBuilder) SetMesh(m MeshIndex, mat MaterialIndex) *NodeBuilder
- func (nb *NodeBuilder) SetSkinnedMesh(m MeshIndex, mat MaterialIndex, skin SkinIndex) *NodeBuilder
- type NodeIndex
- type Property
- type Renderer
- type Shader
- type ShaderExtra
- type ShaderFactory
- type Skin
- type SkinIndex
- type VertexBuilder
- func (vb *VertexBuilder) AddColor(color mgl32.Vec4) *VertexBuilder
- func (vb *VertexBuilder) AddNormal(normal mgl32.Vec3) *VertexBuilder
- func (vb *VertexBuilder) AddTangent(tangent mgl32.Vec3) *VertexBuilder
- func (vb *VertexBuilder) AddUV(uv mgl32.Vec2) *VertexBuilder
- func (vb *VertexBuilder) AddWeights(weights mgl32.Vec4, joints ...uint16) *VertexBuilder
- type VertexFlags
Constants ¶
const ( VFUV = VertexFlags(1) VFNormal = VertexFlags(2) VFTangent = VertexFlags(4) VFWeights = VertexFlags(16) )
const ( Color = Property(0x01000000) CAlbedo = Color + 1 CEmissive = Color + 2 CSpecular = Color + 3 Texture = Property(0x02000000) TxAlbedo = Texture + 1 TxEmissive = Texture + 2 TxSpecular = Texture + 3 TxBump = Texture + 4 TxMetallicRoughness = Texture + 5 Factor = Property(0x03000000) FSpeculaPower = Factor + 1 FMetalness = Factor + 2 FRoughness = Factor + 3 // For decals to specify if normal difference from surface to decal will attenuate decal effect. // 0 - No attanuation, 1 - Full attenuation (factor = dot(normal, decalNormal)) FNormalAttenuation = Factor + 4 // Max level of alpha to discard pixel. FAlphaCutoff = Factor + 5 Special = Property(0xFF000000) SMaxIndex = Special + 1 PropertyKind = Property(0xFF000000) )
const ( MESHKindNormal = MeshKind(0) MESHKindSkinned = MeshKind(1) MESHMax = 2 )
const ( TTranslation = ChannelTarget(1) TScale = ChannelTarget(2) TRotation = ChannelTarget(3) )
Variables ¶
This section is empty.
Functions ¶
func AddInput ¶
func AddInput(ctx vk.APIContext, gr *vk.GraphicsPipeline, kind MeshKind)
func DescribeWhiteImage ¶
func DescribeWhiteImage(ctx vk.APIContext) (desc vk.ImageDescription)
func GetDefaultSampler ¶
Types ¶
type BoundShader ¶ added in v0.20.1
type Channel ¶
type Channel struct { Joint int Input []float32 Output []float32 Target ChannelTarget }
type ChannelTarget ¶
type ChannelTarget uint32
type Compute ¶
type Compute struct {
// contains filtered or unexported fields
}
func NewCompute ¶
func NewCompute(ctx vk.APIContext, dev *vk.Device) *Compute
type Copier ¶
type Copier struct {
// contains filtered or unexported fields
}
func (*Copier) CopyFromImage ¶
func (c *Copier) CopyFromImage(src *vk.Image, imRange vk.ImageRange, kind string, finalLayout vk.ImageLayout) (content []byte)
func (*Copier) CopyToImage ¶
func (c *Copier) CopyToImage(dst *vk.Image, kind string, content []byte, imRange vk.ImageRange, finalLayout vk.ImageLayout)
func (*Copier) CopyWhiteImage ¶
func (*Copier) SetLayout ¶
func (c *Copier) SetLayout(dst *vk.Image, imRange vk.ImageRange, finalLayout vk.ImageLayout)
type DrawContext ¶
type DrawContext struct { Frame Frame Pass vk.RenderPass List *vk.DrawList }
func (*DrawContext) DrawIndexed ¶
type Frame ¶ added in v0.20.1
type Frame interface { // Retrieve renderer associated to this frame GetRenderer() Renderer // Retrieve render cache assosiate to this render instance GetCache() *vk.RenderCache }
type ImageBuilder ¶
type ImageBuilder struct { Kind string Content []byte Usage vk.ImageUsageFlags Desc vk.ImageDescription // contains filtered or unexported fields }
type ImageIndex ¶
type ImageIndex int
type Material ¶
type Material struct { Props MaterialProperties Shader Shader Name string }
type MaterialIndex ¶
type MaterialIndex int
type MaterialInfo ¶ added in v0.20.1
type MaterialInfo struct { Props MaterialProperties Name string Decal bool // contains filtered or unexported fields }
type MaterialProperties ¶
type MaterialProperties map[Property]interface{}
func NewMaterialProperties ¶
func NewMaterialProperties() MaterialProperties
func (MaterialProperties) GetFactor ¶
func (mp MaterialProperties) GetFactor(prop Property, defaultValue float32) float32
func (MaterialProperties) GetImage ¶
func (mp MaterialProperties) GetImage(prop Property) ImageIndex
func (MaterialProperties) SetColor ¶
func (mp MaterialProperties) SetColor(prop Property, val mgl32.Vec4) MaterialProperties
func (MaterialProperties) SetFactor ¶
func (mp MaterialProperties) SetFactor(prop Property, val float32) MaterialProperties
func (MaterialProperties) SetImage ¶
func (mp MaterialProperties) SetImage(prop Property, im ImageIndex) MaterialProperties
type MeshBuilder ¶
type MeshBuilder struct { Vextexies []*VertexBuilder Incides []uint32 // contains filtered or unexported fields }
MeshBuilder is used to construct one mesh. Mesh is then added to model builder
func (*MeshBuilder) AddCube ¶
func (mb *MeshBuilder) AddCube(tr mgl32.Mat4)
AddCube will create simple unit cube (1x1x1) transformed with given transformation This method is used to make simple test models.
func (*MeshBuilder) AddIcosahedron ¶
func (mb *MeshBuilder) AddIcosahedron(tr mgl32.Mat4)
AddIcosahedron adds simple unit icosahedron to mesh
func (*MeshBuilder) AddIndex ¶
func (mb *MeshBuilder) AddIndex(points ...uint32) (index int)
Add indexes to vertexes. Mesh can be used without index information, in witch case each set of three vertexes will make one triagle. VGE don't support any other modes to combine vertexes. Use indexes if you wan't to reuse same vertex multiple times
func (*MeshBuilder) AddPlane ¶
func (mb *MeshBuilder) AddPlane(tr mgl32.Mat4)
AddPlane adds one unit plane to to mesh
func (*MeshBuilder) AddVertex ¶
func (mb *MeshBuilder) AddVertex(position mgl32.Vec3) *VertexBuilder
Add new vertex to mesh. You must provide at least position of mesh
func (*MeshBuilder) GetPositions ¶
func (mb *MeshBuilder) GetPositions() (positions []float32)
GetPosition retrieves all mesh positions as float32 array
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
func (*Model) FindMaterial ¶ added in v0.20.1
func (m *Model) FindMaterial(name string) MaterialIndex
FindMaterial finds material index for named material. Return is -1 if material was not found
func (*Model) GetImageView ¶ added in v0.20.1
func (*Model) GetMaterial ¶
func (m *Model) GetMaterial(idx MaterialIndex) Material
type ModelBuilder ¶
type ModelBuilder struct { MipLevels uint32 ShaderFactory ShaderFactory Materials []MaterialInfo Images []*ImageBuilder Meshes []*MeshBuilder Root *NodeBuilder Skins []Skin // contains filtered or unexported fields }
ModelBuilder allows us to load multiple meshes, materials, images and skins. When we have loaded all nessessary artifacts, model builder can be converted to a model. Model will upload all model information (except Skins) to GPU where Shaders can access them quickly
func (*ModelBuilder) AddDecalMaterial ¶ added in v0.20.1
func (mb *ModelBuilder) AddDecalMaterial(name string, props MaterialProperties) MaterialIndex
Add new Decal material to model builders. For Decal material model builder will not create a shader nor allocate any descriptor sets.
func (*ModelBuilder) AddImage ¶
func (mb *ModelBuilder) AddImage(kind string, content []byte, usage vk.ImageUsageFlags) ImageIndex
Attach image to model. This image can be them bound to material using material properties
func (*ModelBuilder) AddMaterial ¶
func (mb *ModelBuilder) AddMaterial(name string, props MaterialProperties) MaterialIndex
Add new material to model builders. Model builders ShaderFactory is finally used to convert material properties to shader. Most of shader also build a descriptor set that links all static assets like color and textures of a material to a single Vulkan descriptor set.
func (*ModelBuilder) AddMesh ¶
func (mb *ModelBuilder) AddMesh(mesh *MeshBuilder) MeshIndex
Add a mesh to model. Actual mesh content is built with MeshBuilder
func (*ModelBuilder) AddNode ¶
func (mb *ModelBuilder) AddNode(name string, parent *NodeBuilder, transform mgl32.Mat4) *NodeBuilder
Add new node to model. If parent node is empty, predefined root node, named _root will be used.
func (*ModelBuilder) AddSkin ¶
func (mb *ModelBuilder) AddSkin(skin Skin) SkinIndex
Add skin to model
func (*ModelBuilder) AddWhite ¶
func (mb *ModelBuilder) AddWhite() ImageIndex
func (*ModelBuilder) FindMaterial ¶ added in v0.20.1
func (mb *ModelBuilder) FindMaterial(name string) (index MaterialIndex)
FindMaterial retrieves converted named material. Return is -1, nil if no material was found
func (*ModelBuilder) ToModel ¶
func (mb *ModelBuilder) ToModel(ctx vk.APIContext, dev *vk.Device) *Model
Convert content of model builder to actual model and uploads model content (except skins) to GPU
type Node ¶
type NodeBuilder ¶
type NodeBuilder struct { Name string Children []*NodeBuilder Location mgl32.Mat4 Mesh MeshIndex Material MaterialIndex Skin SkinIndex }
func (*NodeBuilder) AddChild ¶
func (nb *NodeBuilder) AddChild(child ...*NodeBuilder) *NodeBuilder
Add childs adds child nodes to a node
func (*NodeBuilder) ForNodes ¶ added in v0.20.1
func (nb *NodeBuilder) ForNodes(action func(n *NodeBuilder, parent *NodeBuilder, index int))
ForNodes recursively enumerates though all nodes child nodes
func (*NodeBuilder) SetMesh ¶
func (nb *NodeBuilder) SetMesh(m MeshIndex, mat MaterialIndex) *NodeBuilder
SetMesh assign a mesh with material to node
func (*NodeBuilder) SetSkinnedMesh ¶
func (nb *NodeBuilder) SetSkinnedMesh(m MeshIndex, mat MaterialIndex, skin SkinIndex) *NodeBuilder
SetMesh assign a mesh with material and skin to node
type Renderer ¶ added in v0.20.1
type Renderer interface { // GetPerRenderer allows nodes to store information that is shared between all frames of renderer. Typically each frame has it's own render // cache where you can store frame relevant assets. Each image of swapchain will get it's own frame. GetPerRenderer(key vk.Key, ctor func(ctx vk.APIContext) interface{}) interface{} }
type Shader ¶
type Shader interface { SetDescriptor(dsMat *vk.DescriptorSet) Draw(ctx *DrawContext, mesh Mesh, world mgl32.Mat4, extra ShaderExtra) DrawSkinned(ctx *DrawContext, mesh Mesh, world mgl32.Mat4, aniMatrix []mgl32.Mat4, extra ShaderExtra) }
type ShaderExtra ¶
type ShaderFactory ¶
type ShaderFactory func(ctx vk.APIContext, dev *vk.Device, propSet MaterialProperties) ( sh Shader, layout *vk.DescriptorLayout, ubf []byte, images []ImageIndex)
type VertexBuilder ¶
type VertexBuilder struct { Index uint32 Position mgl32.Vec3 Uv mgl32.Vec2 Normal mgl32.Vec3 Tangent mgl32.Vec3 Color mgl32.Vec4 Weights mgl32.Vec4 // qtangent mgl32.Quat Joints [4]uint16 // contains filtered or unexported fields }
Vertex builder builds one vertex of a mesh
func (*VertexBuilder) AddColor ¶
func (vb *VertexBuilder) AddColor(color mgl32.Vec4) *VertexBuilder
AddColor adds vertex color. This is not used in current shaders but can be like an extra vec4 value is vertex input
func (*VertexBuilder) AddNormal ¶
func (vb *VertexBuilder) AddNormal(normal mgl32.Vec3) *VertexBuilder
func (*VertexBuilder) AddTangent ¶
func (vb *VertexBuilder) AddTangent(tangent mgl32.Vec3) *VertexBuilder
func (*VertexBuilder) AddUV ¶
func (vb *VertexBuilder) AddUV(uv mgl32.Vec2) *VertexBuilder
func (*VertexBuilder) AddWeights ¶
func (vb *VertexBuilder) AddWeights(weights mgl32.Vec4, joints ...uint16) *VertexBuilder
Add weight and joints to vertex. If you add weights and joints to vertex it will convert whole mesh to a skinned mesh. You must also provide Skin to model nodes that uses skinned mesh. Skinned meshes won't be shown without skin and of cause normal meshes can't handle skins.
type VertexFlags ¶
type VertexFlags int