It is easy to resize entity in a code:
self.transform = Qt3DCore.QTransform()
self.transform.setScale(1.5)
But I want to resize entity dynamically. I want that my entity enlarge when I move camera away from it or shrinks when I approach my camera. Is it possible to do this using proper shaders?
I found this link.
where is a code which I have added added to my vertex shader:
in vec3 vertexPosition;
uniform mat4 modelViewProjection;
void main()
{
float reciprScaleOnscreen = 0.005;
float w = (modelViewProjection * vec4(0.0, 0.0, 0.0, 1.0)).w;
w *= reciprScaleOnscreen;
gl_Position = modelViewProjection * vec4(vertexPosition.xyz * w , 1.0);
}
So there is no need to scale entities in a program. It is simpler to use a shader.