JulienGobin Posted January 7, 2014 Share Posted January 7, 2014 Hi everyone, First of all, happy new year and thanks for this amazing webgl engine. I noticed the view matrix of the camera is computed for each frame when BABYLON.Camera.prototype.getViewMatrix is called by BABYLON.Scene.prototype._renderForCamera (called by BABYLON.Scene.prototype.render). BABYLON.Camera.prototype.getViewMatrix is in two parts:this._computedViewMatrix = this._getViewMatrix();// BABYLON.Camera.prototype._getViewMatrix is overrided in sub-classes (ArcRotateCamera and FreeCamera compute for each frame a matrix and return it)andif (this.parent && this.parent.getWorldMatrix) { if (!this._worldMatrix) { this._worldMatrix = BABYLON.Matrix.Identity(); } this._computedViewMatrix.invertToRef(this._worldMatrix); this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._computedViewMatrix); this._computedViewMatrix.invert(); return this._computedViewMatrix; }which computes the view matrix if the camera has a parent. Is it on purpose that the view matrix is computed for each frame? Is it better for the memory? (instead of caching values like it's done for the meshes; BABYLON.Mesh.prototype.computeWorldMatrix) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 7, 2014 Share Posted January 7, 2014 This is a update I get on my to do list actually Quote Link to comment Share on other sites More sharing options...
JulienGobin Posted January 8, 2014 Author Share Posted January 8, 2014 Ok, thank for your fast reply .I'm already working on a system that makes the job. (Because i really need it), maybe i can send you a pull request when i have finished (tomorrow) ? (I'm also working on a system, based on this first one, that forces the wireframe display when the fps is shutting down when a camera is moving; of course it's optional and parametrable. Will you be interested by it ?). Here what i have done so far : http://jsfiddle.net/JulienGobin/7DT4R/http://jsfiddle.net/JulienGobin/4QhX4/ Quote Link to comment Share on other sites More sharing options...
JulienGobin Posted January 9, 2014 Author Share Posted January 9, 2014 Here it is https://github.com/BabylonJS/Babylon.js/pull/122 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2014 Share Posted January 10, 2014 Excellent and thank you for your contribution:) I have a question about wireframe mode: does it really speed things up? Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 10, 2014 Share Posted January 10, 2014 That could be nice. I guess it speeds up things when meshes have a lot of vertices but it doesn't when the scene contains only meshes will a few number of vertices (not a lot of rasterization to do I guess) Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2014 Share Posted January 10, 2014 In my case this is always worse:( Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 10, 2014 Share Posted January 10, 2014 Really? I didn't check how you do the wireframe rendering but my first thought would be that's it's faster to render in wireframe mode. Weird. Anyway, I guess what JulienGobin uses here http://jsfiddle.net/JulienGobin/4QhX4/ could be modified to use a fastest material when the camera is moving (instead of wireframe). That's kind of cool. this._scene.activeCamera.forceWireframe would be replaced by this._scene.activeCamera.forceFastestMaterial and the material would be set for the mesh in BABYLON.Mesh.prototype.render Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 10, 2014 Share Posted January 10, 2014 I prefer this way actually. Gfx cards are not really good at drawing wireframe gwenael 1 Quote Link to comment Share on other sites More sharing options...
JulienGobin Posted January 13, 2014 Author Share Posted January 13, 2014 (edited) Thank for your reply, the new pull request (without the wireframe stuff) is here : https://github.com/BabylonJS/Babylon.js/pull/126 For the wireframe stuff i'm really surprised that this display mode is worst than the normal one. I will force myself on more test next time ^^'.(Edit : wrong link, my bad) Edited January 14, 2014 by JulienGobin Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 14, 2014 Share Posted January 14, 2014 You will be in the next version (1.8.5). gg! and thanks a lot for your help Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 16, 2014 Share Posted January 16, 2014 Hey Julien, I think there is a bug with your cache: try the train demo and switch to camera attached to the train Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 16, 2014 Share Posted January 16, 2014 Ok I've fixed it gwenael 1 Quote Link to comment Share on other sites More sharing options...
gwenael Posted January 16, 2014 Share Posted January 16, 2014 Thanks. Could you commit the fix please? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 17, 2014 Share Posted January 17, 2014 it is part of the upcoming update gwenael 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.