Limit number of distortions to 10

This commit is contained in:
2025-11-18 23:10:36 +00:00
parent b633b9d55f
commit 8759431fec
4 changed files with 23 additions and 12 deletions
+15 -8
View File
@@ -1,10 +1,11 @@
#version 450 core #version 450 core
in vec2 texPos; in vec2 texPos;
in vec2 distmask[2]; in vec2 distmask[10];
in vec2 pinch[2]; in vec2 pinch[10];
out vec4 fColor; out vec4 fColor;
layout (binding = 1) uniform sampler2D screenTexture; layout (binding = 1) uniform sampler2D screenTexture;
float x = 1 - min(1, sqrt(distance(distmask[0],vec2(0,0)))); layout (location = 0) uniform int n;
//float x = 1 - min(1, sqrt(distance(distmask[0],vec2(0,0))));
//float x = 1 - min(1, dot(distmask,distmask)); //float x = 1 - min(1, dot(distmask,distmask));
vec3 toYUV (vec3 rgb) vec3 toYUV (vec3 rgb)
{ return rgb * mat3 { return rgb * mat3
@@ -22,11 +23,17 @@ vec3 toRGB (vec3 yuv)
} }
void main() void main()
{ {
float y = 1 - min(1, sqrt(distance(distmask[1],vec2(0,0)))); vec2 tpos = texPos;
fColor = texture(screenTexture for(int i = 0; i < n; ++i)
, (texPos + x * pinch[0] {
+ y * pinch[1] float x = 1 - min(1, sqrt(distance(distmask[i],vec2(0,0))));
)); tpos += x * pinch[i];
}
fColor = texture(screenTexture, tpos);
//fColor = texture(screenTexture
// , (texPos + x * pinch[0]
// + y * pinch[1]
// ));
} }
// fColor = vec4 // fColor = vec4
// ( toRGB(vec3( toYUV(texture(screenTexture, texPos).rgb).r // ( toRGB(vec3( toYUV(texture(screenTexture, texPos).rgb).r
+4 -3
View File
@@ -2,9 +2,10 @@
struct DataS { vec2 pos; vec2 v1; vec2 v2; vec2 t1; vec2 t2; vec2 t3; }; struct DataS { vec2 pos; vec2 v1; vec2 v2; vec2 t1; vec2 t2; vec2 t3; };
layout (std430, binding = 9) readonly buffer Data { DataS data[]; }; layout (std430, binding = 9) readonly buffer Data { DataS data[]; };
layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ; layout (std140, binding = 0) uniform TheMat { mat4 theMat; } ;
layout (location = 0) uniform int n;
out vec2 texPos; out vec2 texPos;
out vec2 distmask[2]; out vec2 distmask[10];
out vec2 pinch[2]; out vec2 pinch[10];
const int ks[6] = const int ks[6] =
{0,1,2 // 2--3 {0,1,2 // 2--3
,2,1,3 // | | ,2,1,3 // | |
@@ -31,7 +32,7 @@ mat4 toTransMat (vec2 p)
void main() void main()
{ {
int k = ks[gl_VertexID]; int k = ks[gl_VertexID];
for(int i = 0; i < 2; ++i) for(int i = 0; i < n; ++i)
{ {
vec4 off = theMat * vec4(data[i + gl_VertexID/6].pos, 0,1); vec4 off = theMat * vec4(data[i + gl_VertexID/6].pos, 0,1);
DataS thedata = data[i + gl_VertexID/6]; DataS thedata = data[i + gl_VertexID/6];
+1
View File
@@ -22,4 +22,5 @@ testEvent w = fromMaybe w $ do
20 20
return $ w & cWorld . lWorld . distortions .~ [distortionBulge return $ w & cWorld . lWorld . distortions .~ [distortionBulge
, distortionBulge & rdPos +~ 50 , distortionBulge & rdPos +~ 50
, distortionBulge & rdPos +~ (-50)
] ]
+3 -1
View File
@@ -367,13 +367,15 @@ doDrawing' win pdata u = do
glUseProgram (pdata ^. fullscreenShader) glUseProgram (pdata ^. fullscreenShader)
glDrawArrays GL_TRIANGLES 0 6 glDrawArrays GL_TRIANGLES 0 6
--(RadialDistortion (V2 a b) (V2 c d) (V2 e f) (V2 g h) _:_) -> do --(RadialDistortion (V2 a b) (V2 c d) (V2 e f) (V2 g h) _:_) -> do
rs -> do rs' -> do
let rs = take 10 rs'
glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO) glBindFramebuffer GL_FRAMEBUFFER (pdata ^. fbo2 . _1 . unFBO)
withArray (concatMap rdToVec2s rs) $ withArray (concatMap rdToVec2s rs) $
glNamedBufferSubData (pdata ^. barrelShader . _2 . vboName) 0 glNamedBufferSubData (pdata ^. barrelShader . _2 . vboName) 0
(12 * fromIntegral (length rs * sizeOf (0 :: Float))) (12 * fromIntegral (length rs * sizeOf (0 :: Float)))
glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO glBindTextureUnit 1 $ pdata ^. fboBase . _2 . _1 . unTO
glUseProgram (pdata ^. barrelShader . _1) glUseProgram (pdata ^. barrelShader . _1)
glUniform1i 0 (fromIntegral (length rs))
glDrawArrays GL_TRIANGLES 0 6 glDrawArrays GL_TRIANGLES 0 6
glBindTextureUnit 0 $ pdata ^. fbo2 . _2 . unTO glBindTextureUnit 0 $ pdata ^. fbo2 . _2 . unTO
glBindFramebuffer GL_FRAMEBUFFER 0 glBindFramebuffer GL_FRAMEBUFFER 0