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, view.m, view.m); 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...
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.