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.

Strategy for shaders

Home Forums General Questions Strategy for shaders

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #72045
    tomtm
    Participant

    Hi
    I have a more complex scene with a lot of materials and geoparts.
    Some material palettes are hidden first with the hide function and can be shown by clicking a button.
    This brings my animations to stuck for a while, because I guess the shaders will be compiled in real time. (VR application)
    Is it possible to pre-compile this shaders before the app starts to run?
    In the Init section?

    Thanks Tom

    #72046
    xeon
    Customer

    You may want to assign the materials you want in a preloaded state to be not hidden. They can be assigned to triangle out of camera view. This way the material is loaded into memory before you need it l

    Xeon
    Route 66 Digital
    Interactive Solutions - https://www.r66d.com
    Tutorials - https://www.xeons3dlab.com

    #72048
    kdv
    Participant

    because I guess the shaders will be compiled in real time.

    All shaders are already pre-compiled before rendering. You can see it if you press F12 and then press P quickly three times. All active materials will be listed. Most likely in your case the problem is in geometry bufferes and maybe in textures used in those hidden materials. Try this code to initialize all geometry buffers in the scene.

    To initialize textures you can use this code:

    app.scene.traverse(function(obj) {
      if (obj.isMesh) {
        if (obj.material.isMeshNodeMaterial) {
          for (let name in obj.material.nodeTextures) {
            app.renderer.initTexture(obj.material.nodeTextures[name]);
          }
        }
        app.renderer.updateGeometry(obj);
      }
    });

    Puzzles and JS. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of meaning at all.

    #72058
    tomtm
    Participant

    Thank you guys for the tricks and codes, I will try it and let you know if it worked in my case.

    Thanks Tom

    #72173
    tomtm
    Participant

    Hi,
    I checked several ways to get rid of the frame drops caused by compiling shaders.
    I have a project, which should work in desktop and in VR.

    My best results are: If I make something like an Intro (Poly-Plane with a logo ).
    Behind this plane I move all objects (so that their in the camera field) and unhide all hidden geos and groups , and after this set it to their starting state and position und hide the plane.

    Or is there another approach? Because it’s a feature just to compile what’s in camera view.

    I also tried the code discussed here:

    Frame rate drops when show-ing objects for the first time

    But it doesn’t worked. Maybe I placed the code in the wrong place.
    Or can I use this code with the Execute-Script Puzzle?
    If my Scene is called CarConfigurator would it be

    function runCode(app) {
    app.renderer.compile(app.CarConfigurator, app.camera);
    }

    Thanks Tom

    #72176
    kdv
    Participant

    create simplified app with the same problem and share it here.

    Puzzles and JS. Fast and expensive.

    If you don’t see the meaning in something it primarily means that you just don’t see it but not the absence of meaning at all.

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