Skip to content

Commit de38957

Browse files
committed
Refine Hero component parameters for enhanced mobile rendering
- Updated mobile camera position for improved perspective. - Adjusted character grid scale and pixel size for better visual fidelity on mobile devices. - Set character size to a fixed value for consistency across screen sizes.
1 parent 9c92945 commit de38957

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/components/hero-404/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const DESKTOP_HEIGHT = 256;
1919
const MOBILE_HEIGHT = 260;
2020

2121
const DESKTOP_CAMERA_POSITION = new Vec3(8, -4, 15);
22-
const MOBILE_CAMERA_POSITION = new Vec3(2, -2, 1);
22+
const MOBILE_CAMERA_POSITION = new Vec3(14, -10, 21);
2323

2424
const MODEL_POSITION = new Vec3(0, 0, 0);
2525

@@ -69,7 +69,7 @@ uniform sampler2D uTexture;
6969
out vec4 fragColor;
7070
float character(int n, vec2 p) {
7171
// character grid scale
72-
float scale = uResolution.x < 768.0 ? 6.0 : 6.0;
72+
float scale = uResolution.x < 768.0 ? 5.0 : 6.0;
7373
p = floor(p * vec2(-scale, scale) + 2.5);
7474
if(clamp(p.x, 0.0, 6.0) == p.x && clamp(p.y, 0.0, 6.0) == p.y) {
7575
int a = int(round(p.x) + 5.0 * round(p.y));
@@ -80,7 +80,7 @@ float character(int n, vec2 p) {
8080
void main() {
8181
vec2 pix = gl_FragCoord.xy;
8282
// pixel size
83-
float pixelSize = uResolution.x < 768.0 ? 12.0 : 14.0;
83+
float pixelSize = uResolution.x < 768.0 ? 10.0 : 14.0;
8484
vec3 col = texture(uTexture, floor(pix / pixelSize) * pixelSize / uResolution.xy).rgb;
8585
float gray = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
8686
int n = 2048;
@@ -92,7 +92,7 @@ void main() {
9292
if(gray > 0.7) n = 13195790;
9393
if(gray > 0.8) n = 11512810;
9494
// char size
95-
float charSize = uResolution.x < 768.0 ? 6.0 : 4.0;
95+
float charSize = 4.0;
9696
vec2 p = mod(pix / charSize, 2.0) - vec2(1.0);
9797
col = vec3(character(n, p));
9898
if (gray < 0.2) {

0 commit comments

Comments
 (0)