# Smart Rendering Mode

**URL:** <https://forum.babylonjs.com/t/smart-rendering-mode/32848>\
**Category:** Questions\
**Created:** [August 8, 2022, 2:39pm UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848 "2022-08-08T14:39:50Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Urpgor](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/urpgor/32/17886_2.png) [@Urpgor](https://forum.babylonjs.com/u/Urpgor)\
**Post date:** [August 8, 2022, 2:39pm UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848/1 "2022-08-08T14:39:50Z")

</div>

Hi,  
I was looking into optimizing the # of render calls or CPU utilization in general. In our usecase we don’t have any animations. This means that we would need to perform any redraws only if the camera was moved or the scenegraph changed in any way (including properties of materials and meshes).

I didn’t find any way how Babylon would support smth like that out of the box. My best guess would be now to add all kinds of observables and trigger a redraw based on these callbacks. The problem I discovered so far is just that some of the callbacks are not called as they need a `scene.render()` call in the first place to be triggered.

Does anyone have a good idea how a smart rendering mode could achieved?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [August 8, 2022, 3:00pm UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848/2 "2022-08-08T15:00:04Z")

</div>

I would suggest to keep it outside the babylon code as it might be simpler to know if anything happens from the experience side.

The only problem would be related to camera interactions which I guess could be “infered” from pointer and keyboard events, @PolygonalSun ?

---

<div class="post-metadata">

**Author:** ![PolygonalSun](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/polygonalsun/32/2704_2.png) [@PolygonalSun](https://forum.babylonjs.com/u/PolygonalSun)\
**Post date:** [August 8, 2022, 10:29pm UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848/3 "2022-08-08T22:29:00Z")

</div>

So is the idea that the canvas would only frames is there’s a change to scene like camera movement? I could potentially see doing something along the lines of having some code in the `onInputChangedObservable` object to make sure that the rendering is active and setting a timeout to turn it back off once the input is processed. If there’s an active timeout when more input is received, you could just reset the timeout and that might work.

---

<div class="post-metadata">

**Author:** ![Urpgor](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/urpgor/32/17886_2.png) [@Urpgor](https://forum.babylonjs.com/u/Urpgor)\
**Post date:** [August 9, 2022, 7:24am UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848/4 "2022-08-09T07:24:47Z")

</div>

Camera movement alone is obviously not enough. The following cases come to my mind:

- active camera is changed
- active camera extrinsics or intrinsics change
- mesh added to the scene
- mesh removed from the scene
- mesh attributes are updated
- mesh material is changed
- any uniforms or textures of an active material changes

I’d say these are the usual updates that typically happen. If one needs postprocessing effects then these have to be taken into account as well. We are porting parts of our own C++ render engine to the web and use BabylonJS for that and I was quite surprised that there is no smart render mode.  
Do you think that could be interesting for you?

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [August 9, 2022, 2:03pm UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848/5 "2022-08-09T14:03:20Z")

</div>

Yes it would be nice to have as long as it does not impact for the performances of the general case which is always a hard balance to find.

---

<div class="post-metadata">

**Author:** ![dennemark](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dennemark/32/10745_2.png) [@dennemark](https://forum.babylonjs.com/u/dennemark)\
**Post date:** [October 6, 2022, 8:10am UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848/6 "2022-10-06T08:10:51Z")

</div>

This thread shows how to render on camera changed: [What is the correct way to render on demand - #28 by vimcaw](https://forum.babylonjs.com/t/what-is-the-correct-way-to-render-on-demand/17256/28)

But I agree, it would be interesting to be able to track other options, too.

scene has many observables, but I am not sure, if we can track change of attributes. My work around is rather to render only every x frames, which reduces gpu consumptions already by a lot! However, I am unable to track, if there are active animations. Is there a way to figure this out?  
I have used `scene.onBeforeAnimationsObservable` but it triggers always. And when I check objects such as the animated object or scene, they do not seem to store information on i.e. `scene.animations`. Anyway to track if animations are active?

> **[Babylon.js Playground](https://www.babylonjs-playground.com/#9WUJN%231986)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

---

<div class="post-metadata">

**Author:** ![dennemark](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/dennemark/32/10745_2.png) [@dennemark](https://forum.babylonjs.com/u/dennemark)\
**Post date:** [October 6, 2022, 8:32am UTC](https://forum.babylonjs.com/t/smart-rendering-mode/32848/7 "2022-10-06T08:32:03Z")

</div>

found a way 🙂 [https://www.babylonjs-playground.com/#9WUJN#1986](https://www.babylonjs-playground.com/#9WUJN#1986)  
`scene.animatables` is the right place to search for
