ocl

package
v0.0.0-...-4f29a8f Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildCLGroup

func BuildCLGroup(group *shapes.Group) int32

func BuildRayBuffer

func BuildRayBuffer(rays []geom.Ray) []float64

BuildRayBuffer passes each ray to a float64 slice, using 8 floats per ray. origin + direction.

func BuildSceneBufferCL

func BuildSceneBufferCL(in []shapes.Shape) ([]CLObject, []CLTriangle, []CLGroup)

func Trace

func Trace(objects []CLObject, triangles []CLTriangle, groups []CLGroup, deviceIndex, samples int, camera CLCamera, textures []image.Image, sphereTextures []image.Image, cubeTextures []image.Image) []float64

Trace is the entry point for transforming input data into their OpenCL representations, setting up boilerplate and calling the entry kernel. Should return a slice of float64 RGBA RGBA RGBA once finished.

func Trace32

func Trace32(rays []CLRay32, objects []CLObject32, width, height int) []float32

Trace32 is the entry point for transforming input data into their OpenCL representations, setting up boilerplate and calling the entry kernel. Should return a slice of float32 RGBA RGBA RGBA once finished.

Types

type CLBoundingBox

type CLBoundingBox struct {
	Min [4]float64 // 32 bytes
	Max [4]float64 // 32 bytes
}

type CLCamera

type CLCamera struct {
	Width       int32       // 4
	Height      int32       // 8
	Fov         float64     // 16
	PixelSize   float64     // 24
	HalfWidth   float64     // 32
	HalfHeight  float64     // 40
	Aperture    float64     // 48
	FocalLength float64     // 56
	Inverse     [16]float64 // 128 + 56 == 184
	Padding     [72]byte    // 256-72 == 184
}

type CLGroup

type CLGroup struct {
	BBMin           [4]float64 // 32 bytes
	BBMax           [4]float64 // 32 bytes
	Color           [4]float64 // 32 bytes
	Emission        [4]float64 // 32 bytes
	TriOffset       int32      // 4 bytes
	TriCount        int32      // 4 bytes
	ChildGroupCount int32      // 4 bytes, should always be 2 or 0
	Children        [2]int32   // 8 bytes, allow 2 subgroups.
	Padding         [108]byte  // padding, 108 bytes (can be used as a label)

}

type CLObject

type CLObject struct {
	Transform        [16]float64 // 128 bytes
	Inverse          [16]float64 // 128 bytes
	InverseTranspose [16]float64 // 128 bytes
	Color            [4]float64  // 32 bytes
	Emission         [4]float64  // 32 bytes == 448
	RefractiveIndex  float64     // 8 bytes
	Type             int64       // 8 bytes
	MinY             float64     // 8 bytes
	MaxY             float64     // 8 bytes
	Reflectivity     float64     // 8 bytes
	TextureScaleX    float64
	TextureScaleY    float64
	TextureScaleXNM  float64
	TextureScaleYNM  float64
	BBMin            [4]float64 // 32 bytes
	BBMax            [4]float64 // 32 bytes == 504 + 64 == 568
	ChildCount       int32      // 4 bytes                 572
	Children         [64]int32  // 64x4 == 256             828
	IsTextured       bool       // 1 byte
	TextureIndex     uint8      // 1 byte
	IsTexturedNM     bool       // 1 byte
	TextureIndexNM   uint8      // 1 byte
	IsEnvMap         bool       // 1 byte
	Label            [8]byte
	Padding5         [167]byte
}

type CLObject32

type CLObject32 struct {
	Transform        [16]float32 // 64 bytes 16x4
	Inverse          [16]float32 // 64 bytes
	InverseTranspose [16]float32 // 64 bytes
	Color            [4]float32  // 16 bytes
	Emission         [4]float32  // 16 bytes
	RefractiveIndex  float32     // 4 bytes
	Type             int32       // 4 bytes
	Padding          [6]int32    // 24 bytes

}

type CLRay

type CLRay struct {
	Origin    [4]float64
	Direction [4]float64
}

func BuildRayBufferCL

func BuildRayBufferCL(rays []geom.Ray) []CLRay

type CLRay32

type CLRay32 struct {
	Origin    [4]float32
	Direction [4]float32
}

func BuildRayBufferCL32

func BuildRayBufferCL32(rays []geom.Ray) []CLRay32

BuildRayBufferCL32 builds a slice of CLRay32 from the passed geom.Ray slice, i.e. using float32 instead of float64.

type CLTriangle

type CLTriangle struct {
	P1      [4]float64 // 32 bytes
	P2      [4]float64 // 32 bytes
	P3      [4]float64 // 32 bytes
	E1      [4]float64 // 32 bytes (128)
	E2      [4]float64 // 32 bytes
	N1      [4]float64 // 32 bytes
	N2      [4]float64 // 32 bytes
	N3      [4]float64 // 32 bytes (256 here)
	Color   [4]float64 // 32 bytes (288 bytes)
	Padding [224]byte
}

Jump to

Keyboard shortcuts

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