Gaume Posted January 2, 2017 Share Posted January 2, 2017 I'm trying, using my own shader, to make a billboard using a predefined XZ plane mesh. to do so, i first build the necessary vector (into my own material) to pass to the shader, var cam = scene.activeCamera; var look = cam.position.subtract(mesh.position).normalize(); var view = scene.getViewMatrix(); var up = new BABYLON.Vector3(view.m[1], view.m[5], view.m[9]); var right = BABYLON.Vector3.Cross(up, look); this._effect.setMatrix(__world_str, world); this._effect.setMatrix(__worldViewProjection_str, world.multiply(scene.getTransformMatrix())); this._effect.setVector3(__upVector_str, up); this._effect.setVector3(__rightVector_str, right); this._effect.setVector3(__center_str, mesh.position); then use the values into the shader as : vec3 newp = center + (upVector * position.x) + (rightVector * position.z); vec4 outPosition = worldViewProjection * vec4(newp, 1.); gl_Position = outPosition; where center is the center of the billboard. I use an ArcRotateCamera. However, this is NOT render properly. The plane is ALWAYS facing the camera, which is good, BUT it strectch vertically when spining arround.. What i have missed ??? Quote Link to comment Share on other sites More sharing options...
Gaume Posted January 2, 2017 Author Share Posted January 2, 2017 Hi Guy, found the solution.. the code is correct, was a scalling not set correctly on Y into the mesh and while the scalling is apply after the tranformation (part of the world matrix), it's strech the mesh on X and Z but NOT on Y. I let the code for thus interested by the billboard shader subject. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted January 4, 2017 Share Posted January 4, 2017 Thanks 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.