- /
-
Happy Holidays!
on 1 Dec 2023
- 9
- 57
- 1
- 3
- 641
drawframe(40);
function drawframe(f)
% @"kishimisu" I don't know who you are but you are GLSL god.
% https://www.shadertoy.com/view/mllGzB
% Here is my translation to MATLAB
iRes = 800;
iTime = f/48*2;
persistent fragCoord
if isempty(fragCoord)
[x,y]=meshgrid(1:iRes, 1:iRes);
fragCoord = cat(3,x,flip(y,1));
end
im = mainImage(fragCoord);
imshow(im);
axis equal
axis off
%% magic
function finalColor = mainImage(fragCoord)
finalColor = zeros(iRes, iRes, 3);
r = cat(3,iRes,iRes);
for i = 0:149
t = iTime*0.05;
y = sin(i*0.1 + iTime*0.05);
a = 1.3*(fragCoord + fragCoord - r) / r(2);
b = [cos(i*4 + t*40)*(y*0.5 + 0.5), y] * (1 + sin(y*10)*0.2);
b = cat(3,ones(iRes(1)).*b(1),ones(iRes(1)).*b(2));
c = (y+3)*(cos(i/2 + [4,1,6]) + 1);
d = a + b;
e = abs(vecnorm(d,2,3)/0.01 + cos(t+i) - 1);
for j = 1:3
finalColor(:,:,j) = finalColor(:,:,j) + 0.05./e.*c(j);
end
end
end
end