-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Single Thread version tests successfully
- Loading branch information
1 parent
1a0b49e
commit 15361e3
Showing
19 changed files
with
566 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
.idea/ | ||
.DS_Store | ||
data/.DS_Store | ||
data/.ipynb_checkpoints/ |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
go -fr "6 12 5" -at "0 0 0" -up "0 0 1" -nc -2.3 -fc 2.3 -fov 20 -sz "320 280" -id cube.npy -im cube-meta.npy -fov 14 -us 0.03 -s 0.01 -k ctmr -p rgbalit -b over -lit "1 1 1 -1 1 2 1" -dcn "1.1 1.1 1.1" -dcf "0.4 0.4 0.4" -nt 4 -lutd cube-luta.npy -od cube-lut.npy -om cube-lut-meta.npy | ||
go -fr "6 12 5" -at "0 0 0" -up "0 0 1" -nc -2.3 -fc 2.3 -fov 20 -sz "320 280" -id cube.npy -im cube-meta.npy -fov 14 -us 0.03 -s 0.01 -k ctmr -p rgbalit -b over -lit "1 1 1 -1 1 2 1" -dcn "1.1 1.1 1.1" -dcf "0.4 0.4 0.4" -lutd cube-luta.npy -od cube-lut.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
package rendr | ||
|
||
import ( | ||
"gonum.org/v1/gonum/mat" | ||
"math" | ||
) | ||
|
||
func rndConvoNew(ctx *rndCtx) *rndConvo{ | ||
support := ctx.Kern.Support | ||
cnv := rndConvo{ | ||
Ipos: [3]float64{}, | ||
Value: 0, | ||
Gradient: [3]float64{}, | ||
Inside: 0, | ||
Kern_values: make([]float64, 3*support), | ||
Deriv_values: make([]float64, 3*support), | ||
} | ||
return &cnv | ||
} | ||
|
||
func rndConvoEval(xw, yw, zw float64, cnv *rndConvo, ctx *rndCtx) { | ||
input:= [4]float64{xw, yw, zw, 1} | ||
var output [4]float64 | ||
inVec := mat.NewVecDense(4, input[:]) | ||
outVec:= mat.NewVecDense(4, output[:]) | ||
wtoi := mat.NewDense(4,4,ctx.WtoI[:]) | ||
outVec.MulVec(wtoi, inVec) | ||
cnv.Ipos = [3]float64{output[0], output[1], output[2]} | ||
var n1,n2,n3,start,end int | ||
var alpha1, alpha2, alpha3 float64 | ||
if ctx.Kern.Support %2==0 { | ||
n1 = int(math.Floor(output[0])) | ||
n2 = int(math.Floor(output[1])) | ||
n3 = int(math.Floor(output[2])) | ||
start = 1-ctx.Kern.Support/2 | ||
end = ctx.Kern.Support/2 | ||
} else { | ||
n1 = int(math.Floor(output[0]+0.5)) | ||
n2 = int(math.Floor(output[1]+0.5)) | ||
n3 = int(math.Floor(output[2]+0.5)) | ||
start = (1-ctx.Kern.Support)/2 | ||
end = (ctx.Kern.Support-1)/2 | ||
} | ||
alpha1 = output[0]-float64(n1) | ||
alpha2 = output[1]-float64(n2) | ||
alpha3 = output[2]-float64(n3) | ||
var i,j,k int // loop variables | ||
outside:=0 | ||
if n1+start <0 || uint(n1+end) >=ctx.Vol.Size[0] { | ||
outside = outside + 1 | ||
} else if n2+start<0 || uint(n2+end) >=ctx.Vol.Size[1] { | ||
outside = outside + 1 | ||
} else if n3+start<0 || uint(n3+end) >= ctx.Vol.Size[2] { | ||
outside = outside + 1 | ||
} | ||
if outside>0 { | ||
cnv.Value = ctx.OutsideValue | ||
cnv.Gradient = [3]float64{ctx.OutsideValue, ctx.OutsideValue, ctx.OutsideValue} | ||
cnv.Inside = 0 | ||
return | ||
} | ||
cnv.Inside = 1 | ||
result:=float64(0) | ||
support:= ctx.Kern.Support | ||
k1_val := cnv.Kern_values[:support] | ||
k2_val := cnv.Kern_values[support:2*support] | ||
k3_val := cnv.Kern_values[2*support:] | ||
|
||
ctx.Kern.Apply(k1_val, alpha1) | ||
ctx.Kern.Apply(k2_val, alpha2) | ||
ctx.Kern.Apply(k3_val, alpha3) | ||
volSize := ctx.Vol.Size | ||
for i=start; i<=end; i++ { | ||
for j=start; j<=end; j++ { | ||
for k=start; k<=end; k++ { | ||
dTmp:=ctx.Vol.Data[uint(n3+i)*volSize[1]*volSize[0]+uint(n2+j)*volSize[0]+uint(n1+k)] | ||
result += dTmp*k1_val[k-start] * k2_val[j-start] * k3_val[i-start] | ||
} | ||
} | ||
} | ||
cnv.Value = result | ||
//Deriv | ||
k1_deriv:= cnv.Deriv_values[:support] | ||
k2_deriv:= cnv.Deriv_values[support:2*support] | ||
k3_deriv := cnv.Deriv_values[2*support:] | ||
ctx.Kern.Deriv.Apply(k1_deriv, alpha1) | ||
ctx.Kern.Deriv.Apply(k2_deriv, alpha2) | ||
ctx.Kern.Deriv.Apply(k3_deriv, alpha3) | ||
var tmp_gradient [3]float64 | ||
for i=start; i<=end; i++ { | ||
for j = start; j <= end; j++ { | ||
for k = start; k <= end; k++ { | ||
dTmp:=ctx.Vol.Data[uint(n3+i)*volSize[1]*volSize[0]+uint(n2+j)*volSize[0]+uint(n1+k)] | ||
tmp_gradient[0] += dTmp*k1_deriv[k-start]*k2_val[j-start]*k3_val[i-start] | ||
tmp_gradient[1] += dTmp*k1_val[k-start]*k2_deriv[j-start]*k3_val[i-start] | ||
tmp_gradient[2] += dTmp*k1_val[k-start]*k2_val[j-start]*k3_deriv[i-start] | ||
} | ||
} | ||
} | ||
// Conver from index space to world space | ||
tgradVec := mat.NewVecDense(3, tmp_gradient[:]) | ||
gradVec := mat.NewVecDense(3, cnv.Gradient[:]) | ||
mt := mat.NewDense(3, 3, ctx.MT[:]) | ||
gradVec.MulVec(mt, tgradVec) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package rendr | ||
|
||
import "fmt" | ||
|
||
func rndRender(img *rndImage, ctx *rndCtx, _dhi, _dvi int) { | ||
plen:= rndProbeLen(ctx.Probe) | ||
//timing := uint(ctx.Timing) | ||
img.rndImageAlloc(plen, ctx.Cam.Size[0], ctx.Cam.Size[1], rndTypefloat64) | ||
cnv := rndConvoNew(ctx) | ||
if ctx.ThreadNum==0 { | ||
ray := rndNewRay() | ||
index:= uint(0) | ||
odata:=img.Data | ||
//nipx := ctx.Cam.Size[0] * ctx.Cam.Size[1] | ||
//fmt.Fprintf(os.Stderr, "Rendering") | ||
for jj:= uint(0); jj<ctx.Cam.Size[1]; jj++ { | ||
for ii:=uint(0); ii<ctx.Cam.Size[0]; ii++ { | ||
rndRayGo(odata[index:index+plen], ii, jj, ray, cnv, ctx) | ||
index = index+plen | ||
} | ||
} | ||
} else { | ||
fmt.Println("Multithreading version of Gorendr") | ||
} | ||
} |
Oops, something went wrong.