Load Texture without compression at start

Hello,

I’m working on a scene with text and icons embeded into textures, and I need to load the in full resolution at the loading of the page.

I’ve tried to load without mipmap after a delay and it was starting to work, but the progressive loading seems to be a priority.
My goal is to target some gameobjects containing textures to display their best resolution available.

Here is the script I’m using:

import { Behaviour, GameObject, MeshRenderer } from "@needle-tools/engine";
import { serializable } from "@needle-tools/engine";
import { MeshStandardMaterial, LinearFilter } from "three";

export class TextureQualityEnforcer extends Behaviour {

  @serializable(GameObject)
  public targetObjects: GameObject[] = [];

  // Un champ pour rƩgler le dƩlai en secondes depuis l'inspecteur
  @serializable()
  public applyDelay: number = 1;

  // On transforme "start" en fonction asynchrone pour utiliser "await"
  async start() {
    // On attend le dƩlai spƩcifiƩ avant d'exƩcuter le reste du code
    await this.delay(this.applyDelay * 1000);

    for (const target of this.targetObjects) {
      if (!target) continue;

      const renderer = target.getComponent(MeshRenderer);
      if (!renderer) continue;

      const material = renderer.sharedMaterial as MeshStandardMaterial;
      if (!material || !material.map) continue;

      const texture = material.map;
      console.log(`Application des réglages HQ sur ${target.name} après ${this.applyDelay}s.`);

      // On dit au moteur de ne pas gƩnƩrer/utiliser de mipmaps
      texture.generateMipmaps = false;

      // On applique les autres rƩglages de qualitƩ
      texture.minFilter = LinearFilter;
      texture.magFilter = LinearFilter;
      const maxAniso = this.context.renderer.capabilities.getMaxAnisotropy();
      texture.anisotropy = maxAniso;

      // On signale au moteur que la texture doit ĆŖtre mise Ć  jour
      texture.needsUpdate = true;
    }
  }

  private delay(ms: number): Promise<void> {
    if (ms <= 0) return Promise.resolve();
    return new Promise(resolve => setTimeout(resolve, ms));
  }
}

Do you have another component that do the same action in Needle (4.7.4)?
Is there a fix into the code that can help to make it with your rendering process?

Cheers,
Corentin

Hi Corentin

In Unity find the compression options component (it’s on the same GameObject as your Needle Engine component) and add the specific textures to the list of textures to be excluded from generating LOD textures.

1 Like

I’ll test it on my next session.

Thanks!

Hello Corentin, here are some screenshots of the settings I was referring to

1 Like

Hello Marcel,

I did some tests and it doesn’t seem to work on my scene

The settings:

The result on smartphone web browser

Can you share a link to the website (maybe via PM). It looks like this could also be caused by ETC1S compression. Can you try overriding the texture format and set it to e.g. WebP?

If it doesnt help please send a bugreport via Needle Engine/Report a bug so we can look into it. Disabling texture LODs did work in my test just now so it’d be great to see what’s different for you

1 Like

This topic was automatically closed 13 days after the last reply. New replies are no longer allowed.