I am trying to create billboard using three.js. I tried using THREE.Sprite however size of sprite changes with distance as I am using perspective projection. I tried to create a plane using custom shaderMaterial with custom shader.
Shader code for scaling billboard
vec4 gl_Position = projectionMatrix * (modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(position.x, position.y, 0.0, 0.0));'
same for non scaling billboard, which I am trying implement
float distance = length(modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0));
vec4 newPosition = projectionMatrix * (modelViewMatrix * vec4(0.0, 0.0, 0.0, 1.0) + vec4(position.x, position.y, 0.0, 0.0));
gl_Position= newPosition*distance;
Unfortunately there is no changes in the output. Its still scaled billboard. Any suggestion that might fix the problem?