TGViewer
Прогаем с кенгурой Прогаем с кенгурой @coding_with_kangaroo · 236 subscribers
Post #243 157
Алгоритм

Cчитаем параметры пространства, и когда считаем точки для свертки - применяем его


struct AstigCtx {
float2 e_r;
float2 e_t;
float s_r;
float s_t;
};

struct Parameters {
float2 invSize;
float2 opticalCenter;
float astigK;
};

inline AstigCtx astigSetup(float2 uv, Parameters params) {
AstigCtx C;
float ar = params.invSize.y / params.invSize.x;
float2 df = uv - params.opticalCenter;
float2 dfIso= float2(df.x * ar, df.y);
float rhoN = clamp(length(dfIso) * 2.0f, 0.0f, 1.0f);

float2 rIso = (length(dfIso) > 1e-6f) ? normalize(dfIso) : float2(1.0f, 0.0f);
C.e_r = normalize(float2(rIso.x / ar, rIso.y));
C.e_t = float2(-C.e_r.y, C.e_r.x);

float mag = fabs(params.astigK) * (rhoN * rhoN);
float a = 1.0f + mag;
C.s_r = (params.astigK >= 0.0f) ? (1.0f / a) : a;
C.s_t = (params.astigK >= 0.0f) ? a : (1.0f / a);
return C;
}

inline float2 astigApply(float2 d, AstigCtx C) {
float dr = dot(d, C.e_r);
float dt = dot(d, C.e_t);
return dr * C.s_r * C.e_r + dt * C.s_t * C.e_t;
}
  • ❤ 3
  • 👏 1
More from @coding_with_kangaroo
  1. Oct 7, 2026Пополнение библиотеки. Буду расширять область, а то все картинки да картинки
  2. Oct 7, 2026Post #823
  3. Oct 7, 2026А вот еще вспомнил про pixator и решил затащить поддержку видео
  4. Oct 6, 2026Еще вот так умеет
  5. Oct 6, 2026Оно даже работает
  6. Oct 6, 2026Спагетти-архитектура Я знаю, что можно красиво и аккуратно, но ножек в наличии нет, а с ал…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →