Giter VIP home page Giter VIP logo

Comments (15)

sunag avatar sunag commented on June 1, 2024 3

@sunag Any way to reopen this issue?

Yes, I think it's worth analyzing all these points first.

from three.js.

sunag avatar sunag commented on June 1, 2024 2

Please test using the JavaScript, it will better represent the result.

Just remove any call to render(), and add just one call to measure the rendering time, consider that during this time the compilation of the shader will not be the only thing to be executed, but the creation of textures, geometry, etc… Even so, the result is very different from what is presented above.

const now = performance.now();

renderer.render( scene, camera );

console.log( performance.now() - now );

This cost me around ~0.15 milliseconds in my M1 computer, much lower than 16.66 (1000/60) which represent 60 FPS.

The second frame now - performance.now() returned 0 because the value was too small, since everything was initialized.

from three.js.

alienself avatar alienself commented on June 1, 2024 1

On my side, the screen stays black for about 2 seconds before displaying the first frame which is not the case when using webgl or even babylon webgpu. I have a solid pc with a nvidia 3090 and the I am having the exact same issue on my macbook (actually worse..).

The performance issue is happening inside the WGSLNodeBuilder when the materials are being created. I do not believe that this is related to webgpu api as I do not have such issue with babylon nor emscripten.

As for the benchmark, the load is spread out across multiple frames so it's easier to visualize in the profiler, here is a zoomed out version of the profiler on one of the material during startup (when the page is loaded or material created for the first time):

Screenshot 2023-09-21 201738

As you can see most of the compute is going toward this traverse method in the core/Node.js

	traverse( callback, replaceNode = null ) {

		callback( this, replaceNode );

		for ( const { childNode, replaceNode } of this.getChildren() ) {

			childNode.traverse( callback, replaceNode );

		}

	}

As for JS benchmark in the console sure:

4.399999976158142
0.4000000059604645
0.5999999940395355
0.5
0.4000000059604645
0.5999999940395355
0.5
0.4000000059604645
0.5
0.800000011920929
0.5
0.5999999940395355
0.5
0.6000000238418579
0.5999999940395355
0.5
0.5999999940395355
0.5
0.5999999940395355
0.5
0.7000000178813934
0.5999999940395355
0.5

from three.js.

sunag avatar sunag commented on June 1, 2024 1

If we can replace these VarNode.assign with stack.assign is better, it follows flow, and there is no need to traverse.

from three.js.

mrdoob avatar mrdoob commented on June 1, 2024

Maybe the shader compiler on Windows is super slow compared to the one in MacOS?

from three.js.

sunag avatar sunag commented on June 1, 2024

I had ~0.6 on my laptop with Windows and Ryzen 7 processor, less than 1 ms to render/compile the first frame.

from three.js.

sunag avatar sunag commented on June 1, 2024

In any case, there is a strange behavior, as the frame is taking a long time to appear. I will analyze this more carefully.

from three.js.

alienself avatar alienself commented on June 1, 2024

@sunag Any way to reopen this issue?

from three.js.

sunag avatar sunag commented on June 1, 2024

/ping @LeviPesin about Node.traverse()

from three.js.

LeviPesin avatar LeviPesin commented on June 1, 2024

What is suspicious is that these slow traverses all happen in VarNode.assign(). I think what we should do is fix it so that it works in runtime instead of compile-time (as I suggested in #26795 (comment), for a completely different reason). We can also remove replaceNode then.

I can file a PR for that.

The exact reason for the slowness is maybe that these VarNodes have a tremendous amount of subnodes -- and VarNode.assign() must (in the current implementation) check them all.

from three.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.