- /
-
On The Run
on 21 Oct 2024
- 14
- 160
- 0
- 1
- 1038
Cite your audio source here (if applicable):
Suffering - from EPIC: The Musical by Jorge Rivera-Herrans
drawframe(1);
Write your drawframe function below
function drawframe(f)
% Wavefield generation code shamelessly reused from:
% https://ch.mathworks.com/matlabcentral/communitycontests/contests/8/entries/16195
% Inspired by: https://blogs.mathworks.com/matlab/2023/11/29/creating-natural-textures-with-power-law-noise-clouds-terrains-and-more/
rng(0,'twister')
k = 100;
m = randn(k); % k-by-k matrix
mf = fftshift(fft2(m));
% Filter1 (terrain & local storm conditions)
a = 2; % 1/fᵅ exponent - Brownian noise
d = ((1:k)-(k/2)-1).^2;
dd = sqrt(d(:) + d(:)');
filt = dd .^ -a; % frequency filter
filt(isinf(filt))=1; % replace +/-inf at DC or zero-frequency component
ff1 = mf .* filt;
% Filter2 (swell)
a = 3; % 1
filt = dd .^ -a;
filt(isinf(filt))=1;
ff2 = mf .* filt;
% Construct the wavefield (propagate waves, blend swell & local storm)
waves = rescale(circshift(circshift(ifft2(ifftshift(ff1)),-round(k*f/48/2)),round(k*f/48/2),2)+circshift(circshift(ifft2(ifftshift(ff2)),-round(k*f/48/2)),-round(k*f/48/2),2)*1.5,-.2,.2);
x = linspace(-5, 5, k);
y = linspace(-5, 5, k);
set(gca,'Position',[0 0 1 1])
cla
% Waves
surf(x,y,waves,'FaceColor','b','EdgeColor','none','FaceAlpha',0.8,'FaceLighting','gouraud')
material shiny
view(2)
axis('tight','equal','off')
% Infinity-style light pattern
x2=sin(linspace(0,2*pi,96))*max(x);
y2=[sin(linspace(-pi,pi,48)),sin(linspace(-pi,pi,48))]*max(y)*1/2;
light('style','local','Position',[x2(f) y2(f) 1])
% Eye lights
x2=sin(linspace(0,2*pi,96)-pi/4)*max(x);
light('style','local','Position',[x2(f) y2(f)+0.5 1],'color','r')
light('style','local','Position',[x2(f) y2(f)-0.5 1],'color','r')
% Additional light sources
arrayfun(@(x)light('style','local','Position',[x,10,1]),-3:3:3)
xlim(x([1,end]))
ylim(y([1,end]))
zlim([-.2 1])
end