Documentation ¶
Index ¶
- Constants
- Variables
- func CreateConfig(jsonfile string) error
- func PrintMemUsage()
- func Render(scene *Scene, left, right, top, bottom, percent int, size *string) error
- type BoundingBox
- type Camera
- type Config
- type Intersection
- type Light
- type Material
- type Matrix
- type Node
- type Object
- type Photon
- type PixelStorage
- type Scene
- type Triangle
- type Vector
Constants ¶
const DIFF = 0.000000001
DIFF floating point precision is a killing me.
const MDIFF = -0.000000001
MDIFF Imagine a CPU with no dangling float precision.
Variables ¶
var BumpMapNormals map[string][][]Vector
BumpMapNormals cache to hold bump map information in memory.
var DEFAULT = Config{ AmbientColorSharingRatio: 0.5, AmbientRadius: 2.1, AntialiasSamples: 8, CausticsSamplerLimit: 10000, EnvironmentMap: "", EdgeDetechThreshold: 0.7, Exposure: 0.2, Height: 900, LightSampleCount: 16, MaxReflectionDepth: 3, OcclusionRate: 0.2, Percentage: 100, PhotonSpacing: 0.005, RayCorrection: 0.002, RenderAmbientColors: true, RenderBumpMap: true, RenderCaustics: false, RenderColors: true, RenderLights: true, RenderOcclusion: true, RenderReflections: true, RenderRefractions: true, SamplerLimit: 16, TransparentColor: Vector{0, 0, 0, 0}, Width: 1600, }
DEFAULT configuration parameters. These are likely incorrect :D.
var EnvironmentMap [][]Vector
EnvironmentMap cache.
var GlobalConfig = Config{}
GlobalConfig is reachable from all app context I know that Globals are evil but believe me it's better to have it in global in this application.
var Images map[string][][]Vector
Images map to hold image data in memory for repeating images.
Functions ¶
func PrintMemUsage ¶
func PrintMemUsage()
Types ¶
type Camera ¶
type Camera struct { Position Vector `json:"position"` Target Vector `json:"target"` Up Vector `json:"up"` Fov float64 `json:"fov"` AspectRatio float64 `json:"aspect_ratio"` Zoom float64 `json:"zoom"` Near float64 `json:"near"` Far float64 `json:"far"` Perspective bool `json:"perspective"` Projection *Matrix `json:"projection"` // contains filtered or unexported fields }
Camera structure.
type Config ¶
type Config struct { AmbientColorSharingRatio float64 `json:"ambient_color_ratio"` AmbientRadius float64 `json:"ambient_occlusion_radius"` AntialiasSamples int `json:"antialias_samples"` CausticsSamplerLimit int `json:"caustics_samples"` EdgeDetechThreshold float64 `json:"edge_detect_threshold"` EnvironmentMap string `json:"environment_map"` Exposure float64 `json:"exposure"` Height int `json:"height"` LightSampleCount int `json:"light_sample_count"` MaxReflectionDepth int `json:"max_reflection_depth"` OcclusionRate float64 `json:"occlusion_rate"` PhotonSpacing float64 `json:"photon_spacing"` RayCorrection float64 `json:"ray_correction"` RenderAmbientColors bool `json:"render_ambient_color"` RenderBumpMap bool `json:"render_bump_map"` RenderCaustics bool `json:"render_caustics"` RenderColors bool `json:"render_colors"` RenderLights bool `json:"render_lights"` RenderOcclusion bool `json:"render_occlusion"` RenderReflections bool `json:"render_reflections"` RenderRefractions bool `json:"render_refractions"` SamplerLimit int `json:"sampler_limit"` TransparentColor Vector `json:"transparent_color"` Width int `json:"width"` Percentage int }
Config keeps Raytracer Configuration.
type Intersection ¶
type Intersection struct { Hit bool Triangle *Triangle Intersection Vector IntersectionNormal Vector RayStart Vector RayDir Vector Dist float64 Hits int }
Intersection defines the ratcast triangle intersection result.
type Light ¶
type Light struct { Position Vector `json:"position"` Color Vector `json:"color"` Active bool `json:"active"` LightStrength float64 `json:"light_strength"` Directional bool `json:"directional_light"` Direction Vector `json:"direction"` Samples []Vector }
Light structure.
type Material ¶
type Material struct { Color Vector `json:"color"` Texture string `json:"texture"` Transmission float64 `json:"transmission"` IndexOfRefraction float64 `json:"index_of_refraction"` Indices []indice `json:"indices"` Glossiness float64 `json:"glossiness"` Roughness float64 `json:"roughness"` Light bool `json:"light"` LightStrength float64 `json:"light_strength"` }
Material definition.
type Node ¶
type Node struct { Triangles []Triangle TriangleCount int BoundingBox *BoundingBox Left *Node Right *Node // contains filtered or unexported fields }
Node for KDTree.
type Object ¶
type Object struct { Vertices []Vector `json:"vertices"` Normals []Vector `json:"normals"` TexCoords []Vector `json:"texcoords"` Matrix Matrix `json:"matrix"` Materials map[string]Material `json:"materials"` Children map[string]*Object `json:"children"` Triangles []Triangle Root Node // contains filtered or unexported fields }
Object definition.
func (*Object) UnifyTriangles ¶
func (o *Object) UnifyTriangles()
UnifyTriangles of the object for faster processing.
type Photon ¶
type Photon struct { Location Vector // You can never be sure! Direction Vector Color Vector Intensity float64 }
Photon information to follow.
type PixelStorage ¶
type PixelStorage struct { WorldLocation Intersection DirectLightEnergy Vector Color Vector AmbientColor Vector Depth float64 X int Y int }
PixelStorage to Store pixel information before turning it into a png we need to do this for post-processing.
type Scene ¶
type Scene struct { Objects map[string]*Object `json:"objects"` MasterObject *Object Lights []Light `json:"lights"` Cameras []Camera `json:"observers"` Pixels [][]PixelStorage Width int Height int ShortRadius float64 InputFilename string OutputFilename string }
Scene main structure.
type Triangle ¶
type Triangle struct { P1 Vector P2 Vector P3 Vector N1 Vector N2 Vector N3 Vector T1 Vector T2 Vector T3 Vector Material Material Photons []Photon Smooth bool // contains filtered or unexported fields }
Triangle definition raycasting is already expensive and trying to calculate the triangle in each raycast makes it harder. So we are simplifying triangle definition.