I am interested in incorporating normal maps into the background images on my website. After exploring various implementations, I find that this example on CodePen utilizing three.js stands out as the best option. Despite being new to three.js, I am eager to learn and experiment.
The specific features I hope to achieve are:
① I would prefer the light source to remain static rather than follow the cursor's movement.
This preference stems from the fact that mouse-based interactions do not translate well to mobile devices. Additionally, effects tied to cursor movements can often be distracting. Instead, positioning the light source at a fixed location (such as the center of the page) and allowing it to interact with the background as users scroll seems like a more effective approach.
② I wish to confine the background image within a smaller div container, even when it does not need to span the entire page.
While this may seem straightforward, the current implementation appears to target either the body
element or the entire window
. Further investigation is needed...
③ I aim to be able to incorporate multiple normal map-enabled background images that share consistent lighting for scene coherence.
If the position of the light remains relative to the window dimensions, achieving this might not be overly complex.
④ It would be beneficial to have control over whether the image textures are tiled.
In traditional web development, this task is accomplished through the background-repeat
CSS property. However, the process could differ in three.js. This aspect requires further exploration...
Note: The following points 5 and 6 are optional, but I will outline them in case there are insights on their implementation.
⑤ Implementing the capability to illuminate the "scene" (comprising all normal map-enabled background images on the page) using an image instead of point lights, known as HDR image-based lighting. To prevent page bloat, low-resolution images must be utilized, yet the improvement in aesthetics could be substantial compared to point lights. Initial findings suggest that IBL support exists in three.js, though ongoing research is necessary.
⑥ While challenging to implement, introducing a subtle tilt in the background image or light source position responsive to motions detected by a mobile device accelerometer would be intriguing. However, given limitations in accessing accelerometer data by default on iOS as highlighted here, this idea may remain unfeasible. As an alternative, incorporating parallax motion linked to scrolling behavior could provide a comparable enhancement.