Help with scene rendering

I am not rendering using engine.runrenderloop() method. Runrenderloop() uses up GPU cycles. So, I am calling scene.render() wherever needed.
I am creating Mesh with VertexData(custom data). is VertexData.ApplyToMesh() is async.
When I call the applytomesh() and then render the next line, the mesh is not rendered.
Then, if I render the scene sometime later, the mesh is rendered on the screen

I am not able to reproduce in PG.

Gopinath Vellingiri

applyToMesh is not async but shader compilation is. That’s why you may not see your mesh the very first frame because it needs some time to compile.

You can use material.forceCompilation(mesh, onCompiled, onError) to force the compilation of the shader and be notified in the onComipled callback when it is ready and do a scene rendering.

Alternatively, you can also try to disable parallel shader compilation and see if that helps, by doing:

engine.getCaps().parallelShaderCompile = false;

Thanks. Let me try that.

When I rotate the mesh also I face the same issue. Is it the computation time for rotate?

The world matrices of the meshes are recomputed in the course of scene.render(), so it should work…

Try to call mesh.computeWorldMatrix() yourself to see if that helps.

1 Like