-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathctx.go
85 lines (81 loc) · 1.64 KB
/
ctx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package rendr
import "sync"
var blendmap = map[string] rndBlend {
"over": rndBlendOver,
"max": rndBlendMax,
"sum": rndBlendSum,
}
var probemap = map[string] rndProbe {
"rgbalit":rndProbeRgbaLit,
"rgba":rndProbeRgba,
"value":rndProbeValue,
}
func rndCtxNew(vol *rndVolume, kern *rndKernel,
fr, at, up, dcn,dcf,size [3]float64,
nc, fc, fov, us, s float64,
p, b string,
orth, nt int,
lit [7]float64,
lutfile string) *rndCtx{
ctx := rndCtx{
Vol: vol,
Kern: kern,
SampleOnceStop: 0,
PlaneSep: s,
Probe: probemap[p],
Blend: blendmap[b],
ThreadNum: uint(nt),
OutsideValue: 0,
Timing: 0,
Cam: rndCameraNew(),
Txf: _txf{
len: 0,
vmin: 0,
vmax: 1,
rgba: nil,
unitStep: us,
alphaNear1: 0.98,
},
Levoy: _levoy{
num: 0,
vra: nil,
},
Light: _light{
num: 1,
rgb: [3]float64{lit[0], lit[1], lit[2]},
dir: [3]float64{lit[3], lit[4], lit[5]},
vsp: int(lit[6]),
xyz: [3]float64{},
},
Lparam: _lparam{
ka: 0.2,
kd: 0.8,
ks: 0.1,
p: 150,
dcn: dcn,
dcf: dcf,
},
WtoI: [16]float64{},
MT: [9]float64{},
rWlock: sync.Mutex{},
nextTask: 0,
}
ctx.Cam.rndCameraSet(fr, at, up, nc, fc, fov, uint(size[0]), uint(size[1]), orth)
ctx.Cam.rndCameraUpdate()
ctx.Txf.loadLut(lutfile)
ctx.rndCtxLightUpdate()
ctx.WtoI, ctx.MT = rnd_m4_affine_inv(ctx.Vol.ItoW)
return &ctx
}
func rndProbeLen(probe rndProbe) uint {
l:=uint(0)
switch probe {
case rndProbeRgba:
l=4
case rndProbeRgbaLit:
l=4
default:
l=1
}
return l
}