이미지에 더 부드러운 젤리 / 물 효과
Nov 14 2020
젤리 / 물 표면 효과를 얻으려고합니다. 좀 더 매끄럽게하고 싶습니다. 여기에서는 삼각형으로 된 직사각형을 가져와 각 프레임에 대해 약간의 무작위 노이즈로 모든 점을 섭동합니다. 이것은 다각형을 뒤 틀고 텍스처를 늘려서 난류 액체 표면처럼 보이게합니다.
img = ExampleData[{"TestImage", "House"}];
mesh = TriangulateMesh@Rectangle[{0, 0}, {1, 1}];
coords = MeshCoordinates[mesh];
cells = MeshCells[mesh, 2];
texture = Texture[img];
Table[With[{newcoords = coords + 0.01*RandomPoint[Disk[], Length[coords]]},
Rasterize[
Graphics[{texture,
GraphicsComplex[newcoords, cells,
VertexTextureCoordinates -> coords]}]]
], {30}] // ListAnimate

이것을 더 좋고 덜 불안정하게 만들려면 메쉬 좌표의 작은 무작위 교란을 축적해야한다고 생각합니다. 하지만 메시의 어떤 지점도 시간이 지남에 따라 너무 많이 드리프트하고 다각형을 변형하여 극단적 인 자기 교차로 인해 크게 왜곡되는 것을 원하지 않습니다. 내가 이것을 할 수 있고 계산 시간을 늘리지 않는 방법에 대한 아이디어가 있습니까?
답변
16 kglr Nov 15 2020 at 00:44
혹시:
timg = ImageEffect[img, {"TornFrame"}];
tr[t_] := # + {5 10^-3 Cos[20 #[[2]] + 5 t], 5 10^-3 Sin[20 #[[1]] + 5 t]} &
frames = Table[ImageTransformation[timg, tr[t]], {t, Subdivide[0, 2 Pi, 40]}];
ListAnimate @ frames

11 flinty Nov 15 2020 at 00:45
이 방법은 꽤 잘 작동하는 것 같습니다. 무작위로 위치를 변경하는 대신 각 원래 정점 위치를 중심으로하는 작은 원을 중심으로 각 정점을 회전합니다. 모든 정점은 무작위로 할당 된 단계에서 시작하므로 다각형이 모두 동기화되지 않습니다.
img = ExampleData[{"TestImage", "House"}];
mesh = TriangulateMesh[Rectangle[{0, 0}, {1, 1}],
MaxCellMeasure -> .003]
coords = MeshCoordinates[mesh];
cells = MeshCells[mesh, 2];
texture = Texture[img];
phases = RandomReal[{0, 2 Pi}, Length[coords]];
amplitude = 0.012;
frequency = 1.;
period = 1/30.;
ParallelTable[
With[{newcoords =
MapThread[#1 +
amplitude {Cos[2 Pi t frequency + #2],
Sin[2 Pi t frequency + #2]} &, {coords, phases}]},
Graphics[{texture,
GraphicsComplex[newcoords, cells,
VertexTextureCoordinates -> coords]}]
]
, {t, 0, 1, period}] // ListAnimate
