Nico Posted November 20, 2014 Share Posted November 20, 2014 Hi guys, I have been away for a long time, and I have now a little more time to play again with BabylonJS.I am using RenderPipeline, and I think there is a problem with this feature When I try to use scene.pick there is a shift (I don't know what is the best word to describe this) between my pointer positions and what the pick function returns, I have no problem if I don't use RenderPipeline (so I think the pointer positions values I am sending to the pick function are good). After some investigations I think I found something interesting, inside scene.pick BJS calls createPickingRay function, and I found this code inside :// Moving coordinates to local viewport worldx = x / this._engine.getHardwareScalingLevel() - viewport.x;y = y / this._engine.getHardwareScalingLevel() - (this._engine.getRenderHeight() - viewport.y - viewport.height);To get "y" value, it calls engine.getRenderHeight(), here is the code of this function :public getRenderHeight(): number { if (this._currentRenderTarget) { return this._currentRenderTarget._height; } return this._renderingCanvas.height;}So it is returning the height of the renderTarget if it exists, I use in the RenderPipeline so it exists in this case, but I can't use my screen size here (because of the non power of two texture size limitation in WebGL) so I manually set a 2048x2048 texture while my screen resolution is 1920x1080. If I use comment only the getRenderHeight part, I still have a shift, so the getRenderWidth is used too for the picking, but I didn't try to locate this, since using renderingCanvas width and height seems to solve the problem. These parts are causing this shift between my mouse click and the picking result, when I comment this code like that it seems to work :public getRenderWidth(): number { /*if (this._currentRenderTarget) { return this._currentRenderTarget._width; }*/ return this._renderingCanvas.width;}public getRenderHeight(): number { /*if (this._currentRenderTarget) { return this._currentRenderTarget._height; }*/ return this._renderingCanvas.height;}I don't know how to solve this problem in a clean way, but I have located the problem Does the pick function should always use the canvas width and height instead of using RenderTarget size ? So in this case a parameter can be sent through this two functions to force to return the canvas width/height instead of renderTarget ones, or should it use directly the "getRenderingCanvas" method to get the canvas, and then retrieve its width and height ? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 21, 2014 Share Posted November 21, 2014 perhaps this is a "timing" issue. When do you call your pick? It could be interesting to call it onBeforeRender for instance Quote Link to comment Share on other sites More sharing options...
Nico Posted November 21, 2014 Author Share Posted November 21, 2014 Thanks for the answer! I tried to call the pick function inside the callbacks (beforeRender, or afterRender), and the result is the same, there is always a WebGLTexture reference inside the _currentTargetRender Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 21, 2014 Share Posted November 21, 2014 can you try to create a playground repro? Quote Link to comment Share on other sites More sharing options...
Nico Posted November 24, 2014 Author Share Posted November 24, 2014 Here it is !I have to add a line to the bjs version to make the RenderPipeline works. Inside the PostProcessRenderPass constructor, the _renderList property was not setted, so I added this line :this._renderList = renderList;You will find my custom bjs version inside the attached zip. I put particles to easy show the pointer position (in the 3D world).There is no problem if the renderPipelineManager has not yet attached pipeline to camera, the mouse pointer and the particle source are at the "same position", but when I attach the camera to the pipeline, there is this shift You just have to comment the line 46 to see the difference :postProcessRenderPipelineManager.attachCamerasToRenderPipeline("standardPipeline", camera, false);I still have a WebGL warning, but I don't know where it come from INVALID_ENUM: activeTexture: texture unit out of rangePostProcesses.zip Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 24, 2014 Share Posted November 24, 2014 hello this will be really more convenient if you could create a playground repro BTW I fixed the _renderList issue for the next release:) Quote Link to comment Share on other sites More sharing options...
Nico Posted November 25, 2014 Author Share Posted November 25, 2014 Hello ! I have done a repro case using BabylonJS Playground, you can see it here : http://www.babylonjs...d.com/#2DWHRN#3 In this exemple I am not using the pick function, but the engine.getRenderHeight/Width function to show where is the problem. Since the pick function use this function too, the shift is the same in my exemple, so the particles source is the position you will get using the pick function. Edit : I have added picking on mouseup event. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 26, 2014 Share Posted November 26, 2014 Hey good job it was a bug:) I fixed the playground and will quickly publish the fix on the repo Nico 1 Quote Link to comment Share on other sites More sharing options...
Nico Posted November 27, 2014 Author Share Posted November 27, 2014 Thank you very much for the fix! GameMonetize 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.