Rotation optimization, GPU accelerated


An experimental release, with a possible large increase in rotation performance.

TLDR; Rotation will now cost minimal CPU and animation can be paused while rotation will still work. In one case it goes from 25% of CPU to 0% CPU to rotate multiple complex models.

I moved the rotation calculations from the CPU to GPU by using changing the C3 Model/View matrix to Include the x,y,z rotation angles. The rotation calculation is now done in the C3 standard vertex shader in the GPU with no real increase in GPU performance requirement and the CPU performance for rotation is almost completely eliminated (except for the Model/View matrix calculation.)

You can now pause animation and rotation will continue to work. If animation is not required, this is recommended (I may also change animation paused to the default initialized state.)

Note that rotation with Euler angles (x,y,z) still will suffer from gimbal lock, so if possible, pre-rotate your models in a 3d modeling program (like Blender) to reduce the change of gimbal lock.

Note that animation will still continue to run on CPU and will still be somewhat expensive based on the animation rate and the number of vertices/triangles that must rotate. It's not obvious yet if the animation calculations can be done on the CPU, because in the case of skinned nodes, each vertice may have a different blended transform.)

There may be some issues with this new update in terms of the bounding box, z height, since they are not yet updated based on rotation done on the GPU, this may make the 3DObject 'clip' early. I will work on updating the bounding box and z height to match the GPU based rotation of the vertices.

Please leave feedback, if you see performance improve with rotation (w/o animation) or if you see issues in more complex C3 examples (I restore the C3 Model/View matrix, but there could be issues with changing the matrix or with the original matrix being used.)

Files

3DObject-2-21-0.c3addon 54 kB
Mar 09, 2022

Get Construct 3 3DObject Plugin

Download NowName your own price

Comments

Log in with itch.io to leave a comment.

nice!!!