At minimum I would have a camera with rotation and world position; projections parameters such as angle of view and perspective vs. orthographic; and meshes with scale, angle, and world position.
When rendering a mesh I am wondering if I should calculate the final transformation matrix on the CPU and pass it to my shader, or if I should calculate the transformation matrix inside my shader.
Answer
There is no reason to calculate transformation matrix in shader, it would be just waste of resources, because you would need to calculate it for every vertex and that's not good idea.
If you calculate matrix in cpu, it would cost you few instructions and 16 * float size
data transfer to GPU.
If you calculate matrix in gpu, it would cost you few instructions
* vertices count
and 9 * float size
transfer to GPU - position, rotation, scale.
No comments:
Post a Comment