We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Dynamic Texture Loading Based on Device Memory

Home Forums General Questions Dynamic Texture Loading Based on Device Memory

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #83499
    Nathan Arditti
    Customer

    Hello everyone,

    I’m trying to optimize my Verge3D application by dynamically loading different texture resolutions based on the user’s device memory. The goal is to improve performance on low-end devices while providing a high-quality experience on more powerful machines.

    My approach is to:
    1. Use a run script puzzle to get the value of navigator.deviceMemory.
    2. Store this value in a variable using the set puzzle.
    3. Use an if/else puzzle to check if the value is greater than or equal to a specific threshold (e.g., 4 GB).
    4. Load the appropriate texture resolution (e.g., 4K or 2K) based on the condition.

    I’ve tried using the following JavaScript code in the run script puzzle: return navigator.deviceMemory; and then assigning its output to a variable with the set puzzle. However, I am consistently running into the following error:

    TypeError: Cannot set properties of undefined (setting 'deviceMemory')

    It seems there might be a problem with how the run script puzzle interacts with puzzle variables, or an issue with the timing of the variable creation.

    What is the correct way to implement this logic? I would appreciate any guidance on how to get the deviceMemory value via a script and use it reliably within the puzzle system.

    Thank you !

    #83501
    qiangge
    Participant

    @Nathan, Here is a simple implementation for your reference: it initially uses 1K textures, and then replaces them with higher-resolution textures based on the device conditions.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.