mirror of
https://github.com/stevenrobertson/cuburn.git
synced 2025-02-05 11:40:04 -05:00
Motion blur (a bit)
This commit is contained in:
parent
a7900f187d
commit
a43973f0ff
@ -2,13 +2,17 @@
|
|||||||
The main iteration loop.
|
The main iteration loop.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from ctypes import byref
|
||||||
|
|
||||||
import pycuda.driver as cuda
|
import pycuda.driver as cuda
|
||||||
from pycuda.driver import In, Out, InOut
|
from pycuda.driver import In, Out, InOut
|
||||||
from pycuda.compiler import SourceModule
|
from pycuda.compiler import SourceModule
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
|
from fr0stlib.pyflam3 import flam3_interpolate
|
||||||
from cuburn.code import mwc, variations
|
from cuburn.code import mwc, variations
|
||||||
from cuburn.code.util import *
|
from cuburn.code.util import *
|
||||||
|
from cuburn.render import Genome
|
||||||
|
|
||||||
import tempita
|
import tempita
|
||||||
|
|
||||||
@ -117,22 +121,32 @@ void iter(mwc_st *msts, const iter_info *infos, float *accbuf, float *denbuf) {
|
|||||||
packer = self.packer.view('info'))
|
packer = self.packer.view('info'))
|
||||||
|
|
||||||
|
|
||||||
def silly(features, cp):
|
def silly(features, cps):
|
||||||
|
nsteps = 1000
|
||||||
abuf = np.zeros((512, 512, 4), dtype=np.float32)
|
abuf = np.zeros((512, 512, 4), dtype=np.float32)
|
||||||
dbuf = np.zeros((512, 512), dtype=np.float32)
|
dbuf = np.zeros((512, 512), dtype=np.float32)
|
||||||
seeds = mwc.MWC.make_seeds(512 * 24)
|
seeds = mwc.MWC.make_seeds(512 * nsteps)
|
||||||
|
|
||||||
iter = IterCode(features)
|
iter = IterCode(features)
|
||||||
code = assemble_code(BaseCode, mwc.MWC, iter, iter.packer)
|
code = assemble_code(BaseCode, mwc.MWC, iter, iter.packer)
|
||||||
print code
|
print code
|
||||||
mod = SourceModule(code, options=['-use_fast_math'], keep=True)
|
mod = SourceModule(code, options=['-use_fast_math'], keep=True)
|
||||||
|
|
||||||
info = iter.packer.pack(cp=cp)
|
cps_as_array = (Genome * len(cps))()
|
||||||
print info
|
for i, cp in enumerate(cps):
|
||||||
|
cps_as_array[i] = cp
|
||||||
|
|
||||||
|
cp = Genome()
|
||||||
|
infos = []
|
||||||
|
for n in range(nsteps):
|
||||||
|
flam3_interpolate(cps_as_array, 2, (n - nsteps/2) * 0.001, 0, byref(cp))
|
||||||
|
cp._init()
|
||||||
|
infos.append(iter.packer.pack(cp=cp))
|
||||||
|
infos = np.concatenate(infos)
|
||||||
|
|
||||||
fun = mod.get_function("iter")
|
fun = mod.get_function("iter")
|
||||||
fun(InOut(seeds), In(info), InOut(abuf), InOut(dbuf),
|
fun(InOut(seeds), In(infos), InOut(abuf), InOut(dbuf),
|
||||||
block=(512,1,1), grid=(1,1), time_kernel=True)
|
block=(512,1,1), grid=(nsteps,1), time_kernel=True)
|
||||||
|
|
||||||
return abuf, dbuf
|
return abuf, dbuf
|
||||||
|
|
||||||
|
2
main.py
2
main.py
@ -32,7 +32,7 @@ def main(args):
|
|||||||
with open(args[-1]) as fp:
|
with open(args[-1]) as fp:
|
||||||
genomes = Genome.from_string(fp.read())
|
genomes = Genome.from_string(fp.read())
|
||||||
anim = Animation(genomes)
|
anim = Animation(genomes)
|
||||||
accum, den = silly(anim.features, genomes[0])
|
accum, den = silly(anim.features, genomes)
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
bins = anim.render_frame()
|
bins = anim.render_frame()
|
||||||
|
Loading…
Reference in New Issue
Block a user