Skip to content

Commit 9c92945

Browse files
committed
Update Hero component camera position and shader parameters for improved rendering
- Adjusted mobile camera position to enhance visual perspective. - Modified 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 a73cf0c commit 9c92945

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/components/hero/index.tsx

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

2121
const DESKTOP_CAMERA_POSITION = new Vec3(5, -5, 10);
22-
23-
const MOBILE_CAMERA_POSITION = new Vec3(2, -2, 1);
22+
const MOBILE_CAMERA_POSITION = new Vec3(7, -7, 12);
2423

2524
export const HeroASCII = () => {
2625
const containerRef = useRef<HTMLDivElement>(null);
@@ -68,7 +67,7 @@ uniform sampler2D uTexture;
6867
out vec4 fragColor;
6968
float character(int n, vec2 p) {
7069
// character grid scale
71-
float scale = uResolution.x < 768.0 ? 6.0 : 6.0;
70+
float scale = uResolution.x < 768.0 ? 5.0 : 6.0;
7271
p = floor(p * vec2(-scale, scale) + 2.5);
7372
if(clamp(p.x, 0.0, 6.0) == p.x && clamp(p.y, 0.0, 6.0) == p.y) {
7473
int a = int(round(p.x) + 5.0 * round(p.y));
@@ -79,7 +78,7 @@ float character(int n, vec2 p) {
7978
void main() {
8079
vec2 pix = gl_FragCoord.xy;
8180
// pixel size
82-
float pixelSize = uResolution.x < 768.0 ? 12.0 : 14.0;
81+
float pixelSize = uResolution.x < 768.0 ? 10.0 : 14.0;
8382
vec3 col = texture(uTexture, floor(pix / pixelSize) * pixelSize / uResolution.xy).rgb;
8483
float gray = 0.3 * col.r + 0.59 * col.g + 0.11 * col.b;
8584
int n = 2048;
@@ -91,7 +90,7 @@ void main() {
9190
if(gray > 0.7) n = 13195790;
9291
if(gray > 0.8) n = 11512810;
9392
// char size
94-
float charSize = uResolution.x < 768.0 ? 6.0 : 4.0;
93+
float charSize = 4.0;
9594
vec2 p = mod(pix / charSize, 2.0) - vec2(1.0);
9695
col = vec3(character(n, p));
9796
if (gray < 0.2) {

0 commit comments

Comments
 (0)