responsive-image-canvas/dist/debug.frag.glsl
BaekRyang e371321fd2 feat: Fix image distortion shader and improve loading state
- Fix distortion.frag.glsl to match Flutter original implementation
  - Update computeUV function with single Newton-Raphson iteration
  - Fix coordinate transformation (normalized to pixel)
  - Fix distortion application logic
  - Add break after first matching area (Flutter behavior)

- Add image loading state management
  - Add imageLoaded state
  - Add loading progress callback
  - Add loading UI indicator
  - Improve error handling

- Add comprehensive debug logging
  - ShaderManager: fetch status and shader lengths
  - ThreeScene: shader compilation check, render calls
  - ImageDistortion: lifecycle and loading status

- Add test/debug shaders for troubleshooting
  - test.frag.glsl: Simple pass-through shader
  - debug.frag.glsl: Area visualization shader

- Fix infinite loop bug in animationCallback
  - Use setState updater function to avoid dependency

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-04 11:51:39 +09:00

39 lines
1.1 KiB
GLSL

uniform vec2 u_resolution;
uniform sampler2D u_texture;
uniform vec2 u_points[32];
uniform int u_numAreas;
uniform vec2 u_dragVectors[8];
uniform float u_distortionStrengths[8];
varying vec2 vUv;
void main() {
vec2 texCoord = vUv;
// 디버그: 영역 표시
for (int i = 0; i < 8; i++) {
if (i >= u_numAreas) break;
// 포인트를 픽셀 좌표로 변환
vec2 p0 = u_points[i * 4 + 0] * u_resolution;
vec2 p1 = u_points[i * 4 + 1] * u_resolution;
vec2 p2 = u_points[i * 4 + 2] * u_resolution;
vec2 p3 = u_points[i * 4 + 3] * u_resolution;
vec2 pixelCoord = vUv * u_resolution;
// 경계 상자 체크만
vec2 minP = min(min(p0, p1), min(p2, p3));
vec2 maxP = max(max(p0, p1), max(p2, p3));
// 영역 안에 있으면 빨간색으로 표시
if (pixelCoord.x >= minP.x && pixelCoord.x <= maxP.x &&
pixelCoord.y >= minP.y && pixelCoord.y <= maxP.y) {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); // 빨간색
return;
}
}
// 영역 밖은 원본 이미지
gl_FragColor = texture2D(u_texture, texCoord);
}