[jitter] big thanks
Wesley Smith
wesley.hoke at gmail.com
Sat Sep 15 15:26:01 MDT 2007
- Previous message: [jitter] big thanks
- Next message: [jitter] big thanks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Here's the main loop from xray.jit.water. prev is the previous matrix
in time. Essentially there's a spatial weighting of the neighboring 8
cells and a temporal weighting with the previous value in the location
being calculated. It should be straightforward to implement as a
shader which would be a cross of convolve and slide since it needs
temporal feedback and spatial weighting.
width = prev_minfo->dim[0];
height = prev_minfo->dim[1];
incolspan = in1_minfo->dimstride[0];
inrowspan = in1_minfo->dimstride[1];
outcolspan = out_minfo->dimstride[0];
outrowspan = out_minfo->dimstride[1];
prevcolspan = prev_minfo->dimstride[0];
prevrowspan = prev_minfo->dimstride[1];
if (in1_minfo->type==_jit_sym_float32) {
timestep = x->timestep;
damping = x->damping;
timeSpaceFactor = (timestep*timestep)/(x->spacestep*x->spacestep);
dampFactor = 1 - damping*timestep;
for(i=1; i < height-1; i++) {
fip1_up = (float *)(bip1 + (i-1)*inrowspan);
fip1 = (float *)(bip1 + i*inrowspan);
fip1_down = (float *)(bip1 + (i+1)*inrowspan);
fip2 = (float *)(bip2 + i*inrowspan);
prev_fp = (float *)(prev_bp + i*prevrowspan);
fop = (float *)(bop + i*outrowspan);
for(j=1; j < width-1; j++) {
fop[j] = fip1[j] + dampFactor*(fip1[j] - prev_fp[j] )
- timeSpaceFactor*fip2[j]*(4*fip1[j] - fip1[j-1] - fip1[j+1] -
fip1_up[j] - fip1_down[j]
+ 0.5*(4*fip1[j] - fip1_up[j-1] - fip1_up[j+1] - fip1_down[j-1]
- fip1_down[j+1] ));
CLIP(fop[j], -1, 1);
}
}
}
- Previous message: [jitter] big thanks
- Next message: [jitter] big thanks
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
