gamestudiohx Posted October 12, 2015 Share Posted October 12, 2015 I'm seeing a huge performance drop on mobile browsers whenever I put a skybox on my scene, even if scene is very simple. This can be seen even on BabylonJS site - Lens flares demo http://www.babylonjs.com/?48Can someone confirm this (i hope its not just me...) ?ThreeJS examples work perfectly on my devices, this one for example http://threejs.org/examples/#webgl_materials_envmaps Quote Link to comment Share on other sites More sharing options...
davrous Posted October 12, 2015 Share Posted October 12, 2015 Hello, I don't have any issue on my windows phone. Which mobile are you using? Which version of the OS and browser? Which kind if performance do you have with or without the skybox?Thanks,David Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 is it still true without lens flares? What about texture resolution? It is almost impossible that threejs run faster than us on a so simple scene So can you please share a scene where you see this issue? Quote Link to comment Share on other sites More sharing options...
gamestudiohx Posted October 12, 2015 Author Share Posted October 12, 2015 It looks like I judged too quickly... I'm actually having a problem with BablylonHx targeting android (via C++) - putting a skybox on a scene brings FPS from 60 to 4~5. So I opened both BHx and BJs lens flare example on my two android devices (4.2.1 and 4.2.2) in chrome and firefox and on one device I get 4~5FPS and on another ~10FPS. But the problem is not only in LensFlare example, all of them work really bad.However, ThreeJS examples work much better, this one http://threejs.org/examples/#webgl_materials_envmaps works on constant 60FPS. Can someone with android device check this ? I really don't get what is killing BHx (c++) version, as soon as I put a skybox GameBench is showing 99% Fragment shader load ... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 But what about the Js version of babylon? Are you sure that resolution is the same? perhaphs three.js uses render ratio to reduce the number of pixels to render? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 Is antialiasing enable on both side? is it enabled on three.js? Quote Link to comment Share on other sites More sharing options...
gamestudiohx Posted October 12, 2015 Author Share Posted October 12, 2015 I have no idea what threejs is doing but their examples are very smooth. I'm looking at their god-rays example and I have ~50fps.Antialias is disabled on both Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 99% Fragment shader load: This must come from rendering resolution then. if antialising is off, the resolution is too high Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 I saw that autoClear is turned off on threejs as well Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 Other really important point: babylon.js compensates deviceRatio to always get a smooth rendering. try just to set engine.setHardwareScalingLevel(1.0). I think this could help a lot Quote Link to comment Share on other sites More sharing options...
chg Posted October 12, 2015 Share Posted October 12, 2015 I've noticed the default shaders have a few branches to handle multiple lights/light types. It is possible that the OPs hardware is executing all the paths? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 Nope. these branches are removed during compilation. Quote Link to comment Share on other sites More sharing options...
gamestudiohx Posted October 12, 2015 Author Share Posted October 12, 2015 On BHx _hardwareScalingLevel is locked to 1 for all targets except js. Also the problem is not in rendering resolution or in resolution of skybox images (i've tried all kids of sizes). If I put a Layer as a background for my game then I have no problems - and the image can be even 2048px.It looks like CubeTexture is a performance killer for BHx ?!... This is going to be a long night for me... Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 Please keep me posted if you find something Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 (Thinking out loud): what about anisotropic? did you try setting it to 1 on your cube texture? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 Other idea!!!! this code in the shader:vec3 computeReflectionCoords(float mode, vec4 worldPos, vec3 worldNormal){ if (mode == MAP_SPHERICAL) { vec3 coords = vec3(view * vec4(worldNormal, 0.0)); return vec3(reflectionMatrix * vec4(coords, 1.0)); } else if (mode == MAP_PLANAR) { vec3 viewDir = worldPos.xyz - vEyePosition; vec3 coords = normalize(reflect(viewDir, worldNormal)); return vec3(reflectionMatrix * vec4(coords, 1)); } else if (mode == MAP_CUBIC) { vec3 viewDir = worldPos.xyz - vEyePosition; vec3 coords = reflect(viewDir, worldNormal);#ifdef INVERTCUBICMAP coords.y = 1.0 - coords.y;#endif return vec3(reflectionMatrix * vec4(coords, 0)); } else if (mode == MAP_PROJECTION) { return vec3(reflectionMatrix * (view * worldPos)); } else if (mode == MAP_SKYBOX) { return vPositionUVW; } return vec3(0, 0, 0);}uses too much "if" Let me optimize it a bit chg 1 Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 12, 2015 Share Posted October 12, 2015 I updated the shader relatively to reflection channel. Can you test with the new version?Basically I moved all reflection coordinates computation back to the vertex shader Quote Link to comment Share on other sites More sharing options...
gamestudiohx Posted October 13, 2015 Author Share Posted October 13, 2015 @deltakosh I've tried with your changes and got some improvements. Now I have ~25FPS in my game but the GPU is still on 97% (fragment load).I've also tried without "viewDir" vector (reused coords vec) and got 2-3FPS more: vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal){#ifdef REFLECTIONMAP_SPHERICALvec3 coords = vec3(view * vec4(worldNormal, 0.0)); return vec3(reflectionMatrix * vec4(coords, 1.0));#endif #ifdef REFLECTIONMAP_PLANARvec3 coords = worldPos.xyz - vEyePosition;coords = normalize(reflect(coords, worldNormal)); return vec3(reflectionMatrix * vec4(coords, 1));#endif #ifdef REFLECTIONMAP_CUBICvec3 coords = worldPos.xyz - vEyePosition;coords = reflect(coords, worldNormal);#ifdef INVERTCUBICMAPcoords.y = 1.0 - coords.y;#endifreturn vec3(reflectionMatrix * vec4(coords, 0));#endif Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 13, 2015 Share Posted October 13, 2015 Did you use the very latest version with all the computation done in the vertex shader? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 13, 2015 Share Posted October 13, 2015 And if you are using the skybox, there is no viewdir involved Quote Link to comment Share on other sites More sharing options...
gamestudiohx Posted October 13, 2015 Author Share Posted October 13, 2015 With your latest changes I got pretty big speedup - from 5 to ~25fps but still, when I remove skybox from scene I'm getting 60fps.And I was trying all kinds of reflectionTexture.coordinatesMode (Texture.CUBIC_MODE too - in this case viewdir was used I guess ?!)Anyway, its still unusable for me so I guess I'll use layer as a background image for current project. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 13, 2015 Share Posted October 13, 2015 but can you confirm that you used the vertex shader based version? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 13, 2015 Share Posted October 13, 2015 I updated the lens flare demo as well. Do you still see a major framerate drop with this demo? (Do not forget to clear your cache) Quote Link to comment Share on other sites More sharing options...
gamestudiohx Posted October 13, 2015 Author Share Posted October 13, 2015 Yes, I'm using vertex shader based version in BHx. And now I have 21-23fps in lens flare demo on babylonjs website (it was 10fps before), so there's no "major framerate drop" anymore I guess. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted October 13, 2015 Share Posted October 13, 2015 But still not 60fps The shader is super simple and I do not see where the performance is drained 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.