Putting a photo on the Sea Link in WebGL
How a browser photo becomes a simulated bridge light display: editable drafts, WebGL textures, water reflections, PNG capture and CDN assets.

Putting a photo on a 3D bridge involves more than drawing it over the view. The image needs to follow the cable fans, sit behind objects that obscure it, and appear in the water. The editor also needs to let you try a crop without changing the display you have already applied.
The Sea Link project handles those jobs in a custom WebGL 2 renderer, written in vanilla JavaScript. GLSL shaders draw the scene, water and photo lights. A GLB supplies the bridge and surrounding geometry.
Keep the draft separate from the scene
Choosing a personal photo creates a working image in a browser canvas. The studio accepts JPEG, PNG and WebP, decodes the file locally, and limits the working copy’s long edge to 2,048 pixels. Moving or scaling the image changes a 2,048 × 512 texture atlas: a canvas arranging the artwork for the two cable fans.
The file pipeline rejects unsupported formats and files larger than 20 MiB. It checks decoded images for a minimum size of 8 × 8 pixels and a maximum of 40 million pixels. That second check happens after decoding, so it does not prevent the temporary memory cost of a large image. Failed loads leave the applied display intact, and a load token prevents an older decode from replacing a newer choice.
That atlas feeds the small preview. Pressing Render on bridge uploads it as a WebGL texture and copies the applied source image and settings into separate state. Later edits can change the draft while the bridge keeps displaying the last confirmed version. Clearing the lights leaves the draft available.
This separation also matters during graphics recovery. If the browser loses its WebGL context, the renderer rebuilds the applied image from its saved source and settings. It doesn’t accidentally publish a newer crop still waiting in the editor.
The featured display follows a different path. First opening the studio automatically applies the DevFest Ranchi collage on the left fan and a separately drawn website graphic on the right. Restore Ali’s display also applies it immediately. Personal uploads require Render on bridge; reopening the editor preserves the draft, and clearing the lights does not reload the default.

The studio beside the rendered scene, with a front-elevation preview of the applied display.
Map the image to the cable fans
The photo display adds four tessellated surfaces along the outer cable-fan envelopes around the main Bandra pylon: a left and right fan on each exterior side. Together they contain 8,192 triangles. Their vertices follow the model’s anchor heights, spread and sag. Texture coordinates map the prepared image onto those surfaces.
A GLSL fragment shader samples the image and combines its transparency with a dense ribbon pattern. A second draw adds a soft glow using additive blending. Depth testing lets scene geometry obscure the display where appropriate. The renderer chooses the exterior surface facing the camera and reverses the horizontal texture coordinate on the opposite side, keeping lettering readable from either exterior.
The editor previews the same atlas and fan outline in front elevation. It helps judge framing and clipping; the full scene adds perspective, lighting and occlusion.
Render the reflection from another camera
Before drawing the main view, the renderer mirrors the camera and its target across the water plane. It draws the scene, including the applied photo lights, into an offscreen framebuffer.
The water shader samples that reflection texture, distorts its coordinates with surface motion, and blends it with the water colour and highlights. Changing the artwork or camera therefore changes the reflected scene. The main pass draws opaque objects, water, transparent objects and the photo display in that order.

A night render of the simulated display and its water reflection. This is a scene capture, not a photograph of an installation.
Capture a fresh frame
Take photo and the studio’s Save image use the same capture function. It temporarily removes the editor’s projection offset, renders the current scene, and copies the WebGL canvas into a separate 2D canvas. It then restores the onscreen framing.
The export canvas receives a small iali.dev watermark at 35% opacity before being encoded as a PNG. The watermark changes only the downloaded pixels. The live scene, source photo and preview stay untouched. Capturing a fresh frame also lets the renderer run with preserveDrawingBuffer disabled. The public app offers PNG downloads; the former model and HTML export controls have been removed.
Give rendering a lifecycle
The scene opens with compact View, Light and More controls. Opening the studio closes the expanded exploration controls and initialises its graphics. This defers editor setup; its code is already in the viewer download.
The desktop editor sits beside the scene, while narrow portrait screens use a bottom sheet. The renderer measures the editor’s bounds and shifts its projection so the bridge stays in the available space. After a visitor applies a photo on mobile, the sheet collapses to reveal the result. The automatic featured display leaves the editor open.
The renderer limits the drawing buffer to roughly 2.4 million pixels, with device-pixel-ratio caps of 1.5 for ordinary pointers and 1.25 for coarse pointers. The editor reuses its atlas and preview canvases; brightness and cable-detail changes do not rebuild the atlas pixels.
Rendering pauses when the page is hidden and resets its frame timing on return. Reduced-motion settings pause the ride initially and freeze ambient water motion, while controls can still request a new frame. These limits bound work; they are not a measured frame-rate guarantee.
Fetch the scene; keep personal photos local
The hosted build serves content-hashed JavaScript, CSS and model data from https://cdn.alimustufa.com/_astro/sealink/. The default DevFest Ranchi collage reuses its existing CDN gallery URL and is fetched only when the studio opens. Its original 275,582-byte WebP is preserved, with whole-photo framing that keeps all three collage sections visible.
The model is 9,360,398 bytes of gzip data carried in a .bin asset. The loader checks its byte length and verifies SHA-256 when Web Crypto is available, then uses DecompressionStream to unpack the 38,061,732-byte GLB. Failed or incomplete requests produce a loading error. The asset is served without a gzip Content-Encoding header because the application handles decompression itself.
Keeping the model separate from the page allows independent caching; it does not reduce geometry or decoded memory. These are asset-file sizes, not loading-time measurements. Application downloads are separate from personal-photo processing, which stays in the browser without uploading the chosen file.
Drafts last for the session. Save a PNG to retain the rendered view. The bridge, skyline, bus route and light display are artistic interpretations, not surveyed engineering data or a physical installation plan. The model license permits personal, non-commercial scene captures; commercial use requires written permission.
